rivet-design 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts +7 -4
- package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.js +67 -36
- package/dist/mcp/agent-variants/WorktreeOrchestrator.js.map +1 -1
- package/dist/mcp/agent-variants/generatedDestination.d.ts +2 -2
- package/dist/mcp/agent-variants/generatedDestination.d.ts.map +1 -1
- package/dist/mcp/agent-variants/generatedDestination.js +5 -6
- package/dist/mcp/agent-variants/generatedDestination.js.map +1 -1
- package/dist/mcp/agent-variants/tools.d.ts.map +1 -1
- package/dist/mcp/agent-variants/tools.js +4 -6
- package/dist/mcp/agent-variants/tools.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +6 -12
- package/dist/mcp/server.js.map +1 -1
- package/dist/routes/agentVariants.d.ts.map +1 -1
- package/dist/routes/agentVariants.js +1 -0
- package/dist/routes/agentVariants.js.map +1 -1
- package/dist/routes/mcp.d.ts.map +1 -1
- package/dist/routes/mcp.js +4 -5
- package/dist/routes/mcp.js.map +1 -1
- package/package.json +1 -1
- package/src/ui/dist/assets/{main-Dwk5LfCC.js → main-DjQJnXS8.js} +4 -4
- package/src/ui/dist/index.html +1 -1
|
@@ -67,7 +67,7 @@ function useAtomValueWithDelay<Value>(
|
|
|
67
67
|
${I}px !important;
|
|
68
68
|
${P}px !important;
|
|
69
69
|
}
|
|
70
|
-
`),()=>{var R;(R=a.current)==null||R.removeAttribute("data-motion-pop-id"),S.contains(M)&&S.removeChild(M)}},[t]),y.jsx(FX,{isPresent:t,childRef:a,sizeRef:c,pop:s,children:s===!1?e:f.cloneElement(e,{ref:p})})}const VX=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:s,mode:o,anchorX:a,anchorY:c,root:u})=>{const h=B1(HX),p=f.useId();let m=!0,g=f.useMemo(()=>(m=!1,{id:p,initial:t,isPresent:n,custom:i,onExitComplete:b=>{h.set(b,!0);for(const x of h.values())if(!x)return;r&&r()},register:b=>(h.set(b,!1),()=>h.delete(b))}),[n,h,r]);return s&&m&&(g={...g}),f.useMemo(()=>{h.forEach((b,x)=>h.set(x,!1))},[n]),f.useEffect(()=>{!n&&!h.size&&r&&r()},[n]),e=y.jsx(OX,{pop:o==="popLayout",isPresent:n,anchorX:a,anchorY:c,root:u,children:e}),y.jsx(z1.Provider,{value:g,children:e})};function HX(){return new Map}function qR(e=!0){const t=f.useContext(z1);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=t,s=f.useId();f.useEffect(()=>{if(e)return i(s)},[e]);const o=f.useCallback(()=>e&&r&&r(s),[s,r,e]);return!n&&r?[!1,o]:[!0]}const am=e=>e.key||"";function P_(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const ds=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:s="sync",propagate:o=!1,anchorX:a="left",anchorY:c="top",root:u})=>{const[h,p]=qR(o),m=f.useMemo(()=>P_(e),[e]),g=o&&!h?[]:m.map(am),b=f.useRef(!0),x=f.useRef(m),C=B1(()=>new Map),w=f.useRef(new Set),[E,_]=f.useState(m),[T,I]=f.useState(m);u8(()=>{b.current=!1,x.current=m;for(let S=0;S<T.length;S++){const R=am(T[S]);g.includes(R)?(C.delete(R),w.current.delete(R)):C.get(R)!==!0&&C.set(R,!1)}},[T,g.length,g.join("-")]);const P=[];if(m!==E){let S=[...m];for(let R=0;R<T.length;R++){const $=T[R],L=am($);g.includes(L)||(S.splice(R,0,$),P.push($))}return s==="wait"&&P.length&&(S=P),I(P_(S)),_(m),null}const{forceRender:M}=f.useContext(c8);return y.jsx(y.Fragment,{children:T.map(S=>{const R=am(S),$=o&&!h?!1:m===T||g.includes(R),L=()=>{if(w.current.has(R))return;if(C.has(R))w.current.add(R),C.set(R,!0);else return;let j=!0;C.forEach(O=>{O||(j=!1)}),j&&(M==null||M(),I(x.current),o&&(p==null||p()),r&&r())};return y.jsx(VX,{isPresent:$,initial:!b.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:s,root:u,onExitComplete:$?void 0:L,anchorX:a,anchorY:c,children:S},R)})})},KR=f.createContext({strict:!1}),I_={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let M_=!1;function BX(){if(M_)return;const e={};for(const t in I_)e[t]={isEnabled:n=>I_[t].some(r=>!!n[r])};ER(e),M_=!0}function YR(){return BX(),_Y()}function zX(e){const t=YR();for(const n in e)t[n]={...t[n],...e[n]};ER(t)}const UX=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function n1(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||UX.has(e)}let XR=e=>!n1(e);function ZX(e){typeof e=="function"&&(XR=t=>t.startsWith("on")?!n1(t):e(t))}try{ZX(require("@emotion/is-prop-valid").default)}catch{}function WX(e,t,n){const r={};for(const i in e)i==="values"&&typeof e.values=="object"||Cr(e[i])||(XR(i)||n===!0&&n1(i)||!t&&!n1(i)||e.draggable&&i.startsWith("onDrag"))&&(r[i]=e[i]);return r}const G1=f.createContext({});function GX(e,t){if(W1(e)){const{initial:n,animate:r}=e;return{initial:n===!1||Zh(n)?n:void 0,animate:Zh(r)?r:void 0}}return e.inherit!==!1?t:{}}function qX(e){const{initial:t,animate:n}=GX(e,f.useContext(G1));return f.useMemo(()=>({initial:t,animate:n}),[R_(t),R_(n)])}function R_(e){return Array.isArray(e)?e.join(" "):e}const L8=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function QR(e,t,n){for(const r in t)!Cr(t[r])&&!MR(r,n)&&(e[r]=t[r])}function KX({transformTemplate:e},t){return f.useMemo(()=>{const n=L8();return $8(n,t,e),Object.assign({},n.vars,n.style)},[t])}function YX(e,t){const n=e.style||{},r={};return QR(r,n,e),Object.assign(r,KX(e,t)),r}function XX(e,t){const n={},r=YX(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const JR=()=>({...L8(),attrs:{}});function QX(e,t,n,r){const i=f.useMemo(()=>{const s=JR();return RR(s,t,DR(r),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};QR(s,e.style,e),i.style={...s,...i.style}}return i}const JX=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function j8(e){return typeof e!="string"||e.includes("-")?!1:!!(JX.indexOf(e)>-1||/[A-Z]/u.test(e))}function eQ(e,t,n,{latestValues:r},i,s=!1,o){const c=(o??j8(e)?QX:XX)(t,r,i,e),u=WX(t,typeof e=="string",s),h=e!==f.Fragment?{...u,...c,ref:n}:{},{children:p}=t,m=f.useMemo(()=>Cr(p)?p.get():p,[p]);return f.createElement(e,{...h,children:m})}function tQ({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:nQ(n,r,i,e),renderState:t()}}function nQ(e,t,n,r){const i={},s=r(e,{});for(const m in s)i[m]=ig(s[m]);let{initial:o,animate:a}=e;const c=W1(e),u=kR(e);t&&u&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),a===void 0&&(a=t.animate));let h=n?n.initial===!1:!1;h=h||o===!1;const p=h?a:o;if(p&&typeof p!="boolean"&&!Z1(p)){const m=Array.isArray(p)?p:[p];for(let g=0;g<m.length;g++){const b=S8(e,m[g]);if(b){const{transitionEnd:x,transition:C,...w}=b;for(const E in w){let _=w[E];if(Array.isArray(_)){const T=h?_.length-1:0;_=_[T]}_!==null&&(i[E]=_)}for(const E in x)i[E]=x[E]}}}return i}const e$=e=>(t,n)=>{const r=f.useContext(G1),i=f.useContext(z1),s=()=>tQ(e,t,r,i);return n?s():B1(s)},rQ=e$({scrapeMotionValuesFromProps:D8,createRenderState:L8}),iQ=e$({scrapeMotionValuesFromProps:NR,createRenderState:JR}),sQ=Symbol.for("motionComponentSymbol");function oQ(e,t,n){const r=f.useRef(n);f.useInsertionEffect(()=>{r.current=n});const i=f.useRef(null);return f.useCallback(s=>{var a;s&&((a=e.onMount)==null||a.call(e,s)),t&&(s?t.mount(s):t.unmount());const o=r.current;if(typeof o=="function")if(s){const c=o(s);typeof c=="function"&&(i.current=c)}else i.current?(i.current(),i.current=null):o(s);else o&&(o.current=s)},[t])}const t$=f.createContext({});function Cu(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function aQ(e,t,n,r,i,s){var _,T;const{visualElement:o}=f.useContext(G1),a=f.useContext(KR),c=f.useContext(z1),u=f.useContext(N8),h=u.reducedMotion,p=u.skipAnimations,m=f.useRef(null),g=f.useRef(!1);r=r||a.renderer,!m.current&&r&&(m.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:h,skipAnimations:p,isSVG:s}),g.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const b=m.current,x=f.useContext(t$);b&&!b.projection&&i&&(b.type==="html"||b.type==="svg")&&lQ(m.current,n,i,x);const C=f.useRef(!1);f.useInsertionEffect(()=>{b&&C.current&&b.update(n,c)});const w=n[cR],E=f.useRef(!!w&&typeof window<"u"&&!((_=window.MotionHandoffIsComplete)!=null&&_.call(window,w))&&((T=window.MotionHasOptimisedAnimation)==null?void 0:T.call(window,w)));return u8(()=>{g.current=!0,b&&(C.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),E.current&&b.animationState&&b.animationState.animateChanges())}),f.useEffect(()=>{b&&(!E.current&&b.animationState&&b.animationState.animateChanges(),E.current&&(queueMicrotask(()=>{var I;(I=window.MotionHandoffMarkAsComplete)==null||I.call(window,w)}),E.current=!1),b.enteringChildren=void 0)}),b}function lQ(e,t,n,r){const{layoutId:i,layout:s,drag:o,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutAnchor:h,layoutCrossfade:p}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:n$(e.parent)),e.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&Cu(a),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,crossfade:p,layoutScroll:c,layoutRoot:u,layoutAnchor:h})}function n$(e){if(e)return e.options.allowProjection!==!1?e.projection:n$(e.parent)}function mb(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&zX(r);const s=n?n==="svg":j8(e),o=s?iQ:rQ;function a(u,h){let p;const m={...f.useContext(N8),...u,layoutId:cQ(u)},{isStatic:g}=m,b=qX(u),x=o(u,g);if(!g&&typeof window<"u"){uQ();const C=dQ(m);p=C.MeasureLayout,b.visualElement=aQ(e,x,m,i,C.ProjectionNode,s)}return y.jsxs(G1.Provider,{value:b,children:[p&&b.visualElement?y.jsx(p,{visualElement:b.visualElement,...m}):null,eQ(e,u,oQ(x,b.visualElement,h),x,g,t,s)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=f.forwardRef(a);return c[sQ]=e,c}function cQ({layoutId:e}){const t=f.useContext(c8).id;return t&&e!==void 0?t+"-"+e:e}function uQ(e,t){f.useContext(KR).strict}function dQ(e){const t=YR(),{drag:n,layout:r}=t;if(!n&&!r)return{};const i={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function fQ(e,t){if(typeof Proxy>"u")return mb;const n=new Map,r=(s,o)=>mb(s,o,e,t),i=(s,o)=>r(s,o);return new Proxy(i,{get:(s,o)=>o==="create"?r:(n.has(o)||n.set(o,mb(o,void 0,e,t)),n.get(o))})}const hQ=(e,t)=>t.isSVG??j8(e)?new zY(t):new jY(t,{allowProjection:e!==f.Fragment});class pQ extends nl{constructor(t){super(t),t.animationState||(t.animationState=qY(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Z1(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let mQ=0;class gQ extends nl{constructor(){super(...arguments),this.id=mQ++,this.isExitComplete=!1}update(){var s;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;if(t&&r===!1){if(this.isExitComplete){const{initial:o,custom:a}=this.node.getProps();if(typeof o=="string"||typeof o=="object"&&o!==null&&!Array.isArray(o)){const c=oc(this.node,o,a);if(c){const{transition:u,transitionEnd:h,...p}=c;for(const m in p)(s=this.node.getValue(m))==null||s.jump(p[m])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const vQ={animation:{Feature:pQ},exit:{Feature:gQ}};function xp(e){return{point:{x:e.pageX,y:e.pageY}}}const yQ=e=>t=>P8(t)&&e(t,xp(t));function Sh(e,t,n,r){return Wh(e,t,yQ(n),r)}const r$=({current:e})=>e?e.ownerDocument.defaultView:null,$_=(e,t)=>Math.abs(e-t);function bQ(e,t){const n=$_(e.x,t.x),r=$_(e.y,t.y);return Math.sqrt(n**2+r**2)}const D_=new Set(["auto","scroll"]);class i${constructor(t,n,{transformPagePoint:r,contextWindow:i=window,dragSnapToOrigin:s=!1,distanceThreshold:o=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=g=>{this.handleScroll(g.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=lm(this.lastRawMoveEventInfo,this.transformPagePoint));const g=gb(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,x=bQ(g.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!x)return;const{point:C}=g,{timestamp:w}=br;this.history.push({...C,timestamp:w});const{onStart:E,onMove:_}=this.handlers;b||(E&&E(this.lastMoveEvent,g),this.startEvent=this.lastMoveEvent),_&&_(this.lastMoveEvent,g)},this.handlePointerMove=(g,b)=>{this.lastMoveEvent=g,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=lm(b,this.transformPagePoint),vn.update(this.updatePoint,!0)},this.handlePointerUp=(g,b)=>{this.end();const{onEnd:x,onSessionEnd:C,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=gb(g.type==="pointercancel"?this.lastMoveEventInfo:lm(b,this.transformPagePoint),this.history);this.startEvent&&x&&x(g,E),C&&C(g,E)},!P8(t))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=o,this.contextWindow=i||window;const c=xp(t),u=lm(c,this.transformPagePoint),{point:h}=u,{timestamp:p}=br;this.history=[{...h,timestamp:p}];const{onSessionStart:m}=n;m&&m(t,gb(u,this.history)),this.removeListeners=vp(Sh(this.contextWindow,"pointermove",this.handlePointerMove),Sh(this.contextWindow,"pointerup",this.handlePointerUp),Sh(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(D_.has(r.overflowX)||D_.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,i=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},s={x:i.x-n.x,y:i.y-n.y};s.x===0&&s.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(t,i),vn.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Wa(this.updatePoint)}}function lm(e,t){return t?{point:t(e.point)}:e}function N_(e,t){return{x:e.x-t.x,y:e.y-t.y}}function gb({point:e},t){return{point:e,delta:N_(e,s$(t)),offset:N_(e,xQ(t)),velocity:wQ(t,.1)}}function xQ(e){return e[0]}function s$(e){return e[e.length-1]}function wQ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=s$(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Si(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Si(t)*2&&(r=e[1]);const s=Vi(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};const o={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function kQ(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?gn(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?gn(n,e,r.max):Math.min(e,n)),e}function L_(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function CQ(e,{top:t,left:n,bottom:r,right:i}){return{x:L_(e.x,n,i),y:L_(e.y,t,r)}}function j_(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function EQ(e,t){return{x:j_(e.x,t.x),y:j_(e.y,t.y)}}function SQ(e,t){let n=.5;const r=Br(e),i=Br(t);return i>r?n=zh(t.min,t.max-r,e.min):r>i&&(n=zh(e.min,e.max-i,t.min)),Xs(0,1,n)}function _Q(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const lw=.35;function AQ(e=lw){return e===!1?e=0:e===!0&&(e=lw),{x:F_(e,"left","right"),y:F_(e,"top","bottom")}}function F_(e,t,n){return{min:O_(e,t),max:O_(e,n)}}function O_(e,t){return typeof e=="number"?e:e[t]||0}const TQ=new WeakMap;class PQ{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ir(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const s=p=>{n&&this.snapToCursor(xp(p).point),this.stopAnimation()},o=(p,m)=>{const{drag:g,dragPropagation:b,onDragStart:x}=this.getProps();if(g&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=nY(g),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ns(w=>{let E=this.getAxisMotionValue(w).get()||0;if(Gs.test(E)){const{projection:_}=this.visualElement;if(_&&_.layout){const T=_.layout.layoutBox[w];T&&(E=Br(T)*(parseFloat(E)/100))}}this.originPoint[w]=E}),x&&vn.update(()=>x(p,m),!1,!0),Q4(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},a=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m;const{dragPropagation:g,dragDirectionLock:b,onDirectionLock:x,onDrag:C}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:w}=m;if(b&&this.currentDirection===null){this.currentDirection=MQ(w),this.currentDirection!==null&&x&&x(this.currentDirection);return}this.updateAxis("x",m.point,w),this.updateAxis("y",m.point,w),this.visualElement.render(),C&&vn.update(()=>C(p,m),!1,!0)},c=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m,this.stop(p,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new i$(t,{onSessionStart:s,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:r,contextWindow:r$(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,i=n||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!i||!r)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&vn.postRender(()=>a(r,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:i}=this.getProps();if(!r||!cm(t,i,this.currentDirection))return;const s=this.getAxisMotionValue(t);let o=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(o=kQ(o,this.constraints[t],this.elastic[t])),s.set(o)}resolveConstraints(){var s;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)==null?void 0:s.layout,i=this.constraints;t&&Cu(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=CQ(r.layoutBox,t):this.constraints=!1,this.elastic=AQ(n),i!==this.constraints&&!Cu(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&Ns(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=_Q(r.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Cu(t))return!1;const r=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;i.root&&(i.root.scroll=void 0,i.root.updateScroll());const s=MY(r,i.root,this.visualElement.getTransformPagePoint());let o=EQ(i.layout.layoutBox,s);if(n){const a=n(TY(o));this.hasMutatedConstraints=!!a,a&&(o=_R(a))}return o}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=Ns(h=>{if(!cm(h,n,this.currentDirection))return;let p=c&&c[h]||{};(o===!0||o===h)&&(p={min:0,max:0});const m=i?200:1e6,g=i?40:1e7,b={type:"inertia",velocity:r?t[h]:0,bounceStiffness:m,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...s,...p};return this.startAxisValueAnimation(h,b)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return Q4(this.visualElement,t),r.start(E8(t,r,0,n,this.visualElement,!1))}stopAnimation(){Ns(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps()[n];return i||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){Ns(n=>{const{drag:r}=this.getProps();if(!cm(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n],c=s.get()||0;s.set(t[n]-gn(o,a,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Cu(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Ns(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();i[o]=SQ({min:c,max:c},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),Ns(o=>{if(!cm(o,t,null))return;const a=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];a.set(gn(c,u,i[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;TQ.set(this.visualElement,this);const t=this.visualElement.current,n=Sh(t,"pointerdown",u=>{const{drag:h,dragListener:p=!0}=this.getProps(),m=u.target,g=m!==t&&lY(m);h&&p&&!g&&this.start(u)});let r;const i=()=>{const{dragConstraints:u}=this.getProps();Cu(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),r||(r=IQ(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,o=s.addEventListener("measure",i);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),vn.read(i);const a=Wh(window,"resize",()=>this.scalePositionWithinConstraints()),c=s.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:h})=>{this.isDragging&&h&&(Ns(p=>{const m=this.getAxisMotionValue(p);m&&(this.originPoint[p]+=u[p].translate,m.set(m.get()+u[p].translate))}),this.visualElement.render())}));return()=>{a(),n(),o(),c&&c(),r&&r()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:o=lw,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function V_(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function IQ(e,t,n){const r=GS(e,V_(n)),i=GS(t,V_(n));return()=>{r(),i()}}function cm(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function MQ(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class RQ extends nl{constructor(t){super(t),this.removeGroupControls=zi,this.removeListeners=zi,this.controls=new PQ(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||zi}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const vb=e=>(t,n)=>{e&&vn.update(()=>e(t,n),!1,!0)};class $Q extends nl{constructor(){super(...arguments),this.removePointerDownListener=zi}onPointerDown(t){this.session=new i$(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:r$(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:vb(t),onStart:vb(n),onMove:vb(r),onEnd:(s,o)=>{delete this.session,i&&vn.postRender(()=>i(s,o))}}}mount(){this.removePointerDownListener=Sh(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let yb=!1;class DQ extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=t;s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),yb&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),sg.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,{projection:o}=r;return o&&(o.isPresent=s,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),yb=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==s?o.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?o.promote():o.relegate()||vn.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:r}=t;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),T8.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=t;yb=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function o$(e){const[t,n]=qR(),r=f.useContext(c8);return y.jsx(DQ,{...e,layoutGroup:r,switchLayoutGroup:f.useContext(t$),isPresent:t,safeToRemove:n})}const NQ={pan:{Feature:$Q},drag:{Feature:RQ,ProjectionNode:GR,MeasureLayout:o$}};function H_(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,s=r[i];s&&vn.postRender(()=>s(t,xp(t)))}class LQ extends nl{mount(){const{current:t}=this.node;t&&(this.unmount=iY(t,(n,r)=>(H_(this.node,r,"Start"),i=>H_(this.node,i,"End"))))}unmount(){}}class jQ extends nl{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=vp(Wh(this.node.current,"focus",()=>this.onFocus()),Wh(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function B_(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),s=r[i];s&&vn.postRender(()=>s(t,xp(t)))}class FQ extends nl{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=uY(t,(i,s)=>(B_(this.node,s,"Start"),(o,{success:a})=>B_(this.node,o,a?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const cw=new WeakMap,bb=new WeakMap,OQ=e=>{const t=cw.get(e.target);t&&t(e)},VQ=e=>{e.forEach(OQ)};function HQ({root:e,...t}){const n=e||document;bb.has(n)||bb.set(n,{});const r=bb.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(VQ,{root:e,...t})),r[i]}function BQ(e,t,n){const r=HQ(t);return cw.set(e,n),r.observe(e),()=>{cw.delete(e),r.unobserve(e)}}const zQ={some:0,all:1};class UQ extends nl{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var c;(c=this.stopObserver)==null||c.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:s}=t,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:zQ[i]},a=u=>{const{isIntersecting:h}=u;if(this.isInView===h||(this.isInView=h,s&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:p,onViewportLeave:m}=this.node.getProps(),g=h?p:m;g&&g(u)};this.stopObserver=BQ(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(ZQ(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function ZQ({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const WQ={inView:{Feature:UQ},tap:{Feature:FQ},focus:{Feature:jQ},hover:{Feature:LQ}},GQ={layout:{ProjectionNode:GR,MeasureLayout:o$}},qQ={...vQ,...WQ,...NQ,...GQ},dn=fQ(qQ,hQ);function KQ(e){e.values.forEach(t=>t.stop())}function uw(e,t){[...t].reverse().forEach(r=>{const i=e.getVariant(r);i&&_8(e,i),e.variantChildren&&e.variantChildren.forEach(s=>{uw(s,t)})})}function YQ(e,t){if(Array.isArray(t))return uw(e,t);if(typeof t=="string")return uw(e,[t]);_8(e,t)}function XQ(){const e=new Set,t={subscribe(n){return e.add(n),()=>void e.delete(n)},start(n,r){const i=[];return e.forEach(s=>{i.push(fR(s,n,{transitionOverride:r}))}),Promise.all(i)},set(n){return e.forEach(r=>{YQ(r,n)})},stop(){e.forEach(n=>{KQ(n)})},mount(){return()=>{t.stop()}}};return t}function QQ(){const e=B1(XQ);return u8(e.mount,[]),e}var kc=EI();const JQ=xc(kc);function eJ(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const tJ=e=>{switch(e){case"success":return iJ;case"info":return oJ;case"warning":return sJ;case"error":return aJ;default:return null}},nJ=Array(12).fill(0),rJ=({visible:e,className:t})=>xe.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},xe.createElement("div",{className:"sonner-spinner"},nJ.map((n,r)=>xe.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),iJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xe.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),sJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},xe.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),oJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xe.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),aJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xe.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),lJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},xe.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),xe.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),cJ=()=>{const[e,t]=xe.useState(document.hidden);return xe.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let dw=1;class uJ{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...i}=t,s=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:dw++,o=this.toasts.find(c=>c.id===s),a=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),o?this.toasts=this.toasts.map(c=>c.id===s?(this.publish({...c,...t,id:s,title:r}),{...c,...t,id:s,dismissible:a,title:r}):c):this.addToast({title:r,...i,dismissible:a,id:s}),s},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(t instanceof Function?t():t);let s=r!==void 0,o;const a=i.then(async u=>{if(o=["resolve",u],xe.isValidElement(u))s=!1,this.create({id:r,type:"default",message:u});else if(fJ(u)&&!u.ok){s=!1;const p=typeof n.error=="function"?await n.error(`HTTP error! status: ${u.status}`):n.error,m=typeof n.description=="function"?await n.description(`HTTP error! status: ${u.status}`):n.description,b=typeof p=="object"&&!xe.isValidElement(p)?p:{message:p};this.create({id:r,type:"error",description:m,...b})}else if(u instanceof Error){s=!1;const p=typeof n.error=="function"?await n.error(u):n.error,m=typeof n.description=="function"?await n.description(u):n.description,b=typeof p=="object"&&!xe.isValidElement(p)?p:{message:p};this.create({id:r,type:"error",description:m,...b})}else if(n.success!==void 0){s=!1;const p=typeof n.success=="function"?await n.success(u):n.success,m=typeof n.description=="function"?await n.description(u):n.description,b=typeof p=="object"&&!xe.isValidElement(p)?p:{message:p};this.create({id:r,type:"success",description:m,...b})}}).catch(async u=>{if(o=["reject",u],n.error!==void 0){s=!1;const h=typeof n.error=="function"?await n.error(u):n.error,p=typeof n.description=="function"?await n.description(u):n.description,g=typeof h=="object"&&!xe.isValidElement(h)?h:{message:h};this.create({id:r,type:"error",description:p,...g})}}).finally(()=>{s&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),c=()=>new Promise((u,h)=>a.then(()=>o[0]==="reject"?h(o[1]):u(o[1])).catch(h));return typeof r!="string"&&typeof r!="number"?{unwrap:c}:Object.assign(r,{unwrap:c})},this.custom=(t,n)=>{const r=(n==null?void 0:n.id)||dw++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const ei=new uJ,dJ=(e,t)=>{const n=(t==null?void 0:t.id)||dw++;return ei.addToast({title:e,...t,id:n}),n},fJ=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",hJ=dJ,pJ=()=>ei.toasts,mJ=()=>ei.getActiveToasts(),lt=Object.assign(hJ,{success:ei.success,info:ei.info,warning:ei.warning,error:ei.error,custom:ei.custom,message:ei.message,promise:ei.promise,dismiss:ei.dismiss,loading:ei.loading},{getHistory:pJ,getToasts:mJ});eJ("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function um(e){return e.label!==void 0}const gJ=3,vJ="24px",yJ="16px",z_=4e3,bJ=356,xJ=14,wJ=45,kJ=200;function Ms(...e){return e.filter(Boolean).join(" ")}function CJ(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const EJ=e=>{var t,n,r,i,s,o,a,c,u;const{invert:h,toast:p,unstyled:m,interacting:g,setHeights:b,visibleToasts:x,heights:C,index:w,toasts:E,expanded:_,removeToast:T,defaultRichColors:I,closeButton:P,style:M,cancelButtonStyle:S,actionButtonStyle:R,className:$="",descriptionClassName:L="",duration:j,position:O,gap:H,expandByDefault:B,classNames:Z,icons:K,closeButtonAriaLabel:q="Close toast"}=e,[te,F]=xe.useState(null),[V,W]=xe.useState(null),[N,z]=xe.useState(!1),[Q,J]=xe.useState(!1),[re,G]=xe.useState(!1),[X,de]=xe.useState(!1),[ve,we]=xe.useState(!1),[je,Ae]=xe.useState(0),[Le,tt]=xe.useState(0),vt=xe.useRef(p.duration||j||z_),Je=xe.useRef(null),ye=xe.useRef(null),Ke=w===0,Dt=w+1<=x,Mt=p.type,jt=p.dismissible!==!1,bn=p.className||"",nn=p.descriptionClassName||"",he=xe.useMemo(()=>C.findIndex(Ze=>Ze.toastId===p.id)||0,[C,p.id]),be=xe.useMemo(()=>{var Ze;return(Ze=p.closeButton)!=null?Ze:P},[p.closeButton,P]),Ue=xe.useMemo(()=>p.duration||j||z_,[p.duration,j]),ot=xe.useRef(0),at=xe.useRef(0),Ht=xe.useRef(0),Ut=xe.useRef(null),[ee,Y]=O.split("-"),se=xe.useMemo(()=>C.reduce((Ze,wt,De)=>De>=he?Ze:Ze+wt.height,0),[C,he]),ce=cJ(),le=p.invert||h,ge=Mt==="loading";at.current=xe.useMemo(()=>he*H+se,[he,se]),xe.useEffect(()=>{vt.current=Ue},[Ue]),xe.useEffect(()=>{z(!0)},[]),xe.useEffect(()=>{const Ze=ye.current;if(Ze){const wt=Ze.getBoundingClientRect().height;return tt(wt),b(De=>[{toastId:p.id,height:wt,position:p.position},...De]),()=>b(De=>De.filter(Nt=>Nt.toastId!==p.id))}},[b,p.id]),xe.useLayoutEffect(()=>{if(!N)return;const Ze=ye.current,wt=Ze.style.height;Ze.style.height="auto";const De=Ze.getBoundingClientRect().height;Ze.style.height=wt,tt(De),b(Nt=>Nt.find(Tt=>Tt.toastId===p.id)?Nt.map(Tt=>Tt.toastId===p.id?{...Tt,height:De}:Tt):[{toastId:p.id,height:De,position:p.position},...Nt])},[N,p.title,p.description,b,p.id,p.jsx,p.action,p.cancel]);const ke=xe.useCallback(()=>{J(!0),Ae(at.current),b(Ze=>Ze.filter(wt=>wt.toastId!==p.id)),setTimeout(()=>{T(p)},kJ)},[p,T,b,at]);xe.useEffect(()=>{if(p.promise&&Mt==="loading"||p.duration===1/0||p.type==="loading")return;let Ze;return _||g||ce?(()=>{if(Ht.current<ot.current){const Nt=new Date().getTime()-ot.current;vt.current=vt.current-Nt}Ht.current=new Date().getTime()})():(()=>{vt.current!==1/0&&(ot.current=new Date().getTime(),Ze=setTimeout(()=>{p.onAutoClose==null||p.onAutoClose.call(p,p),ke()},vt.current))})(),()=>clearTimeout(Ze)},[_,g,p,Mt,ce,ke]),xe.useEffect(()=>{p.delete&&(ke(),p.onDismiss==null||p.onDismiss.call(p,p))},[ke,p.delete]);function $e(){var Ze;if(K!=null&&K.loading){var wt;return xe.createElement("div",{className:Ms(Z==null?void 0:Z.loader,p==null||(wt=p.classNames)==null?void 0:wt.loader,"sonner-loader"),"data-visible":Mt==="loading"},K.loading)}return xe.createElement(rJ,{className:Ms(Z==null?void 0:Z.loader,p==null||(Ze=p.classNames)==null?void 0:Ze.loader),visible:Mt==="loading"})}const ct=p.icon||(K==null?void 0:K[Mt])||tJ(Mt);var rt,Jt;return xe.createElement("li",{tabIndex:0,ref:ye,className:Ms($,bn,Z==null?void 0:Z.toast,p==null||(t=p.classNames)==null?void 0:t.toast,Z==null?void 0:Z.default,Z==null?void 0:Z[Mt],p==null||(n=p.classNames)==null?void 0:n[Mt]),"data-sonner-toast":"","data-rich-colors":(rt=p.richColors)!=null?rt:I,"data-styled":!(p.jsx||p.unstyled||m),"data-mounted":N,"data-promise":!!p.promise,"data-swiped":ve,"data-removed":Q,"data-visible":Dt,"data-y-position":ee,"data-x-position":Y,"data-index":w,"data-front":Ke,"data-swiping":re,"data-dismissible":jt,"data-type":Mt,"data-invert":le,"data-swipe-out":X,"data-swipe-direction":V,"data-expanded":!!(_||B&&N),"data-testid":p.testId,style:{"--index":w,"--toasts-before":w,"--z-index":E.length-w,"--offset":`${Q?je:at.current}px`,"--initial-height":B?"auto":`${Le}px`,...M,...p.style},onDragEnd:()=>{G(!1),F(null),Ut.current=null},onPointerDown:Ze=>{Ze.button!==2&&(ge||!jt||(Je.current=new Date,Ae(at.current),Ze.target.setPointerCapture(Ze.pointerId),Ze.target.tagName!=="BUTTON"&&(G(!0),Ut.current={x:Ze.clientX,y:Ze.clientY})))},onPointerUp:()=>{var Ze,wt,De;if(X||!jt)return;Ut.current=null;const Nt=Number(((Ze=ye.current)==null?void 0:Ze.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),At=Number(((wt=ye.current)==null?void 0:wt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Tt=new Date().getTime()-((De=Je.current)==null?void 0:De.getTime()),on=te==="x"?Nt:At,Qn=Math.abs(on)/Tt;if(Math.abs(on)>=wJ||Qn>.11){Ae(at.current),p.onDismiss==null||p.onDismiss.call(p,p),W(te==="x"?Nt>0?"right":"left":At>0?"down":"up"),ke(),de(!0);return}else{var Vn,Jn;(Vn=ye.current)==null||Vn.style.setProperty("--swipe-amount-x","0px"),(Jn=ye.current)==null||Jn.style.setProperty("--swipe-amount-y","0px")}we(!1),G(!1),F(null)},onPointerMove:Ze=>{var wt,De,Nt;if(!Ut.current||!jt||((wt=window.getSelection())==null?void 0:wt.toString().length)>0)return;const Tt=Ze.clientY-Ut.current.y,on=Ze.clientX-Ut.current.x;var Qn;const Vn=(Qn=e.swipeDirections)!=null?Qn:CJ(O);!te&&(Math.abs(on)>1||Math.abs(Tt)>1)&&F(Math.abs(on)>Math.abs(Tt)?"x":"y");let Jn={x:0,y:0};const en=Mn=>1/(1.5+Math.abs(Mn)/20);if(te==="y"){if(Vn.includes("top")||Vn.includes("bottom"))if(Vn.includes("top")&&Tt<0||Vn.includes("bottom")&&Tt>0)Jn.y=Tt;else{const Mn=Tt*en(Tt);Jn.y=Math.abs(Mn)<Math.abs(Tt)?Mn:Tt}}else if(te==="x"&&(Vn.includes("left")||Vn.includes("right")))if(Vn.includes("left")&&on<0||Vn.includes("right")&&on>0)Jn.x=on;else{const Mn=on*en(on);Jn.x=Math.abs(Mn)<Math.abs(on)?Mn:on}(Math.abs(Jn.x)>0||Math.abs(Jn.y)>0)&&we(!0),(De=ye.current)==null||De.style.setProperty("--swipe-amount-x",`${Jn.x}px`),(Nt=ye.current)==null||Nt.style.setProperty("--swipe-amount-y",`${Jn.y}px`)}},be&&!p.jsx&&Mt!=="loading"?xe.createElement("button",{"aria-label":q,"data-disabled":ge,"data-close-button":!0,onClick:ge||!jt?()=>{}:()=>{ke(),p.onDismiss==null||p.onDismiss.call(p,p)},className:Ms(Z==null?void 0:Z.closeButton,p==null||(r=p.classNames)==null?void 0:r.closeButton)},(Jt=K==null?void 0:K.close)!=null?Jt:lJ):null,(Mt||p.icon||p.promise)&&p.icon!==null&&((K==null?void 0:K[Mt])!==null||p.icon)?xe.createElement("div",{"data-icon":"",className:Ms(Z==null?void 0:Z.icon,p==null||(i=p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||$e():null,p.type!=="loading"?ct:null):null,xe.createElement("div",{"data-content":"",className:Ms(Z==null?void 0:Z.content,p==null||(s=p.classNames)==null?void 0:s.content)},xe.createElement("div",{"data-title":"",className:Ms(Z==null?void 0:Z.title,p==null||(o=p.classNames)==null?void 0:o.title)},p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title),p.description?xe.createElement("div",{"data-description":"",className:Ms(L,nn,Z==null?void 0:Z.description,p==null||(a=p.classNames)==null?void 0:a.description)},typeof p.description=="function"?p.description():p.description):null),xe.isValidElement(p.cancel)?p.cancel:p.cancel&&um(p.cancel)?xe.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||S,onClick:Ze=>{um(p.cancel)&&jt&&(p.cancel.onClick==null||p.cancel.onClick.call(p.cancel,Ze),ke())},className:Ms(Z==null?void 0:Z.cancelButton,p==null||(c=p.classNames)==null?void 0:c.cancelButton)},p.cancel.label):null,xe.isValidElement(p.action)?p.action:p.action&&um(p.action)?xe.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||R,onClick:Ze=>{um(p.action)&&(p.action.onClick==null||p.action.onClick.call(p.action,Ze),!Ze.defaultPrevented&&ke())},className:Ms(Z==null?void 0:Z.actionButton,p==null||(u=p.classNames)==null?void 0:u.actionButton)},p.action.label):null)};function U_(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function SJ(e,t){const n={};return[e,t].forEach((r,i)=>{const s=i===1,o=s?"--mobile-offset":"--offset",a=s?yJ:vJ;function c(u){["top","right","bottom","left"].forEach(h=>{n[`${o}-${h}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${o}-${u}`]=a:n[`${o}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):c(a)}),n}const a$=xe.forwardRef(function(t,n){const{id:r,invert:i,position:s="bottom-right",hotkey:o=["altKey","KeyT"],expand:a,closeButton:c,className:u,offset:h,mobileOffset:p,theme:m="light",richColors:g,duration:b,style:x,visibleToasts:C=gJ,toastOptions:w,dir:E=U_(),gap:_=xJ,icons:T,containerAriaLabel:I="Notifications"}=t,[P,M]=xe.useState([]),S=xe.useMemo(()=>r?P.filter(N=>N.toasterId===r):P.filter(N=>!N.toasterId),[P,r]),R=xe.useMemo(()=>Array.from(new Set([s].concat(S.filter(N=>N.position).map(N=>N.position)))),[S,s]),[$,L]=xe.useState([]),[j,O]=xe.useState(!1),[H,B]=xe.useState(!1),[Z,K]=xe.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),q=xe.useRef(null),te=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=xe.useRef(null),V=xe.useRef(!1),W=xe.useCallback(N=>{M(z=>{var Q;return(Q=z.find(J=>J.id===N.id))!=null&&Q.delete||ei.dismiss(N.id),z.filter(({id:J})=>J!==N.id)})},[]);return xe.useEffect(()=>ei.subscribe(N=>{if(N.dismiss){requestAnimationFrame(()=>{M(z=>z.map(Q=>Q.id===N.id?{...Q,delete:!0}:Q))});return}setTimeout(()=>{JQ.flushSync(()=>{M(z=>{const Q=z.findIndex(J=>J.id===N.id);return Q!==-1?[...z.slice(0,Q),{...z[Q],...N},...z.slice(Q+1)]:[N,...z]})})})}),[P]),xe.useEffect(()=>{if(m!=="system"){K(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;const N=window.matchMedia("(prefers-color-scheme: dark)");try{N.addEventListener("change",({matches:z})=>{K(z?"dark":"light")})}catch{N.addListener(({matches:Q})=>{try{K(Q?"dark":"light")}catch(J){console.error(J)}})}},[m]),xe.useEffect(()=>{P.length<=1&&O(!1)},[P]),xe.useEffect(()=>{const N=z=>{var Q;if(o.every(G=>z[G]||z.code===G)){var re;O(!0),(re=q.current)==null||re.focus()}z.code==="Escape"&&(document.activeElement===q.current||(Q=q.current)!=null&&Q.contains(document.activeElement))&&O(!1)};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[o]),xe.useEffect(()=>{if(q.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,V.current=!1)}},[q.current]),xe.createElement("section",{ref:n,"aria-label":`${I} ${te}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},R.map((N,z)=>{var Q;const[J,re]=N.split("-");return S.length?xe.createElement("ol",{key:N,dir:E==="auto"?U_():E,tabIndex:-1,ref:q,className:u,"data-sonner-toaster":!0,"data-sonner-theme":Z,"data-y-position":J,"data-x-position":re,style:{"--front-toast-height":`${((Q=$[0])==null?void 0:Q.height)||0}px`,"--width":`${bJ}px`,"--gap":`${_}px`,...x,...SJ(h,p)},onBlur:G=>{V.current&&!G.currentTarget.contains(G.relatedTarget)&&(V.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||V.current||(V.current=!0,F.current=G.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{H||O(!1)},onDragEnd:()=>O(!1),onPointerDown:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||B(!0)},onPointerUp:()=>B(!1)},S.filter(G=>!G.position&&z===0||G.position===N).map((G,X)=>{var de,ve;return xe.createElement(EJ,{key:G.id,icons:T,index:X,toast:G,defaultRichColors:g,duration:(de=w==null?void 0:w.duration)!=null?de:b,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:i,visibleToasts:C,closeButton:(ve=w==null?void 0:w.closeButton)!=null?ve:c,interacting:H,position:N,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,closeButtonAriaLabel:w==null?void 0:w.closeButtonAriaLabel,removeToast:W,toasts:S.filter(we=>we.position==G.position),heights:$.filter(we=>we.position==G.position),setHeights:L,expandByDefault:a,gap:_,expanded:j,swipeDirections:t.swipeDirections})})):null}))}),ls=e=>({ok:!0,value:e}),ti=e=>({ok:!1,error:e}),l$=(e,t)=>`style:${e}:${t}`,c$=e=>`text:${e}`,u$=e=>{const t=[e.rivetId,e.xpath,e.cssSelector].filter(n=>!!n).map(n=>n.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:["unknown"]},d$=e=>u$(e)[0],oh=(e,t)=>u$(e).includes(t),ac=e=>{const t=d$(e.elementId),n=e.batchId?`:${e.batchId}`:"";return e.type==="style"?`${l$(t,e.property)}${n}`:`${c$(t)}${n}`};class f$ extends Error{constructor(t){super(t),this.name="DOMError"}}class iu extends f${constructor(t,n){super(n||`Element not found: rivetId=${t.rivetId}, xpath=${t.xpath}`),this.identifier=t,this.name="ElementNotFoundError"}}class _J extends f${constructor(t,n,r){super(r||`Failed to apply style: ${t} = ${n}. Value may be invalid.`),this.property=t,this.value=n,this.name="StyleApplicationError"}}const yr=[];for(let e=0;e<256;++e)yr.push((e+256).toString(16).slice(1));function AJ(e,t=0){return(yr[e[t+0]]+yr[e[t+1]]+yr[e[t+2]]+yr[e[t+3]]+"-"+yr[e[t+4]]+yr[e[t+5]]+"-"+yr[e[t+6]]+yr[e[t+7]]+"-"+yr[e[t+8]]+yr[e[t+9]]+"-"+yr[e[t+10]]+yr[e[t+11]]+yr[e[t+12]]+yr[e[t+13]]+yr[e[t+14]]+yr[e[t+15]]).toLowerCase()}const TJ=new Uint8Array(16);function PJ(){return crypto.getRandomValues(TJ)}function Ga(e,t,n){return crypto.randomUUID?crypto.randomUUID():IJ(e)}function IJ(e,t,n){var i;e=e||{};const r=e.random??((i=e.rng)==null?void 0:i.call(e))??PJ();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,AJ(r)}var og={exports:{}},MJ=og.exports,Z_;function RJ(){return Z_||(Z_=1,(function(e){(function(t,n){e.exports?e.exports=n():t.log=n()})(MJ,function(){var t=function(){},n="undefined",r=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],s={},o=null;function a(x,C){var w=x[C];if(typeof w.bind=="function")return w.bind(x);try{return Function.prototype.bind.call(w,x)}catch{return function(){return Function.prototype.apply.apply(w,[x,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function u(x){return x==="debug"&&(x="log"),typeof console===n?!1:x==="trace"&&r?c:console[x]!==void 0?a(console,x):console.log!==void 0?a(console,"log"):t}function h(){for(var x=this.getLevel(),C=0;C<i.length;C++){var w=i[C];this[w]=C<x?t:this.methodFactory(w,x,this.name)}if(this.log=this.debug,typeof console===n&&x<this.levels.SILENT)return"No console available for logging"}function p(x){return function(){typeof console!==n&&(h.call(this),this[x].apply(this,arguments))}}function m(x,C,w){return u(x)||p.apply(this,arguments)}function g(x,C){var w=this,E,_,T,I="loglevel";typeof x=="string"?I+=":"+x:typeof x=="symbol"&&(I=void 0);function P(L){var j=(i[L]||"silent").toUpperCase();if(!(typeof window===n||!I)){try{window.localStorage[I]=j;return}catch{}try{window.document.cookie=encodeURIComponent(I)+"="+j+";"}catch{}}}function M(){var L;if(!(typeof window===n||!I)){try{L=window.localStorage[I]}catch{}if(typeof L===n)try{var j=window.document.cookie,O=encodeURIComponent(I),H=j.indexOf(O+"=");H!==-1&&(L=/^([^;]+)/.exec(j.slice(H+O.length+1))[1])}catch{}return w.levels[L]===void 0&&(L=void 0),L}}function S(){if(!(typeof window===n||!I)){try{window.localStorage.removeItem(I)}catch{}try{window.document.cookie=encodeURIComponent(I)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function R(L){var j=L;if(typeof j=="string"&&w.levels[j.toUpperCase()]!==void 0&&(j=w.levels[j.toUpperCase()]),typeof j=="number"&&j>=0&&j<=w.levels.SILENT)return j;throw new TypeError("log.setLevel() called with invalid level: "+L)}w.name=x,w.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},w.methodFactory=C||m,w.getLevel=function(){return T??_??E},w.setLevel=function(L,j){return T=R(L),j!==!1&&P(T),h.call(w)},w.setDefaultLevel=function(L){_=R(L),M()||w.setLevel(L,!1)},w.resetLevel=function(){T=null,S(),h.call(w)},w.enableAll=function(L){w.setLevel(w.levels.TRACE,L)},w.disableAll=function(L){w.setLevel(w.levels.SILENT,L)},w.rebuild=function(){if(o!==w&&(E=R(o.getLevel())),h.call(w),o===w)for(var L in s)s[L].rebuild()},E=R(o?o.getLevel():"WARN");var $=M();$!=null&&(T=R($)),h.call(w)}o=new g,o.getLogger=function(C){if(typeof C!="symbol"&&typeof C!="string"||C==="")throw new TypeError("You must supply a name when creating a logger.");var w=s[C];return w||(w=s[C]=new g(C,o.methodFactory)),w};var b=typeof window!==n?window.log:void 0;return o.noConflict=function(){return typeof window!==n&&window.log===o&&(window.log=b),o},o.getLoggers=function(){return s},o.default=o,o})})(og)),og.exports}var $J=RJ();const os=xc($J),DJ="INFO",NJ=DJ.toUpperCase();os.setLevel(os.levels[NJ]||os.levels.INFO);const $t=e=>{const t=e?`[${e}] `:"";return{trace:(n,...r)=>os.trace(`${t}${n}`,...r),debug:(n,...r)=>os.debug(`${t}${n}`,...r),info:(n,...r)=>os.info(`${t}${n}`,...r),warn:(n,...r)=>os.warn(`${t}${n}`,...r),error:(n,...r)=>{os.error(`${t}${n}`,...r);try{const s=r.map(a=>a instanceof Error?a.message:String(a)).join(" ").slice(0,512),o={source:"ui",error_message:n,service:e??"unknown",error_type:"logged_error",url:window.location.pathname,error_args_count:r.length,...s?{error_detail:s}:{}};yt.capture("logger_error",o)}catch(i){console.error("[logger] Failed to send logger_error to PostHog:",i)}},api:(n,...r)=>os.info(`${t}API: ${n}`,...r),hook:(n,...r)=>os.debug(`${t}Hook: ${n}`,...r),mount:(n,...r)=>os.debug(`${t}Mount: ${n}`,...r)}},h$={0:0,"0.5":2,1:4,"1.5":6,2:8,"2.5":10,3:12,"3.5":14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},fw=h$,p$=new Map;for(const[e,t]of Object.entries(h$))p$.set(t,e);const LJ=1,dm=(e,t,n=fw)=>{const r=e.match(/^(\d+(?:\.\d+)?)px$/);if(!r)return e;const i=parseFloat(r[1]),s=Math.round(i),a=(n===fw?p$:new Map(Object.entries(n).map(([c,u])=>[Math.round(u),c]))).get(s);if(a!==void 0)return`${t==="width"?"w":"h"}-${a}`;for(const[c,u]of Object.entries(n))if(Math.abs(i-u)<=LJ)return`${t==="width"?"w":"h"}-${c}`;return e},jJ=(e,t=fw)=>{const n=e.match(/^(w|h)-(.+)$/);if(!n)return e;const r=n[2],i=t[r];return i===void 0?e:`${i}px`},da=$t("StyleManipulationService");class FJ{constructor(t,n){fn(this,"hmrUnsubscribe",null);this.adapter=t,this.tracker=n,this.hmrUnsubscribe=this.adapter.onHMR(()=>{this.handleHMR()})}async previewStyleChange(t,n,r){return this.adapter.applyStyle(t,n,r)}async applyStyleChange(t,n,r,i,s,o){let a;if(s!==void 0)a=s;else{const h=await this.adapter.getComputedStylesForElement(t);if(!h.ok)return ti(h.error);a=h.value[r]||""}const c=await this.adapter.applyStyle(t,r,i);if(!c.ok)return ti(c.error);const u={type:"style",id:Ga(),timestamp:Date.now(),elementId:t,elementContext:n,property:r,oldValue:a,newValue:o??i};return this.tracker.recordChange(u),ls(void 0)}recordTextChange(t,n,r,i){const s={type:"text",id:Ga(),timestamp:Date.now(),elementId:t,elementContext:n,oldText:r,newText:i};this.tracker.recordChange(s)}async undo(){const t=this.tracker.undo();return t?await this.clearAndReapply(t):ls(void 0)}async redo(){const t=this.tracker.getChanges();return this.tracker.redo()?await this.clearAndReapply(t):ls(void 0)}getChanges(){return this.tracker.getChanges()}getStyleChanges(){return this.tracker.getStyleChanges()}getTextChanges(){return this.tracker.getTextChanges()}getChangeCount(){return this.tracker.getChangeCount()}canUndo(){return this.tracker.canUndo()}canRedo(){return this.tracker.canRedo()}flushPending(){this.tracker.flushPending()}async revertSpecificChange(t){const n=ac(t),r=await this.adapter.findElement(t.elementId);if(!r.ok){const o=r.error;return ti(o instanceof Error?o:new Error(String(o)))}const i=r.value;try{t.type==="style"?t.property==="width"||t.property==="height"?i.style[t.property]="":i.style[t.property]=t.oldValue:i.textContent=t.oldText}catch(o){return da.warn("Failed to revert specific change:",o),ti(o instanceof Error?o:new Error("Failed to revert change"))}return this.tracker.removeChange(n)||da.warn("removeChange found no entry for key:",n),ls(void 0)}clear(){this.tracker.clear()}removeTrackedChangeById(t){return this.tracker.removeChangeById(t)!==null}async transaction(t){await this.tracker.transaction(t)}getChangesForElement(t){return this.tracker.getChanges().filter(n=>oh(n.elementId,t))}hasChanges(t){return this.tracker.hasChanges(t)}onChange(t){return this.tracker.onChange(t)}async handleHMR(){da.info("HMR detected, reapplying changes"),await new Promise(n=>setTimeout(n,100));const t=await this.reapplyAllChanges({stylesOnly:!0});t.ok||da.warn("Failed to reapply changes after HMR:",t.error)}async clearAndReapply(t){for(const n of t){const r=await this.adapter.findElement(n.elementId);if(r.ok){const i=r.value;try{n.type==="style"?n.property==="width"||n.property==="height"?i.style[n.property]="":i.style[n.property]=n.oldValue:i.textContent=n.oldText}catch(s){da.warn("Failed to restore baseline:",s)}}}return await this.reapplyAllChanges()}async reapplyAllChanges(t={}){const n=this.tracker.getChanges(),r=t.stylesOnly?n.filter(s=>s.type==="style"):n,i=[];for(const s of r)if(s.type==="style"){const o=s.property==="width"||s.property==="height"?jJ(s.newValue):s.newValue,a=await this.adapter.applyStyle(s.elementId,s.property,o);a.ok||i.push({change:s,error:a.error})}else{const o=await this.adapter.findElement(s.elementId);if(o.ok){const a=o.value;a.textContent=s.newText}else i.push({change:s,error:o.error})}return i.length>0?(da.warn(`Failed to reapply ${i.length}/${r.length} changes`,i),ti(new Error(`Failed to reapply ${i.length} changes. First error: ${i[0].error.message}`))):ls(void 0)}async clearInlineChanges(){const t=this.tracker.getChanges();for(const n of t){const r=await this.adapter.findElement(n.elementId);if(!r.ok){da.warn("Could not find element to clear change:",r.error);continue}const i=r.value;try{n.type==="style"?i.style[n.property]="":i.textContent=n.oldText}catch(s){da.warn("Failed to clear change:",s)}}return ls(void 0)}async clearInlineStyles(){return this.clearInlineChanges()}destroy(){this.hmrUnsubscribe&&(this.hmrUnsubscribe(),this.hmrUnsubscribe=null)}}const OJ=300;class VJ{constructor(){fn(this,"history",{current:new Map,past:[],future:[]});fn(this,"pendingChanges",new Map);fn(this,"currentBatchId",null);fn(this,"debounceTimer",null);fn(this,"onChangeCallbacks",[]);fn(this,"stateBeforePending",null);fn(this,"transactionDepth",0)}recordChange(t){this.pendingChanges.size===0&&(this.currentBatchId=Ga(),this.stateBeforePending=new Map(this.history.current)),this.currentBatchId&&(t.batchId=this.currentBatchId);const n=d$(t.elementId),r=t.type==="style"?l$(n,t.property):c$(n),i=Array.from(this.history.current.entries()).find(([o])=>o===r||o.startsWith(`${r}:`));if(i){const o=i[1];t.type==="style"&&o.type==="style"?t.oldValue=o.oldValue:t.type==="text"&&o.type==="text"&&(t.oldText=o.oldText)}const s=ac(t);this.history.current.set(s,t),this.pendingChanges.set(s,t),this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.commitPending()},OJ),this.notifyChange()}flushPending(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.commitPending()}removeChange(t){const n=this.history.current.get(t)??this.pendingChanges.get(t)??null,r=this.history.current.has(t),i=this.pendingChanges.has(t);return!r&&!i?null:(r&&this.history.current.delete(t),i&&this.pendingChanges.delete(t),n&&this.stateBeforePending&&(this.stateBeforePending=this.removeChangeFromSnapshotById(this.stateBeforePending,n.id)),i&&this.pendingChanges.size===0&&(this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.stateBeforePending=null,this.currentBatchId=null),r&&(this.history.future=[]),n&&(this.history.past=this.history.past.map(s=>this.removeChangeFromSnapshotById(s,n.id)).filter(s=>s.size>0)),this.notifyChange(),n)}removeChangeById(t){const n=Array.from(this.history.current.entries()).find(([,i])=>i.id===t);if(n)return this.removeChange(n[0]);const r=Array.from(this.pendingChanges.entries()).find(([,i])=>i.id===t);return r?this.removeChange(r[0]):null}removeChangeFromSnapshotById(t,n){return new Map(Array.from(t.entries()).filter(([,r])=>r.id!==n))}commitPending(){this.pendingChanges.size===0||!this.stateBeforePending||this.transactionDepth>0||(this.history.past.push(this.stateBeforePending),this.history.future=[],this.pendingChanges.clear(),this.stateBeforePending=null,this.currentBatchId=null,this.notifyChange())}undo(){if(this.pendingChanges.size>0&&this.commitPending(),this.history.past.length===0)return null;const t=new Map(this.history.current);this.history.future.push(t),this.history.current=this.history.past.pop(),this.notifyChange();const n=[];for(const[r,i]of t)this.history.current.has(r)||n.push(i);return n}redo(){if(this.history.future.length===0)return null;const t=new Map(this.history.current);this.history.past.push(t),this.history.current=this.history.future.pop(),this.notifyChange();const n=[];for(const[r,i]of this.history.current)t.has(r)||n.push(i);return n}getChanges(){return Array.from(this.history.current.values())}getStyleChanges(){return Array.from(this.history.current.values()).filter(t=>t.type==="style")}getTextChanges(){return Array.from(this.history.current.values()).filter(t=>t.type==="text")}getChangeCount(){return this.getUniqueBatchCount(this.history.current.values())}getStyleBatchCount(){return this.getUniqueBatchCount(Array.from(this.history.current.values()).filter(t=>t.type==="style"))}getTextBatchCount(){return this.getUniqueBatchCount(Array.from(this.history.current.values()).filter(t=>t.type==="text"))}getUniqueBatchCount(t){const n=new Set;for(const r of t)r.batchId?n.add(r.batchId):n.add(r.id);return n.size}canUndo(){return this.history.past.length>0||this.pendingChanges.size>0}canRedo(){return this.history.future.length>0}clear(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.history={current:new Map,past:[],future:[]},this.pendingChanges.clear(),this.stateBeforePending=null,this.currentBatchId=null,this.notifyChange()}getStyleChange(t,n){return Array.from(this.history.current.values()).filter(i=>i.type==="style"&&oh(i.elementId,t)&&i.property===n).sort((i,s)=>s.timestamp-i.timestamp)[0]}getTextChange(t){return Array.from(this.history.current.values()).filter(r=>r.type==="text"&&oh(r.elementId,t)).sort((r,i)=>i.timestamp-r.timestamp)[0]}hasChanges(t){return Array.from(this.history.current.values()).some(n=>oh(n.elementId,t))}getChangesForElement(t){return Array.from(this.history.current.values()).filter(n=>oh(n.elementId,t))}onChange(t){return this.onChangeCallbacks.push(t),()=>{const n=this.onChangeCallbacks.indexOf(t);n!==-1&&this.onChangeCallbacks.splice(n,1)}}notifyChange(){this.onChangeCallbacks.forEach(t=>t())}export(){return{current:Array.from(this.history.current.entries()),past:this.history.past.map(t=>Array.from(t.entries())),future:this.history.future.map(t=>Array.from(t.entries()))}}import(t){this.history={current:new Map(t.current),past:t.past.map(n=>new Map(n)),future:t.future.map(n=>new Map(n))},this.notifyChange()}async transaction(t){const n=this.pendingChanges.size===0;n&&(this.currentBatchId=Ga(),this.stateBeforePending=new Map(this.history.current)),this.transactionDepth++;try{await t()}catch(r){throw n&&this.stateBeforePending&&(this.history.current=new Map(this.stateBeforePending),this.pendingChanges.clear(),this.currentBatchId=null,this.stateBeforePending=null),r}finally{this.transactionDepth--,n&&this.transactionDepth===0&&this.flushPending()}}}const Qs={kind:"base"};function ah(e){return e.kind==="variant"}function No(e){return e.kind==="base"?"base":`variant:${e.sessionId}:${e.variantId}`}function Gh(e,t){return e.kind==="base"&&t.kind==="base"?!0:e.kind==="variant"&&t.kind==="variant"?e.sessionId===t.sessionId&&e.variantId===t.variantId:!1}const Mu={color:"colors",background:"colors",backgroundColor:"colors",borderColor:"colors",borderTopColor:"colors",borderRightColor:"colors",borderBottomColor:"colors",borderLeftColor:"colors",outlineColor:"colors",borderRadius:"borderRadius",borderTopLeftRadius:"borderRadius",borderTopRightRadius:"borderRadius",borderBottomRightRadius:"borderRadius",borderBottomLeftRadius:"borderRadius",boxShadow:"boxShadow",padding:"spacing",paddingTop:"spacing",paddingRight:"spacing",paddingBottom:"spacing",paddingLeft:"spacing",margin:"spacing",marginTop:"spacing",marginRight:"spacing",marginBottom:"spacing",marginLeft:"spacing",gap:"spacing",rowGap:"spacing",columnGap:"spacing",width:"spacing",height:"spacing",maxWidth:"spacing",maxHeight:"spacing",minWidth:"spacing",minHeight:"spacing",fontSize:"fontSize",fontFamily:"fontFamily"},HJ="claude-opus-4-8",BJ={resize:{default:!1},variants:{default:!1},designSystemEditor:{default:!1},branchDiff:{default:!1},gitUi:{default:!0},createProject:{default:!1},desktopForceUpgrade:{default:!1},deployPrototype:{default:!1},generativeControls:{default:!1},refineMode:{default:!1}},m$=Object.fromEntries(Object.entries(BJ).map(([e,t])=>[e,{isEnabled:t.default}])),Js=Qe(null),zJ=Qe([]),UJ=Qe(""),ZJ=Qe([]),rl=Qe("view"),F8=Qe(null,(e,t,n)=>{n==="edit"&&!e(Ti).refineMode.isEnabled||(t(rl,n),n==="view"&&(t(Js,null),t(H8,null)))}),wp=Qe(!0),O8=Qe("chat"),g$=Qe(0),v$=Qe({name:null,email:null}),y$=Qe(0),ps=Qe(Qs),hw=Qe(new Map),pw=Qe(new Map),WJ=Qe(null,(e,t,n)=>{const r=new Map(e(hw));n.ref?r.set(n.surfaceId,n.ref):r.delete(n.surfaceId),t(hw,r)}),GJ=Qe(null,(e,t,n)=>{const r=new Map(e(pw));n.adapter?r.set(n.surfaceId,n.adapter):r.delete(n.surfaceId),t(pw,r)}),kp=Qe(e=>{const t=e(hw),n=No(e(ps));return t.get(n)??t.get("base")??null}),Pd=Qe(e=>{const t=e(pw),n=No(e(ps));return t.get(n)??t.get("base")??null}),Id=Qe(null),q1=Qe({isEditing:!1,element:null,originalText:""}),b$=Qe(!1),qh=new Map,qJ=e=>{const t=No(e);let n=qh.get(t);return n||(n=new VJ,qh.set(t,n)),n},V8=Qe(e=>qJ(e(ps)),(e,t,n)=>{qh.set(No(e(ps)),n)}),KJ=e=>{for(const t of[...qh.keys()])t==="base"||e.has(t)||qh.delete(t)},mw=Qe(null),K1=Qe(null),H8=Qe(null),W_=[{id:"claude-sonnet-4-6",name:"Sonnet 4.6",description:"Fast and capable"},{id:"claude-opus-4-8",name:"Opus 4.8",description:"Most capable"},{id:"claude-opus-4-7",name:"Opus 4.7",description:"Highly capable"},{id:"claude-opus-4-6",name:"Opus 4.6",description:"Highly capable"},{id:"claude-haiku-4-5",name:"Haiku 4.5",description:"Fast and affordable"}],x$=Qe(HJ),Hi=Qe(new Map),r1=Qe(null),B8=Qe(null),gw=Qe(0),i1=Qe(null),vw=Qe(!1),w$=Qe(null),yw=Qe(null),Kh=Qe(null),z8=Qe(null),Cc=Qe(null),il=Qe({active:!1}),k$=Qe(!1),qa=Qe(null),YJ=Qe(null,(e,t,n)=>{const r=c=>{const u=c??Qs;return u.kind==="variant"&&!n.has(No(u))},i=e(Hi);let s=null;for(const[c,u]of i)r(u.target)&&(s??(s=new Set)).add(c);if(s){const c=new Map(i);for(const u of s)c.delete(u);t(Hi,c)}r(e(ps))&&(t(ps,Qs),t(Js,null));const o=e(r1);o&&r(o.target)&&(t(r1,null),t(pc,!1));const a=e(qa);a&&(s!=null&&s.has(a.commentId))&&t(qa,null),KJ(n)}),Ti=Qe(m$),C$=Qe(!1),Y1=Qe(null),E$=Qe(!1),Cp=Qe(!1),U8=Qe(null),XJ=()=>{var e;return typeof window>"u"?null:((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.agentApplyMode)??null},X1=Qe(XJ()),Z8=Qe(null),QJ=Qe(!1),pc=Qe(!1),S$=Qe(!1),_$=Qe(0),JJ=Qe(0);function A$(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=A$(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function W8(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=A$(e))&&(r&&(r+=" "),r+=t);return r}const eee=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},tee=(e,t)=>({classGroupId:e,validator:t}),T$=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),s1="-",G_=[],nee="arbitrary..",ree=e=>{const t=see(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return iee(o);const a=o.split(s1),c=a[0]===""&&a.length>1?1:0;return P$(a,c,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const c=r[o],u=n[o];return c?u?eee(u,c):c:u||G_}return n[o]||G_}}},P$=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],s=n.nextPart.get(i);if(s){const u=P$(e,t+1,s);if(u)return u}const o=n.validators;if(o===null)return;const a=t===0?e.join(s1):e.slice(t).join(s1),c=o.length;for(let u=0;u<c;u++){const h=o[u];if(h.validator(a))return h.classGroupId}},iee=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?nee+r:void 0})(),see=e=>{const{theme:t,classGroups:n}=e;return oee(n,t)},oee=(e,t)=>{const n=T$();for(const r in e){const i=e[r];G8(i,n,r,t)}return n},G8=(e,t,n,r)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];aee(o,t,n,r)}},aee=(e,t,n,r)=>{if(typeof e=="string"){lee(e,t,n);return}if(typeof e=="function"){cee(e,t,n,r);return}uee(e,t,n,r)},lee=(e,t,n)=>{const r=e===""?t:I$(t,e);r.classGroupId=n},cee=(e,t,n,r)=>{if(dee(e)){G8(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(tee(n,e))},uee=(e,t,n,r)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[a,c]=i[o];G8(c,I$(t,a),n,r)}},I$=(e,t)=>{let n=e;const r=t.split(s1),i=r.length;for(let s=0;s<i;s++){const o=r[s];let a=n.nextPart.get(o);a||(a=T$(),n.nextPart.set(o,a)),n=a}return n},dee=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,fee=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(s,o)=>{n[s]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=r[s])!==void 0)return i(s,o),o},set(s,o){s in n?n[s]=o:i(s,o)}}},bw="!",q_=":",hee=[],K_=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),pee=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const s=[];let o=0,a=0,c=0,u;const h=i.length;for(let x=0;x<h;x++){const C=i[x];if(o===0&&a===0){if(C===q_){s.push(i.slice(c,x)),c=x+1;continue}if(C==="/"){u=x;continue}}C==="["?o++:C==="]"?o--:C==="("?a++:C===")"&&a--}const p=s.length===0?i:i.slice(c);let m=p,g=!1;p.endsWith(bw)?(m=p.slice(0,-1),g=!0):p.startsWith(bw)&&(m=p.slice(1),g=!0);const b=u&&u>c?u-c:void 0;return K_(s,g,m,b)};if(t){const i=t+q_,s=r;r=o=>o.startsWith(i)?s(o.slice(i.length)):K_(hee,!1,o,void 0,!0)}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},mee=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let s=0;s<n.length;s++){const o=n[s],a=o[0]==="[",c=t.has(o);a||c?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},gee=e=>({cache:fee(e.cacheSize),parseClassName:pee(e),sortModifiers:mee(e),postfixLookupClassGroupIds:vee(e),...ree(e)}),vee=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},yee=/\s+/,bee=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s,postfixLookupClassGroupIds:o}=t,a=[],c=e.trim().split(yee);let u="";for(let h=c.length-1;h>=0;h-=1){const p=c[h],{isExternal:m,modifiers:g,hasImportantModifier:b,baseClassName:x,maybePostfixModifierPosition:C}=n(p);if(m){u=p+(u.length>0?" "+u:u);continue}let w=!!C,E;if(w){const M=x.substring(0,C);E=r(M);const S=E&&o[E]?r(x):void 0;S&&S!==E&&(E=S,w=!1)}else E=r(x);if(!E){if(!w){u=p+(u.length>0?" "+u:u);continue}if(E=r(x),!E){u=p+(u.length>0?" "+u:u);continue}w=!1}const _=g.length===0?"":g.length===1?g[0]:s(g).join(":"),T=b?_+bw:_,I=T+E;if(a.indexOf(I)>-1)continue;a.push(I);const P=i(E,w);for(let M=0;M<P.length;++M){const S=P[M];a.push(T+S)}u=p+(u.length>0?" "+u:u)}return u},xee=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=M$(n))&&(i&&(i+=" "),i+=r);return i},M$=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=M$(e[r]))&&(n&&(n+=" "),n+=t);return n},wee=(e,...t)=>{let n,r,i,s;const o=c=>{const u=t.reduce((h,p)=>p(h),e());return n=gee(u),r=n.cache.get,i=n.cache.set,s=a,a(c)},a=c=>{const u=r(c);if(u)return u;const h=bee(c,n);return i(c,h),h};return s=o,(...c)=>s(xee(...c))},kee=[],rr=e=>{const t=n=>n[e]||kee;return t.isThemeGetter=!0,t},R$=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$$=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Cee=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Eee=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,See=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,_ee=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Aee=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Tee=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,fa=e=>Cee.test(e),Lt=e=>!!e&&!Number.isNaN(Number(e)),Rs=e=>!!e&&Number.isInteger(Number(e)),xb=e=>e.endsWith("%")&&Lt(e.slice(0,-1)),vo=e=>Eee.test(e),D$=()=>!0,Pee=e=>See.test(e)&&!_ee.test(e),q8=()=>!1,Iee=e=>Aee.test(e),Mee=e=>Tee.test(e),Ree=e=>!We(e)&&!qe(e),$ee=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Dee=e=>sl(e,j$,q8),We=e=>R$.test(e),Dl=e=>sl(e,F$,Pee),Y_=e=>sl(e,Bee,Lt),Nee=e=>sl(e,V$,D$),Lee=e=>sl(e,O$,q8),X_=e=>sl(e,N$,q8),jee=e=>sl(e,L$,Mee),fm=e=>sl(e,H$,Iee),qe=e=>$$.test(e),Ff=e=>Ec(e,F$),Fee=e=>Ec(e,O$),Q_=e=>Ec(e,N$),Oee=e=>Ec(e,j$),Vee=e=>Ec(e,L$),hm=e=>Ec(e,H$,!0),Hee=e=>Ec(e,V$,!0),sl=(e,t,n)=>{const r=R$.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ec=(e,t,n=!1)=>{const r=$$.exec(e);return r?r[1]?t(r[1]):n:!1},N$=e=>e==="position"||e==="percentage",L$=e=>e==="image"||e==="url",j$=e=>e==="length"||e==="size"||e==="bg-size",F$=e=>e==="length",Bee=e=>e==="number",O$=e=>e==="family-name",V$=e=>e==="number"||e==="weight",H$=e=>e==="shadow",zee=()=>{const e=rr("color"),t=rr("font"),n=rr("text"),r=rr("font-weight"),i=rr("tracking"),s=rr("leading"),o=rr("breakpoint"),a=rr("container"),c=rr("spacing"),u=rr("radius"),h=rr("shadow"),p=rr("inset-shadow"),m=rr("text-shadow"),g=rr("drop-shadow"),b=rr("blur"),x=rr("perspective"),C=rr("aspect"),w=rr("ease"),E=rr("animate"),_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...T(),qe,We],P=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],S=()=>[qe,We,c],R=()=>[fa,"full","auto",...S()],$=()=>[Rs,"none","subgrid",qe,We],L=()=>["auto",{span:["full",Rs,qe,We]},Rs,qe,We],j=()=>[Rs,"auto",qe,We],O=()=>["auto","min","max","fr",qe,We],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],B=()=>["start","end","center","stretch","center-safe","end-safe"],Z=()=>["auto",...S()],K=()=>[fa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...S()],q=()=>[fa,"screen","full","dvw","lvw","svw","min","max","fit",...S()],te=()=>[fa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...S()],F=()=>[e,qe,We],V=()=>[...T(),Q_,X_,{position:[qe,We]}],W=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N=()=>["auto","cover","contain",Oee,Dee,{size:[qe,We]}],z=()=>[xb,Ff,Dl],Q=()=>["","none","full",u,qe,We],J=()=>["",Lt,Ff,Dl],re=()=>["solid","dashed","dotted","double"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],X=()=>[Lt,xb,Q_,X_],de=()=>["","none",b,qe,We],ve=()=>["none",Lt,qe,We],we=()=>["none",Lt,qe,We],je=()=>[Lt,qe,We],Ae=()=>[fa,"full",...S()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[vo],breakpoint:[vo],color:[D$],container:[vo],"drop-shadow":[vo],ease:["in","out","in-out"],font:[Ree],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[vo],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[vo],shadow:[vo],spacing:["px",Lt],text:[vo],"text-shadow":[vo],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",fa,We,qe,C]}],container:["container"],"container-type":[{"@container":["","normal","size",qe,We]}],"container-named":[$ee],columns:[{columns:[Lt,We,qe,a]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:I()}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[Rs,"auto",qe,We]}],basis:[{basis:[fa,"full","auto",a,...S()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Lt,fa,"auto","initial","none",We]}],grow:[{grow:["",Lt,qe,We]}],shrink:[{shrink:["",Lt,qe,We]}],order:[{order:[Rs,"first","last","none",qe,We]}],"grid-cols":[{"grid-cols":$()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":j()}],"col-end":[{"col-end":j()}],"grid-rows":[{"grid-rows":$()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":j()}],"row-end":[{"row-end":j()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...B(),"normal"]}],"justify-self":[{"justify-self":["auto",...B()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...B(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...B(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...B(),"baseline"]}],"place-self":[{"place-self":["auto",...B()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pbs:[{pbs:S()}],pbe:[{pbe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:Z()}],mx:[{mx:Z()}],my:[{my:Z()}],ms:[{ms:Z()}],me:[{me:Z()}],mbs:[{mbs:Z()}],mbe:[{mbe:Z()}],mt:[{mt:Z()}],mr:[{mr:Z()}],mb:[{mb:Z()}],ml:[{ml:Z()}],"space-x":[{"space-x":S()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":S()}],"space-y-reverse":["space-y-reverse"],size:[{size:K()}],"inline-size":[{inline:["auto",...q()]}],"min-inline-size":[{"min-inline":["auto",...q()]}],"max-inline-size":[{"max-inline":["none",...q()]}],"block-size":[{block:["auto",...te()]}],"min-block-size":[{"min-block":["auto",...te()]}],"max-block-size":[{"max-block":["none",...te()]}],w:[{w:[a,"screen",...K()]}],"min-w":[{"min-w":[a,"screen","none",...K()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...K()]}],h:[{h:["screen","lh",...K()]}],"min-h":[{"min-h":["screen","lh","none",...K()]}],"max-h":[{"max-h":["screen","lh",...K()]}],"font-size":[{text:["base",n,Ff,Dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Hee,Nee]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xb,We]}],"font-family":[{font:[Fee,Lee,t]}],"font-features":[{"font-features":[We]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,qe,We]}],"line-clamp":[{"line-clamp":[Lt,"none",qe,Y_]}],leading:[{leading:[s,...S()]}],"list-image":[{"list-image":["none",qe,We]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",qe,We]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:[Lt,"from-font","auto",qe,Dl]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Lt,"auto",qe,We]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"tab-size":[{tab:[Rs,qe,We]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",qe,We]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",qe,We]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:W()}],"bg-size":[{bg:N()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Rs,qe,We],radial:["",qe,We],conic:[Rs,qe,We]},Vee,jee]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:Q()}],"rounded-s":[{"rounded-s":Q()}],"rounded-e":[{"rounded-e":Q()}],"rounded-t":[{"rounded-t":Q()}],"rounded-r":[{"rounded-r":Q()}],"rounded-b":[{"rounded-b":Q()}],"rounded-l":[{"rounded-l":Q()}],"rounded-ss":[{"rounded-ss":Q()}],"rounded-se":[{"rounded-se":Q()}],"rounded-ee":[{"rounded-ee":Q()}],"rounded-es":[{"rounded-es":Q()}],"rounded-tl":[{"rounded-tl":Q()}],"rounded-tr":[{"rounded-tr":Q()}],"rounded-br":[{"rounded-br":Q()}],"rounded-bl":[{"rounded-bl":Q()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-bs":[{"border-bs":J()}],"border-w-be":[{"border-be":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...re(),"hidden","none"]}],"divide-style":[{divide:[...re(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-bs":[{"border-bs":F()}],"border-color-be":[{"border-be":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...re(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Lt,qe,We]}],"outline-w":[{outline:["",Lt,Ff,Dl]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",h,hm,fm]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",p,hm,fm]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Lt,Dl]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",m,hm,fm]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Lt,qe,We]}],"mix-blend":[{"mix-blend":[...G(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":G()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Lt]}],"mask-image-linear-from-pos":[{"mask-linear-from":X()}],"mask-image-linear-to-pos":[{"mask-linear-to":X()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":X()}],"mask-image-t-to-pos":[{"mask-t-to":X()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":X()}],"mask-image-r-to-pos":[{"mask-r-to":X()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":X()}],"mask-image-b-to-pos":[{"mask-b-to":X()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":X()}],"mask-image-l-to-pos":[{"mask-l-to":X()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":X()}],"mask-image-x-to-pos":[{"mask-x-to":X()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":X()}],"mask-image-y-to-pos":[{"mask-y-to":X()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[qe,We]}],"mask-image-radial-from-pos":[{"mask-radial-from":X()}],"mask-image-radial-to-pos":[{"mask-radial-to":X()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Lt]}],"mask-image-conic-from-pos":[{"mask-conic-from":X()}],"mask-image-conic-to-pos":[{"mask-conic-to":X()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:V()}],"mask-repeat":[{mask:W()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",qe,We]}],filter:[{filter:["","none",qe,We]}],blur:[{blur:de()}],brightness:[{brightness:[Lt,qe,We]}],contrast:[{contrast:[Lt,qe,We]}],"drop-shadow":[{"drop-shadow":["","none",g,hm,fm]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Lt,qe,We]}],"hue-rotate":[{"hue-rotate":[Lt,qe,We]}],invert:[{invert:["",Lt,qe,We]}],saturate:[{saturate:[Lt,qe,We]}],sepia:[{sepia:["",Lt,qe,We]}],"backdrop-filter":[{"backdrop-filter":["","none",qe,We]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[Lt,qe,We]}],"backdrop-contrast":[{"backdrop-contrast":[Lt,qe,We]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Lt,qe,We]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Lt,qe,We]}],"backdrop-invert":[{"backdrop-invert":["",Lt,qe,We]}],"backdrop-opacity":[{"backdrop-opacity":[Lt,qe,We]}],"backdrop-saturate":[{"backdrop-saturate":[Lt,qe,We]}],"backdrop-sepia":[{"backdrop-sepia":["",Lt,qe,We]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",qe,We]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Lt,"initial",qe,We]}],ease:[{ease:["linear","initial",w,qe,We]}],delay:[{delay:[Lt,qe,We]}],animate:[{animate:["none",E,qe,We]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,qe,We]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:ve()}],"rotate-x":[{"rotate-x":ve()}],"rotate-y":[{"rotate-y":ve()}],"rotate-z":[{"rotate-z":ve()}],scale:[{scale:we()}],"scale-x":[{"scale-x":we()}],"scale-y":[{"scale-y":we()}],"scale-z":[{"scale-z":we()}],"scale-3d":["scale-3d"],skew:[{skew:je()}],"skew-x":[{"skew-x":je()}],"skew-y":[{"skew-y":je()}],transform:[{transform:[qe,We,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ae()}],"translate-x":[{"translate-x":Ae()}],"translate-y":[{"translate-y":Ae()}],"translate-z":[{"translate-z":Ae()}],"translate-none":["translate-none"],zoom:[{zoom:[Rs,qe,We]}],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",qe,We]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":F()}],"scrollbar-track-color":[{"scrollbar-track":F()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mbs":[{"scroll-mbs":S()}],"scroll-mbe":[{"scroll-mbe":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pbs":[{"scroll-pbs":S()}],"scroll-pbe":[{"scroll-pbe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",qe,We]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[Lt,Ff,Dl,Y_]}],stroke:[{stroke:["none",...F()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},B$=wee(zee);function zn(...e){return B$(W8(e))}const Ka={fast:{type:"spring",duration:.08,bounce:0},moderate:{type:"spring",duration:.16,bounce:.15}},J_=["#f59e0b","#38bdf8","#34d399","#a78bfa","#fb7185","#22d3ee","#fb923c","#a3e635","#e879f9","#2dd4bf"];function z$(e){let t=0;for(let r=0;r<e.length;r++)t=t*31+e.charCodeAt(r)|0;const n=J_[Math.abs(t)%J_.length];return{color:n,backgroundColor:`${n}22`}}function U$(e,t={}){const{axis:n="y"}=t,r=f.useRef(new Map),[i,s]=f.useState(null),[o,a]=f.useState([]),c=f.useRef([]),u=f.useRef(0),h=f.useRef(null),p=f.useRef(null),m=f.useCallback(()=>{if(!e.current)return;const E=[];r.current.forEach((_,T)=>{E[T]={top:_.offsetTop,height:_.offsetHeight,left:_.offsetLeft,width:_.offsetWidth}}),c.current=E,a(E)},[e]),g=f.useCallback((w,E)=>{E?r.current.set(w,E):r.current.delete(w),p.current!==null&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{p.current=null,m()})},[m]),b=f.useCallback(w=>{const E=w.clientX,_=w.clientY;h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null;const T=e.current;if(!T)return;const I=T.getBoundingClientRect(),P=n==="x"?E:_;let M=null,S=1/0,R=null;const $=c.current,L=n==="x"?T.scrollLeft:T.scrollTop,j=n==="x"?T.clientLeft:T.clientTop,O=n==="x"?I.left:I.top,H=n==="x"?T.offsetWidth:T.offsetHeight,B=n==="x"?I.width:I.height,Z=H>0?B/H:1;for(let K=0;K<$.length;K++){const q=$[K];if(!q)continue;const te=n==="x"?q.left:q.top,F=O+(j+te-L)*Z,V=(n==="x"?q.width:q.height)*Z,W=F+V;P>=F&&P<=W&&(R=K);const N=F+V/2,z=Math.abs(P-N);z<S&&(S=z,M=K)}s(R??M)})},[n,e]),x=f.useCallback(()=>{u.current+=1,m()},[m]),C=f.useCallback(()=>{h.current!==null&&(cancelAnimationFrame(h.current),h.current=null),s(null)},[]);return f.useEffect(()=>()=>{h.current!==null&&cancelAnimationFrame(h.current),p.current!==null&&cancelAnimationFrame(p.current)},[]),{activeIndex:i,setActiveIndex:s,itemRects:o,sessionRef:u,handlers:{onMouseMove:b,onMouseEnter:x,onMouseLeave:C},registerItem:g,measureItems:m}}function Uee(e,t,n){f.useEffect(()=>(e(t,n.current),()=>e(t,null)),[t,e,n])}const Zee=["⡡⠊⢔⠡","⠊⡰⡡⡘","⢔⢅⠈⢢","⡁⢂⠆⡍","⢔⠨⢑⢐","⠨⡑⡠⠊"],K8=({className:e}={})=>y.jsx("div",{className:`rivet-sparkle relative overflow-hidden font-mono leading-none ${e??"text-base text-primary"}`,style:{height:"1em",width:"4ch"},"aria-hidden":"true",children:y.jsx("div",{className:"rivet-sparkle-strip",children:Zee.map((t,n)=>y.jsx("span",{className:"block",style:{height:"1em",lineHeight:"1em"},children:t},n))})});function Wee(e){var i,s,o;const{sessionId:t,variant:n,projectContext:r}=e;return n.status!=="succeeded"?null:((i=n.preview)==null?void 0:i.kind)==="static_artifact"?n.preview.url:t&&(r==null?void 0:r.kind)==="fresh"&&((s=r.executionPlan)==null?void 0:s.mode)!=="vite_app"&&((o=n.preview)==null?void 0:o.kind)!=="dev_server"?`/api/variants/${t}/static/${n.workItemId}`:null}const eA=6,mi=$t("AgentVariantsPanel");function pm(e,...t){return e?t.some(n=>(n??"").toLowerCase().includes(e)):!0}async function su(e){try{const t=await e.json();return{message:typeof t.message=="string"?t.message:null,errorCode:typeof t.errorCode=="string"?t.errorCode:null}}catch{return{message:null,errorCode:null}}}const Gee=(e,t)=>e.length===t.length&&e.every((n,r)=>{const i=t[r];return n.sessionId===i.sessionId&&n.variantId===i.variantId&&n.label===i.label&&n.brief===i.brief&&n.createdAt===i.createdAt}),tA=()=>{var ee;const e=Ce(il),t=Ce(Y1),n=((ee=Ce(Ti).deployPrototype)==null?void 0:ee.isEnabled)??!1,r=Ce(Cp),i=Ce(U8),s=ze(gw),o=ze(i1),a=ze(vw),c=ze(w$),u=ze(Kh),h=ze(z8),p=ze(Cc),m=Ce(yw),g=ze(yw),[b,x]=f.useState(""),[C,w]=f.useState(null),[E,_]=f.useState({}),[T,I]=f.useState({}),[P,M]=f.useState(null),[S,R]=f.useState([]),$=f.useRef([]);$.current=S;const[L,j]=f.useState(null),O=f.useMemo(()=>e.active?e.variants:[],[e]),H=e.active?e.sessionId:null,B=f.useMemo(()=>[...H?S.filter(se=>se.sessionId!==H):S].sort((se,ce)=>{const le=new Date(se.createdAt).getTime(),ge=new Date(ce.createdAt).getTime();return(Number.isNaN(ge)?0:ge)-(Number.isNaN(le)?0:le)}),[S,H]),Z=e.active?e.projectContext:null,K=(Z==null?void 0:Z.kind)==="fresh"?Z.workspaceRoot:t,q=f.useMemo(()=>K?`?projectPath=${encodeURIComponent(K)}`:"",[K]),te=f.useRef(null),F=f.useRef(null),V=f.useRef(null),W=f.useRef(!1),N=f.useCallback((Y,se)=>{se.button!==0&&se.pointerType==="mouse"||(V.current={kind:"live",variantId:Y,startX:se.clientX,startY:se.clientY,committed:!1})},[]),z=f.useCallback((Y,se)=>{se.button!==0&&se.pointerType==="mouse"||(V.current={kind:"past",entry:Y,startX:se.clientX,startY:se.clientY,committed:!1})},[]);f.useEffect(()=>{const Y=le=>{const ge=V.current;if(!ge)return;const ke=le.clientX-ge.startX,$e=le.clientY-ge.startY;if(!ge.committed){if(ke*ke+$e*$e<eA*eA)return;const ct=window.getSelection();if(ct&&!ct.isCollapsed){V.current=null;return}if(ge.kind==="live"){const rt=O.find(Ze=>Ze.workItemId===ge.variantId);if(!rt||rt.status!=="succeeded"){V.current=null;return}const Jt=Wee({sessionId:H,variant:rt,projectContext:Z});u({sessionId:H??"",variantId:rt.workItemId,label:rt.label||"Direction",url:Jt,runLabel:rt.runLabel,description:rt.description})}else{const{entry:rt}=ge,Jt=`/api/variants/history/${encodeURIComponent(rt.sessionId)}/${encodeURIComponent(rt.variantId)}/preview${q}`;u({sessionId:rt.sessionId,variantId:rt.variantId,label:rt.label||"Direction",url:Jt,runLabel:rt.runLabel,description:rt.brief})}ge.committed=!0}h({x:le.clientX,y:le.clientY})},se=()=>{const le=V.current;le!=null&&le.committed&&(W.current=!0),V.current=null,h(null)},ce=le=>{var ge;le.key==="Escape"&&(ge=V.current)!=null&&ge.committed&&(V.current=null,u(null),h(null))};return window.addEventListener("pointermove",Y),window.addEventListener("pointerup",se),window.addEventListener("pointercancel",se),window.addEventListener("keydown",ce),()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",se),window.removeEventListener("pointercancel",se),window.removeEventListener("keydown",ce)}},[O,H,Z,q,u,h]);const Q=f.useMemo(()=>{var se;if(L)return null;const Y=m?O.find(ce=>ce.workItemId===m):null;return Y?Y.status==="succeeded"?Y.workItemId:null:e.active?((se=O.find(ce=>{var le,ge;return ce.status==="succeeded"&&(((le=ce.preview)==null?void 0:le.kind)==="static_artifact"||((ge=ce.preview)==null?void 0:ge.kind)==="dev_server")}))==null?void 0:se.workItemId)??null:null},[m,L,e,O]),J=f.useCallback(async Y=>{var ce,le,ge,ke;if(!H)return;const se=(Y==null?void 0:Y.workItemId)??null;w({kind:"switch",variantId:se??void 0});try{if(((ce=Y==null?void 0:Y.preview)==null?void 0:ce.kind)==="static_artifact"){if(a(!1),c(null),((le=Y.refinement)==null?void 0:le.status)==="succeeded"){const rt=Y.preview.url.includes("?")?"&":"?";o(`${Y.preview.url}${rt}refinement=${encodeURIComponent(Y.refinement.workItemId)}`)}else o(Y.preview.url);s(rt=>rt+1);return}if(se&&H&&e.active&&e.projectContext.kind==="fresh"&&((ge=e.projectContext.executionPlan)==null?void 0:ge.mode)!=="vite_app"&&((ke=Y==null?void 0:Y.preview)==null?void 0:ke.kind)!=="dev_server"){a(!1),c(null),o(`/api/variants/${H}/static/${se}`),s(rt=>rt+1);return}a(!0);const $e=await fetch(`/api/variants/${H}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:se})});if(!$e.ok){mi.warn(`switch failed: HTTP ${$e.status}`),a(!1),c(null);return}const{port:ct}=await $e.json();o(null),c(ct!==null?se:null),ct!==null&&s(rt=>rt+1)}catch($e){mi.warn("preview-port switch failed",$e),a(!1),c(null)}finally{w(null)}},[H,e,s,o,a,c]),re=f.useCallback(Y=>{if(W.current){W.current=!1;return}const se=Y.status==="succeeded",ce=Y.status==="pending"||Y.status==="running";if(!se&&!ce)return;const le=O.find(ge=>ge.workItemId===m);g(Y.workItemId),j(null),se?(F.current=Y.workItemId,p(null),J(Y)):(o(null),a(!1)),yt.capture("variants_panel.preview_switched",{sessionId:H,fromVariantId:le==null?void 0:le.workItemId,toVariantId:Y.workItemId,armed:ce})},[m,H,p,g,J,O,o,a]),G=e.active?`${e.sessionId}:${e.stage}`:"inactive";f.useEffect(()=>{let Y=!1;return(async()=>{try{const se=await fetch(`/api/variants/history${q}`,{credentials:"same-origin"});if(!se.ok)return;const ce=await se.json();if(Y)return;const le=(ce.variants??[]).filter(ge=>{var ke;return((ke=ge.preview)==null?void 0:ke.kind)==="static"});if(Gee($.current,le))return;$.current=le,R(le)}catch(se){mi.warn("Failed to load past variants",se)}})(),()=>{Y=!0}},[G,q]);const X=f.useCallback(Y=>{if(W.current){W.current=!1;return}p(null),j(`${Y.sessionId}:${Y.variantId}`),g(null),a(!1),c(null),o(`/api/variants/history/${encodeURIComponent(Y.sessionId)}/${encodeURIComponent(Y.variantId)}/preview${q}`)},[j,g,o,c,p,a,q]),de=f.useCallback(async Y=>{var ce,le;const se=((le=(ce=Y.actions)==null?void 0:ce.commit)==null?void 0:le.enabled)??Y.status==="succeeded";if(!(!H||!se)){yt.capture("variants_panel.commit_clicked",{sessionId:H,variantId:Y.workItemId,variantLabel:Y.label}),w({kind:"commit",variantId:Y.workItemId});try{const ge=await fetch(`/api/variants/${H}/commit`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:Y.workItemId})});if(!ge.ok){const{message:$e,errorCode:ct}=await su(ge);mi.warn(`commit failed: HTTP ${ge.status} ${ct??""} ${$e??""}`),yt.capture("variants_panel.commit_failed",{sessionId:H,variantId:Y.workItemId,httpStatus:ge.status,errorCode:ct??null,errorMessage:$e??null}),lt.error("Couldn't send direction",{description:$e??`The server rejected the request (HTTP ${ge.status}). Try again, or pick a different direction.`});return}const ke=await ge.json().catch(()=>null);yt.capture("variants_panel.commit_succeeded",{sessionId:H,variantId:Y.workItemId,payloadKind:(ke==null?void 0:ke.payloadKind)??null,duplicate:(ke==null?void 0:ke.duplicate)??!1}),lt.success(`Sent "${Y.label}" to your project`,{description:(ke==null?void 0:ke.payloadKind)==="project-created"?`Project created at ${(ke==null?void 0:ke.destinationPath)??"destination"}.`:"Direction diff applied to your working tree (uncommitted)."}),(ke==null?void 0:ke.payloadKind)!=="project-created"&&(o(null),a(!1),s($e=>$e+1))}catch(ge){mi.warn("commit failed",ge),yt.capture("variants_panel.commit_failed",{sessionId:H,variantId:Y.workItemId,httpStatus:null,errorCode:"NETWORK_ERROR",errorMessage:ge instanceof Error?ge.message:String(ge)}),lt.error("Couldn't send direction",{description:"Network or server error. Check that the Rivet backend is reachable and try again."})}finally{w(null)}}},[H,s,o,a]),ve=f.useCallback(async(Y,se,ce)=>{yt.capture("variants_panel.deploy_clicked",{sessionId:Y,variantId:se,variantLabel:ce});try{const le=await fetch(`/api/variants/${Y}/deploy`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:se,...t?{projectPath:t}:{}})});if(!le.ok){const{message:$e,errorCode:ct}=await su(le);return mi.warn(`deploy failed: HTTP ${le.status} ${ct??""} ${$e??""}`),yt.capture("variants_panel.deploy_failed",{sessionId:Y,variantId:se,httpStatus:le.status,errorCode:ct??null,errorMessage:$e??null}),lt.error("Couldn't deploy this direction",{description:$e??`The server rejected the request (HTTP ${le.status}). Try again.`}),null}const ge=await le.json().catch(()=>null),ke=ge==null?void 0:ge.shareUrl;return ke?(await navigator.clipboard.writeText(ke).catch(()=>{}),yt.capture("variants_panel.deploy_succeeded",{sessionId:Y,variantId:se}),lt.success(`"${ce}" is live — link copied`,{action:{label:"Open",onClick:()=>window.open(ke,"_blank","noopener")}}),ke):(lt.error("Couldn't deploy this direction",{description:"The deploy host returned an unexpected response."}),null)}catch(le){return mi.warn("deploy failed",le),yt.capture("variants_panel.deploy_failed",{sessionId:Y,variantId:se,httpStatus:null,errorCode:"NETWORK_ERROR",errorMessage:le instanceof Error?le.message:String(le)}),lt.error("Couldn't deploy this direction",{description:"Network or server error. Check that the Rivet backend is reachable and try again."}),null}},[t]),we=f.useCallback(async Y=>{if(!H)return;const se=E[Y.workItemId];if(se){await navigator.clipboard.writeText(se).catch(()=>{}),lt.success("Share link copied",{action:{label:"Open",onClick:()=>window.open(se,"_blank","noopener")}});return}w({kind:"deploy",variantId:Y.workItemId});try{const ce=await ve(H,Y.workItemId,Y.label);ce&&_(le=>({...le,[Y.workItemId]:ce}))}finally{w(null)}},[H,E,ve]),je=f.useCallback(async Y=>{const se=`${Y.sessionId}:${Y.variantId}`,ce=T[se];if(ce){await navigator.clipboard.writeText(ce).catch(()=>{}),lt.success("Share link copied",{action:{label:"Open",onClick:()=>window.open(ce,"_blank","noopener")}});return}M(se);try{const le=await ve(Y.sessionId,Y.variantId,Y.label);le&&I(ge=>({...ge,[se]:le}))}finally{M(null)}},[T,ve]),Ae=f.useCallback(async()=>{if(H){w({kind:"cancel"});try{await fetch(`/api/variants/${H}/cancel`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({reason:"user-dismissed-from-panel"})}),o(null),a(!1),s(Y=>Y+1)}catch(Y){mi.warn("cancel failed",Y)}finally{w(null)}}},[H,s,o,a]),Le=f.useCallback(async Y=>{if(H){yt.capture("variants_panel.remove_clicked",{sessionId:H,variantId:Y.workItemId,variantLabelLength:Y.label.length}),w({kind:"remove",variantId:Y.workItemId});try{const se=await fetch(`/api/variants/${H}/${Y.workItemId}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:"{}"});if(!se.ok){const{message:ce}=await su(se);mi.warn(`remove failed: HTTP ${se.status} ${ce??""}`),lt.error("Couldn't remove direction",{description:ce??`The server rejected the request (HTTP ${se.status}). Try again.`});return}(Y.workItemId===Q||Y.workItemId===m)&&(g(null),o(null),a(!1),s(ce=>ce+1))}catch(se){mi.warn("remove failed",se),lt.error("Couldn't remove direction",{description:"Network or server error. Try again."})}finally{w(null)}}},[H,m,Q,g,o,a,s]),tt=f.useCallback(async Y=>{if(!K){lt.error("Couldn't remove direction",{description:"No project path available."});return}yt.capture("variants_panel.remove_past_clicked",{sessionId:Y.sessionId,variantId:Y.variantId});const se=`${Y.sessionId}:${Y.variantId}`,ce=le=>le.sessionId===Y.sessionId&&le.variantId===Y.variantId;R(le=>le.filter(ge=>!ce(ge))),L===se&&(j(null),o(null),a(!1),s(le=>le+1));try{const le=await fetch(`/api/variants/history/${encodeURIComponent(Y.sessionId)}/${encodeURIComponent(Y.variantId)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:K})});if(!le.ok){const{message:ge}=await su(le);R(ke=>ke.some(ce)?ke:[...ke,Y]),lt.error("Couldn't remove direction",{description:ge??`The server rejected the request (HTTP ${le.status}). Try again.`})}}catch(le){mi.warn("remove past failed",le),R(ge=>ge.some(ce)?ge:[...ge,Y]),lt.error("Couldn't remove direction",{description:"Network or server error. Try again."})}},[K,L,o,a,s]),[vt,Je]=f.useState(null),[ye,Ke]=f.useState(null),Dt=f.useCallback(Y=>{Ke(Y)},[]),Mt=f.useCallback(()=>{Ke(null)},[]),jt=f.useCallback(async Y=>{const se=Y.trim();if(se)try{await navigator.clipboard.writeText(se),lt.success("Description copied")}catch{lt.error("Couldn't copy description")}},[]),bn=f.useCallback(async(Y,se)=>{Ke(null);const ce=se.trim();if(!ce)return;if(Y.kind==="active"){if(!H||ce===Y.variant.label)return;yt.capture("variants_panel.rename",{sessionId:H,variantId:Y.variant.workItemId,labelLength:ce.length,past:!1});try{const ke=await fetch(`/api/variants/${H}/${Y.variant.workItemId}/rename`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({label:ce})});if(!ke.ok){const{message:$e}=await su(ke);lt.error("Couldn't rename direction",{description:$e??`The server rejected the request (HTTP ${ke.status}). Try again.`})}}catch(ke){mi.warn("rename failed",ke),lt.error("Couldn't rename direction",{description:"Network or server error. Try again."})}return}const{entry:le}=Y;if(ce===le.label.trim())return;if(!K){lt.error("Couldn't rename direction",{description:"No project path available."});return}yt.capture("variants_panel.rename",{sessionId:le.sessionId,variantId:le.variantId,labelLength:ce.length,past:!0});const ge=ke=>ke.sessionId===le.sessionId&&ke.variantId===le.variantId;R(ke=>ke.map($e=>ge($e)?{...$e,label:ce}:$e));try{const ke=await fetch(`/api/variants/history/${encodeURIComponent(le.sessionId)}/${encodeURIComponent(le.variantId)}/rename`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({label:ce,projectPath:K})});if(!ke.ok){const{message:$e}=await su(ke);R(ct=>ct.map(rt=>ge(rt)?{...rt,label:le.label}:rt)),lt.error("Couldn't rename direction",{description:$e??`The server rejected the request (HTTP ${ke.status}). Try again.`})}}catch(ke){mi.warn("rename failed",ke),R($e=>$e.map(ct=>ge(ct)?{...ct,label:le.label}:ct)),lt.error("Couldn't rename direction",{description:"Network or server error. Try again."})}},[H,K]);f.useEffect(()=>{if(te.current!==H){const se=te.current===null;if(te.current=H,F.current=null,o(null),a(!1),c(null),p(null),g(null),j(null),!se)return}if(L||!Q||e.active!==!0||F.current===Q)return;const Y=O.find(se=>se.workItemId===Q);Y&&(F.current=Q,p(null),J(Y))},[H,L,Q,e,O,J,p,g]),f.useEffect(()=>{const Y=b.trim().toLowerCase(),se=O.filter($e=>$e.status==="succeeded"&&pm(Y,$e.label,$e.runLabel)),ce=B.filter($e=>pm(Y,$e.label,$e.runLabel,$e.brief));if(se.length===0&&ce.length===0)return;const le=[...se.map($e=>({source:"live",variant:$e})),...ce.map($e=>({source:"past",entry:$e}))],ge=$e=>$e.source==="live"?`live:${$e.variant.workItemId}`:`past:${$e.entry.sessionId}:${$e.entry.variantId}`,ke=$e=>{if($e.key==="Enter"){const Nt=O.find(At=>At.workItemId===vt);Nt&&Nt.status==="succeeded"&&($e.preventDefault(),re(Nt));return}if($e.key!=="ArrowUp"&&$e.key!=="ArrowDown")return;$e.preventDefault();const ct=Q?`live:${Q}`:null,rt=L?`past:${L}`:ct,Jt=rt?le.findIndex(Nt=>ge(Nt)===rt):-1;let Ze;if(Jt===-1?Ze=$e.key==="ArrowDown"?0:le.length-1:$e.key==="ArrowDown"?Ze=Math.min(Jt+1,le.length-1):Ze=Math.max(Jt-1,0),Ze===Jt)return;const wt=le[Ze];wt.source==="live"?re(wt.variant):X(wt.entry);const De=document.querySelector(`[data-variant-key="${ge(wt)}"]`);De instanceof HTMLElement&&De.focus({preventScroll:!0})};return window.addEventListener("keydown",ke),()=>window.removeEventListener("keydown",ke)},[O,B,b,L,Q,vt,re,X]);const nn="Directions",he=O.find(Y=>Y.workItemId===Q)??null,be=L?S.find(Y=>`${Y.sessionId}:${Y.variantId}`===L)??null:null,Ue=!!(be&&n),ot=e.active?e.artifacts??[]:[],at=[...e.active?O.map(Y=>({kind:"active",variant:Y})):[],...B.map(Y=>({kind:"past",entry:Y}))],Ht=b.trim().toLowerCase(),Ut=Ht?at.filter(Y=>Y.kind==="active"?pm(Ht,Y.variant.label,Y.variant.runLabel):pm(Ht,Y.entry.label,Y.entry.runLabel,Y.entry.brief)):at;return y.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y.jsx(rte,{label:nn}),at.length>0?y.jsx("div",{className:"px-3 pt-2 pb-1",children:y.jsxs("div",{className:"relative",children:[y.jsx(a8,{size:13,className:"text-content-muted pointer-events-none absolute top-1/2 left-2 -translate-y-1/2"}),y.jsx("input",{type:"text",value:b,onChange:Y=>x(Y.target.value),placeholder:"Search variants…","aria-label":"Search variants",className:"border-main-border bg-main-input/40 text-content placeholder:text-content-muted focus:ring-content-muted/40 w-full rounded-md border py-1.5 pr-2 pl-7 text-xs focus:ring-1 focus:outline-none"})]})}):null,y.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2",children:[e.active&&O.length===0?y.jsx(ste,{stage:e.stage}):null,!e.active&&B.length===0?y.jsx(ote,{isMCPSession:r,mcpEditor:i}):null,at.length>0&&Ut.length===0?y.jsxs("p",{className:"text-content-muted px-1 py-6 text-center text-xs",children:["No variants match “",b.trim(),"”."]}):null,Ut.length>0?y.jsx(qee,{rows:Ut,activeVariantId:m??Q,activePastKey:L,busy:C,editingKey:ye,onSelectActive:re,onSelectPast:X,onActivePointerDown:N,onPastPointerDown:z,onHover:Je,onRemove:Le,onRemovePast:tt,onStartRename:Dt,onCommitRename:bn,onCancelRename:Mt,onCopyDescription:jt}):null,e.active?y.jsx(ete,{artifacts:ot}):null]}),Ue&&be?y.jsx(Xee,{entry:be,deploying:P===L,deployedUrl:L?T[L]??null:null,onDeploy:je}):null,!Ue&&e.active?y.jsx(ite,{selectedVariant:he,busy:C,canCancel:C===null,onCancel:Ae,onSend:de,onDeploy:we,canDeploy:n&&(Z==null?void 0:Z.kind)==="fresh",deployedUrl:he?E[he.workItemId]??null:null,mcpEditor:i,isMCPSession:r}):null]})},qee=({rows:e,activeVariantId:t,activePastKey:n,busy:r,editingKey:i,onSelectActive:s,onSelectPast:o,onActivePointerDown:a,onPastPointerDown:c,onHover:u,onRemove:h,onRemovePast:p,onStartRename:m,onCommitRename:g,onCancelRename:b,onCopyDescription:x})=>{const C=f.useRef(null),{activeIndex:w,itemRects:E,sessionRef:_,handlers:T,registerItem:I}=U$(C),P=(r==null?void 0:r.kind)==="switch",M=w!==null?E[w]:null;return y.jsxs("div",{ref:C,className:"relative",onMouseEnter:T.onMouseEnter,onMouseMove:T.onMouseMove,onMouseLeave:T.onMouseLeave,children:[y.jsx(ds,{children:M&&y.jsx(dn.div,{className:"bg-hover pointer-events-none absolute z-0 rounded-md",initial:{opacity:0,top:M.top,left:M.left,width:M.width,height:M.height},animate:{opacity:1,top:M.top,left:M.left,width:M.width,height:M.height},exit:{opacity:0,transition:{duration:.06}},transition:{...Ka.fast,opacity:{duration:.08}}},_.current)}),y.jsx("ul",{className:"relative",children:e.map((S,R)=>{const $=S.kind==="active"?`live:${S.variant.workItemId}`:`past:${S.entry.sessionId}:${S.entry.variantId}`,L=S.kind==="active"?S.variant.workItemId===t:`${S.entry.sessionId}:${S.entry.variantId}`===n;return y.jsx(Kee,{rowKey:$,row:S,index:R,isSelected:L,isEditing:i===$,isSwitchInFlight:P,busy:r,registerItem:I,onSelectActive:s,onSelectPast:o,onActivePointerDown:a,onPastPointerDown:c,onHover:u,onRemove:h,onRemovePast:p,onStartRename:m,onCommitRename:g,onCancelRename:b,onCopyDescription:x},$)})})]})},Kee=({rowKey:e,row:t,index:n,isSelected:r,isEditing:i,isSwitchInFlight:s,busy:o,registerItem:a,onSelectActive:c,onSelectPast:u,onActivePointerDown:h,onPastPointerDown:p,onHover:m,onRemove:g,onRemovePast:b,onStartRename:x,onCommitRename:C,onCancelRename:w,onCopyDescription:E})=>{var F,V,W,N;const _=f.useRef(null);Uee(a,n,_);const T=t.kind==="active",I=t.kind==="active"?t.variant:null,P=t.kind==="past"?t.entry:null,M=T?I.status==="succeeded":!0,S=T&&(I.status==="pending"||I.status==="running"),R=T?M||S:!0,$=T&&I.status==="failed",L=T&&I.status==="cancelled",j=T&&(((F=I.refinement)==null?void 0:F.status)==="pending"||((V=I.refinement)==null?void 0:V.status)==="running"),O=T&&((W=I.refinement)==null?void 0:W.status)==="succeeded",H=T&&((N=I.refinement)==null?void 0:N.status)==="failed",B=T&&(!R||s),Z=T&&(o==null?void 0:o.kind)==="remove"&&o.variantId===I.workItemId,K=T?I.label||`Direction ${n+1}`:P.label.trim()||"Untitled direction",q=T?I.runLabel:P.runLabel,te=T?I.description:P.brief;return i?y.jsx("li",{ref:_,"data-proximity-index":n,className:"group relative z-10",children:y.jsx("div",{className:"bg-main-input flex w-full items-start gap-2 rounded-md px-3 py-2",children:y.jsxs("span",{className:"min-w-0 flex-1",children:[y.jsx(Yee,{initial:K,onCommit:z=>C(t,z),onCancel:w}),te&&y.jsx("span",{className:"text-content-muted mt-1 line-clamp-2 block text-xs leading-snug",children:te})]})})}):y.jsxs("li",{ref:_,"data-proximity-index":n,className:"group relative z-10",children:[y.jsxs("div",{role:"button",tabIndex:R?0:-1,"data-variant-id":T?I.workItemId:void 0,"data-variant-key":e,onClick:()=>{if(B)return;const z=window.getSelection();z&&!z.isCollapsed||(t.kind==="active"?c(t.variant):u(t.entry))},onKeyDown:z=>{B||(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),z.stopPropagation(),t.kind==="active"?c(t.variant):u(t.entry))},onPointerDown:z=>{B||(t.kind==="active"?M&&h(t.variant.workItemId,z):p(t.entry,z))},"aria-pressed":R?r:void 0,"aria-disabled":T?!R:void 0,"aria-busy":S,onMouseEnter:T?()=>m(I.workItemId):void 0,onMouseLeave:T?()=>m(null):void 0,className:zn("focus-visible:ring-content-muted/40 flex w-full items-start gap-2 rounded-md px-3 py-2 text-left transition-colors focus:outline-none focus-visible:ring-1",r&&"bg-main-input ring-content-muted/40 ring-1 ring-inset",M&&"cursor-grab active:cursor-grabbing",S&&"cursor-pointer",!M&&!S&&"cursor-not-allowed opacity-60",B&&"cursor-not-allowed opacity-50"),style:M?{touchAction:"none"}:void 0,children:[S&&y.jsx(K8,{className:"text-content-muted mt-0.5 shrink-0 text-sm"}),y.jsxs("span",{className:"min-w-0 flex-1",children:[y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx("span",{title:"Double-click to rename",onDoubleClick:z=>{z.stopPropagation(),x(e)},className:zn("min-w-0 flex-1 cursor-text truncate text-sm font-medium select-text",M||r?"text-content":"text-content-muted"),children:K}),$&&y.jsx(Of,{label:"Failed"}),L&&y.jsx(Of,{label:"Cancelled"}),j&&y.jsx(Of,{label:"Refining"}),O&&y.jsx(Of,{label:"Refined"}),H&&y.jsx(Of,{label:"Refine failed"})]}),te&&y.jsx("span",{className:"text-content-muted mt-0.5 line-clamp-2 block cursor-text text-xs leading-snug select-text",children:te})]}),y.jsx("span",{className:"relative mt-0.5 ml-1 flex h-5 shrink-0 items-center justify-end",children:q&&y.jsx("span",{className:zn("max-w-[8rem] truncate rounded px-1.5 py-0.5 text-[10px] font-medium opacity-100 transition-opacity duration-150 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0"),style:z$(q),children:q})})]}),y.jsxs("div",{className:zn("absolute top-1.5 right-2 flex items-center gap-0.5 transition-opacity duration-150","pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100"),children:[te&&y.jsx("button",{type:"button","aria-label":"Copy description",title:"Copy description",onClick:z=>{z.stopPropagation(),E(te)},onPointerDown:z=>z.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:y.jsx(H1,{size:13,weight:"bold"})}),y.jsx("button",{type:"button","aria-label":"Rename direction",title:"Rename direction",onClick:z=>{z.stopPropagation(),x(e)},onPointerDown:z=>z.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:y.jsx(tM,{size:13,weight:"bold"})}),y.jsx("button",{type:"button","data-variant-remove-id":t.kind==="active"?t.variant.workItemId:void 0,"aria-label":"Remove direction",title:"Remove direction",disabled:Z,onClick:z=>{z.stopPropagation(),t.kind==="active"?g(t.variant):b(t.entry)},onPointerDown:z=>z.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 ml-1 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",children:y.jsx(mM,{size:13,weight:"bold"})})]})]})},Yee=({initial:e,onCommit:t,onCancel:n})=>{const[r,i]=f.useState(e),s=f.useRef(!1),o=f.useCallback(c=>{c&&(c.focus(),c.select())},[]),a=c=>{s.current||(s.current=!0,c?t(r):n())};return y.jsx("input",{ref:o,type:"text",value:r,maxLength:120,"aria-label":"Rename direction",onChange:c=>i(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?(c.preventDefault(),a(!0)):c.key==="Escape"&&(c.preventDefault(),a(!1))},onBlur:()=>a(!0),onClick:c=>c.stopPropagation(),onPointerDown:c=>c.stopPropagation(),className:"border-content-muted/40 bg-main text-content focus:ring-content-muted/50 w-full rounded border px-1.5 py-0.5 text-sm font-medium focus:ring-1 focus:outline-none"})},Of=({label:e})=>y.jsx("span",{className:"bg-main-input text-content-muted shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase",children:e}),Xee=({entry:e,deploying:t,deployedUrl:n,onDeploy:r})=>{const s=t?"Deploying…":n?"Copy link":"Deploy & Share";return y.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"text-content truncate text-sm font-medium",children:e.label.trim()||"Untitled direction"}),n?y.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}),y.jsxs("button",{type:"button",onClick:()=>r(e),disabled:t,title:n?`Copy share link (${n})`:"Deploy this direction and get a public link to share",className:"border-main-border text-content hover:bg-main-input flex shrink-0 items-center gap-1 rounded-md border px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[n&&!t?y.jsx(H1,{size:12,weight:"bold"}):null,s]})]})},Qee={agent_browser:"Browser extracted",cache:"Cached",static:"Bundled catalog",manual:"Manual"},Jee={design_context:"DESIGN.md",source_context:"Source",qa_report:"QA",asset:"Asset"},ete=({artifacts:e})=>{const[t,n]=f.useState(null),r=f.useMemo(()=>t&&e.some(s=>s.id===t)?t:null,[e,t]);if(e.length===0)return null;const i=s=>{n(o=>o===s?null:s)};return y.jsxs("section",{"aria-label":"Directions session artifacts",className:"mt-4",children:[y.jsx("div",{className:"flex shrink-0 items-center px-3 py-2",children:y.jsx("span",{className:"text-content truncate text-sm font-medium",children:"Artifacts"})}),y.jsx("ul",{className:"mt-2 space-y-1 px-1",children:e.map(s=>y.jsx(tte,{artifact:s,isExpanded:s.id===r,onToggle:()=>i(s.id)},s.id))})]})},tte=({artifact:e,isExpanded:t,onToggle:n})=>{const r=Jee[e.kind],i=e.source?Qee[e.source]:null,s=[e.kind==="design_context"?null:i,e.summary].filter(Boolean).join(" · "),o=e.kind==="design_context"&&!!e.viewUrl,a=`${t?"Hide":"View"} ${r} artifact${e.label?`: ${e.label}`:""}`;return o?y.jsx("li",{className:"border-main-border rounded-md border",children:y.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs",children:[y.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"border-content-muted/30 bg-main-input text-content-muted shrink-0 rounded-full border px-2 py-0.5 text-[9px] font-semibold tracking-wide uppercase",children:r}),y.jsx("span",{className:"text-content truncate text-xs font-medium",children:e.label})]}),s?y.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:s}):null]}),y.jsx("a",{href:e.viewUrl,target:"_blank",rel:"noreferrer","aria-label":`Open ${r} artifact${e.label?`: ${e.label}`:""}`,className:"text-content-muted hover:bg-main-input hover:text-content focus-visible:ring-content-muted/40 shrink-0 rounded p-1 transition-colors focus:outline-none focus-visible:ring-1",children:y.jsx(i8,{className:"h-3.5 w-3.5",weight:"bold"})})]})}):y.jsxs("li",{className:"border-main-border rounded-md border",children:[y.jsxs("button",{type:"button",onClick:n,"aria-expanded":t,"aria-label":a,className:"hover:bg-main-input flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs transition-colors",children:[y.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-content-muted text-[10px] font-semibold tracking-wide uppercase",children:r}),y.jsx("span",{className:"text-content truncate text-xs font-medium",children:e.label})]}),s?y.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:s}):null]}),y.jsx("span",{className:"text-content-muted shrink-0 text-[11px]",children:t?"Hide":"View"})]}),t?y.jsx("div",{className:"border-main-border bg-main-light border-t px-3 py-2",children:y.jsx(nte,{artifact:e})}):null]})},nte=({artifact:e})=>y.jsxs("div",{className:"text-content-muted space-y-1 text-[11px]",children:[e.summary?y.jsx("p",{children:e.summary}):null,e.path?y.jsxs("p",{children:["Stored at ",e.path]}):null,!e.summary&&!e.path?y.jsx("p",{children:"No inline content available for this artifact."}):null]}),rte=({label:e})=>y.jsx("div",{className:"flex shrink-0 items-center px-3 py-2",children:y.jsx("span",{className:"text-content truncate text-sm font-medium",title:e,children:e})}),ite=({selectedVariant:e,busy:t,canCancel:n,onCancel:r,onSend:i,onDeploy:s,canDeploy:o,deployedUrl:a,mcpEditor:c,isMCPSession:u})=>{var T,I,P,M,S,R;const h=((T=e==null?void 0:e.refinement)==null?void 0:T.status)==="pending"||((I=e==null?void 0:e.refinement)==null?void 0:I.status)==="running",p=e?(((M=(P=e.actions)==null?void 0:P.commit)==null?void 0:M.enabled)??e.status==="succeeded")&&!h:!1,m=p&&t===null,g=(t==null?void 0:t.kind)==="commit"&&t.variantId===(e==null?void 0:e.workItemId),b=(t==null?void 0:t.kind)==="deploy"&&t.variantId===(e==null?void 0:e.workItemId),x=o&&p,w=b?"Deploying…":a?"Copy link":"Deploy & Share",E=u?Z$(c):"agent",_=g?"Sending…":`Send to ${E}`;return y.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-2 border-t px-3 pt-2 pb-4",children:[y.jsx("button",{type:"button",onClick:r,disabled:!n,className:"text-content-muted hover:bg-main-input hover:text-content rounded-md px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:"Clear all"}),y.jsxs("div",{className:"flex items-center gap-2",children:[x?y.jsxs("button",{type:"button",onClick:()=>{e&&s(e)},disabled:t!==null,title:a?`Copy share link (${a})`:"Build this direction and get a public link to share for feedback",className:"border-main-border text-content hover:bg-main-input flex items-center gap-1 rounded-md border px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[a&&!b?y.jsx(H1,{size:12,weight:"bold"}):null,w]}):null,y.jsx("button",{type:"button",onClick:()=>{e&&i(e)},disabled:!m,title:h?"Wait for this refinement to finish before sending":(R=(S=e==null?void 0:e.actions)==null?void 0:S.commit)==null?void 0:R.reason,className:"bg-secondary text-secondary-foreground hover:bg-accent rounded-md px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:_})]})]})},ste=({stage:e})=>y.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[y.jsx("div",{className:"text-content text-sm",children:"No directions ready yet."}),y.jsxs("div",{className:"text-content-muted text-xs",children:["Stage: ",e]})]});function Z$(e){return e==="cursor"?"Cursor":e==="codex"?"Codex":e==="claude-desktop"?"Claude":"Claude Code"}const nA="Try different ways to create a dropdown that feels fluid and dynamic",ote=({isMCPSession:e=!1,mcpEditor:t=null})=>{const[n,r]=f.useState(!1),i=Z$(t),s=e?i:"your coding agent",o=()=>{navigator.clipboard.writeText(nA).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})};return y.jsxs("div",{className:"flex flex-col items-start gap-3 px-2 py-2",children:[y.jsxs("p",{className:"text-content text-sm font-medium",children:["Go to ",s," to create directions"]}),y.jsxs("div",{className:"w-full",children:[y.jsx("p",{className:"text-content-muted mb-2 text-xs",children:"Here's a sample prompt to use:"}),y.jsxs("div",{className:"border-main-border bg-main-input relative rounded-md border px-3 py-2.5 pr-8",children:[y.jsxs("p",{className:"text-content-muted text-xs leading-snug",children:["“",nA,"”"]}),y.jsx("button",{type:"button",onClick:o,className:"text-content-muted hover:bg-main-border hover:text-content absolute top-2 right-2 rounded p-0.5 transition-colors",title:"Copy to clipboard",children:n?y.jsx(za,{className:"h-3.5 w-3.5 text-emerald-500",weight:"bold"}):y.jsx(H1,{className:"h-3.5 w-3.5",weight:"bold"})})]})]})]})},W$={pill:{item:"rounded-[20px]",bg:"rounded-[20px]",focusRing:"rounded-[22px]",mergedBg:"rounded-2xl",container:"rounded-3xl",button:"rounded-[20px]",input:"rounded-[20px]"},rounded:{item:"rounded-lg",bg:"rounded-lg",focusRing:"rounded-[10px]",mergedBg:"rounded-lg",container:"rounded-xl",button:"rounded-lg",input:"rounded-lg"}},G$=f.createContext(null);function Md(){const e=f.useContext(G$);return e?e.classes:W$.pill}function ate(e){const t=document.documentElement;t.classList.add("transitioning"),t.offsetHeight,e(),setTimeout(()=>t.classList.remove("transitioning"),200)}function lte({children:e,defaultShape:t="pill"}){const[n,r]=f.useState(t),i=f.useCallback(s=>{ate(()=>r(s))},[]);return y.jsx(G$.Provider,{value:{shape:n,setShape:i,classes:W$[n]},children:e})}function cte({value:e,onValueChange:t,options:n,className:r,"aria-label":i}){const s=Md(),o=f.useId();return y.jsx("div",{role:"tablist","aria-label":i,className:zn("relative flex gap-1",r),children:n.map(a=>{const c=a.value===e;return y.jsxs("button",{type:"button",role:"tab","aria-selected":c,"data-cy":a["data-cy"],onClick:()=>t(a.value),className:zn("relative flex-1 select-none px-3 py-1 text-xs font-medium outline-none transition-colors",s.item,c?"text-content":"text-content-subtle hover:text-content"),children:[c?y.jsx(dn.span,{layoutId:o,className:zn("bg-main-input absolute inset-0",s.bg),transition:Ka.fast}):null,y.jsx("span",{className:"relative z-10",children:a.label})]},a.value)})})}const wb=$t("StreamingUtils"),ute=async(e,t)=>{var m;const{url:n,method:r="POST",headers:i={},body:s,signal:o}=e,{onChunk:a,onProgress:c,onComplete:u,onError:h,onCanceled:p}=t;try{const g=await fetch(n,{method:r,headers:{"Content-Type":"application/json",...i},body:JSON.stringify(s),signal:o});if(!g.ok){if(g.status===401)throw new Error("Authentication required. Please run `rivet logout` and `rivet login` to re-authenticate.");if(g.status===429){const E=await g.json().catch(()=>({})),_=E.message||E.error||"";throw _.includes("SPEND_LIMIT_EXCEEDED:")?new Error(_):new Error(_||"Rate limit exceeded. Please try again shortly.")}throw new Error(`HTTP error! status: ${g.status}`)}const b=(m=g.body)==null?void 0:m.getReader(),x=new TextDecoder;if(!b)throw new Error("No response body reader available");let C="",w="";for(;;){const{done:E,value:_}=await b.read();if(E)break;C+=x.decode(_,{stream:!0});const T=C.split(`
|
|
70
|
+
`),()=>{var R;(R=a.current)==null||R.removeAttribute("data-motion-pop-id"),S.contains(M)&&S.removeChild(M)}},[t]),y.jsx(FX,{isPresent:t,childRef:a,sizeRef:c,pop:s,children:s===!1?e:f.cloneElement(e,{ref:p})})}const VX=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:s,mode:o,anchorX:a,anchorY:c,root:u})=>{const h=B1(HX),p=f.useId();let m=!0,g=f.useMemo(()=>(m=!1,{id:p,initial:t,isPresent:n,custom:i,onExitComplete:b=>{h.set(b,!0);for(const x of h.values())if(!x)return;r&&r()},register:b=>(h.set(b,!1),()=>h.delete(b))}),[n,h,r]);return s&&m&&(g={...g}),f.useMemo(()=>{h.forEach((b,x)=>h.set(x,!1))},[n]),f.useEffect(()=>{!n&&!h.size&&r&&r()},[n]),e=y.jsx(OX,{pop:o==="popLayout",isPresent:n,anchorX:a,anchorY:c,root:u,children:e}),y.jsx(z1.Provider,{value:g,children:e})};function HX(){return new Map}function qR(e=!0){const t=f.useContext(z1);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=t,s=f.useId();f.useEffect(()=>{if(e)return i(s)},[e]);const o=f.useCallback(()=>e&&r&&r(s),[s,r,e]);return!n&&r?[!1,o]:[!0]}const am=e=>e.key||"";function P_(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const ds=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:s="sync",propagate:o=!1,anchorX:a="left",anchorY:c="top",root:u})=>{const[h,p]=qR(o),m=f.useMemo(()=>P_(e),[e]),g=o&&!h?[]:m.map(am),b=f.useRef(!0),x=f.useRef(m),C=B1(()=>new Map),w=f.useRef(new Set),[E,_]=f.useState(m),[T,I]=f.useState(m);u8(()=>{b.current=!1,x.current=m;for(let S=0;S<T.length;S++){const R=am(T[S]);g.includes(R)?(C.delete(R),w.current.delete(R)):C.get(R)!==!0&&C.set(R,!1)}},[T,g.length,g.join("-")]);const P=[];if(m!==E){let S=[...m];for(let R=0;R<T.length;R++){const $=T[R],L=am($);g.includes(L)||(S.splice(R,0,$),P.push($))}return s==="wait"&&P.length&&(S=P),I(P_(S)),_(m),null}const{forceRender:M}=f.useContext(c8);return y.jsx(y.Fragment,{children:T.map(S=>{const R=am(S),$=o&&!h?!1:m===T||g.includes(R),L=()=>{if(w.current.has(R))return;if(C.has(R))w.current.add(R),C.set(R,!0);else return;let j=!0;C.forEach(O=>{O||(j=!1)}),j&&(M==null||M(),I(x.current),o&&(p==null||p()),r&&r())};return y.jsx(VX,{isPresent:$,initial:!b.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:s,root:u,onExitComplete:$?void 0:L,anchorX:a,anchorY:c,children:S},R)})})},KR=f.createContext({strict:!1}),I_={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let M_=!1;function BX(){if(M_)return;const e={};for(const t in I_)e[t]={isEnabled:n=>I_[t].some(r=>!!n[r])};ER(e),M_=!0}function YR(){return BX(),_Y()}function zX(e){const t=YR();for(const n in e)t[n]={...t[n],...e[n]};ER(t)}const UX=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function n1(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||UX.has(e)}let XR=e=>!n1(e);function ZX(e){typeof e=="function"&&(XR=t=>t.startsWith("on")?!n1(t):e(t))}try{ZX(require("@emotion/is-prop-valid").default)}catch{}function WX(e,t,n){const r={};for(const i in e)i==="values"&&typeof e.values=="object"||Cr(e[i])||(XR(i)||n===!0&&n1(i)||!t&&!n1(i)||e.draggable&&i.startsWith("onDrag"))&&(r[i]=e[i]);return r}const G1=f.createContext({});function GX(e,t){if(W1(e)){const{initial:n,animate:r}=e;return{initial:n===!1||Zh(n)?n:void 0,animate:Zh(r)?r:void 0}}return e.inherit!==!1?t:{}}function qX(e){const{initial:t,animate:n}=GX(e,f.useContext(G1));return f.useMemo(()=>({initial:t,animate:n}),[R_(t),R_(n)])}function R_(e){return Array.isArray(e)?e.join(" "):e}const L8=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function QR(e,t,n){for(const r in t)!Cr(t[r])&&!MR(r,n)&&(e[r]=t[r])}function KX({transformTemplate:e},t){return f.useMemo(()=>{const n=L8();return $8(n,t,e),Object.assign({},n.vars,n.style)},[t])}function YX(e,t){const n=e.style||{},r={};return QR(r,n,e),Object.assign(r,KX(e,t)),r}function XX(e,t){const n={},r=YX(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const JR=()=>({...L8(),attrs:{}});function QX(e,t,n,r){const i=f.useMemo(()=>{const s=JR();return RR(s,t,DR(r),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};QR(s,e.style,e),i.style={...s,...i.style}}return i}const JX=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function j8(e){return typeof e!="string"||e.includes("-")?!1:!!(JX.indexOf(e)>-1||/[A-Z]/u.test(e))}function eQ(e,t,n,{latestValues:r},i,s=!1,o){const c=(o??j8(e)?QX:XX)(t,r,i,e),u=WX(t,typeof e=="string",s),h=e!==f.Fragment?{...u,...c,ref:n}:{},{children:p}=t,m=f.useMemo(()=>Cr(p)?p.get():p,[p]);return f.createElement(e,{...h,children:m})}function tQ({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:nQ(n,r,i,e),renderState:t()}}function nQ(e,t,n,r){const i={},s=r(e,{});for(const m in s)i[m]=ig(s[m]);let{initial:o,animate:a}=e;const c=W1(e),u=kR(e);t&&u&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),a===void 0&&(a=t.animate));let h=n?n.initial===!1:!1;h=h||o===!1;const p=h?a:o;if(p&&typeof p!="boolean"&&!Z1(p)){const m=Array.isArray(p)?p:[p];for(let g=0;g<m.length;g++){const b=S8(e,m[g]);if(b){const{transitionEnd:x,transition:C,...w}=b;for(const E in w){let _=w[E];if(Array.isArray(_)){const T=h?_.length-1:0;_=_[T]}_!==null&&(i[E]=_)}for(const E in x)i[E]=x[E]}}}return i}const e$=e=>(t,n)=>{const r=f.useContext(G1),i=f.useContext(z1),s=()=>tQ(e,t,r,i);return n?s():B1(s)},rQ=e$({scrapeMotionValuesFromProps:D8,createRenderState:L8}),iQ=e$({scrapeMotionValuesFromProps:NR,createRenderState:JR}),sQ=Symbol.for("motionComponentSymbol");function oQ(e,t,n){const r=f.useRef(n);f.useInsertionEffect(()=>{r.current=n});const i=f.useRef(null);return f.useCallback(s=>{var a;s&&((a=e.onMount)==null||a.call(e,s)),t&&(s?t.mount(s):t.unmount());const o=r.current;if(typeof o=="function")if(s){const c=o(s);typeof c=="function"&&(i.current=c)}else i.current?(i.current(),i.current=null):o(s);else o&&(o.current=s)},[t])}const t$=f.createContext({});function Cu(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function aQ(e,t,n,r,i,s){var _,T;const{visualElement:o}=f.useContext(G1),a=f.useContext(KR),c=f.useContext(z1),u=f.useContext(N8),h=u.reducedMotion,p=u.skipAnimations,m=f.useRef(null),g=f.useRef(!1);r=r||a.renderer,!m.current&&r&&(m.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:h,skipAnimations:p,isSVG:s}),g.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const b=m.current,x=f.useContext(t$);b&&!b.projection&&i&&(b.type==="html"||b.type==="svg")&&lQ(m.current,n,i,x);const C=f.useRef(!1);f.useInsertionEffect(()=>{b&&C.current&&b.update(n,c)});const w=n[cR],E=f.useRef(!!w&&typeof window<"u"&&!((_=window.MotionHandoffIsComplete)!=null&&_.call(window,w))&&((T=window.MotionHasOptimisedAnimation)==null?void 0:T.call(window,w)));return u8(()=>{g.current=!0,b&&(C.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),E.current&&b.animationState&&b.animationState.animateChanges())}),f.useEffect(()=>{b&&(!E.current&&b.animationState&&b.animationState.animateChanges(),E.current&&(queueMicrotask(()=>{var I;(I=window.MotionHandoffMarkAsComplete)==null||I.call(window,w)}),E.current=!1),b.enteringChildren=void 0)}),b}function lQ(e,t,n,r){const{layoutId:i,layout:s,drag:o,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutAnchor:h,layoutCrossfade:p}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:n$(e.parent)),e.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&Cu(a),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,crossfade:p,layoutScroll:c,layoutRoot:u,layoutAnchor:h})}function n$(e){if(e)return e.options.allowProjection!==!1?e.projection:n$(e.parent)}function mb(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&zX(r);const s=n?n==="svg":j8(e),o=s?iQ:rQ;function a(u,h){let p;const m={...f.useContext(N8),...u,layoutId:cQ(u)},{isStatic:g}=m,b=qX(u),x=o(u,g);if(!g&&typeof window<"u"){uQ();const C=dQ(m);p=C.MeasureLayout,b.visualElement=aQ(e,x,m,i,C.ProjectionNode,s)}return y.jsxs(G1.Provider,{value:b,children:[p&&b.visualElement?y.jsx(p,{visualElement:b.visualElement,...m}):null,eQ(e,u,oQ(x,b.visualElement,h),x,g,t,s)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=f.forwardRef(a);return c[sQ]=e,c}function cQ({layoutId:e}){const t=f.useContext(c8).id;return t&&e!==void 0?t+"-"+e:e}function uQ(e,t){f.useContext(KR).strict}function dQ(e){const t=YR(),{drag:n,layout:r}=t;if(!n&&!r)return{};const i={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function fQ(e,t){if(typeof Proxy>"u")return mb;const n=new Map,r=(s,o)=>mb(s,o,e,t),i=(s,o)=>r(s,o);return new Proxy(i,{get:(s,o)=>o==="create"?r:(n.has(o)||n.set(o,mb(o,void 0,e,t)),n.get(o))})}const hQ=(e,t)=>t.isSVG??j8(e)?new zY(t):new jY(t,{allowProjection:e!==f.Fragment});class pQ extends nl{constructor(t){super(t),t.animationState||(t.animationState=qY(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Z1(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let mQ=0;class gQ extends nl{constructor(){super(...arguments),this.id=mQ++,this.isExitComplete=!1}update(){var s;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;if(t&&r===!1){if(this.isExitComplete){const{initial:o,custom:a}=this.node.getProps();if(typeof o=="string"||typeof o=="object"&&o!==null&&!Array.isArray(o)){const c=oc(this.node,o,a);if(c){const{transition:u,transitionEnd:h,...p}=c;for(const m in p)(s=this.node.getValue(m))==null||s.jump(p[m])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const vQ={animation:{Feature:pQ},exit:{Feature:gQ}};function xp(e){return{point:{x:e.pageX,y:e.pageY}}}const yQ=e=>t=>P8(t)&&e(t,xp(t));function Sh(e,t,n,r){return Wh(e,t,yQ(n),r)}const r$=({current:e})=>e?e.ownerDocument.defaultView:null,$_=(e,t)=>Math.abs(e-t);function bQ(e,t){const n=$_(e.x,t.x),r=$_(e.y,t.y);return Math.sqrt(n**2+r**2)}const D_=new Set(["auto","scroll"]);class i${constructor(t,n,{transformPagePoint:r,contextWindow:i=window,dragSnapToOrigin:s=!1,distanceThreshold:o=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=g=>{this.handleScroll(g.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=lm(this.lastRawMoveEventInfo,this.transformPagePoint));const g=gb(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,x=bQ(g.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!x)return;const{point:C}=g,{timestamp:w}=br;this.history.push({...C,timestamp:w});const{onStart:E,onMove:_}=this.handlers;b||(E&&E(this.lastMoveEvent,g),this.startEvent=this.lastMoveEvent),_&&_(this.lastMoveEvent,g)},this.handlePointerMove=(g,b)=>{this.lastMoveEvent=g,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=lm(b,this.transformPagePoint),vn.update(this.updatePoint,!0)},this.handlePointerUp=(g,b)=>{this.end();const{onEnd:x,onSessionEnd:C,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=gb(g.type==="pointercancel"?this.lastMoveEventInfo:lm(b,this.transformPagePoint),this.history);this.startEvent&&x&&x(g,E),C&&C(g,E)},!P8(t))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=o,this.contextWindow=i||window;const c=xp(t),u=lm(c,this.transformPagePoint),{point:h}=u,{timestamp:p}=br;this.history=[{...h,timestamp:p}];const{onSessionStart:m}=n;m&&m(t,gb(u,this.history)),this.removeListeners=vp(Sh(this.contextWindow,"pointermove",this.handlePointerMove),Sh(this.contextWindow,"pointerup",this.handlePointerUp),Sh(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(D_.has(r.overflowX)||D_.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,i=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},s={x:i.x-n.x,y:i.y-n.y};s.x===0&&s.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(t,i),vn.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Wa(this.updatePoint)}}function lm(e,t){return t?{point:t(e.point)}:e}function N_(e,t){return{x:e.x-t.x,y:e.y-t.y}}function gb({point:e},t){return{point:e,delta:N_(e,s$(t)),offset:N_(e,xQ(t)),velocity:wQ(t,.1)}}function xQ(e){return e[0]}function s$(e){return e[e.length-1]}function wQ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=s$(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Si(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Si(t)*2&&(r=e[1]);const s=Vi(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};const o={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function kQ(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?gn(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?gn(n,e,r.max):Math.min(e,n)),e}function L_(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function CQ(e,{top:t,left:n,bottom:r,right:i}){return{x:L_(e.x,n,i),y:L_(e.y,t,r)}}function j_(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function EQ(e,t){return{x:j_(e.x,t.x),y:j_(e.y,t.y)}}function SQ(e,t){let n=.5;const r=Br(e),i=Br(t);return i>r?n=zh(t.min,t.max-r,e.min):r>i&&(n=zh(e.min,e.max-i,t.min)),Xs(0,1,n)}function _Q(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const lw=.35;function AQ(e=lw){return e===!1?e=0:e===!0&&(e=lw),{x:F_(e,"left","right"),y:F_(e,"top","bottom")}}function F_(e,t,n){return{min:O_(e,t),max:O_(e,n)}}function O_(e,t){return typeof e=="number"?e:e[t]||0}const TQ=new WeakMap;class PQ{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ir(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const s=p=>{n&&this.snapToCursor(xp(p).point),this.stopAnimation()},o=(p,m)=>{const{drag:g,dragPropagation:b,onDragStart:x}=this.getProps();if(g&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=nY(g),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ns(w=>{let E=this.getAxisMotionValue(w).get()||0;if(Gs.test(E)){const{projection:_}=this.visualElement;if(_&&_.layout){const T=_.layout.layoutBox[w];T&&(E=Br(T)*(parseFloat(E)/100))}}this.originPoint[w]=E}),x&&vn.update(()=>x(p,m),!1,!0),Q4(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},a=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m;const{dragPropagation:g,dragDirectionLock:b,onDirectionLock:x,onDrag:C}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:w}=m;if(b&&this.currentDirection===null){this.currentDirection=MQ(w),this.currentDirection!==null&&x&&x(this.currentDirection);return}this.updateAxis("x",m.point,w),this.updateAxis("y",m.point,w),this.visualElement.render(),C&&vn.update(()=>C(p,m),!1,!0)},c=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m,this.stop(p,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new i$(t,{onSessionStart:s,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:r,contextWindow:r$(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,i=n||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!i||!r)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&vn.postRender(()=>a(r,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:i}=this.getProps();if(!r||!cm(t,i,this.currentDirection))return;const s=this.getAxisMotionValue(t);let o=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(o=kQ(o,this.constraints[t],this.elastic[t])),s.set(o)}resolveConstraints(){var s;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)==null?void 0:s.layout,i=this.constraints;t&&Cu(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=CQ(r.layoutBox,t):this.constraints=!1,this.elastic=AQ(n),i!==this.constraints&&!Cu(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&Ns(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=_Q(r.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Cu(t))return!1;const r=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;i.root&&(i.root.scroll=void 0,i.root.updateScroll());const s=MY(r,i.root,this.visualElement.getTransformPagePoint());let o=EQ(i.layout.layoutBox,s);if(n){const a=n(TY(o));this.hasMutatedConstraints=!!a,a&&(o=_R(a))}return o}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=Ns(h=>{if(!cm(h,n,this.currentDirection))return;let p=c&&c[h]||{};(o===!0||o===h)&&(p={min:0,max:0});const m=i?200:1e6,g=i?40:1e7,b={type:"inertia",velocity:r?t[h]:0,bounceStiffness:m,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...s,...p};return this.startAxisValueAnimation(h,b)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return Q4(this.visualElement,t),r.start(E8(t,r,0,n,this.visualElement,!1))}stopAnimation(){Ns(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps()[n];return i||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){Ns(n=>{const{drag:r}=this.getProps();if(!cm(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n],c=s.get()||0;s.set(t[n]-gn(o,a,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Cu(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Ns(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();i[o]=SQ({min:c,max:c},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),Ns(o=>{if(!cm(o,t,null))return;const a=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];a.set(gn(c,u,i[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;TQ.set(this.visualElement,this);const t=this.visualElement.current,n=Sh(t,"pointerdown",u=>{const{drag:h,dragListener:p=!0}=this.getProps(),m=u.target,g=m!==t&&lY(m);h&&p&&!g&&this.start(u)});let r;const i=()=>{const{dragConstraints:u}=this.getProps();Cu(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),r||(r=IQ(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,o=s.addEventListener("measure",i);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),vn.read(i);const a=Wh(window,"resize",()=>this.scalePositionWithinConstraints()),c=s.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:h})=>{this.isDragging&&h&&(Ns(p=>{const m=this.getAxisMotionValue(p);m&&(this.originPoint[p]+=u[p].translate,m.set(m.get()+u[p].translate))}),this.visualElement.render())}));return()=>{a(),n(),o(),c&&c(),r&&r()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:o=lw,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function V_(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function IQ(e,t,n){const r=GS(e,V_(n)),i=GS(t,V_(n));return()=>{r(),i()}}function cm(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function MQ(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class RQ extends nl{constructor(t){super(t),this.removeGroupControls=zi,this.removeListeners=zi,this.controls=new PQ(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||zi}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const vb=e=>(t,n)=>{e&&vn.update(()=>e(t,n),!1,!0)};class $Q extends nl{constructor(){super(...arguments),this.removePointerDownListener=zi}onPointerDown(t){this.session=new i$(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:r$(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:vb(t),onStart:vb(n),onMove:vb(r),onEnd:(s,o)=>{delete this.session,i&&vn.postRender(()=>i(s,o))}}}mount(){this.removePointerDownListener=Sh(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let yb=!1;class DQ extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=t;s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),yb&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),sg.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,{projection:o}=r;return o&&(o.isPresent=s,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),yb=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==s?o.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?o.promote():o.relegate()||vn.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:r}=t;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),T8.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=t;yb=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function o$(e){const[t,n]=qR(),r=f.useContext(c8);return y.jsx(DQ,{...e,layoutGroup:r,switchLayoutGroup:f.useContext(t$),isPresent:t,safeToRemove:n})}const NQ={pan:{Feature:$Q},drag:{Feature:RQ,ProjectionNode:GR,MeasureLayout:o$}};function H_(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,s=r[i];s&&vn.postRender(()=>s(t,xp(t)))}class LQ extends nl{mount(){const{current:t}=this.node;t&&(this.unmount=iY(t,(n,r)=>(H_(this.node,r,"Start"),i=>H_(this.node,i,"End"))))}unmount(){}}class jQ extends nl{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=vp(Wh(this.node.current,"focus",()=>this.onFocus()),Wh(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function B_(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),s=r[i];s&&vn.postRender(()=>s(t,xp(t)))}class FQ extends nl{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=uY(t,(i,s)=>(B_(this.node,s,"Start"),(o,{success:a})=>B_(this.node,o,a?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const cw=new WeakMap,bb=new WeakMap,OQ=e=>{const t=cw.get(e.target);t&&t(e)},VQ=e=>{e.forEach(OQ)};function HQ({root:e,...t}){const n=e||document;bb.has(n)||bb.set(n,{});const r=bb.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(VQ,{root:e,...t})),r[i]}function BQ(e,t,n){const r=HQ(t);return cw.set(e,n),r.observe(e),()=>{cw.delete(e),r.unobserve(e)}}const zQ={some:0,all:1};class UQ extends nl{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var c;(c=this.stopObserver)==null||c.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:s}=t,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:zQ[i]},a=u=>{const{isIntersecting:h}=u;if(this.isInView===h||(this.isInView=h,s&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:p,onViewportLeave:m}=this.node.getProps(),g=h?p:m;g&&g(u)};this.stopObserver=BQ(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(ZQ(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function ZQ({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const WQ={inView:{Feature:UQ},tap:{Feature:FQ},focus:{Feature:jQ},hover:{Feature:LQ}},GQ={layout:{ProjectionNode:GR,MeasureLayout:o$}},qQ={...vQ,...WQ,...NQ,...GQ},dn=fQ(qQ,hQ);function KQ(e){e.values.forEach(t=>t.stop())}function uw(e,t){[...t].reverse().forEach(r=>{const i=e.getVariant(r);i&&_8(e,i),e.variantChildren&&e.variantChildren.forEach(s=>{uw(s,t)})})}function YQ(e,t){if(Array.isArray(t))return uw(e,t);if(typeof t=="string")return uw(e,[t]);_8(e,t)}function XQ(){const e=new Set,t={subscribe(n){return e.add(n),()=>void e.delete(n)},start(n,r){const i=[];return e.forEach(s=>{i.push(fR(s,n,{transitionOverride:r}))}),Promise.all(i)},set(n){return e.forEach(r=>{YQ(r,n)})},stop(){e.forEach(n=>{KQ(n)})},mount(){return()=>{t.stop()}}};return t}function QQ(){const e=B1(XQ);return u8(e.mount,[]),e}var kc=EI();const JQ=xc(kc);function eJ(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const tJ=e=>{switch(e){case"success":return iJ;case"info":return oJ;case"warning":return sJ;case"error":return aJ;default:return null}},nJ=Array(12).fill(0),rJ=({visible:e,className:t})=>xe.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},xe.createElement("div",{className:"sonner-spinner"},nJ.map((n,r)=>xe.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),iJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xe.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),sJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},xe.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),oJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xe.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),aJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xe.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),lJ=xe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},xe.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),xe.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),cJ=()=>{const[e,t]=xe.useState(document.hidden);return xe.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let dw=1;class uJ{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...i}=t,s=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:dw++,o=this.toasts.find(c=>c.id===s),a=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),o?this.toasts=this.toasts.map(c=>c.id===s?(this.publish({...c,...t,id:s,title:r}),{...c,...t,id:s,dismissible:a,title:r}):c):this.addToast({title:r,...i,dismissible:a,id:s}),s},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(t instanceof Function?t():t);let s=r!==void 0,o;const a=i.then(async u=>{if(o=["resolve",u],xe.isValidElement(u))s=!1,this.create({id:r,type:"default",message:u});else if(fJ(u)&&!u.ok){s=!1;const p=typeof n.error=="function"?await n.error(`HTTP error! status: ${u.status}`):n.error,m=typeof n.description=="function"?await n.description(`HTTP error! status: ${u.status}`):n.description,b=typeof p=="object"&&!xe.isValidElement(p)?p:{message:p};this.create({id:r,type:"error",description:m,...b})}else if(u instanceof Error){s=!1;const p=typeof n.error=="function"?await n.error(u):n.error,m=typeof n.description=="function"?await n.description(u):n.description,b=typeof p=="object"&&!xe.isValidElement(p)?p:{message:p};this.create({id:r,type:"error",description:m,...b})}else if(n.success!==void 0){s=!1;const p=typeof n.success=="function"?await n.success(u):n.success,m=typeof n.description=="function"?await n.description(u):n.description,b=typeof p=="object"&&!xe.isValidElement(p)?p:{message:p};this.create({id:r,type:"success",description:m,...b})}}).catch(async u=>{if(o=["reject",u],n.error!==void 0){s=!1;const h=typeof n.error=="function"?await n.error(u):n.error,p=typeof n.description=="function"?await n.description(u):n.description,g=typeof h=="object"&&!xe.isValidElement(h)?h:{message:h};this.create({id:r,type:"error",description:p,...g})}}).finally(()=>{s&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),c=()=>new Promise((u,h)=>a.then(()=>o[0]==="reject"?h(o[1]):u(o[1])).catch(h));return typeof r!="string"&&typeof r!="number"?{unwrap:c}:Object.assign(r,{unwrap:c})},this.custom=(t,n)=>{const r=(n==null?void 0:n.id)||dw++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const ei=new uJ,dJ=(e,t)=>{const n=(t==null?void 0:t.id)||dw++;return ei.addToast({title:e,...t,id:n}),n},fJ=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",hJ=dJ,pJ=()=>ei.toasts,mJ=()=>ei.getActiveToasts(),lt=Object.assign(hJ,{success:ei.success,info:ei.info,warning:ei.warning,error:ei.error,custom:ei.custom,message:ei.message,promise:ei.promise,dismiss:ei.dismiss,loading:ei.loading},{getHistory:pJ,getToasts:mJ});eJ("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function um(e){return e.label!==void 0}const gJ=3,vJ="24px",yJ="16px",z_=4e3,bJ=356,xJ=14,wJ=45,kJ=200;function Ms(...e){return e.filter(Boolean).join(" ")}function CJ(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const EJ=e=>{var t,n,r,i,s,o,a,c,u;const{invert:h,toast:p,unstyled:m,interacting:g,setHeights:b,visibleToasts:x,heights:C,index:w,toasts:E,expanded:_,removeToast:T,defaultRichColors:I,closeButton:P,style:M,cancelButtonStyle:S,actionButtonStyle:R,className:$="",descriptionClassName:L="",duration:j,position:O,gap:H,expandByDefault:B,classNames:Z,icons:K,closeButtonAriaLabel:q="Close toast"}=e,[te,F]=xe.useState(null),[V,W]=xe.useState(null),[N,z]=xe.useState(!1),[Q,J]=xe.useState(!1),[re,G]=xe.useState(!1),[X,de]=xe.useState(!1),[ve,we]=xe.useState(!1),[je,Ae]=xe.useState(0),[Le,tt]=xe.useState(0),vt=xe.useRef(p.duration||j||z_),Je=xe.useRef(null),ye=xe.useRef(null),Ke=w===0,Dt=w+1<=x,Mt=p.type,jt=p.dismissible!==!1,bn=p.className||"",nn=p.descriptionClassName||"",he=xe.useMemo(()=>C.findIndex(Ze=>Ze.toastId===p.id)||0,[C,p.id]),be=xe.useMemo(()=>{var Ze;return(Ze=p.closeButton)!=null?Ze:P},[p.closeButton,P]),Ue=xe.useMemo(()=>p.duration||j||z_,[p.duration,j]),ot=xe.useRef(0),at=xe.useRef(0),Ht=xe.useRef(0),Ut=xe.useRef(null),[ee,Y]=O.split("-"),se=xe.useMemo(()=>C.reduce((Ze,wt,De)=>De>=he?Ze:Ze+wt.height,0),[C,he]),ce=cJ(),le=p.invert||h,ge=Mt==="loading";at.current=xe.useMemo(()=>he*H+se,[he,se]),xe.useEffect(()=>{vt.current=Ue},[Ue]),xe.useEffect(()=>{z(!0)},[]),xe.useEffect(()=>{const Ze=ye.current;if(Ze){const wt=Ze.getBoundingClientRect().height;return tt(wt),b(De=>[{toastId:p.id,height:wt,position:p.position},...De]),()=>b(De=>De.filter(Nt=>Nt.toastId!==p.id))}},[b,p.id]),xe.useLayoutEffect(()=>{if(!N)return;const Ze=ye.current,wt=Ze.style.height;Ze.style.height="auto";const De=Ze.getBoundingClientRect().height;Ze.style.height=wt,tt(De),b(Nt=>Nt.find(Tt=>Tt.toastId===p.id)?Nt.map(Tt=>Tt.toastId===p.id?{...Tt,height:De}:Tt):[{toastId:p.id,height:De,position:p.position},...Nt])},[N,p.title,p.description,b,p.id,p.jsx,p.action,p.cancel]);const ke=xe.useCallback(()=>{J(!0),Ae(at.current),b(Ze=>Ze.filter(wt=>wt.toastId!==p.id)),setTimeout(()=>{T(p)},kJ)},[p,T,b,at]);xe.useEffect(()=>{if(p.promise&&Mt==="loading"||p.duration===1/0||p.type==="loading")return;let Ze;return _||g||ce?(()=>{if(Ht.current<ot.current){const Nt=new Date().getTime()-ot.current;vt.current=vt.current-Nt}Ht.current=new Date().getTime()})():(()=>{vt.current!==1/0&&(ot.current=new Date().getTime(),Ze=setTimeout(()=>{p.onAutoClose==null||p.onAutoClose.call(p,p),ke()},vt.current))})(),()=>clearTimeout(Ze)},[_,g,p,Mt,ce,ke]),xe.useEffect(()=>{p.delete&&(ke(),p.onDismiss==null||p.onDismiss.call(p,p))},[ke,p.delete]);function $e(){var Ze;if(K!=null&&K.loading){var wt;return xe.createElement("div",{className:Ms(Z==null?void 0:Z.loader,p==null||(wt=p.classNames)==null?void 0:wt.loader,"sonner-loader"),"data-visible":Mt==="loading"},K.loading)}return xe.createElement(rJ,{className:Ms(Z==null?void 0:Z.loader,p==null||(Ze=p.classNames)==null?void 0:Ze.loader),visible:Mt==="loading"})}const ct=p.icon||(K==null?void 0:K[Mt])||tJ(Mt);var rt,Jt;return xe.createElement("li",{tabIndex:0,ref:ye,className:Ms($,bn,Z==null?void 0:Z.toast,p==null||(t=p.classNames)==null?void 0:t.toast,Z==null?void 0:Z.default,Z==null?void 0:Z[Mt],p==null||(n=p.classNames)==null?void 0:n[Mt]),"data-sonner-toast":"","data-rich-colors":(rt=p.richColors)!=null?rt:I,"data-styled":!(p.jsx||p.unstyled||m),"data-mounted":N,"data-promise":!!p.promise,"data-swiped":ve,"data-removed":Q,"data-visible":Dt,"data-y-position":ee,"data-x-position":Y,"data-index":w,"data-front":Ke,"data-swiping":re,"data-dismissible":jt,"data-type":Mt,"data-invert":le,"data-swipe-out":X,"data-swipe-direction":V,"data-expanded":!!(_||B&&N),"data-testid":p.testId,style:{"--index":w,"--toasts-before":w,"--z-index":E.length-w,"--offset":`${Q?je:at.current}px`,"--initial-height":B?"auto":`${Le}px`,...M,...p.style},onDragEnd:()=>{G(!1),F(null),Ut.current=null},onPointerDown:Ze=>{Ze.button!==2&&(ge||!jt||(Je.current=new Date,Ae(at.current),Ze.target.setPointerCapture(Ze.pointerId),Ze.target.tagName!=="BUTTON"&&(G(!0),Ut.current={x:Ze.clientX,y:Ze.clientY})))},onPointerUp:()=>{var Ze,wt,De;if(X||!jt)return;Ut.current=null;const Nt=Number(((Ze=ye.current)==null?void 0:Ze.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),At=Number(((wt=ye.current)==null?void 0:wt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Tt=new Date().getTime()-((De=Je.current)==null?void 0:De.getTime()),on=te==="x"?Nt:At,Qn=Math.abs(on)/Tt;if(Math.abs(on)>=wJ||Qn>.11){Ae(at.current),p.onDismiss==null||p.onDismiss.call(p,p),W(te==="x"?Nt>0?"right":"left":At>0?"down":"up"),ke(),de(!0);return}else{var Vn,Jn;(Vn=ye.current)==null||Vn.style.setProperty("--swipe-amount-x","0px"),(Jn=ye.current)==null||Jn.style.setProperty("--swipe-amount-y","0px")}we(!1),G(!1),F(null)},onPointerMove:Ze=>{var wt,De,Nt;if(!Ut.current||!jt||((wt=window.getSelection())==null?void 0:wt.toString().length)>0)return;const Tt=Ze.clientY-Ut.current.y,on=Ze.clientX-Ut.current.x;var Qn;const Vn=(Qn=e.swipeDirections)!=null?Qn:CJ(O);!te&&(Math.abs(on)>1||Math.abs(Tt)>1)&&F(Math.abs(on)>Math.abs(Tt)?"x":"y");let Jn={x:0,y:0};const en=Mn=>1/(1.5+Math.abs(Mn)/20);if(te==="y"){if(Vn.includes("top")||Vn.includes("bottom"))if(Vn.includes("top")&&Tt<0||Vn.includes("bottom")&&Tt>0)Jn.y=Tt;else{const Mn=Tt*en(Tt);Jn.y=Math.abs(Mn)<Math.abs(Tt)?Mn:Tt}}else if(te==="x"&&(Vn.includes("left")||Vn.includes("right")))if(Vn.includes("left")&&on<0||Vn.includes("right")&&on>0)Jn.x=on;else{const Mn=on*en(on);Jn.x=Math.abs(Mn)<Math.abs(on)?Mn:on}(Math.abs(Jn.x)>0||Math.abs(Jn.y)>0)&&we(!0),(De=ye.current)==null||De.style.setProperty("--swipe-amount-x",`${Jn.x}px`),(Nt=ye.current)==null||Nt.style.setProperty("--swipe-amount-y",`${Jn.y}px`)}},be&&!p.jsx&&Mt!=="loading"?xe.createElement("button",{"aria-label":q,"data-disabled":ge,"data-close-button":!0,onClick:ge||!jt?()=>{}:()=>{ke(),p.onDismiss==null||p.onDismiss.call(p,p)},className:Ms(Z==null?void 0:Z.closeButton,p==null||(r=p.classNames)==null?void 0:r.closeButton)},(Jt=K==null?void 0:K.close)!=null?Jt:lJ):null,(Mt||p.icon||p.promise)&&p.icon!==null&&((K==null?void 0:K[Mt])!==null||p.icon)?xe.createElement("div",{"data-icon":"",className:Ms(Z==null?void 0:Z.icon,p==null||(i=p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||$e():null,p.type!=="loading"?ct:null):null,xe.createElement("div",{"data-content":"",className:Ms(Z==null?void 0:Z.content,p==null||(s=p.classNames)==null?void 0:s.content)},xe.createElement("div",{"data-title":"",className:Ms(Z==null?void 0:Z.title,p==null||(o=p.classNames)==null?void 0:o.title)},p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title),p.description?xe.createElement("div",{"data-description":"",className:Ms(L,nn,Z==null?void 0:Z.description,p==null||(a=p.classNames)==null?void 0:a.description)},typeof p.description=="function"?p.description():p.description):null),xe.isValidElement(p.cancel)?p.cancel:p.cancel&&um(p.cancel)?xe.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||S,onClick:Ze=>{um(p.cancel)&&jt&&(p.cancel.onClick==null||p.cancel.onClick.call(p.cancel,Ze),ke())},className:Ms(Z==null?void 0:Z.cancelButton,p==null||(c=p.classNames)==null?void 0:c.cancelButton)},p.cancel.label):null,xe.isValidElement(p.action)?p.action:p.action&&um(p.action)?xe.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||R,onClick:Ze=>{um(p.action)&&(p.action.onClick==null||p.action.onClick.call(p.action,Ze),!Ze.defaultPrevented&&ke())},className:Ms(Z==null?void 0:Z.actionButton,p==null||(u=p.classNames)==null?void 0:u.actionButton)},p.action.label):null)};function U_(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function SJ(e,t){const n={};return[e,t].forEach((r,i)=>{const s=i===1,o=s?"--mobile-offset":"--offset",a=s?yJ:vJ;function c(u){["top","right","bottom","left"].forEach(h=>{n[`${o}-${h}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${o}-${u}`]=a:n[`${o}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):c(a)}),n}const a$=xe.forwardRef(function(t,n){const{id:r,invert:i,position:s="bottom-right",hotkey:o=["altKey","KeyT"],expand:a,closeButton:c,className:u,offset:h,mobileOffset:p,theme:m="light",richColors:g,duration:b,style:x,visibleToasts:C=gJ,toastOptions:w,dir:E=U_(),gap:_=xJ,icons:T,containerAriaLabel:I="Notifications"}=t,[P,M]=xe.useState([]),S=xe.useMemo(()=>r?P.filter(N=>N.toasterId===r):P.filter(N=>!N.toasterId),[P,r]),R=xe.useMemo(()=>Array.from(new Set([s].concat(S.filter(N=>N.position).map(N=>N.position)))),[S,s]),[$,L]=xe.useState([]),[j,O]=xe.useState(!1),[H,B]=xe.useState(!1),[Z,K]=xe.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),q=xe.useRef(null),te=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=xe.useRef(null),V=xe.useRef(!1),W=xe.useCallback(N=>{M(z=>{var Q;return(Q=z.find(J=>J.id===N.id))!=null&&Q.delete||ei.dismiss(N.id),z.filter(({id:J})=>J!==N.id)})},[]);return xe.useEffect(()=>ei.subscribe(N=>{if(N.dismiss){requestAnimationFrame(()=>{M(z=>z.map(Q=>Q.id===N.id?{...Q,delete:!0}:Q))});return}setTimeout(()=>{JQ.flushSync(()=>{M(z=>{const Q=z.findIndex(J=>J.id===N.id);return Q!==-1?[...z.slice(0,Q),{...z[Q],...N},...z.slice(Q+1)]:[N,...z]})})})}),[P]),xe.useEffect(()=>{if(m!=="system"){K(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;const N=window.matchMedia("(prefers-color-scheme: dark)");try{N.addEventListener("change",({matches:z})=>{K(z?"dark":"light")})}catch{N.addListener(({matches:Q})=>{try{K(Q?"dark":"light")}catch(J){console.error(J)}})}},[m]),xe.useEffect(()=>{P.length<=1&&O(!1)},[P]),xe.useEffect(()=>{const N=z=>{var Q;if(o.every(G=>z[G]||z.code===G)){var re;O(!0),(re=q.current)==null||re.focus()}z.code==="Escape"&&(document.activeElement===q.current||(Q=q.current)!=null&&Q.contains(document.activeElement))&&O(!1)};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[o]),xe.useEffect(()=>{if(q.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,V.current=!1)}},[q.current]),xe.createElement("section",{ref:n,"aria-label":`${I} ${te}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},R.map((N,z)=>{var Q;const[J,re]=N.split("-");return S.length?xe.createElement("ol",{key:N,dir:E==="auto"?U_():E,tabIndex:-1,ref:q,className:u,"data-sonner-toaster":!0,"data-sonner-theme":Z,"data-y-position":J,"data-x-position":re,style:{"--front-toast-height":`${((Q=$[0])==null?void 0:Q.height)||0}px`,"--width":`${bJ}px`,"--gap":`${_}px`,...x,...SJ(h,p)},onBlur:G=>{V.current&&!G.currentTarget.contains(G.relatedTarget)&&(V.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||V.current||(V.current=!0,F.current=G.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{H||O(!1)},onDragEnd:()=>O(!1),onPointerDown:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||B(!0)},onPointerUp:()=>B(!1)},S.filter(G=>!G.position&&z===0||G.position===N).map((G,X)=>{var de,ve;return xe.createElement(EJ,{key:G.id,icons:T,index:X,toast:G,defaultRichColors:g,duration:(de=w==null?void 0:w.duration)!=null?de:b,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:i,visibleToasts:C,closeButton:(ve=w==null?void 0:w.closeButton)!=null?ve:c,interacting:H,position:N,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,closeButtonAriaLabel:w==null?void 0:w.closeButtonAriaLabel,removeToast:W,toasts:S.filter(we=>we.position==G.position),heights:$.filter(we=>we.position==G.position),setHeights:L,expandByDefault:a,gap:_,expanded:j,swipeDirections:t.swipeDirections})})):null}))}),ls=e=>({ok:!0,value:e}),ti=e=>({ok:!1,error:e}),l$=(e,t)=>`style:${e}:${t}`,c$=e=>`text:${e}`,u$=e=>{const t=[e.rivetId,e.xpath,e.cssSelector].filter(n=>!!n).map(n=>n.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:["unknown"]},d$=e=>u$(e)[0],oh=(e,t)=>u$(e).includes(t),ac=e=>{const t=d$(e.elementId),n=e.batchId?`:${e.batchId}`:"";return e.type==="style"?`${l$(t,e.property)}${n}`:`${c$(t)}${n}`};class f$ extends Error{constructor(t){super(t),this.name="DOMError"}}class iu extends f${constructor(t,n){super(n||`Element not found: rivetId=${t.rivetId}, xpath=${t.xpath}`),this.identifier=t,this.name="ElementNotFoundError"}}class _J extends f${constructor(t,n,r){super(r||`Failed to apply style: ${t} = ${n}. Value may be invalid.`),this.property=t,this.value=n,this.name="StyleApplicationError"}}const yr=[];for(let e=0;e<256;++e)yr.push((e+256).toString(16).slice(1));function AJ(e,t=0){return(yr[e[t+0]]+yr[e[t+1]]+yr[e[t+2]]+yr[e[t+3]]+"-"+yr[e[t+4]]+yr[e[t+5]]+"-"+yr[e[t+6]]+yr[e[t+7]]+"-"+yr[e[t+8]]+yr[e[t+9]]+"-"+yr[e[t+10]]+yr[e[t+11]]+yr[e[t+12]]+yr[e[t+13]]+yr[e[t+14]]+yr[e[t+15]]).toLowerCase()}const TJ=new Uint8Array(16);function PJ(){return crypto.getRandomValues(TJ)}function Ga(e,t,n){return crypto.randomUUID?crypto.randomUUID():IJ(e)}function IJ(e,t,n){var i;e=e||{};const r=e.random??((i=e.rng)==null?void 0:i.call(e))??PJ();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,AJ(r)}var og={exports:{}},MJ=og.exports,Z_;function RJ(){return Z_||(Z_=1,(function(e){(function(t,n){e.exports?e.exports=n():t.log=n()})(MJ,function(){var t=function(){},n="undefined",r=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],s={},o=null;function a(x,C){var w=x[C];if(typeof w.bind=="function")return w.bind(x);try{return Function.prototype.bind.call(w,x)}catch{return function(){return Function.prototype.apply.apply(w,[x,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function u(x){return x==="debug"&&(x="log"),typeof console===n?!1:x==="trace"&&r?c:console[x]!==void 0?a(console,x):console.log!==void 0?a(console,"log"):t}function h(){for(var x=this.getLevel(),C=0;C<i.length;C++){var w=i[C];this[w]=C<x?t:this.methodFactory(w,x,this.name)}if(this.log=this.debug,typeof console===n&&x<this.levels.SILENT)return"No console available for logging"}function p(x){return function(){typeof console!==n&&(h.call(this),this[x].apply(this,arguments))}}function m(x,C,w){return u(x)||p.apply(this,arguments)}function g(x,C){var w=this,E,_,T,I="loglevel";typeof x=="string"?I+=":"+x:typeof x=="symbol"&&(I=void 0);function P(L){var j=(i[L]||"silent").toUpperCase();if(!(typeof window===n||!I)){try{window.localStorage[I]=j;return}catch{}try{window.document.cookie=encodeURIComponent(I)+"="+j+";"}catch{}}}function M(){var L;if(!(typeof window===n||!I)){try{L=window.localStorage[I]}catch{}if(typeof L===n)try{var j=window.document.cookie,O=encodeURIComponent(I),H=j.indexOf(O+"=");H!==-1&&(L=/^([^;]+)/.exec(j.slice(H+O.length+1))[1])}catch{}return w.levels[L]===void 0&&(L=void 0),L}}function S(){if(!(typeof window===n||!I)){try{window.localStorage.removeItem(I)}catch{}try{window.document.cookie=encodeURIComponent(I)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function R(L){var j=L;if(typeof j=="string"&&w.levels[j.toUpperCase()]!==void 0&&(j=w.levels[j.toUpperCase()]),typeof j=="number"&&j>=0&&j<=w.levels.SILENT)return j;throw new TypeError("log.setLevel() called with invalid level: "+L)}w.name=x,w.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},w.methodFactory=C||m,w.getLevel=function(){return T??_??E},w.setLevel=function(L,j){return T=R(L),j!==!1&&P(T),h.call(w)},w.setDefaultLevel=function(L){_=R(L),M()||w.setLevel(L,!1)},w.resetLevel=function(){T=null,S(),h.call(w)},w.enableAll=function(L){w.setLevel(w.levels.TRACE,L)},w.disableAll=function(L){w.setLevel(w.levels.SILENT,L)},w.rebuild=function(){if(o!==w&&(E=R(o.getLevel())),h.call(w),o===w)for(var L in s)s[L].rebuild()},E=R(o?o.getLevel():"WARN");var $=M();$!=null&&(T=R($)),h.call(w)}o=new g,o.getLogger=function(C){if(typeof C!="symbol"&&typeof C!="string"||C==="")throw new TypeError("You must supply a name when creating a logger.");var w=s[C];return w||(w=s[C]=new g(C,o.methodFactory)),w};var b=typeof window!==n?window.log:void 0;return o.noConflict=function(){return typeof window!==n&&window.log===o&&(window.log=b),o},o.getLoggers=function(){return s},o.default=o,o})})(og)),og.exports}var $J=RJ();const os=xc($J),DJ="INFO",NJ=DJ.toUpperCase();os.setLevel(os.levels[NJ]||os.levels.INFO);const $t=e=>{const t=e?`[${e}] `:"";return{trace:(n,...r)=>os.trace(`${t}${n}`,...r),debug:(n,...r)=>os.debug(`${t}${n}`,...r),info:(n,...r)=>os.info(`${t}${n}`,...r),warn:(n,...r)=>os.warn(`${t}${n}`,...r),error:(n,...r)=>{os.error(`${t}${n}`,...r);try{const s=r.map(a=>a instanceof Error?a.message:String(a)).join(" ").slice(0,512),o={source:"ui",error_message:n,service:e??"unknown",error_type:"logged_error",url:window.location.pathname,error_args_count:r.length,...s?{error_detail:s}:{}};yt.capture("logger_error",o)}catch(i){console.error("[logger] Failed to send logger_error to PostHog:",i)}},api:(n,...r)=>os.info(`${t}API: ${n}`,...r),hook:(n,...r)=>os.debug(`${t}Hook: ${n}`,...r),mount:(n,...r)=>os.debug(`${t}Mount: ${n}`,...r)}},h$={0:0,"0.5":2,1:4,"1.5":6,2:8,"2.5":10,3:12,"3.5":14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},fw=h$,p$=new Map;for(const[e,t]of Object.entries(h$))p$.set(t,e);const LJ=1,dm=(e,t,n=fw)=>{const r=e.match(/^(\d+(?:\.\d+)?)px$/);if(!r)return e;const i=parseFloat(r[1]),s=Math.round(i),a=(n===fw?p$:new Map(Object.entries(n).map(([c,u])=>[Math.round(u),c]))).get(s);if(a!==void 0)return`${t==="width"?"w":"h"}-${a}`;for(const[c,u]of Object.entries(n))if(Math.abs(i-u)<=LJ)return`${t==="width"?"w":"h"}-${c}`;return e},jJ=(e,t=fw)=>{const n=e.match(/^(w|h)-(.+)$/);if(!n)return e;const r=n[2],i=t[r];return i===void 0?e:`${i}px`},da=$t("StyleManipulationService");class FJ{constructor(t,n){fn(this,"hmrUnsubscribe",null);this.adapter=t,this.tracker=n,this.hmrUnsubscribe=this.adapter.onHMR(()=>{this.handleHMR()})}async previewStyleChange(t,n,r){return this.adapter.applyStyle(t,n,r)}async applyStyleChange(t,n,r,i,s,o){let a;if(s!==void 0)a=s;else{const h=await this.adapter.getComputedStylesForElement(t);if(!h.ok)return ti(h.error);a=h.value[r]||""}const c=await this.adapter.applyStyle(t,r,i);if(!c.ok)return ti(c.error);const u={type:"style",id:Ga(),timestamp:Date.now(),elementId:t,elementContext:n,property:r,oldValue:a,newValue:o??i};return this.tracker.recordChange(u),ls(void 0)}recordTextChange(t,n,r,i){const s={type:"text",id:Ga(),timestamp:Date.now(),elementId:t,elementContext:n,oldText:r,newText:i};this.tracker.recordChange(s)}async undo(){const t=this.tracker.undo();return t?await this.clearAndReapply(t):ls(void 0)}async redo(){const t=this.tracker.getChanges();return this.tracker.redo()?await this.clearAndReapply(t):ls(void 0)}getChanges(){return this.tracker.getChanges()}getStyleChanges(){return this.tracker.getStyleChanges()}getTextChanges(){return this.tracker.getTextChanges()}getChangeCount(){return this.tracker.getChangeCount()}canUndo(){return this.tracker.canUndo()}canRedo(){return this.tracker.canRedo()}flushPending(){this.tracker.flushPending()}async revertSpecificChange(t){const n=ac(t),r=await this.adapter.findElement(t.elementId);if(!r.ok){const o=r.error;return ti(o instanceof Error?o:new Error(String(o)))}const i=r.value;try{t.type==="style"?t.property==="width"||t.property==="height"?i.style[t.property]="":i.style[t.property]=t.oldValue:i.textContent=t.oldText}catch(o){return da.warn("Failed to revert specific change:",o),ti(o instanceof Error?o:new Error("Failed to revert change"))}return this.tracker.removeChange(n)||da.warn("removeChange found no entry for key:",n),ls(void 0)}clear(){this.tracker.clear()}removeTrackedChangeById(t){return this.tracker.removeChangeById(t)!==null}async transaction(t){await this.tracker.transaction(t)}getChangesForElement(t){return this.tracker.getChanges().filter(n=>oh(n.elementId,t))}hasChanges(t){return this.tracker.hasChanges(t)}onChange(t){return this.tracker.onChange(t)}async handleHMR(){da.info("HMR detected, reapplying changes"),await new Promise(n=>setTimeout(n,100));const t=await this.reapplyAllChanges({stylesOnly:!0});t.ok||da.warn("Failed to reapply changes after HMR:",t.error)}async clearAndReapply(t){for(const n of t){const r=await this.adapter.findElement(n.elementId);if(r.ok){const i=r.value;try{n.type==="style"?n.property==="width"||n.property==="height"?i.style[n.property]="":i.style[n.property]=n.oldValue:i.textContent=n.oldText}catch(s){da.warn("Failed to restore baseline:",s)}}}return await this.reapplyAllChanges()}async reapplyAllChanges(t={}){const n=this.tracker.getChanges(),r=t.stylesOnly?n.filter(s=>s.type==="style"):n,i=[];for(const s of r)if(s.type==="style"){const o=s.property==="width"||s.property==="height"?jJ(s.newValue):s.newValue,a=await this.adapter.applyStyle(s.elementId,s.property,o);a.ok||i.push({change:s,error:a.error})}else{const o=await this.adapter.findElement(s.elementId);if(o.ok){const a=o.value;a.textContent=s.newText}else i.push({change:s,error:o.error})}return i.length>0?(da.warn(`Failed to reapply ${i.length}/${r.length} changes`,i),ti(new Error(`Failed to reapply ${i.length} changes. First error: ${i[0].error.message}`))):ls(void 0)}async clearInlineChanges(){const t=this.tracker.getChanges();for(const n of t){const r=await this.adapter.findElement(n.elementId);if(!r.ok){da.warn("Could not find element to clear change:",r.error);continue}const i=r.value;try{n.type==="style"?i.style[n.property]="":i.textContent=n.oldText}catch(s){da.warn("Failed to clear change:",s)}}return ls(void 0)}async clearInlineStyles(){return this.clearInlineChanges()}destroy(){this.hmrUnsubscribe&&(this.hmrUnsubscribe(),this.hmrUnsubscribe=null)}}const OJ=300;class VJ{constructor(){fn(this,"history",{current:new Map,past:[],future:[]});fn(this,"pendingChanges",new Map);fn(this,"currentBatchId",null);fn(this,"debounceTimer",null);fn(this,"onChangeCallbacks",[]);fn(this,"stateBeforePending",null);fn(this,"transactionDepth",0)}recordChange(t){this.pendingChanges.size===0&&(this.currentBatchId=Ga(),this.stateBeforePending=new Map(this.history.current)),this.currentBatchId&&(t.batchId=this.currentBatchId);const n=d$(t.elementId),r=t.type==="style"?l$(n,t.property):c$(n),i=Array.from(this.history.current.entries()).find(([o])=>o===r||o.startsWith(`${r}:`));if(i){const o=i[1];t.type==="style"&&o.type==="style"?t.oldValue=o.oldValue:t.type==="text"&&o.type==="text"&&(t.oldText=o.oldText)}const s=ac(t);this.history.current.set(s,t),this.pendingChanges.set(s,t),this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.commitPending()},OJ),this.notifyChange()}flushPending(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.commitPending()}removeChange(t){const n=this.history.current.get(t)??this.pendingChanges.get(t)??null,r=this.history.current.has(t),i=this.pendingChanges.has(t);return!r&&!i?null:(r&&this.history.current.delete(t),i&&this.pendingChanges.delete(t),n&&this.stateBeforePending&&(this.stateBeforePending=this.removeChangeFromSnapshotById(this.stateBeforePending,n.id)),i&&this.pendingChanges.size===0&&(this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.stateBeforePending=null,this.currentBatchId=null),r&&(this.history.future=[]),n&&(this.history.past=this.history.past.map(s=>this.removeChangeFromSnapshotById(s,n.id)).filter(s=>s.size>0)),this.notifyChange(),n)}removeChangeById(t){const n=Array.from(this.history.current.entries()).find(([,i])=>i.id===t);if(n)return this.removeChange(n[0]);const r=Array.from(this.pendingChanges.entries()).find(([,i])=>i.id===t);return r?this.removeChange(r[0]):null}removeChangeFromSnapshotById(t,n){return new Map(Array.from(t.entries()).filter(([,r])=>r.id!==n))}commitPending(){this.pendingChanges.size===0||!this.stateBeforePending||this.transactionDepth>0||(this.history.past.push(this.stateBeforePending),this.history.future=[],this.pendingChanges.clear(),this.stateBeforePending=null,this.currentBatchId=null,this.notifyChange())}undo(){if(this.pendingChanges.size>0&&this.commitPending(),this.history.past.length===0)return null;const t=new Map(this.history.current);this.history.future.push(t),this.history.current=this.history.past.pop(),this.notifyChange();const n=[];for(const[r,i]of t)this.history.current.has(r)||n.push(i);return n}redo(){if(this.history.future.length===0)return null;const t=new Map(this.history.current);this.history.past.push(t),this.history.current=this.history.future.pop(),this.notifyChange();const n=[];for(const[r,i]of this.history.current)t.has(r)||n.push(i);return n}getChanges(){return Array.from(this.history.current.values())}getStyleChanges(){return Array.from(this.history.current.values()).filter(t=>t.type==="style")}getTextChanges(){return Array.from(this.history.current.values()).filter(t=>t.type==="text")}getChangeCount(){return this.getUniqueBatchCount(this.history.current.values())}getStyleBatchCount(){return this.getUniqueBatchCount(Array.from(this.history.current.values()).filter(t=>t.type==="style"))}getTextBatchCount(){return this.getUniqueBatchCount(Array.from(this.history.current.values()).filter(t=>t.type==="text"))}getUniqueBatchCount(t){const n=new Set;for(const r of t)r.batchId?n.add(r.batchId):n.add(r.id);return n.size}canUndo(){return this.history.past.length>0||this.pendingChanges.size>0}canRedo(){return this.history.future.length>0}clear(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.history={current:new Map,past:[],future:[]},this.pendingChanges.clear(),this.stateBeforePending=null,this.currentBatchId=null,this.notifyChange()}getStyleChange(t,n){return Array.from(this.history.current.values()).filter(i=>i.type==="style"&&oh(i.elementId,t)&&i.property===n).sort((i,s)=>s.timestamp-i.timestamp)[0]}getTextChange(t){return Array.from(this.history.current.values()).filter(r=>r.type==="text"&&oh(r.elementId,t)).sort((r,i)=>i.timestamp-r.timestamp)[0]}hasChanges(t){return Array.from(this.history.current.values()).some(n=>oh(n.elementId,t))}getChangesForElement(t){return Array.from(this.history.current.values()).filter(n=>oh(n.elementId,t))}onChange(t){return this.onChangeCallbacks.push(t),()=>{const n=this.onChangeCallbacks.indexOf(t);n!==-1&&this.onChangeCallbacks.splice(n,1)}}notifyChange(){this.onChangeCallbacks.forEach(t=>t())}export(){return{current:Array.from(this.history.current.entries()),past:this.history.past.map(t=>Array.from(t.entries())),future:this.history.future.map(t=>Array.from(t.entries()))}}import(t){this.history={current:new Map(t.current),past:t.past.map(n=>new Map(n)),future:t.future.map(n=>new Map(n))},this.notifyChange()}async transaction(t){const n=this.pendingChanges.size===0;n&&(this.currentBatchId=Ga(),this.stateBeforePending=new Map(this.history.current)),this.transactionDepth++;try{await t()}catch(r){throw n&&this.stateBeforePending&&(this.history.current=new Map(this.stateBeforePending),this.pendingChanges.clear(),this.currentBatchId=null,this.stateBeforePending=null),r}finally{this.transactionDepth--,n&&this.transactionDepth===0&&this.flushPending()}}}const Qs={kind:"base"};function ah(e){return e.kind==="variant"}function No(e){return e.kind==="base"?"base":`variant:${e.sessionId}:${e.variantId}`}function Gh(e,t){return e.kind==="base"&&t.kind==="base"?!0:e.kind==="variant"&&t.kind==="variant"?e.sessionId===t.sessionId&&e.variantId===t.variantId:!1}const Mu={color:"colors",background:"colors",backgroundColor:"colors",borderColor:"colors",borderTopColor:"colors",borderRightColor:"colors",borderBottomColor:"colors",borderLeftColor:"colors",outlineColor:"colors",borderRadius:"borderRadius",borderTopLeftRadius:"borderRadius",borderTopRightRadius:"borderRadius",borderBottomRightRadius:"borderRadius",borderBottomLeftRadius:"borderRadius",boxShadow:"boxShadow",padding:"spacing",paddingTop:"spacing",paddingRight:"spacing",paddingBottom:"spacing",paddingLeft:"spacing",margin:"spacing",marginTop:"spacing",marginRight:"spacing",marginBottom:"spacing",marginLeft:"spacing",gap:"spacing",rowGap:"spacing",columnGap:"spacing",width:"spacing",height:"spacing",maxWidth:"spacing",maxHeight:"spacing",minWidth:"spacing",minHeight:"spacing",fontSize:"fontSize",fontFamily:"fontFamily"},HJ="claude-opus-4-8",BJ={resize:{default:!1},variants:{default:!1},designSystemEditor:{default:!1},branchDiff:{default:!1},gitUi:{default:!0},createProject:{default:!1},desktopForceUpgrade:{default:!1},deployPrototype:{default:!1},generativeControls:{default:!1},refineMode:{default:!1}},m$=Object.fromEntries(Object.entries(BJ).map(([e,t])=>[e,{isEnabled:t.default}])),Js=Qe(null),zJ=Qe([]),UJ=Qe(""),ZJ=Qe([]),rl=Qe("view"),F8=Qe(null,(e,t,n)=>{n==="edit"&&!e(Ti).refineMode.isEnabled||(t(rl,n),n==="view"&&(t(Js,null),t(H8,null)))}),wp=Qe(!0),O8=Qe("chat"),g$=Qe(0),v$=Qe({name:null,email:null}),y$=Qe(0),ps=Qe(Qs),hw=Qe(new Map),pw=Qe(new Map),WJ=Qe(null,(e,t,n)=>{const r=new Map(e(hw));n.ref?r.set(n.surfaceId,n.ref):r.delete(n.surfaceId),t(hw,r)}),GJ=Qe(null,(e,t,n)=>{const r=new Map(e(pw));n.adapter?r.set(n.surfaceId,n.adapter):r.delete(n.surfaceId),t(pw,r)}),kp=Qe(e=>{const t=e(hw),n=No(e(ps));return t.get(n)??t.get("base")??null}),Pd=Qe(e=>{const t=e(pw),n=No(e(ps));return t.get(n)??t.get("base")??null}),Id=Qe(null),q1=Qe({isEditing:!1,element:null,originalText:""}),b$=Qe(!1),qh=new Map,qJ=e=>{const t=No(e);let n=qh.get(t);return n||(n=new VJ,qh.set(t,n)),n},V8=Qe(e=>qJ(e(ps)),(e,t,n)=>{qh.set(No(e(ps)),n)}),KJ=e=>{for(const t of[...qh.keys()])t==="base"||e.has(t)||qh.delete(t)},mw=Qe(null),K1=Qe(null),H8=Qe(null),W_=[{id:"claude-sonnet-4-6",name:"Sonnet 4.6",description:"Fast and capable"},{id:"claude-opus-4-8",name:"Opus 4.8",description:"Most capable"},{id:"claude-opus-4-7",name:"Opus 4.7",description:"Highly capable"},{id:"claude-opus-4-6",name:"Opus 4.6",description:"Highly capable"},{id:"claude-haiku-4-5",name:"Haiku 4.5",description:"Fast and affordable"}],x$=Qe(HJ),Hi=Qe(new Map),r1=Qe(null),B8=Qe(null),gw=Qe(0),i1=Qe(null),vw=Qe(!1),w$=Qe(null),yw=Qe(null),Kh=Qe(null),z8=Qe(null),Cc=Qe(null),il=Qe({active:!1}),k$=Qe(!1),qa=Qe(null),YJ=Qe(null,(e,t,n)=>{const r=c=>{const u=c??Qs;return u.kind==="variant"&&!n.has(No(u))},i=e(Hi);let s=null;for(const[c,u]of i)r(u.target)&&(s??(s=new Set)).add(c);if(s){const c=new Map(i);for(const u of s)c.delete(u);t(Hi,c)}r(e(ps))&&(t(ps,Qs),t(Js,null));const o=e(r1);o&&r(o.target)&&(t(r1,null),t(pc,!1));const a=e(qa);a&&(s!=null&&s.has(a.commentId))&&t(qa,null),KJ(n)}),Ti=Qe(m$),C$=Qe(!1),Y1=Qe(null),E$=Qe(!1),Cp=Qe(!1),U8=Qe(null),XJ=()=>{var e;return typeof window>"u"?null:((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.agentApplyMode)??null},X1=Qe(XJ()),Z8=Qe(null),QJ=Qe(!1),pc=Qe(!1),S$=Qe(!1),_$=Qe(0),JJ=Qe(0);function A$(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=A$(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function W8(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=A$(e))&&(r&&(r+=" "),r+=t);return r}const eee=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},tee=(e,t)=>({classGroupId:e,validator:t}),T$=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),s1="-",G_=[],nee="arbitrary..",ree=e=>{const t=see(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return iee(o);const a=o.split(s1),c=a[0]===""&&a.length>1?1:0;return P$(a,c,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const c=r[o],u=n[o];return c?u?eee(u,c):c:u||G_}return n[o]||G_}}},P$=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],s=n.nextPart.get(i);if(s){const u=P$(e,t+1,s);if(u)return u}const o=n.validators;if(o===null)return;const a=t===0?e.join(s1):e.slice(t).join(s1),c=o.length;for(let u=0;u<c;u++){const h=o[u];if(h.validator(a))return h.classGroupId}},iee=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?nee+r:void 0})(),see=e=>{const{theme:t,classGroups:n}=e;return oee(n,t)},oee=(e,t)=>{const n=T$();for(const r in e){const i=e[r];G8(i,n,r,t)}return n},G8=(e,t,n,r)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];aee(o,t,n,r)}},aee=(e,t,n,r)=>{if(typeof e=="string"){lee(e,t,n);return}if(typeof e=="function"){cee(e,t,n,r);return}uee(e,t,n,r)},lee=(e,t,n)=>{const r=e===""?t:I$(t,e);r.classGroupId=n},cee=(e,t,n,r)=>{if(dee(e)){G8(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(tee(n,e))},uee=(e,t,n,r)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[a,c]=i[o];G8(c,I$(t,a),n,r)}},I$=(e,t)=>{let n=e;const r=t.split(s1),i=r.length;for(let s=0;s<i;s++){const o=r[s];let a=n.nextPart.get(o);a||(a=T$(),n.nextPart.set(o,a)),n=a}return n},dee=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,fee=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(s,o)=>{n[s]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=r[s])!==void 0)return i(s,o),o},set(s,o){s in n?n[s]=o:i(s,o)}}},bw="!",q_=":",hee=[],K_=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),pee=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const s=[];let o=0,a=0,c=0,u;const h=i.length;for(let x=0;x<h;x++){const C=i[x];if(o===0&&a===0){if(C===q_){s.push(i.slice(c,x)),c=x+1;continue}if(C==="/"){u=x;continue}}C==="["?o++:C==="]"?o--:C==="("?a++:C===")"&&a--}const p=s.length===0?i:i.slice(c);let m=p,g=!1;p.endsWith(bw)?(m=p.slice(0,-1),g=!0):p.startsWith(bw)&&(m=p.slice(1),g=!0);const b=u&&u>c?u-c:void 0;return K_(s,g,m,b)};if(t){const i=t+q_,s=r;r=o=>o.startsWith(i)?s(o.slice(i.length)):K_(hee,!1,o,void 0,!0)}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},mee=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let s=0;s<n.length;s++){const o=n[s],a=o[0]==="[",c=t.has(o);a||c?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},gee=e=>({cache:fee(e.cacheSize),parseClassName:pee(e),sortModifiers:mee(e),postfixLookupClassGroupIds:vee(e),...ree(e)}),vee=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},yee=/\s+/,bee=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s,postfixLookupClassGroupIds:o}=t,a=[],c=e.trim().split(yee);let u="";for(let h=c.length-1;h>=0;h-=1){const p=c[h],{isExternal:m,modifiers:g,hasImportantModifier:b,baseClassName:x,maybePostfixModifierPosition:C}=n(p);if(m){u=p+(u.length>0?" "+u:u);continue}let w=!!C,E;if(w){const M=x.substring(0,C);E=r(M);const S=E&&o[E]?r(x):void 0;S&&S!==E&&(E=S,w=!1)}else E=r(x);if(!E){if(!w){u=p+(u.length>0?" "+u:u);continue}if(E=r(x),!E){u=p+(u.length>0?" "+u:u);continue}w=!1}const _=g.length===0?"":g.length===1?g[0]:s(g).join(":"),T=b?_+bw:_,I=T+E;if(a.indexOf(I)>-1)continue;a.push(I);const P=i(E,w);for(let M=0;M<P.length;++M){const S=P[M];a.push(T+S)}u=p+(u.length>0?" "+u:u)}return u},xee=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=M$(n))&&(i&&(i+=" "),i+=r);return i},M$=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=M$(e[r]))&&(n&&(n+=" "),n+=t);return n},wee=(e,...t)=>{let n,r,i,s;const o=c=>{const u=t.reduce((h,p)=>p(h),e());return n=gee(u),r=n.cache.get,i=n.cache.set,s=a,a(c)},a=c=>{const u=r(c);if(u)return u;const h=bee(c,n);return i(c,h),h};return s=o,(...c)=>s(xee(...c))},kee=[],rr=e=>{const t=n=>n[e]||kee;return t.isThemeGetter=!0,t},R$=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$$=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Cee=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Eee=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,See=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,_ee=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Aee=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Tee=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,fa=e=>Cee.test(e),Lt=e=>!!e&&!Number.isNaN(Number(e)),Rs=e=>!!e&&Number.isInteger(Number(e)),xb=e=>e.endsWith("%")&&Lt(e.slice(0,-1)),vo=e=>Eee.test(e),D$=()=>!0,Pee=e=>See.test(e)&&!_ee.test(e),q8=()=>!1,Iee=e=>Aee.test(e),Mee=e=>Tee.test(e),Ree=e=>!We(e)&&!qe(e),$ee=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Dee=e=>sl(e,j$,q8),We=e=>R$.test(e),Dl=e=>sl(e,F$,Pee),Y_=e=>sl(e,Bee,Lt),Nee=e=>sl(e,V$,D$),Lee=e=>sl(e,O$,q8),X_=e=>sl(e,N$,q8),jee=e=>sl(e,L$,Mee),fm=e=>sl(e,H$,Iee),qe=e=>$$.test(e),Ff=e=>Ec(e,F$),Fee=e=>Ec(e,O$),Q_=e=>Ec(e,N$),Oee=e=>Ec(e,j$),Vee=e=>Ec(e,L$),hm=e=>Ec(e,H$,!0),Hee=e=>Ec(e,V$,!0),sl=(e,t,n)=>{const r=R$.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ec=(e,t,n=!1)=>{const r=$$.exec(e);return r?r[1]?t(r[1]):n:!1},N$=e=>e==="position"||e==="percentage",L$=e=>e==="image"||e==="url",j$=e=>e==="length"||e==="size"||e==="bg-size",F$=e=>e==="length",Bee=e=>e==="number",O$=e=>e==="family-name",V$=e=>e==="number"||e==="weight",H$=e=>e==="shadow",zee=()=>{const e=rr("color"),t=rr("font"),n=rr("text"),r=rr("font-weight"),i=rr("tracking"),s=rr("leading"),o=rr("breakpoint"),a=rr("container"),c=rr("spacing"),u=rr("radius"),h=rr("shadow"),p=rr("inset-shadow"),m=rr("text-shadow"),g=rr("drop-shadow"),b=rr("blur"),x=rr("perspective"),C=rr("aspect"),w=rr("ease"),E=rr("animate"),_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...T(),qe,We],P=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],S=()=>[qe,We,c],R=()=>[fa,"full","auto",...S()],$=()=>[Rs,"none","subgrid",qe,We],L=()=>["auto",{span:["full",Rs,qe,We]},Rs,qe,We],j=()=>[Rs,"auto",qe,We],O=()=>["auto","min","max","fr",qe,We],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],B=()=>["start","end","center","stretch","center-safe","end-safe"],Z=()=>["auto",...S()],K=()=>[fa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...S()],q=()=>[fa,"screen","full","dvw","lvw","svw","min","max","fit",...S()],te=()=>[fa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...S()],F=()=>[e,qe,We],V=()=>[...T(),Q_,X_,{position:[qe,We]}],W=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N=()=>["auto","cover","contain",Oee,Dee,{size:[qe,We]}],z=()=>[xb,Ff,Dl],Q=()=>["","none","full",u,qe,We],J=()=>["",Lt,Ff,Dl],re=()=>["solid","dashed","dotted","double"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],X=()=>[Lt,xb,Q_,X_],de=()=>["","none",b,qe,We],ve=()=>["none",Lt,qe,We],we=()=>["none",Lt,qe,We],je=()=>[Lt,qe,We],Ae=()=>[fa,"full",...S()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[vo],breakpoint:[vo],color:[D$],container:[vo],"drop-shadow":[vo],ease:["in","out","in-out"],font:[Ree],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[vo],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[vo],shadow:[vo],spacing:["px",Lt],text:[vo],"text-shadow":[vo],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",fa,We,qe,C]}],container:["container"],"container-type":[{"@container":["","normal","size",qe,We]}],"container-named":[$ee],columns:[{columns:[Lt,We,qe,a]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:I()}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[Rs,"auto",qe,We]}],basis:[{basis:[fa,"full","auto",a,...S()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Lt,fa,"auto","initial","none",We]}],grow:[{grow:["",Lt,qe,We]}],shrink:[{shrink:["",Lt,qe,We]}],order:[{order:[Rs,"first","last","none",qe,We]}],"grid-cols":[{"grid-cols":$()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":j()}],"col-end":[{"col-end":j()}],"grid-rows":[{"grid-rows":$()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":j()}],"row-end":[{"row-end":j()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...B(),"normal"]}],"justify-self":[{"justify-self":["auto",...B()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...B(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...B(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...B(),"baseline"]}],"place-self":[{"place-self":["auto",...B()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pbs:[{pbs:S()}],pbe:[{pbe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:Z()}],mx:[{mx:Z()}],my:[{my:Z()}],ms:[{ms:Z()}],me:[{me:Z()}],mbs:[{mbs:Z()}],mbe:[{mbe:Z()}],mt:[{mt:Z()}],mr:[{mr:Z()}],mb:[{mb:Z()}],ml:[{ml:Z()}],"space-x":[{"space-x":S()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":S()}],"space-y-reverse":["space-y-reverse"],size:[{size:K()}],"inline-size":[{inline:["auto",...q()]}],"min-inline-size":[{"min-inline":["auto",...q()]}],"max-inline-size":[{"max-inline":["none",...q()]}],"block-size":[{block:["auto",...te()]}],"min-block-size":[{"min-block":["auto",...te()]}],"max-block-size":[{"max-block":["none",...te()]}],w:[{w:[a,"screen",...K()]}],"min-w":[{"min-w":[a,"screen","none",...K()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...K()]}],h:[{h:["screen","lh",...K()]}],"min-h":[{"min-h":["screen","lh","none",...K()]}],"max-h":[{"max-h":["screen","lh",...K()]}],"font-size":[{text:["base",n,Ff,Dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Hee,Nee]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xb,We]}],"font-family":[{font:[Fee,Lee,t]}],"font-features":[{"font-features":[We]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,qe,We]}],"line-clamp":[{"line-clamp":[Lt,"none",qe,Y_]}],leading:[{leading:[s,...S()]}],"list-image":[{"list-image":["none",qe,We]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",qe,We]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:[Lt,"from-font","auto",qe,Dl]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Lt,"auto",qe,We]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"tab-size":[{tab:[Rs,qe,We]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",qe,We]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",qe,We]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:W()}],"bg-size":[{bg:N()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Rs,qe,We],radial:["",qe,We],conic:[Rs,qe,We]},Vee,jee]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:Q()}],"rounded-s":[{"rounded-s":Q()}],"rounded-e":[{"rounded-e":Q()}],"rounded-t":[{"rounded-t":Q()}],"rounded-r":[{"rounded-r":Q()}],"rounded-b":[{"rounded-b":Q()}],"rounded-l":[{"rounded-l":Q()}],"rounded-ss":[{"rounded-ss":Q()}],"rounded-se":[{"rounded-se":Q()}],"rounded-ee":[{"rounded-ee":Q()}],"rounded-es":[{"rounded-es":Q()}],"rounded-tl":[{"rounded-tl":Q()}],"rounded-tr":[{"rounded-tr":Q()}],"rounded-br":[{"rounded-br":Q()}],"rounded-bl":[{"rounded-bl":Q()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-bs":[{"border-bs":J()}],"border-w-be":[{"border-be":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...re(),"hidden","none"]}],"divide-style":[{divide:[...re(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-bs":[{"border-bs":F()}],"border-color-be":[{"border-be":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...re(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Lt,qe,We]}],"outline-w":[{outline:["",Lt,Ff,Dl]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",h,hm,fm]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",p,hm,fm]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Lt,Dl]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",m,hm,fm]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Lt,qe,We]}],"mix-blend":[{"mix-blend":[...G(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":G()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Lt]}],"mask-image-linear-from-pos":[{"mask-linear-from":X()}],"mask-image-linear-to-pos":[{"mask-linear-to":X()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":X()}],"mask-image-t-to-pos":[{"mask-t-to":X()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":X()}],"mask-image-r-to-pos":[{"mask-r-to":X()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":X()}],"mask-image-b-to-pos":[{"mask-b-to":X()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":X()}],"mask-image-l-to-pos":[{"mask-l-to":X()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":X()}],"mask-image-x-to-pos":[{"mask-x-to":X()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":X()}],"mask-image-y-to-pos":[{"mask-y-to":X()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[qe,We]}],"mask-image-radial-from-pos":[{"mask-radial-from":X()}],"mask-image-radial-to-pos":[{"mask-radial-to":X()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Lt]}],"mask-image-conic-from-pos":[{"mask-conic-from":X()}],"mask-image-conic-to-pos":[{"mask-conic-to":X()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:V()}],"mask-repeat":[{mask:W()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",qe,We]}],filter:[{filter:["","none",qe,We]}],blur:[{blur:de()}],brightness:[{brightness:[Lt,qe,We]}],contrast:[{contrast:[Lt,qe,We]}],"drop-shadow":[{"drop-shadow":["","none",g,hm,fm]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Lt,qe,We]}],"hue-rotate":[{"hue-rotate":[Lt,qe,We]}],invert:[{invert:["",Lt,qe,We]}],saturate:[{saturate:[Lt,qe,We]}],sepia:[{sepia:["",Lt,qe,We]}],"backdrop-filter":[{"backdrop-filter":["","none",qe,We]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[Lt,qe,We]}],"backdrop-contrast":[{"backdrop-contrast":[Lt,qe,We]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Lt,qe,We]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Lt,qe,We]}],"backdrop-invert":[{"backdrop-invert":["",Lt,qe,We]}],"backdrop-opacity":[{"backdrop-opacity":[Lt,qe,We]}],"backdrop-saturate":[{"backdrop-saturate":[Lt,qe,We]}],"backdrop-sepia":[{"backdrop-sepia":["",Lt,qe,We]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",qe,We]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Lt,"initial",qe,We]}],ease:[{ease:["linear","initial",w,qe,We]}],delay:[{delay:[Lt,qe,We]}],animate:[{animate:["none",E,qe,We]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,qe,We]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:ve()}],"rotate-x":[{"rotate-x":ve()}],"rotate-y":[{"rotate-y":ve()}],"rotate-z":[{"rotate-z":ve()}],scale:[{scale:we()}],"scale-x":[{"scale-x":we()}],"scale-y":[{"scale-y":we()}],"scale-z":[{"scale-z":we()}],"scale-3d":["scale-3d"],skew:[{skew:je()}],"skew-x":[{"skew-x":je()}],"skew-y":[{"skew-y":je()}],transform:[{transform:[qe,We,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ae()}],"translate-x":[{"translate-x":Ae()}],"translate-y":[{"translate-y":Ae()}],"translate-z":[{"translate-z":Ae()}],"translate-none":["translate-none"],zoom:[{zoom:[Rs,qe,We]}],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",qe,We]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":F()}],"scrollbar-track-color":[{"scrollbar-track":F()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mbs":[{"scroll-mbs":S()}],"scroll-mbe":[{"scroll-mbe":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pbs":[{"scroll-pbs":S()}],"scroll-pbe":[{"scroll-pbe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",qe,We]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[Lt,Ff,Dl,Y_]}],stroke:[{stroke:["none",...F()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},B$=wee(zee);function zn(...e){return B$(W8(e))}const Ka={fast:{type:"spring",duration:.08,bounce:0},moderate:{type:"spring",duration:.16,bounce:.15}},J_=["#f59e0b","#38bdf8","#34d399","#a78bfa","#fb7185","#22d3ee","#fb923c","#a3e635","#e879f9","#2dd4bf"];function z$(e){let t=0;for(let r=0;r<e.length;r++)t=t*31+e.charCodeAt(r)|0;const n=J_[Math.abs(t)%J_.length];return{color:n,backgroundColor:`${n}22`}}function U$(e,t={}){const{axis:n="y"}=t,r=f.useRef(new Map),[i,s]=f.useState(null),[o,a]=f.useState([]),c=f.useRef([]),u=f.useRef(0),h=f.useRef(null),p=f.useRef(null),m=f.useCallback(()=>{if(!e.current)return;const E=[];r.current.forEach((_,T)=>{E[T]={top:_.offsetTop,height:_.offsetHeight,left:_.offsetLeft,width:_.offsetWidth}}),c.current=E,a(E)},[e]),g=f.useCallback((w,E)=>{E?r.current.set(w,E):r.current.delete(w),p.current!==null&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{p.current=null,m()})},[m]),b=f.useCallback(w=>{const E=w.clientX,_=w.clientY;h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null;const T=e.current;if(!T)return;const I=T.getBoundingClientRect(),P=n==="x"?E:_;let M=null,S=1/0,R=null;const $=c.current,L=n==="x"?T.scrollLeft:T.scrollTop,j=n==="x"?T.clientLeft:T.clientTop,O=n==="x"?I.left:I.top,H=n==="x"?T.offsetWidth:T.offsetHeight,B=n==="x"?I.width:I.height,Z=H>0?B/H:1;for(let K=0;K<$.length;K++){const q=$[K];if(!q)continue;const te=n==="x"?q.left:q.top,F=O+(j+te-L)*Z,V=(n==="x"?q.width:q.height)*Z,W=F+V;P>=F&&P<=W&&(R=K);const N=F+V/2,z=Math.abs(P-N);z<S&&(S=z,M=K)}s(R??M)})},[n,e]),x=f.useCallback(()=>{u.current+=1,m()},[m]),C=f.useCallback(()=>{h.current!==null&&(cancelAnimationFrame(h.current),h.current=null),s(null)},[]);return f.useEffect(()=>()=>{h.current!==null&&cancelAnimationFrame(h.current),p.current!==null&&cancelAnimationFrame(p.current)},[]),{activeIndex:i,setActiveIndex:s,itemRects:o,sessionRef:u,handlers:{onMouseMove:b,onMouseEnter:x,onMouseLeave:C},registerItem:g,measureItems:m}}function Uee(e,t,n){f.useEffect(()=>(e(t,n.current),()=>e(t,null)),[t,e,n])}const Zee=["⡡⠊⢔⠡","⠊⡰⡡⡘","⢔⢅⠈⢢","⡁⢂⠆⡍","⢔⠨⢑⢐","⠨⡑⡠⠊"],K8=({className:e}={})=>y.jsx("div",{className:`rivet-sparkle relative overflow-hidden font-mono leading-none ${e??"text-base text-primary"}`,style:{height:"1em",width:"4ch"},"aria-hidden":"true",children:y.jsx("div",{className:"rivet-sparkle-strip",children:Zee.map((t,n)=>y.jsx("span",{className:"block",style:{height:"1em",lineHeight:"1em"},children:t},n))})});function Wee(e){var i,s,o;const{sessionId:t,variant:n,projectContext:r}=e;return n.status!=="succeeded"?null:((i=n.preview)==null?void 0:i.kind)==="static_artifact"?n.preview.url:t&&(r==null?void 0:r.kind)==="fresh"&&((s=r.executionPlan)==null?void 0:s.mode)!=="vite_app"&&((o=n.preview)==null?void 0:o.kind)!=="dev_server"?`/api/variants/${t}/static/${n.workItemId}`:null}const eA=6,mi=$t("AgentVariantsPanel");function pm(e,...t){return e?t.some(n=>(n??"").toLowerCase().includes(e)):!0}async function su(e){try{const t=await e.json();return{message:typeof t.message=="string"?t.message:null,errorCode:typeof t.errorCode=="string"?t.errorCode:null}}catch{return{message:null,errorCode:null}}}const Gee=(e,t)=>e.length===t.length&&e.every((n,r)=>{const i=t[r];return n.sessionId===i.sessionId&&n.variantId===i.variantId&&n.label===i.label&&n.brief===i.brief&&n.createdAt===i.createdAt}),tA=()=>{var ee;const e=Ce(il),t=Ce(Y1),n=((ee=Ce(Ti).deployPrototype)==null?void 0:ee.isEnabled)??!1,r=Ce(Cp),i=Ce(U8),s=ze(gw),o=ze(i1),a=ze(vw),c=ze(w$),u=ze(Kh),h=ze(z8),p=ze(Cc),m=Ce(yw),g=ze(yw),[b,x]=f.useState(""),[C,w]=f.useState(null),[E,_]=f.useState({}),[T,I]=f.useState({}),[P,M]=f.useState(null),[S,R]=f.useState([]),$=f.useRef([]);$.current=S;const[L,j]=f.useState(null),O=f.useMemo(()=>e.active?e.variants:[],[e]),H=e.active?e.sessionId:null,B=f.useMemo(()=>[...H?S.filter(se=>se.sessionId!==H):S].sort((se,ce)=>{const le=new Date(se.createdAt).getTime(),ge=new Date(ce.createdAt).getTime();return(Number.isNaN(ge)?0:ge)-(Number.isNaN(le)?0:le)}),[S,H]),Z=e.active?e.projectContext:null,K=(Z==null?void 0:Z.kind)==="fresh"?Z.workspacePath:t,q=f.useMemo(()=>K?`?projectPath=${encodeURIComponent(K)}`:"",[K]),te=f.useRef(null),F=f.useRef(null),V=f.useRef(null),W=f.useRef(!1),N=f.useCallback((Y,se)=>{se.button!==0&&se.pointerType==="mouse"||(V.current={kind:"live",variantId:Y,startX:se.clientX,startY:se.clientY,committed:!1})},[]),z=f.useCallback((Y,se)=>{se.button!==0&&se.pointerType==="mouse"||(V.current={kind:"past",entry:Y,startX:se.clientX,startY:se.clientY,committed:!1})},[]);f.useEffect(()=>{const Y=le=>{const ge=V.current;if(!ge)return;const ke=le.clientX-ge.startX,$e=le.clientY-ge.startY;if(!ge.committed){if(ke*ke+$e*$e<eA*eA)return;const ct=window.getSelection();if(ct&&!ct.isCollapsed){V.current=null;return}if(ge.kind==="live"){const rt=O.find(Ze=>Ze.workItemId===ge.variantId);if(!rt||rt.status!=="succeeded"){V.current=null;return}const Jt=Wee({sessionId:H,variant:rt,projectContext:Z});u({sessionId:H??"",variantId:rt.workItemId,label:rt.label||"Direction",url:Jt,runLabel:rt.runLabel,description:rt.description})}else{const{entry:rt}=ge,Jt=`/api/variants/history/${encodeURIComponent(rt.sessionId)}/${encodeURIComponent(rt.variantId)}/preview${q}`;u({sessionId:rt.sessionId,variantId:rt.variantId,label:rt.label||"Direction",url:Jt,runLabel:rt.runLabel,description:rt.brief})}ge.committed=!0}h({x:le.clientX,y:le.clientY})},se=()=>{const le=V.current;le!=null&&le.committed&&(W.current=!0),V.current=null,h(null)},ce=le=>{var ge;le.key==="Escape"&&(ge=V.current)!=null&&ge.committed&&(V.current=null,u(null),h(null))};return window.addEventListener("pointermove",Y),window.addEventListener("pointerup",se),window.addEventListener("pointercancel",se),window.addEventListener("keydown",ce),()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",se),window.removeEventListener("pointercancel",se),window.removeEventListener("keydown",ce)}},[O,H,Z,q,u,h]);const Q=f.useMemo(()=>{var se;if(L)return null;const Y=m?O.find(ce=>ce.workItemId===m):null;return Y?Y.status==="succeeded"?Y.workItemId:null:e.active?((se=O.find(ce=>{var le,ge;return ce.status==="succeeded"&&(((le=ce.preview)==null?void 0:le.kind)==="static_artifact"||((ge=ce.preview)==null?void 0:ge.kind)==="dev_server")}))==null?void 0:se.workItemId)??null:null},[m,L,e,O]),J=f.useCallback(async Y=>{var ce,le,ge,ke;if(!H)return;const se=(Y==null?void 0:Y.workItemId)??null;w({kind:"switch",variantId:se??void 0});try{if(((ce=Y==null?void 0:Y.preview)==null?void 0:ce.kind)==="static_artifact"){if(a(!1),c(null),((le=Y.refinement)==null?void 0:le.status)==="succeeded"){const rt=Y.preview.url.includes("?")?"&":"?";o(`${Y.preview.url}${rt}refinement=${encodeURIComponent(Y.refinement.workItemId)}`)}else o(Y.preview.url);s(rt=>rt+1);return}if(se&&H&&e.active&&e.projectContext.kind==="fresh"&&((ge=e.projectContext.executionPlan)==null?void 0:ge.mode)!=="vite_app"&&((ke=Y==null?void 0:Y.preview)==null?void 0:ke.kind)!=="dev_server"){a(!1),c(null),o(`/api/variants/${H}/static/${se}`),s(rt=>rt+1);return}a(!0);const $e=await fetch(`/api/variants/${H}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:se})});if(!$e.ok){mi.warn(`switch failed: HTTP ${$e.status}`),a(!1),c(null);return}const{port:ct}=await $e.json();o(null),c(ct!==null?se:null),ct!==null&&s(rt=>rt+1)}catch($e){mi.warn("preview-port switch failed",$e),a(!1),c(null)}finally{w(null)}},[H,e,s,o,a,c]),re=f.useCallback(Y=>{if(W.current){W.current=!1;return}const se=Y.status==="succeeded",ce=Y.status==="pending"||Y.status==="running";if(!se&&!ce)return;const le=O.find(ge=>ge.workItemId===m);g(Y.workItemId),j(null),se?(F.current=Y.workItemId,p(null),J(Y)):(o(null),a(!1)),yt.capture("variants_panel.preview_switched",{sessionId:H,fromVariantId:le==null?void 0:le.workItemId,toVariantId:Y.workItemId,armed:ce})},[m,H,p,g,J,O,o,a]),G=e.active?`${e.sessionId}:${e.stage}`:"inactive";f.useEffect(()=>{let Y=!1;return(async()=>{try{const se=await fetch(`/api/variants/history${q}`,{credentials:"same-origin"});if(!se.ok)return;const ce=await se.json();if(Y)return;const le=(ce.variants??[]).filter(ge=>{var ke;return((ke=ge.preview)==null?void 0:ke.kind)==="static"});if(Gee($.current,le))return;$.current=le,R(le)}catch(se){mi.warn("Failed to load past variants",se)}})(),()=>{Y=!0}},[G,q]);const X=f.useCallback(Y=>{if(W.current){W.current=!1;return}p(null),j(`${Y.sessionId}:${Y.variantId}`),g(null),a(!1),c(null),o(`/api/variants/history/${encodeURIComponent(Y.sessionId)}/${encodeURIComponent(Y.variantId)}/preview${q}`)},[j,g,o,c,p,a,q]),de=f.useCallback(async Y=>{var ce,le;const se=((le=(ce=Y.actions)==null?void 0:ce.commit)==null?void 0:le.enabled)??Y.status==="succeeded";if(!(!H||!se)){yt.capture("variants_panel.commit_clicked",{sessionId:H,variantId:Y.workItemId,variantLabel:Y.label}),w({kind:"commit",variantId:Y.workItemId});try{const ge=await fetch(`/api/variants/${H}/commit`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:Y.workItemId})});if(!ge.ok){const{message:$e,errorCode:ct}=await su(ge);mi.warn(`commit failed: HTTP ${ge.status} ${ct??""} ${$e??""}`),yt.capture("variants_panel.commit_failed",{sessionId:H,variantId:Y.workItemId,httpStatus:ge.status,errorCode:ct??null,errorMessage:$e??null}),lt.error("Couldn't send direction",{description:$e??`The server rejected the request (HTTP ${ge.status}). Try again, or pick a different direction.`});return}const ke=await ge.json().catch(()=>null);yt.capture("variants_panel.commit_succeeded",{sessionId:H,variantId:Y.workItemId,payloadKind:(ke==null?void 0:ke.payloadKind)??null,duplicate:(ke==null?void 0:ke.duplicate)??!1}),lt.success(`Sent "${Y.label}" to your project`,{description:(ke==null?void 0:ke.payloadKind)==="project-created"?`Project created at ${(ke==null?void 0:ke.destinationPath)??"destination"}.`:"Direction diff applied to your working tree (uncommitted)."}),(ke==null?void 0:ke.payloadKind)!=="project-created"&&(o(null),a(!1),s($e=>$e+1))}catch(ge){mi.warn("commit failed",ge),yt.capture("variants_panel.commit_failed",{sessionId:H,variantId:Y.workItemId,httpStatus:null,errorCode:"NETWORK_ERROR",errorMessage:ge instanceof Error?ge.message:String(ge)}),lt.error("Couldn't send direction",{description:"Network or server error. Check that the Rivet backend is reachable and try again."})}finally{w(null)}}},[H,s,o,a]),ve=f.useCallback(async(Y,se,ce)=>{yt.capture("variants_panel.deploy_clicked",{sessionId:Y,variantId:se,variantLabel:ce});try{const le=await fetch(`/api/variants/${Y}/deploy`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:se,...t?{projectPath:t}:{}})});if(!le.ok){const{message:$e,errorCode:ct}=await su(le);return mi.warn(`deploy failed: HTTP ${le.status} ${ct??""} ${$e??""}`),yt.capture("variants_panel.deploy_failed",{sessionId:Y,variantId:se,httpStatus:le.status,errorCode:ct??null,errorMessage:$e??null}),lt.error("Couldn't deploy this direction",{description:$e??`The server rejected the request (HTTP ${le.status}). Try again.`}),null}const ge=await le.json().catch(()=>null),ke=ge==null?void 0:ge.shareUrl;return ke?(await navigator.clipboard.writeText(ke).catch(()=>{}),yt.capture("variants_panel.deploy_succeeded",{sessionId:Y,variantId:se}),lt.success(`"${ce}" is live — link copied`,{action:{label:"Open",onClick:()=>window.open(ke,"_blank","noopener")}}),ke):(lt.error("Couldn't deploy this direction",{description:"The deploy host returned an unexpected response."}),null)}catch(le){return mi.warn("deploy failed",le),yt.capture("variants_panel.deploy_failed",{sessionId:Y,variantId:se,httpStatus:null,errorCode:"NETWORK_ERROR",errorMessage:le instanceof Error?le.message:String(le)}),lt.error("Couldn't deploy this direction",{description:"Network or server error. Check that the Rivet backend is reachable and try again."}),null}},[t]),we=f.useCallback(async Y=>{if(!H)return;const se=E[Y.workItemId];if(se){await navigator.clipboard.writeText(se).catch(()=>{}),lt.success("Share link copied",{action:{label:"Open",onClick:()=>window.open(se,"_blank","noopener")}});return}w({kind:"deploy",variantId:Y.workItemId});try{const ce=await ve(H,Y.workItemId,Y.label);ce&&_(le=>({...le,[Y.workItemId]:ce}))}finally{w(null)}},[H,E,ve]),je=f.useCallback(async Y=>{const se=`${Y.sessionId}:${Y.variantId}`,ce=T[se];if(ce){await navigator.clipboard.writeText(ce).catch(()=>{}),lt.success("Share link copied",{action:{label:"Open",onClick:()=>window.open(ce,"_blank","noopener")}});return}M(se);try{const le=await ve(Y.sessionId,Y.variantId,Y.label);le&&I(ge=>({...ge,[se]:le}))}finally{M(null)}},[T,ve]),Ae=f.useCallback(async()=>{if(H){w({kind:"cancel"});try{await fetch(`/api/variants/${H}/cancel`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({reason:"user-dismissed-from-panel"})}),o(null),a(!1),s(Y=>Y+1)}catch(Y){mi.warn("cancel failed",Y)}finally{w(null)}}},[H,s,o,a]),Le=f.useCallback(async Y=>{if(H){yt.capture("variants_panel.remove_clicked",{sessionId:H,variantId:Y.workItemId,variantLabelLength:Y.label.length}),w({kind:"remove",variantId:Y.workItemId});try{const se=await fetch(`/api/variants/${H}/${Y.workItemId}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:"{}"});if(!se.ok){const{message:ce}=await su(se);mi.warn(`remove failed: HTTP ${se.status} ${ce??""}`),lt.error("Couldn't remove direction",{description:ce??`The server rejected the request (HTTP ${se.status}). Try again.`});return}(Y.workItemId===Q||Y.workItemId===m)&&(g(null),o(null),a(!1),s(ce=>ce+1))}catch(se){mi.warn("remove failed",se),lt.error("Couldn't remove direction",{description:"Network or server error. Try again."})}finally{w(null)}}},[H,m,Q,g,o,a,s]),tt=f.useCallback(async Y=>{if(!K){lt.error("Couldn't remove direction",{description:"No project path available."});return}yt.capture("variants_panel.remove_past_clicked",{sessionId:Y.sessionId,variantId:Y.variantId});const se=`${Y.sessionId}:${Y.variantId}`,ce=le=>le.sessionId===Y.sessionId&&le.variantId===Y.variantId;R(le=>le.filter(ge=>!ce(ge))),L===se&&(j(null),o(null),a(!1),s(le=>le+1));try{const le=await fetch(`/api/variants/history/${encodeURIComponent(Y.sessionId)}/${encodeURIComponent(Y.variantId)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:K})});if(!le.ok){const{message:ge}=await su(le);R(ke=>ke.some(ce)?ke:[...ke,Y]),lt.error("Couldn't remove direction",{description:ge??`The server rejected the request (HTTP ${le.status}). Try again.`})}}catch(le){mi.warn("remove past failed",le),R(ge=>ge.some(ce)?ge:[...ge,Y]),lt.error("Couldn't remove direction",{description:"Network or server error. Try again."})}},[K,L,o,a,s]),[vt,Je]=f.useState(null),[ye,Ke]=f.useState(null),Dt=f.useCallback(Y=>{Ke(Y)},[]),Mt=f.useCallback(()=>{Ke(null)},[]),jt=f.useCallback(async Y=>{const se=Y.trim();if(se)try{await navigator.clipboard.writeText(se),lt.success("Description copied")}catch{lt.error("Couldn't copy description")}},[]),bn=f.useCallback(async(Y,se)=>{Ke(null);const ce=se.trim();if(!ce)return;if(Y.kind==="active"){if(!H||ce===Y.variant.label)return;yt.capture("variants_panel.rename",{sessionId:H,variantId:Y.variant.workItemId,labelLength:ce.length,past:!1});try{const ke=await fetch(`/api/variants/${H}/${Y.variant.workItemId}/rename`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({label:ce})});if(!ke.ok){const{message:$e}=await su(ke);lt.error("Couldn't rename direction",{description:$e??`The server rejected the request (HTTP ${ke.status}). Try again.`})}}catch(ke){mi.warn("rename failed",ke),lt.error("Couldn't rename direction",{description:"Network or server error. Try again."})}return}const{entry:le}=Y;if(ce===le.label.trim())return;if(!K){lt.error("Couldn't rename direction",{description:"No project path available."});return}yt.capture("variants_panel.rename",{sessionId:le.sessionId,variantId:le.variantId,labelLength:ce.length,past:!0});const ge=ke=>ke.sessionId===le.sessionId&&ke.variantId===le.variantId;R(ke=>ke.map($e=>ge($e)?{...$e,label:ce}:$e));try{const ke=await fetch(`/api/variants/history/${encodeURIComponent(le.sessionId)}/${encodeURIComponent(le.variantId)}/rename`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({label:ce,projectPath:K})});if(!ke.ok){const{message:$e}=await su(ke);R(ct=>ct.map(rt=>ge(rt)?{...rt,label:le.label}:rt)),lt.error("Couldn't rename direction",{description:$e??`The server rejected the request (HTTP ${ke.status}). Try again.`})}}catch(ke){mi.warn("rename failed",ke),R($e=>$e.map(ct=>ge(ct)?{...ct,label:le.label}:ct)),lt.error("Couldn't rename direction",{description:"Network or server error. Try again."})}},[H,K]);f.useEffect(()=>{if(te.current!==H){const se=te.current===null;if(te.current=H,F.current=null,o(null),a(!1),c(null),p(null),g(null),j(null),!se)return}if(L||!Q||e.active!==!0||F.current===Q)return;const Y=O.find(se=>se.workItemId===Q);Y&&(F.current=Q,p(null),J(Y))},[H,L,Q,e,O,J,p,g]),f.useEffect(()=>{const Y=b.trim().toLowerCase(),se=O.filter($e=>$e.status==="succeeded"&&pm(Y,$e.label,$e.runLabel)),ce=B.filter($e=>pm(Y,$e.label,$e.runLabel,$e.brief));if(se.length===0&&ce.length===0)return;const le=[...se.map($e=>({source:"live",variant:$e})),...ce.map($e=>({source:"past",entry:$e}))],ge=$e=>$e.source==="live"?`live:${$e.variant.workItemId}`:`past:${$e.entry.sessionId}:${$e.entry.variantId}`,ke=$e=>{if($e.key==="Enter"){const Nt=O.find(At=>At.workItemId===vt);Nt&&Nt.status==="succeeded"&&($e.preventDefault(),re(Nt));return}if($e.key!=="ArrowUp"&&$e.key!=="ArrowDown")return;$e.preventDefault();const ct=Q?`live:${Q}`:null,rt=L?`past:${L}`:ct,Jt=rt?le.findIndex(Nt=>ge(Nt)===rt):-1;let Ze;if(Jt===-1?Ze=$e.key==="ArrowDown"?0:le.length-1:$e.key==="ArrowDown"?Ze=Math.min(Jt+1,le.length-1):Ze=Math.max(Jt-1,0),Ze===Jt)return;const wt=le[Ze];wt.source==="live"?re(wt.variant):X(wt.entry);const De=document.querySelector(`[data-variant-key="${ge(wt)}"]`);De instanceof HTMLElement&&De.focus({preventScroll:!0})};return window.addEventListener("keydown",ke),()=>window.removeEventListener("keydown",ke)},[O,B,b,L,Q,vt,re,X]);const nn="Directions",he=O.find(Y=>Y.workItemId===Q)??null,be=L?S.find(Y=>`${Y.sessionId}:${Y.variantId}`===L)??null:null,Ue=!!(be&&n),ot=e.active?e.artifacts??[]:[],at=[...e.active?O.map(Y=>({kind:"active",variant:Y})):[],...B.map(Y=>({kind:"past",entry:Y}))],Ht=b.trim().toLowerCase(),Ut=Ht?at.filter(Y=>Y.kind==="active"?pm(Ht,Y.variant.label,Y.variant.runLabel):pm(Ht,Y.entry.label,Y.entry.runLabel,Y.entry.brief)):at;return y.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y.jsx(rte,{label:nn}),at.length>0?y.jsx("div",{className:"px-3 pt-2 pb-1",children:y.jsxs("div",{className:"relative",children:[y.jsx(a8,{size:13,className:"text-content-muted pointer-events-none absolute top-1/2 left-2 -translate-y-1/2"}),y.jsx("input",{type:"text",value:b,onChange:Y=>x(Y.target.value),placeholder:"Search variants…","aria-label":"Search variants",className:"border-main-border bg-main-input/40 text-content placeholder:text-content-muted focus:ring-content-muted/40 w-full rounded-md border py-1.5 pr-2 pl-7 text-xs focus:ring-1 focus:outline-none"})]})}):null,y.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2",children:[e.active&&O.length===0?y.jsx(ste,{stage:e.stage}):null,!e.active&&B.length===0?y.jsx(ote,{isMCPSession:r,mcpEditor:i}):null,at.length>0&&Ut.length===0?y.jsxs("p",{className:"text-content-muted px-1 py-6 text-center text-xs",children:["No variants match “",b.trim(),"”."]}):null,Ut.length>0?y.jsx(qee,{rows:Ut,activeVariantId:m??Q,activePastKey:L,busy:C,editingKey:ye,onSelectActive:re,onSelectPast:X,onActivePointerDown:N,onPastPointerDown:z,onHover:Je,onRemove:Le,onRemovePast:tt,onStartRename:Dt,onCommitRename:bn,onCancelRename:Mt,onCopyDescription:jt}):null,e.active?y.jsx(ete,{artifacts:ot}):null]}),Ue&&be?y.jsx(Xee,{entry:be,deploying:P===L,deployedUrl:L?T[L]??null:null,onDeploy:je}):null,!Ue&&e.active?y.jsx(ite,{selectedVariant:he,busy:C,canCancel:C===null,onCancel:Ae,onSend:de,onDeploy:we,canDeploy:n&&(Z==null?void 0:Z.kind)==="fresh",deployedUrl:he?E[he.workItemId]??null:null,mcpEditor:i,isMCPSession:r}):null]})},qee=({rows:e,activeVariantId:t,activePastKey:n,busy:r,editingKey:i,onSelectActive:s,onSelectPast:o,onActivePointerDown:a,onPastPointerDown:c,onHover:u,onRemove:h,onRemovePast:p,onStartRename:m,onCommitRename:g,onCancelRename:b,onCopyDescription:x})=>{const C=f.useRef(null),{activeIndex:w,itemRects:E,sessionRef:_,handlers:T,registerItem:I}=U$(C),P=(r==null?void 0:r.kind)==="switch",M=w!==null?E[w]:null;return y.jsxs("div",{ref:C,className:"relative",onMouseEnter:T.onMouseEnter,onMouseMove:T.onMouseMove,onMouseLeave:T.onMouseLeave,children:[y.jsx(ds,{children:M&&y.jsx(dn.div,{className:"bg-hover pointer-events-none absolute z-0 rounded-md",initial:{opacity:0,top:M.top,left:M.left,width:M.width,height:M.height},animate:{opacity:1,top:M.top,left:M.left,width:M.width,height:M.height},exit:{opacity:0,transition:{duration:.06}},transition:{...Ka.fast,opacity:{duration:.08}}},_.current)}),y.jsx("ul",{className:"relative",children:e.map((S,R)=>{const $=S.kind==="active"?`live:${S.variant.workItemId}`:`past:${S.entry.sessionId}:${S.entry.variantId}`,L=S.kind==="active"?S.variant.workItemId===t:`${S.entry.sessionId}:${S.entry.variantId}`===n;return y.jsx(Kee,{rowKey:$,row:S,index:R,isSelected:L,isEditing:i===$,isSwitchInFlight:P,busy:r,registerItem:I,onSelectActive:s,onSelectPast:o,onActivePointerDown:a,onPastPointerDown:c,onHover:u,onRemove:h,onRemovePast:p,onStartRename:m,onCommitRename:g,onCancelRename:b,onCopyDescription:x},$)})})]})},Kee=({rowKey:e,row:t,index:n,isSelected:r,isEditing:i,isSwitchInFlight:s,busy:o,registerItem:a,onSelectActive:c,onSelectPast:u,onActivePointerDown:h,onPastPointerDown:p,onHover:m,onRemove:g,onRemovePast:b,onStartRename:x,onCommitRename:C,onCancelRename:w,onCopyDescription:E})=>{var F,V,W,N;const _=f.useRef(null);Uee(a,n,_);const T=t.kind==="active",I=t.kind==="active"?t.variant:null,P=t.kind==="past"?t.entry:null,M=T?I.status==="succeeded":!0,S=T&&(I.status==="pending"||I.status==="running"),R=T?M||S:!0,$=T&&I.status==="failed",L=T&&I.status==="cancelled",j=T&&(((F=I.refinement)==null?void 0:F.status)==="pending"||((V=I.refinement)==null?void 0:V.status)==="running"),O=T&&((W=I.refinement)==null?void 0:W.status)==="succeeded",H=T&&((N=I.refinement)==null?void 0:N.status)==="failed",B=T&&(!R||s),Z=T&&(o==null?void 0:o.kind)==="remove"&&o.variantId===I.workItemId,K=T?I.label||`Direction ${n+1}`:P.label.trim()||"Untitled direction",q=T?I.runLabel:P.runLabel,te=T?I.description:P.brief;return i?y.jsx("li",{ref:_,"data-proximity-index":n,className:"group relative z-10",children:y.jsx("div",{className:"bg-main-input flex w-full items-start gap-2 rounded-md px-3 py-2",children:y.jsxs("span",{className:"min-w-0 flex-1",children:[y.jsx(Yee,{initial:K,onCommit:z=>C(t,z),onCancel:w}),te&&y.jsx("span",{className:"text-content-muted mt-1 line-clamp-2 block text-xs leading-snug",children:te})]})})}):y.jsxs("li",{ref:_,"data-proximity-index":n,className:"group relative z-10",children:[y.jsxs("div",{role:"button",tabIndex:R?0:-1,"data-variant-id":T?I.workItemId:void 0,"data-variant-key":e,onClick:()=>{if(B)return;const z=window.getSelection();z&&!z.isCollapsed||(t.kind==="active"?c(t.variant):u(t.entry))},onKeyDown:z=>{B||(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),z.stopPropagation(),t.kind==="active"?c(t.variant):u(t.entry))},onPointerDown:z=>{B||(t.kind==="active"?M&&h(t.variant.workItemId,z):p(t.entry,z))},"aria-pressed":R?r:void 0,"aria-disabled":T?!R:void 0,"aria-busy":S,onMouseEnter:T?()=>m(I.workItemId):void 0,onMouseLeave:T?()=>m(null):void 0,className:zn("focus-visible:ring-content-muted/40 flex w-full items-start gap-2 rounded-md px-3 py-2 text-left transition-colors focus:outline-none focus-visible:ring-1",r&&"bg-main-input ring-content-muted/40 ring-1 ring-inset",M&&"cursor-grab active:cursor-grabbing",S&&"cursor-pointer",!M&&!S&&"cursor-not-allowed opacity-60",B&&"cursor-not-allowed opacity-50"),style:M?{touchAction:"none"}:void 0,children:[S&&y.jsx(K8,{className:"text-content-muted mt-0.5 shrink-0 text-sm"}),y.jsxs("span",{className:"min-w-0 flex-1",children:[y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx("span",{title:"Double-click to rename",onDoubleClick:z=>{z.stopPropagation(),x(e)},className:zn("min-w-0 flex-1 cursor-text truncate text-sm font-medium select-text",M||r?"text-content":"text-content-muted"),children:K}),$&&y.jsx(Of,{label:"Failed"}),L&&y.jsx(Of,{label:"Cancelled"}),j&&y.jsx(Of,{label:"Refining"}),O&&y.jsx(Of,{label:"Refined"}),H&&y.jsx(Of,{label:"Refine failed"})]}),te&&y.jsx("span",{className:"text-content-muted mt-0.5 line-clamp-2 block cursor-text text-xs leading-snug select-text",children:te})]}),y.jsx("span",{className:"relative mt-0.5 ml-1 flex h-5 shrink-0 items-center justify-end",children:q&&y.jsx("span",{className:zn("max-w-[8rem] truncate rounded px-1.5 py-0.5 text-[10px] font-medium opacity-100 transition-opacity duration-150 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0"),style:z$(q),children:q})})]}),y.jsxs("div",{className:zn("absolute top-1.5 right-2 flex items-center gap-0.5 transition-opacity duration-150","pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100"),children:[te&&y.jsx("button",{type:"button","aria-label":"Copy description",title:"Copy description",onClick:z=>{z.stopPropagation(),E(te)},onPointerDown:z=>z.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:y.jsx(H1,{size:13,weight:"bold"})}),y.jsx("button",{type:"button","aria-label":"Rename direction",title:"Rename direction",onClick:z=>{z.stopPropagation(),x(e)},onPointerDown:z=>z.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:y.jsx(tM,{size:13,weight:"bold"})}),y.jsx("button",{type:"button","data-variant-remove-id":t.kind==="active"?t.variant.workItemId:void 0,"aria-label":"Remove direction",title:"Remove direction",disabled:Z,onClick:z=>{z.stopPropagation(),t.kind==="active"?g(t.variant):b(t.entry)},onPointerDown:z=>z.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 ml-1 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",children:y.jsx(mM,{size:13,weight:"bold"})})]})]})},Yee=({initial:e,onCommit:t,onCancel:n})=>{const[r,i]=f.useState(e),s=f.useRef(!1),o=f.useCallback(c=>{c&&(c.focus(),c.select())},[]),a=c=>{s.current||(s.current=!0,c?t(r):n())};return y.jsx("input",{ref:o,type:"text",value:r,maxLength:120,"aria-label":"Rename direction",onChange:c=>i(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?(c.preventDefault(),a(!0)):c.key==="Escape"&&(c.preventDefault(),a(!1))},onBlur:()=>a(!0),onClick:c=>c.stopPropagation(),onPointerDown:c=>c.stopPropagation(),className:"border-content-muted/40 bg-main text-content focus:ring-content-muted/50 w-full rounded border px-1.5 py-0.5 text-sm font-medium focus:ring-1 focus:outline-none"})},Of=({label:e})=>y.jsx("span",{className:"bg-main-input text-content-muted shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase",children:e}),Xee=({entry:e,deploying:t,deployedUrl:n,onDeploy:r})=>{const s=t?"Deploying…":n?"Copy link":"Deploy & Share";return y.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"text-content truncate text-sm font-medium",children:e.label.trim()||"Untitled direction"}),n?y.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}),y.jsxs("button",{type:"button",onClick:()=>r(e),disabled:t,title:n?`Copy share link (${n})`:"Deploy this direction and get a public link to share",className:"border-main-border text-content hover:bg-main-input flex shrink-0 items-center gap-1 rounded-md border px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[n&&!t?y.jsx(H1,{size:12,weight:"bold"}):null,s]})]})},Qee={agent_browser:"Browser extracted",cache:"Cached",static:"Bundled catalog",manual:"Manual"},Jee={design_context:"DESIGN.md",source_context:"Source",qa_report:"QA",asset:"Asset"},ete=({artifacts:e})=>{const[t,n]=f.useState(null),r=f.useMemo(()=>t&&e.some(s=>s.id===t)?t:null,[e,t]);if(e.length===0)return null;const i=s=>{n(o=>o===s?null:s)};return y.jsxs("section",{"aria-label":"Directions session artifacts",className:"mt-4",children:[y.jsx("div",{className:"flex shrink-0 items-center px-3 py-2",children:y.jsx("span",{className:"text-content truncate text-sm font-medium",children:"Artifacts"})}),y.jsx("ul",{className:"mt-2 space-y-1 px-1",children:e.map(s=>y.jsx(tte,{artifact:s,isExpanded:s.id===r,onToggle:()=>i(s.id)},s.id))})]})},tte=({artifact:e,isExpanded:t,onToggle:n})=>{const r=Jee[e.kind],i=e.source?Qee[e.source]:null,s=[e.kind==="design_context"?null:i,e.summary].filter(Boolean).join(" · "),o=e.kind==="design_context"&&!!e.viewUrl,a=`${t?"Hide":"View"} ${r} artifact${e.label?`: ${e.label}`:""}`;return o?y.jsx("li",{className:"border-main-border rounded-md border",children:y.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs",children:[y.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"border-content-muted/30 bg-main-input text-content-muted shrink-0 rounded-full border px-2 py-0.5 text-[9px] font-semibold tracking-wide uppercase",children:r}),y.jsx("span",{className:"text-content truncate text-xs font-medium",children:e.label})]}),s?y.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:s}):null]}),y.jsx("a",{href:e.viewUrl,target:"_blank",rel:"noreferrer","aria-label":`Open ${r} artifact${e.label?`: ${e.label}`:""}`,className:"text-content-muted hover:bg-main-input hover:text-content focus-visible:ring-content-muted/40 shrink-0 rounded p-1 transition-colors focus:outline-none focus-visible:ring-1",children:y.jsx(i8,{className:"h-3.5 w-3.5",weight:"bold"})})]})}):y.jsxs("li",{className:"border-main-border rounded-md border",children:[y.jsxs("button",{type:"button",onClick:n,"aria-expanded":t,"aria-label":a,className:"hover:bg-main-input flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs transition-colors",children:[y.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-content-muted text-[10px] font-semibold tracking-wide uppercase",children:r}),y.jsx("span",{className:"text-content truncate text-xs font-medium",children:e.label})]}),s?y.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:s}):null]}),y.jsx("span",{className:"text-content-muted shrink-0 text-[11px]",children:t?"Hide":"View"})]}),t?y.jsx("div",{className:"border-main-border bg-main-light border-t px-3 py-2",children:y.jsx(nte,{artifact:e})}):null]})},nte=({artifact:e})=>y.jsxs("div",{className:"text-content-muted space-y-1 text-[11px]",children:[e.summary?y.jsx("p",{children:e.summary}):null,e.path?y.jsxs("p",{children:["Stored at ",e.path]}):null,!e.summary&&!e.path?y.jsx("p",{children:"No inline content available for this artifact."}):null]}),rte=({label:e})=>y.jsx("div",{className:"flex shrink-0 items-center px-3 py-2",children:y.jsx("span",{className:"text-content truncate text-sm font-medium",title:e,children:e})}),ite=({selectedVariant:e,busy:t,canCancel:n,onCancel:r,onSend:i,onDeploy:s,canDeploy:o,deployedUrl:a,mcpEditor:c,isMCPSession:u})=>{var T,I,P,M,S,R;const h=((T=e==null?void 0:e.refinement)==null?void 0:T.status)==="pending"||((I=e==null?void 0:e.refinement)==null?void 0:I.status)==="running",p=e?(((M=(P=e.actions)==null?void 0:P.commit)==null?void 0:M.enabled)??e.status==="succeeded")&&!h:!1,m=p&&t===null,g=(t==null?void 0:t.kind)==="commit"&&t.variantId===(e==null?void 0:e.workItemId),b=(t==null?void 0:t.kind)==="deploy"&&t.variantId===(e==null?void 0:e.workItemId),x=o&&p,w=b?"Deploying…":a?"Copy link":"Deploy & Share",E=u?Z$(c):"agent",_=g?"Sending…":`Send to ${E}`;return y.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-2 border-t px-3 pt-2 pb-4",children:[y.jsx("button",{type:"button",onClick:r,disabled:!n,className:"text-content-muted hover:bg-main-input hover:text-content rounded-md px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:"Clear all"}),y.jsxs("div",{className:"flex items-center gap-2",children:[x?y.jsxs("button",{type:"button",onClick:()=>{e&&s(e)},disabled:t!==null,title:a?`Copy share link (${a})`:"Build this direction and get a public link to share for feedback",className:"border-main-border text-content hover:bg-main-input flex items-center gap-1 rounded-md border px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[a&&!b?y.jsx(H1,{size:12,weight:"bold"}):null,w]}):null,y.jsx("button",{type:"button",onClick:()=>{e&&i(e)},disabled:!m,title:h?"Wait for this refinement to finish before sending":(R=(S=e==null?void 0:e.actions)==null?void 0:S.commit)==null?void 0:R.reason,className:"bg-secondary text-secondary-foreground hover:bg-accent rounded-md px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:_})]})]})},ste=({stage:e})=>y.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[y.jsx("div",{className:"text-content text-sm",children:"No directions ready yet."}),y.jsxs("div",{className:"text-content-muted text-xs",children:["Stage: ",e]})]});function Z$(e){return e==="cursor"?"Cursor":e==="codex"?"Codex":e==="claude-desktop"?"Claude":"Claude Code"}const nA="Try different ways to create a dropdown that feels fluid and dynamic",ote=({isMCPSession:e=!1,mcpEditor:t=null})=>{const[n,r]=f.useState(!1),i=Z$(t),s=e?i:"your coding agent",o=()=>{navigator.clipboard.writeText(nA).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})};return y.jsxs("div",{className:"flex flex-col items-start gap-3 px-2 py-2",children:[y.jsxs("p",{className:"text-content text-sm font-medium",children:["Go to ",s," to create directions"]}),y.jsxs("div",{className:"w-full",children:[y.jsx("p",{className:"text-content-muted mb-2 text-xs",children:"Here's a sample prompt to use:"}),y.jsxs("div",{className:"border-main-border bg-main-input relative rounded-md border px-3 py-2.5 pr-8",children:[y.jsxs("p",{className:"text-content-muted text-xs leading-snug",children:["“",nA,"”"]}),y.jsx("button",{type:"button",onClick:o,className:"text-content-muted hover:bg-main-border hover:text-content absolute top-2 right-2 rounded p-0.5 transition-colors",title:"Copy to clipboard",children:n?y.jsx(za,{className:"h-3.5 w-3.5 text-emerald-500",weight:"bold"}):y.jsx(H1,{className:"h-3.5 w-3.5",weight:"bold"})})]})]})]})},W$={pill:{item:"rounded-[20px]",bg:"rounded-[20px]",focusRing:"rounded-[22px]",mergedBg:"rounded-2xl",container:"rounded-3xl",button:"rounded-[20px]",input:"rounded-[20px]"},rounded:{item:"rounded-lg",bg:"rounded-lg",focusRing:"rounded-[10px]",mergedBg:"rounded-lg",container:"rounded-xl",button:"rounded-lg",input:"rounded-lg"}},G$=f.createContext(null);function Md(){const e=f.useContext(G$);return e?e.classes:W$.pill}function ate(e){const t=document.documentElement;t.classList.add("transitioning"),t.offsetHeight,e(),setTimeout(()=>t.classList.remove("transitioning"),200)}function lte({children:e,defaultShape:t="pill"}){const[n,r]=f.useState(t),i=f.useCallback(s=>{ate(()=>r(s))},[]);return y.jsx(G$.Provider,{value:{shape:n,setShape:i,classes:W$[n]},children:e})}function cte({value:e,onValueChange:t,options:n,className:r,"aria-label":i}){const s=Md(),o=f.useId();return y.jsx("div",{role:"tablist","aria-label":i,className:zn("relative flex gap-1",r),children:n.map(a=>{const c=a.value===e;return y.jsxs("button",{type:"button",role:"tab","aria-selected":c,"data-cy":a["data-cy"],onClick:()=>t(a.value),className:zn("relative flex-1 select-none px-3 py-1 text-xs font-medium outline-none transition-colors",s.item,c?"text-content":"text-content-subtle hover:text-content"),children:[c?y.jsx(dn.span,{layoutId:o,className:zn("bg-main-input absolute inset-0",s.bg),transition:Ka.fast}):null,y.jsx("span",{className:"relative z-10",children:a.label})]},a.value)})})}const wb=$t("StreamingUtils"),ute=async(e,t)=>{var m;const{url:n,method:r="POST",headers:i={},body:s,signal:o}=e,{onChunk:a,onProgress:c,onComplete:u,onError:h,onCanceled:p}=t;try{const g=await fetch(n,{method:r,headers:{"Content-Type":"application/json",...i},body:JSON.stringify(s),signal:o});if(!g.ok){if(g.status===401)throw new Error("Authentication required. Please run `rivet logout` and `rivet login` to re-authenticate.");if(g.status===429){const E=await g.json().catch(()=>({})),_=E.message||E.error||"";throw _.includes("SPEND_LIMIT_EXCEEDED:")?new Error(_):new Error(_||"Rate limit exceeded. Please try again shortly.")}throw new Error(`HTTP error! status: ${g.status}`)}const b=(m=g.body)==null?void 0:m.getReader(),x=new TextDecoder;if(!b)throw new Error("No response body reader available");let C="",w="";for(;;){const{done:E,value:_}=await b.read();if(E)break;C+=x.decode(_,{stream:!0});const T=C.split(`
|
|
71
71
|
`);C=T.pop()||"";for(const I of T)if(I.trim()!==""){if(I.startsWith("event: ")){w=I.slice(7).trim();continue}if(I.startsWith("data: "))try{const P=JSON.parse(I.slice(6));if(w==="progress")c("current",P.content||"");else if(P.content&&!P.done)a("current",P.content);else if(P.error){h("current",P.details||P.error);break}else if(P.done){u("current",P.usage,P);break}}catch(P){wb.warn("Failed to parse SSE data:",P)}}}}catch(g){if(g instanceof DOMException&&g.name==="AbortError"){wb.info("Streaming request aborted by user"),p==null||p("current");return}wb.warn("Streaming request failed:",g);const b=g instanceof Error?g.message:"An unexpected error occurred.";h("unknown",b)}},dte=e=>{const t=(h,p)=>{e(m=>m.map(g=>g.id===h?{...g,message:g.message+p}:g))},n=(h,p)=>{e(m=>m.map(g=>g.id===h?{...g,message:p}:g))},r=h=>{e(p=>p.map(m=>m.id===h?{...m,isLoading:!1}:m))},i=(h,p,m)=>{e(g=>g.map(b=>{if(b.id!==h)return b;const x=(m??b.message).trim(),C=x.length>0&&x!==p.trim();return{...b,message:p,summary:p,details:C?x:void 0,isDetailsAvailable:C,isLoading:!1}}))},s=(h,p)=>{e(m=>m.map(g=>g.id===h?{...g,message:`Error: ${p}`,isLoading:!1}:g))},o=(h,p,m="",g=!1,b)=>{const x={id:h,message:m,isUser:p,isLoading:!p,isProgress:g,images:b};e(C=>[...C,x])};return{updateStreamingMessage:t,replaceStreamingMessage:n,finalizeStreamingMessage:r,finalizeWithSummaryAndDetails:i,setErrorMessage:s,addStreamingMessage:o,addProgressMessage:(h,p="")=>{o(h,!1,p,!0)},updateOrAddProgressMessage:(h,p)=>{e(m=>{const g=m.filter(x=>!x.isProgress),b={id:h,message:p,isUser:!1,isLoading:!0,isProgress:!0};return[...g,b]})},removeProgressMessages:()=>{e(h=>h.filter(p=>!p.isProgress))}}},Nl=$t("useAgent"),fte=()=>{const[e,t]=f.useState(!1),[n,r]=f.useState(null),[i,s]=f.useState(""),o=Ce(Id),a=Ce(x$),c=f.useRef(null),u=f.useCallback(()=>{c.current&&(Nl.info("Cancelling agent modification"),c.current.abort(),c.current=null,t(!1))},[]);return{modifyWithAgent:f.useCallback(async(p,m)=>{var g;c.current&&c.current.abort(),c.current=new AbortController,t(!0),r(null),s("");try{const{instruction:b,elements:x,images:C,sessionId:w,traceId:E,posthogSessionId:_}=p;Nl.info("Starting agentic modification:",{instruction:b.slice(0,50),elementCount:x.length,hasSessionId:!!w});const T={url:"/api/code/modify-agentic",body:{instruction:b,elements:x,images:C,designTokens:o||void 0,sessionId:w,model:a,traceId:E,posthogSessionId:_},signal:(g=c.current)==null?void 0:g.signal};let I=null,P=null,M=!1;if(await ute(T,{onChunk:(S,R)=>{var $;s(L=>L+R),($=m==null?void 0:m.onChunk)==null||$.call(m,R)},onProgress:(S,R)=>{var $;Nl.debug("Agent progress:",R),($=m==null?void 0:m.onProgress)==null||$.call(m,R)},onComplete:(S,R,$)=>{var j,O,H;I=$||{changes:"Agentic modification completed",filesModified:[],totalElements:x.length},Nl.info("Agentic modification complete:",{filesModified:((j=I.filesModified)==null?void 0:j.length)||0,sessionId:I.sessionId}),(H=m==null?void 0:m.onComplete)==null||H.call(m,{usage:R,sessionId:I.sessionId,model:I.model,ttfmMs:I.ttfmMs,changes:I.changes,filesModified:((O=I.filesModified)==null?void 0:O.map(B=>B.filePath))??[]})},onError:(S,R)=>{var $;P=R,Nl.warn("Agentic modification error:",R),($=m==null?void 0:m.onError)==null||$.call(m,R)},onCanceled:()=>{var S;M=!0,Nl.info("Agentic modification canceled"),(S=m==null?void 0:m.onCanceled)==null||S.call(m)}}),M)return null;if(P)throw new Error(P);return I}catch(b){const x=b instanceof Error?b.message:"Agentic modification failed";return r(x),Nl.warn("Agentic modification error:",x),null}finally{t(!1)}},[o,a]),cancelModification:u,isModifying:e,error:n,streamingContent:i,clearError:()=>r(null),clearStreamingContent:()=>s("")}},o1=e=>e.includes("-")?e:e.replace(/([A-Z])/g,"-$1").toLowerCase(),Y8=e=>e.finalizedVariant?e.finalizedVariant:null,hte=e=>Object.entries(e).map(([t,n])=>`${o1(t)}: ${n}`).join("; "),rA=e=>{const t={};for(const n of e)t[o1(String(n.property))]=n.newValue;return hte(t)},X8=(e,t)=>{const n=Y8(e);if(!n||!n.changeSpec)return t.length===0?"":`
|
|
72
72
|
**Design-panel style edits to implement:** ${rA(t)}`;let r=`
|
|
73
73
|
**Selected design direction:** ${n.label}
|
|
@@ -503,7 +503,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
503
503
|
* See the LICENSE file in the root directory of this source tree.
|
|
504
504
|
*/const s1e=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],o1e=kt("x",s1e),a1e={"chevron-right":Fme,"chevron-down":Lme,pipette:Ige,x:o1e,copy:Ume,menu:pge,dot:Wme,monitor:yge,sun:e1e,moon:xge,"rectangle-horizontal":Lge,circle:Vme,"square-library":Yge,clock:Bme,star:Qge,settings:Uge,plus:Dge,"arrow-left":Eme,"arrow-right":_me,"arrow-up":Tme,search:Bge,loader:lge,users:i1e,lock:uge,mail:fge,bell:Ime,shield:Wge,palette:Ege,lightbulb:ige,rocket:Fge,heart:Yme,paintbrush:kge,brain:Rme,globe:qme,user:n1e,image:ege,link:oge,check:Dme,"rotate-ccw":Vge,play:Rge,pause:_ge,home:Qme,"message-circle":gge,inbox:nge,pencil:Tge,"skip-forward":qge},dT={lucide:a1e},qj=f.createContext(null);function E1(e){const t=f.useContext(qj);return t?dT[t.iconLibrary][e]:dT.lucide[e]}function l1e({children:e,defaultLibrary:t="lucide"}){const[n,r]=f.useState(t),i=f.useCallback(s=>{r(s)},[]);return y.jsx(qj.Provider,{value:{iconLibrary:n,setIconLibrary:i},children:e})}const Kj=f.createContext(null);function rk(){return f.useContext(Kj)}const Yj=f.createContext(null);function Xj(){const e=f.useContext(Yj);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within an AccordionItem");return e}const c1e=f.forwardRef((e,t)=>{const{children:n,type:r="single",className:i,...s}=e,o=f.useRef(null),a=f.useRef(new Map),[c,u]=f.useState(new Map),{activeIndex:h,setActiveIndex:p,itemRects:m,sessionRef:g,handlers:b,registerItem:x,measureItems:C}=U$(o),w=f.useCallback((G,X)=>{X?a.current.set(G,X):a.current.delete(G)},[]),E=f.useCallback(()=>{if(!o.current)return;const G=new Map;a.current.forEach((X,de)=>{G.set(de,{top:X.offsetTop,left:X.offsetLeft,width:X.offsetWidth,height:X.offsetHeight})}),u(G)},[]),[_,T]=f.useState(()=>r==="single"?e.defaultValue??"":""),[I,P]=f.useState(()=>r==="multiple"?e.defaultValue??[]:[]),M=e.onValueChange,S=e.onValueChange,R=e.value,$=new Set(r==="multiple"?e.value??I:(()=>{const G=e.value??_;return G?[G]:[]})()),L=f.useCallback(G=>{const X=e;X.onValueChange?X.onValueChange(G):T(G)},[M]),j=f.useCallback(G=>{const X=e;X.onValueChange?X.onValueChange(G):P(G)},[S]),O=f.useCallback(G=>{if(r==="multiple"){const X=e.value??I;j(X.filter(de=>de!==G))}else L("")},[r,L,j,I,R]);f.useEffect(()=>{C(),E()},[C,E,n]);const H=[...$].join(",");f.useEffect(()=>{C(),E()},[C,E,H]);const[B,Z]=f.useState(null),K=h!==null?m[h]:null,q=B!==null?m[B]:null,te=h!==null&&!c.has(h),F=Md(),{value:V,defaultValue:W,onValueChange:N,collapsible:z,type:Q,...J}=s,re=r==="multiple"?{type:"multiple",value:e.value??I,onValueChange:j}:{type:"single",collapsible:e.collapsible??!0,value:e.value??_,onValueChange:L};return y.jsx(Kj.Provider,{value:{registerItem:x,registerFullItem:w,activeIndex:h,grouped:!0,remeasure:()=>{C(),E()},openValues:$,openItemRects:c,toggleValue:O},children:y.jsx(Wj,{...re,asChild:!0,children:y.jsxs("div",{ref:G=>{o.current=G,typeof t=="function"?t(G):t&&(t.current=G)},onMouseEnter:b.onMouseEnter,onMouseMove:G=>{const X=o.current;if(X){const de=X.getBoundingClientRect(),ve=X.offsetHeight,we=de.height,je=ve>0?we/ve:1,Ae=(G.clientY-de.top)/je+X.scrollTop;for(const[Le,tt]of c){const vt=m[Le];if(!vt)continue;const Je=vt.top+vt.height,ye=tt.top+tt.height;if(Ae>=Je&&Ae<=ye){p(null);return}}}b.onMouseMove(G)},onMouseLeave:b.onMouseLeave,onFocus:G=>{var de;const X=(de=G.target.closest("[data-proximity-index]"))==null?void 0:de.getAttribute("data-proximity-index");if(X!=null){const ve=Number(X);p(ve),Z(G.target.matches(":focus-visible")?ve:null)}},onBlur:G=>{var X;(X=o.current)!=null&&X.contains(G.relatedTarget)||(Z(null),p(null))},className:zn("relative flex flex-col gap-0.5 w-72 max-w-full",i),...J,children:[y.jsx(ds,{children:[...c.entries()].map(([G,X])=>y.jsx(dn.div,{className:`absolute ${F.bg} bg-accent/20 dark:bg-accent/12 pointer-events-none`,initial:!1,animate:{top:X.top,left:X.left,width:X.width,height:X.height,opacity:te?.7:1},exit:{opacity:0,transition:{duration:.12}},transition:{top:{duration:0},left:{duration:0},width:{duration:0},height:{duration:0},opacity:{duration:.08}}},`expanded-${G}`))}),y.jsx(ds,{children:K&&y.jsx(dn.div,{className:`absolute ${F.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:K.top,left:K.left,width:K.width,height:K.height},animate:{opacity:1,top:K.top,left:K.left,width:K.width,height:K.height},exit:{opacity:0,transition:{duration:.06}},transition:{...Ka.fast,opacity:{duration:.08}}},g.current)}),y.jsx(ds,{children:q&&y.jsx(dn.div,{className:`absolute ${F.focusRing} pointer-events-none z-20 border border-[#6B97FF]`,initial:!1,animate:{left:q.left-2,top:q.top-2,width:q.width+4,height:q.height+4},exit:{opacity:0,transition:{duration:.06}},transition:{...Ka.fast,opacity:{duration:.08}}})}),n]})})})});c1e.displayName="AccordionGroup";const ik=f.forwardRef(({children:e,type:t="single",collapsible:n=!0,defaultValue:r,value:i,onValueChange:s,className:o,...a},c)=>{const[u,h]=f.useState(()=>t==="single"?r??"":""),[p,m]=f.useState(()=>t==="multiple"?r??[]:[]),g=new Set(t==="multiple"?i??p:(()=>{const E=i??u;return E?[E]:[]})()),b=f.useCallback(E=>{s?s(E):h(E)},[s]),x=f.useCallback(E=>{s?s(E):m(E)},[s]),C=f.useCallback(E=>{t==="multiple"?x((i??p).filter(T=>T!==E)):b("")},[t,i,p,b,x]),w=t==="multiple"?{type:"multiple",value:i??p,defaultValue:r,onValueChange:x}:{type:"single",collapsible:n,value:i??u,defaultValue:r,onValueChange:b};return y.jsx(Wj,{...w,asChild:!0,children:y.jsx("div",{ref:c,className:zn("w-72 max-w-full flex flex-col gap-0.5",o),...a,children:y.jsx(Qj.Provider,{value:g,children:y.jsx(Jj.Provider,{value:C,children:e})})})})});ik.displayName="Accordion";const Qj=f.createContext(new Set),Jj=f.createContext(()=>{}),sk=f.forwardRef(({value:e,index:t,disabled:n,children:r,className:i,...s},o)=>{const a=f.useRef(null),c=rk(),u=f.useContext(Qj),h=f.useContext(Jj),p=Md(),m=c!=null&&c.grouped?c.openValues.has(e):u.has(e),g=f.useRef(null),b=f.useCallback(()=>{c!=null&&c.grouped?c.toggleValue(e):h(e)},[c,h,e]);return f.useEffect(()=>{if(c!=null&&c.grouped&&t!==void 0)return c.registerItem(t,g.current),()=>c.registerItem(t,null)},[t,c]),f.useEffect(()=>{if(c!=null&&c.grouped&&t!==void 0)return m?c.registerFullItem(t,a.current):c.registerFullItem(t,null),()=>c.registerFullItem(t,null)},[t,c,m]),y.jsx(Yj.Provider,{value:{index:t,value:e,isOpen:m,onToggle:b,triggerRef:g},children:y.jsxs(hme,{ref:x=>{a.current=x,typeof o=="function"?o(x):o&&(o.current=x)},value:e,disabled:n,"data-proximity-index":t,className:zn(!(c!=null&&c.grouped)&&"relative",i),...s,children:[!(c!=null&&c.grouped)&&y.jsx(ds,{children:m&&y.jsx(dn.div,{className:`absolute inset-0 ${p.bg} bg-accent/20 dark:bg-accent/12 pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.06}},transition:{duration:.08}})}),r]})})});sk.displayName="AccordionItem";const ok=f.forwardRef(({children:e,className:t,...n},r)=>{const i=E1("chevron-right"),s=rk(),{index:o,isOpen:a,triggerRef:c}=Xj(),u=Md(),[h,p]=f.useState(!1),m=s!=null&&s.grouped?s.activeIndex===o:h,g=y.jsx(pme,{asChild:!0,children:y.jsx("div",{children:y.jsxs(mme,{ref:r,className:zn(`relative z-10 flex items-center gap-2.5 ${u.item} px-3 py-2 w-full cursor-pointer outline-none select-none`,!(s!=null&&s.grouped)&&"focus-visible:ring-1 focus-visible:ring-[#6B97FF] focus-visible:ring-offset-0",t),...n,children:[y.jsxs("span",{className:"inline-grid text-[13px] flex-1 text-left",children:[y.jsx("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:Ih.semibold},"aria-hidden":"true",children:e}),y.jsx("span",{className:zn("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80",a||m?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:a?Ih.semibold:Ih.normal},children:e})]}),y.jsx(dn.span,{className:"shrink-0 inline-flex items-center justify-center",animate:{rotate:a?90:0},transition:Ka.fast,children:y.jsx(i,{size:16,strokeWidth:a||m?2:1.5,className:zn("transition-[color,stroke-width] duration-80",a||m?"text-foreground":"text-muted-foreground")})})]})})});return s!=null&&s.grouped?y.jsx("div",{ref:c,children:g}):y.jsxs("div",{className:"relative",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[y.jsx(ds,{children:h&&y.jsx(dn.div,{className:`absolute inset-0 ${u.bg} bg-hover pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.06}},transition:{duration:.08}})}),g]})});ok.displayName="AccordionTrigger";const ak=f.forwardRef(({children:e,className:t,...n},r)=>{const i=rk(),{isOpen:s}=Xj();return y.jsx(ds,{initial:!1,children:s&&y.jsx(gme,{forceMount:!0,asChild:!0,...n,children:y.jsx(dn.div,{ref:r,className:zn("overflow-hidden",t),initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{...Ka.moderate,bounce:0},onUpdate:()=>{i==null||i.remeasure()},onAnimationComplete:()=>{i==null||i.remeasure()},children:y.jsx("div",{className:"px-3 pb-3 pt-1 text-[13px] text-muted-foreground",children:e})})})})});ak.displayName="AccordionContent";const Uu=({children:e,defaultValue:t=[],className:n=""})=>y.jsx(ik,{type:"multiple",defaultValue:t,className:zn("w-full",n),children:e}),u1e=({value:e,title:t,description:n,dataCy:r,icon:i,children:s,className:o=""})=>{const a=o.includes("first-item");return y.jsxs(sk,{value:e,className:zn("w-full",!a&&"border-t border-main-border"),children:[y.jsxs(ok,{"data-cy":r,children:[i?y.jsx("span",{className:"mr-1 inline-flex items-center",children:i}):null,t]}),y.jsxs(ak,{children:[n?y.jsx("p",{className:"pb-2 text-sm text-content-subtle",children:n}):null,s]})]})};Uu.Item=u1e;const d1e=$t("usePropertyTransaction"),f1e=({value:e,onApply:t,onPreview:n,onChange:r})=>{const[i,s]=f.useState(null),[o,a]=f.useState(null);f.useEffect(()=>{i!==null&&o!==null&&String(e)===o&&(d1e.debug(`Detected Undo/Revert for value: ${e}`),s(null),a(null))},[e]);const c=p=>{o===null&&a(String(e)),s(p),n&&n(p)},u=p=>{const m=p??i??String(e);o!==null&&m!==o&&t&&t(m,o),s(null),a(null)},h=()=>{o!==null&&(n&&n(o),r&&r(o)),s(null),a(null)};return{displayValue:i??String(e),isDirty:i!==null&&i!==o,stage:c,commit:u,rollback:h}};function sp(e){if(h1e())e.focus({preventScroll:!0});else{let t=p1e(e);e.focus(),m1e(t)}}let Lm=null;function h1e(){if(Lm==null){Lm=!1;try{document.createElement("div").focus({get preventScroll(){return Lm=!0,!0}})}catch{}}return Lm}function p1e(e){let t=e.parentNode,n=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function m1e(e){for(let{element:t,scrollTop:n,scrollLeft:r}of e)t.scrollTop=n,t.scrollLeft=r}var eF={};eF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"أداة انتقاء اللون",colorSwatch:"تغيير الألوان",transparent:"شفاف",twoDimensionalSlider:"مُنزلق 2D"};var tF={};tF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Средство за избиране на цвят",colorSwatch:"цветна мостра",transparent:"прозрачен",twoDimensionalSlider:"2D плъзгач"};var nF={};nF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Výběr barvy",colorSwatch:"barevný vzorek",transparent:"průhledný",twoDimensionalSlider:"2D posuvník"};var rF={};rF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Farvevælger",colorSwatch:"farveprøve",transparent:"gennemsigtig",twoDimensionalSlider:"2D-skyder"};var iF={};iF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Farbwähler",colorSwatch:"Farbfeld",transparent:"transparent",twoDimensionalSlider:"2D-Schieberegler"};var sF={};sF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Επιλογέας χρωμάτων",colorSwatch:"χρωματικό δείγμα",transparent:"διαφανές",twoDimensionalSlider:"Ρυθμιστικό 2D"};var oF={};oF={colorPicker:"Color picker",twoDimensionalSlider:"2D slider",colorNameAndValue:e=>`${e.name}: ${e.value}`,colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorSwatch:"color swatch",transparent:"transparent"};var aF={};aF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Selector de color",colorSwatch:"muestra de color",transparent:"transparente",twoDimensionalSlider:"Regulador 2D"};var lF={};lF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Värvivalija",colorSwatch:"värvinäidis",transparent:"läbipaistev",twoDimensionalSlider:"2D-liugur"};var cF={};cF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Värimuokkain",colorSwatch:"värimalli",transparent:"läpinäkyvä",twoDimensionalSlider:"2D-liukusäädin"};var uF={};uF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name} : ${e.value}`,colorPicker:"Sélecteur de couleurs",colorSwatch:"Échantillon de couleurs",transparent:"Transparent",twoDimensionalSlider:"Curseur 2D"};var dF={};dF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"בוחר הצבעים",colorSwatch:"דוגמית צבע",transparent:"שקוף",twoDimensionalSlider:"מחוון דו מימדי"};var fF={};fF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Odabir boje",colorSwatch:"uzorak boje",transparent:"transparentno",twoDimensionalSlider:"2D klizač"};var hF={};hF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Színválasztó",colorSwatch:"színtár",transparent:"átlátszó",twoDimensionalSlider:"2D-csúszka"};var pF={};pF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Selettore colore",colorSwatch:"campione di colore",transparent:"trasparente",twoDimensionalSlider:"Cursore 2D"};var mF={};mF={colorInputLabel:e=>`${e.label}、${e.channelLabel}`,colorNameAndValue:e=>`${e.name} : ${e.value}`,colorPicker:"カラーピッカー",colorSwatch:"カラースウォッチ",transparent:"透明",twoDimensionalSlider:"2D スライダー"};var gF={};gF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"색상 피커",colorSwatch:"색상 견본",transparent:"투명도",twoDimensionalSlider:"2D 슬라이더"};var vF={};vF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Spalvų parinkiklis",colorSwatch:"spalvų pavyzdys",transparent:"skaidrus",twoDimensionalSlider:"2D slankiklis"};var yF={};yF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Krāsu atlasītājs",colorSwatch:"krāsu paraugs",transparent:"caurspīdīgs",twoDimensionalSlider:"2D slīdnis"};var bF={};bF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Fargevelger",colorSwatch:"fargekart",transparent:"gjennomsiktig",twoDimensionalSlider:"2D-glidebryter"};var xF={};xF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Kleurkiezer",colorSwatch:"kleurstaal",transparent:"transparant",twoDimensionalSlider:"2D-schuifregelaar"};var wF={};wF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Próbnik kolorów",colorSwatch:"próbka koloru",transparent:"przezroczysty",twoDimensionalSlider:"Suwak 2D"};var kF={};kF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Seletor de cores",colorSwatch:"amostra de cores",transparent:"transparente",twoDimensionalSlider:"Controle deslizante 2D"};var CF={};CF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Seletor de cores",colorSwatch:"amostra de cor",transparent:"transparente",twoDimensionalSlider:"Controle deslizante 2D"};var EF={};EF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Selector de culori",colorSwatch:"specimen de culoare",transparent:"transparent",twoDimensionalSlider:"Glisor 2D"};var SF={};SF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Палитра цветов",colorSwatch:"цветовой образец",transparent:"прозрачный",twoDimensionalSlider:"Ползунок 2D"};var _F={};_F={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Výber farieb",colorSwatch:"vzorkovník farieb",transparent:"transparentný",twoDimensionalSlider:"2D jazdec"};var AF={};AF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Izbirnik barv",colorSwatch:"barvna paleta",transparent:"prozorno",twoDimensionalSlider:"2D drsnik"};var TF={};TF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Birač boja",colorSwatch:"Uzorak boje",transparent:"providno",twoDimensionalSlider:"2D klizač"};var PF={};PF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Färgväljaren",colorSwatch:"färgruta",transparent:"genomskinlig",twoDimensionalSlider:"2D-reglage"};var IF={};IF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Renk Seçici",colorSwatch:"renk örneği",transparent:"saydam",twoDimensionalSlider:"2D sürgü"};var MF={};MF={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Палітра кольорів",colorSwatch:"зразок кольору",transparent:"прозорий",twoDimensionalSlider:"Повзунок 2D"};var RF={};RF={colorInputLabel:e=>`${e.label}、${e.channelLabel}`,colorNameAndValue:e=>`${e.name}:${e.value}`,colorPicker:"拾色器",colorSwatch:"颜色色板",transparent:"透明",twoDimensionalSlider:"2D 滑块"};var $F={};$F={colorInputLabel:e=>`${e.label},${e.channelLabel}`,colorNameAndValue:e=>`${e.name}:${e.value}`,colorPicker:"檢色器",colorSwatch:"色票",transparent:"透明",twoDimensionalSlider:"2D 滑桿"};var DF={};DF={"ar-AE":eF,"bg-BG":tF,"cs-CZ":nF,"da-DK":rF,"de-DE":iF,"el-GR":sF,"en-US":oF,"es-ES":aF,"et-EE":lF,"fi-FI":cF,"fr-FR":uF,"he-IL":dF,"hr-HR":fF,"hu-HU":hF,"it-IT":pF,"ja-JP":mF,"ko-KR":gF,"lt-LT":vF,"lv-LV":yF,"nb-NO":bF,"nl-NL":xF,"pl-PL":wF,"pt-BR":kF,"pt-PT":CF,"ro-RO":EF,"ru-RU":SF,"sk-SK":_F,"sl-SI":AF,"sr-SP":TF,"sv-SE":PF,"tr-TR":IF,"uk-UA":MF,"zh-CN":RF,"zh-TW":$F};function Iv(e){var n;if(typeof window>"u"||window.navigator==null)return!1;let t=(n=window.navigator.userAgentData)==null?void 0:n.brands;return Array.isArray(t)&&t.some(r=>e.test(r.brand))||e.test(window.navigator.userAgent)}function lk(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function hl(e){let t=null;return()=>(t==null&&(t=e()),t)}const S1=hl(function(){return lk(/^Mac/i)}),g1e=hl(function(){return lk(/^iPhone/i)}),NF=hl(function(){return lk(/^iPad/i)||S1()&&navigator.maxTouchPoints>1}),ck=hl(function(){return g1e()||NF()}),v1e=hl(function(){return Iv(/AppleWebKit/i)&&!y1e()}),y1e=hl(function(){return Iv(/Chrome/i)}),LF=hl(function(){return Iv(/Android/i)}),b1e=hl(function(){return Iv(/Firefox/i)});function x1e(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const Mv=typeof document<"u"?xe.useLayoutEffect:()=>{},jF={prefix:String(Math.round(Math.random()*1e10)),current:0},FF=xe.createContext(jF),w1e=xe.createContext(!1);let dx=new WeakMap;function k1e(e=!1){var r,i;let t=f.useContext(FF),n=f.useRef(null);if(n.current===null&&!e){let s=(i=(r=xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)==null?void 0:r.ReactCurrentOwner)==null?void 0:i.current;if(s){let o=dx.get(s);o==null?dx.set(s,{id:t.current,state:s.memoizedState}):s.memoizedState!==o.state&&(t.current=o.id,dx.delete(s))}n.current=++t.current}return n.current}function C1e(e){let t=f.useContext(FF),n=k1e(!!e),r=`react-aria${t.prefix}`;return e||`${r}-${n}`}function E1e(e){let t=xe.useId(),[n]=f.useState(OF()),r=n?"react-aria":`react-aria${jF.prefix}`;return e||`${r}-${t}`}const S1e=typeof xe.useId=="function"?E1e:C1e;function _1e(){return!1}function A1e(){return!0}function T1e(e){return()=>{}}function OF(){return typeof xe.useSyncExternalStore=="function"?xe.useSyncExternalStore(T1e,_1e,A1e):f.useContext(w1e)}let P1e=!!(typeof window<"u"&&window.document&&window.document.createElement),Zu=new Map,hh;typeof FinalizationRegistry<"u"&&(hh=new FinalizationRegistry(e=>{Zu.delete(e)}));function l6(e){let[t,n]=f.useState(e),r=f.useRef(null),i=S1e(t),s=f.useRef(null);if(hh&&hh.register(s,i),P1e){const o=Zu.get(i);o&&!o.includes(r)?o.push(r):Zu.set(i,[r])}return Mv(()=>{let o=i;return()=>{hh&&hh.unregister(s),Zu.delete(o)}},[i]),f.useEffect(()=>{let o=r.current;return o&&n(o),()=>{o&&(r.current=null)}}),i}function I1e(e,t){if(e===t)return e;let n=Zu.get(e);if(n)return n.forEach(i=>i.current=t),t;let r=Zu.get(t);return r?(r.forEach(i=>i.current=e),e):t}function M1e(...e){return e.length===1&&e[0]?e[0]:t=>{let n=!1;const r=e.map(i=>{const s=fT(i,t);return n||(n=typeof s=="function"),s});if(n)return()=>{r.forEach((i,s)=>{typeof i=="function"?i():fT(e[s],null)})}}}function fT(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function $o(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];for(let i in r){let s=t[i],o=r[i];typeof s=="function"&&typeof o=="function"&&i[0]==="o"&&i[1]==="n"&&i.charCodeAt(2)>=65&&i.charCodeAt(2)<=90?t[i]=x1e(s,o):(i==="className"||i==="UNSAFE_className")&&typeof s=="string"&&typeof o=="string"?t[i]=W8(s,o):i==="id"&&s&&o?t.id=I1e(s,o):i==="ref"&&s&&o?t.ref=M1e(s,o):t[i]=o!==void 0?o:s}}return t}function Wi(e,t=-1/0,n=1/0){return Math.min(Math.max(e,t),n)}function jm(e,t){let n=e,r=0,i=t.toString(),s=i.toLowerCase().indexOf("e-");if(s>0)r=Math.abs(Math.floor(Math.log10(Math.abs(t))))+s;else{let o=i.indexOf(".");o>=0&&(r=i.length-o)}if(r>0){let o=Math.pow(10,r);n=Math.round(n*o)/o}return n}function cs(e,t,n,r){t=Number(t),n=Number(n);let i=(e-(isNaN(t)?0:t))%r,s=jm(Math.abs(i)*2>=r?e+Math.sign(i)*(r-Math.abs(i)):e-i,r);return isNaN(t)?!isNaN(n)&&s>n&&(s=Math.floor(jm(n/r,r))*r):s<t?s=t:!isNaN(n)&&s>n&&(s=t+Math.floor(jm((n-t)/r,r))*r),s=jm(s,r),s}function Xn(e,t,n=10){const r=Math.pow(n,t);return Math.round(e*r)/r}var VF={};VF={alpha:"ألفا",black:"أسود",blue:"أزرق","blue purple":"أرجواني مزرق",brightness:"السطوع",brown:"بني","brown yellow":"أصفر بني",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"سماوي","cyan blue":"أزرق سماوي",dark:"داكن",gray:"رمادي",grayish:"مائل للرمادي",green:"أخضر","green cyan":"سماوي مخضر",hue:"درجة اللون",light:"فاتح",lightness:"الإضاءة",magenta:"أرجواني","magenta pink":"أرجواني وردي",orange:"برتقالي","orange yellow":"أصفر برتقالي",pale:"باهت",pink:"وردي","pink red":"أحمر وردي",purple:"أرجواني","purple magenta":"بنفسجي",red:"أحمر","red orange":"برتقالي محمر",saturation:"التشبع",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} شفاف`,"very dark":"داكن جدًا","very light":"فاتح جدًا",vibrant:"ساطع",white:"أبيض",yellow:"أصفر","yellow green":"أخضر مصفر"};var HF={};HF={alpha:"Алфа",black:"черно",blue:"Синьо","blue purple":"синьо лилаво",brightness:"Яркост",brown:"кафяво","brown yellow":"кафяво жълто",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"циан","cyan blue":"циан синьо",dark:"тъмно",gray:"сиво",grayish:"сивкав",green:"Зелено","green cyan":"зелен циан",hue:"Оттенък",light:"светло",lightness:"Лекота",magenta:"магента","magenta pink":"магента розово",orange:"оранжево","orange yellow":"оранжево жълто",pale:"бледо",pink:"розово","pink red":"розово червено",purple:"лилаво","purple magenta":"лилаво магента",red:"Червено","red orange":"червен портокал",saturation:"Наситеност",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} прозрачен`,"very dark":"много тъмно","very light":"много светло",vibrant:" ярко",white:"бяло",yellow:"жълто","yellow green":"жълто зелен"};var BF={};BF={alpha:"Alfa",black:"černá",blue:"Modrá","blue purple":"modrofialová",brightness:"Jas",brown:"hnědá","brown yellow":"hnědožlutá",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"tyrkysová","cyan blue":"tyrkysovomodrá",dark:"tmavá",gray:"šedá",grayish:"našedlá",green:"Zelená","green cyan":"zelenotyrkysová",hue:"Odstín",light:"světlá",lightness:"Světlost",magenta:"purpurová","magenta pink":"purpurově růžová",orange:"oranžová","orange yellow":"oranžovožlutá",pale:"bledá",pink:"růžová","pink red":"růžovočervená",purple:"fialová","purple magenta":"fialově purpurová",red:"Červená","red orange":"červenooranžová",saturation:"Sytost",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} průhledné`,"very dark":"velmi tmavá","very light":"velmi světlá",vibrant:"zářivá",white:"bílá",yellow:"žlutá","yellow green":"žlutozelená"};var zF={};zF={alpha:"Alfa",black:"sort",blue:"Blå","blue purple":"blålilla",brightness:"Lysstyrke",brown:"brun","brown yellow":"brungul",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyan","cyan blue":"cyan blå",dark:"mørk",gray:"grå",grayish:"grålig",green:"Grøn","green cyan":"grøn cyan",hue:"Tone",light:"lys",lightness:"Lyshed",magenta:"magenta","magenta pink":"magenta pink",orange:"orange","orange yellow":"orangegul",pale:"bleg",pink:"lyserød","pink red":"lyserødlig rød",purple:"lilla","purple magenta":"lilla magenta",red:"Rød","red orange":"rødorange",saturation:"Farvemætning",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} gennemsigtig`,"very dark":"meget mørk","very light":"meget lys",vibrant:"klar",white:"hvid",yellow:"gul","yellow green":"gulgrøn"};var UF={};UF={alpha:"Alpha",black:"Schwarz",blue:"Blau","blue purple":"Blaulila",brightness:"Helligkeit",brown:"Braun","brown yellow":"Braungelb",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"Cyan","cyan blue":"Cyanblau",dark:"dunkles",gray:"Grau",grayish:"gräuliches",green:"Grün","green cyan":"Grüncyan",hue:"Farbton",light:"helles",lightness:"Leuchtkraft",magenta:"Magenta","magenta pink":"Magentarosa",orange:"Orange","orange yellow":"Orangegelb",pale:"blasses",pink:"Rosa","pink red":"Rosarot",purple:"Lila","purple magenta":"Lilamagenta",red:"Rot","red orange":"Rotorange",saturation:"Sättigung",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, zu ${e.percentTransparent} transparent`,"very dark":"sehr dunkles","very light":"sehr helles",vibrant:"lebhaftes",white:"Weiß",yellow:"Gelb","yellow green":"Gelbgrün"};var ZF={};ZF={alpha:"Άλφα",black:"μαύρο",blue:"Μπλε","blue purple":"μπλε μωβ",brightness:"Φωτεινότητα",brown:"καφέ","brown yellow":"καφέ κίτρινο",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"κυανό","cyan blue":"κυανό μπλε",dark:"σκούρο",gray:"γκρι",grayish:"γκριζωπό",green:"Πράσινο","green cyan":"πράσινο κυανό",hue:"Τόνος",light:"ανοιχτό",lightness:"Φωτεινότητα",magenta:"ματζέντα","magenta pink":"ματζέντα ροζ",orange:"πορτοκαλί","orange yellow":"πορτοκαλί κίτρινο",pale:"ανοιχτό",pink:"ροζ","pink red":"ροζ κόκκινο",purple:"μωβ","purple magenta":"μωβ ματζέντα",red:"Κόκκινο","red orange":"κόκκινο πορτοκαλί",saturation:"Κορεσμός",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} διαφανές`,"very dark":"πολύ σκούρο","very light":"πολύ ανοιχτό",vibrant:"έντονο",white:"λευκό",yellow:"κίτρινο","yellow green":"κίτρινο πράσινο"};var WF={};WF={hue:"Hue",saturation:"Saturation",lightness:"Lightness",brightness:"Brightness",red:"Red",green:"Green",blue:"Blue",alpha:"Alpha",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparent`,"very dark":"very dark",dark:"dark",light:"light","very light":"very light",pale:"pale",grayish:"grayish",vibrant:"vibrant",black:"black",white:"white",gray:"gray",pink:"pink","pink red":"pink red","red orange":"red orange",brown:"brown",orange:"orange","orange yellow":"orange yellow","brown yellow":"brown yellow",yellow:"yellow","yellow green":"yellow green","green cyan":"green cyan",cyan:"cyan","cyan blue":"cyan blue","blue purple":"blue purple",purple:"purple","purple magenta":"purple magenta",magenta:"magenta","magenta pink":"magenta pink"};var GF={};GF={alpha:"Alpha",black:"negro",blue:"Azul","blue purple":"púrpura azulado",brightness:"Brillo",brown:"marrón","brown yellow":"amarillo amarronado",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cian","cyan blue":"azul cian",dark:"oscuro",gray:"gris",grayish:"grisáceo",green:"Verde","green cyan":"cian verdoso",hue:"Tono",light:"claro",lightness:"Luminosidad",magenta:"magenta","magenta pink":"rosa magenta",orange:"naranja","orange yellow":"amarillo anaranjado",pale:"pálido",pink:"rosa","pink red":"rojo rosado",purple:"morado","purple magenta":"magenta violáceo",red:"Rojo","red orange":"naranja rojizo",saturation:"Saturación",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparente`,"very dark":"muy oscuro","very light":"muy claro",vibrant:"intenso",white:"blanco",yellow:"amarillo","yellow green":"verde amarillento"};var qF={};qF={alpha:"Alfa",black:"must",blue:"Sinine","blue purple":"sinakaslilla",brightness:"Heledus",brown:"pruun","brown yellow":"pruunikaskollane",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"tsüaan","cyan blue":"tsüaansinine",dark:"tume",gray:"hall",grayish:"hallikas",green:"Roheline","green cyan":"tsüaanroheline",hue:"Värv",light:"valgus",lightness:"Valgus",magenta:"magentapunane","magenta pink":"magentaroosa",orange:"oranž","orange yellow":"oranžikaskollane",pale:"kahvatu",pink:"roosa","pink red":"vaarikapunane",purple:"lilla","purple magenta":"purpurne magenta",red:"Punane","red orange":"punakasoranž",saturation:"Küllastus",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} läbipaistev`,"very dark":"väga tume","very light":"väga hele",vibrant:"ere",white:"valge",yellow:"kollane","yellow green":"kollakasroheline"};var KF={};KF={alpha:"Alpha",black:"musta",blue:"Sininen","blue purple":"sinivioletti",brightness:"Kirkkaus",brown:"ruskea","brown yellow":"ruskeankeltainen",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"syaani","cyan blue":"syaaninsininen",dark:"tumma",gray:"harmaa",grayish:"harmahtava",green:"Vihreä","green cyan":"vihreänsyaani",hue:"Sävy",light:"vaalea",lightness:"Valomäärä",magenta:"magenta","magenta pink":"magentapinkki",orange:"oranssi","orange yellow":"oranssinkeltainen",pale:"vaalea",pink:"pinkki","pink red":"vaaleanpunainen",purple:"violetti","purple magenta":"violettimagenta",red:"Punainen","red orange":"punaoranssi",saturation:"Värikylläisyys",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} läpinäkyvä`,"very dark":"hyvin tumma","very light":"erittäin vaalea",vibrant:"eloisa",white:"valkea",yellow:"keltainen","yellow green":"keltavihreä"};var YF={};YF={alpha:"Alpha",black:"Noir",blue:"Bleu","blue purple":"Violet bleu",brightness:"Luminosité",brown:"Brun","brown yellow":"Jaune brun",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"Cyan","cyan blue":"Bleu cyan",dark:"Sombre",gray:"Gris",grayish:"Grisâtre",green:"Vert","green cyan":"Cyan vert",hue:"Teinte",light:"Clair",lightness:"Luminosité",magenta:"Magenta","magenta pink":"Rose magenta",orange:"Orange","orange yellow":"Jaune orangé",pale:"Pâle",pink:"Rose","pink red":"Rouge rosé",purple:"Violet","purple magenta":"Magenta violet",red:"Rouge","red orange":"Orange rouge",saturation:"Saturation",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparent`,"very dark":"Très sombre","very light":"Très clair",vibrant:"Vif",white:"Blanc",yellow:"Jaune","yellow green":"Vert jaune"};var XF={};XF={alpha:"אלפא",black:"שחור",blue:"כחול","blue purple":"כחול סגול",brightness:"בהירות",brown:"חום","brown yellow":"חום צהוב",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"טורקיז","cyan blue":"כחול ציאן",dark:"כהה",gray:"אפור",grayish:"אפרפר",green:"ירוק","green cyan":"ציאן ירוק",hue:"גוון",light:"אור",lightness:"כמות אור",magenta:"מג'נטה","magenta pink":"ורוד מג'נטה",orange:"כתום","orange yellow":"כתום צהוב",pale:"חיוור",pink:"ורוד","pink red":"ורוד אדום",purple:"סגול","purple magenta":"מג'נטה סגול",red:"אדום","red orange":"כתום אדום",saturation:"רוויה",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} שקוף`,"very dark":"כהה מאוד","very light":"בהיר מאוד",vibrant:"תוסס",white:"לבן",yellow:"צהוב","yellow green":"צהוב ירוק"};var QF={};QF={alpha:"Alfa",black:"crno",blue:"Plava","blue purple":"plavo ljubičasta",brightness:"Svjetlina",brown:"smeđa","brown yellow":"smeđe žuta",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cijan","cyan blue":"cijan plava",dark:"tamno",gray:"siva",grayish:"sivkasto",green:"Zelena","green cyan":"zelena cijan",hue:"Nijansa",light:"svjetlo",lightness:"Osvijetljenost",magenta:"magenta","magenta pink":"magentno ružičasta",orange:"narančasta","orange yellow":"narančasto žuta",pale:"blijeda",pink:"ružičasta","pink red":"ružičasto crvena",purple:"ljubičasta","purple magenta":"ljubičasta magenta",red:"Crvena","red orange":"crveno narančasta",saturation:"Zasićenost",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} prozirnosti`,"very dark":"jako tamna","very light":"vrlo svijetlo",vibrant:"vibrantna",white:"bijela",yellow:"žuto","yellow green":"žuto zelena"};var JF={};JF={alpha:"Alfa",black:"fekete",blue:"Kék","blue purple":"kék lila",brightness:"Fényesség",brown:"barna","brown yellow":"barna sárga",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"ciánkék","cyan blue":"ciánkék",dark:"sötét",gray:"szürke",grayish:"szürkés",green:"Zöld","green cyan":"zöld ciánkék",hue:"Színárnyalat",light:"világos",lightness:"Világosság",magenta:"bíbor","magenta pink":"bíbor rózsaszín",orange:"narancs","orange yellow":"narancssárga",pale:"halvány",pink:"rózsaszín","pink red":"rózsaszín piros",purple:"lila","purple magenta":"lila bíbor",red:"Piros","red orange":"piros narancs",saturation:"Telítettség",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} átlátszó`,"very dark":"nagyon sötét","very light":"nagyon világos",vibrant:"élénk",white:"fehér",yellow:"sárga","yellow green":"sárga zöld"};var eO={};eO={alpha:"Alfa",black:"nero",blue:"Blu","blue purple":"blu viola",brightness:"Luminosità",brown:"marrone","brown yellow":"giallo bruno",colorName:e=>`${e.hue} ${e.chroma} ${e.lightness}`,cyan:"ciano","cyan blue":"blu ciano",dark:"scuro",gray:"grigio",grayish:"grigiastro",green:"Verde","green cyan":"verde ciano",hue:"Tonalità",light:"chiaro",lightness:"Luminosità",magenta:"magenta","magenta pink":"rosa magenta",orange:"arancio","orange yellow":"giallo arancio",pale:"tenue",pink:"rosa","pink red":"rosa rosso",purple:"viola","purple magenta":"viola magenta",red:"Rosso","red orange":"rosso arancio",saturation:"Saturazione",transparentColorName:e=>`${e.hue} ${e.chroma} ${e.lightness}, trasparenza ${e.percentTransparent}`,"very dark":"molto scuro","very light":"molto chiaro",vibrant:"vivace",white:"bianco",yellow:"giallo","yellow green":"giallo verde"};var tO={};tO={alpha:"アルファ",black:"ブラック",blue:"青","blue purple":"ブルーパープル",brightness:"明るさ",brown:"ブラウン","brown yellow":"ブラウンイエロー",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"シアン","cyan blue":"シアンブルー",dark:"ダーク",gray:"グレー",grayish:"グレイッシュ",green:"緑","green cyan":"グリーンシアン",hue:"色相",light:"ライト",lightness:"明度",magenta:"マゼンタ","magenta pink":"マゼンタピンク",orange:"オレンジ","orange yellow":"オレンジイエロー",pale:"ペール",pink:"ピンク","pink red":"ピンクレッド",purple:"パープル","purple magenta":"パープルマゼンタ",red:"赤","red orange":"レッドオレンジ",saturation:"彩度",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} 透明`,"very dark":"最も暗い","very light":"ベリーライト",vibrant:"鮮やか",white:"ホワイト",yellow:"イエロー","yellow green":"イエローグリーン"};var nO={};nO={alpha:"알파",black:"검은색",blue:"파랑","blue purple":"청자색",brightness:"명도",brown:"갈색","brown yellow":"황갈색",colorName:e=>`${e.lightness}, ${e.chroma}, ${e.hue}`,cyan:"청록색","cyan blue":"청록색",dark:"다크",gray:"회색",grayish:"회갈색",green:"초록","green cyan":"청록색",hue:"색조",light:"라이트",lightness:"밝기",magenta:"자홍색","magenta pink":"마젠타 핑크",orange:"주황색","orange yellow":"불그스름한 노랑",pale:"흙색",pink:"분홍색","pink red":"핑크 레드",purple:"자주색","purple magenta":"보라빛 자홍색",red:"빨강","red orange":"붉은 주황색",saturation:"채도",transparentColorName:e=>`${e.lightness}, ${e.chroma}, ${e.hue}, ${e.percentTransparent} 투명도`,"very dark":"매우 어두운","very light":"매우 연함",vibrant:"강렬한",white:"흰색",yellow:"노란색","yellow green":"연두색"};var rO={};rO={alpha:"Alfa",black:"juoda",blue:"Mėlyna","blue purple":"melsvai violetinė",brightness:"Ryškumas",brown:"ruda","brown yellow":"rusvai geltona",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"žalsvai mėlyna","cyan blue":"žalsvai mėlyna",dark:"tamsi",gray:"pilka",grayish:"pilkšva",green:"Žalia","green cyan":"žalsvai mėlyna",hue:"Atspalvis",light:"šviesi",lightness:"Šviesumas",magenta:"rausvai raudona","magenta pink":"purpurinė",orange:"oranžinė","orange yellow":"oranžinio atspalvio geltona",pale:"blyški",pink:"rožinė","pink red":"rožinė raudona",purple:"violetinė","purple magenta":"purpurinė rausvai raudona",red:"Raudona","red orange":"rausvai oranžinė",saturation:"Įsotinimas",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} skaidri`,"very dark":"labai tamsi","very light":"labai šviesi",vibrant:"ryški",white:"balta",yellow:"geltona","yellow green":"gelsvai žalia"};var iO={};iO={alpha:"Alfa",black:"melns",blue:"Zila","blue purple":"zili violets",brightness:"Spilgtums",brown:"brūns","brown yellow":"brūni dzeltens",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"ciāns","cyan blue":"ciāna zils",dark:"tumšs",gray:"pelēks",grayish:"pelēcīgs",green:"Zaļa","green cyan":"zaļš ciāns",hue:"Nokrāsa",light:"gaišs",lightness:"Gaišums",magenta:"fuksiju","magenta pink":"fuksiju rozā",orange:"oranžs","orange yellow":"oranži dzeltens",pale:"bāls",pink:"rozā","pink red":"rozīgi sarkans",purple:"violets","purple magenta":"violets fuksiju",red:"Sarkana","red orange":"sarkanīgi oranžs",saturation:"Piesātinājums",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} caurspīdīgs`,"very dark":"ļoti tumšs","very light":"ļoti gaišs",vibrant:"košs",white:"balts",yellow:"dzeltens","yellow green":"dzelteni zaļš"};var sO={};sO={alpha:"Alfa",black:"svart",blue:"Blå","blue purple":"blålilla",brightness:"Lysstyrke",brown:"brun","brown yellow":"brungul",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyan","cyan blue":"cyanblå",dark:"mørk",gray:"grå",grayish:"gråaktig",green:"Grønn","green cyan":"grønncyan",hue:"Fargetone",light:"lys",lightness:"Lyshet",magenta:"magenta","magenta pink":"magentarosa",orange:"oransje","orange yellow":"oransjegul",pale:"blek",pink:"rosa","pink red":"rosarød",purple:"lilla","purple magenta":"lillamagenta",red:"Rød","red orange":"rødoransje",saturation:"Metning",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} gjennomsiktig`,"very dark":"svært mørk","very light":"svært lys",vibrant:"levende",white:"hvit",yellow:"gul","yellow green":"gulgrønn"};var oO={};oO={alpha:"Alfa",black:"zwart",blue:"Blauw","blue purple":"paarsblauw",brightness:"Helderheid",brown:"bruin","brown yellow":"bruingeel",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyaan","cyan blue":"cyaanblauw",dark:"donker",gray:"grijs",grayish:"grijsachtig",green:"Groen","green cyan":"cyaangroen",hue:"Kleurtoon",light:"licht",lightness:"Lichtsterkte",magenta:"magenta","magenta pink":"magentaroze",orange:"oranje","orange yellow":"oranjegeel",pale:"bleek",pink:"roze","pink red":"rozerood",purple:"paars","purple magenta":"magentapaars",red:"Rood","red orange":"roodoranje",saturation:"Verzadiging",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparant`,"very dark":"heel donker","very light":"heel licht",vibrant:"levendig",white:"wit",yellow:"geel","yellow green":"geelgroen"};var aO={};aO={alpha:"Alfa",black:"czarny",blue:"Niebieski","blue purple":"niebiesko-fioletowy",brightness:"Jasność",brown:"brązowy","brown yellow":"brązowo-żółty",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyjanowy","cyan blue":"cyjanowo-niebieski",dark:"ciemny",gray:"szary",grayish:"szarawy",green:"Zielony","green cyan":"zielono-cyjanowy",hue:"Odcień",light:"jasny",lightness:"Jaskrawość",magenta:"purpurowy","magenta pink":"purpurowo-różowy",orange:"pomarańczowy","orange yellow":"pomarańczowo-żółty",pale:"blady",pink:"różowy","pink red":"różowo-czerwony",purple:"fioletowy","purple magenta":"fioletowo-purpurowy",red:"Czerwony","red orange":"czerwono-pomarańczowy",saturation:"Nasycenie",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} przezroczystości`,"very dark":"bardzo ciemny","very light":"bardzo jasny",vibrant:"intensywny",white:"biały",yellow:"żółty","yellow green":"żółto-zielony"};var lO={};lO={alpha:"Alfa",black:"preto",blue:"Azul","blue purple":"roxo azulado",brightness:"Brilho",brown:"marrom","brown yellow":"marrom amarelado",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"ciano","cyan blue":"azul-ciano",dark:"escuro",gray:"cinza",grayish:"acinzentado",green:"Verde","green cyan":"verde-ciano",hue:"Matiz",light:"claro",lightness:"Luminosidade",magenta:"magenta","magenta pink":"rosa-magenta",orange:"laranja","orange yellow":"amarelo alaranjado",pale:"pálido",pink:"rosa","pink red":"rosa avermelhado",purple:"roxo","purple magenta":"roxo-magenta",red:"Vermelho","red orange":"laranja avermelhado",saturation:"Saturação",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparente`,"very dark":"muito escuro","very light":"muito claro",vibrant:"vibrante",white:"branco",yellow:"amarelo","yellow green":"verde amarelado"};var cO={};cO={alpha:"Alfa",black:"preto",blue:"Azul","blue purple":"azul-púrpura",brightness:"Luminosidade",brown:"castanho","brown yellow":"amarelo-castanho",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"ciano","cyan blue":"azul-ciano",dark:"escuro",gray:"cinzento",grayish:"acinzentado",green:"Verde","green cyan":"verde-ciano",hue:"Tonalidade",light:"claro",lightness:"Claridade",magenta:"magenta","magenta pink":"rosa-magenta",orange:"laranja","orange yellow":"amarelo-laranja",pale:"pálido",pink:"cor-de-rosa","pink red":"vermelho-rosa",purple:"púrpura","purple magenta":"púrpura-magenta",red:"Vermelho","red orange":"laranja-vermelho",saturation:"Saturação",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparente`,"very dark":"muito escuro","very light":"muito claro",vibrant:"vibrante",white:"branco",yellow:"amarelo","yellow green":"verde-amarelo"};var uO={};uO={alpha:"Alfa",black:"negru",blue:"Albastru","blue purple":"albastru-violet",brightness:"Luminozitate",brown:"maro","brown yellow":"galben maro",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"bleu","cyan blue":"albastru-bleu",dark:"închis",gray:"gri",grayish:"cenușiu",green:"Verde","green cyan":"verde bleu",hue:"Nuanță",light:"deschis",lightness:"Luminozitate",magenta:"fucsia","magenta pink":"roz-fucsia",orange:"portocaliu","orange yellow":"galben-portocaliu",pale:"pal",pink:"roz","pink red":"roz-roșu",purple:"violet","purple magenta":"violet-fucsia",red:"Roșu","red orange":"portocaliu-roșu",saturation:"Saturație",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparent`,"very dark":"foarte închis","very light":"foarte deschis",vibrant:"plin de viață",white:"alb",yellow:"galben","yellow green":"galben-verde"};var dO={};dO={alpha:"Альфа",black:"черный",blue:"Синий","blue purple":"сине-фиолетовый",brightness:"Яркость",brown:"коричневый","brown yellow":"коричнево-желтый",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"голубой","cyan blue":"цвет морской волны",dark:"темный",gray:"серый",grayish:"сероватый",green:"Зеленый","green cyan":"сине-зеленый",hue:"Оттенок",light:"светлый",lightness:"Освещенность",magenta:"пурпурный","magenta pink":"пурпурно-розовый",orange:"оранжевый","orange yellow":"оранжево-желтый",pale:"бледный",pink:"розовый","pink red":"розово-красный",purple:"фиолетовый","purple magenta":"фиолетово-пурпурный",red:"Красный","red orange":"красно-оранжевый",saturation:"Насыщенность",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, прозрачный на ${e.percentTransparent}`,"very dark":"очень темный","very light":"очень светлый",vibrant:"яркий",white:"белый",yellow:"желтый","yellow green":"желто-зеленый"};var fO={};fO={alpha:"Alfa",black:"čierna",blue:"Modrá","blue purple":"modrofialová",brightness:"Jas",brown:"hnedá","brown yellow":"hnedožltá",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"azúrová","cyan blue":"azúrová modrá",dark:"tmavá",gray:"sivá",grayish:"sivastá",green:"Zelená","green cyan":"zelená azúrová",hue:"Odtieň",light:"svetlá",lightness:"Svetlosť",magenta:"purpurová","magenta pink":"ružová purpurová",orange:"oranžová","orange yellow":"oranžovožltá",pale:"bledá",pink:"ružová","pink red":"ružovočervená",purple:"fialová","purple magenta":"fialová purpurová",red:"Červená","red orange":"červenooranžová",saturation:"Sýtosť",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} priehľadná`,"very dark":"veľmi tmavá","very light":"veľmi svetlá",vibrant:"energická",white:"biela",yellow:"žltá","yellow green":"žltozelená"};var hO={};hO={alpha:"Alfa",black:"črna",blue:"Modra","blue purple":"modro vijolična",brightness:"Svetlost",brown:"rjava","brown yellow":"rjavo rumena",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cian","cyan blue":"cian modra",dark:"temna",gray:"siva",grayish:"sivkasta",green:"Zelena","green cyan":"zelena cian",hue:"Barva",light:"svetla",lightness:"Lahkost",magenta:"škrlatna","magenta pink":"škrlatno roza",orange:"oranžna","orange yellow":"oranžno rumena",pale:"bleda",pink:"roza","pink red":"roza rdeča",purple:"vijolična","purple magenta":"vijolično škrlatna",red:"Rdeča","red orange":"rdeče oranžna",saturation:"Nasičenost",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} prozorna`,"very dark":"zelo temna","very light":"zelo svetla",vibrant:"živahna",white:"bela",yellow:"rumena","yellow green":"rumeno zelena"};var pO={};pO={alpha:"Alfa",black:"crno",blue:"Plava","blue purple":"plavoljubičasta",brightness:"Osvetljenost",brown:"smeđa","brown yellow":"smeđežuta",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cijan","cyan blue":"cijan plava",dark:"tamno",gray:"siva",grayish:"sivkasta",green:"Zelena","green cyan":"zeleno cijan",hue:"Nijansa",light:"svetla",lightness:"Osvetljenje",magenta:"purpurnocrvena","magenta pink":"magenta ružičasta",orange:"narandžasta","orange yellow":"narandžastožuta",pale:"bledo",pink:"ružičasta","pink red":"ružičastocrvena",purple:"ljubičasta","purple magenta":"ljubičasta magenta",red:"Crvena","red orange":"crvenonarandžasta",saturation:"Zasićenje",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} prozirna`,"very dark":"veoma tamno","very light":"vrlo svetlo",vibrant:"živopisna",white:"bela",yellow:"žuto","yellow green":"žutozelena"};var mO={};mO={alpha:"Alfa",black:"svart",blue:"Blått","blue purple":"blålila",brightness:"Ljusstyrka",brown:"brun","brown yellow":"brungul",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyan","cyan blue":"cyanblå",dark:"mörk",gray:"grå",grayish:"gråaktig",green:"Grönt","green cyan":"grön cyan",hue:"Nyans",light:"ljus",lightness:"Ljushet",magenta:"magenta","magenta pink":"magentarosa",orange:"orange","orange yellow":"orangegul",pale:"blek",pink:"rosa","pink red":"rosaröd",purple:"lila","purple magenta":"lila magenta",red:"Rött","red orange":"rödorange",saturation:"Mättnad",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} genomskinlig`,"very dark":"mycket mörk","very light":"mycket ljus",vibrant:"livfull",white:"vit",yellow:"gul","yellow green":"gulgrön"};var gO={};gO={alpha:"Alfa",black:"siyah",blue:"Mavi","blue purple":"mavi mor",brightness:"Parlaklık",brown:"kahverengi","brown yellow":"kahverengi sarı",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"camgöbeği","cyan blue":"camgöbeği mavi",dark:"koyu",gray:"gri",grayish:"grimsi",green:"Yeşil","green cyan":"yeşil camgöbeği",hue:"Ton",light:"açık",lightness:"Canlılık",magenta:"eflatun","magenta pink":"eflatun pembe",orange:"turuncu","orange yellow":"turuncu sarı",pale:"solgun",pink:"pembe","pink red":"pembe kırmızı",purple:"mor","purple magenta":"mor eflatun",red:"Kırmızı","red orange":"kırmızı portakal",saturation:"Doygunluk",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} saydam`,"very dark":"çok koyu","very light":"çok açık",vibrant:"canlı",white:"beyaz",yellow:"sarı","yellow green":"sarı yeşil"};var vO={};vO={alpha:"Альфа",black:"чорний",blue:"Синій","blue purple":"синьо-фіолетовий",brightness:"Яскравість",brown:"коричневий","brown yellow":"коричнево-жовтий",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"блакитний","cyan blue":"синьо-блакитний",dark:"темний",gray:"сірий",grayish:"сіруватий",green:"Зелений","green cyan":"зелено-блакитний",hue:"Тон",light:"світлий",lightness:"Освітленість",magenta:"пурпуровий","magenta pink":"пурпурово-рожевий",orange:"помаранчевий","orange yellow":"помаранчево-жовтий",pale:"блідий",pink:"рожевий","pink red":"рожево-червоний",purple:"фіолетовий","purple magenta":"фіолетово-пурпуровий",red:"Червоний","red orange":"червоно-помаранчевий",saturation:"Насиченість",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, прозорий на ${e.percentTransparent}`,"very dark":"дуже темний","very light":"дуже світлий",vibrant:"яскравий",white:"білий",yellow:"жовтий","yellow green":"жовто-зелений"};var yO={};yO={alpha:"Alpha",black:"黑色",blue:"蓝色","blue purple":"蓝紫色",brightness:"亮度",brown:"棕色的","brown yellow":"棕黄色",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"蓝绿色","cyan blue":"青蓝色",dark:"深色",gray:"灰色",grayish:"浅灰色的",green:"绿色","green cyan":"绿青色",hue:"色相",light:"浅色",lightness:"明亮度",magenta:"紫红色","magenta pink":"紫粉色",orange:"橙色","orange yellow":"橙黄色",pale:"苍白的",pink:"粉色","pink red":"粉红色",purple:"紫色","purple magenta":"紫洋红色",red:"红色","red orange":"红橙色",saturation:"饱和度",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} 透明`,"very dark":"很暗","very light":"很浅",vibrant:"生机勃勃",white:"白色",yellow:"黄色","yellow green":"黄色/绿色"};var bO={};bO={alpha:"Alpha",black:"黑",blue:"藍色","blue purple":"藍紫",brightness:"亮度",brown:"棕","brown yellow":"棕黃",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"青","cyan blue":"青藍",dark:"暗",gray:"灰",grayish:"偏灰",green:"綠色","green cyan":"青綠",hue:"色相",light:"淺",lightness:"明亮",magenta:"洋紅","magenta pink":"淺洋紅",orange:"橙","orange yellow":"橙黃",pale:"淡",pink:"粉紅","pink red":"粉紅",purple:"紫","purple magenta":"紫洋紅",red:"紅色","red orange":"橙紅",saturation:"飽和度",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} 透明`,"very dark":"很暗","very light":"很淺",vibrant:"鮮豔",white:"白",yellow:"黃","yellow green":"黃綠"};var xO={};xO={"ar-AE":VF,"bg-BG":HF,"cs-CZ":BF,"da-DK":zF,"de-DE":UF,"el-GR":ZF,"en-US":WF,"es-ES":GF,"et-EE":qF,"fi-FI":KF,"fr-FR":YF,"he-IL":XF,"hr-HR":QF,"hu-HU":JF,"it-IT":eO,"ja-JP":tO,"ko-KR":nO,"lt-LT":rO,"lv-LV":iO,"nb-NO":sO,"nl-NL":oO,"pl-PL":aO,"pt-BR":lO,"pt-PT":cO,"ro-RO":uO,"ru-RU":dO,"sk-SK":fO,"sl-SI":hO,"sr-SP":pO,"sv-SE":mO,"tr-TR":gO,"uk-UA":vO,"zh-CN":yO,"zh-TW":bO};const R1e=Symbol.for("react-aria.i18n.locale"),$1e=Symbol.for("react-aria.i18n.strings");let mu;class Oa{constructor(t,n="en-US"){this.strings=Object.fromEntries(Object.entries(t).filter(([,r])=>r)),this.defaultLocale=n}getStringForLocale(t,n){let i=this.getStringsForLocale(n)[t];if(!i)throw new Error(`Could not find intl message ${t} in ${n} locale`);return i}getStringsForLocale(t){let n=this.strings[t];return n||(n=D1e(t,this.strings,this.defaultLocale),this.strings[t]=n),n}static getGlobalDictionaryForPackage(t){if(typeof window>"u")return null;let n=window[R1e];if(mu===void 0){let i=window[$1e];if(!i)return null;mu={};for(let s in i)mu[s]=new Oa({[n]:i[s]},n)}let r=mu==null?void 0:mu[t];if(!r)throw new Error(`Strings for package "${t}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);return r}}function D1e(e,t,n="en-US"){if(t[e])return t[e];let r=N1e(e);if(t[r])return t[r];for(let i in t)if(i.startsWith(r+"-"))return t[i];return t[n]}function N1e(e){return Intl.Locale?new Intl.Locale(e).language:e.split("-")[0]}const hT=new Map,pT=new Map;class wO{constructor(t,n){this.locale=t,this.strings=n}format(t,n){let r=this.strings.getStringForLocale(t,this.locale);return typeof r=="function"?r(n,this):r}plural(t,n,r="cardinal"){let i=n["="+t];if(i)return typeof i=="function"?i():i;let s=this.locale+":"+r,o=hT.get(s);o||(o=new Intl.PluralRules(this.locale,{type:r}),hT.set(s,o));let a=o.select(t);return i=n[a]||n.other,typeof i=="function"?i():i}number(t){let n=pT.get(this.locale);return n||(n=new Intl.NumberFormat(this.locale),pT.set(this.locale,n)),n.format(t)}select(t,n){let r=t[n]||t.other;return typeof r=="function"?r():r}}let fx=new Map,c6=!1;try{c6=new Intl.NumberFormat("de-DE",{signDisplay:"exceptZero"}).resolvedOptions().signDisplay==="exceptZero"}catch{}let _1=!1;try{_1=new Intl.NumberFormat("de-DE",{style:"unit",unit:"degree"}).resolvedOptions().style==="unit"}catch{}const kO={degree:{narrow:{default:"°","ja-JP":" 度","zh-TW":"度","sl-SI":" °"}}};class Rv{constructor(t,n={}){this.numberFormatter=L1e(t,n),this.options=n}format(t){var r;let n="";if(!c6&&this.options.signDisplay!=null?n=j1e(this.numberFormatter,this.options.signDisplay,t):n=this.numberFormatter.format(t),this.options.style==="unit"&&!_1){let{unit:i,unitDisplay:s="short",locale:o}=this.resolvedOptions();if(!i)return n;let a=(r=kO[i])==null?void 0:r[s];n+=a[o]||a.default}return n}formatToParts(t){return this.numberFormatter.formatToParts(t)}formatRange(t,n){if(typeof this.numberFormatter.formatRange=="function")return this.numberFormatter.formatRange(t,n);if(n<t)throw new RangeError("End date must be >= start date");return`${this.format(t)} – ${this.format(n)}`}formatRangeToParts(t,n){if(typeof this.numberFormatter.formatRangeToParts=="function")return this.numberFormatter.formatRangeToParts(t,n);if(n<t)throw new RangeError("End date must be >= start date");let r=this.numberFormatter.formatToParts(t),i=this.numberFormatter.formatToParts(n);return[...r.map(s=>({...s,source:"startRange"})),{type:"literal",value:" – ",source:"shared"},...i.map(s=>({...s,source:"endRange"}))]}resolvedOptions(){let t=this.numberFormatter.resolvedOptions();return!c6&&this.options.signDisplay!=null&&(t={...t,signDisplay:this.options.signDisplay}),!_1&&this.options.style==="unit"&&(t={...t,style:"unit",unit:this.options.unit,unitDisplay:this.options.unitDisplay}),t}}function L1e(e,t={}){var s;let{numberingSystem:n}=t;if(n&&e.includes("-nu-")&&(e.includes("-u-")||(e+="-u-"),e+=`-nu-${n}`),t.style==="unit"&&!_1){let{unit:o,unitDisplay:a="short"}=t;if(!o)throw new Error('unit option must be provided with style: "unit"');if(!((s=kO[o])!=null&&s[a]))throw new Error(`Unsupported unit ${o} with unitDisplay = ${a}`);t={...t,style:"decimal"}}let r=e+(t?Object.entries(t).sort((o,a)=>o[0]<a[0]?-1:1).join():"");if(fx.has(r))return fx.get(r);let i=new Intl.NumberFormat(e,t);return fx.set(r,i),i}function j1e(e,t,n){if(t==="auto")return e.format(n);if(t==="never")return e.format(Math.abs(n));{let r=!1;if(t==="always"?r=n>0||Object.is(n,0):t==="exceptZero"&&(Object.is(n,-0)||Object.is(n,0)?n=Math.abs(n):r=n>0),r){let i=e.format(-n),s=e.format(n),o=i.replace(s,"").replace(/\u200e|\u061C/,"");return[...o].length!==1&&console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case"),i.replace(s,"!!!").replace(o,"+").replace("!!!",s)}else return e.format(n)}}function F1e(e){return e&&e.__esModule?e.default:e}let hx=new Oa(F1e(xO));function Do(e){let t=op.parse(e)||ap.parse(e)||lp.parse(e);if(t)return t;throw new Error("Invalid color value: "+e)}function Wu(e){return typeof e=="string"?Do(e):e}function CO(e){return e===360?e:(e%360+360)%360}const mT=.68,O1e=.85,gT=.55,vT=.001,px=[[0,"pink"],[15,"red"],[48,"orange"],[94,"yellow"],[135,"green"],[175,"cyan"],[264,"blue"],[284,"purple"],[320,"magenta"],[349,"pink"]];class uk{toHexInt(){return this.toFormat("rgb").toHexInt()}getChannelValue(t){if(t in this)return this[t];throw new Error("Unsupported color channel: "+t)}withChannelValue(t,n){if(t in this){let r=this.clone();return r[t]=n,r}throw new Error("Unsupported color channel: "+t)}getChannelName(t,n){return(Oa.getGlobalDictionaryForPackage("@react-stately/color")||hx).getStringForLocale(t,n)}getColorSpaceAxes(t){let{xChannel:n,yChannel:r}=t,i=n||this.getColorChannels().find(a=>a!==r),s=r||this.getColorChannels().find(a=>a!==i),o=this.getColorChannels().find(a=>a!==i&&a!==s);return{xChannel:i,yChannel:s,zChannel:o}}getColorName(t){let[n,r,i]=yT(this),s=Oa.getGlobalDictionaryForPackage("@react-stately/color")||hx;if(n>.999)return s.getStringForLocale("white",t);if(n<.001)return s.getStringForLocale("black",t);let o;[o,n]=this.getOklchHue(n,r,i,t);let a="",c="";r<=.1&&r>=vT?n>=.7?c="pale":c="grayish":r>=.15&&(c="vibrant"),n<.3?a="very dark":n<gT?a="dark":n<.7||(n<.85?a="light":a="very light"),c&&(c=s.getStringForLocale(c,t)),a&&(a=s.getStringForLocale(a,t));let u=this.getChannelValue("alpha"),h=new wO(t,s);if(u<1){let p=new Rv(t,{style:"percent"}).format(1-u);return h.format("transparentColorName",{lightness:a,chroma:c,hue:o,percentTransparent:p}).replace(/\s+/g," ").trim()}else return h.format("colorName",{lightness:a,chroma:c,hue:o}).replace(/\s+/g," ").trim()}getOklchHue(t,n,r,i){let s=Oa.getGlobalDictionaryForPackage("@react-stately/color")||hx;if(n<vT)return[s.getStringForLocale("gray",i),t];for(let o=0;o<px.length;o++){let[a,c]=px[o],[u,h]=px[o+1]||[360,"pink"];if(r>=a&&r<u)return c==="orange"&&(t<mT?c="brown":t=t-mT+gT),r>a+(u-a)/2&&c!==h?c=`${c} ${h}`:c==="yellow"&&t<O1e&&(c="yellow green"),[s.getStringForLocale(c,i).toLocaleLowerCase(i),t]}throw new Error("Unexpected hue")}getHueName(t){let[n,r,i]=yT(this),[s]=this.getOklchHue(n,r,i,t);return s}}const Du=class Du extends uk{constructor(t,n,r,i){super(),this.red=t,this.green=n,this.blue=r,this.alpha=i}static parse(t){let n=[];if(/^#[\da-f]+$/i.test(t)&&[4,5,7,9].includes(t.length)){const i=(t.length<6?t.replace(/[^#]/gi,"$&$&"):t).slice(1).split("");for(;i.length>0;)n.push(parseInt(i.splice(0,2).join(""),16));n[3]=n[3]!==void 0?n[3]/255:void 0}const r=t.match(/^rgba?\((.*)\)$/);if(r!=null&&r[1]&&(n=r[1].split(",").map(i=>Number(i.trim())),n=n.map((i,s)=>Wi(i??0,0,s<3?255:1))),!(n[0]===void 0||n[1]===void 0||n[2]===void 0))return n.length<3?void 0:new Du(n[0],n[1],n[2],n[3]??1)}toString(t="css"){switch(t){case"hex":return"#"+(this.red.toString(16).padStart(2,"0")+this.green.toString(16).padStart(2,"0")+this.blue.toString(16).padStart(2,"0")).toUpperCase();case"hexa":return"#"+(this.red.toString(16).padStart(2,"0")+this.green.toString(16).padStart(2,"0")+this.blue.toString(16).padStart(2,"0")+Math.round(this.alpha*255).toString(16).padStart(2,"0")).toUpperCase();case"rgb":return`rgb(${this.red}, ${this.green}, ${this.blue})`;case"css":case"rgba":return`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;default:return this.toFormat(t).toString(t)}}toFormat(t){switch(t){case"hex":case"hexa":case"rgb":case"rgba":return this;case"hsb":case"hsba":return this.toHSB();case"hsl":case"hsla":return this.toHSL();default:throw new Error("Unsupported color conversion: rgb -> "+t)}}toHexInt(){return this.red<<16|this.green<<8|this.blue}toHSB(){const t=this.red/255,n=this.green/255,r=this.blue/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=s-i,a=s===0?0:o/s;let c=0;if(o!==0){switch(s){case t:c=(n-r)/o+(n<r?6:0);break;case n:c=(r-t)/o+2;break;case r:c=(t-n)/o+4;break}c/=6}return new ap(Xn(c*360,2),Xn(a*100,2),Xn(s*100,2),this.alpha)}toHSL(){const t=this.red/255,n=this.green/255,r=this.blue/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=(s+i)/2,a=s-i;let c,u;if(a===0)c=u=0;else{switch(u=a/(o<.5?s+i:2-s-i),s){case t:c=(n-r)/a+(n<r?6:0);break;case n:c=(r-t)/a+2;break;case r:default:c=(t-n)/a+4;break}c/=6}return new lp(Xn(c*360,2),Xn(u*100,2),Xn(o*100,2),this.alpha)}clone(){return new Du(this.red,this.green,this.blue,this.alpha)}getChannelRange(t){switch(t){case"red":case"green":case"blue":return{minValue:0,maxValue:255,step:1,pageSize:17};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+t)}}getChannelFormatOptions(t){switch(t){case"red":case"green":case"blue":return{style:"decimal"};case"alpha":return{style:"percent"};default:throw new Error("Unknown color channel: "+t)}}formatChannelValue(t,n){let r=this.getChannelFormatOptions(t),i=this.getChannelValue(t);return new Rv(n,r).format(i)}getColorSpace(){return"rgb"}getColorChannels(){return Du.colorChannels}};Du.colorChannels=["red","green","blue"];let op=Du;const V1e=/hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/,Nu=class Nu extends uk{constructor(t,n,r,i){super(),this.hue=t,this.saturation=n,this.brightness=r,this.alpha=i}static parse(t){let n;if(n=t.match(V1e)){const[r,i,s,o]=(n[1]??n[2]).split(",").map(a=>Number(a.trim().replace("%","")));return new Nu(CO(r),Wi(i,0,100),Wi(s,0,100),Wi(o??1,0,1))}}toString(t="css"){switch(t){case"css":return this.toHSL().toString("css");case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"hsb":return`hsb(${this.hue}, ${Xn(this.saturation,2)}%, ${Xn(this.brightness,2)}%)`;case"hsba":return`hsba(${this.hue}, ${Xn(this.saturation,2)}%, ${Xn(this.brightness,2)}%, ${this.alpha})`;default:return this.toFormat(t).toString(t)}}toFormat(t){switch(t){case"hsb":case"hsba":return this;case"hsl":case"hsla":return this.toHSL();case"rgb":case"rgba":return this.toRGB();default:throw new Error("Unsupported color conversion: hsb -> "+t)}}toHSL(){let t=this.saturation/100,n=this.brightness/100,r=n*(1-t/2);return t=r===0||r===1?0:(n-r)/Math.min(r,1-r),new lp(Xn(this.hue,2),Xn(t*100,2),Xn(r*100,2),this.alpha)}toRGB(){let t=this.hue,n=this.saturation/100,r=this.brightness/100,i=(s,o=(s+t/60)%6)=>r-n*r*Math.max(Math.min(o,4-o,1),0);return new op(Math.round(i(5)*255),Math.round(i(3)*255),Math.round(i(1)*255),this.alpha)}clone(){return new Nu(this.hue,this.saturation,this.brightness,this.alpha)}getChannelRange(t){switch(t){case"hue":return{minValue:0,maxValue:360,step:1,pageSize:15};case"saturation":case"brightness":return{minValue:0,maxValue:100,step:1,pageSize:10};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+t)}}getChannelFormatOptions(t){switch(t){case"hue":return{style:"unit",unit:"degree",unitDisplay:"narrow"};case"saturation":case"brightness":case"alpha":return{style:"percent"};default:throw new Error("Unknown color channel: "+t)}}formatChannelValue(t,n){let r=this.getChannelFormatOptions(t),i=this.getChannelValue(t);return(t==="saturation"||t==="brightness")&&(i/=100),new Rv(n,r).format(i)}getColorSpace(){return"hsb"}getColorChannels(){return Nu.colorChannels}};Nu.colorChannels=["hue","saturation","brightness"];let ap=Nu;const H1e=/hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/,Lu=class Lu extends uk{constructor(t,n,r,i){super(),this.hue=t,this.saturation=n,this.lightness=r,this.alpha=i}static parse(t){let n;if(n=t.match(H1e)){const[r,i,s,o]=(n[1]??n[2]).split(",").map(a=>Number(a.trim().replace("%","")));return new Lu(CO(r),Wi(i,0,100),Wi(s,0,100),Wi(o??1,0,1))}}toString(t="css"){switch(t){case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"hsl":return`hsl(${this.hue}, ${Xn(this.saturation,2)}%, ${Xn(this.lightness,2)}%)`;case"css":case"hsla":return`hsla(${this.hue}, ${Xn(this.saturation,2)}%, ${Xn(this.lightness,2)}%, ${this.alpha})`;default:return this.toFormat(t).toString(t)}}toFormat(t){switch(t){case"hsl":case"hsla":return this;case"hsb":case"hsba":return this.toHSB();case"rgb":case"rgba":return this.toRGB();default:throw new Error("Unsupported color conversion: hsl -> "+t)}}toHSB(){let t=this.saturation/100,n=this.lightness/100,r=n+t*Math.min(n,1-n);return t=r===0?0:2*(1-n/r),new ap(Xn(this.hue,2),Xn(t*100,2),Xn(r*100,2),this.alpha)}toRGB(){let t=this.hue,n=this.saturation/100,r=this.lightness/100,i=n*Math.min(r,1-r),s=(o,a=(o+t/30)%12)=>r-i*Math.max(Math.min(a-3,9-a,1),-1);return new op(Math.round(s(0)*255),Math.round(s(8)*255),Math.round(s(4)*255),this.alpha)}clone(){return new Lu(this.hue,this.saturation,this.lightness,this.alpha)}getChannelRange(t){switch(t){case"hue":return{minValue:0,maxValue:360,step:1,pageSize:15};case"saturation":case"lightness":return{minValue:0,maxValue:100,step:1,pageSize:10};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+t)}}getChannelFormatOptions(t){switch(t){case"hue":return{style:"unit",unit:"degree",unitDisplay:"narrow"};case"saturation":case"lightness":case"alpha":return{style:"percent"};default:throw new Error("Unknown color channel: "+t)}}formatChannelValue(t,n){let r=this.getChannelFormatOptions(t),i=this.getChannelValue(t);return(t==="saturation"||t==="lightness")&&(i/=100),new Rv(n,r).format(i)}getColorSpace(){return"hsl"}getColorChannels(){return Lu.colorChannels}};Lu.colorChannels=["hue","saturation","lightness"];let lp=Lu;function yT(e){let t=e.toFormat("rgb"),n=t.getChannelValue("red")/255,r=t.getChannelValue("green")/255,i=t.getChannelValue("blue")/255;[n,r,i]=z1e(n,r,i);let[s,o,a]=U1e(n,r,i),[c,u,h]=Z1e(s,o,a);return B1e(c,u,h)}function B1e(e,t,n){var r=Math.atan2(n,t)*180/Math.PI;return[e,Math.sqrt(t**2+n**2),r>=0?r:r+360]}function z1e(e,t,n){return[mx(e),mx(t),mx(n)]}function mx(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*Math.pow((n+.055)/1.055,2.4)}function U1e(e,t,n){return u6([.4123907992659595,.35758433938387796,.1804807884018343,.21263900587151036,.7151686787677559,.07219231536073371,.01933081871559185,.11919477979462599,.9505321522496606],e,t,n)}function Z1e(e,t,n){const r=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],i=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];let[s,o,a]=u6(r,e,t,n);return u6(i,Math.cbrt(s),Math.cbrt(o),Math.cbrt(a))}function u6(e,t,n,r){let i=e[0]*t+e[1]*n+e[2]*r,s=e[3]*t+e[4]*n+e[5]*r,o=e[6]*t+e[7]*n+e[8]*r;return[i,s,o]}const EO=e=>[0,60,120,180,240,300,360].map(t=>e.withChannelValue("hue",t).toString("css")).join(", "),SO=e=>`${e.withChannelValue("saturation",0)}, transparent`,W1e={hue:EO,saturation:SO,lightness:()=>"black, transparent, white"},G1e={hue:EO,saturation:SO,brightness:()=>"black, transparent"};function q1e({direction:e,state:t,zChannel:n,xChannel:r,yChannel:i}){return f.useMemo(()=>{let o=e==="rtl"?"left":"right",a={},c=t.value.getChannelValue(n);switch(t.value.getColorSpace()){case"rgb":{let m=Do("rgb(0, 0, 0)");a={background:[`linear-gradient(to ${o}, ${m.withChannelValue(r,0)}, ${m.withChannelValue(r,255)})`,`linear-gradient(to top, ${m.withChannelValue(i,0)}, ${m.withChannelValue(i,255)})`,m.withChannelValue(n,c)].join(","),backgroundBlendMode:"screen"};break}case"hsl":{let m=t.value.getColorChannels(),g=Do("hsl(0, 100%, 50%)").withChannelValue(n,c),b=m.filter(x=>x!==n).map(x=>`linear-gradient(to ${x===r?o:"top"}, ${W1e[x](g)})`).reverse();n==="hue"&&b.push(g.toString("css")),a={background:b.join(", ")};break}case"hsb":{let m=t.value.getColorChannels(),g=Do("hsb(0, 100%, 100%)").withChannelValue(n,c),b=m.filter(x=>x!==n).map(x=>`linear-gradient(to ${x===r?o:"top"}, ${G1e[x](g)})`).reverse();n==="hue"&&b.push(g.toString("css")),a={background:b.join(", ")};break}}let{x:u,y:h}=t.getThumbPosition();e==="rtl"&&(u=1-u);let p={forcedColorAdjust:"none"};return{colorAreaStyleProps:{style:{position:"relative",touchAction:"none",...p,...a}},thumbStyleProps:{style:{position:"absolute",left:`${u*100}%`,top:`${h*100}%`,transform:"translate(-50%, -50%)",touchAction:"none",...p}}}},[e,t,n,r,i])}const Es=e=>(e==null?void 0:e.ownerDocument)??document,wd=e=>e&&"window"in e&&e.window===e?e:Es(e).defaultView||window;function K1e(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function Y1e(e){return K1e(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let X1e=!1;function dk(){return X1e}function Fm(e,t){if(!dk())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n.tagName==="SLOT"&&n.assignedSlot?n=n.assignedSlot.parentNode:Y1e(n)?n=n.host:n=n.parentNode}return!1}const tl=(e=document)=>{var n;if(!dk())return e.activeElement;let t=e.activeElement;for(;t&&"shadowRoot"in t&&((n=t.shadowRoot)!=null&&n.activeElement);)t=t.shadowRoot.activeElement;return t};function Er(e){if(dk()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}function _O(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Q1e(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function AO(e){let t=f.useRef({isFocused:!1,observer:null});return Mv(()=>{const n=t.current;return()=>{n.observer&&(n.observer.disconnect(),n.observer=null)}},[]),f.useCallback(n=>{let r=Er(n);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){t.current.isFocused=!0;let i=r,s=o=>{if(t.current.isFocused=!1,i.disabled){let a=_O(o);e==null||e(a)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};i.addEventListener("focusout",s,{once:!0}),t.current.observer=new MutationObserver(()=>{var o;if(t.current.isFocused&&i.disabled){(o=t.current.observer)==null||o.disconnect();let a=i===tl()?null:tl();i.dispatchEvent(new FocusEvent("blur",{relatedTarget:a})),i.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:a}))}}),t.current.observer.observe(i,{attributes:!0,attributeFilter:["disabled"]})}},[e])}let J1e=!1;function A1(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:i}=e;const s=f.useCallback(c=>{if(Er(c)===c.currentTarget)return r&&r(c),i&&i(!1),!0},[r,i]),o=AO(s),a=f.useCallback(c=>{let u=Er(c);const h=Es(u),p=h?tl(h):tl();u===c.currentTarget&&u===p&&(n&&n(c),i&&i(!0),o(c))},[i,n,o]);return{focusProps:{onFocus:!t&&(n||i||r)?a:void 0,onBlur:!t&&(r||i)?s:void 0}}}function $p(){let e=f.useRef(new Map),t=f.useCallback((i,s,o,a)=>{let c=a!=null&&a.once?(...u)=>{e.current.delete(o),o(...u)}:o;e.current.set(o,{type:s,eventTarget:i,fn:c,options:a}),i.addEventListener(s,c,a)},[]),n=f.useCallback((i,s,o,a)=>{var u;let c=((u=e.current.get(o))==null?void 0:u.fn)||o;i.removeEventListener(s,c,a),e.current.delete(o)},[]),r=f.useCallback(()=>{e.current.forEach((i,s)=>{n(i.eventTarget,i.type,s,i.options)})},[n]);return f.useEffect(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:r}}function fk(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:r,onFocusWithinChange:i}=e,s=f.useRef({isFocusWithin:!1}),{addGlobalListener:o,removeAllGlobalListeners:a}=$p(),c=f.useCallback(p=>{Fm(p.currentTarget,Er(p))&&s.current.isFocusWithin&&!Fm(p.currentTarget,p.relatedTarget)&&(s.current.isFocusWithin=!1,a(),n&&n(p),i&&i(!1))},[n,i,s,a]),u=AO(c),h=f.useCallback(p=>{if(!Fm(p.currentTarget,Er(p)))return;let m=Er(p);const g=Es(m),b=tl(g);if(!s.current.isFocusWithin&&b===m){r&&r(p),i&&i(!0),s.current.isFocusWithin=!0,u(p);let x=p.currentTarget;o(g,"focus",C=>{let w=Er(C);if(s.current.isFocusWithin&&!Fm(x,w)){let E=new g.defaultView.FocusEvent("blur",{relatedTarget:w});Q1e(E,x);let _=_O(E);c(_)}},{capture:!0})}},[r,i,u,o,c]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:h,onBlur:c}}}const eve=xe.useInsertionEffect??Mv;function d6(e){const t=f.useRef(null);return eve(()=>{t.current=e},[e]),f.useCallback((...n)=>{const r=t.current;return r==null?void 0:r(...n)},[])}function TO(e,t,n){let r=d6(i=>{n&&!i.defaultPrevented&&n(t)});f.useEffect(()=>{var s;let i=(s=e==null?void 0:e.current)==null?void 0:s.form;return i==null||i.addEventListener("reset",r),()=>{i==null||i.removeEventListener("reset",r)}},[e])}function bT(e){if(!e)return;let t=!0;return n=>{let r={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){t=!0},continuePropagation(){t=!1},isPropagationStopped(){return t}};e(r),t&&n.stopPropagation()}}function hk(e){return{keyboardProps:e.isDisabled?{}:{onKeyDown:bT(e.onKeyDown),onKeyUp:bT(e.onKeyUp)}}}function mg(e,t){let{id:n,"aria-label":r,"aria-labelledby":i}=e;return n=l6(n),i&&r?i=[...new Set([n,...i.trim().split(/\s+/)])].join(" "):i&&(i=i.trim().split(/\s+/).join(" ")),!r&&!i&&t&&(r=t),{id:n,"aria-label":r,"aria-labelledby":i}}const tve=new Set(["Arab","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),nve=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function rve(e){if(Intl.Locale){let n=new Intl.Locale(e).maximize(),r=typeof n.getTextInfo=="function"?n.getTextInfo():n.textInfo;if(r)return r.direction==="rtl";if(n.script)return tve.has(n.script)}let t=e.split("-")[0];return nve.has(t)}const PO=Symbol.for("react-aria.i18n.locale");function IO(){let e=typeof window<"u"&&window[PO]||typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:rve(e)?"rtl":"ltr"}}let f6=IO(),ph=new Set;function xT(){f6=IO();for(let e of ph)e(f6)}function ive(){let e=OF(),[t,n]=f.useState(f6);return f.useEffect(()=>(ph.size===0&&window.addEventListener("languagechange",xT),ph.add(n),()=>{ph.delete(n),ph.size===0&&window.removeEventListener("languagechange",xT)}),[]),e?{locale:typeof window<"u"&&window[PO]||"en-US",direction:"ltr"}:t}const sve=xe.createContext(null);function Bd(){let e=ive();return f.useContext(sve)||e}const wT=new WeakMap;function ove(e){let t=wT.get(e);return t||(t=new Oa(e),wT.set(e,t)),t}function ave(e,t){return t&&Oa.getGlobalDictionaryForPackage(t)||ove(e)}function lve(e,t){let{locale:n}=Bd(),r=ave(e,t);return f.useMemo(()=>new wO(n,r),[n,r])}let Sa=new Map,h6=new Set;function kT(){if(typeof window>"u")return;function e(r){return"propertyName"in r}let t=r=>{let i=Er(r);if(!e(r)||!i)return;let s=Sa.get(i);s||(s=new Set,Sa.set(i,s),i.addEventListener("transitioncancel",n,{once:!0})),s.add(r.propertyName)},n=r=>{let i=Er(r);if(!e(r)||!i)return;let s=Sa.get(i);if(s&&(s.delete(r.propertyName),s.size===0&&(i.removeEventListener("transitioncancel",n),Sa.delete(i)),Sa.size===0)){for(let o of h6)o();h6.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",n)}typeof document<"u"&&(document.readyState!=="loading"?kT():document.addEventListener("DOMContentLoaded",kT));function cve(){for(const[e]of Sa)"isConnected"in e&&!e.isConnected&&Sa.delete(e)}function MO(e){requestAnimationFrame(()=>{cve(),Sa.size===0?e():h6.add(e)})}let $u="default",p6="",gg=new WeakMap;function uve(e){if(ck()){if($u==="default"){const t=Es(e);p6=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}$u="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";gg.set(e,e.style[t]),e.style[t]="none"}}function dve(e){if(ck()){if($u!=="disabled")return;$u="restoring",setTimeout(()=>{MO(()=>{if($u==="restoring"){const t=Es(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=p6||""),p6="",$u="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&gg.has(e)){let t=gg.get(e),n="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[n]==="none"&&(e.style[n]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),gg.delete(e)}}function T1(e){let{onMoveStart:t,onMove:n,onMoveEnd:r}=e,i=f.useRef({didMove:!1,lastPosition:null,id:null}),{addGlobalListener:s,removeGlobalListener:o}=$p(),a=f.useCallback((m,g,b,x)=>{b===0&&x===0||(i.current.didMove||(i.current.didMove=!0,t==null||t({type:"movestart",pointerType:g,shiftKey:m.shiftKey,metaKey:m.metaKey,ctrlKey:m.ctrlKey,altKey:m.altKey})),n==null||n({type:"move",pointerType:g,deltaX:b,deltaY:x,shiftKey:m.shiftKey,metaKey:m.metaKey,ctrlKey:m.ctrlKey,altKey:m.altKey}))},[t,n,i]),c=d6(a),u=f.useCallback((m,g)=>{dve(),i.current.didMove&&(r==null||r({type:"moveend",pointerType:g,shiftKey:m.shiftKey,metaKey:m.metaKey,ctrlKey:m.ctrlKey,altKey:m.altKey}))},[r,i]),h=d6(u);return{moveProps:f.useMemo(()=>{let m={},g=()=>{uve(),i.current.didMove=!1};{let x=w=>{var E,_;if(w.pointerId===i.current.id){let T=w.pointerType||"mouse";c(w,T,w.pageX-(((E=i.current.lastPosition)==null?void 0:E.pageX)??0),w.pageY-(((_=i.current.lastPosition)==null?void 0:_.pageY)??0)),i.current.lastPosition={pageX:w.pageX,pageY:w.pageY}}},C=w=>{if(w.pointerId===i.current.id){let E=w.pointerType||"mouse";h(w,E),i.current.id=null;let _=wd(Er(w));o(_,"pointermove",x,!1),o(_,"pointerup",C,!1),o(_,"pointercancel",C,!1)}};m.onPointerDown=w=>{if(w.button===0&&i.current.id==null){g(),w.stopPropagation(),w.preventDefault(),i.current.lastPosition={pageX:w.pageX,pageY:w.pageY},i.current.id=w.pointerId;let E=wd(Er(w));s(E,"pointermove",x,!1),s(E,"pointerup",C,!1),s(E,"pointercancel",C,!1)}}}let b=(x,C,w)=>{g(),c(x,"keyboard",C,w),h(x,"keyboard")};return m.onKeyDown=x=>{switch(x.key){case"Left":case"ArrowLeft":x.preventDefault(),x.stopPropagation(),b(x,-1,0);break;case"Right":case"ArrowRight":x.preventDefault(),x.stopPropagation(),b(x,1,0);break;case"Up":case"ArrowUp":x.preventDefault(),x.stopPropagation(),b(x,0,-1);break;case"Down":case"ArrowDown":x.preventDefault(),x.stopPropagation(),b(x,0,1);break}},m},[s,o,i])}}const CT={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"};function RO(e={}){let{style:t,isFocusable:n}=e,[r,i]=f.useState(!1),{focusWithinProps:s}=fk({isDisabled:!n,onFocusWithinChange:a=>i(a)}),o=f.useMemo(()=>r?t:t?{...CT,...t}:CT,[r]);return{visuallyHiddenProps:{...s,style:o}}}function fve(e){return e&&e.__esModule?e.default:e}function hve(e,t){let{isDisabled:n,inputXRef:r,inputYRef:i,containerRef:s,"aria-label":o,xName:a,yName:c,form:u}=e,h=lve(fve(DF),"@react-aria/color"),{addGlobalListener:p,removeGlobalListener:m}=$p(),{direction:g,locale:b}=Bd(),[x,C]=f.useState(null),w=f.useCallback((ye=r)=>{ye.current&&sp(ye.current)},[r]);TO(r,t.defaultValue,t.setValue);let[E,_]=f.useState(!1),[T,I]=f.useState(!1),{xChannel:P,yChannel:M,zChannel:S}=t.channels,R=t.xChannelStep,$=t.yChannelStep,L=f.useRef(null),{keyboardProps:j}=hk({onKeyDown(ye){if(!/^(PageUp|PageDown|Home|End)$/.test(ye.key)){ye.continuePropagation();return}ye.preventDefault(),t.setDragging(!0),_(!0);let Ke;switch(ye.key){case"PageUp":t.incrementY(t.yChannelPageStep),Ke="y";break;case"PageDown":t.decrementY(t.yChannelPageStep),Ke="y";break;case"Home":g==="rtl"?t.incrementX(t.xChannelPageStep):t.decrementX(t.xChannelPageStep),Ke="x";break;case"End":g==="rtl"?t.decrementX(t.xChannelPageStep):t.incrementX(t.xChannelPageStep),Ke="x";break}t.setDragging(!1),Ke&&(w(Ke==="x"?r:i),C(Ke))}}),O={onMoveStart(){L.current=null,t.setDragging(!0)},onMove({deltaX:ye,deltaY:Ke,pointerType:Dt,shiftKey:Mt}){var ce;let{incrementX:jt,decrementX:bn,incrementY:nn,decrementY:he,xChannelPageStep:be,xChannelStep:Ue,yChannelPageStep:ot,yChannelStep:at,getThumbPosition:Ht,setColorFromPoint:Ut}=t;L.current==null&&(L.current=Ht());let{width:ee,height:Y}=((ce=s.current)==null?void 0:ce.getBoundingClientRect())||{width:0,height:0},se=ye!==0||Ke!==0;if(Dt==="keyboard"){let le=Mt&&be>Ue?be:Ue,ge=Mt&&ot>at?ot:at;ye>0&&g==="ltr"||ye<0&&g==="rtl"?jt(le):ye<0&&g==="ltr"||ye>0&&g==="rtl"?bn(le):Ke>0?he(ge):Ke<0&&nn(ge),_(se),x=se&&Math.abs(Ke)>Math.abs(ye)?"y":"x",C(x)}else L.current.x+=(g==="rtl"?-1:1)*ye/ee,L.current.y+=Ke/Y,Ut(L.current.x,L.current.y)},onMoveEnd(){K.current=!1,t.setDragging(!1),w(x==="x"?r:i)}},{moveProps:H}=T1(O),{focusWithinProps:B}=fk({onFocusWithinChange:ye=>{ye||(_(!1),I(!1))}}),Z=f.useRef(void 0),K=f.useRef(!1),{moveProps:q}=T1({onMoveStart(){K.current&&O.onMoveStart()},onMove(ye){K.current&&O.onMove(ye)},onMoveEnd(){K.current&&O.onMoveEnd()}}),te=ye=>{t.isDragging||(Z.current=ye,_(!1),w(),t.setDragging(!0),typeof PointerEvent<"u"?p(window,"pointerup",F,!1):(p(window,"mouseup",F,!1),p(window,"touchend",F,!1)))},F=ye=>{var Dt;(ye.pointerId??((Dt=ye.changedTouches)==null?void 0:Dt[0].identifier))===Z.current&&(_(!1),w(),t.setDragging(!1),Z.current=void 0,K.current=!1,typeof PointerEvent<"u"?m(window,"pointerup",F,!1):(m(window,"mouseup",F,!1),m(window,"touchend",F,!1)))},V=(ye,Ke,Dt,Mt)=>{let jt=ye.getBoundingClientRect(),{width:bn,height:nn}=jt,he=(Dt-jt.x)/bn,be=(Mt-jt.y)/nn;g==="rtl"&&(he=1-he),he>=0&&he<=1&&be>=0&&be<=1&&!t.isDragging&&Z.current===void 0&&(K.current=!0,_(!1),Z.current=Ke,t.setColorFromPoint(he,be),w(),t.setDragging(!0),typeof PointerEvent<"u"?p(window,"pointerup",W,!1):(p(window,"mouseup",W,!1),p(window,"touchend",W,!1)))},W=ye=>{var Dt;let Ke=ye.pointerId??((Dt=ye.changedTouches)==null?void 0:Dt[0].identifier);K.current&&Ke===Z.current&&(K.current=!1,_(!1),Z.current=void 0,t.setDragging(!1),w(),typeof PointerEvent<"u"?m(window,"pointerup",W,!1):(m(window,"mouseup",W,!1),m(window,"touchend",W,!1)))},N=n?{}:$o({...typeof PointerEvent<"u"?{onPointerDown:ye=>{ye.pointerType==="mouse"&&(ye.button!==0||ye.altKey||ye.ctrlKey||ye.metaKey)||V(ye.currentTarget,ye.pointerId,ye.clientX,ye.clientY)}}:{onMouseDown:ye=>{ye.button!==0||ye.altKey||ye.ctrlKey||ye.metaKey||V(ye.currentTarget,void 0,ye.clientX,ye.clientY)},onTouchStart:ye=>{V(ye.currentTarget,ye.changedTouches[0].identifier,ye.changedTouches[0].clientX,ye.changedTouches[0].clientY)}}},q),z=n?{}:$o({...typeof PointerEvent<"u"?{onPointerDown:ye=>{ye.pointerType==="mouse"&&(ye.button!==0||ye.altKey||ye.ctrlKey||ye.metaKey)||te(ye.pointerId)}}:{onMouseDown:ye=>{ye.button!==0||ye.altKey||ye.ctrlKey||ye.metaKey||te(void 0)},onTouchStart:ye=>{te(ye.changedTouches[0].identifier)}}},B,j,H),{focusProps:Q}=A1({onFocus:()=>{C("x")}}),{focusProps:J}=A1({onFocus:()=>{C("y")}});const re=ye=>{const{target:Ke}=ye;I(!0),Ke===r.current?t.setXValue(parseFloat(Ke.value)):Ke===i.current&&t.setYValue(parseFloat(Ke.value))};let G=ck()||LF(),X=t.getDisplayColor();const de=f.useCallback(ye=>`${T||E?h.format("colorNameAndValue",{name:X.getChannelName(ye,b),value:X.formatChannelValue(ye,b)}):[h.format("colorNameAndValue",{name:X.getChannelName(ye,b),value:X.formatChannelValue(ye,b)}),h.format("colorNameAndValue",{name:X.getChannelName(ye===M?P:M,b),value:X.formatChannelValue(ye===M?P:M,b)}),h.format("colorNameAndValue",{name:X.getChannelName(S,b),value:X.formatChannelValue(S,b)})].join(", ")}, ${X.getColorName(b)}`,[b,X,h,T,E,P,M,S]);let ve=h.format("colorPicker"),we=mg({...e,"aria-label":o?h.format("colorInputLabel",{label:o,channelLabel:ve}):ve}),je=mg({...e,"aria-label":o?h.format("colorInputLabel",{label:o,channelLabel:ve}):ve}),Ae=mg({...e,"aria-label":o?`${o}, ${ve}`:void 0},G?ve:void 0),Le=h.format("twoDimensionalSlider"),{visuallyHiddenProps:tt}=RO({style:{opacity:"0.0001",width:"100%",height:"100%",pointerEvents:"none"}}),{colorAreaStyleProps:vt,thumbStyleProps:Je}=q1e({direction:g,state:t,xChannel:P,yChannel:M,zChannel:S});return{colorAreaProps:{...Ae,...N,...vt,role:"group"},thumbProps:{...z,...Je,role:"presentation"},xInputProps:{...we,...tt,...Q,type:"range",min:t.value.getChannelRange(P).minValue,max:t.value.getChannelRange(P).maxValue,step:R,"aria-roledescription":Le,"aria-valuetext":de(P),"aria-orientation":"horizontal","aria-describedby":e["aria-describedby"],"aria-details":e["aria-details"],disabled:n,value:t.value.getChannelValue(P),name:a,form:u,tabIndex:G||!x||x==="x"?void 0:-1,"aria-hidden":G||!x||x==="x"||E?void 0:"true",onChange:re},yInputProps:{...je,...tt,...J,type:"range",min:t.value.getChannelRange(M).minValue,max:t.value.getChannelRange(M).maxValue,step:$,"aria-roledescription":Le,"aria-valuetext":de(M),"aria-orientation":"vertical","aria-describedby":e["aria-describedby"],"aria-details":e["aria-details"],disabled:n,value:t.value.getChannelValue(M),name:c,form:u,tabIndex:G||x==="y"?void 0:-1,"aria-hidden":G||x==="y"||E?void 0:"true",onChange:re}}}const pk=new WeakMap;function m6(e,t){let n=pk.get(e);if(!n)throw new Error("Unknown slider state");return`${n.id}-${t}`}function pve(e){return e.pointerType===""&&e.isTrusted?!0:LF()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function cp(e,t,n=!0){var c,u;let{metaKey:r,ctrlKey:i,altKey:s,shiftKey:o}=t;b1e()&&((u=(c=window.event)==null?void 0:c.type)!=null&&u.startsWith("key"))&&e.target==="_blank"&&(S1()?r=!0:i=!0);let a=v1e()&&S1()&&!NF()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:i,altKey:s,shiftKey:o}):new MouseEvent("click",{metaKey:r,ctrlKey:i,altKey:s,shiftKey:o,detail:1,bubbles:!0,cancelable:!0});cp.isOpening=n,sp(e),e.dispatchEvent(a),cp.isOpening=!1}cp.isOpening=!1;let Ac=null;const g6=new Set;let Mh=new Map,bc=!1,v6=!1;const mve={Tab:!0,Escape:!0};function $v(e,t){for(let n of g6)n(e,t)}function gve(e){return!(e.metaKey||!S1()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function P1(e){bc=!0,!cp.isOpening&&gve(e)&&(Ac="keyboard",$v("keyboard",e))}function Gu(e){Ac="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(bc=!0,$v("pointer",e))}function $O(e){!cp.isOpening&&pve(e)&&(bc=!0,Ac="virtual")}function DO(e){let t=wd(Er(e)),n=Es(Er(e));Er(e)===t||Er(e)===n||J1e||!e.isTrusted||(!bc&&!v6&&(Ac="virtual",$v("virtual",e)),bc=!1,v6=!1)}function NO(){bc=!1,v6=!0}function y6(e){if(typeof window>"u"||typeof document>"u")return;const t=wd(e),n=Es(e);if(Mh.get(t))return;let r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){bc=!0,r.apply(this,arguments)},n.addEventListener("keydown",P1,!0),n.addEventListener("keyup",P1,!0),n.addEventListener("click",$O,!0),t.addEventListener("focus",DO,!0),t.addEventListener("blur",NO,!1),typeof PointerEvent<"u"&&(n.addEventListener("pointerdown",Gu,!0),n.addEventListener("pointermove",Gu,!0),n.addEventListener("pointerup",Gu,!0)),t.addEventListener("beforeunload",()=>{LO(e)},{once:!0}),Mh.set(t,{focus:r})}const LO=(e,t)=>{const n=wd(e),r=Es(e);t&&r.removeEventListener("DOMContentLoaded",t),Mh.has(n)&&(n.HTMLElement.prototype.focus=Mh.get(n).focus,r.removeEventListener("keydown",P1,!0),r.removeEventListener("keyup",P1,!0),r.removeEventListener("click",$O,!0),n.removeEventListener("focus",DO,!0),n.removeEventListener("blur",NO,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",Gu,!0),r.removeEventListener("pointermove",Gu,!0),r.removeEventListener("pointerup",Gu,!0)),Mh.delete(n))};function vve(e){const t=Es(e);let n;return t.readyState!=="loading"?y6(e):(n=()=>{y6(e)},t.addEventListener("DOMContentLoaded",n)),()=>LO(e,n)}typeof document<"u"&&vve();function b6(){return Ac!=="pointer"}function yve(){return Ac}function bve(e){Ac=e,$v(e,null)}const xve=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function wve(e,t,n){let r=n?Er(n):void 0,i=Es(r),s=wd(r);const o=typeof s<"u"?s.HTMLInputElement:HTMLInputElement,a=typeof s<"u"?s.HTMLTextAreaElement:HTMLTextAreaElement,c=typeof s<"u"?s.HTMLElement:HTMLElement,u=typeof s<"u"?s.KeyboardEvent:KeyboardEvent;let h=tl(i);return e=e||h instanceof o&&!xve.has(h.type)||h instanceof a||h instanceof c&&h.isContentEditable,!(e&&t==="keyboard"&&n instanceof u&&!mve[n.key])}function kve(e,t,n){y6(),f.useEffect(()=>{if((n==null?void 0:n.enabled)===!1)return;let r=(i,s)=>{wve(!!(n!=null&&n.isTextInput),i,s)&&e(b6())};return g6.add(r),()=>{g6.delete(r)}},t)}function jO(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:s="label"}=e;t=l6(t);let o=l6(),a={};n&&(r=r?`${o} ${r}`:o,a={id:o,htmlFor:s==="label"?t:void 0});let c=mg({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:a,fieldProps:c}}function Cve(e,t,n){let{labelProps:r,fieldProps:i}=jO(e),s=e.orientation==="vertical";pk.set(t,{id:r.id??i.id,"aria-describedby":e["aria-describedby"],"aria-details":e["aria-details"]});let{direction:o}=Bd(),{addGlobalListener:a,removeGlobalListener:c}=$p();const u=f.useRef(null),h=o==="rtl",p=f.useRef(null),{moveProps:m}=T1({onMoveStart(){p.current=null},onMove({deltaX:C,deltaY:w}){if(!n.current)return;let{height:E,width:_}=n.current.getBoundingClientRect(),T=s?E:_;p.current==null&&u.current!=null&&(p.current=t.getThumbPercent(u.current)*T);let I=s?w:C;if((s||h)&&(I=-I),p.current+=I,u.current!=null&&n.current){const P=Wi(p.current/T,0,1);t.setThumbPercent(u.current,P)}},onMoveEnd(){u.current!=null&&(t.setThumbDragging(u.current,!1),u.current=null)}});let g=f.useRef(void 0),b=(C,w,E,_)=>{if(n.current&&!e.isDisabled&&t.values.every((T,I)=>!t.isThumbDragging(I))){let{height:T,width:I,top:P,left:M}=n.current.getBoundingClientRect(),S=s?T:I,j=((s?_:E)-(s?P:M))/S;(o==="rtl"||s)&&(j=1-j);let O=t.getPercentValue(j),H,B=t.values.findIndex(Z=>O-Z<0);if(B===0)H=B;else if(B===-1)H=t.values.length-1;else{let Z=t.values[B-1],K=t.values[B];Math.abs(Z-O)<Math.abs(K-O)?H=B-1:H=B}H>=0&&t.isThumbEditable(H)?(C.preventDefault(),u.current=H,t.setFocusedThumb(H),g.current=w,t.setThumbDragging(u.current,!0),t.setThumbValue(H,O),a(window,"mouseup",x,!1),a(window,"touchend",x,!1),a(window,"pointerup",x,!1)):u.current=null}},x=C=>{var E;(C.pointerId??((E=C.changedTouches)==null?void 0:E[0].identifier))===g.current&&(u.current!=null&&(t.setThumbDragging(u.current,!1),u.current=null),c(window,"mouseup",x,!1),c(window,"touchend",x,!1),c(window,"pointerup",x,!1))};return"htmlFor"in r&&r.htmlFor&&(delete r.htmlFor,r.onClick=()=>{var C;(C=document.getElementById(m6(t,0)))==null||C.focus(),bve("keyboard")}),{labelProps:r,groupProps:{role:"group",...i},trackProps:$o({onMouseDown(C){C.button!==0||C.altKey||C.ctrlKey||C.metaKey||b(C,void 0,C.clientX,C.clientY)},onPointerDown(C){C.pointerType==="mouse"&&(C.button!==0||C.altKey||C.ctrlKey||C.metaKey)||b(C,C.pointerId,C.clientX,C.clientY)},onTouchStart(C){b(C,C.changedTouches[0].identifier,C.changedTouches[0].clientX,C.changedTouches[0].clientY)},style:{position:"relative",touchAction:"none"}},m),outputProps:{htmlFor:t.values.map((C,w)=>m6(t,w)).join(" "),"aria-live":"off"}}}function Eve(e){if(!e.isConnected)return;const t=Es(e);if(yve()==="virtual"){let n=tl(t);MO(()=>{const r=tl(t);(r===n||r===t.body)&&e.isConnected&&sp(e)})}else sp(e)}function Sve(e,t){Mv(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}let _ve=xe.createContext(null);function Ave(e){let t=f.useContext(_ve)||{};Sve(t,e);let{ref:n,...r}=t;return r}function Tve(e,t){let{focusProps:n}=A1(e),{keyboardProps:r}=hk(e),i=$o(n,r),s=Ave(t),o=e.isDisabled?{}:s,a=f.useRef(e.autoFocus);f.useEffect(()=>{a.current&&t.current&&Eve(t.current),a.current=!1},[t]);let c=e.excludeFromTabOrder?-1:0;return e.isDisabled&&(c=void 0),{focusableProps:$o({...i,tabIndex:c},o)}}function Pve(e,t){let{index:n=0,isRequired:r,validationState:i,isInvalid:s,trackRef:o,inputRef:a,orientation:c=t.orientation,name:u,form:h}=e,p=e.isDisabled||t.isDisabled,m=c==="vertical",{direction:g}=Bd(),{addGlobalListener:b,removeGlobalListener:x}=$p(),C=pk.get(t);const{labelProps:w,fieldProps:E}=jO({...e,id:m6(t,n),"aria-labelledby":`${C.id} ${e["aria-labelledby"]??""}`.trim()}),_=t.values[n],T=f.useCallback(()=>{a.current&&sp(a.current)},[a]),I=t.focusedThumb===n;f.useEffect(()=>{I&&T()},[I,T]);let P=g==="rtl",M=f.useRef(null),{keyboardProps:S}=hk({onKeyDown(Z){let{getThumbMaxValue:K,getThumbMinValue:q,decrementThumb:te,incrementThumb:F,setThumbValue:V,setThumbDragging:W,pageSize:N}=t;if(!/^(PageUp|PageDown|Home|End)$/.test(Z.key)){Z.continuePropagation();return}switch(Z.preventDefault(),W(n,!0),Z.key){case"PageUp":F(n,N);break;case"PageDown":te(n,N);break;case"Home":V(n,q(n));break;case"End":V(n,K(n));break}W(n,!1)}}),{moveProps:R}=T1({onMoveStart(){M.current=null,t.setThumbDragging(n,!0)},onMove({deltaX:Z,deltaY:K,pointerType:q,shiftKey:te}){const{getThumbPercent:F,setThumbPercent:V,decrementThumb:W,incrementThumb:N,step:z,pageSize:Q}=t;if(!o.current)return;let{width:J,height:re}=o.current.getBoundingClientRect(),G=m?re:J;if(M.current==null&&(M.current=F(n)*G),q==="keyboard")Z>0&&P||Z<0&&!P||K>0?W(n,te?Q:z):N(n,te?Q:z);else{let X=m?K:Z;(m||P)&&(X=-X),M.current+=X,V(n,Wi(M.current/G,0,1))}},onMoveEnd(){t.setThumbDragging(n,!1)}});t.setThumbEditable(n,!p);const{focusableProps:$}=Tve($o(e,{onFocus:()=>t.setFocusedThumb(n),onBlur:()=>t.setFocusedThumb(void 0)}),a);let L=f.useRef(void 0),j=Z=>{T(),L.current=Z,t.setThumbDragging(n,!0),b(window,"mouseup",O,!1),b(window,"touchend",O,!1),b(window,"pointerup",O,!1)},O=Z=>{var q;(Z.pointerId??((q=Z.changedTouches)==null?void 0:q[0].identifier))===L.current&&(T(),t.setThumbDragging(n,!1),x(window,"mouseup",O,!1),x(window,"touchend",O,!1),x(window,"pointerup",O,!1))},H=t.getThumbPercent(n);(m||g==="rtl")&&(H=1-H);let B=p?{}:$o(S,R,{onMouseDown:Z=>{Z.button!==0||Z.altKey||Z.ctrlKey||Z.metaKey||j()},onPointerDown:Z=>{Z.button!==0||Z.altKey||Z.ctrlKey||Z.metaKey||j(Z.pointerId)},onTouchStart:Z=>{j(Z.changedTouches[0].identifier)}});return TO(a,t.defaultValues[n],Z=>{t.setThumbValue(n,Z)}),{inputProps:$o($,E,{type:"range",tabIndex:p?void 0:0,min:t.getThumbMinValue(n),max:t.getThumbMaxValue(n),step:t.step,value:_,name:u,form:h,disabled:p,"aria-orientation":c,"aria-valuetext":t.getThumbValueLabel(n),"aria-required":r||void 0,"aria-invalid":s||i==="invalid"||void 0,"aria-errormessage":e["aria-errormessage"],"aria-describedby":[C["aria-describedby"],e["aria-describedby"]].filter(Boolean).join(" "),"aria-details":[C["aria-details"],e["aria-details"]].filter(Boolean).join(" "),onChange:Z=>{t.setThumbValue(n,parseFloat(Er(Z).value))}}),thumbProps:{...B,style:{position:"absolute",[m?"top":"left"]:`${H*100}%`,transform:"translate(-50%, -50%)",touchAction:"none"}},labelProps:w,isDragging:t.isThumbDragging(n),isDisabled:p,isFocused:I}}function Ive(e,t){let{trackRef:n,inputRef:r,orientation:i,channel:s,"aria-label":o,name:a,form:c}=e,{locale:u,direction:h}=Bd();!e.label&&!o&&!e["aria-labelledby"]&&(o=t.value.getChannelName(s,u));let{groupProps:p,trackProps:m,labelProps:g,outputProps:b}=Cve({...e,"aria-label":o},t,n),{inputProps:x,thumbProps:C}=Pve({index:0,orientation:i,isDisabled:e.isDisabled,name:a,form:c,trackRef:n,inputRef:r},t),w=t.getDisplayColor(),E=()=>{let I;switch(i==="vertical"?I="top":h==="ltr"?I="right":I="left",s){case"hue":{let P=[0,60,120,180,240,300,360].map(M=>w.withChannelValue("hue",M).toString("css")).join(", ");return`linear-gradient(to ${I}, ${P})`}case"lightness":{let P=t.getThumbMinValue(0),M=t.getThumbMaxValue(0),S=w.withChannelValue(s,P).toString("css"),R=w.withChannelValue(s,(M-P)/2).toString("css"),$=w.withChannelValue(s,M).toString("css");return`linear-gradient(to ${I}, ${S}, ${R}, ${$})`}case"saturation":case"brightness":case"red":case"green":case"blue":case"alpha":{let P=w.withChannelValue(s,t.getThumbMinValue(0)).toString("css"),M=w.withChannelValue(s,t.getThumbMaxValue(0)).toString("css");return`linear-gradient(to ${I}, ${P}, ${M})`}default:throw new Error("Unknown color channel: "+s)}},_={forcedColorAdjust:"none"};s==="hue"?x["aria-valuetext"]+=`, ${w.getHueName(u)}`:s!=="alpha"&&(x["aria-valuetext"]+=`, ${w.getColorName(u)}`);let{visuallyHiddenProps:T}=RO({style:{opacity:"0.0001",width:"100%",height:"100%",pointerEvents:"none"}});return{trackProps:{...$o(p,m),style:{...m.style,..._,background:E()}},inputProps:{...x,style:{...x.style,...T.style}},thumbProps:{...C,style:{...C.style,..._}},labelProps:g,outputProps:b}}const Mve=typeof document<"u"?xe.useInsertionEffect??xe.useLayoutEffect:()=>{};function mk(e,t,n){let[r,i]=f.useState(e||t),s=f.useRef(r),o=f.useRef(e!==void 0),a=e!==void 0;f.useEffect(()=>{o.current,o.current=a},[a]);let c=a?e:r;Mve(()=>{s.current=c});let[,u]=f.useReducer(()=>({}),{}),h=f.useCallback((p,...m)=>{let g=typeof p=="function"?p(s.current):p;Object.is(s.current,g)||(s.current=g,i(g),u(),n==null||n(g,...m))},[n]);return[c,h]}function FO(e={}){let{autoFocus:t=!1,isTextInput:n,within:r}=e,i=f.useRef({isFocused:!1,isFocusVisible:t||b6()}),[s,o]=f.useState(!1),[a,c]=f.useState(()=>i.current.isFocused&&i.current.isFocusVisible),u=f.useCallback(()=>c(i.current.isFocused&&i.current.isFocusVisible),[]),h=f.useCallback(g=>{i.current.isFocused=g,i.current.isFocusVisible=b6(),o(g),u()},[u]);kve(g=>{i.current.isFocusVisible=g,u()},[n,s],{enabled:s,isTextInput:n});let{focusProps:p}=A1({isDisabled:r,onFocusChange:h}),{focusWithinProps:m}=fk({isDisabled:!r,onFocusWithinChange:h});return{isFocused:s,isFocusVisible:a,focusProps:r?m:p}}const Rve=Do("#ffffff");function $ve(e){let{value:t,defaultValue:n,colorSpace:r,xChannel:i,yChannel:s,onChange:o,onChangeEnd:a}=e;!t&&!n&&(n=Rve),t&&(t=Wu(t)),n&&(n=Wu(n));let[c,u]=mk(t,n,o),[h]=f.useState(c),p=f.useMemo(()=>r&&c?c.toFormat(r):c,[c,r]),m=f.useRef(p),g=Z=>{m.current=Z,u(Z)},b=f.useMemo(()=>p.getColorSpaceAxes({xChannel:i,yChannel:s}),[p,i,s]),x=p.getChannelRange(b.xChannel),C=p.getChannelRange(b.yChannel),{minValue:w,maxValue:E,step:_,pageSize:T}=x,{minValue:I,maxValue:P,step:M,pageSize:S}=C,[R,$]=f.useState(!1),L=f.useRef(!1),j=p.getChannelValue(b.xChannel),O=p.getChannelValue(b.yChannel),H=Z=>{if(Z===j)return;let K=p.withChannelValue(b.xChannel,Z);g(K)},B=Z=>{if(Z===O)return;let K=p.withChannelValue(b.yChannel,Z);g(K)};return{channels:b,xChannelStep:_,yChannelStep:M,xChannelPageStep:T,yChannelPageStep:S,value:p,defaultValue:t!==void 0?h:n,setValue(Z){g(Wu(Z))},xValue:j,setXValue:H,yValue:O,setYValue:B,setColorFromPoint(Z,K){let q=w+Wi(Z,0,1)*(E-w),te=I+(1-Wi(K,0,1))*(P-I),F;q!==j&&(q=cs(q,w,E,_),F=p.withChannelValue(b.xChannel,q)),te!==O&&(te=cs(te,I,P,M),F=(F||p).withChannelValue(b.yChannel,te)),F&&g(F)},getThumbPosition(){let Z=(j-w)/(E-w),K=1-(O-I)/(P-I);return{x:Z,y:K}},incrementX(Z=1){H(j+Z>E?E:cs(j+Z,w,E,_))},incrementY(Z=1){B(O+Z>P?P:cs(O+Z,I,P,M))},decrementX(Z=1){H(cs(j-Z,w,E,_))},decrementY(Z=1){B(cs(O-Z,I,P,M))},setDragging(Z){let K=L.current;L.current=Z,a&&!Z&&K&&a(m.current),$(Z)},isDragging:R,getDisplayColor(){return p.withChannelValue("alpha",1)}}}const Dve=0,Nve=100,Lve=1;function jve(e){const{isDisabled:t=!1,minValue:n=Dve,maxValue:r=Nve,numberFormatter:i,step:s=Lve,orientation:o="horizontal"}=e;let a=f.useMemo(()=>{let N=(r-n)/10;return N=cs(N,0,N+s,s),Math.max(N,s)},[s,r,n]),c=f.useCallback(N=>N==null?void 0:N.map((z,Q)=>{let J=Q===0?n:N[Q-1],re=Q===N.length-1?r:N[Q+1];return cs(z,J,re,s)}),[n,r,s]),u=f.useMemo(()=>c(ST(e.value)),[e.value,c]),h=f.useMemo(()=>c(ST(e.defaultValue)??[n]),[e.defaultValue,n,c]),p=_T(e.value,e.defaultValue,e.onChange),m=_T(e.value,e.defaultValue,e.onChangeEnd);const[g,b]=mk(u,h,p);let[x]=f.useState(g);const[C,w]=f.useState(new Array(g.length).fill(!1)),E=f.useRef(new Array(g.length).fill(!0)),[_,T]=f.useState(void 0),I=f.useRef(g),P=f.useRef(C);let M=N=>{I.current=N,b(N)},S=N=>{P.current=N,w(N)};function R(N){return(N-n)/(r-n)}function $(N){return N===0?n:g[N-1]}function L(N){return N===g.length-1?r:g[N+1]}function j(N){return E.current[N]}function O(N,z){E.current[N]=z}function H(N,z){if(t||!j(N))return;const Q=$(N),J=L(N);z=cs(z,Q,J,s);let re=ET(I.current,N,z);M(re)}function B(N,z){if(t||!j(N))return;z&&(I.current=g);const Q=P.current[N];P.current=ET(P.current,N,z),S(P.current),m&&Q&&!P.current.some(Boolean)&&m(I.current)}let Z=f.useRef(null);function K(N=g){switch(typeof N=="number"&&(N=[N]),N.length){case 0:return"";case 1:return i.format(N[0]);case 2:return i.formatRange(N[0],N[1]);default:{let z=N.map(J=>i.format(J)),Q=Z.current;return(!Q||Q.resolvedOptions().locale!==i.resolvedOptions().locale)&&(Q=Z.current=new Intl.ListFormat(i.resolvedOptions().locale,{type:"unit"})),Q.format(z)}}}function q(N,z){H(N,F(z))}function te(N){return Math.round((N-n)/s)*s+n}function F(N){const z=N*(r-n)+n;return Wi(te(z),n,r)}function V(N,z=1){let Q=Math.max(z,s);H(N,cs(g[N]+Q,n,r,s))}function W(N,z=1){let Q=Math.max(z,s);H(N,cs(g[N]-Q,n,r,s))}return{values:g,defaultValues:e.defaultValue!==void 0?h:x,getThumbValue:N=>g[N],setThumbValue:H,setThumbPercent:q,isThumbDragging:N=>C[N],setThumbDragging:B,focusedThumb:_,setFocusedThumb:T,getThumbPercent:N=>R(g[N]),getValuePercent:R,getThumbValueLabel:N=>K(g[N]),getFormattedValue:K,getThumbMinValue:$,getThumbMaxValue:L,getPercentValue:F,isThumbEditable:j,setThumbEditable:O,incrementThumb:V,decrementThumb:W,step:s,pageSize:a,orientation:o,isDisabled:t}}function ET(e,t,n){return e[t]===n?e:[...e.slice(0,t),n,...e.slice(t+1)]}function ST(e){if(e!=null)return Array.isArray(e)?e:[e]}function _T(e,t,n){return r=>{typeof e=="number"||typeof t=="number"?n==null||n(r[0]):n==null||n(r)}}function Fve(e){let{channel:t,colorSpace:n,value:r,defaultValue:i,onChange:s,locale:o,...a}=e;if(r==null&&i==null)throw new Error("useColorSliderState requires a value or defaultValue");r&&(r=Wu(r)),i&&(i=Wu(i));let[c,u]=mk(r,i,s),h=f.useMemo(()=>n&&c?c.toFormat(n):c,[c,n]),[p]=f.useState(c),m=i??p,g=f.useMemo(()=>n&&m?m.toFormat(n):m,[m,n]),b=f.useMemo(()=>new Intl.NumberFormat,[]),x=jve({...h.getChannelRange(t),...a,numberFormatter:b,value:h.getChannelValue(t),defaultValue:g.getChannelValue(t),onChange(E){u(h.withChannelValue(t,E))},onChangeEnd(E){e.onChangeEnd&&e.onChangeEnd(h.withChannelValue(t,E))}}),{step:C,pageSize:w}=h.getChannelRange(t);return{...x,value:h,setValue(E){u(Wu(E))},getDisplayColor(){switch(t){case"hue":return Do(`hsl(${h.getChannelValue("hue")}, 100%, 50%)`);case"lightness":case"brightness":case"saturation":case"red":case"green":case"blue":return h.withChannelValue("alpha",1);case"alpha":return h;default:throw new Error("Unknown color channel: "+t)}},getThumbValueLabel(){return h.formatChannelValue(t,o)},getFormattedValue(){return h.formatChannelValue(t,o)},step:C,pageSize:w,isDragging:x.isThumbDragging(0)}}const Ove=()=>{const e=ze(S$),t=typeof window<"u"&&"EyeDropper"in window;return{pickColor:f.useCallback(async()=>{if(!t)return null;const r=new EyeDropper;try{return e(!0),await new Promise(s=>requestAnimationFrame(s)),(await r.open()).sRGBHex}catch{return null}finally{e(!1)}},[t,e]),isSupported:t}},AT=28,I1=20,vg=4,Om=28,Vve=e=>{if(typeof document>"u")return null;const t=document.createElement("span");if(t.style.color="",t.style.color=e,!t.style.color)return null;t.style.display="none",document.body.appendChild(t);const n=window.getComputedStyle(t).color;return document.body.removeChild(t),n||null},OO=e=>{const t=cc(e);try{const n=Rt(t);return Do(n.hex())}catch{try{const n=Vve(t);return n?Do(n):null}catch{return null}}},TT=e=>OO(e)??Do("#000000"),Hve=e=>{var m;const t=f.useRef(null),n=f.useRef(null),r=f.useRef(null),i=$ve(e),{isDisabled:s}=e,{colorAreaProps:o,xInputProps:a,yInputProps:c,thumbProps:u}=hve({...e,inputXRef:t,inputYRef:n,containerRef:r},i),{focusProps:h,isFocusVisible:p}=FO();return y.jsx("div",{ref:r,...o,style:{...o.style,width:"100%",aspectRatio:"1",borderRadius:vg,background:s?"rgb(142, 142, 142)":(m=o.style)==null?void 0:m.background,opacity:s?.3:void 0},className:"relative",children:y.jsxs("div",{...u,style:{...u.style,background:s?"rgb(142, 142, 142)":i.getDisplayColor().toString("css"),border:`2px solid ${s?"rgb(142, 142, 142)":"white"}`,borderRadius:"50%",boxShadow:"0 0 0 1px black, inset 0 0 0 1px black",boxSizing:"border-box",height:p?AT+vg:I1,width:p?AT+vg:I1},children:[y.jsx("input",{ref:t,...a,...h}),y.jsx("input",{ref:n,...c,...h})]})})},Bve=e=>{var b;const{isDisabled:t}=e,{locale:n}=Bd(),r=Fve({...e,locale:n}),i=f.useRef(null),s=f.useRef(null),o=e.label||r.value.getChannelName(e.channel,n),{trackProps:a,thumbProps:c,inputProps:u,labelProps:h,outputProps:p}=Ive({...e,label:o,trackRef:i,inputRef:s},r),{focusProps:m,isFocusVisible:g}=FO();return y.jsxs("div",{className:"flex w-full flex-col",children:[y.jsxs("div",{className:"flex",children:[y.jsx("label",{...h,className:"text-xs text-content",children:o}),y.jsx("output",{...p,className:"flex-1 text-right text-xs text-content",children:r.value.formatChannelValue(e.channel,n)})]}),y.jsx("div",{...a,ref:i,style:{...a.style,height:Om,borderRadius:vg,background:t?"rgb(142, 142, 142)":(b=a.style)==null?void 0:b.background},className:"relative mt-2 w-full",children:y.jsx("div",{...c,style:{...c.style,top:Om/2,background:t?"rgb(142, 142, 142)":r.getDisplayColor().toString("css"),border:`2px solid ${t?"rgb(142, 142, 142)":"white"}`,boxShadow:"0 0 0 1px black, inset 0 0 0 1px black",width:g?Om+4:I1,height:g?Om+4:I1,borderRadius:"50%",boxSizing:"border-box"},children:y.jsx("input",{ref:s,...u,...m})})})]})},gx=e=>{const t=e.trim().toLowerCase();return t.startsWith("oklch")?"oklch":t.startsWith("hsl")?"hsl":t.startsWith("rgb")?"rgb":"hex"},PT=(e,t)=>{if(t==="rgb")return e.toString("rgb");if(t==="hsl")return e.toString("hsl");if(t==="oklch")try{const[n,r,i]=Rt(e.toString("css")).oklch(),s=Number.isNaN(i)?0:i;return`oklch(${(n*100).toFixed(2)}% ${r.toFixed(4)} ${s.toFixed(2)})`}catch{return e.toString("hex")}return e.toString("hex")},Dv=({value:e,onChange:t,onCommit:n,dataCy:r})=>{const i=e||"#000000",[s,o]=f.useState(i),[a,c]=f.useState(gx(i)),u=f.useRef(null),{pickColor:h,isSupported:p}=Ove();f.useEffect(()=>{e&&(o(e),c(gx(e)))},[e]);const m=f.useMemo(()=>TT(s).toFormat("hsb"),[s]),g=E=>{const _=a,T=_==="oklch"?"hex":_;_==="oklch"&&c("hex");const I=PT(E,T);o(I),t==null||t(I)},b=E=>{o(E);const _=gx(E);_!==a&&c(_),OO(E)&&(t==null||t(E.trim()))},x=a==="oklch"?["oklch","hex","rgb","hsl"]:["hex","rgb","hsl"],C=[a].concat(x.filter(E=>E!==a)),w=E=>{const _=TT(s),T=PT(_,E);c(E),o(T),t==null||t(T)};return y.jsx("div",{className:"flex flex-col bg-main",onKeyDown:E=>{E.key==="Enter"&&n&&(E.preventDefault(),n(s))},children:y.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[y.jsx(Hve,{value:m,onChange:g,xChannel:"saturation",yChannel:"brightness"}),y.jsx(Bve,{value:m,onChange:g,channel:"hue"}),y.jsxs("div",{className:`grid gap-3 ${p?"grid-cols-[80px_1fr_auto]":"grid-cols-[80px_1fr]"}`,children:[y.jsxs("div",{className:"relative",children:[y.jsx("select",{value:a,onChange:E=>w(E.target.value),className:"h-10 w-full appearance-none rounded border border-divider bg-main-input px-3 pr-8 text-[11px] font-medium text-content outline-none","data-cy":r?`${r}-format`:void 0,children:C.map(E=>y.jsx("option",{value:E,children:E.toUpperCase()},E))}),y.jsx(Ba,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-content-subtle",weight:"bold"})]}),y.jsx("div",{className:"grid h-10 grid-cols-1 overflow-hidden rounded border border-divider bg-main-input",children:y.jsx("input",{ref:u,value:s,onChange:E=>b(E.target.value),className:"bg-transparent px-4 text-[11px] font-medium text-content outline-none","data-cy":r?`${r}-value`:void 0})}),p&&y.jsx("button",{type:"button",title:"Pick color from screen",className:"flex h-10 w-10 items-center justify-center rounded border border-divider text-content-subtle transition-colors hover:bg-main-hover hover:text-content",onClick:async()=>{const E=await h();E&&(o(E),c("hex"),t==null||t(E),n==null||n(E))},"data-cy":r?`${r}-eyedropper`:void 0,children:y.jsx(lG,{className:"h-4 w-4"})})]})]})})};var vx,IT;function zve(){if(IT)return vx;IT=1;var e="Expected a function",t=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt,c=typeof W0=="object"&&W0&&W0.Object===Object&&W0,u=typeof self=="object"&&self&&self.Object===Object&&self,h=c||u||Function("return this")(),p=Object.prototype,m=p.toString,g=Math.max,b=Math.min,x=function(){return h.Date.now()};function C(P,M,S){var R,$,L,j,O,H,B=0,Z=!1,K=!1,q=!0;if(typeof P!="function")throw new TypeError(e);M=I(M)||0,E(S)&&(Z=!!S.leading,K="maxWait"in S,L=K?g(I(S.maxWait)||0,M):L,q="trailing"in S?!!S.trailing:q);function te(G){var X=R,de=$;return R=$=void 0,B=G,j=P.apply(de,X),j}function F(G){return B=G,O=setTimeout(N,M),Z?te(G):j}function V(G){var X=G-H,de=G-B,ve=M-X;return K?b(ve,L-de):ve}function W(G){var X=G-H,de=G-B;return H===void 0||X>=M||X<0||K&&de>=L}function N(){var G=x();if(W(G))return z(G);O=setTimeout(N,V(G))}function z(G){return O=void 0,q&&R?te(G):(R=$=void 0,j)}function Q(){O!==void 0&&clearTimeout(O),B=0,R=H=$=O=void 0}function J(){return O===void 0?j:z(x())}function re(){var G=x(),X=W(G);if(R=arguments,$=this,H=G,X){if(O===void 0)return F(H);if(K)return O=setTimeout(N,M),te(H)}return O===void 0&&(O=setTimeout(N,M)),j}return re.cancel=Q,re.flush=J,re}function w(P,M,S){var R=!0,$=!0;if(typeof P!="function")throw new TypeError(e);return E(S)&&(R="leading"in S?!!S.leading:R,$="trailing"in S?!!S.trailing:$),C(P,M,{leading:R,maxWait:M,trailing:$})}function E(P){var M=typeof P;return!!P&&(M=="object"||M=="function")}function _(P){return!!P&&typeof P=="object"}function T(P){return typeof P=="symbol"||_(P)&&m.call(P)==n}function I(P){if(typeof P=="number")return P;if(T(P))return t;if(E(P)){var M=typeof P.valueOf=="function"?P.valueOf():P;P=E(M)?M+"":M}if(typeof P!="string")return P===0?P:+P;P=P.replace(r,"");var S=s.test(P);return S||o.test(P)?a(P.slice(2),S?2:8):i.test(P)?t:+P}return vx=w,vx}var Uve=zve();const Zve=xc(Uve),gk=({value:e,options:t,onChange:n,onApply:r,onPreview:i,onBlur:s,disabled:o=!1,renderOption:a,emptyMessage:c="No options available",contentWidth:u="w-56",dataCy:h})=>{const[p,m]=f.useState(!1),[g,b]=f.useState(-1),[x,C]=f.useState(e),w=f.useRef(!1),E=f.useRef([]),_=t.find(R=>R.value===e),T=(_==null?void 0:_.label)??e??"Select";f.useEffect(()=>{var R;p&&g>=0&&((R=E.current[g])==null||R.scrollIntoView({block:"nearest"}))},[g,p]);const I=R=>{n(R),i&&i(R)},P=R=>{if(R){C(e),w.current=!1;const $=t.findIndex(L=>L.value===e);b($>=0?$:0)}else w.current||I(x);m(R)},M=R=>{w.current=!0,n(R),r&&r(R,x),m(!1)},S=R=>{if(t.length!==0)switch(R.key){case"ArrowDown":{R.preventDefault();const $=Math.min(g+1,t.length-1);b($),I(t[$].value);break}case"ArrowUp":{R.preventDefault();const $=Math.max(g-1,0);b($),I(t[$].value);break}case"Enter":{R.preventDefault(),g>=0&&g<t.length&&M(t[g].value);break}}};return y.jsxs(Fo,{open:p,onOpenChange:P,children:[y.jsx(ul,{asChild:!0,children:y.jsxs("button",{type:"button",disabled:o,className:`flex w-28 items-center justify-between rounded px-3 py-1 text-xs focus:outline-none ${o?"cursor-not-allowed opacity-50":"bg-main-input text-content hover:bg-main-hover"}`,onBlur:s,title:T,"data-cy":h,children:[y.jsx("span",{className:"truncate",children:T}),y.jsx(Ba,{className:"h-3 w-3 flex-shrink-0",weight:"bold"})]})}),y.jsx(Oo,{children:y.jsx(Vo,{className:`z-[60] border-divider bg-main ${u} rounded-lg border-[1px] p-3 shadow-lg`,sideOffset:5,align:"end",onKeyDown:S,children:t.length>0?y.jsx("div",{className:"max-h-96 space-y-1 overflow-y-auto",role:"listbox","aria-activedescendant":g>=0?`preview-select-option-${g}`:void 0,children:t.map((R,$)=>{const L=R.value===x,j=$===g;let O="";return j?O="bg-main-hover":L&&(O="bg-main-light"),y.jsx("div",{id:`preview-select-option-${$}`,ref:H=>{E.current[$]=H},role:"option","aria-selected":L,onClick:()=>M(R.value),onMouseEnter:()=>{b($),I(R.value)},className:`w-full cursor-pointer rounded px-3 py-2 text-left text-xs text-content transition-colors ${O}`,title:R.value,children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"min-w-0 flex-1",children:a?a(R):y.jsx("span",{children:R.label})}),L?y.jsx(za,{size:14,className:"flex-shrink-0",weight:"bold"}):null]})},R.value)})}):y.jsx("div",{className:"text-center text-xs text-content-subtle",children:c})})})]})},MT=[0,45,90,135,180,225,270,315],Wve="#808080",Gve="#555555",qve="rgba(255, 255, 255, 0.4)",Kve=50,Yve=10,Xve=[{value:"linear",label:"Linear"},{value:"radial",label:"Radial"},{value:"diamond",label:"Diamond"}],Qve=({value:e,onChange:t,onCommit:n,dataCy:r})=>{const[i,s]=f.useState(()=>Iw(e)??DD),[o,a]=f.useState(null),[c,u]=f.useState(null),h=f.useRef(null),p=f.useRef(!1),m=f.useRef(t);f.useEffect(()=>{m.current=t},[t]),f.useEffect(()=>{if(p.current)return;const S=Iw(e);S&&s(S)},[e]);const g=f.useMemo(()=>Zve(S=>{m.current(uh(S))},16),[]),b=f.useCallback((S,R=!1)=>{s(S),R?t(uh(S)):g(S)},[t,g]),x=S=>{b({...i,type:S},!0)},C=S=>{b({...i,angle:(S%360+360)%360},!0)},w=()=>{const S=i.angle;let R=MT.find($=>$>S);R===void 0&&(R=MT[0]),C(R)},E=(S,R)=>{const $=[...i.stops];$[S]={...$[S],color:R},b({...i,stops:$},!0)},_=(S,R,$=!1)=>{const L=Math.max(0,Math.min(100,R)),j=[...i.stops];j[S]={...j[S],position:L},b({...i,stops:j},$)},T=S=>{var Z;const R=(Z=h.current)==null?void 0:Z.getBoundingClientRect();if(!R)return;const $=x6(S.clientX,R),L=[...i.stops].sort((K,q)=>K.position-q.position),H={color:Rt.scale(L.map(K=>K.color)).domain(L.map(K=>K.position/100))($/100).hex(),position:$},B=[...i.stops,H];b({...i,stops:B},!0)},I=S=>{if(i.stops.length<=2)return;const R=i.stops.filter(($,L)=>L!==S);b({...i,stops:R},!0),u(null),a(null)},P=()=>{const S=[...i.stops].sort((B,Z)=>B.position-Z.position),R=Rt.scale(S.map(B=>B.color)).domain(S.map(B=>B.position/100));let $=-1,L=50,j=Wve;for(let B=0;B<S.length-1;B++){const Z=S[B+1].position-S[B].position;Z>$&&($=Z,L=S[B].position+Z/2,j=R(L/100).hex())}const O={color:j,position:L},H=[...i.stops,O];b({...i,stops:H},!0),a(i.stops.length)},M=()=>{const S=i.stops.map(R=>({...R,position:100-R.position}));b({...i,stops:S},!0)};return y.jsxs("div",{className:"flex w-full select-none flex-col bg-main text-content",onKeyDown:S=>{S.key==="Enter"&&n&&(S.preventDefault(),n(uh(i)))},children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[y.jsx(gk,{value:i.type,options:Xve,onChange:S=>x(S),contentWidth:"w-32",dataCy:r?`${r}-type`:void 0}),y.jsxs("div",{className:"flex items-center gap-3 text-content-subtle",children:[(i.type==="linear"||i.type==="diamond")&&y.jsx("button",{type:"button",onClick:w,className:"group flex h-6 w-7 items-center justify-center rounded bg-main-input transition-colors hover:bg-main-hover",title:"Cycle common angles",children:y.jsx(s8,{className:"h-3.5 w-3.5 text-content-subtle transition-transform duration-200 group-hover:text-content",style:{transform:`rotate(${i.angle}deg)`},weight:"bold"})}),y.jsx(sG,{className:"h-3.5 w-3.5 cursor-pointer hover:text-content",onClick:M,weight:"bold"})]})]}),y.jsx("div",{className:"px-4 py-3",children:y.jsxs("div",{className:"relative h-10 w-full",children:[y.jsx("div",{ref:h,className:"absolute inset-0 top-2 h-6 cursor-crosshair rounded-sm border border-divider",style:{background:uh({...i,type:"linear",angle:90})},onClick:T,"data-cy":r?`${r}-bar`:void 0}),i.stops.map((S,R)=>y.jsx(Jve,{stop:S,active:o===R,onDrag:$=>{_(R,$),a(R)},onDragStart:()=>{p.current=!0,a(R)},onDragEnd:$=>{_(R,$,!0),p.current=!1},onTap:()=>a(R),barElementRef:h},R))]})}),y.jsxs("div",{className:"flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[y.jsx("span",{className:"text-[11px] font-medium text-content-subtle",children:"Stops"}),y.jsx(fG,{className:"h-3.5 w-3.5 cursor-pointer text-content-subtle hover:text-content",onClick:P,weight:"bold"})]}),y.jsx("div",{className:"flex flex-col",children:i.stops.map((S,R)=>y.jsxs("div",{className:el("flex items-center gap-2 bg-main px-4 py-2 hover:bg-main-hover",o===R&&"bg-main-hover"),children:[y.jsxs("div",{className:"flex w-12 items-center rounded bg-main-input px-1 py-1",children:[y.jsx("input",{type:"text",className:"w-full bg-transparent text-center text-[11px] outline-none",value:Math.round(S.position),onChange:$=>{const L=$.target.value.replace(/\D/g,"");_(R,parseInt(L)||0,!0)}}),y.jsx("span",{className:"pr-1 text-[10px] text-content-subtle",children:"%"})]}),y.jsxs(Fo,{open:c===R,onOpenChange:$=>{u($?R:null),$&&a(R)},children:[y.jsx(ul,{asChild:!0,children:y.jsxs("div",{className:"flex flex-1 cursor-pointer items-center gap-2 rounded bg-main-input px-2 py-1",children:[y.jsx("div",{className:"h-3.5 w-3.5 rounded-sm border border-white/10",style:{backgroundColor:S.color}}),y.jsx("span",{className:"text-[11px] uppercase",children:S.color.replace("#","")})]})}),y.jsx(Oo,{children:y.jsx(Vo,{className:"z-ui-primary outline-none",side:"right",sideOffset:10,children:y.jsx("div",{className:"rounded-lg border border-divider bg-main shadow-xl",children:y.jsx(Dv,{value:S.color,onChange:$=>E(R,$),dataCy:r?`${r}-stop-${R}-picker`:void 0})})})})]}),y.jsx(dG,{className:"h-3.5 w-3.5 cursor-pointer text-content-subtle hover:text-content",onClick:()=>I(R),weight:"bold"})]},R))})]})]})},Jve=({stop:e,active:t,onDrag:n,onDragStart:r,onDragEnd:i,onTap:s,barElementRef:o})=>y.jsx(dn.div,{onPanStart:()=>{s(),r()},onPan:(a,c)=>{var h;const u=(h=o.current)==null?void 0:h.getBoundingClientRect();u&&n(x6(c.point.x,u))},onPanEnd:(a,c)=>{var h;const u=(h=o.current)==null?void 0:h.getBoundingClientRect();u&&i(x6(c.point.x,u))},onTap:a=>{a.stopPropagation(),s()},style:{left:`${e.position}%`,zIndex:t?Kve:Yve},className:"absolute top-1 -ml-2.5 cursor-grab touch-none active:cursor-grabbing",children:y.jsxs("div",{className:el("relative flex flex-col items-center",t&&"scale-110"),children:[y.jsx("div",{className:el("h-5 w-5 rounded border shadow-md",t?"ring-2 ring-primary":"border-white/20"),style:{backgroundColor:e.color,borderColor:t?Gve:void 0}}),y.jsx("div",{className:"mt-[1px] h-0 w-0 border-l-[4px] border-r-[4px] border-t-[6px] border-l-transparent border-r-transparent",style:{borderTopColor:qve}})]})}),x6=(e,t)=>(e-t.left)/t.width*100,eye=({value:e,onChange:t,onCommit:n,dataCy:r})=>{var m,g;const i=Xh(e),[s,o]=f.useState(i?"gradient":"solid"),[a,c]=f.useState(i?((g=(m=Iw(e))==null?void 0:m.stops[0])==null?void 0:g.color)??"#000000":e),[u,h]=f.useState(i?e:uh(DD));f.useEffect(()=>{Xh(e)?(h(e),o("gradient")):(c(e),o("solid"))},[e]);const p=b=>{o(b),t(b==="solid"?a:u)};return y.jsxs("div",{className:"flex h-[450px] w-[280px] flex-col overflow-hidden",children:[y.jsxs("div",{className:"bg-main-secondary flex rounded-t-lg border-b border-divider p-1",children:[y.jsx("button",{type:"button",onClick:()=>p("solid"),className:`flex-1 rounded-md px-3 py-1.5 text-[11px] font-semibold transition-all ${s==="solid"?"bg-main text-white shadow-sm":"text-content-subtle hover:bg-main-hover hover:text-content"}`,children:"Solid"}),y.jsx("button",{type:"button",onClick:()=>p("gradient"),className:`flex-1 rounded-md px-3 py-1.5 text-[11px] font-semibold transition-all ${s==="gradient"?"bg-main text-white shadow-sm":"text-content-subtle hover:bg-main-hover hover:text-content"}`,children:"Gradient"})]}),y.jsx("div",{className:"flex-1 overflow-auto",children:s==="solid"?y.jsx(Dv,{value:a,onChange:b=>{c(b),t(b)},onCommit:n,dataCy:r?`${r}-solid`:void 0}):y.jsx(Qve,{value:u,onChange:b=>{h(b),t(b)},onCommit:n,dataCy:r?`${r}-gradient`:void 0})})]})},tye=({value:e,onChange:t,onApply:n,onPreview:r,onBlur:i,disabled:s=!1,dataCy:o})=>{const a=Ce(Id),c=f.useMemo(()=>a!=null&&a.registry.fontFamily?Object.entries(a.registry.fontFamily).map(([h,p])=>({value:typeof p=="string"?p:"",label:`${h} (${typeof p=="string"?p:""})`})):[],[a]),u=h=>{const p=a!=null&&a.registry.fontFamily?Object.entries(a.registry.fontFamily).find(([,g])=>(typeof g=="string"?g:"")===h.value):void 0,m=p==null?void 0:p[0];return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"font-medium",children:m??h.value}),y.jsx("div",{className:"truncate text-[10px] text-content-subtle",children:h.value})]})};return y.jsx(gk,{value:e,options:c,onChange:t,onApply:n,onPreview:r,onBlur:i,disabled:s,renderOption:u,emptyMessage:"No font families configured in design tokens",contentWidth:"w-80",dataCy:o})},nye=[{value:"100",label:"100 - Thin"},{value:"200",label:"200 - Extra Light"},{value:"300",label:"300 - Light"},{value:"400",label:"400 - Normal"},{value:"500",label:"500 - Medium"},{value:"600",label:"600 - Semi Bold"},{value:"700",label:"700 - Bold"},{value:"800",label:"800 - Extra Bold"},{value:"900",label:"900 - Black"}],rye=e=>y.jsx("span",{style:{fontWeight:parseInt(e.value,10)},children:e.label}),fc=e=>{const{type:t,value:n,onChange:r,onApply:i,onPreview:s,onBlur:o,property:a,disabled:c=!1,isLoading:u=!1,options:h=[],className:p="",icon:m,dataCy:g}=e,b=Ce(Id),x=f.useRef(null),[C,w]=f.useState(null),[E,_]=f.useState(!1),[T,I]=f.useState(!1),[P,M]=f.useState("");f.useLayoutEffect(()=>{x.current&&C!==null&&x.current.setSelectionRange(C,C)},[n,C]);const{displayValue:S,stage:R,commit:$,rollback:L}=f1e({value:n,onApply:i,onPreview:s,onChange:r}),j=!!(a&&b&&Mu[a]&&b.registry[Mu[a]]&&Object.keys(b.registry[Mu[a]]).length>0),H=a?((V,W)=>{if(!b||!V)return null;const N=Mu[V];if(!N)return null;const z=b.registry[N];if(!z)return null;const Q=String(W),J=N==="colors"?cc(Q,!0):Q;for(const[re,G]of Object.entries(z))if(typeof G=="string"){if((N==="colors"?cc(G,!0):G)===J)return re}else for(const[X,de]of Object.entries(G))if((N==="colors"?cc(de,!0):de)===J)return X==="DEFAULT"?re:`${re}-${X}`;return null})(a,n):null,B=V=>{let W=V.target.value;const N=V.target.selectionStart;t==="spacing"&&W&&!isNaN(Number(W))&&!W.endsWith(" ")&&(W=`${W}px`),w(N),R(W),r(W)},Z=V=>{const W=V.match(/^(-?[\d.]+)(.*)$/);return W?{num:parseFloat(W[1]),unit:W[2]}:{num:0,unit:""}},K=(V,W)=>{const{num:N,unit:z}=Z(V);return isNaN(N)?V:`${N+W}${z}`},q=V=>{if(V.key==="Enter"){$();return}if((t==="text"||t==="spacing")&&(V.key==="ArrowUp"||V.key==="ArrowDown")){V.preventDefault();const W=V.key==="ArrowUp"?1:-1,N=K(S,W);R(N),r(N)}},te=()=>{$(),o&&o(),w(null)},F=(V,W)=>{r(W),i&&i(W)};if(a==="fontFamily")return y.jsx(tye,{value:n,onChange:r,onApply:i,onPreview:s,onBlur:o,disabled:c||u,dataCy:g});if(a==="fontWeight")return y.jsx(gk,{value:n,options:nye,onChange:r,onApply:i,onPreview:s,onBlur:o,disabled:c||u,renderOption:rye,dataCy:g});if(t==="alignment"){const V=[{value:"left",icon:bG},{value:"center",icon:yG},{value:"right",icon:xG}];return y.jsx("div",{className:"flex w-28 items-center justify-between gap-1 rounded bg-main-input px-2 py-1","data-cy":g,children:V.map(W=>{const N=W.icon,z=n===W.value||!n&&W.value==="left";return y.jsx("button",{type:"button",disabled:c||u,onClick:()=>{r(W.value),i&&i(W.value)},className:`flex items-center justify-center rounded p-1 transition-colors ${z?"text-content":"text-content-subtle hover:text-content"} ${c?"cursor-not-allowed opacity-50":""}`,title:`Align ${W.value}`,"data-cy":g?`${g}-align-${W.value}`:void 0,children:y.jsx(N,{className:"h-3.5 w-3.5",weight:"bold"})},W.value)})})}switch(t){case"color":{const V=S,W=H||V,N=Xh(String(V)),z=y.jsxs("button",{type:"button",disabled:c||u,className:"flex w-28 items-center space-x-2 rounded bg-main-input px-2 py-1 transition-colors hover:bg-main-hover focus:outline-none",onBlur:te,title:W,"data-cy":g,children:[y.jsx("div",{className:"h-4 w-4 rounded-sm border border-white/10",style:N?{backgroundImage:V}:{backgroundColor:V}}),y.jsx("span",{className:"min-w-0 flex-1 truncate text-left font-mono text-xs text-content",children:W})]}),Q=a==="background"?eye:Dv;if(j&&a){const J=y.jsx(Q,{value:V,onChange:re=>{R(re),r(re)},onCommit:()=>{$(),_(!1)},dataCy:g?`${g}-picker`:void 0});return y.jsx(pg,{property:a,onSelectToken:F,colorPickerElement:J,onColorPickerCancel:()=>{L()},isOpen:E,onOpenChange:re=>{re||$(),_(re)},disabled:c||u,currentValue:n,dataCy:g?`${g}-token-selector`:void 0,children:z})}return y.jsxs(Fo,{open:E,onOpenChange:J=>{J||$(),_(J)},children:[y.jsx(ul,{asChild:!0,children:z}),y.jsx(Oo,{children:y.jsx(Vo,{className:"z-[60] max-h-[80vh] overflow-y-auto rounded-lg border-[1px] border-divider bg-main shadow-lg",sideOffset:5,collisionPadding:10,onOpenAutoFocus:J=>J.preventDefault(),"data-cy":g?`${g}-popover-content`:void 0,children:y.jsx(Q,{value:V,onChange:J=>{R(J),r(J)},onCommit:()=>{$(),_(!1)},dataCy:g?`${g}-picker`:void 0})})})]})}case"range":{const V=H||S,W=y.jsxs("div",{className:"flex w-28 items-center rounded bg-main-input","data-cy":g,children:[y.jsx("input",{type:"text",value:V,onChange:N=>{r(N.target.value)},onFocus:N=>{N.target.select()},onKeyDown:N=>{if(N.key==="Enter"&&i){i();return}if(N.key==="ArrowUp"||N.key==="ArrowDown"){N.preventDefault();const z=N.key==="ArrowUp"?1:-1,Q=parseFloat(n.toString());if(!isNaN(Q)){const J=Math.max(0,Math.min(100,Q+z));r(J.toString())}}},onBlur:te,disabled:c||u,readOnly:!!(H&&j),className:"min-w-0 flex-1 bg-transparent px-4 py-1 text-left text-xs text-content placeholder-content-subtle focus:outline-none",placeholder:"100","data-cy":g}),y.jsx("span",{className:"pr-3 text-xs text-content-subtle",children:"%"})]});return j&&a?y.jsx(pg,{property:a,onSelectToken:F,disabled:c||u,children:W}):W}case"readonly":return y.jsx("input",{type:"text",value:n,disabled:!0,className:"w-28 cursor-not-allowed truncate rounded bg-main-input px-4 py-1 text-left text-xs text-content-subtle",title:n,"data-cy":g});case"select":{const V="__custom__",N=!h.includes(n)?V:n;return y.jsxs("div",{className:"flex items-center space-x-1",children:[y.jsxs(Ev,{value:N,onValueChange:z=>{z===V?(I(!0),M(n||"")):(r(z),i&&i(z))},disabled:c||u,children:[y.jsxs(Sv,{className:`flex w-28 items-center justify-between rounded px-3 py-1 text-xs transition-colors focus:outline-none ${c?"cursor-not-allowed opacity-50":"bg-main-input text-content hover:bg-main-hover"}`,onBlur:te,"data-cy":g,children:[y.jsx(aj,{className:"truncate"}),y.jsx(lj,{className:"flex-shrink-0",children:y.jsx(Ba,{className:"h-3 w-3",weight:"bold"})})]}),y.jsx(G3,{children:y.jsx(q3,{className:"z-[60] overflow-hidden rounded-lg border-[1px] border-divider bg-main shadow-lg",children:y.jsxs(Y3,{className:"p-1",children:[h.map(z=>y.jsxs(ja,{value:z,className:"relative flex cursor-pointer items-center rounded px-8 py-2 text-xs text-content outline-none hover:bg-main-hover data-[highlighted]:bg-main-hover",children:[y.jsx(ip,{className:"absolute left-2 inline-flex items-center",children:y.jsx(za,{className:"h-3 w-3",weight:"bold"})}),y.jsx(xd,{children:z})]},z)),y.jsx(Cj,{className:"my-1 h-px bg-divider"}),y.jsx(ja,{value:V,className:"relative flex cursor-pointer items-center rounded px-8 py-2 text-xs text-content outline-none hover:bg-main-hover data-[highlighted]:bg-main-hover",children:y.jsx(xd,{children:"Custom..."})})]})})})]}),T&&y.jsxs(Fo,{open:T,onOpenChange:I,children:[y.jsx(y0e,{}),y.jsx(Oo,{children:y.jsx(Vo,{className:"z-[60] rounded-lg border-[1px] border-divider bg-main p-3 shadow-lg",sideOffset:5,onOpenAutoFocus:z=>{z.preventDefault(),setTimeout(()=>{const Q=document.getElementById("custom-value-input");Q==null||Q.focus(),Q==null||Q.select()},0)},children:y.jsxs("div",{className:"flex flex-col space-y-2",children:[y.jsx("label",{htmlFor:"custom-value-input",className:"text-xs font-medium text-content",children:"Enter custom value:"}),y.jsx("input",{id:"custom-value-input",type:"text",value:P,onChange:z=>M(z.target.value),onKeyDown:z=>{z.key==="Enter"?(r(P),i&&i(P),I(!1)):z.key==="Escape"&&I(!1)},className:"w-32 rounded bg-main-input px-3 py-1 text-xs text-content focus:outline-none",placeholder:"e.g., bold"}),y.jsxs("div",{className:"flex space-x-2",children:[y.jsx("button",{type:"button",onClick:()=>{r(P),i&&i(P),I(!1)},className:"flex-1 rounded bg-primary px-3 py-1 text-xs text-white hover:bg-primary-hover",children:"Apply"}),y.jsx("button",{type:"button",onClick:()=>I(!1),className:"flex-1 rounded px-3 py-1 text-xs text-content-subtle hover:bg-main-hover",children:"Cancel"})]})]})})})]})]})}case"text":case"spacing":default:{const V=H||S,N=t==="spacing"&&typeof V=="string"?V.replace(/px$/,""):V,z=t==="spacing"?y.jsxs("div",{className:`flex w-full items-center rounded bg-main-input ${p}`,children:[m&&y.jsx("span",{className:"pl-2",children:m}),y.jsx("input",{ref:x,type:"text",value:N,onChange:B,onKeyDown:q,onBlur:te,disabled:c||u,readOnly:!!(H&&j),className:`min-w-0 flex-1 bg-transparent py-1 text-left text-xs text-content placeholder-content-subtle focus:outline-none ${m?"pl-2":"px-4"}`,"data-cy":g}),y.jsx("span",{className:"pr-3 text-xs text-content-subtle",children:"px"})]}):y.jsx("input",{ref:x,type:"text",value:V,onChange:B,onKeyDown:q,onBlur:te,disabled:c||u,readOnly:!!(H&&j),className:`w-28 truncate rounded bg-main-input px-4 py-1 text-left text-xs text-content placeholder-content-subtle focus:outline-none ${p}`,"data-cy":g});return j&&a?y.jsx(pg,{property:a,onSelectToken:F,disabled:c||u,children:z}):z}}},iye=({label:e,type:t,properties:n,formattedComputedStyles:r,pendingChanges:i,handlePendingCssChange:s,applyPropertyChange:o,onPreview:a,performTransaction:c,handleBlur:u,dataCy:h})=>{const[p,m]=f.useState(!1),g=O=>{var H;return i[O]??((H=r[O])==null?void 0:H.value)??"0px"},b=g(n.left)===g(n.right)?g(n.left):"mixed",x=g(n.top)===g(n.bottom)?g(n.top):"mixed",C=O=>{s(n.left,O),s(n.right,O)},w=O=>{s(n.top,O),s(n.bottom,O)},E=async O=>{const H=O??g(n.left);await c(async()=>{await o(n.left,H),await o(n.right,H)})},_=async O=>{const H=O??g(n.top);await c(async()=>{await o(n.top,H),await o(n.bottom,H)})},T=O=>{a(n.left,O),a(n.right,O)},I=O=>{a(n.top,O),a(n.bottom,O)},P=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:y.jsx("path",{d:"M7 10V4M7 4L5 6M7 4L9 6",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),M=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:y.jsx("path",{d:"M7 4V10M7 10L5 8M7 10L9 8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),S=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:y.jsx("path",{d:"M10 7H4M4 7L6 5M4 7L6 9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),R=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:y.jsx("path",{d:"M4 7H10M10 7L8 5M10 7L8 9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),$=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:y.jsx("path",{d:"M2 7H12M2 7L4 5M2 7L4 9M12 7L10 5M12 7L10 9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),L=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:y.jsx("path",{d:"M7 2V12M7 2L5 4M7 2L9 4M7 12L5 10M7 12L9 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),j=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:y.jsx("path",{d:"M3 5.5V4C3 3.44772 3.44772 3 4 3H5.5M8.5 3H10C10.5523 3 11 3.44772 11 4V5.5M11 8.5V10C11 10.5523 10.5523 11 10 11H8.5M5.5 11H4C3.44772 11 3 10.5523 3 10V8.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})});return y.jsxs("div",{className:"flex flex-col space-y-1","data-cy":h,children:[y.jsx("span",{className:"text-xs font-normal tracking-wider text-content",children:e}),y.jsxs("div",{className:"flex items-center gap-2",children:[p?y.jsx("div",{className:"flex-1",children:y.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{key:n.top,Icon:P},{key:n.bottom,Icon:M},{key:n.left,Icon:S},{key:n.right,Icon:R}].map(({key:O,Icon:H})=>y.jsx(fc,{type:"spacing",property:O,value:g(O),onChange:B=>s(O,B),onApply:B=>o(O,B??g(O)),onPreview:B=>a(O,B),onBlur:()=>u(O),icon:y.jsx(H,{})},O))})}):y.jsxs("div",{className:"grid flex-1 grid-cols-2 gap-2",children:[y.jsx(fc,{type:"spacing",property:n.left,value:b,onChange:C,onApply:E,onPreview:T,onBlur:()=>{u(n.left),u(n.right)},icon:y.jsx($,{})}),y.jsx(fc,{type:"spacing",property:n.top,value:x,onChange:w,onApply:_,onPreview:I,onBlur:()=>{u(n.top),u(n.bottom)},icon:y.jsx(L,{})})]}),y.jsx("button",{onClick:()=>m(!p),className:`shrink-0 self-start rounded p-1 transition-colors hover:bg-main-hover ${p?"bg-main-hover text-content":"text-content-subtle"}`,title:p?"Collapse":"Expand all sides",children:y.jsx(j,{})})]})]})},sye=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:y.jsx("path",{d:"M2 7H12M2 7L4 5M2 7L4 9M12 7L10 5M12 7L10 9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),oye=()=>y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:y.jsx("path",{d:"M7 2V12M7 2L5 4M7 2L9 4M7 12L5 10M7 12L9 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),aye=({properties:e,formattedComputedStyles:t,pendingChanges:n,handlePendingCssChange:r,handlePendingPercentageChange:i,applyPropertyChange:s,previewPropertyChange:o,performTransaction:a,handleBlur:c})=>{const u=new Set,h=[{label:"Padding",type:"padding",keys:["paddingTop","paddingBottom","paddingLeft","paddingRight"],properties:{top:"paddingTop",bottom:"paddingBottom",left:"paddingLeft",right:"paddingRight"}},{label:"Margin",type:"margin",keys:["marginTop","marginBottom","marginLeft","marginRight"],properties:{top:"marginTop",bottom:"marginBottom",left:"marginLeft",right:"marginRight"}}];return y.jsx("div",{className:"space-y-4 px-4 pb-4 pt-2",children:e.map(p=>{const{key:m,label:g,type:b,options:x}=p;if(u.has(m))return null;const C=h.find(w=>w.keys.includes(m));if(C)return C.keys.forEach(w=>u.add(w)),y.jsx(iye,{label:C.label,type:C.type,properties:C.properties,formattedComputedStyles:t,pendingChanges:n,handlePendingCssChange:r,applyPropertyChange:s,onPreview:o,performTransaction:a,handleBlur:c,dataCy:`spacing-input-${C.type}`},`${C.type}-group`);if(m==="width"){const w=e.find(E=>E.key==="height");if(w)return u.add("width"),u.add("height"),y.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[y.jsx(fc,{type:b,property:m,value:n[m]??t[m].value,onChange:E=>r(m,E),onApply:(E,_)=>{const T=E??n[m]??t[m].value;s(m,T,_)},onPreview:E=>o(m,E),onBlur:()=>c(m),icon:y.jsx(sye,{}),dataCy:`property-input-${m}`}),y.jsx(fc,{type:w.type,property:w.key,value:n[w.key]??t[w.key].value,onChange:E=>r(w.key,E),onApply:(E,_)=>{const T=E??n[w.key]??t[w.key].value;s(w.key,T,_)},onPreview:E=>o(w.key,E),onBlur:()=>c(w.key),icon:y.jsx(oye,{}),dataCy:`property-input-${w.key}`})]},"width-height-group")}return u.add(m),y.jsxs("div",{className:"flex items-center justify-between gap-2","data-cy":`property-group-${m}`,children:[y.jsx("label",{className:"min-w-0 flex-1 truncate text-xs text-content",children:g}),y.jsx(fc,{type:b,property:m,value:n[m]??t[m].value,onChange:w=>{b==="range"?i(m,w+"%"):r(m,w)},onApply:(w,E)=>{const _=w??n[m]??t[m].value;s(m,_,E)},onPreview:w=>o(m,w),onBlur:()=>c(m),isLoading:!1,options:x,dataCy:`property-input-${m}`})]},m)})})},lye=({propertyCategories:e,formattedComputedStyles:t,pendingChanges:n,handlePendingCssChange:r,handlePendingPercentageChange:i,applyPropertyChange:s,previewPropertyChange:o,performTransaction:a,handleBlur:c})=>y.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:y.jsx(Uu,{defaultValue:e.map(u=>u.value),className:"overflow-visible",children:e.map((u,h)=>y.jsx(Uu.Item,{value:u.value,dataCy:`inspector-section-${u.value}`,title:u.title,className:h===0?"first-item":"",children:y.jsx(aye,{properties:u.properties,formattedComputedStyles:t,pendingChanges:n,handlePendingCssChange:r,handlePendingPercentageChange:i,applyPropertyChange:s,previewPropertyChange:o,performTransaction:a,handleBlur:c})},u.value))})});var VO=["PageUp","PageDown"],HO=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],BO={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},zd="Slider",[w6,cye,uye]=xv(zd),[vk]=ws(zd,[uye]),[dye,Dp]=vk(zd),zO=f.forwardRef((e,t)=>{const{name:n,min:r=0,max:i=100,step:s=1,orientation:o="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:h,onValueChange:p=()=>{},onValueCommit:m=()=>{},inverted:g=!1,form:b,...x}=e,C=f.useRef(new Set),w=f.useRef(0),E=f.useRef(!1),T=o==="horizontal"?fye:hye,[I=[],P]=ys({prop:h,defaultProp:u,onChange:j=>{var H;(H=[...C.current][w.current])==null||H.focus({preventScroll:!0,focusVisible:E.current}),E.current=!1,p(j)}}),M=f.useRef(I);function S(j){const O=vye(I,j);L(j,O)}function R(j){L(j,w.current)}function $(){const j=M.current[w.current];I[w.current]!==j&&m(I)}function L(j,O,{commit:H}={commit:!1}){const B=wye(s),Z=kye(Math.round((j-r)/s)*s+r,B),K=w1(Z,[r,i]);P((q=[])=>{const te=mye(q,K,O);if(xye(te,c*s)){w.current=te.indexOf(K);const F=String(te)!==String(q);return F&&H&&m(te),F?te:q}else return q})}return y.jsx(dye,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:i,valueIndexToChangeRef:w,thumbs:C.current,values:I,orientation:o,form:b,children:y.jsx(w6.Provider,{scope:e.__scopeSlider,children:y.jsx(w6.Slot,{scope:e.__scopeSlider,children:y.jsx(T,{"aria-disabled":a,"data-disabled":a?"":void 0,...x,ref:t,onPointerDown:dt(x.onPointerDown,()=>{a||(M.current=I,E.current=!1)}),min:r,max:i,inverted:g,onSlideStart:a?void 0:S,onSlideMove:a?void 0:R,onSlideEnd:a?void 0:$,onHomeKeyDown:()=>{a||(E.current=!0,L(r,0,{commit:!0}))},onEndKeyDown:()=>{a||(E.current=!0,L(i,I.length-1,{commit:!0}))},onStepKeyDown:({event:j,direction:O})=>{if(!a){E.current=!0;const Z=VO.includes(j.key)||j.shiftKey&&HO.includes(j.key)?10:1,K=w.current,q=I[K],te=s*Z*O;L(q+te,K,{commit:!0})}}})})})})});zO.displayName=zd;var[UO,ZO]=vk(zd,{startEdge:"left",endEdge:"right",size:"width",direction:1}),fye=f.forwardRef((e,t)=>{const{min:n,max:r,dir:i,inverted:s,onSlideStart:o,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...h}=e,[p,m]=f.useState(null),g=Qt(t,_=>m(_)),b=f.useRef(void 0),x=Rp(i),C=x==="ltr",w=C&&!s||!C&&s;function E(_){const T=b.current||p.getBoundingClientRect(),I=[0,T.width],M=yk(I,w?[n,r]:[r,n]);return b.current=T,M(_-T.left)}return y.jsx(UO,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:y.jsx(WO,{dir:x,"data-orientation":"horizontal",...h,ref:g,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const T=E(_.clientX);o==null||o(T)},onSlideMove:_=>{const T=E(_.clientX);a==null||a(T)},onSlideEnd:()=>{b.current=void 0,c==null||c()},onStepKeyDown:_=>{const I=BO[w?"from-left":"from-right"].includes(_.key);u==null||u({event:_,direction:I?-1:1})}})})}),hye=f.forwardRef((e,t)=>{const{min:n,max:r,inverted:i,onSlideStart:s,onSlideMove:o,onSlideEnd:a,onStepKeyDown:c,...u}=e,h=f.useRef(null),p=Qt(t,h),m=f.useRef(void 0),g=!i;function b(x){const C=m.current||h.current.getBoundingClientRect(),w=[0,C.height],_=yk(w,g?[r,n]:[n,r]);return m.current=C,_(x-C.top)}return y.jsx(UO,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:y.jsx(WO,{"data-orientation":"vertical",...u,ref:p,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const C=b(x.clientY);s==null||s(C)},onSlideMove:x=>{const C=b(x.clientY);o==null||o(C)},onSlideEnd:()=>{m.current=void 0,a==null||a()},onStepKeyDown:x=>{const w=BO[g?"from-bottom":"from-top"].includes(x.key);c==null||c({event:x,direction:w?-1:1})}})})}),WO=f.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:s,onHomeKeyDown:o,onEndKeyDown:a,onStepKeyDown:c,...u}=e,h=Dp(zd,n);return y.jsx(Et.span,{...u,ref:t,onKeyDown:dt(e.onKeyDown,p=>{p.key==="Home"?(o(p),p.preventDefault()):p.key==="End"?(a(p),p.preventDefault()):VO.concat(HO).includes(p.key)&&(c(p),p.preventDefault())}),onPointerDown:dt(e.onPointerDown,p=>{const m=p.target;m.setPointerCapture(p.pointerId),p.preventDefault(),h.thumbs.has(m)?m.focus({preventScroll:!0,focusVisible:!1}):r(p)}),onPointerMove:dt(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&i(p)}),onPointerUp:dt(e.onPointerUp,p=>{const m=p.target;m.hasPointerCapture(p.pointerId)&&(m.releasePointerCapture(p.pointerId),s(p))})})}),GO="SliderTrack",qO=f.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Dp(GO,n);return y.jsx(Et.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:t})});qO.displayName=GO;var k6="SliderRange",KO=f.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Dp(k6,n),s=ZO(k6,n),o=f.useRef(null),a=Qt(t,o),c=i.values.length,u=i.values.map(m=>iV(m,i.min,i.max)),h=c>1?Math.min(...u):0,p=100-Math.max(...u);return y.jsx(Et.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:h+"%",[s.endEdge]:p+"%"}})});KO.displayName=k6;var YO="SliderThumb",[pye,XO]=vk(YO),QO="SliderThumbProvider";function JO(e){const{__scopeSlider:t,name:n,children:r,internal_do_not_use_render:i}=e,s=Dp(QO,t),o=cye(t),[a,c]=f.useState(null),u=f.useMemo(()=>a?o().findIndex(C=>C.ref.current===a):-1,[o,a]),h=SL(a),p=a?!!s.form||!!a.closest("form"):!0,m=s.values[u],g=n??(s.name?s.name+(s.values.length>1?"[]":""):void 0),b=m===void 0?0:iV(m,s.min,s.max);f.useEffect(()=>{if(a)return s.thumbs.add(a),()=>{s.thumbs.delete(a)}},[a,s.thumbs]);const x={value:m,name:g,form:s.form,isFormControl:p,index:u,thumb:a,onThumbChange:c,percent:b,size:h};return y.jsx(pye,{scope:t,...x,children:Cye(i)?i(x):r})}JO.displayName=QO;var yg="SliderThumbTrigger",eV=f.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Dp(yg,n),s=ZO(yg,n),{index:o,value:a,percent:c,size:u,onThumbChange:h}=XO(yg,n),p=Qt(t,x=>h(x)),m=gye(o,i.values.length),g=u==null?void 0:u[s.size],b=g?yye(g,c,s.direction):0;return y.jsx("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${c}% + ${b}px)`},children:y.jsx(w6.ItemSlot,{scope:n,children:y.jsx(Et.span,{role:"slider","aria-label":e["aria-label"]||m,"aria-valuemin":i.min,"aria-valuenow":a,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...r,ref:p,style:a===void 0?{display:"none"}:e.style,onFocus:dt(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})})})});eV.displayName=yg;var tV=f.forwardRef((e,t)=>{const{__scopeSlider:n,name:r,...i}=e;return y.jsx(JO,{__scopeSlider:n,name:r,internal_do_not_use_render:({index:s,isFormControl:o})=>y.jsxs(y.Fragment,{children:[y.jsx(eV,{...i,ref:t,__scopeSlider:n}),o?y.jsx(rV,{__scopeSlider:n},s):null]})})});tV.displayName=YO;var nV="SliderBubbleInput",rV=f.forwardRef(({__scopeSlider:e,...t},n)=>{const{value:r,name:i,form:s}=XO(nV,e),o=f.useRef(null),a=Qt(o,n),c=tj(r);return f.useEffect(()=>{const u=o.current;if(!u)return;const h=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(h,"value").set;if(c!==r&&m){const g=new Event("input",{bubbles:!0});m.call(u,r),u.dispatchEvent(g)}},[c,r]),y.jsx(Et.input,{style:{display:"none"},name:i,form:s,...t,ref:a,defaultValue:r})});rV.displayName=nV;function mye(e=[],t,n){const r=[...e];return r[n]=t,r.sort((i,s)=>i-s)}function iV(e,t,n){const s=100/(n-t)*(e-t);return w1(s,[0,100])}function gye(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function vye(e,t){if(e.length===1)return 0;const n=e.map(i=>Math.abs(i-t)),r=Math.min(...n);return n.indexOf(r)}function yye(e,t,n){const r=e/2,s=yk([0,50],[0,r]);return(r-s(t)*n)*n}function bye(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function xye(e,t){if(t>0){const n=bye(e);return Math.min(...n)>=t}return!0}function yk(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function wye(e){if(!Number.isFinite(e))return 0;const t=e.toString();if(t.includes("e")){const[r,i]=t.split("e"),s=r.split(".")[1]||"",o=Number(i);return Math.max(0,s.length-o)}const n=t.split(".")[1];return n?n.length:0}function kye(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}function Cye(e){return typeof e=="function"}const M1=f.forwardRef(({className:e,...t},n)=>y.jsxs(zO,{ref:n,className:zn("relative flex w-full touch-none select-none items-center","data-[disabled]:opacity-50",e),...t,children:[y.jsx(qO,{className:"relative h-1 w-full grow overflow-hidden rounded-full bg-input",children:y.jsx(KO,{className:"absolute h-full bg-primary"})}),y.jsx(tV,{className:zn("block h-3.5 w-3.5 rounded-full border border-border bg-foreground shadow-sm","transition-transform hover:scale-110 active:scale-95","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6B97FF]","disabled:pointer-events-none")})]}));M1.displayName="Slider";const Eye=({control:e,value:t,onChange:n,disabled:r})=>{const i=e.config,s=i.min??0,o=i.max??100,a=i.step??1,c=i.unit??"",u=c3(e,t),h=typeof u=="number"?u:parseFloat(String(u??s)),p=Number.isFinite(h)?h:s;return y.jsxs("div",{className:"flex w-44 items-center gap-2.5",children:[y.jsx(M1,{min:s,max:o,step:a,value:[p],disabled:r,onValueChange:([m])=>n(m),"data-cy":`control-${e.id}-slider`}),y.jsxs("span",{className:"w-12 shrink-0 text-right text-[12px] tabular-nums text-muted-foreground",children:[Number.isInteger(p)?p:p.toFixed(2),c]})]})},Sye=({control:e,value:t,onChange:n,disabled:r})=>{const s=e.config.swatches??[],o=c3(e,t);return y.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:s.map(a=>{const c=o===a;return y.jsx(dn.button,{type:"button",disabled:r,whileHover:r?void 0:{scale:1.12},whileTap:r?void 0:{scale:.94},transition:Ka.fast,onClick:()=>n(a),title:a,className:zn("h-6 w-6 rounded-full border",c?"border-transparent ring-2 ring-primary ring-offset-1 ring-offset-background":"border-border",r&&"cursor-not-allowed opacity-50"),style:{backgroundColor:a},"data-cy":`control-${e.id}-swatch`},a)})})},_ye=({control:e,value:t,onChange:n,disabled:r})=>{const s=e.config.options??[],o=c3(e,t),a=Md(),c=E1("check");return y.jsx("div",{className:"flex w-full flex-col gap-1.5",children:s.map(u=>{const h=o===u.id;return y.jsxs(dn.button,{type:"button",disabled:r,whileTap:r?void 0:{scale:.99},transition:Ka.fast,onClick:()=>n(u.id),className:zn("flex items-center justify-between px-3 py-2 text-left text-[12px] transition-colors",a.button,h?"bg-primary/15 text-foreground":"text-muted-foreground hover:bg-hover hover:text-foreground",r&&"cursor-not-allowed opacity-50"),"data-cy":`control-${e.id}-option`,children:[y.jsx("span",{className:"truncate",children:u.label}),h&&y.jsx(c,{size:14,strokeWidth:2,className:"shrink-0 text-primary"})]},u.id)})})},Aye=({control:e})=>y.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",title:`Unsupported control kind: ${e.kind}`,children:e.kind}),Tye={"scoped-slider":Eye,"swatch-set":Sye,"option-cards":_ye},Pye=e=>Tye[e]??Aye,Iye=e=>e==="option-cards",Mye=(e,t)=>{if(!e)return{css:""};const n=[];for(const r of e.sections)for(const i of r.controls){const s=jD(i,t==null?void 0:t.values[i.id]);for(const o of s)n.push(`${o.selector} { ${o.property}: ${o.value}; }`)}return{css:n.join(`
|
|
505
505
|
`)}},kd=new Map,Nv=new Map,bs=Qe(0),sV=Qe(!1),Tc=e=>No(e(ps)),bk=e=>Nv.get(e)??{values:{}},Lv=Qe(e=>(e(bs),kd.get(Tc(e))??null)),oV=Qe(e=>(e(bs),bk(Tc(e)))),Rye=Qe(e=>{e(bs);const t=Tc(e);return Mye(kd.get(t)??null,bk(t))}),aV=Qe(null,(e,t,n)=>{const r=Tc(e);n?kd.set(r,n):kd.delete(r),Nv.set(r,{values:{}}),t(bs,e(bs)+1)}),$ye=Qe(null,(e,t,n)=>{const r=Tc(e),i=kd.get(r),s=i?{...i,sections:[...i.sections,...n.sections]}:{version:1,intent:n.intent,sections:n.sections};kd.set(r,s),t(bs,e(bs)+1)}),lV=Qe(null,(e,t,n)=>{const r=Tc(e),s={...bk(r).values};n.value===void 0?delete s[n.controlId]:s[n.controlId]=n.value,Nv.set(r,{values:s}),t(bs,e(bs)+1)}),cV=Qe(null,(e,t)=>{Nv.set(Tc(e),{values:{}}),t(bs,e(bs)+1)}),zl=({className:e})=>y.jsx("div",{className:`rounded bg-muted-foreground/15 ${e??""}`}),Dye=({stacked:e=!1})=>e?y.jsxs("div",{className:"flex flex-col gap-1.5",children:[y.jsx(zl,{className:"h-2.5 w-20"}),y.jsxs("div",{className:"flex flex-col gap-1.5",children:[y.jsx(zl,{className:"h-6 w-full rounded-lg"}),y.jsx(zl,{className:"h-6 w-full rounded-lg"})]})]}):y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx(zl,{className:"h-2.5 w-20"}),y.jsx(zl,{className:"h-2 w-28 rounded-full"})]}),RT=({rows:e,stackedLast:t=!1})=>y.jsxs("div",{className:"px-1 py-2",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2",children:[y.jsx(zl,{className:"h-3.5 w-3.5 rounded"}),y.jsx(zl,{className:"h-3 w-24"})]}),y.jsx("div",{className:"space-y-4 px-2 pt-1",children:Array.from({length:e}).map((n,r)=>y.jsx(Dye,{stacked:t&&r===e-1},r))})]}),Nye=()=>y.jsxs("div",{className:"animate-pulse px-2 pb-2","data-cy":"generated-interface-skeleton","aria-hidden":"true",children:[y.jsx(RT,{rows:3}),y.jsx(RT,{rows:2,stackedLast:!0})]}),Lye=()=>{const e=Ce(Lv),t=Ce(oV),n=ze(lV),r=ze(cV),i=ze(aV),s=Ce(sV),o=E1("rotate-ccw"),a=E1("x"),c=!!(e&&e.sections.length>0);if(!c&&!s)return null;const u=h=>{const p=Pye(h.kind),m=Iye(h.kind),g=t.values[h.id],b=g!==void 0&&g!==h.baseline,x=y.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[y.jsx("label",{className:"min-w-0 truncate text-[12px] text-foreground",title:h.label,children:h.label}),b&&y.jsx("button",{type:"button",onClick:()=>n({controlId:h.id,value:void 0}),className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",title:"Reset to baseline",children:y.jsx(o,{size:12,strokeWidth:1.75})})]}),C=y.jsx(p,{control:h,value:g,onChange:w=>n({controlId:h.id,value:w})});return y.jsx("div",{"data-cy":`control-${h.id}`,children:m?y.jsxs("div",{className:"flex flex-col gap-1.5",children:[x,C]}):y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[x,C]})},h.id)};return y.jsxs("div",{children:[e&&c&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[y.jsx("span",{className:"truncate text-[12px] text-muted-foreground",title:e.intent,children:e.intent}),y.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[y.jsxs("button",{type:"button",onClick:()=>r(),className:"flex items-center gap-1 rounded px-1.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-hover hover:text-foreground",title:"Reset all controls to baseline",children:[y.jsx(o,{size:12,strokeWidth:1.75}),"Reset"]}),y.jsxs("button",{type:"button",onClick:()=>i(null),className:"flex items-center gap-1 rounded px-1.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-hover hover:text-foreground",title:"Clear generated interface",children:[y.jsx(a,{size:12,strokeWidth:1.75}),"Clear"]})]})]}),y.jsx(ik,{type:"multiple",defaultValue:e.sections.map(h=>h.id),className:"w-full px-2 pb-2",children:e.sections.map((h,p)=>y.jsxs(sk,{value:h.id,index:p,"data-cy":`interface-section-${h.id}`,children:[y.jsx(ok,{children:h.title}),y.jsx(ak,{children:y.jsx("div",{className:"space-y-4 pt-1",children:h.controls.map(u)})})]},h.id))},e.sections.map(h=>h.id).join(","))]}),s&&y.jsx(Nye,{})]})},jye=$t("useGenerateInterface"),Fye=(e,t)=>{if(!t)return e;const n=t.defaultView,r=o=>{try{return t.querySelector(o)!==null}catch{return!1}},i=o=>{if(!o.binding||!n)return;let a;try{a=t.querySelector(o.binding.selector)}catch{return}if(!a)return;const c=n.getComputedStyle(a).getPropertyValue(o.binding.property).trim();if(c){if(o.kind==="scoped-slider"){const u=parseFloat(c);return Number.isFinite(u)?u:void 0}return c}},s=[];for(const o of e){const a=[];for(const c of o.controls){const u=yie(c);if(u.length>0&&!u.some(r))continue;const h=i(c);a.push(h===void 0?c:{...c,baseline:h,default:h})}a.length>0&&s.push({...o,controls:a})}return s},Oye=()=>{const e=Ce(kp),t=Ce(Js),n=Ce(Lv),r=ze(aV),i=ze($ye),[s,o]=Bn(sV),[a,c]=f.useState(null);return{generate:f.useCallback(async(h,p={})=>{var b,x;const m=h.trim();if(!m||s)return;o(!0),c(null);const g=t?[`tag: ${((b=t.tagName)==null?void 0:b.toLowerCase())??"unknown"}`,t.className?`classes: ${t.className}`:null].filter(Boolean).join(`
|
|
506
|
-
`):void 0;try{const C=await fetch("/api/controls/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:m,existingSectionTitles:p.merge&&n?n.sections.map(T=>T.title):void 0,elementSummary:g})});if(!C.ok){const T=await C.json().catch(()=>({}));throw new Error(T.error||`Generation failed (${C.status})`)}const w=await C.json(),E=(x=e==null?void 0:e.current)==null?void 0:x.contentDocument,_=Fye(w.sections??[],E);p.merge&&n?i({intent:m,sections:_}):r({version:1,intent:m,sections:_})}catch(C){const w=C instanceof Error?C.message:"Generation failed";jye.error("Interface generation failed",C),c(w)}finally{o(!1)}},[s,t,n,e,r,i]),isGenerating:s,error:a}},Vye=$t("interfaceInjection"),$T="rivet-override-layer",DT=(e,t)=>{if(!(e!=null&&e.head))return;let n=e.getElementById($T);n||(n=e.createElement("style"),n.id=$T,e.head.appendChild(n)),n.textContent=t},Hye=()=>{const e=Ce(Rye),t=Ce(kp),n=Ce(Pd);f.useEffect(()=>{var r;if(DT((r=t==null?void 0:t.current)==null?void 0:r.contentDocument,e.css),Vye.debug("Applied interface override layer",{bytes:e.css.length}),!!n)return n.onHMR(()=>{requestAnimationFrame(()=>{var i;DT((i=t==null?void 0:t.current)==null?void 0:i.contentDocument,e.css)})})},[e,t,n])},Bye=()=>{Hye();const e=Ce(Lv),{generate:t,isGenerating:n,error:r}=Oye(),[i,s]=f.useState(""),o=f.useRef(null),a=p=>{p.style.height="auto",p.style.height=`${p.scrollHeight}px`},c=p=>{s(p.target.value),a(p.target)},u=()=>{var m;const p=i.trim();!p||n||(t(p,{merge:!!e}),s(""),o.current&&(o.current.style.height="auto"),(m=o.current)==null||m.blur())},h=p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&(p.preventDefault(),p.nativeEvent.stopImmediatePropagation(),u())};return y.jsxs("div",{className:"flex-shrink-0 border-t border-main-border p-3",children:[r?y.jsx("p",{className:"mb-2 text-xs text-red-400",children:r}):null,y.jsxs("div",{className:"rounded-lg bg-main-input outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[y.jsx("textarea",{ref:o,value:i,onChange:c,onKeyDown:h,placeholder:e?"Describe more controls to add…":"Describe what you want to edit (e.g. “tune the card hover and shadow”)",disabled:n,className:"max-h-32 min-h-[2.5rem] w-full resize-none overflow-y-auto bg-transparent pb-1 pl-3 pr-3 pt-3 text-sm text-content placeholder-content-subtle focus:outline-none disabled:opacity-50",rows:3,"data-cy":"generated-interface-prompt"}),y.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1",children:[n?y.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-content-subtle",children:[y.jsx(K8,{className:"text-sm text-primary"}),"Generating controls…"]}):y.jsx("span",{className:"text-xs text-content-subtle",children:"Generate controls"}),y.jsx("button",{onClick:u,disabled:!i.trim()||n,className:"flex items-center justify-center rounded bg-primary p-1 text-content transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-80",title:"Generate controls (⌘↵)","data-cy":"generated-interface-submit",children:y.jsx(s8,{className:"h-5 w-5",weight:"bold"})})]})]})]})},zye=$t("useDiffStats"),Uye={files:[],totalInsertions:0,totalDeletions:0},uV=()=>{const e=Ce(mw),t=ze(mw),n=(e==null?void 0:e.diffStats)??Uye,r=!1,i=null,s=f.useCallback(async()=>{const a=await _w();return a&&t(a),(a==null?void 0:a.diffStats)??null},[t]),o=f.useCallback(async a=>{try{const c=await fetch("/api/git/revert-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:a})});if(!c.ok)throw new Error(`Failed to revert file: ${c.status}`);const u=await _w();return u&&t(u),!0}catch(c){return zye.warn("Error reverting file:",c),!1}},[t]);return{stats:n,fetchDiffStats:s,revertFile:o,isLoading:r,error:i}},Wf=$t("useGitPublish"),Zye=()=>{const[e,t]=f.useState(!1),[n,r]=f.useState(null),{fetchStatus:i}=J1(),s=f.useCallback(async()=>{Wf.debug("publishChanges called"),t(!0),r(null);try{Wf.debug("Making fetch request to /api/git/publish");const a=await fetch("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"}});if(Wf.debug("Response received",{status:a.status,ok:a.ok}),!a.ok){const u=await a.json();throw new Error(u.details||u.error||`HTTP ${a.status}`)}const c=await a.json();return Wf.info("Git publish completed successfully:",c.prUrl),{data:c,error:null}}catch(a){const c=a instanceof Error?a.message:"Failed to publish changes";return r(c),Wf.warn("Git publish error:",a),{data:null,error:c}}finally{t(!1)}},[]);return{publishChanges:f.useCallback(async a=>{const{data:c,error:u}=await s();return c?i():u&&a("error","Failed to publish changes",u),c},[s,i]),isPublishing:e,error:n,clearError:()=>r(null)}},NT=$t("useGitPush"),Wye=()=>{const[e,t]=f.useState(!1);return{pushCommits:f.useCallback(async()=>{t(!0);try{const r=await fetch("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"}});if(!r.ok){const i=await r.json();throw new Error(i.details||i.error||`HTTP ${r.status}`)}return NT.info("Push completed successfully"),{success:!0,error:null}}catch(r){const i=r instanceof Error?r.message:"Failed to push";return NT.warn("Push error:",r),{success:!1,error:i}}finally{t(!1)}},[]),isPushing:e}},Gye=2e3,qye=()=>{const e=xs(),{stats:t,fetchDiffStats:n,revertFile:r}=uV(),{fetchStatus:i}=J1(),[s,o]=f.useState(null),[a,c]=f.useState(null),u=f.useRef(null),h=async x=>{if(x){const C=await n();e==null||e.capture("git_diff_viewed",{file_count:(C==null?void 0:C.files.length)??0,total_insertions:(C==null?void 0:C.totalInsertions)??0,total_deletions:(C==null?void 0:C.totalDeletions)??0})}},p=async x=>{o(x);const C=await r(x);o(null),C?(e==null||e.capture("git_file_reverted",{file_path:x}),i()):e==null||e.capture("git_file_revert_failed",{file_path:x})},m=t.totalInsertions>0||t.totalDeletions>0,g=x=>{u.current=setTimeout(()=>{c(x)},Gye)},b=()=>{u.current&&(clearTimeout(u.current),u.current=null),c(null)};return y.jsxs(Fo,{onOpenChange:h,children:[y.jsx(ul,{asChild:!0,children:y.jsx("button",{type:"button",className:el("flex h-7 flex-shrink-0 items-center gap-2 rounded-md px-2 text-xs font-medium transition-colors","text-content-subtle hover:bg-main-hover hover:text-content",!m&&"opacity-50"),children:m?y.jsxs("div",{className:"flex items-center gap-1.5 leading-none",children:[y.jsxs("span",{className:"text-green-400",children:["+",t.totalInsertions]}),y.jsxs("span",{className:"text-red-400",children:["-",t.totalDeletions]})]}):null})}),y.jsx(Oo,{children:y.jsx(Vo,{className:"z-[60] w-80 rounded-lg border-[1px] border-divider bg-main p-3 shadow-lg",sideOffset:5,align:"end",children:t.files.length>0?y.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:t.files.map(x=>{const C=x.file.split("/").pop()??x.file,w=s===x.file;return y.jsxs("div",{className:"relative flex items-center gap-2 rounded border border-transparent px-2 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input",onMouseEnter:()=>g(x.file),onMouseLeave:b,children:[a===x.file?y.jsx("div",{className:"absolute bottom-full left-0 mb-1 max-w-xs truncate rounded border border-divider bg-main px-2 py-1 text-xs text-content shadow-md",children:x.file}):null,y.jsx("span",{className:"min-w-0 flex-1 truncate",children:C}),y.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsxs("span",{className:"text-green-400",children:["+",x.insertions]}),y.jsxs("span",{className:"text-red-400",children:["-",x.deletions]}),y.jsx("button",{type:"button",onClick:()=>p(x.file),disabled:w,className:"text-content-subtle transition-colors hover:text-red-400 disabled:opacity-50",title:`Revert ${C}`,children:y.jsx(Bh,{className:`h-3 w-3 ${w?"animate-spin":""}`,weight:"bold"})})]})]},x.file)})}):y.jsx("div",{className:"py-2 text-center text-xs text-content-subtle",children:"No changes on this branch"})})})]})};var[jv]=ws("Tooltip",[Hd]),Fv=Hd(),dV="TooltipProvider",Kye=700,C6="tooltip.open",[Yye,xk]=jv(dV),fV=e=>{const{__scopeTooltip:t,delayDuration:n=Kye,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=f.useRef(!0),a=f.useRef(!1),c=f.useRef(0);return f.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),y.jsx(Yye,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:f.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:f.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:f.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:s})};fV.displayName=dV;var up="Tooltip",[Xye,Np]=jv(up),hV=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,c=xk(up,e.__scopeTooltip),u=Fv(t),[h,p]=f.useState(null),m=Zi(),g=f.useRef(0),b=o??c.disableHoverableContent,x=a??c.delayDuration,C=f.useRef(!1),[w,E]=ys({prop:r,defaultProp:i??!1,onChange:M=>{M?(c.onOpen(),document.dispatchEvent(new CustomEvent(C6))):c.onClose(),s==null||s(M)},caller:up}),_=f.useMemo(()=>w?C.current?"delayed-open":"instant-open":"closed",[w]),T=f.useCallback(()=>{window.clearTimeout(g.current),g.current=0,C.current=!1,E(!0)},[E]),I=f.useCallback(()=>{window.clearTimeout(g.current),g.current=0,E(!1)},[E]),P=f.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{C.current=!0,E(!0),g.current=0},x)},[x,E]);return f.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),y.jsx(B3,{...u,children:y.jsx(Xye,{scope:t,contentId:m,open:w,stateAttribute:_,trigger:h,onTriggerChange:p,onTriggerEnter:f.useCallback(()=>{c.isOpenDelayedRef.current?P():T()},[c.isOpenDelayedRef,P,T]),onTriggerLeave:f.useCallback(()=>{b?I():(window.clearTimeout(g.current),g.current=0)},[I,b]),onOpen:T,onClose:I,disableHoverableContent:b,children:n})})};hV.displayName=up;var E6="TooltipTrigger",pV=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Np(E6,n),s=xk(E6,n),o=Fv(n),a=f.useRef(null),c=Qt(t,a,i.onTriggerChange),u=f.useRef(!1),h=f.useRef(!1),p=f.useCallback(()=>u.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),y.jsx(gv,{asChild:!0,...o,children:y.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:dt(e.onPointerMove,m=>{m.pointerType!=="touch"&&!h.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),h.current=!0)}),onPointerLeave:dt(e.onPointerLeave,()=>{i.onTriggerLeave(),h.current=!1}),onPointerDown:dt(e.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:dt(e.onFocus,()=>{u.current||i.onOpen()}),onBlur:dt(e.onBlur,i.onClose),onClick:dt(e.onClick,i.onClose)})})});pV.displayName=E6;var wk="TooltipPortal",[Qye,Jye]=jv(wk,{forceMount:void 0}),mV=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Np(wk,t);return y.jsx(Qye,{scope:t,forceMount:n,children:y.jsx(ks,{present:n||s.open,children:y.jsx(Ip,{asChild:!0,container:i,children:r})})})};mV.displayName=wk;var Cd="TooltipContent",gV=f.forwardRef((e,t)=>{const n=Jye(Cd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Np(Cd,e.__scopeTooltip);return y.jsx(ks,{present:r||o.open,children:o.disableHoverableContent?y.jsx(vV,{side:i,...s,ref:t}):y.jsx(e2e,{side:i,...s,ref:t})})}),e2e=f.forwardRef((e,t)=>{const n=Np(Cd,e.__scopeTooltip),r=xk(Cd,e.__scopeTooltip),i=f.useRef(null),s=Qt(t,i),[o,a]=f.useState(null),{trigger:c,onClose:u}=n,h=i.current,{onPointerInTransitChange:p}=r,m=f.useCallback(()=>{a(null),p(!1)},[p]),g=f.useCallback((b,x)=>{const C=b.currentTarget,w={x:b.clientX,y:b.clientY},E=i2e(w,C.getBoundingClientRect()),_=s2e(w,E),T=o2e(x.getBoundingClientRect()),I=l2e([..._,...T]);a(I),p(!0)},[p]);return f.useEffect(()=>()=>m(),[m]),f.useEffect(()=>{if(c&&h){const b=C=>g(C,h),x=C=>g(C,c);return c.addEventListener("pointerleave",b),h.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",b),h.removeEventListener("pointerleave",x)}}},[c,h,g,m]),f.useEffect(()=>{if(o){const b=x=>{const C=x.target,w={x:x.clientX,y:x.clientY},E=(c==null?void 0:c.contains(C))||(h==null?void 0:h.contains(C)),_=!a2e(w,o);E?m():_&&(m(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,h,o,u,m]),y.jsx(vV,{...e,ref:s})}),[t2e,n2e]=jv(up,{isInside:!1}),r2e=Mfe("TooltipContent"),vV=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,c=Np(Cd,n),u=Fv(n),{onClose:h}=c;return f.useEffect(()=>(document.addEventListener(C6,h),()=>document.removeEventListener(C6,h)),[h]),f.useEffect(()=>{if(c.trigger){const p=m=>{m.target instanceof Node&&m.target.contains(c.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,h]),y.jsx(Tp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:y.jsxs(z3,{"data-state":c.stateAttribute,...u,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[y.jsx(r2e,{children:r}),y.jsx(t2e,{scope:n,isInside:!0,children:y.jsx(A0e,{id:c.contentId,role:"tooltip",children:i||r})})]})})});gV.displayName=Cd;var yV="TooltipArrow",bV=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Fv(n);return n2e(yV,n).isInside?null:y.jsx(U3,{...i,...r,ref:t})});bV.displayName=yV;function i2e(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function s2e(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function o2e(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function a2e(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],c=t[o],u=a.x,h=a.y,p=c.x,m=c.y;h>r!=m>r&&n<(p-u)*(r-h)/(m-h)+u&&(i=!i)}return i}function l2e(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),c2e(t)}function c2e(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xV=fV,kk=hV,Ck=pV,Ek=mV,Sk=gV,wV=bV;const LT=$t("useBranches"),u2e=()=>{const[e,t]=f.useState([]),[n,r]=f.useState(!1),[i,s]=f.useState(!1),o=f.useCallback(async()=>{try{r(!0);const c=await fetch("/api/git/branches");if(!c.ok)throw new Error("Failed to fetch branches");const u=await c.json();t(u.branches||[])}catch(c){LT.warn("Failed to fetch branches:",c)}finally{r(!1)}},[]),a=f.useCallback(async c=>{try{s(!0);const u=await fetch("/api/git/switch-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branchName:c})});if(!u.ok){const h=await u.json();throw new Error(h.details||h.error||"Failed to switch branch")}return!0}catch(u){throw LT.warn(`Failed to switch to branch ${c}:`,u),u}finally{s(!1)}},[]);return f.useEffect(()=>{o()},[o]),{branches:e,isLoading:n,isSwitching:i,fetchBranches:o,switchToBranch:a}},d2e=({branch:e})=>y.jsxs(kk,{children:[y.jsx(Ck,{asChild:!0,children:y.jsxs(ja,{value:e,"data-branch":e,className:el("flex w-full cursor-pointer items-center justify-between rounded-md border border-transparent px-2 py-1.5 text-left text-sm outline-none transition-colors","text-content-subtle hover:bg-main-hover hover:text-content data-[highlighted]:border-primary-border data-[highlighted]:bg-main-hover data-[highlighted]:text-content","data-[state=checked]:bg-transparent"),children:[y.jsx(xd,{children:y.jsx("span",{className:"block max-w-[200px] truncate pr-4",children:e})}),y.jsx(ip,{className:"ml-auto",children:y.jsx(za,{className:"h-4 w-4 flex-shrink-0 text-content-subtle",weight:"bold"})})]})}),y.jsx(Ek,{children:y.jsxs(Sk,{className:"z-50 max-w-[300px] break-all rounded bg-main-input px-3 py-1.5 text-xs text-content shadow-lg",side:"right",sideOffset:8,children:[e,y.jsx(wV,{className:"fill-main-input"})]})})]}),f2e=({currentBranch:e,onSwitch:t})=>{const n=xs(),{branches:r,isSwitching:i,switchToBranch:s}=u2e(),[o,a]=f.useState(!1),[c,u]=f.useState(""),h=f.useCallback(g=>{a(g),g&&(n==null||n.capture("git_branch_picker_opened",{current_branch:e,branch_count:r.length}))},[n,e,r.length]);f.useEffect(()=>{o||u("")},[o]);const p=r.filter(g=>g.toLowerCase().includes(c.toLowerCase())),m=f.useCallback(async g=>{if(g!==e)try{await s(g),n==null||n.capture("git_branch_switched",{from_branch:e,to_branch:g}),lt.success(`Switched to branch: ${g}`),t==null||t(g)}catch(b){const x=b instanceof Error?b.message:"Unknown error";n==null||n.capture("git_branch_switch_failed",{from_branch:e,to_branch:g,error:x}),lt.error(`Failed to switch branch: ${x}`)}},[e,s,t,n]);return f.useEffect(()=>{if(!o)return;const g=requestAnimationFrame(()=>{setTimeout(()=>{const b=document.querySelector(`[data-branch="${e}"]`);b instanceof HTMLElement&&b.scrollIntoView({block:"center",behavior:"auto"})},50)});return()=>cancelAnimationFrame(g)},[e,o]),y.jsx(xV,{delayDuration:300,children:y.jsxs(Ev,{open:o,onOpenChange:h,value:e,onValueChange:m,children:[y.jsxs(kk,{children:[y.jsx(Ck,{asChild:!0,children:y.jsx(Sv,{asChild:!0,children:y.jsxs("button",{className:el("flex min-w-0 max-w-[180px] items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors","text-content hover:bg-main-hover","border border-transparent hover:border-main-border",i&&"cursor-not-allowed opacity-50"),disabled:i,children:[y.jsx(wh,{className:"h-3.5 w-3.5 flex-shrink-0 text-content-subtle",weight:"bold"}),y.jsx("span",{className:"truncate",children:e}),y.jsx(Ba,{className:"h-3.5 w-3.5 flex-shrink-0 text-content-subtle opacity-50",weight:"bold"})]})})}),y.jsx(Ek,{children:y.jsxs(Sk,{className:"z-50 max-w-[300px] break-all rounded bg-main-input px-3 py-1.5 text-xs text-content shadow-lg",sideOffset:5,children:[e,y.jsx(wV,{className:"fill-main-input"})]})})]}),y.jsx(Pj,{align:"start",onCloseAutoFocus:g=>g.preventDefault(),header:y.jsx("div",{className:"sticky top-0 border-b-[1px] border-divider bg-main p-2",children:y.jsx("div",{className:"flex items-center gap-2",children:y.jsxs("div",{className:"relative flex-1",children:[y.jsx(a8,{className:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-content-subtle",size:14,weight:"bold"}),y.jsx("input",{type:"text",placeholder:"Search branches...",className:"w-full rounded bg-main-input py-1.5 pl-8 pr-2 text-xs text-content placeholder-content-subtle outline-none focus:outline-none",value:c,onChange:g=>u(g.target.value),autoFocus:!0})]})})}),children:p.length===0?y.jsx("div",{className:"px-2 py-4 text-center text-sm text-content-subtle",children:"No branches found"}):p.map(g=>y.jsx(d2e,{branch:g},g))})]})})};var Ov="Dialog",[kV]=ws(Ov),[h2e,Ss]=kV(Ov),Lp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=f.useRef(null),c=f.useRef(null),[u,h]=ys({prop:r,defaultProp:i??!1,onChange:s,caller:Ov});return y.jsx(h2e,{scope:t,triggerRef:a,contentRef:c,contentId:Zi(),titleId:Zi(),descriptionId:Zi(),open:u,onOpenChange:h,onOpenToggle:f.useCallback(()=>h(p=>!p),[h]),modal:o,children:n})};Lp.displayName=Ov;var CV="DialogTrigger",p2e=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(CV,n),s=Qt(t,i.triggerRef);return y.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Ak(i.open),...r,ref:s,onClick:dt(e.onClick,i.onOpenToggle)})});p2e.displayName=CV;var _k="DialogPortal",[m2e,EV]=kV(_k,{forceMount:void 0}),jp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Ss(_k,t);return y.jsx(m2e,{scope:t,forceMount:n,children:f.Children.map(r,o=>y.jsx(ks,{present:n||s.open,children:y.jsx(Ip,{asChild:!0,container:i,children:o})}))})};jp.displayName=_k;var R1="DialogOverlay",Fp=f.forwardRef((e,t)=>{const n=EV(R1,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Ss(R1,e.__scopeDialog);return s.modal?y.jsx(ks,{present:r||s.open,children:y.jsx(v2e,{...i,ref:t})}):null});Fp.displayName=R1;var g2e=vd("DialogOverlay.RemoveScroll"),v2e=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(R1,n),s=qfe(),o=Qt(t,s);return y.jsx(yv,{as:g2e,allowPinchZoom:!0,shards:[i.contentRef],children:y.jsx(Et.div,{"data-state":Ak(i.open),...r,ref:o,style:{pointerEvents:"auto",...r.style}})})}),Ed="DialogContent",Op=f.forwardRef((e,t)=>{const n=EV(Ed,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Ss(Ed,e.__scopeDialog);return y.jsx(ks,{present:r||s.open,children:s.modal?y.jsx(y2e,{...i,ref:t}):y.jsx(b2e,{...i,ref:t})})});Op.displayName=Ed;var y2e=f.forwardRef((e,t)=>{const n=Ss(Ed,e.__scopeDialog),r=f.useRef(null),i=Qt(t,n.contentRef,r);return f.useEffect(()=>{const s=r.current;if(s)return Z3(s)},[]),y.jsx(SV,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:dt(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:dt(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:dt(e.onFocusOutside,s=>s.preventDefault())})}),b2e=f.forwardRef((e,t)=>{const n=Ss(Ed,e.__scopeDialog),r=f.useRef(!1),i=f.useRef(!1);return y.jsx(SV,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),SV=f.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Ss(Ed,n);return R3(),y.jsx(y.Fragment,{children:y.jsx(dv,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:y.jsx(Tp,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ak(a.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),_V="DialogTitle",Sd=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(_V,n);return y.jsx(Et.h2,{id:i.titleId,...r,ref:t})});Sd.displayName=_V;var AV="DialogDescription",x2e=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(AV,n);return y.jsx(Et.p,{id:i.descriptionId,...r,ref:t})});x2e.displayName=AV;var TV="DialogClose",Vv=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(TV,n);return y.jsx(Et.button,{type:"button",...r,ref:t,onClick:dt(e.onClick,()=>i.onOpenChange(!1))})});Vv.displayName=TV;function Ak(e){return e?"open":"closed"}const Vm=$t("useCommit"),w2e=()=>{const[e,t]=f.useState(!1),[n,r]=f.useState(!1),i=f.useCallback(async()=>{r(!0);try{const o=await fetch("/api/git/generate-commit-message");if(!o.ok){const c=await o.json();throw new Error(c.error||`HTTP ${o.status}`)}return(await o.json()).message}catch(o){return Vm.warn("Failed to generate commit message:",o),null}finally{r(!1)}},[]);return{commit:f.useCallback(async(o,a=!1)=>{t(!0);try{const c=await fetch("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:o,push:a})}),u=await c.json();if(!c.ok&&u.sha)return Vm.warn("Commit succeeded but push failed:",u.details),{sha:u.sha,pushed:!1,pushError:u.details||u.error};if(!c.ok)throw new Error(u.details||u.error||`HTTP ${c.status}`);return Vm.info("Committed successfully:",u.sha),{sha:u.sha,pushed:!!u.pushed}}catch(c){throw Vm.warn("Failed to commit:",c),c}finally{t(!1)}},[]),generateMessage:i,isCommitting:e,isGenerating:n}},k2e=$t("CommitModal"),C2e=({isOpen:e,onClose:t,onCommitted:n})=>{const r=xs(),{commit:i,generateMessage:s,isCommitting:o,isGenerating:a}=w2e(),[c,u]=f.useState(""),[h,p]=f.useState(null);f.useEffect(()=>{e&&(u(""),s().then(b=>{b&&u(b)}))},[e,s]);const m=f.useCallback(async(b=!1)=>{if(c.trim()){p(b?"push":"commit");try{const x=await i(c.trim(),b);r==null||r.capture("git_commit",{has_push:b,is_pushed:x.pushed,has_push_error:!!x.pushError,message_length:c.trim().length}),n(),t(),x.pushError&<.error("Commit succeeded but push failed",{description:x.pushError})}catch(x){r==null||r.capture("git_commit_failed",{has_push:b,error:x instanceof Error?x.message:"unknown"}),k2e.error("Commit failed:",x),lt.error("Commit failed",{description:x instanceof Error?x.message:"Failed to commit"})}finally{p(null)}}},[i,c,n,t,r]),g=f.useCallback(b=>{b.key==="Enter"&&b.metaKey&&(b.preventDefault(),m(!b.shiftKey))},[m]);return y.jsx(Lp,{open:e,onOpenChange:b=>!b&&t(),children:y.jsxs(jp,{children:[y.jsx(Fp,{className:"fixed inset-0 z-max bg-black/40"}),y.jsx(Op,{className:"fixed left-1/2 top-1/2 z-max w-[420px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx(Sd,{className:"text-lg font-semibold text-content",children:"Commit Changes"}),y.jsx(Vv,{asChild:!0,children:y.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",children:y.jsx(Ho,{className:"h-4 w-4",weight:"bold"})})})]}),y.jsxs("div",{className:"relative",children:[y.jsx("textarea",{value:c,onChange:b=>u(b.target.value),onKeyDown:g,placeholder:a?"Generating message...":"Enter commit message",disabled:a,rows:3,className:"w-full resize-none rounded-md bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),a?y.jsx("div",{className:"absolute right-3 top-2.5",children:y.jsx(Ua,{className:"h-4 w-4 animate-spin text-content-subtle",weight:"bold"})}):null]}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx("button",{onClick:()=>m(!1),disabled:o||a||!c.trim(),className:"flex flex-1 items-center justify-center gap-1.5 rounded-md border border-divider px-3 py-2 text-xs text-white transition-colors hover:bg-main-hover disabled:opacity-50",children:h==="commit"?"Committing...":"Commit"}),y.jsx("button",{onClick:()=>m(!0),disabled:o||a||!c.trim(),className:"flex flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:h==="push"?"Committing...":"Commit & Push"})]})]})})]})})},jT=$t("CreateBranchModal"),E2e=({isOpen:e,onClose:t,onCreated:n})=>{const r=xs(),[i,s]=f.useState(""),[o,a]=f.useState(!1),[c,u]=f.useState(!1);f.useEffect(()=>{e&&(s(""),a(!0),fetch("/api/git/generate-branch-name").then(m=>{if(!m.ok)throw new Error(`HTTP ${m.status}`);return m.json()}).then(m=>{s(m.branchName)}).catch(m=>{jT.error("Failed to generate branch name:",m),s("rivet/")}).finally(()=>{a(!1)}))},[e]);const h=f.useCallback(async()=>{if(!i.trim()||c||o)return;u(!0);const m=i.trim();try{const g=await fetch("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branchName:m})});if(!g.ok){const b=await g.json();throw new Error(b.details||b.error||`HTTP ${g.status}`)}n(m),t()}catch(g){const b=g instanceof Error?g.message:"Failed to create branch";r==null||r.capture("git_branch_create_failed",{branch:m,error:b}),lt.error("Failed to create branch",{description:b}),jT.error("Failed to create branch:",g)}finally{u(!1)}},[i,c,o,n,t,r]),p=f.useCallback(m=>{m.key==="Enter"&&(m.preventDefault(),h())},[h]);return y.jsx(Lp,{open:e,onOpenChange:m=>!m&&t(),children:y.jsxs(jp,{children:[y.jsx(Fp,{className:"fixed inset-0 z-max bg-black/40"}),y.jsx(Op,{className:"fixed left-1/2 top-1/2 z-max w-[420px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx(Sd,{className:"text-lg font-semibold text-content",children:"Create Branch"}),y.jsx(Vv,{asChild:!0,children:y.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",children:y.jsx(Ho,{className:"h-4 w-4",weight:"bold"})})})]}),y.jsxs("div",{className:"relative",children:[y.jsx("input",{type:"text",value:i,onChange:m=>s(m.target.value),onKeyDown:p,placeholder:o?"Generating name...":"Enter branch name",disabled:o,className:"w-full rounded-md bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),o?y.jsx("div",{className:"absolute right-3 top-2.5",children:y.jsx(Ua,{className:"h-4 w-4 animate-spin text-content-subtle",weight:"bold"})}):null]}),y.jsx("button",{onClick:h,disabled:c||o||!i.trim(),className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:c?"Creating...":"Create"})]})})]})})},S2e=({prUrl:e,branchName:t,isOpen:n,isLoading:r=!1,onClose:i})=>{const s=xs(),o=f.useCallback(a=>{a.key!=="Enter"||a.repeat||r||(a.preventDefault(),e&&(s==null||s.capture("git_pr_link_clicked",{branch:t,pr_url:e,source:"keyboard"}),window.open(e,"_blank","noopener,noreferrer")))},[r,e,s,t]);return f.useEffect(()=>{if(n)return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n,o]),y.jsx(Lp,{open:n,onOpenChange:a=>!a&&i(),children:y.jsxs(jp,{children:[y.jsx(Fp,{className:"fixed inset-0 z-max bg-black/40"}),y.jsxs(Op,{className:"fixed left-1/2 top-1/2 z-max w-[380px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:[r?y.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[y.jsx(Ua,{className:"h-6 w-6 animate-spin text-primary",weight:"bold"}),y.jsx(Sd,{className:"text-sm font-medium text-content",children:"Creating pull request..."})]}):null,r?null:y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx(Sd,{className:"whitespace-nowrap text-sm font-semibold text-content",children:"Created Pull Request"}),t?y.jsxs("span",{className:"inline-flex max-w-[180px] shrink-0 items-center gap-1 rounded-md bg-main-input px-2 py-0.5 text-xs text-content-muted",children:[y.jsx(wh,{className:"h-3 w-3 shrink-0",weight:"bold"}),y.jsx("span",{className:"truncate",children:t})]}):null]}),y.jsxs("a",{href:e??"#",target:"_blank",rel:"noopener noreferrer",onClick:()=>{s==null||s.capture("git_pr_link_clicked",{branch:t,pr_url:e,source:"button"})},className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover",children:["View PR",y.jsx(i8,{className:"h-3 w-3",weight:"bold"})]})]})]})]})})},PV=({primaryLabel:e,primaryIcon:t,primaryAction:n,isDisabled:r=!1,isLoading:i=!1,loadingLabel:s,dropdownItems:o})=>{const[a,c]=f.useState(!1),u=i?s??e:e;return y.jsxs("div",{className:"flex items-stretch",children:[y.jsxs("button",{onClick:n,disabled:r||i,className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-l-md bg-main-hover px-3 text-xs font-medium text-white transition-colors hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:[t?y.jsx(t,{className:"h-3.5 w-3.5",weight:"bold"}):null,u]}),y.jsxs(Fo,{open:a,onOpenChange:c,children:[y.jsx(ul,{asChild:!0,children:y.jsx("button",{disabled:i,className:"h-7 flex-shrink-0 rounded-r-md border-l border-white/20 bg-main-hover px-1.5 text-white transition-colors hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:y.jsx(Ba,{className:"h-3.5 w-3.5",weight:"bold"})})}),y.jsx(Oo,{children:y.jsx(Vo,{className:"z-[60] min-w-[140px] rounded-lg border border-divider bg-main p-1 shadow-lg",sideOffset:5,align:"end",children:o.map(h=>{const p=h.icon;return y.jsxs("button",{onClick:()=>{h.isDisabled||(h.onClick(),c(!1))},disabled:h.isDisabled,className:"flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:[p?y.jsx(p,{className:"h-3.5 w-3.5",weight:"bold"}):null,h.label]},h.label)})})})]})]})},_2e=f.createContext(null);function A2e(e){switch(e){case"top":return{y:4};case"bottom":return{y:-4};case"left":return{x:4};case"right":return{x:-4}}}function Tk({content:e,children:t,side:n="top",sideOffset:r=8,delayDuration:i=200,className:s,forceOpen:o,onOpenChange:a}){const[c,u]=f.useState(!1),h=o!==void 0?o:c,[p,m]=f.useState(!1),g=Md(),b=f.useContext(_2e);f.useEffect(()=>{h&&m(!0)},[h]);const x=()=>{h||m(!1)},C=A2e(n);return y.jsx(xV,{delayDuration:i,children:y.jsxs(kk,{open:h,onOpenChange:w=>{u(w),a==null||a(w)},children:[y.jsx(Ck,{asChild:!0,children:t}),p&&y.jsx(Ek,{forceMount:!0,container:b??void 0,children:y.jsx(Sk,{side:n,sideOffset:r,forceMount:!0,className:"z-tooltip",children:y.jsx(dn.div,{className:zn("bg-neutral-900 text-white text-[12px] px-2 py-1 border border-white/10 shadow-lg",g.bg,s),style:{fontVariationSettings:Ih.medium},initial:{opacity:0,scale:.8,...C},animate:{opacity:h?1:0,scale:h?1:.9,x:0,y:0},transition:h?{type:"spring",duration:.34,bounce:.55}:{duration:.1},onAnimationComplete:x,children:e})})})]})})}const Ys=({label:e,children:t,side:n="top",sideOffset:r=8,delayDuration:i=300,disabled:s=!1})=>s?y.jsx(y.Fragment,{children:t}):y.jsx(Tk,{content:e,side:n,sideOffset:r,delayDuration:i,children:t}),yx=$t("GitHome"),T2e=({onClose:e})=>e?y.jsx("div",{className:"z-10 flex h-10 flex-shrink-0 items-center border-b border-main-border bg-main-light px-3",children:y.jsx(Ys,{label:"Close chat",side:"bottom",children:y.jsx("button",{onClick:e,className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:y.jsx(Ug,{className:"h-4 w-4",weight:"bold"})})})}):null,P2e=({onUndo:e,isUndoing:t=!1,onClose:n})=>{const r=xs(),s=Ce(Ti).branchDiff.isEnabled,{status:o,fetchStatus:a}=J1(),{stats:c}=uV(),{publishChanges:u,isPublishing:h}=Zye(),{pushCommits:p,isPushing:m}=Wye(),[g,b]=f.useState(!1),[x,C]=f.useState(!1),[w,E]=f.useState(!1),[_,T]=f.useState(null),[I,P]=f.useState(null),M=(o==null?void 0:o.branchName)??null,S=(o==null?void 0:o.hasUncommittedChanges)??!1,R=c.totalInsertions>0||c.totalDeletions>0,$=(o==null?void 0:o.canUndo)??!1,L=(o==null?void 0:o.prUrl)??null,j=f.useCallback((je,Ae,Le,tt)=>{je==="success"?lt.success(Ae,{description:Le,action:tt?{label:tt.label,onClick:tt.onClick}:void 0}):je==="info"?lt.info(Ae,{description:Le}):(Le&&yx.error(`${Ae}:`,Le),lt.error(Ae))},[]),O=f.useCallback(async()=>{r==null||r.capture("git_pr_create_started",{branch:M}),E(!0),T(null);let je=!1;const Le=await u((tt,vt,Je)=>{tt==="error"&&(je=!0,r==null||r.capture("git_pr_create_failed",{branch:M,error:Je??vt}),yx.error("Failed to create PR:",Je??vt),E(!1),lt.error("Failed to create PR",{description:Je??vt}))});Le!=null&&Le.prUrl?(r==null||r.capture("git_pr_created",{branch:Le.branchName,pr_url:Le.prUrl}),T(Le.prUrl),P(Le.branchName),a()):je||(r==null||r.capture("git_pr_create_failed",{branch:M,error:"unknown"}),yx.error("Failed to create PR: unknown error"),E(!1),lt.error("Failed to create PR",{description:"Something went wrong creating the pull request."}))},[u,a,r,M]),H=f.useCallback(async()=>{r==null||r.capture("git_push_started",{branch:M});const{success:je,error:Ae}=await p();je?(r==null||r.capture("git_push_succeeded",{branch:M}),j("success","Changes pushed to GitHub")):(r==null||r.capture("git_push_failed",{branch:M,error:Ae}),j("error","Failed to push",Ae??void 0))},[p,j,r,M]),B=f.useCallback(()=>{L&&(r==null||r.capture("git_pr_opened",{branch:M,pr_url:L}),window.open(L,"_blank","noopener,noreferrer"))},[L,r,M]),Z=f.useCallback(()=>{a(),lt.success("Changes committed")},[a]),K=f.useCallback(je=>{r==null||r.capture("git_branch_created",{branch:je,from_branch:M}),a(),lt.success("Branch created")},[a,r,M]),q=f.useCallback(()=>{r==null||r.capture("git_commit_modal_opened",{branch:M}),b(!0)},[r,M]),te=f.useCallback(()=>{r==null||r.capture("git_create_branch_modal_opened",{branch:M}),C(!0)},[r,M]),F=f.useCallback(()=>{r==null||r.capture("git_undo_commit",{branch:M}),e==null||e(j)},[r,M,e,j]),V=S,W=!!L,N=M==="main"&&!V&&!W,z=W?"Go to PR":"Create PR",Q=W?i8:CS,J=W?B:O,re=!W&&!R;let G=V?"Commit":z,X=V?kS:Q,de=V?q:J,ve=V?!1:re;N&&(G="New Branch",X=wh,de=te,ve=!1);const we=V?[{label:"Undo Commit",icon:Bh,onClick:F,isDisabled:t||!$},{label:"Push Commits",icon:wS,onClick:H,isDisabled:m||!R},{label:z,icon:Q,onClick:J,isDisabled:h||re},{label:"Create New Branch",icon:wh,onClick:te}]:[{label:"Undo Commit",icon:Bh,onClick:F,isDisabled:t||!$},{label:"Push Commits",icon:wS,onClick:H,isDisabled:m||!R},...N?[{label:"Create PR",icon:CS,onClick:O,isDisabled:!0}]:[{label:"Commit",icon:kS,onClick:q,isDisabled:!S},{label:"Create Branch",icon:wh,onClick:te}]];return M?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"z-10 flex h-10 flex-shrink-0 items-center justify-between border-b border-main-border bg-main-light px-3",children:[n&&y.jsxs(y.Fragment,{children:[y.jsx("button",{onClick:n,title:"Close panel",className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:y.jsx(Ug,{className:"h-4 w-4",weight:"bold"})}),y.jsx("div",{className:"mx-1 h-4 w-[1px] flex-shrink-0 bg-divider/20"})]}),y.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 pr-2",children:[y.jsx(f2e,{currentBranch:M,onSwitch:()=>{a()}}),s&&R&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-4 w-[1px] flex-shrink-0 bg-divider/20"}),y.jsx(qye,{})]})]}),y.jsx(PV,{primaryLabel:G,primaryIcon:X,primaryAction:de,isDisabled:ve,isLoading:!1,loadingLabel:"Creating PR...",dropdownItems:we})]}),y.jsx(C2e,{isOpen:g,onClose:()=>b(!1),onCommitted:Z}),y.jsx(E2e,{isOpen:x,onClose:()=>C(!1),onCreated:K}),y.jsx(S2e,{prUrl:_,branchName:I??void 0,isOpen:w,isLoading:h,onClose:()=>E(!1)})]}):n?y.jsx("div",{className:"z-10 flex h-10 flex-shrink-0 items-center border-b border-main-border bg-main-light px-3",children:y.jsx("button",{onClick:n,title:"Close panel",className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:y.jsx(Ug,{className:"h-4 w-4",weight:"bold"})})}):null},I2e=e=>{const t=Ce(C$),r=Ce(Ti).gitUi.isEnabled;return!t||!r?y.jsx(T2e,{onClose:e.onClose}):y.jsx(P2e,{...e})},M2e=$t("SupportTicketModal"),FT=5e3,bx="feedback",R2e=e=>{var r;if(!e)return null;const t=(r=e.formErrors)==null?void 0:r[0];if(t)return t;const n=e.fieldErrors??{};for(const i of Object.values(n)){const s=i==null?void 0:i[0];if(s)return s}return null},$2e=async e=>{let t;try{t=await e.json()}catch{t=void 0}if(e.status===400){if(typeof(t==null?void 0:t.details)=="string"&&t.details.trim())return t.details;if(typeof(t==null?void 0:t.details)=="object"&&t.details!==null){const n=R2e(t.details);if(n)return n}return"Please check your feedback and try again."}return e.status>=500?typeof(t==null?void 0:t.details)=="string"&&t.details.trim()?t.details:"Could not send feedback right now. Please try again later.":typeof(t==null?void 0:t.error)=="string"&&t.error.trim()?t.error:`HTTP ${e.status}`},D2e=({isOpen:e,onClose:t,contactEmail:n})=>{const r=xs(),[i,s]=f.useState(""),[o,a]=f.useState(!1),c=f.useCallback(()=>{s("")},[]),u=f.useCallback(()=>{o||(c(),t())},[o,t,c]),h=f.useCallback(async()=>{const b=i.trim();if(!(!b||o)){a(!0);try{const x=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,C=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,w=n==null?void 0:n.trim(),E=await fetch("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:bx,message:b,contactEmail:w||void 0,metadata:{posthogSessionId:x??void 0,posthogDistinctId:C??void 0,appVersion:"0.11.3",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!E.ok){const _=await $2e(E);throw new Error(_)}r==null||r.capture("support_ticket_submitted",{ticket_type:bx,has_posthog_session_id:!!x}),lt.success("Feedback sent",{description:"Thanks for sharing this."}),c(),t()}catch(x){const C=x instanceof Error?x.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:bx,error:C}),M2e.error("Failed to submit support ticket:",C),lt.error("Could not send feedback",{description:C})}finally{a(!1)}}},[n,o,i,t,r,c]),p=f.useCallback(b=>{b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),h())},[h]),m=FT-i.length,g=o||i.trim().length===0;return y.jsx(Lp,{open:e,onOpenChange:b=>!b&&u(),children:y.jsxs(jp,{children:[y.jsx(Fp,{className:"fixed inset-0 z-max bg-black/40"}),y.jsx(Op,{className:"fixed left-1/2 top-1/2 z-max w-[480px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx(Sd,{className:"text-lg font-semibold text-content",children:"Send feedback"}),y.jsx(Vv,{asChild:!0,children:y.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",disabled:o,children:y.jsx(Ho,{className:"h-4 w-4",weight:"bold"})})})]}),y.jsx("p",{className:"text-sm text-content-subtle",children:"Tell us what happened or what we can improve."}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("label",{htmlFor:"support-ticket-message",className:"text-xs font-medium text-content-muted",children:"Your feedback"}),y.jsx("textarea",{id:"support-ticket-message",value:i,onChange:b=>s(b.target.value),onKeyDown:p,maxLength:FT,rows:7,disabled:o,placeholder:"What happened?",className:"w-full resize-none rounded-md border border-divider bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),y.jsxs("div",{className:"flex justify-between text-xs text-content-subtle",children:[y.jsx("span",{children:"Context details are included automatically."}),y.jsx("span",{children:m})]})]}),y.jsx("button",{onClick:h,disabled:g,className:"flex w-full items-center justify-center gap-2 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:o?y.jsxs(y.Fragment,{children:[y.jsx(Ua,{className:"h-4 w-4 animate-spin",weight:"bold"}),y.jsx("span",{children:"Sending..."})]}):y.jsx("span",{children:"Send feedback"})})]})})]})})},N2e=$t("ProfileAvatar"),L2e=(e,t)=>{const n=(e??"").trim();if(n){const i=n.split(/\s+/).filter(Boolean);return i.length>=2?(i[0][0]+i[i.length-1][0]).toUpperCase():i[0].slice(0,2).toUpperCase()}const r=(t??"").split("@")[0]??"";if(r){const i=r.split(/[._\-+]/).filter(Boolean);return i.length>=2?(i[0][0]+i[1][0]).toUpperCase():r.slice(0,2).toUpperCase()}return""},j2e=({className:e=""})=>{const{name:t,email:n}=Ce(v$),[r,i]=f.useState(!1),[s,o]=f.useState(!1),[a,c]=f.useState(!1),u=L2e(t,n);if(!u)return null;const h=(t==null?void 0:t.trim())||null,p=(n==null?void 0:n.trim())||null,m=async()=>{c(!0);try{const g=await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!g.ok)throw new Error(`Logout failed: ${g.status}`)}catch(g){N2e.warn("Logout request failed",g),lt.error("Could not log out. Please try again."),c(!1);return}window.location.reload()};return y.jsxs(y.Fragment,{children:[y.jsxs(Fo,{open:r,onOpenChange:i,children:[y.jsx(ul,{asChild:!0,children:y.jsx("button",{type:"button","aria-label":"Account",className:`flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full border border-main-border bg-main-input text-[10px] font-semibold leading-none text-content-muted transition-colors hover:text-content ${e}`,children:u})}),y.jsx(Oo,{children:y.jsxs(Vo,{className:"z-[60] min-w-[180px] rounded-lg border border-divider bg-main p-1 shadow-lg",sideOffset:6,align:"end",children:[h||p?y.jsxs("div",{className:"border-b border-main-border px-3 py-2",children:[h?y.jsx("div",{className:"truncate text-xs font-medium text-content",children:h}):null,p?y.jsx("div",{className:"truncate text-[11px] text-content-muted",children:p}):null]}):null,y.jsxs("button",{type:"button",onClick:()=>{i(!1),o(!0)},className:"mt-1 flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input",children:[y.jsx(o8,{className:"h-3.5 w-3.5",weight:"bold"}),"Support & feedback"]}),y.jsxs("button",{type:"button",onClick:m,disabled:a,className:"mt-1 flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:[y.jsx(hG,{className:"h-3.5 w-3.5",weight:"bold"}),a?"Logging out…":"Log out"]})]})})]}),y.jsx(D2e,{isOpen:s,onClose:()=>o(!1),contactEmail:n??void 0})]})},Wt=$t("ElementInspector"),F2e=({chatMessages:e,setChatMessages:t,onClose:n})=>{const[r,i]=Bn(Js),s=Ce(Pd),[o]=Bn(K1),{undoLastChange:a,isUndoing:c}=Yie(),{status:u,fetchStatus:h}=J1(),m=Ce(Ti).gitUi.isEnabled,g=m?(u==null?void 0:u.canUndo)??!1:!1,b=f.useCallback(async()=>{if(!s||!r)return;await new Promise(E=>requestAnimationFrame(E)),Wt.debug("Refreshing element styles for:",r.tagName);const w=await s.reSelectElement(OD(r));if(w){s.setCurrentElement(w);const E=s.getComputedStyles();s.showSelectionOverlay(w),UD("style_refresh"),i({...r,computedStyles:E})}else Wt.warn("Could not find element for refresh:",r.xpath)},[s,r,i]),x=f.useCallback(async()=>{if(!(o!=null&&o.canUndo()))return!1;const w=await o.undo();return w.ok?(await b(),!0):(Wt.error("Failed to undo:",w.error.message),!1)},[o,b]),C=f.useCallback(async w=>{var _;if(!m||!g||!await a((T,I,P)=>{w?w(T,I,P):T==="success"?lt.success(I,{description:P}):T==="info"?lt.message(I,{description:P}):(P&&Wt.error(`${I}:`,P),lt.error(I))}))return!1;if(await h(),(s==null?void 0:s.type)==="iframe"&&"forceReload"in s){Wt.info("Force reloading iframe after git undo");try{await((_=s.forceReload)==null?void 0:_.call(s))}catch(T){return Wt.error("Iframe reload failed, but git undo succeeded:",T),w==null||w("info","Changes reverted successfully","Please refresh the page to see the updated preview"),!0}}return await b(),!0},[b,g,m,a,h,s]);return y.jsxs("div",{className:"relative flex h-full w-96 cursor-auto flex-col overflow-hidden bg-main font-main shadow-2xl scrollbar-hide","data-cy":"element-inspector",children:[y.jsx(j2e,{className:"absolute right-3 top-2 z-20"}),y.jsx(I2e,{onUndo:C,isUndoing:c,onClose:n}),y.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:y.jsx(O2e,{chatMessages:e,setChatMessages:t,handleUndo:x,refreshElementStyles:b,fetchStatus:h})})]})},O2e=({chatMessages:e,setChatMessages:t,handleUndo:n,refreshElementStyles:r,fetchStatus:i})=>{const s=xs(),[o,a]=Bn(Js),c=Ce(Pd),[u,h]=Bn(Hi),p=wc(),m=Ce(kp),g=Ce(ps),b=Ce(Cc),x=Ce(il),C=f.useRef(x);C.current=x;const w=f.useMemo(()=>Lie(u,g),[u,g]),E=f.useMemo(()=>{if(!ah(g))return null;const{sessionId:_e,variantId:Oe}=g;for(const ut of[b==null?void 0:b.left,b==null?void 0:b.right])if(ut&&ut.sessionId===_e&&ut.variantId===Oe)return ut.label;if(x.active){const ut=x.variants.find(gt=>gt.workItemId===Oe);if(ut)return ut.label}return"Direction"},[g,b,x]),_=Ce(V8),[T,I]=Bn(K1);f.useEffect(()=>{if(!c)return;T&&T.destroy();const _e=new FJ(c,_);return I(_e),window.manipulationService=_e,()=>{_e.destroy(),I(null),delete window.manipulationService}},[c,_,I]);const[P,M]=f.useState(null),[S,R]=f.useState(0),$=ze(y$),L=Array.from(u.values()).filter(_e=>_e.status==="pending").length,[j,O]=Bn(QJ),[H,B]=f.useState({}),[Z,K]=f.useState(0),q=f.useRef(null),te=f.useRef(null),F=f.useRef(null),[V,W]=f.useState(0),N=f.useRef({}),z=f.useRef(!1),Q=f.useCallback(_e=>{const Oe=C.current;Oe.active&&Oe.sessionId===_e.sessionId&&DA(_e,Oe.variants,N.current),z.current=!1,F.current=_e,W(ut=>ut+1)},[]),J=f.useCallback(()=>{F.current!==null&&(F.current=null,W(_e=>_e+1))},[]),re=f.useCallback(_e=>{te.current=_e,K(Oe=>Oe+1)},[]),G=f.useCallback(()=>{const _e=te.current;te.current=null,J(),K(Oe=>Oe+1),_e&&(_e.changeIds.length>0&&T&&_e.changeIds.forEach(Oe=>{T.removeTrackedChangeById(Oe)}),_e.commentIds.length>0&&h(Oe=>{if(Oe.size===0)return Oe;const ut=(m==null?void 0:m.current)??null;if(ut){const qt=_e.commentIds.map(St=>Oe.get(St)).filter(St=>St!=null);Hu(ut,qt)}const gt=new Map(Oe);return _e.commentIds.forEach(qt=>{gt.delete(qt)}),gt}))},[T,h,m,J]),X=f.useCallback(()=>{te.current=null,J(),K(_e=>_e+1)},[J]),{modifyWithAgent:de,cancelModification:ve,isModifying:we}=fte(),je=Ce(E$),Ae=Ce(Cp),Le=Ce(X1),tt=Ce(Z8),{sendChanges:vt,sendChatMessage:Je}=nD(),{status:ye,resetStatus:Ke}=Zie(),Dt=f.useMemo(()=>_ie(ye),[ye]),Mt=Ce(U8),{onRoundStarted:jt,onProgressSteps:bn,onAssistantChunk:nn,onRoundCompleted:he,onRoundFailed:be,onRoundCanceled:Ue,getActiveAssistantMessageId:ot,getCancellationMessage:at,setPhase:Ht}=Kie({setChatMessages:t,isMCPSession:Ae}),Ut=Ce(rl),ee=Ut==="comment",Y=Ce(Ti).generativeControls.isEnabled,se=Ce(Lv),ce=Ce(oV),le=ze(cV),ge=ze(lV),ke=f.useMemo(()=>bie(se,ce),[se,ce]),$e=ze(F8),ct=Ce(pc),[rt,Jt]=Bn(O8),wt=!Ae&&Ut!=="edit",De=wt?rt==="directions":Ut!=="edit"&&!(Ae&&Le==="embedded"),{startRound:Nt,resetPhase:At}=zie({mcpStatus:ye,isPublishing:j,isMCPSession:Ae,setIsPublishing:O,fetchStatus:i,refreshElementStyles:r,getActiveAssistantMessageId:ot,onProgressSteps:bn,onRoundCompleted:he,setSessionUxPhase:Ht,clearQueuedPendingSnapshot:G});f.useEffect(()=>{if(!Ae||!j)return;const _e=F.current;if(!_e)return;if(x.active&&x.sessionId===_e.sessionId)z.current=!0;else{if(!z.current)return;X(),O(!1),At(),Ht("idle");const Yt=ot();Yt&&be({assistantMessageId:Yt,error:"Static preview variant refinement was interrupted."});return}const ut=N.current,gt=jie(_e,x.variants,ut);if(gt.status==="pending")return;DA(_e,x.variants,ut);const qt=_e.variantIds.length>1,St=ot();if(gt.status==="succeeded"){G(),O(!1),At(),Ht("idle"),St&&he({assistantMessageId:St,finalMessage:qt?"Static preview variants refined.":"Static preview variant refined."});return}if(X(),O(!1),At(),Ht("idle"),St){let Yt;gt.status==="cancelled"?Yt="Static preview variant refinement was cancelled.":gt.errorCode?Yt=`Static preview variant refinement failed (${gt.errorCode}).`:Yt="Static preview variant refinement failed.",be({assistantMessageId:St,error:Yt})}},[G,X,ot,Ae,j,he,be,At,O,Ht,V,x]),f.useEffect(()=>{o&&(Ae||(q.current=null))},[o==null?void 0:o.xpath,Ae]);const Tt=we||j,on=je,Qn=Mie((o==null?void 0:o.computedStyles)||{});f.useEffect(()=>{var qt,St;if(!o||!c||c.type!=="iframe")return;let _e=!1;const Oe=OD(o),ut=((St=(qt=o.filePaths)==null?void 0:qt[0])==null?void 0:St.filePath)||void 0;return(async()=>{const Yt=await c.reSelectElement(Oe);if(_e||!Yt)return;const rn=Ga();c.injectRivetId(Yt,rn);const Un=c.createElementIdentifier(Yt);Un.rivetId=rn,Un.filePath=ut,M(Un)})(),()=>{_e=!0}},[o,c]);const Vn=Ce(q1);f.useEffect(()=>{if(!T)return;const _e=_.getChangeCount();return R(_e),$(_e),_.onChange(()=>{const ut=_.getChangeCount();R(ut),$(ut)})},[_,T,$]);const Jn=!!o&&!ee;f.useEffect(()=>{var ut;const _e=gt=>{if(!((gt.metaKey||gt.ctrlKey)&>.key.toLowerCase()==="z"&&!gt.shiftKey)||Vn.isEditing)return;const St=document.activeElement;St&&(St.tagName==="INPUT"||St.tagName==="TEXTAREA"||St.tagName==="SELECT"||St.getAttribute("contenteditable")==="true")&&!Jn||(gt.preventDefault(),Wt.debug("Undo shortcut triggered"),s==null||s.capture("undo"),n())},Oe=(ut=m==null?void 0:m.current)==null?void 0:ut.contentDocument;return window.addEventListener("keydown",_e),Oe==null||Oe.addEventListener("keydown",_e),()=>{window.removeEventListener("keydown",_e),Oe==null||Oe.removeEventListener("keydown",_e)}},[Jn,n,Vn.isEditing,m]);const en=_e=>{_e!==Ut&&(s==null||s.capture("inspector_tab_changed",{from_tab:Ut,to_tab:_e})),$e(_e)};J8({shortcuts:[{key:"1",handler:()=>{Wt.debug("Switching to Styles tab (1)"),en("edit")},description:"Switch to Styles tab"},{key:"2",handler:()=>{Wt.debug("Switching to Chat tab (2)"),en("comment")},description:"Switch to Chat tab"},{key:"1",metaKey:!0,handler:()=>{Wt.debug("Switching to Styles tab (Cmd+1)"),en("edit")},description:"Switch to Styles tab"},{key:"1",ctrlKey:!0,handler:()=>{Wt.debug("Switching to Styles tab (Ctrl+1)"),en("edit")},description:"Switch to Styles tab"},{key:"2",metaKey:!0,handler:()=>{Wt.debug("Switching to Chat tab (Cmd+2)"),en("comment")},description:"Switch to Chat tab"},{key:"2",ctrlKey:!0,handler:()=>{Wt.debug("Switching to Chat tab (Ctrl+2)"),en("comment")},description:"Switch to Chat tab"}]});const Mn=f.useCallback(async()=>{var Oe;if(Tt)return;Hte(),Hu((m==null?void 0:m.current)??null,u.values());const _e=p.get(qa);_e&&(await f1(_e.diff),p.set(qa,null));for(const ut of u.values()){const gt=(Oe=ut.finalizedVariant)==null?void 0:Oe.codeDiff;gt&&await f1(gt)}T==null||T.clear(),h(new Map),le()},[Tt,T,h,m,u,p,le]),ci=f.useCallback(async()=>{const Oe=Oie(Ae?u:w,T,ke);if(!Oe)return;X();const{pendingComments:ut,styleChanges:gt,textChanges:qt,pendingSnapshot:St,applyPointers:Yt,hasComments:rn,hasDesignChanges:Un,hasInterfaceChanges:st}=Oe;if(s==null||s.capture("apply",{comment_count:ut.length,design_edit_count:gt.length+qt.length,interface_change_count:Oe.interfaceChanges.length,has_comments:rn,has_design_changes:Un,has_interface_changes:st}),Ae){$e("comment"),Ke(),O(!0),Nt();const sn=Db(Yt),{assistantMessageId:xn}=jt({userMessage:sn,startPhase:"starting"});if(Wt.debug("[MCP] new apply round — asstMsgId:",xn),re(St),!rn&&!Un&&st){const _s=await Je(Mw(ke));if(_s.cancelled)return;_s.success||(X(),lt.error(_s.error||"Failed to send changes"),be({assistantMessageId:xn,error:_s.error||"Failed to send changes"}),O(!1),At());return}const er=await vt();if(er.cancelled)return;if(!er.success){X(),lt.error(er.error||"Failed to send changes"),be({assistantMessageId:xn,error:er.error||"Failed to send changes"}),O(!1),At();return}st&&await Je(Mw(ke)),(er.changeIdsToClear||er.commentIdsToClear)&&re({...St,commentIds:er.commentIdsToClear??St.commentIds,changeIds:er.changeIdsToClear??St.changeIds}),er.staticPreviewVariantIds&&er.staticPreviewVariantIds.length>0&&er.staticPreviewSessionId&&Q({sessionId:er.staticPreviewSessionId,variantIds:er.staticPreviewVariantIds});return}$e("comment"),O(!0);const Zn=Vie(Oe),ln=Hie(Oe),ar=Db(Yt),{assistantMessageId:Pi}=jt({userMessage:ar,startPhase:"applying"});re(St);const io=ut.flatMap(sn=>sn.images??[]),Nr=Bie();Wt.debug("Calling modifyWithAgent");let ui=!1;try{await de({instruction:Zn,elements:Array.from(ln.values()),images:io.length>0?io:void 0,sessionId:q.current??void 0},{onProgress:sn=>{if(Nr.recordActivity(),!sn.startsWith("Agent:")){const xn=sn.match(/^\[([^\]]+)\]/);xn&&Nr.recordToolStart(xn[1])}},onChunk:sn=>{Nr.recordActivity(),Nr.recordReasoningChunk(),nn({content:sn,assistantMessageId:Pi})},onComplete:async sn=>{var Uo;ui=!0;const xn=Nr.finalize();Wt.debug(`modifyWithAgent completed in ${xn.agentExecutionDuration}ms`);const er=NA(sn.changes,sn.filesModified);if(he({assistantMessageId:Pi,finalMessage:er}),sn.sessionId&&(q.current=sn.sessionId),G(),Un){Wt.debug("Refreshing styles and status");try{await r(),await i()}catch(ml){Wt.warn("Style/status refresh failed:",ml)}}rn&&Wt.debug("Sent pending comments were cleared after completion."),st&&le();const _s=Date.now();if((c==null?void 0:c.type)==="iframe"&&"forceReload"in c){Wt.debug("Force reloading iframe");try{await((Uo=c.forceReload)==null?void 0:Uo.call(c))}catch(ml){Wt.warn("Iframe reload failed:",ml)}}const Zd=Date.now();s==null||s.capture("code_modification",{success:!0,source:"apply",instruction_length:Zn.length,element_count:ln.size,modification_time_ms:xn.agentExecutionDuration}),s==null||s.capture("agent_apply_session",{success:!0,env:"production",total_duration_ms:Nr.elapsed(),agent_execution_duration_ms:xn.agentExecutionDuration,tool_execution_duration_ms:xn.totalToolDuration,model_reasoning_duration_ms:xn.agentExecutionDuration-xn.totalToolDuration,time_to_first_message_ms:xn.timeToFirstMessage,post_processing_duration_ms:_s-xn.agentEndTime,iframe_reload_duration_ms:Zd-_s,model:sn.model,tool_counts:xn.toolCounts,total_tool_calls:Object.values(xn.toolCounts).reduce((ml,Wd)=>ml+Wd,0),reasoning_chunk_count:xn.reasoningChunkCount,element_count:ln.size,comment_count:ut.length,design_edit_count:S,instruction_length:Zn.length,session_id:sn.sessionId,server_ttfm_ms:sn.ttfmMs}),O(!1),At()},onError:async sn=>{if(ui=!0,Wt.error("Error in modifyWithAgent:",sn),be({assistantMessageId:Pi,error:sn}),X(),s==null||s.capture("code_modification",{success:!1,source:"apply",instruction_length:Zn.length,element_count:ln.size,error_message:sn}),s==null||s.capture("agent_apply_session",{success:!1,env:"production",total_duration_ms:Nr.elapsed(),error_message:sn,element_count:ln.size,instruction_length:Zn.length}),Un)try{await(T==null?void 0:T.clearInlineChanges())}catch(xn){Wt.warn("Failed to clear inline changes:",xn)}wm(sn)?km(sn):lt.error("Failed to apply changes"),O(!1),At()},onCanceled:()=>{ui=!0,O(!1),At(),X()}})}catch(sn){ui=!0,Wt.error("Unexpected error in handleApplyAll:",sn),X();const xn=sn instanceof Error?sn.message:"An unexpected error occurred";be({assistantMessageId:Pi,error:xn}),wm(xn)?km(xn):lt.error("Failed to apply changes"),O(!1),At()}finally{ui||(Wt.warn("modifyWithAgent returned without triggering onComplete or onError"),X(),be({assistantMessageId:Pi,error:"Agent request failed to initialize or timed out without feedback."}),lt.error("Failed to apply changes"),O(!1),At())}},[w,u,T,c,de,r,i,S,s,Ae,vt,Je,Ke,jt,nn,he,be,$e,Nt,At,O,re,G,X,ke,le,Q]);f.useEffect(()=>{const _e=Oe=>{(Oe.metaKey||Oe.ctrlKey)&&Oe.key==="Enter"&&(ct||(L>0||S>0||ke.length>0)&&!j&&!Tt&&(Oe.preventDefault(),Wt.debug("Apply all shortcut triggered (Cmd/Ctrl+Enter)"),ci()))};return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[L,S,ke,j,Tt,ct,ci]);const Ud=f.useCallback(async(_e,Oe)=>{var qt;if(!T||!P||!c||c.type!=="iframe")return;const gt=((qt=Qn[_e])==null?void 0:qt.type)==="range"?(parseFloat(Oe)/100).toString():Oe;await T.previewStyleChange(P,_e,gt)},[T,P,c,Qn]),Zv=f.useCallback(async(_e,Oe,ut)=>{var rn;const gt=Oe;if(!gt||!T||!P||!o||!c||c.type!=="iframe")return;const St=((rn=Qn[_e])==null?void 0:rn.type)==="range"?(parseFloat(gt)/100).toString():gt,Yt=await T.applyStyleChange(P,o,_e,St,ut);if(Yt.ok){const Un=await c.getComputedStylesForElement(P);Un.ok&&a({...o,computedStyles:Un.value}),B(Zn=>{const ln={...Zn};return delete ln[_e],ln});const st=Rw.find(Zn=>Zn.properties.some(ln=>ln.key===_e));s==null||s.capture("design_property_changed",{property:_e,category:st==null?void 0:st.value})}else Wt.error("Failed to apply style:",Yt.error.message),lt.error("Failed to apply style")},[T,P,o,c,Qn,B,a,s]),Wv=f.useCallback(async _e=>{T&&await T.transaction(_e)},[T]),Gv=(_e,Oe)=>{B(ut=>({...ut,[_e]:Oe}))},no=(_e,Oe)=>{const ut=Oe.replace("%","").trim();if(ut===""){B(St=>({...St,[_e]:""}));return}const gt=parseFloat(ut);if(Number.isNaN(gt))return;const qt=Math.max(0,Math.min(100,gt));B(St=>({...St,[_e]:qt.toString()}))},Hp=_e=>{B(Oe=>{const ut={...Oe};return delete ut[_e],ut})},Bp=f.useCallback(async()=>{if(!T)return;const _e=await T.redo();_e.ok?await r():Wt.error("Failed to redo:",_e.error.message)},[T,r]),qv=f.useCallback(()=>{const _e=at();Ae&&Le==="embedded"&&fetch("/api/agent/stop",{method:"POST",headers:tt?{"x-rivet-queue-token":tt}:void 0}).catch(Oe=>{Wt.warn("Failed to stop embedded agent run:",Oe)}),ve(),O(!1),At(),X(),Ue({cancellationMessage:_e})},[ve,O,At,X,Ue,at,Ae,Le,tt]),zp=f.useCallback(async(_e,Oe)=>{Ke();const ut=Date.now();X();const gt=Array.from(u.values()).filter(ln=>ln.status==="pending"),qt=gt.length>0,St=gt.map(ln=>({id:ln.id,instruction:ln.instruction})),Yt=HD({pendingComments:St,styleChanges:[],textChanges:[],includeComments:qt,includeChanges:!1});s==null||s.capture("chat",{message_length:_e.length,has_images:!!(Oe!=null&&Oe.length),image_count:(Oe==null?void 0:Oe.length)??0,has_pending_comments:qt,pending_comment_count:gt.length,has_selected_element:!!o});const rn=qt?BD(gt):_e,Un=qt?VD(gt,[],[]):[],st=qt&&Un.length>0?Db(Un):_e,{assistantMessageId:Zn}=jt({userMessage:st,images:Oe,startPhase:Ae?"starting":"applying"});Yt.commentIds.length>0&&re(Yt);try{if(Ae){Ke(),O(!0),Nt();const ln=await Je(rn,Oe);if(ln.cancelled)return;ln.success||(X(),be({assistantMessageId:Zn,error:ln.error||"Failed to send to Claude Code"}),O(!1),At())}else if(on){const ln=o?[o]:[];await de({instruction:rn,elements:ln,images:Oe,sessionId:q.current??void 0},{onProgress:()=>{},onChunk:ar=>{nn({content:ar,assistantMessageId:Zn})},onComplete:async({sessionId:ar,changes:Pi,filesModified:io})=>{var ui;const Nr=NA(Pi,io);if(he({assistantMessageId:Zn,finalMessage:Nr}),G(),s==null||s.capture("code_modification",{success:!0,source:"chat",instruction_length:rn.length,element_count:ln.length,modification_time_ms:Date.now()-ut}),ar&&(q.current=ar),qt&&Wt.debug("Sent pending comments were cleared after completion."),(c==null?void 0:c.type)==="iframe"&&"forceReload"in c)try{await((ui=c.forceReload)==null?void 0:ui.call(c))}catch(sn){Wt.warn("Iframe reload after agent modification failed:",sn)}r()},onError:ar=>{X(),be({assistantMessageId:Zn,error:ar}),s==null||s.capture("code_modification",{success:!1,source:"chat",instruction_length:rn.length,element_count:ln.length,error_message:ar,modification_time_ms:Date.now()-ut}),Wt.error("Code modification error details:",ar),wm(ar)?km(ar):lt.error("Code Modification Error")},onCanceled:()=>{O(!1),At(),X()}})}else Wt.error("Chat mode not supported"),lt.error("Chat mode not supported")}catch(ln){Wt.error("Error with streaming request:",ln);const ar=ln instanceof Error?ln.message:"An unexpected error occurred.";X(),O(!1),At(),be({assistantMessageId:Zn,error:ar}),wm(ar)?km(ar):lt.error("Failed to generate AI response")}},[Ke,u,T,s,o,Ae,Je,on,de,c,r,jt,nn,he,be,Nt,At,O,re,G,X]),qi=f.useMemo(()=>{const _e=Array.from(w.values()).filter(st=>st.status==="pending"),Oe=(T==null?void 0:T.getStyleChanges())??[],ut=(T==null?void 0:T.getTextChanges())??[],gt=Oe.map(st=>({id:st.id,key:ac(st),property:String(st.property),newValue:st.newValue,timestamp:st.timestamp})),qt=ut.map(st=>({id:st.id,key:ac(st),oldText:st.oldText,newText:st.newText,timestamp:st.timestamp})),St=Nie(_e.map(st=>({id:st.id,instruction:st.instruction,finalizedVariant:st.finalizedVariant,styleVariants:st.styleVariants,selectedVariantIndex:st.selectedVariantIndex,variantGenerationStatus:st.variantGenerationStatus,requestedVariantCount:st.requestedVariantCount})),gt,qt);for(const st of ke)St.push({id:st.id,kind:"interface",detail:FD(st)});const Yt=te.current;if(!Tt||!Yt)return St;const rn=new Set(Yt.commentIds),Un=new Map;return gt.forEach(st=>{Un.set(st.id,st.key)}),qt.forEach(st=>{Un.set(st.id,st.key)}),Yt.changeIds.forEach(st=>{const Zn=Un.get(st);Zn&&rn.add(Zn)}),St.filter(st=>!rn.has(st.id))},[w,S,T,Tt,Z,ke]),Pc=f.useCallback(async _e=>{if(_e.kind==="interface"){ge({controlId:_e.id,value:void 0});return}if(_e.kind==="comment"){h(qt=>{const St=qt.get(_e.id),Yt=(m==null?void 0:m.current)??null;Yt&&(St==null?void 0:St.previewBaselineStyle)!==void 0&&Hu(Yt,[St]);const rn=new Map(qt);return rn.delete(_e.id),rn});return}if(!T)return;const ut=T.getChanges().find(qt=>ac(qt)===_e.id);if(!ut){Wt.warn("No tracked change for pending row",_e.id);return}const gt=await T.revertSpecificChange(ut);if(!gt.ok){Wt.error("revertSpecificChange failed:",gt.error.message),lt.error("Could not revert change");return}await r()},[T,h,r,m,ge]),ro=Ae?Dt||(j&&(ye==null?void 0:ye.status)!=="APPLYING"?kie:j?wie:null):null,Up=y.jsx(X0e,{chatMessages:e,statusHint:ro,handleChatSend:zp,handleStop:qv,isProcessing:Tt,pendingChangeRows:qi,onRemovePendingChange:Pc,onApplyPendingChanges:ci,onClearPendingChanges:Mn,disableInputWhileProcessing:Le!=="embedded",showModelPicker:Le!=="embedded"}),Kv=y.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center",children:[y.jsx("p",{className:"text-sm text-content-subtle",children:"Select an element to edit, or leave a comment on the page."}),ro&&y.jsx("p",{className:"mt-2 text-xs text-content-subtle",children:ro})]});return(()=>{const _e=Eie({isMCPSession:Ae,isChatOpen:ee,hasSelectedElement:!!o,showDirections:De,hasPendingChanges:qi.length>0,changeCount:S,isPublishing:j,isProcessing:Tt,hasStatusHint:!!ro,shouldUseAgentChat:Le==="embedded"}),Oe=o?y.jsx(lye,{propertyCategories:Rw,formattedComputedStyles:Qn,pendingChanges:H,handlePendingCssChange:Gv,handlePendingPercentageChange:no,applyPropertyChange:Zv,previewPropertyChange:Ud,performTransaction:Wv,handleBlur:Hp},o.xpath):null,ut=Y&&Ut==="edit"?y.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[y.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-hide",children:[y.jsx(Lye,{}),_e.showDesignPanel?Oe:null]}),qi.length>0?y.jsx("div",{className:"flex-shrink-0 border-t border-main-border px-3 py-2",children:y.jsx(n6,{tags:qi,onRemoveTag:Pc,onClearAll:Mn,canClear:!j&&!Tt})}):null,y.jsx(Bye,{})]}):Ut==="edit"&&_e.showDesignPanel&&Oe?Oe:wt?y.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[y.jsx("div",{className:"flex-shrink-0 border-b border-main-border bg-main-light px-2 py-1.5",children:y.jsx(cte,{"aria-label":"Panel view",value:rt,onValueChange:Jt,options:[{value:"chat",label:"Chat","data-cy":"rhs-tab-chat"},{value:"directions",label:"Directions","data-cy":"rhs-tab-directions"}]})}),y.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:rt==="directions"?y.jsx(tA,{}):Up})]}):_e.showChatPanel?Up:_e.showDesignPanel?Oe:De?y.jsx(tA,{}):_e.showMCPEmptyState?Kv:null,gt=qi.length;return y.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[E&&!De?y.jsx("div",{className:"flex flex-shrink-0 items-center border-b border-main-border bg-main-light px-4 py-1.5 text-xs text-content-subtle",children:y.jsxs("span",{className:"truncate",children:["Editing"," ",y.jsx("span",{className:"font-medium text-content",children:E})]})}):null,ut,_e.showExternalPendingChanges&&y.jsx("div",{className:"flex-shrink-0 border-t border-main-border px-4 py-2",children:y.jsx(n6,{tags:qi,onRemoveTag:Pc,onClearAll:Mn,canClear:!j&&!Tt})}),_e.showExternalStatusHint&&ro&&y.jsx("div",{className:`flex-shrink-0 px-4 py-2 ${qi.length===0?"border-t border-main-border":""}`,children:y.jsx("p",{className:"text-center text-xs text-content-subtle",children:ro})}),(_e.showActionBar||Y&&Ut==="edit"&&qi.length>0)&&y.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-t border-main-border bg-main-light px-4 py-3",children:[y.jsxs("div",{className:"flex gap-2",children:[y.jsx("button",{onClick:n,disabled:!(T!=null&&T.canUndo()),className:"rounded p-1.5 text-content transition-colors hover:bg-main-hover disabled:cursor-not-allowed disabled:opacity-30",title:"Undo (Cmd+Z)",children:y.jsx(Bh,{className:"h-4 w-4"})}),y.jsx("button",{onClick:Bp,disabled:!(T!=null&&T.canRedo()),className:"rounded p-1.5 text-content transition-colors hover:bg-main-hover disabled:cursor-not-allowed disabled:opacity-30",title:"Redo (Cmd+Shift+Z)",children:y.jsx(iG,{className:"h-4 w-4"})})]}),y.jsx("button",{onClick:ci,disabled:j||Tt,className:"rounded border border-primary px-3 py-1 text-xs font-medium text-gray-300 hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-30",title:Ae?`Send ${gt||"pending"} changes to ${Mt||"Claude Code"}`:"Apply all pending changes (⌘↵)","data-cy":"inspector-apply-button",children:Sie({isMCPSession:Ae,isApplying:j||Tt,pendingChangeCount:gt})})]})]})})()},V2e=$t("useServerConfig"),H2e=()=>{const[e,t]=f.useState(null),[n,r]=f.useState(!0),[i,s]=f.useState(null),o=f.useCallback(async()=>{var a;try{r(!0),s(null);const c=await fetch("/api/health");if(!c.ok)throw new Error(`Failed to fetch config: ${c.status}`);const u=await c.json();if(!u.framework)throw new Error("Server did not return framework information");const h={userPort:((a=u.ports)==null?void 0:a.userDevServer)||3e3,framework:u.framework};return t(h),h}catch(c){const u=c instanceof Error?c.message:"Failed to fetch server config";throw s(u),V2e.warn("Error fetching server config:",c),c}finally{r(!1)}},[]);return{config:e,fetchConfig:o,isLoading:n,error:i}},B2e="data:image/svg+xml,%3csvg%20width='453'%20height='416'%20viewBox='0%200%20453%20416'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1326_108)'%3e%3cpath%20d='M186.07%2025.5539C186.07%2011.4409%20197.511%200%20211.624%200H335.5C400.393%200%20453%2052.6065%20453%20117.5C453%20182.393%20400.393%20235%20335.5%20235H216.639C199.756%20235%20186.07%20221.314%20186.07%20204.431C186.07%20186.743%20198.071%20169.863%20215.299%20165.853C225.291%20163.528%20238.671%20160.53%20256.58%20156.667C258.587%20156.234%20260.54%20155.796%20262.442%20155.354C307.627%20144.861%20299.146%20103.217%20256.58%2084.7815C234.082%2075.0381%20218.731%2068.1115%20208.265%2063.1881C194.851%2056.8779%20186.07%2040.378%20186.07%2025.5539Z'%20fill='white'/%3e%3cpath%20d='M381.709%20415.715C329.789%20415.715%20287.699%20373.625%20287.699%20321.705V314.306C287.699%20288.346%20308.744%20267.301%20334.704%20267.301C386.624%20267.301%20428.714%20309.391%20428.714%20361.311V368.71C428.714%20394.67%20407.669%20415.715%20381.709%20415.715Z'%20fill='white'/%3e%3cpath%20d='M0%2073.5927C0%2033.1632%2032.7745%200.388672%2073.2039%200.388672C113.633%200.388672%20146.408%2033.1632%20146.408%2073.5926V338.795C146.408%20379.225%20113.633%20411.999%2073.2039%20411.999C32.7745%20411.999%200%20379.225%200%20338.795V73.5927Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1326_108'%3e%3crect%20width='453'%20height='416'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",OT=(e,t)=>y.jsxs("div",{className:"flex flex-row items-center gap-2",children:[y.jsx("span",{children:e}),t?y.jsx("span",{className:"rounded bg-white/15 px-1.5 py-0.5 text-[10px] leading-none font-bold",children:t}):null]}),z2e={type:"spring",duration:.3,bounce:0},U2e=({mode:e,onModeChange:t,isLoading:n=!1,disabled:r=!1})=>{const[i,s]=f.useState(!1),o=Ce(Hi),a=Ce(y$),c=ze(wp),u=Ce(Ti).refineMode.isEnabled,h=e!=="view"||i,m=Array.from(o.values()).filter(b=>b.status==="pending").length+a,g=(b,x,C,w,E)=>{const _=r?"Disconnected":x,T=e===b;return y.jsx(Ys,{label:OT(_,r?void 0:C),disabled:!h,children:y.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),b==="edit"&&c(!0),t(b)},disabled:r,className:`rounded-md p-2 transition-colors ${T?"bg-primary/20 text-primary":"text-content hover:bg-main-input"} ${r?"cursor-not-allowed opacity-50":""}`,"data-cy":E,children:w})})};return y.jsxs(dn.div,{className:"z-ui-primary absolute right-6 bottom-6",initial:{y:100,opacity:0},animate:{y:n?100:0,opacity:n?0:1},transition:{duration:.6,ease:"easeOut",delay:n?0:.3},children:[m>0&&!h&&y.jsx(dn.span,{className:"bg-primary pointer-events-none absolute -top-1 -right-1 z-10 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[9px] leading-none font-bold text-white",animate:{opacity:1},transition:{duration:.15,delay:.2},children:m>9?"9+":m}),y.jsxs(dn.div,{layout:!0,className:`border-primary/30 bg-main overflow-hidden border shadow-lg ${h?"":"cursor-pointer"}`,style:{borderRadius:h?10:9999},transition:z2e,onClick:h?void 0:()=>s(!0),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[y.jsx(dn.div,{className:"absolute flex items-center justify-center",style:{width:40,height:40,top:0,left:0},animate:{opacity:h?0:1},transition:h?{duration:0}:{duration:0,delay:.2},"aria-hidden":h,children:y.jsx("img",{src:B2e,alt:"Rivet",style:{width:16,height:16}})}),!h&&y.jsx("div",{style:{width:40,height:40}}),y.jsxs(dn.div,{className:"flex items-center gap-1 p-2",style:{position:h?"relative":"absolute",inset:0,pointerEvents:h?"auto":"none"},animate:{opacity:h?1:0},transition:h?{duration:0,delay:.22}:{duration:0},children:[g("view","Select","V",y.jsx(aG,{className:"h-5 w-5",weight:"bold"}),"mode-select"),g("comment","Comment","C",y.jsx(o8,{className:"h-5 w-5",weight:"bold"}),"mode-comment"),u?g("edit","Refine","R",y.jsx(mG,{className:"h-5 w-5"}),"mode-design"):null,y.jsx("div",{className:"bg-primary/20 mx-1 h-4 w-px"}),y.jsx(Ys,{label:OT(r?"Disconnected":"Collapse",r?void 0:"X"),disabled:!h,children:y.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),t("view"),s(!1)},disabled:r,"aria-label":"Collapse",className:`text-content hover:bg-main-input rounded-md p-2 transition-colors ${r?"cursor-not-allowed opacity-50":""}`,"data-cy":"mode-view",children:y.jsx(Ho,{className:"h-5 w-5",weight:"bold"})})})]})]})]})},Z2e=async()=>{let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return Hm();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable"};let n;try{n=await e.json()}catch{return Hm()}const r=n.devServerHealth;return r?r.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable"}:r.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable"}:{isOk:!1,unavailableReason:r.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable"}:Hm()},Hm=async()=>{try{const e=await fetch("/");return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable"}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}},VT=$t("usePreviewUpstreamHealth"),W2e=500,G2e=4e3,q2e=15e3,K2e=(e,t={})=>{const n=f.useRef(null),r=f.useRef(null),i=t.probeMsWhileDown??W2e,s=t.probeMsWhileUp??G2e,o=t.firstUnreachableCaptureAfterMs??q2e,a=t.rerunProbeImmediatelyOnVersion,c=t.skip??!1,[u,h]=f.useState(e==="static"),[p,m]=f.useState(0),[g,b]=f.useState(null),[x,C]=f.useState(0),[w,E]=f.useState(!1),[_,T]=f.useState(!1),[I,P]=f.useState(e==="static"?null:"upstream_unreachable");return f.useEffect(()=>{if(e==="static"){h(!0),b(null),C(0),E(!1),T(!0),P(null);return}if(c){h(!1),b(null),C(0),E(!1),T(!0),P("upstream_unreachable"),n.current=null;return}let M=!0;const S=Date.now();b(S),C(0),E(!1),h(!1),T(!1),P("upstream_unreachable");const R={current:!1},$={current:!1},L={current:!1},j={current:null},O={current:!1};let H=null;const B=()=>{L.current||(L.current=!0,M&&T(!0))},Z=()=>{H!==null&&(clearTimeout(H),H=null)},K=(te,F)=>{Z(),H=setTimeout(F,te)},q=async()=>{if(!M)return;C(N=>N+1);const{isOk:te,unavailableReason:F}=await Z2e();if(!M)return;if(B(),te){const N=!O.current;O.current=!0,h(!0),P(null),j.current=null,$.current=!1,E(!1),R.current?N&&(yt==null||yt.capture("preview_upstream_restored",{framework:e})):(R.current=!0,yt==null||yt.capture("preview_dev_server_ready",{framework:e,ready_after_ms:Date.now()-S})),K(s,q);return}const V=O.current;O.current=!1,h(!1),P(F),j.current===null&&(j.current=Date.now(),$.current=!1,E(!1)),V&&(yt==null||yt.capture("preview_upstream_lost",{framework:e}),m(N=>N+1),VT.warn("Preview upstream became unavailable after it was ready"));const W=Date.now()-j.current;W>=o&&!$.current&&($.current=!0,E(!0),yt==null||yt.capture("preview_dev_server_unreachable",{framework:e,elapsed_ms:W}),VT.warn("Dev server did not become ready within timeout window")),K(i,q)};return n.current=()=>K(0,q),K(0,q),()=>{M=!1,n.current=null,Z()}},[e,i,s,o,c]),f.useEffect(()=>{var S;if(e==="static"||a===void 0)return;const M=r.current;r.current=a,M!==null&&M!==a&&((S=n.current)==null||S.call(n))},[e,a]),{isUpstreamReady:u,iframeRemountKey:p,probeStartedAt:g,probeAttemptCount:x,isFirstUnreachableWindowExceeded:w,initialProbeComplete:_,unavailableReason:I}};function Y2e(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const X2e=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Va(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let gu=null;function IV(e={}){return gu||(e.includeStyleProperties?(gu=e.includeStyleProperties,gu):(gu=Va(window.getComputedStyle(document.documentElement)),gu))}function $1(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Q2e(e){const t=$1(e,"border-left-width"),n=$1(e,"border-right-width");return e.clientWidth+t+n}function J2e(e){const t=$1(e,"border-top-width"),n=$1(e,"border-bottom-width");return e.clientHeight+t+n}function MV(e,t={}){const n=t.width||Q2e(e),r=t.height||J2e(e);return{width:n,height:r}}function ebe(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const gi=16384;function tbe(e){(e.width>gi||e.height>gi)&&(e.width>gi&&e.height>gi?e.width>e.height?(e.height*=gi/e.width,e.width=gi):(e.width*=gi/e.height,e.height=gi):e.width>gi?(e.height*=gi/e.width,e.width=gi):(e.width*=gi/e.height,e.height=gi))}function D1(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function nbe(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function rbe(e,t,n){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(e),nbe(i)}const oi=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||oi(n,t)};function ibe(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function sbe(e,t){return IV(t).map(n=>{const r=e.getPropertyValue(n),i=e.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function obe(e,t,n,r){const i=`.${e}:${t}`,s=n.cssText?ibe(n):sbe(n,r);return document.createTextNode(`${i}{${s}}`)}function HT(e,t,n,r){const i=window.getComputedStyle(e,n),s=i.getPropertyValue("content");if(s===""||s==="none")return;const o=X2e();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(obe(o,n,i,r)),t.appendChild(a)}function abe(e,t,n){HT(e,t,":before",n),HT(e,t,":after",n)}const BT="application/font-woff",zT="image/jpeg",lbe={woff:BT,woff2:BT,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:zT,jpeg:zT,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function cbe(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function Pk(e){const t=cbe(e).toLowerCase();return lbe[t]||""}function ube(e){return e.split(/,/)[1]}function S6(e){return e.search(/^(data:)/)!==-1}function dbe(e,t){return`data:${t};base64,${e}`}async function RV(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((s,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{s(n({res:r,result:a.result}))}catch(c){o(c)}},a.readAsDataURL(i)})}const xx={};function fbe(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Ik(e,t,n){const r=fbe(e,t,n.includeQueryParams);if(xx[r]!=null)return xx[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const s=await RV(e,n.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),ube(a)));i=dbe(s,t)}catch(s){i=n.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;s&&(o=typeof s=="string"?s:s.message),o&&console.warn(o)}return xx[r]=i,i}async function hbe(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):D1(t)}async function pbe(e,t){if(e.currentSrc){const s=document.createElement("canvas"),o=s.getContext("2d");s.width=e.clientWidth,s.height=e.clientHeight,o==null||o.drawImage(e,0,0,s.width,s.height);const a=s.toDataURL();return D1(a)}const n=e.poster,r=Pk(n),i=await Ik(n,r,t);return D1(i)}async function mbe(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await Hv(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function gbe(e,t){return oi(e,HTMLCanvasElement)?hbe(e):oi(e,HTMLVideoElement)?pbe(e,t):oi(e,HTMLIFrameElement)?mbe(e,t):e.cloneNode($V(e))}const vbe=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",$V=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function ybe(e,t,n){var r,i;if($V(t))return t;let s=[];return vbe(e)&&e.assignedNodes?s=Va(e.assignedNodes()):oi(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?s=Va(e.contentDocument.body.childNodes):s=Va(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),s.length===0||oi(e,HTMLVideoElement)||await s.reduce((o,a)=>o.then(()=>Hv(a,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function bbe(e,t,n){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):IV(n).forEach(s=>{let o=i.getPropertyValue(s);s==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),oi(e,HTMLIFrameElement)&&s==="display"&&o==="inline"&&(o="block"),s==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(s,o,i.getPropertyPriority(s))})}function xbe(e,t){oi(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),oi(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function wbe(e,t){if(oi(e,HTMLSelectElement)){const r=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function kbe(e,t,n){return oi(t,Element)&&(bbe(e,t,n),abe(e,t,n),xbe(e,t),wbe(e,t)),t}async function Cbe(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let s=0;s<n.length;s++){const a=n[s].getAttribute("xlink:href");if(a){const c=e.querySelector(a),u=document.querySelector(a);!c&&u&&!r[a]&&(r[a]=await Hv(u,t,!0))}}const i=Object.values(r);if(i.length){const s="http://www.w3.org/1999/xhtml",o=document.createElementNS(s,"svg");o.setAttribute("xmlns",s),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(s,"defs");o.appendChild(a);for(let c=0;c<i.length;c++)a.appendChild(i[c]);e.appendChild(o)}return e}async function Hv(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>gbe(r,t)).then(r=>ybe(e,r,t)).then(r=>kbe(e,r,t)).then(r=>Cbe(r,t))}const DV=/url\((['"]?)([^'"]+?)\1\)/g,Ebe=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Sbe=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function _be(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Abe(e){const t=[];return e.replace(DV,(n,r,i)=>(t.push(i),n)),t.filter(n=>!S6(n))}async function Tbe(e,t,n,r,i){try{const s=n?Y2e(t,n):t,o=Pk(t);let a;return i||(a=await Ik(s,o,r)),e.replace(_be(t),`$1${a}$3`)}catch{}return e}function Pbe(e,{preferredFontFormat:t}){return t?e.replace(Sbe,n=>{for(;;){const[r,,i]=Ebe.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function NV(e){return e.search(DV)!==-1}async function LV(e,t,n){if(!NV(e))return e;const r=Pbe(e,n);return Abe(r).reduce((s,o)=>s.then(a=>Tbe(a,o,t,n)),Promise.resolve(r))}async function vu(e,t,n){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const s=await LV(i,null,n);return t.style.setProperty(e,s,t.style.getPropertyPriority(e)),!0}return!1}async function Ibe(e,t){await vu("background",e,t)||await vu("background-image",e,t),await vu("mask",e,t)||await vu("-webkit-mask",e,t)||await vu("mask-image",e,t)||await vu("-webkit-mask-image",e,t)}async function Mbe(e,t){const n=oi(e,HTMLImageElement);if(!(n&&!S6(e.src))&&!(oi(e,SVGImageElement)&&!S6(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,i=await Ik(r,Pk(r),t);await new Promise((s,o)=>{e.onload=s,e.onerror=t.onImageErrorHandler?(...c)=>{try{s(t.onImageErrorHandler(...c))}catch(u){o(u)}}:o;const a=e;a.decode&&(a.decode=s),a.loading==="lazy"&&(a.loading="eager"),n?(e.srcset="",e.src=i):e.href.baseVal=i})}async function Rbe(e,t){const r=Va(e.childNodes).map(i=>jV(i,t));await Promise.all(r).then(()=>e)}async function jV(e,t){oi(e,Element)&&(await Ibe(e,t),await Mbe(e,t),await Rbe(e,t))}function $be(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),e}const UT={};async function ZT(e){let t=UT[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},UT[e]=t,t}async function WT(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,e.url).href),RV(a,t.fetchRequestInit,({result:c})=>(n=n.replace(o,`url(${c})`),[o,c]))});return Promise.all(s).then(()=>n)}function GT(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=i.exec(r);if(c===null)break;t.push(c[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let c=s.exec(r);if(c===null){if(c=a.exec(r),c===null)break;s.lastIndex=a.lastIndex}else a.lastIndex=s.lastIndex;t.push(c[0])}return t}async function Dbe(e,t){const n=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{Va(i.cssRules||[]).forEach((s,o)=>{if(s.type===CSSRule.IMPORT_RULE){let a=o+1;const c=s.href,u=ZT(c).then(h=>WT(h,t)).then(h=>GT(h).forEach(p=>{try{i.insertRule(p,p.startsWith("@import")?a+=1:i.cssRules.length)}catch(m){console.error("Error inserting rule from remote css",{rule:p,error:m})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(u)}})}catch(s){const o=e.find(a=>a.href==null)||document.styleSheets[0];i.href!=null&&r.push(ZT(i.href).then(a=>WT(a,t)).then(a=>GT(a).forEach(c=>{o.insertRule(c,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{Va(i.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),n))}function Nbe(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>NV(t.style.getPropertyValue("src")))}async function Lbe(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Va(e.ownerDocument.styleSheets),r=await Dbe(n,t);return Nbe(r)}function FV(e){return e.trim().replace(/["']/g,"")}function jbe(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(FV(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(e),t}async function Fbe(e,t){const n=await Lbe(e,t),r=jbe(e);return(await Promise.all(n.filter(s=>r.has(FV(s.style.fontFamily))).map(s=>{const o=s.parentStyleSheet?s.parentStyleSheet.href:null;return LV(s.cssText,o,t)}))).join(`
|
|
506
|
+
`):void 0;try{const C=await fetch("/api/controls/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:m,existingSectionTitles:p.merge&&n?n.sections.map(T=>T.title):void 0,elementSummary:g})});if(!C.ok){const T=await C.json().catch(()=>({}));throw new Error(T.error||`Generation failed (${C.status})`)}const w=await C.json(),E=(x=e==null?void 0:e.current)==null?void 0:x.contentDocument,_=Fye(w.sections??[],E);p.merge&&n?i({intent:m,sections:_}):r({version:1,intent:m,sections:_})}catch(C){const w=C instanceof Error?C.message:"Generation failed";jye.error("Interface generation failed",C),c(w)}finally{o(!1)}},[s,t,n,e,r,i]),isGenerating:s,error:a}},Vye=$t("interfaceInjection"),$T="rivet-override-layer",DT=(e,t)=>{if(!(e!=null&&e.head))return;let n=e.getElementById($T);n||(n=e.createElement("style"),n.id=$T,e.head.appendChild(n)),n.textContent=t},Hye=()=>{const e=Ce(Rye),t=Ce(kp),n=Ce(Pd);f.useEffect(()=>{var r;if(DT((r=t==null?void 0:t.current)==null?void 0:r.contentDocument,e.css),Vye.debug("Applied interface override layer",{bytes:e.css.length}),!!n)return n.onHMR(()=>{requestAnimationFrame(()=>{var i;DT((i=t==null?void 0:t.current)==null?void 0:i.contentDocument,e.css)})})},[e,t,n])},Bye=()=>{Hye();const e=Ce(Lv),{generate:t,isGenerating:n,error:r}=Oye(),[i,s]=f.useState(""),o=f.useRef(null),a=p=>{p.style.height="auto",p.style.height=`${p.scrollHeight}px`},c=p=>{s(p.target.value),a(p.target)},u=()=>{var m;const p=i.trim();!p||n||(t(p,{merge:!!e}),s(""),o.current&&(o.current.style.height="auto"),(m=o.current)==null||m.blur())},h=p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&(p.preventDefault(),p.nativeEvent.stopImmediatePropagation(),u())};return y.jsxs("div",{className:"flex-shrink-0 border-t border-main-border p-3",children:[r?y.jsx("p",{className:"mb-2 text-xs text-red-400",children:r}):null,y.jsxs("div",{className:"rounded-lg bg-main-input outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[y.jsx("textarea",{ref:o,value:i,onChange:c,onKeyDown:h,placeholder:e?"Describe more controls to add…":"Describe what you want to edit (e.g. “tune the card hover and shadow”)",disabled:n,className:"max-h-32 min-h-[2.5rem] w-full resize-none overflow-y-auto bg-transparent pb-1 pl-3 pr-3 pt-3 text-sm text-content placeholder-content-subtle focus:outline-none disabled:opacity-50",rows:3,"data-cy":"generated-interface-prompt"}),y.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1",children:[n?y.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-content-subtle",children:[y.jsx(K8,{className:"text-sm text-primary"}),"Generating controls…"]}):y.jsx("span",{className:"text-xs text-content-subtle",children:"Generate controls"}),y.jsx("button",{onClick:u,disabled:!i.trim()||n,className:"flex items-center justify-center rounded bg-primary p-1 text-content transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-80",title:"Generate controls (⌘↵)","data-cy":"generated-interface-submit",children:y.jsx(s8,{className:"h-5 w-5",weight:"bold"})})]})]})]})},zye=$t("useDiffStats"),Uye={files:[],totalInsertions:0,totalDeletions:0},uV=()=>{const e=Ce(mw),t=ze(mw),n=(e==null?void 0:e.diffStats)??Uye,r=!1,i=null,s=f.useCallback(async()=>{const a=await _w();return a&&t(a),(a==null?void 0:a.diffStats)??null},[t]),o=f.useCallback(async a=>{try{const c=await fetch("/api/git/revert-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:a})});if(!c.ok)throw new Error(`Failed to revert file: ${c.status}`);const u=await _w();return u&&t(u),!0}catch(c){return zye.warn("Error reverting file:",c),!1}},[t]);return{stats:n,fetchDiffStats:s,revertFile:o,isLoading:r,error:i}},Wf=$t("useGitPublish"),Zye=()=>{const[e,t]=f.useState(!1),[n,r]=f.useState(null),{fetchStatus:i}=J1(),s=f.useCallback(async()=>{Wf.debug("publishChanges called"),t(!0),r(null);try{Wf.debug("Making fetch request to /api/git/publish");const a=await fetch("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"}});if(Wf.debug("Response received",{status:a.status,ok:a.ok}),!a.ok){const u=await a.json();throw new Error(u.details||u.error||`HTTP ${a.status}`)}const c=await a.json();return Wf.info("Git publish completed successfully:",c.prUrl),{data:c,error:null}}catch(a){const c=a instanceof Error?a.message:"Failed to publish changes";return r(c),Wf.warn("Git publish error:",a),{data:null,error:c}}finally{t(!1)}},[]);return{publishChanges:f.useCallback(async a=>{const{data:c,error:u}=await s();return c?i():u&&a("error","Failed to publish changes",u),c},[s,i]),isPublishing:e,error:n,clearError:()=>r(null)}},NT=$t("useGitPush"),Wye=()=>{const[e,t]=f.useState(!1);return{pushCommits:f.useCallback(async()=>{t(!0);try{const r=await fetch("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"}});if(!r.ok){const i=await r.json();throw new Error(i.details||i.error||`HTTP ${r.status}`)}return NT.info("Push completed successfully"),{success:!0,error:null}}catch(r){const i=r instanceof Error?r.message:"Failed to push";return NT.warn("Push error:",r),{success:!1,error:i}}finally{t(!1)}},[]),isPushing:e}},Gye=2e3,qye=()=>{const e=xs(),{stats:t,fetchDiffStats:n,revertFile:r}=uV(),{fetchStatus:i}=J1(),[s,o]=f.useState(null),[a,c]=f.useState(null),u=f.useRef(null),h=async x=>{if(x){const C=await n();e==null||e.capture("git_diff_viewed",{file_count:(C==null?void 0:C.files.length)??0,total_insertions:(C==null?void 0:C.totalInsertions)??0,total_deletions:(C==null?void 0:C.totalDeletions)??0})}},p=async x=>{o(x);const C=await r(x);o(null),C?(e==null||e.capture("git_file_reverted",{file_path:x}),i()):e==null||e.capture("git_file_revert_failed",{file_path:x})},m=t.totalInsertions>0||t.totalDeletions>0,g=x=>{u.current=setTimeout(()=>{c(x)},Gye)},b=()=>{u.current&&(clearTimeout(u.current),u.current=null),c(null)};return y.jsxs(Fo,{onOpenChange:h,children:[y.jsx(ul,{asChild:!0,children:y.jsx("button",{type:"button",className:el("flex h-7 flex-shrink-0 items-center gap-2 rounded-md px-2 text-xs font-medium transition-colors","text-content-subtle hover:bg-main-hover hover:text-content",!m&&"opacity-50"),children:m?y.jsxs("div",{className:"flex items-center gap-1.5 leading-none",children:[y.jsxs("span",{className:"text-green-400",children:["+",t.totalInsertions]}),y.jsxs("span",{className:"text-red-400",children:["-",t.totalDeletions]})]}):null})}),y.jsx(Oo,{children:y.jsx(Vo,{className:"z-[60] w-80 rounded-lg border-[1px] border-divider bg-main p-3 shadow-lg",sideOffset:5,align:"end",children:t.files.length>0?y.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:t.files.map(x=>{const C=x.file.split("/").pop()??x.file,w=s===x.file;return y.jsxs("div",{className:"relative flex items-center gap-2 rounded border border-transparent px-2 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input",onMouseEnter:()=>g(x.file),onMouseLeave:b,children:[a===x.file?y.jsx("div",{className:"absolute bottom-full left-0 mb-1 max-w-xs truncate rounded border border-divider bg-main px-2 py-1 text-xs text-content shadow-md",children:x.file}):null,y.jsx("span",{className:"min-w-0 flex-1 truncate",children:C}),y.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsxs("span",{className:"text-green-400",children:["+",x.insertions]}),y.jsxs("span",{className:"text-red-400",children:["-",x.deletions]}),y.jsx("button",{type:"button",onClick:()=>p(x.file),disabled:w,className:"text-content-subtle transition-colors hover:text-red-400 disabled:opacity-50",title:`Revert ${C}`,children:y.jsx(Bh,{className:`h-3 w-3 ${w?"animate-spin":""}`,weight:"bold"})})]})]},x.file)})}):y.jsx("div",{className:"py-2 text-center text-xs text-content-subtle",children:"No changes on this branch"})})})]})};var[jv]=ws("Tooltip",[Hd]),Fv=Hd(),dV="TooltipProvider",Kye=700,C6="tooltip.open",[Yye,xk]=jv(dV),fV=e=>{const{__scopeTooltip:t,delayDuration:n=Kye,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=f.useRef(!0),a=f.useRef(!1),c=f.useRef(0);return f.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),y.jsx(Yye,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:f.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:f.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:f.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:s})};fV.displayName=dV;var up="Tooltip",[Xye,Np]=jv(up),hV=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,c=xk(up,e.__scopeTooltip),u=Fv(t),[h,p]=f.useState(null),m=Zi(),g=f.useRef(0),b=o??c.disableHoverableContent,x=a??c.delayDuration,C=f.useRef(!1),[w,E]=ys({prop:r,defaultProp:i??!1,onChange:M=>{M?(c.onOpen(),document.dispatchEvent(new CustomEvent(C6))):c.onClose(),s==null||s(M)},caller:up}),_=f.useMemo(()=>w?C.current?"delayed-open":"instant-open":"closed",[w]),T=f.useCallback(()=>{window.clearTimeout(g.current),g.current=0,C.current=!1,E(!0)},[E]),I=f.useCallback(()=>{window.clearTimeout(g.current),g.current=0,E(!1)},[E]),P=f.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{C.current=!0,E(!0),g.current=0},x)},[x,E]);return f.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),y.jsx(B3,{...u,children:y.jsx(Xye,{scope:t,contentId:m,open:w,stateAttribute:_,trigger:h,onTriggerChange:p,onTriggerEnter:f.useCallback(()=>{c.isOpenDelayedRef.current?P():T()},[c.isOpenDelayedRef,P,T]),onTriggerLeave:f.useCallback(()=>{b?I():(window.clearTimeout(g.current),g.current=0)},[I,b]),onOpen:T,onClose:I,disableHoverableContent:b,children:n})})};hV.displayName=up;var E6="TooltipTrigger",pV=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Np(E6,n),s=xk(E6,n),o=Fv(n),a=f.useRef(null),c=Qt(t,a,i.onTriggerChange),u=f.useRef(!1),h=f.useRef(!1),p=f.useCallback(()=>u.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),y.jsx(gv,{asChild:!0,...o,children:y.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:dt(e.onPointerMove,m=>{m.pointerType!=="touch"&&!h.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),h.current=!0)}),onPointerLeave:dt(e.onPointerLeave,()=>{i.onTriggerLeave(),h.current=!1}),onPointerDown:dt(e.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:dt(e.onFocus,()=>{u.current||i.onOpen()}),onBlur:dt(e.onBlur,i.onClose),onClick:dt(e.onClick,i.onClose)})})});pV.displayName=E6;var wk="TooltipPortal",[Qye,Jye]=jv(wk,{forceMount:void 0}),mV=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Np(wk,t);return y.jsx(Qye,{scope:t,forceMount:n,children:y.jsx(ks,{present:n||s.open,children:y.jsx(Ip,{asChild:!0,container:i,children:r})})})};mV.displayName=wk;var Cd="TooltipContent",gV=f.forwardRef((e,t)=>{const n=Jye(Cd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Np(Cd,e.__scopeTooltip);return y.jsx(ks,{present:r||o.open,children:o.disableHoverableContent?y.jsx(vV,{side:i,...s,ref:t}):y.jsx(e2e,{side:i,...s,ref:t})})}),e2e=f.forwardRef((e,t)=>{const n=Np(Cd,e.__scopeTooltip),r=xk(Cd,e.__scopeTooltip),i=f.useRef(null),s=Qt(t,i),[o,a]=f.useState(null),{trigger:c,onClose:u}=n,h=i.current,{onPointerInTransitChange:p}=r,m=f.useCallback(()=>{a(null),p(!1)},[p]),g=f.useCallback((b,x)=>{const C=b.currentTarget,w={x:b.clientX,y:b.clientY},E=i2e(w,C.getBoundingClientRect()),_=s2e(w,E),T=o2e(x.getBoundingClientRect()),I=l2e([..._,...T]);a(I),p(!0)},[p]);return f.useEffect(()=>()=>m(),[m]),f.useEffect(()=>{if(c&&h){const b=C=>g(C,h),x=C=>g(C,c);return c.addEventListener("pointerleave",b),h.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",b),h.removeEventListener("pointerleave",x)}}},[c,h,g,m]),f.useEffect(()=>{if(o){const b=x=>{const C=x.target,w={x:x.clientX,y:x.clientY},E=(c==null?void 0:c.contains(C))||(h==null?void 0:h.contains(C)),_=!a2e(w,o);E?m():_&&(m(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,h,o,u,m]),y.jsx(vV,{...e,ref:s})}),[t2e,n2e]=jv(up,{isInside:!1}),r2e=Mfe("TooltipContent"),vV=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,c=Np(Cd,n),u=Fv(n),{onClose:h}=c;return f.useEffect(()=>(document.addEventListener(C6,h),()=>document.removeEventListener(C6,h)),[h]),f.useEffect(()=>{if(c.trigger){const p=m=>{m.target instanceof Node&&m.target.contains(c.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,h]),y.jsx(Tp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:y.jsxs(z3,{"data-state":c.stateAttribute,...u,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[y.jsx(r2e,{children:r}),y.jsx(t2e,{scope:n,isInside:!0,children:y.jsx(A0e,{id:c.contentId,role:"tooltip",children:i||r})})]})})});gV.displayName=Cd;var yV="TooltipArrow",bV=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Fv(n);return n2e(yV,n).isInside?null:y.jsx(U3,{...i,...r,ref:t})});bV.displayName=yV;function i2e(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function s2e(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function o2e(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function a2e(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],c=t[o],u=a.x,h=a.y,p=c.x,m=c.y;h>r!=m>r&&n<(p-u)*(r-h)/(m-h)+u&&(i=!i)}return i}function l2e(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),c2e(t)}function c2e(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xV=fV,kk=hV,Ck=pV,Ek=mV,Sk=gV,wV=bV;const LT=$t("useBranches"),u2e=()=>{const[e,t]=f.useState([]),[n,r]=f.useState(!1),[i,s]=f.useState(!1),o=f.useCallback(async()=>{try{r(!0);const c=await fetch("/api/git/branches");if(!c.ok)throw new Error("Failed to fetch branches");const u=await c.json();t(u.branches||[])}catch(c){LT.warn("Failed to fetch branches:",c)}finally{r(!1)}},[]),a=f.useCallback(async c=>{try{s(!0);const u=await fetch("/api/git/switch-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branchName:c})});if(!u.ok){const h=await u.json();throw new Error(h.details||h.error||"Failed to switch branch")}return!0}catch(u){throw LT.warn(`Failed to switch to branch ${c}:`,u),u}finally{s(!1)}},[]);return f.useEffect(()=>{o()},[o]),{branches:e,isLoading:n,isSwitching:i,fetchBranches:o,switchToBranch:a}},d2e=({branch:e})=>y.jsxs(kk,{children:[y.jsx(Ck,{asChild:!0,children:y.jsxs(ja,{value:e,"data-branch":e,className:el("flex w-full cursor-pointer items-center justify-between rounded-md border border-transparent px-2 py-1.5 text-left text-sm outline-none transition-colors","text-content-subtle hover:bg-main-hover hover:text-content data-[highlighted]:border-primary-border data-[highlighted]:bg-main-hover data-[highlighted]:text-content","data-[state=checked]:bg-transparent"),children:[y.jsx(xd,{children:y.jsx("span",{className:"block max-w-[200px] truncate pr-4",children:e})}),y.jsx(ip,{className:"ml-auto",children:y.jsx(za,{className:"h-4 w-4 flex-shrink-0 text-content-subtle",weight:"bold"})})]})}),y.jsx(Ek,{children:y.jsxs(Sk,{className:"z-50 max-w-[300px] break-all rounded bg-main-input px-3 py-1.5 text-xs text-content shadow-lg",side:"right",sideOffset:8,children:[e,y.jsx(wV,{className:"fill-main-input"})]})})]}),f2e=({currentBranch:e,onSwitch:t})=>{const n=xs(),{branches:r,isSwitching:i,switchToBranch:s}=u2e(),[o,a]=f.useState(!1),[c,u]=f.useState(""),h=f.useCallback(g=>{a(g),g&&(n==null||n.capture("git_branch_picker_opened",{current_branch:e,branch_count:r.length}))},[n,e,r.length]);f.useEffect(()=>{o||u("")},[o]);const p=r.filter(g=>g.toLowerCase().includes(c.toLowerCase())),m=f.useCallback(async g=>{if(g!==e)try{await s(g),n==null||n.capture("git_branch_switched",{from_branch:e,to_branch:g}),lt.success(`Switched to branch: ${g}`),t==null||t(g)}catch(b){const x=b instanceof Error?b.message:"Unknown error";n==null||n.capture("git_branch_switch_failed",{from_branch:e,to_branch:g,error:x}),lt.error(`Failed to switch branch: ${x}`)}},[e,s,t,n]);return f.useEffect(()=>{if(!o)return;const g=requestAnimationFrame(()=>{setTimeout(()=>{const b=document.querySelector(`[data-branch="${e}"]`);b instanceof HTMLElement&&b.scrollIntoView({block:"center",behavior:"auto"})},50)});return()=>cancelAnimationFrame(g)},[e,o]),y.jsx(xV,{delayDuration:300,children:y.jsxs(Ev,{open:o,onOpenChange:h,value:e,onValueChange:m,children:[y.jsxs(kk,{children:[y.jsx(Ck,{asChild:!0,children:y.jsx(Sv,{asChild:!0,children:y.jsxs("button",{className:el("flex min-w-0 max-w-[180px] items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors","text-content hover:bg-main-hover","border border-transparent hover:border-main-border",i&&"cursor-not-allowed opacity-50"),disabled:i,children:[y.jsx(wh,{className:"h-3.5 w-3.5 flex-shrink-0 text-content-subtle",weight:"bold"}),y.jsx("span",{className:"truncate",children:e}),y.jsx(Ba,{className:"h-3.5 w-3.5 flex-shrink-0 text-content-subtle opacity-50",weight:"bold"})]})})}),y.jsx(Ek,{children:y.jsxs(Sk,{className:"z-50 max-w-[300px] break-all rounded bg-main-input px-3 py-1.5 text-xs text-content shadow-lg",sideOffset:5,children:[e,y.jsx(wV,{className:"fill-main-input"})]})})]}),y.jsx(Pj,{align:"start",onCloseAutoFocus:g=>g.preventDefault(),header:y.jsx("div",{className:"sticky top-0 border-b-[1px] border-divider bg-main p-2",children:y.jsx("div",{className:"flex items-center gap-2",children:y.jsxs("div",{className:"relative flex-1",children:[y.jsx(a8,{className:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-content-subtle",size:14,weight:"bold"}),y.jsx("input",{type:"text",placeholder:"Search branches...",className:"w-full rounded bg-main-input py-1.5 pl-8 pr-2 text-xs text-content placeholder-content-subtle outline-none focus:outline-none",value:c,onChange:g=>u(g.target.value),autoFocus:!0})]})})}),children:p.length===0?y.jsx("div",{className:"px-2 py-4 text-center text-sm text-content-subtle",children:"No branches found"}):p.map(g=>y.jsx(d2e,{branch:g},g))})]})})};var Ov="Dialog",[kV]=ws(Ov),[h2e,Ss]=kV(Ov),Lp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=f.useRef(null),c=f.useRef(null),[u,h]=ys({prop:r,defaultProp:i??!1,onChange:s,caller:Ov});return y.jsx(h2e,{scope:t,triggerRef:a,contentRef:c,contentId:Zi(),titleId:Zi(),descriptionId:Zi(),open:u,onOpenChange:h,onOpenToggle:f.useCallback(()=>h(p=>!p),[h]),modal:o,children:n})};Lp.displayName=Ov;var CV="DialogTrigger",p2e=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(CV,n),s=Qt(t,i.triggerRef);return y.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Ak(i.open),...r,ref:s,onClick:dt(e.onClick,i.onOpenToggle)})});p2e.displayName=CV;var _k="DialogPortal",[m2e,EV]=kV(_k,{forceMount:void 0}),jp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Ss(_k,t);return y.jsx(m2e,{scope:t,forceMount:n,children:f.Children.map(r,o=>y.jsx(ks,{present:n||s.open,children:y.jsx(Ip,{asChild:!0,container:i,children:o})}))})};jp.displayName=_k;var R1="DialogOverlay",Fp=f.forwardRef((e,t)=>{const n=EV(R1,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Ss(R1,e.__scopeDialog);return s.modal?y.jsx(ks,{present:r||s.open,children:y.jsx(v2e,{...i,ref:t})}):null});Fp.displayName=R1;var g2e=vd("DialogOverlay.RemoveScroll"),v2e=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(R1,n),s=qfe(),o=Qt(t,s);return y.jsx(yv,{as:g2e,allowPinchZoom:!0,shards:[i.contentRef],children:y.jsx(Et.div,{"data-state":Ak(i.open),...r,ref:o,style:{pointerEvents:"auto",...r.style}})})}),Ed="DialogContent",Op=f.forwardRef((e,t)=>{const n=EV(Ed,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Ss(Ed,e.__scopeDialog);return y.jsx(ks,{present:r||s.open,children:s.modal?y.jsx(y2e,{...i,ref:t}):y.jsx(b2e,{...i,ref:t})})});Op.displayName=Ed;var y2e=f.forwardRef((e,t)=>{const n=Ss(Ed,e.__scopeDialog),r=f.useRef(null),i=Qt(t,n.contentRef,r);return f.useEffect(()=>{const s=r.current;if(s)return Z3(s)},[]),y.jsx(SV,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:dt(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:dt(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:dt(e.onFocusOutside,s=>s.preventDefault())})}),b2e=f.forwardRef((e,t)=>{const n=Ss(Ed,e.__scopeDialog),r=f.useRef(!1),i=f.useRef(!1);return y.jsx(SV,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),SV=f.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Ss(Ed,n);return R3(),y.jsx(y.Fragment,{children:y.jsx(dv,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:y.jsx(Tp,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ak(a.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),_V="DialogTitle",Sd=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(_V,n);return y.jsx(Et.h2,{id:i.titleId,...r,ref:t})});Sd.displayName=_V;var AV="DialogDescription",x2e=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(AV,n);return y.jsx(Et.p,{id:i.descriptionId,...r,ref:t})});x2e.displayName=AV;var TV="DialogClose",Vv=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ss(TV,n);return y.jsx(Et.button,{type:"button",...r,ref:t,onClick:dt(e.onClick,()=>i.onOpenChange(!1))})});Vv.displayName=TV;function Ak(e){return e?"open":"closed"}const Vm=$t("useCommit"),w2e=()=>{const[e,t]=f.useState(!1),[n,r]=f.useState(!1),i=f.useCallback(async()=>{r(!0);try{const o=await fetch("/api/git/generate-commit-message");if(!o.ok){const c=await o.json();throw new Error(c.error||`HTTP ${o.status}`)}return(await o.json()).message}catch(o){return Vm.warn("Failed to generate commit message:",o),null}finally{r(!1)}},[]);return{commit:f.useCallback(async(o,a=!1)=>{t(!0);try{const c=await fetch("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:o,push:a})}),u=await c.json();if(!c.ok&&u.sha)return Vm.warn("Commit succeeded but push failed:",u.details),{sha:u.sha,pushed:!1,pushError:u.details||u.error};if(!c.ok)throw new Error(u.details||u.error||`HTTP ${c.status}`);return Vm.info("Committed successfully:",u.sha),{sha:u.sha,pushed:!!u.pushed}}catch(c){throw Vm.warn("Failed to commit:",c),c}finally{t(!1)}},[]),generateMessage:i,isCommitting:e,isGenerating:n}},k2e=$t("CommitModal"),C2e=({isOpen:e,onClose:t,onCommitted:n})=>{const r=xs(),{commit:i,generateMessage:s,isCommitting:o,isGenerating:a}=w2e(),[c,u]=f.useState(""),[h,p]=f.useState(null);f.useEffect(()=>{e&&(u(""),s().then(b=>{b&&u(b)}))},[e,s]);const m=f.useCallback(async(b=!1)=>{if(c.trim()){p(b?"push":"commit");try{const x=await i(c.trim(),b);r==null||r.capture("git_commit",{has_push:b,is_pushed:x.pushed,has_push_error:!!x.pushError,message_length:c.trim().length}),n(),t(),x.pushError&<.error("Commit succeeded but push failed",{description:x.pushError})}catch(x){r==null||r.capture("git_commit_failed",{has_push:b,error:x instanceof Error?x.message:"unknown"}),k2e.error("Commit failed:",x),lt.error("Commit failed",{description:x instanceof Error?x.message:"Failed to commit"})}finally{p(null)}}},[i,c,n,t,r]),g=f.useCallback(b=>{b.key==="Enter"&&b.metaKey&&(b.preventDefault(),m(!b.shiftKey))},[m]);return y.jsx(Lp,{open:e,onOpenChange:b=>!b&&t(),children:y.jsxs(jp,{children:[y.jsx(Fp,{className:"fixed inset-0 z-max bg-black/40"}),y.jsx(Op,{className:"fixed left-1/2 top-1/2 z-max w-[420px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx(Sd,{className:"text-lg font-semibold text-content",children:"Commit Changes"}),y.jsx(Vv,{asChild:!0,children:y.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",children:y.jsx(Ho,{className:"h-4 w-4",weight:"bold"})})})]}),y.jsxs("div",{className:"relative",children:[y.jsx("textarea",{value:c,onChange:b=>u(b.target.value),onKeyDown:g,placeholder:a?"Generating message...":"Enter commit message",disabled:a,rows:3,className:"w-full resize-none rounded-md bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),a?y.jsx("div",{className:"absolute right-3 top-2.5",children:y.jsx(Ua,{className:"h-4 w-4 animate-spin text-content-subtle",weight:"bold"})}):null]}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx("button",{onClick:()=>m(!1),disabled:o||a||!c.trim(),className:"flex flex-1 items-center justify-center gap-1.5 rounded-md border border-divider px-3 py-2 text-xs text-white transition-colors hover:bg-main-hover disabled:opacity-50",children:h==="commit"?"Committing...":"Commit"}),y.jsx("button",{onClick:()=>m(!0),disabled:o||a||!c.trim(),className:"flex flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:h==="push"?"Committing...":"Commit & Push"})]})]})})]})})},jT=$t("CreateBranchModal"),E2e=({isOpen:e,onClose:t,onCreated:n})=>{const r=xs(),[i,s]=f.useState(""),[o,a]=f.useState(!1),[c,u]=f.useState(!1);f.useEffect(()=>{e&&(s(""),a(!0),fetch("/api/git/generate-branch-name").then(m=>{if(!m.ok)throw new Error(`HTTP ${m.status}`);return m.json()}).then(m=>{s(m.branchName)}).catch(m=>{jT.error("Failed to generate branch name:",m),s("rivet/")}).finally(()=>{a(!1)}))},[e]);const h=f.useCallback(async()=>{if(!i.trim()||c||o)return;u(!0);const m=i.trim();try{const g=await fetch("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branchName:m})});if(!g.ok){const b=await g.json();throw new Error(b.details||b.error||`HTTP ${g.status}`)}n(m),t()}catch(g){const b=g instanceof Error?g.message:"Failed to create branch";r==null||r.capture("git_branch_create_failed",{branch:m,error:b}),lt.error("Failed to create branch",{description:b}),jT.error("Failed to create branch:",g)}finally{u(!1)}},[i,c,o,n,t,r]),p=f.useCallback(m=>{m.key==="Enter"&&(m.preventDefault(),h())},[h]);return y.jsx(Lp,{open:e,onOpenChange:m=>!m&&t(),children:y.jsxs(jp,{children:[y.jsx(Fp,{className:"fixed inset-0 z-max bg-black/40"}),y.jsx(Op,{className:"fixed left-1/2 top-1/2 z-max w-[420px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx(Sd,{className:"text-lg font-semibold text-content",children:"Create Branch"}),y.jsx(Vv,{asChild:!0,children:y.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",children:y.jsx(Ho,{className:"h-4 w-4",weight:"bold"})})})]}),y.jsxs("div",{className:"relative",children:[y.jsx("input",{type:"text",value:i,onChange:m=>s(m.target.value),onKeyDown:p,placeholder:o?"Generating name...":"Enter branch name",disabled:o,className:"w-full rounded-md bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),o?y.jsx("div",{className:"absolute right-3 top-2.5",children:y.jsx(Ua,{className:"h-4 w-4 animate-spin text-content-subtle",weight:"bold"})}):null]}),y.jsx("button",{onClick:h,disabled:c||o||!i.trim(),className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:c?"Creating...":"Create"})]})})]})})},S2e=({prUrl:e,branchName:t,isOpen:n,isLoading:r=!1,onClose:i})=>{const s=xs(),o=f.useCallback(a=>{a.key!=="Enter"||a.repeat||r||(a.preventDefault(),e&&(s==null||s.capture("git_pr_link_clicked",{branch:t,pr_url:e,source:"keyboard"}),window.open(e,"_blank","noopener,noreferrer")))},[r,e,s,t]);return f.useEffect(()=>{if(n)return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n,o]),y.jsx(Lp,{open:n,onOpenChange:a=>!a&&i(),children:y.jsxs(jp,{children:[y.jsx(Fp,{className:"fixed inset-0 z-max bg-black/40"}),y.jsxs(Op,{className:"fixed left-1/2 top-1/2 z-max w-[380px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:[r?y.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[y.jsx(Ua,{className:"h-6 w-6 animate-spin text-primary",weight:"bold"}),y.jsx(Sd,{className:"text-sm font-medium text-content",children:"Creating pull request..."})]}):null,r?null:y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx(Sd,{className:"whitespace-nowrap text-sm font-semibold text-content",children:"Created Pull Request"}),t?y.jsxs("span",{className:"inline-flex max-w-[180px] shrink-0 items-center gap-1 rounded-md bg-main-input px-2 py-0.5 text-xs text-content-muted",children:[y.jsx(wh,{className:"h-3 w-3 shrink-0",weight:"bold"}),y.jsx("span",{className:"truncate",children:t})]}):null]}),y.jsxs("a",{href:e??"#",target:"_blank",rel:"noopener noreferrer",onClick:()=>{s==null||s.capture("git_pr_link_clicked",{branch:t,pr_url:e,source:"button"})},className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover",children:["View PR",y.jsx(i8,{className:"h-3 w-3",weight:"bold"})]})]})]})]})})},PV=({primaryLabel:e,primaryIcon:t,primaryAction:n,isDisabled:r=!1,isLoading:i=!1,loadingLabel:s,dropdownItems:o})=>{const[a,c]=f.useState(!1),u=i?s??e:e;return y.jsxs("div",{className:"flex items-stretch",children:[y.jsxs("button",{onClick:n,disabled:r||i,className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-l-md bg-main-hover px-3 text-xs font-medium text-white transition-colors hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:[t?y.jsx(t,{className:"h-3.5 w-3.5",weight:"bold"}):null,u]}),y.jsxs(Fo,{open:a,onOpenChange:c,children:[y.jsx(ul,{asChild:!0,children:y.jsx("button",{disabled:i,className:"h-7 flex-shrink-0 rounded-r-md border-l border-white/20 bg-main-hover px-1.5 text-white transition-colors hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:y.jsx(Ba,{className:"h-3.5 w-3.5",weight:"bold"})})}),y.jsx(Oo,{children:y.jsx(Vo,{className:"z-[60] min-w-[140px] rounded-lg border border-divider bg-main p-1 shadow-lg",sideOffset:5,align:"end",children:o.map(h=>{const p=h.icon;return y.jsxs("button",{onClick:()=>{h.isDisabled||(h.onClick(),c(!1))},disabled:h.isDisabled,className:"flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:[p?y.jsx(p,{className:"h-3.5 w-3.5",weight:"bold"}):null,h.label]},h.label)})})})]})]})},_2e=f.createContext(null);function A2e(e){switch(e){case"top":return{y:4};case"bottom":return{y:-4};case"left":return{x:4};case"right":return{x:-4}}}function Tk({content:e,children:t,side:n="top",sideOffset:r=8,delayDuration:i=200,className:s,forceOpen:o,onOpenChange:a}){const[c,u]=f.useState(!1),h=o!==void 0?o:c,[p,m]=f.useState(!1),g=Md(),b=f.useContext(_2e);f.useEffect(()=>{h&&m(!0)},[h]);const x=()=>{h||m(!1)},C=A2e(n);return y.jsx(xV,{delayDuration:i,children:y.jsxs(kk,{open:h,onOpenChange:w=>{u(w),a==null||a(w)},children:[y.jsx(Ck,{asChild:!0,children:t}),p&&y.jsx(Ek,{forceMount:!0,container:b??void 0,children:y.jsx(Sk,{side:n,sideOffset:r,forceMount:!0,className:"z-tooltip",children:y.jsx(dn.div,{className:zn("bg-neutral-900 text-white text-[12px] px-2 py-1 border border-white/10 shadow-lg",g.bg,s),style:{fontVariationSettings:Ih.medium},initial:{opacity:0,scale:.8,...C},animate:{opacity:h?1:0,scale:h?1:.9,x:0,y:0},transition:h?{type:"spring",duration:.34,bounce:.55}:{duration:.1},onAnimationComplete:x,children:e})})})]})})}const Ys=({label:e,children:t,side:n="top",sideOffset:r=8,delayDuration:i=300,disabled:s=!1})=>s?y.jsx(y.Fragment,{children:t}):y.jsx(Tk,{content:e,side:n,sideOffset:r,delayDuration:i,children:t}),yx=$t("GitHome"),T2e=({onClose:e})=>e?y.jsx("div",{className:"z-10 flex h-10 flex-shrink-0 items-center border-b border-main-border bg-main-light px-3",children:y.jsx(Ys,{label:"Close chat",side:"bottom",children:y.jsx("button",{onClick:e,className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:y.jsx(Ug,{className:"h-4 w-4",weight:"bold"})})})}):null,P2e=({onUndo:e,isUndoing:t=!1,onClose:n})=>{const r=xs(),s=Ce(Ti).branchDiff.isEnabled,{status:o,fetchStatus:a}=J1(),{stats:c}=uV(),{publishChanges:u,isPublishing:h}=Zye(),{pushCommits:p,isPushing:m}=Wye(),[g,b]=f.useState(!1),[x,C]=f.useState(!1),[w,E]=f.useState(!1),[_,T]=f.useState(null),[I,P]=f.useState(null),M=(o==null?void 0:o.branchName)??null,S=(o==null?void 0:o.hasUncommittedChanges)??!1,R=c.totalInsertions>0||c.totalDeletions>0,$=(o==null?void 0:o.canUndo)??!1,L=(o==null?void 0:o.prUrl)??null,j=f.useCallback((je,Ae,Le,tt)=>{je==="success"?lt.success(Ae,{description:Le,action:tt?{label:tt.label,onClick:tt.onClick}:void 0}):je==="info"?lt.info(Ae,{description:Le}):(Le&&yx.error(`${Ae}:`,Le),lt.error(Ae))},[]),O=f.useCallback(async()=>{r==null||r.capture("git_pr_create_started",{branch:M}),E(!0),T(null);let je=!1;const Le=await u((tt,vt,Je)=>{tt==="error"&&(je=!0,r==null||r.capture("git_pr_create_failed",{branch:M,error:Je??vt}),yx.error("Failed to create PR:",Je??vt),E(!1),lt.error("Failed to create PR",{description:Je??vt}))});Le!=null&&Le.prUrl?(r==null||r.capture("git_pr_created",{branch:Le.branchName,pr_url:Le.prUrl}),T(Le.prUrl),P(Le.branchName),a()):je||(r==null||r.capture("git_pr_create_failed",{branch:M,error:"unknown"}),yx.error("Failed to create PR: unknown error"),E(!1),lt.error("Failed to create PR",{description:"Something went wrong creating the pull request."}))},[u,a,r,M]),H=f.useCallback(async()=>{r==null||r.capture("git_push_started",{branch:M});const{success:je,error:Ae}=await p();je?(r==null||r.capture("git_push_succeeded",{branch:M}),j("success","Changes pushed to GitHub")):(r==null||r.capture("git_push_failed",{branch:M,error:Ae}),j("error","Failed to push",Ae??void 0))},[p,j,r,M]),B=f.useCallback(()=>{L&&(r==null||r.capture("git_pr_opened",{branch:M,pr_url:L}),window.open(L,"_blank","noopener,noreferrer"))},[L,r,M]),Z=f.useCallback(()=>{a(),lt.success("Changes committed")},[a]),K=f.useCallback(je=>{r==null||r.capture("git_branch_created",{branch:je,from_branch:M}),a(),lt.success("Branch created")},[a,r,M]),q=f.useCallback(()=>{r==null||r.capture("git_commit_modal_opened",{branch:M}),b(!0)},[r,M]),te=f.useCallback(()=>{r==null||r.capture("git_create_branch_modal_opened",{branch:M}),C(!0)},[r,M]),F=f.useCallback(()=>{r==null||r.capture("git_undo_commit",{branch:M}),e==null||e(j)},[r,M,e,j]),V=S,W=!!L,N=M==="main"&&!V&&!W,z=W?"Go to PR":"Create PR",Q=W?i8:CS,J=W?B:O,re=!W&&!R;let G=V?"Commit":z,X=V?kS:Q,de=V?q:J,ve=V?!1:re;N&&(G="New Branch",X=wh,de=te,ve=!1);const we=V?[{label:"Undo Commit",icon:Bh,onClick:F,isDisabled:t||!$},{label:"Push Commits",icon:wS,onClick:H,isDisabled:m||!R},{label:z,icon:Q,onClick:J,isDisabled:h||re},{label:"Create New Branch",icon:wh,onClick:te}]:[{label:"Undo Commit",icon:Bh,onClick:F,isDisabled:t||!$},{label:"Push Commits",icon:wS,onClick:H,isDisabled:m||!R},...N?[{label:"Create PR",icon:CS,onClick:O,isDisabled:!0}]:[{label:"Commit",icon:kS,onClick:q,isDisabled:!S},{label:"Create Branch",icon:wh,onClick:te}]];return M?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"z-10 flex h-10 flex-shrink-0 items-center justify-between border-b border-main-border bg-main-light px-3",children:[n&&y.jsxs(y.Fragment,{children:[y.jsx("button",{onClick:n,title:"Close panel",className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:y.jsx(Ug,{className:"h-4 w-4",weight:"bold"})}),y.jsx("div",{className:"mx-1 h-4 w-[1px] flex-shrink-0 bg-divider/20"})]}),y.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 pr-2",children:[y.jsx(f2e,{currentBranch:M,onSwitch:()=>{a()}}),s&&R&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-4 w-[1px] flex-shrink-0 bg-divider/20"}),y.jsx(qye,{})]})]}),y.jsx(PV,{primaryLabel:G,primaryIcon:X,primaryAction:de,isDisabled:ve,isLoading:!1,loadingLabel:"Creating PR...",dropdownItems:we})]}),y.jsx(C2e,{isOpen:g,onClose:()=>b(!1),onCommitted:Z}),y.jsx(E2e,{isOpen:x,onClose:()=>C(!1),onCreated:K}),y.jsx(S2e,{prUrl:_,branchName:I??void 0,isOpen:w,isLoading:h,onClose:()=>E(!1)})]}):n?y.jsx("div",{className:"z-10 flex h-10 flex-shrink-0 items-center border-b border-main-border bg-main-light px-3",children:y.jsx("button",{onClick:n,title:"Close panel",className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:y.jsx(Ug,{className:"h-4 w-4",weight:"bold"})})}):null},I2e=e=>{const t=Ce(C$),r=Ce(Ti).gitUi.isEnabled;return!t||!r?y.jsx(T2e,{onClose:e.onClose}):y.jsx(P2e,{...e})},M2e=$t("SupportTicketModal"),FT=5e3,bx="feedback",R2e=e=>{var r;if(!e)return null;const t=(r=e.formErrors)==null?void 0:r[0];if(t)return t;const n=e.fieldErrors??{};for(const i of Object.values(n)){const s=i==null?void 0:i[0];if(s)return s}return null},$2e=async e=>{let t;try{t=await e.json()}catch{t=void 0}if(e.status===400){if(typeof(t==null?void 0:t.details)=="string"&&t.details.trim())return t.details;if(typeof(t==null?void 0:t.details)=="object"&&t.details!==null){const n=R2e(t.details);if(n)return n}return"Please check your feedback and try again."}return e.status>=500?typeof(t==null?void 0:t.details)=="string"&&t.details.trim()?t.details:"Could not send feedback right now. Please try again later.":typeof(t==null?void 0:t.error)=="string"&&t.error.trim()?t.error:`HTTP ${e.status}`},D2e=({isOpen:e,onClose:t,contactEmail:n})=>{const r=xs(),[i,s]=f.useState(""),[o,a]=f.useState(!1),c=f.useCallback(()=>{s("")},[]),u=f.useCallback(()=>{o||(c(),t())},[o,t,c]),h=f.useCallback(async()=>{const b=i.trim();if(!(!b||o)){a(!0);try{const x=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,C=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,w=n==null?void 0:n.trim(),E=await fetch("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:bx,message:b,contactEmail:w||void 0,metadata:{posthogSessionId:x??void 0,posthogDistinctId:C??void 0,appVersion:"0.11.4",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!E.ok){const _=await $2e(E);throw new Error(_)}r==null||r.capture("support_ticket_submitted",{ticket_type:bx,has_posthog_session_id:!!x}),lt.success("Feedback sent",{description:"Thanks for sharing this."}),c(),t()}catch(x){const C=x instanceof Error?x.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:bx,error:C}),M2e.error("Failed to submit support ticket:",C),lt.error("Could not send feedback",{description:C})}finally{a(!1)}}},[n,o,i,t,r,c]),p=f.useCallback(b=>{b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),h())},[h]),m=FT-i.length,g=o||i.trim().length===0;return y.jsx(Lp,{open:e,onOpenChange:b=>!b&&u(),children:y.jsxs(jp,{children:[y.jsx(Fp,{className:"fixed inset-0 z-max bg-black/40"}),y.jsx(Op,{className:"fixed left-1/2 top-1/2 z-max w-[480px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx(Sd,{className:"text-lg font-semibold text-content",children:"Send feedback"}),y.jsx(Vv,{asChild:!0,children:y.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",disabled:o,children:y.jsx(Ho,{className:"h-4 w-4",weight:"bold"})})})]}),y.jsx("p",{className:"text-sm text-content-subtle",children:"Tell us what happened or what we can improve."}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("label",{htmlFor:"support-ticket-message",className:"text-xs font-medium text-content-muted",children:"Your feedback"}),y.jsx("textarea",{id:"support-ticket-message",value:i,onChange:b=>s(b.target.value),onKeyDown:p,maxLength:FT,rows:7,disabled:o,placeholder:"What happened?",className:"w-full resize-none rounded-md border border-divider bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),y.jsxs("div",{className:"flex justify-between text-xs text-content-subtle",children:[y.jsx("span",{children:"Context details are included automatically."}),y.jsx("span",{children:m})]})]}),y.jsx("button",{onClick:h,disabled:g,className:"flex w-full items-center justify-center gap-2 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:o?y.jsxs(y.Fragment,{children:[y.jsx(Ua,{className:"h-4 w-4 animate-spin",weight:"bold"}),y.jsx("span",{children:"Sending..."})]}):y.jsx("span",{children:"Send feedback"})})]})})]})})},N2e=$t("ProfileAvatar"),L2e=(e,t)=>{const n=(e??"").trim();if(n){const i=n.split(/\s+/).filter(Boolean);return i.length>=2?(i[0][0]+i[i.length-1][0]).toUpperCase():i[0].slice(0,2).toUpperCase()}const r=(t??"").split("@")[0]??"";if(r){const i=r.split(/[._\-+]/).filter(Boolean);return i.length>=2?(i[0][0]+i[1][0]).toUpperCase():r.slice(0,2).toUpperCase()}return""},j2e=({className:e=""})=>{const{name:t,email:n}=Ce(v$),[r,i]=f.useState(!1),[s,o]=f.useState(!1),[a,c]=f.useState(!1),u=L2e(t,n);if(!u)return null;const h=(t==null?void 0:t.trim())||null,p=(n==null?void 0:n.trim())||null,m=async()=>{c(!0);try{const g=await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!g.ok)throw new Error(`Logout failed: ${g.status}`)}catch(g){N2e.warn("Logout request failed",g),lt.error("Could not log out. Please try again."),c(!1);return}window.location.reload()};return y.jsxs(y.Fragment,{children:[y.jsxs(Fo,{open:r,onOpenChange:i,children:[y.jsx(ul,{asChild:!0,children:y.jsx("button",{type:"button","aria-label":"Account",className:`flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full border border-main-border bg-main-input text-[10px] font-semibold leading-none text-content-muted transition-colors hover:text-content ${e}`,children:u})}),y.jsx(Oo,{children:y.jsxs(Vo,{className:"z-[60] min-w-[180px] rounded-lg border border-divider bg-main p-1 shadow-lg",sideOffset:6,align:"end",children:[h||p?y.jsxs("div",{className:"border-b border-main-border px-3 py-2",children:[h?y.jsx("div",{className:"truncate text-xs font-medium text-content",children:h}):null,p?y.jsx("div",{className:"truncate text-[11px] text-content-muted",children:p}):null]}):null,y.jsxs("button",{type:"button",onClick:()=>{i(!1),o(!0)},className:"mt-1 flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input",children:[y.jsx(o8,{className:"h-3.5 w-3.5",weight:"bold"}),"Support & feedback"]}),y.jsxs("button",{type:"button",onClick:m,disabled:a,className:"mt-1 flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:[y.jsx(hG,{className:"h-3.5 w-3.5",weight:"bold"}),a?"Logging out…":"Log out"]})]})})]}),y.jsx(D2e,{isOpen:s,onClose:()=>o(!1),contactEmail:n??void 0})]})},Wt=$t("ElementInspector"),F2e=({chatMessages:e,setChatMessages:t,onClose:n})=>{const[r,i]=Bn(Js),s=Ce(Pd),[o]=Bn(K1),{undoLastChange:a,isUndoing:c}=Yie(),{status:u,fetchStatus:h}=J1(),m=Ce(Ti).gitUi.isEnabled,g=m?(u==null?void 0:u.canUndo)??!1:!1,b=f.useCallback(async()=>{if(!s||!r)return;await new Promise(E=>requestAnimationFrame(E)),Wt.debug("Refreshing element styles for:",r.tagName);const w=await s.reSelectElement(OD(r));if(w){s.setCurrentElement(w);const E=s.getComputedStyles();s.showSelectionOverlay(w),UD("style_refresh"),i({...r,computedStyles:E})}else Wt.warn("Could not find element for refresh:",r.xpath)},[s,r,i]),x=f.useCallback(async()=>{if(!(o!=null&&o.canUndo()))return!1;const w=await o.undo();return w.ok?(await b(),!0):(Wt.error("Failed to undo:",w.error.message),!1)},[o,b]),C=f.useCallback(async w=>{var _;if(!m||!g||!await a((T,I,P)=>{w?w(T,I,P):T==="success"?lt.success(I,{description:P}):T==="info"?lt.message(I,{description:P}):(P&&Wt.error(`${I}:`,P),lt.error(I))}))return!1;if(await h(),(s==null?void 0:s.type)==="iframe"&&"forceReload"in s){Wt.info("Force reloading iframe after git undo");try{await((_=s.forceReload)==null?void 0:_.call(s))}catch(T){return Wt.error("Iframe reload failed, but git undo succeeded:",T),w==null||w("info","Changes reverted successfully","Please refresh the page to see the updated preview"),!0}}return await b(),!0},[b,g,m,a,h,s]);return y.jsxs("div",{className:"relative flex h-full w-96 cursor-auto flex-col overflow-hidden bg-main font-main shadow-2xl scrollbar-hide","data-cy":"element-inspector",children:[y.jsx(j2e,{className:"absolute right-3 top-2 z-20"}),y.jsx(I2e,{onUndo:C,isUndoing:c,onClose:n}),y.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:y.jsx(O2e,{chatMessages:e,setChatMessages:t,handleUndo:x,refreshElementStyles:b,fetchStatus:h})})]})},O2e=({chatMessages:e,setChatMessages:t,handleUndo:n,refreshElementStyles:r,fetchStatus:i})=>{const s=xs(),[o,a]=Bn(Js),c=Ce(Pd),[u,h]=Bn(Hi),p=wc(),m=Ce(kp),g=Ce(ps),b=Ce(Cc),x=Ce(il),C=f.useRef(x);C.current=x;const w=f.useMemo(()=>Lie(u,g),[u,g]),E=f.useMemo(()=>{if(!ah(g))return null;const{sessionId:_e,variantId:Oe}=g;for(const ut of[b==null?void 0:b.left,b==null?void 0:b.right])if(ut&&ut.sessionId===_e&&ut.variantId===Oe)return ut.label;if(x.active){const ut=x.variants.find(gt=>gt.workItemId===Oe);if(ut)return ut.label}return"Direction"},[g,b,x]),_=Ce(V8),[T,I]=Bn(K1);f.useEffect(()=>{if(!c)return;T&&T.destroy();const _e=new FJ(c,_);return I(_e),window.manipulationService=_e,()=>{_e.destroy(),I(null),delete window.manipulationService}},[c,_,I]);const[P,M]=f.useState(null),[S,R]=f.useState(0),$=ze(y$),L=Array.from(u.values()).filter(_e=>_e.status==="pending").length,[j,O]=Bn(QJ),[H,B]=f.useState({}),[Z,K]=f.useState(0),q=f.useRef(null),te=f.useRef(null),F=f.useRef(null),[V,W]=f.useState(0),N=f.useRef({}),z=f.useRef(!1),Q=f.useCallback(_e=>{const Oe=C.current;Oe.active&&Oe.sessionId===_e.sessionId&&DA(_e,Oe.variants,N.current),z.current=!1,F.current=_e,W(ut=>ut+1)},[]),J=f.useCallback(()=>{F.current!==null&&(F.current=null,W(_e=>_e+1))},[]),re=f.useCallback(_e=>{te.current=_e,K(Oe=>Oe+1)},[]),G=f.useCallback(()=>{const _e=te.current;te.current=null,J(),K(Oe=>Oe+1),_e&&(_e.changeIds.length>0&&T&&_e.changeIds.forEach(Oe=>{T.removeTrackedChangeById(Oe)}),_e.commentIds.length>0&&h(Oe=>{if(Oe.size===0)return Oe;const ut=(m==null?void 0:m.current)??null;if(ut){const qt=_e.commentIds.map(St=>Oe.get(St)).filter(St=>St!=null);Hu(ut,qt)}const gt=new Map(Oe);return _e.commentIds.forEach(qt=>{gt.delete(qt)}),gt}))},[T,h,m,J]),X=f.useCallback(()=>{te.current=null,J(),K(_e=>_e+1)},[J]),{modifyWithAgent:de,cancelModification:ve,isModifying:we}=fte(),je=Ce(E$),Ae=Ce(Cp),Le=Ce(X1),tt=Ce(Z8),{sendChanges:vt,sendChatMessage:Je}=nD(),{status:ye,resetStatus:Ke}=Zie(),Dt=f.useMemo(()=>_ie(ye),[ye]),Mt=Ce(U8),{onRoundStarted:jt,onProgressSteps:bn,onAssistantChunk:nn,onRoundCompleted:he,onRoundFailed:be,onRoundCanceled:Ue,getActiveAssistantMessageId:ot,getCancellationMessage:at,setPhase:Ht}=Kie({setChatMessages:t,isMCPSession:Ae}),Ut=Ce(rl),ee=Ut==="comment",Y=Ce(Ti).generativeControls.isEnabled,se=Ce(Lv),ce=Ce(oV),le=ze(cV),ge=ze(lV),ke=f.useMemo(()=>bie(se,ce),[se,ce]),$e=ze(F8),ct=Ce(pc),[rt,Jt]=Bn(O8),wt=!Ae&&Ut!=="edit",De=wt?rt==="directions":Ut!=="edit"&&!(Ae&&Le==="embedded"),{startRound:Nt,resetPhase:At}=zie({mcpStatus:ye,isPublishing:j,isMCPSession:Ae,setIsPublishing:O,fetchStatus:i,refreshElementStyles:r,getActiveAssistantMessageId:ot,onProgressSteps:bn,onRoundCompleted:he,setSessionUxPhase:Ht,clearQueuedPendingSnapshot:G});f.useEffect(()=>{if(!Ae||!j)return;const _e=F.current;if(!_e)return;if(x.active&&x.sessionId===_e.sessionId)z.current=!0;else{if(!z.current)return;X(),O(!1),At(),Ht("idle");const Yt=ot();Yt&&be({assistantMessageId:Yt,error:"Static preview variant refinement was interrupted."});return}const ut=N.current,gt=jie(_e,x.variants,ut);if(gt.status==="pending")return;DA(_e,x.variants,ut);const qt=_e.variantIds.length>1,St=ot();if(gt.status==="succeeded"){G(),O(!1),At(),Ht("idle"),St&&he({assistantMessageId:St,finalMessage:qt?"Static preview variants refined.":"Static preview variant refined."});return}if(X(),O(!1),At(),Ht("idle"),St){let Yt;gt.status==="cancelled"?Yt="Static preview variant refinement was cancelled.":gt.errorCode?Yt=`Static preview variant refinement failed (${gt.errorCode}).`:Yt="Static preview variant refinement failed.",be({assistantMessageId:St,error:Yt})}},[G,X,ot,Ae,j,he,be,At,O,Ht,V,x]),f.useEffect(()=>{o&&(Ae||(q.current=null))},[o==null?void 0:o.xpath,Ae]);const Tt=we||j,on=je,Qn=Mie((o==null?void 0:o.computedStyles)||{});f.useEffect(()=>{var qt,St;if(!o||!c||c.type!=="iframe")return;let _e=!1;const Oe=OD(o),ut=((St=(qt=o.filePaths)==null?void 0:qt[0])==null?void 0:St.filePath)||void 0;return(async()=>{const Yt=await c.reSelectElement(Oe);if(_e||!Yt)return;const rn=Ga();c.injectRivetId(Yt,rn);const Un=c.createElementIdentifier(Yt);Un.rivetId=rn,Un.filePath=ut,M(Un)})(),()=>{_e=!0}},[o,c]);const Vn=Ce(q1);f.useEffect(()=>{if(!T)return;const _e=_.getChangeCount();return R(_e),$(_e),_.onChange(()=>{const ut=_.getChangeCount();R(ut),$(ut)})},[_,T,$]);const Jn=!!o&&!ee;f.useEffect(()=>{var ut;const _e=gt=>{if(!((gt.metaKey||gt.ctrlKey)&>.key.toLowerCase()==="z"&&!gt.shiftKey)||Vn.isEditing)return;const St=document.activeElement;St&&(St.tagName==="INPUT"||St.tagName==="TEXTAREA"||St.tagName==="SELECT"||St.getAttribute("contenteditable")==="true")&&!Jn||(gt.preventDefault(),Wt.debug("Undo shortcut triggered"),s==null||s.capture("undo"),n())},Oe=(ut=m==null?void 0:m.current)==null?void 0:ut.contentDocument;return window.addEventListener("keydown",_e),Oe==null||Oe.addEventListener("keydown",_e),()=>{window.removeEventListener("keydown",_e),Oe==null||Oe.removeEventListener("keydown",_e)}},[Jn,n,Vn.isEditing,m]);const en=_e=>{_e!==Ut&&(s==null||s.capture("inspector_tab_changed",{from_tab:Ut,to_tab:_e})),$e(_e)};J8({shortcuts:[{key:"1",handler:()=>{Wt.debug("Switching to Styles tab (1)"),en("edit")},description:"Switch to Styles tab"},{key:"2",handler:()=>{Wt.debug("Switching to Chat tab (2)"),en("comment")},description:"Switch to Chat tab"},{key:"1",metaKey:!0,handler:()=>{Wt.debug("Switching to Styles tab (Cmd+1)"),en("edit")},description:"Switch to Styles tab"},{key:"1",ctrlKey:!0,handler:()=>{Wt.debug("Switching to Styles tab (Ctrl+1)"),en("edit")},description:"Switch to Styles tab"},{key:"2",metaKey:!0,handler:()=>{Wt.debug("Switching to Chat tab (Cmd+2)"),en("comment")},description:"Switch to Chat tab"},{key:"2",ctrlKey:!0,handler:()=>{Wt.debug("Switching to Chat tab (Ctrl+2)"),en("comment")},description:"Switch to Chat tab"}]});const Mn=f.useCallback(async()=>{var Oe;if(Tt)return;Hte(),Hu((m==null?void 0:m.current)??null,u.values());const _e=p.get(qa);_e&&(await f1(_e.diff),p.set(qa,null));for(const ut of u.values()){const gt=(Oe=ut.finalizedVariant)==null?void 0:Oe.codeDiff;gt&&await f1(gt)}T==null||T.clear(),h(new Map),le()},[Tt,T,h,m,u,p,le]),ci=f.useCallback(async()=>{const Oe=Oie(Ae?u:w,T,ke);if(!Oe)return;X();const{pendingComments:ut,styleChanges:gt,textChanges:qt,pendingSnapshot:St,applyPointers:Yt,hasComments:rn,hasDesignChanges:Un,hasInterfaceChanges:st}=Oe;if(s==null||s.capture("apply",{comment_count:ut.length,design_edit_count:gt.length+qt.length,interface_change_count:Oe.interfaceChanges.length,has_comments:rn,has_design_changes:Un,has_interface_changes:st}),Ae){$e("comment"),Ke(),O(!0),Nt();const sn=Db(Yt),{assistantMessageId:xn}=jt({userMessage:sn,startPhase:"starting"});if(Wt.debug("[MCP] new apply round — asstMsgId:",xn),re(St),!rn&&!Un&&st){const _s=await Je(Mw(ke));if(_s.cancelled)return;_s.success||(X(),lt.error(_s.error||"Failed to send changes"),be({assistantMessageId:xn,error:_s.error||"Failed to send changes"}),O(!1),At());return}const er=await vt();if(er.cancelled)return;if(!er.success){X(),lt.error(er.error||"Failed to send changes"),be({assistantMessageId:xn,error:er.error||"Failed to send changes"}),O(!1),At();return}st&&await Je(Mw(ke)),(er.changeIdsToClear||er.commentIdsToClear)&&re({...St,commentIds:er.commentIdsToClear??St.commentIds,changeIds:er.changeIdsToClear??St.changeIds}),er.staticPreviewVariantIds&&er.staticPreviewVariantIds.length>0&&er.staticPreviewSessionId&&Q({sessionId:er.staticPreviewSessionId,variantIds:er.staticPreviewVariantIds});return}$e("comment"),O(!0);const Zn=Vie(Oe),ln=Hie(Oe),ar=Db(Yt),{assistantMessageId:Pi}=jt({userMessage:ar,startPhase:"applying"});re(St);const io=ut.flatMap(sn=>sn.images??[]),Nr=Bie();Wt.debug("Calling modifyWithAgent");let ui=!1;try{await de({instruction:Zn,elements:Array.from(ln.values()),images:io.length>0?io:void 0,sessionId:q.current??void 0},{onProgress:sn=>{if(Nr.recordActivity(),!sn.startsWith("Agent:")){const xn=sn.match(/^\[([^\]]+)\]/);xn&&Nr.recordToolStart(xn[1])}},onChunk:sn=>{Nr.recordActivity(),Nr.recordReasoningChunk(),nn({content:sn,assistantMessageId:Pi})},onComplete:async sn=>{var Uo;ui=!0;const xn=Nr.finalize();Wt.debug(`modifyWithAgent completed in ${xn.agentExecutionDuration}ms`);const er=NA(sn.changes,sn.filesModified);if(he({assistantMessageId:Pi,finalMessage:er}),sn.sessionId&&(q.current=sn.sessionId),G(),Un){Wt.debug("Refreshing styles and status");try{await r(),await i()}catch(ml){Wt.warn("Style/status refresh failed:",ml)}}rn&&Wt.debug("Sent pending comments were cleared after completion."),st&&le();const _s=Date.now();if((c==null?void 0:c.type)==="iframe"&&"forceReload"in c){Wt.debug("Force reloading iframe");try{await((Uo=c.forceReload)==null?void 0:Uo.call(c))}catch(ml){Wt.warn("Iframe reload failed:",ml)}}const Zd=Date.now();s==null||s.capture("code_modification",{success:!0,source:"apply",instruction_length:Zn.length,element_count:ln.size,modification_time_ms:xn.agentExecutionDuration}),s==null||s.capture("agent_apply_session",{success:!0,env:"production",total_duration_ms:Nr.elapsed(),agent_execution_duration_ms:xn.agentExecutionDuration,tool_execution_duration_ms:xn.totalToolDuration,model_reasoning_duration_ms:xn.agentExecutionDuration-xn.totalToolDuration,time_to_first_message_ms:xn.timeToFirstMessage,post_processing_duration_ms:_s-xn.agentEndTime,iframe_reload_duration_ms:Zd-_s,model:sn.model,tool_counts:xn.toolCounts,total_tool_calls:Object.values(xn.toolCounts).reduce((ml,Wd)=>ml+Wd,0),reasoning_chunk_count:xn.reasoningChunkCount,element_count:ln.size,comment_count:ut.length,design_edit_count:S,instruction_length:Zn.length,session_id:sn.sessionId,server_ttfm_ms:sn.ttfmMs}),O(!1),At()},onError:async sn=>{if(ui=!0,Wt.error("Error in modifyWithAgent:",sn),be({assistantMessageId:Pi,error:sn}),X(),s==null||s.capture("code_modification",{success:!1,source:"apply",instruction_length:Zn.length,element_count:ln.size,error_message:sn}),s==null||s.capture("agent_apply_session",{success:!1,env:"production",total_duration_ms:Nr.elapsed(),error_message:sn,element_count:ln.size,instruction_length:Zn.length}),Un)try{await(T==null?void 0:T.clearInlineChanges())}catch(xn){Wt.warn("Failed to clear inline changes:",xn)}wm(sn)?km(sn):lt.error("Failed to apply changes"),O(!1),At()},onCanceled:()=>{ui=!0,O(!1),At(),X()}})}catch(sn){ui=!0,Wt.error("Unexpected error in handleApplyAll:",sn),X();const xn=sn instanceof Error?sn.message:"An unexpected error occurred";be({assistantMessageId:Pi,error:xn}),wm(xn)?km(xn):lt.error("Failed to apply changes"),O(!1),At()}finally{ui||(Wt.warn("modifyWithAgent returned without triggering onComplete or onError"),X(),be({assistantMessageId:Pi,error:"Agent request failed to initialize or timed out without feedback."}),lt.error("Failed to apply changes"),O(!1),At())}},[w,u,T,c,de,r,i,S,s,Ae,vt,Je,Ke,jt,nn,he,be,$e,Nt,At,O,re,G,X,ke,le,Q]);f.useEffect(()=>{const _e=Oe=>{(Oe.metaKey||Oe.ctrlKey)&&Oe.key==="Enter"&&(ct||(L>0||S>0||ke.length>0)&&!j&&!Tt&&(Oe.preventDefault(),Wt.debug("Apply all shortcut triggered (Cmd/Ctrl+Enter)"),ci()))};return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[L,S,ke,j,Tt,ct,ci]);const Ud=f.useCallback(async(_e,Oe)=>{var qt;if(!T||!P||!c||c.type!=="iframe")return;const gt=((qt=Qn[_e])==null?void 0:qt.type)==="range"?(parseFloat(Oe)/100).toString():Oe;await T.previewStyleChange(P,_e,gt)},[T,P,c,Qn]),Zv=f.useCallback(async(_e,Oe,ut)=>{var rn;const gt=Oe;if(!gt||!T||!P||!o||!c||c.type!=="iframe")return;const St=((rn=Qn[_e])==null?void 0:rn.type)==="range"?(parseFloat(gt)/100).toString():gt,Yt=await T.applyStyleChange(P,o,_e,St,ut);if(Yt.ok){const Un=await c.getComputedStylesForElement(P);Un.ok&&a({...o,computedStyles:Un.value}),B(Zn=>{const ln={...Zn};return delete ln[_e],ln});const st=Rw.find(Zn=>Zn.properties.some(ln=>ln.key===_e));s==null||s.capture("design_property_changed",{property:_e,category:st==null?void 0:st.value})}else Wt.error("Failed to apply style:",Yt.error.message),lt.error("Failed to apply style")},[T,P,o,c,Qn,B,a,s]),Wv=f.useCallback(async _e=>{T&&await T.transaction(_e)},[T]),Gv=(_e,Oe)=>{B(ut=>({...ut,[_e]:Oe}))},no=(_e,Oe)=>{const ut=Oe.replace("%","").trim();if(ut===""){B(St=>({...St,[_e]:""}));return}const gt=parseFloat(ut);if(Number.isNaN(gt))return;const qt=Math.max(0,Math.min(100,gt));B(St=>({...St,[_e]:qt.toString()}))},Hp=_e=>{B(Oe=>{const ut={...Oe};return delete ut[_e],ut})},Bp=f.useCallback(async()=>{if(!T)return;const _e=await T.redo();_e.ok?await r():Wt.error("Failed to redo:",_e.error.message)},[T,r]),qv=f.useCallback(()=>{const _e=at();Ae&&Le==="embedded"&&fetch("/api/agent/stop",{method:"POST",headers:tt?{"x-rivet-queue-token":tt}:void 0}).catch(Oe=>{Wt.warn("Failed to stop embedded agent run:",Oe)}),ve(),O(!1),At(),X(),Ue({cancellationMessage:_e})},[ve,O,At,X,Ue,at,Ae,Le,tt]),zp=f.useCallback(async(_e,Oe)=>{Ke();const ut=Date.now();X();const gt=Array.from(u.values()).filter(ln=>ln.status==="pending"),qt=gt.length>0,St=gt.map(ln=>({id:ln.id,instruction:ln.instruction})),Yt=HD({pendingComments:St,styleChanges:[],textChanges:[],includeComments:qt,includeChanges:!1});s==null||s.capture("chat",{message_length:_e.length,has_images:!!(Oe!=null&&Oe.length),image_count:(Oe==null?void 0:Oe.length)??0,has_pending_comments:qt,pending_comment_count:gt.length,has_selected_element:!!o});const rn=qt?BD(gt):_e,Un=qt?VD(gt,[],[]):[],st=qt&&Un.length>0?Db(Un):_e,{assistantMessageId:Zn}=jt({userMessage:st,images:Oe,startPhase:Ae?"starting":"applying"});Yt.commentIds.length>0&&re(Yt);try{if(Ae){Ke(),O(!0),Nt();const ln=await Je(rn,Oe);if(ln.cancelled)return;ln.success||(X(),be({assistantMessageId:Zn,error:ln.error||"Failed to send to Claude Code"}),O(!1),At())}else if(on){const ln=o?[o]:[];await de({instruction:rn,elements:ln,images:Oe,sessionId:q.current??void 0},{onProgress:()=>{},onChunk:ar=>{nn({content:ar,assistantMessageId:Zn})},onComplete:async({sessionId:ar,changes:Pi,filesModified:io})=>{var ui;const Nr=NA(Pi,io);if(he({assistantMessageId:Zn,finalMessage:Nr}),G(),s==null||s.capture("code_modification",{success:!0,source:"chat",instruction_length:rn.length,element_count:ln.length,modification_time_ms:Date.now()-ut}),ar&&(q.current=ar),qt&&Wt.debug("Sent pending comments were cleared after completion."),(c==null?void 0:c.type)==="iframe"&&"forceReload"in c)try{await((ui=c.forceReload)==null?void 0:ui.call(c))}catch(sn){Wt.warn("Iframe reload after agent modification failed:",sn)}r()},onError:ar=>{X(),be({assistantMessageId:Zn,error:ar}),s==null||s.capture("code_modification",{success:!1,source:"chat",instruction_length:rn.length,element_count:ln.length,error_message:ar,modification_time_ms:Date.now()-ut}),Wt.error("Code modification error details:",ar),wm(ar)?km(ar):lt.error("Code Modification Error")},onCanceled:()=>{O(!1),At(),X()}})}else Wt.error("Chat mode not supported"),lt.error("Chat mode not supported")}catch(ln){Wt.error("Error with streaming request:",ln);const ar=ln instanceof Error?ln.message:"An unexpected error occurred.";X(),O(!1),At(),be({assistantMessageId:Zn,error:ar}),wm(ar)?km(ar):lt.error("Failed to generate AI response")}},[Ke,u,T,s,o,Ae,Je,on,de,c,r,jt,nn,he,be,Nt,At,O,re,G,X]),qi=f.useMemo(()=>{const _e=Array.from(w.values()).filter(st=>st.status==="pending"),Oe=(T==null?void 0:T.getStyleChanges())??[],ut=(T==null?void 0:T.getTextChanges())??[],gt=Oe.map(st=>({id:st.id,key:ac(st),property:String(st.property),newValue:st.newValue,timestamp:st.timestamp})),qt=ut.map(st=>({id:st.id,key:ac(st),oldText:st.oldText,newText:st.newText,timestamp:st.timestamp})),St=Nie(_e.map(st=>({id:st.id,instruction:st.instruction,finalizedVariant:st.finalizedVariant,styleVariants:st.styleVariants,selectedVariantIndex:st.selectedVariantIndex,variantGenerationStatus:st.variantGenerationStatus,requestedVariantCount:st.requestedVariantCount})),gt,qt);for(const st of ke)St.push({id:st.id,kind:"interface",detail:FD(st)});const Yt=te.current;if(!Tt||!Yt)return St;const rn=new Set(Yt.commentIds),Un=new Map;return gt.forEach(st=>{Un.set(st.id,st.key)}),qt.forEach(st=>{Un.set(st.id,st.key)}),Yt.changeIds.forEach(st=>{const Zn=Un.get(st);Zn&&rn.add(Zn)}),St.filter(st=>!rn.has(st.id))},[w,S,T,Tt,Z,ke]),Pc=f.useCallback(async _e=>{if(_e.kind==="interface"){ge({controlId:_e.id,value:void 0});return}if(_e.kind==="comment"){h(qt=>{const St=qt.get(_e.id),Yt=(m==null?void 0:m.current)??null;Yt&&(St==null?void 0:St.previewBaselineStyle)!==void 0&&Hu(Yt,[St]);const rn=new Map(qt);return rn.delete(_e.id),rn});return}if(!T)return;const ut=T.getChanges().find(qt=>ac(qt)===_e.id);if(!ut){Wt.warn("No tracked change for pending row",_e.id);return}const gt=await T.revertSpecificChange(ut);if(!gt.ok){Wt.error("revertSpecificChange failed:",gt.error.message),lt.error("Could not revert change");return}await r()},[T,h,r,m,ge]),ro=Ae?Dt||(j&&(ye==null?void 0:ye.status)!=="APPLYING"?kie:j?wie:null):null,Up=y.jsx(X0e,{chatMessages:e,statusHint:ro,handleChatSend:zp,handleStop:qv,isProcessing:Tt,pendingChangeRows:qi,onRemovePendingChange:Pc,onApplyPendingChanges:ci,onClearPendingChanges:Mn,disableInputWhileProcessing:Le!=="embedded",showModelPicker:Le!=="embedded"}),Kv=y.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center",children:[y.jsx("p",{className:"text-sm text-content-subtle",children:"Select an element to edit, or leave a comment on the page."}),ro&&y.jsx("p",{className:"mt-2 text-xs text-content-subtle",children:ro})]});return(()=>{const _e=Eie({isMCPSession:Ae,isChatOpen:ee,hasSelectedElement:!!o,showDirections:De,hasPendingChanges:qi.length>0,changeCount:S,isPublishing:j,isProcessing:Tt,hasStatusHint:!!ro,shouldUseAgentChat:Le==="embedded"}),Oe=o?y.jsx(lye,{propertyCategories:Rw,formattedComputedStyles:Qn,pendingChanges:H,handlePendingCssChange:Gv,handlePendingPercentageChange:no,applyPropertyChange:Zv,previewPropertyChange:Ud,performTransaction:Wv,handleBlur:Hp},o.xpath):null,ut=Y&&Ut==="edit"?y.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[y.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-hide",children:[y.jsx(Lye,{}),_e.showDesignPanel?Oe:null]}),qi.length>0?y.jsx("div",{className:"flex-shrink-0 border-t border-main-border px-3 py-2",children:y.jsx(n6,{tags:qi,onRemoveTag:Pc,onClearAll:Mn,canClear:!j&&!Tt})}):null,y.jsx(Bye,{})]}):Ut==="edit"&&_e.showDesignPanel&&Oe?Oe:wt?y.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[y.jsx("div",{className:"flex-shrink-0 border-b border-main-border bg-main-light px-2 py-1.5",children:y.jsx(cte,{"aria-label":"Panel view",value:rt,onValueChange:Jt,options:[{value:"chat",label:"Chat","data-cy":"rhs-tab-chat"},{value:"directions",label:"Directions","data-cy":"rhs-tab-directions"}]})}),y.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:rt==="directions"?y.jsx(tA,{}):Up})]}):_e.showChatPanel?Up:_e.showDesignPanel?Oe:De?y.jsx(tA,{}):_e.showMCPEmptyState?Kv:null,gt=qi.length;return y.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[E&&!De?y.jsx("div",{className:"flex flex-shrink-0 items-center border-b border-main-border bg-main-light px-4 py-1.5 text-xs text-content-subtle",children:y.jsxs("span",{className:"truncate",children:["Editing"," ",y.jsx("span",{className:"font-medium text-content",children:E})]})}):null,ut,_e.showExternalPendingChanges&&y.jsx("div",{className:"flex-shrink-0 border-t border-main-border px-4 py-2",children:y.jsx(n6,{tags:qi,onRemoveTag:Pc,onClearAll:Mn,canClear:!j&&!Tt})}),_e.showExternalStatusHint&&ro&&y.jsx("div",{className:`flex-shrink-0 px-4 py-2 ${qi.length===0?"border-t border-main-border":""}`,children:y.jsx("p",{className:"text-center text-xs text-content-subtle",children:ro})}),(_e.showActionBar||Y&&Ut==="edit"&&qi.length>0)&&y.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-t border-main-border bg-main-light px-4 py-3",children:[y.jsxs("div",{className:"flex gap-2",children:[y.jsx("button",{onClick:n,disabled:!(T!=null&&T.canUndo()),className:"rounded p-1.5 text-content transition-colors hover:bg-main-hover disabled:cursor-not-allowed disabled:opacity-30",title:"Undo (Cmd+Z)",children:y.jsx(Bh,{className:"h-4 w-4"})}),y.jsx("button",{onClick:Bp,disabled:!(T!=null&&T.canRedo()),className:"rounded p-1.5 text-content transition-colors hover:bg-main-hover disabled:cursor-not-allowed disabled:opacity-30",title:"Redo (Cmd+Shift+Z)",children:y.jsx(iG,{className:"h-4 w-4"})})]}),y.jsx("button",{onClick:ci,disabled:j||Tt,className:"rounded border border-primary px-3 py-1 text-xs font-medium text-gray-300 hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-30",title:Ae?`Send ${gt||"pending"} changes to ${Mt||"Claude Code"}`:"Apply all pending changes (⌘↵)","data-cy":"inspector-apply-button",children:Sie({isMCPSession:Ae,isApplying:j||Tt,pendingChangeCount:gt})})]})]})})()},V2e=$t("useServerConfig"),H2e=()=>{const[e,t]=f.useState(null),[n,r]=f.useState(!0),[i,s]=f.useState(null),o=f.useCallback(async()=>{var a;try{r(!0),s(null);const c=await fetch("/api/health");if(!c.ok)throw new Error(`Failed to fetch config: ${c.status}`);const u=await c.json();if(!u.framework)throw new Error("Server did not return framework information");const h={userPort:((a=u.ports)==null?void 0:a.userDevServer)||3e3,framework:u.framework};return t(h),h}catch(c){const u=c instanceof Error?c.message:"Failed to fetch server config";throw s(u),V2e.warn("Error fetching server config:",c),c}finally{r(!1)}},[]);return{config:e,fetchConfig:o,isLoading:n,error:i}},B2e="data:image/svg+xml,%3csvg%20width='453'%20height='416'%20viewBox='0%200%20453%20416'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1326_108)'%3e%3cpath%20d='M186.07%2025.5539C186.07%2011.4409%20197.511%200%20211.624%200H335.5C400.393%200%20453%2052.6065%20453%20117.5C453%20182.393%20400.393%20235%20335.5%20235H216.639C199.756%20235%20186.07%20221.314%20186.07%20204.431C186.07%20186.743%20198.071%20169.863%20215.299%20165.853C225.291%20163.528%20238.671%20160.53%20256.58%20156.667C258.587%20156.234%20260.54%20155.796%20262.442%20155.354C307.627%20144.861%20299.146%20103.217%20256.58%2084.7815C234.082%2075.0381%20218.731%2068.1115%20208.265%2063.1881C194.851%2056.8779%20186.07%2040.378%20186.07%2025.5539Z'%20fill='white'/%3e%3cpath%20d='M381.709%20415.715C329.789%20415.715%20287.699%20373.625%20287.699%20321.705V314.306C287.699%20288.346%20308.744%20267.301%20334.704%20267.301C386.624%20267.301%20428.714%20309.391%20428.714%20361.311V368.71C428.714%20394.67%20407.669%20415.715%20381.709%20415.715Z'%20fill='white'/%3e%3cpath%20d='M0%2073.5927C0%2033.1632%2032.7745%200.388672%2073.2039%200.388672C113.633%200.388672%20146.408%2033.1632%20146.408%2073.5926V338.795C146.408%20379.225%20113.633%20411.999%2073.2039%20411.999C32.7745%20411.999%200%20379.225%200%20338.795V73.5927Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1326_108'%3e%3crect%20width='453'%20height='416'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",OT=(e,t)=>y.jsxs("div",{className:"flex flex-row items-center gap-2",children:[y.jsx("span",{children:e}),t?y.jsx("span",{className:"rounded bg-white/15 px-1.5 py-0.5 text-[10px] leading-none font-bold",children:t}):null]}),z2e={type:"spring",duration:.3,bounce:0},U2e=({mode:e,onModeChange:t,isLoading:n=!1,disabled:r=!1})=>{const[i,s]=f.useState(!1),o=Ce(Hi),a=Ce(y$),c=ze(wp),u=Ce(Ti).refineMode.isEnabled,h=e!=="view"||i,m=Array.from(o.values()).filter(b=>b.status==="pending").length+a,g=(b,x,C,w,E)=>{const _=r?"Disconnected":x,T=e===b;return y.jsx(Ys,{label:OT(_,r?void 0:C),disabled:!h,children:y.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),b==="edit"&&c(!0),t(b)},disabled:r,className:`rounded-md p-2 transition-colors ${T?"bg-primary/20 text-primary":"text-content hover:bg-main-input"} ${r?"cursor-not-allowed opacity-50":""}`,"data-cy":E,children:w})})};return y.jsxs(dn.div,{className:"z-ui-primary absolute right-6 bottom-6",initial:{y:100,opacity:0},animate:{y:n?100:0,opacity:n?0:1},transition:{duration:.6,ease:"easeOut",delay:n?0:.3},children:[m>0&&!h&&y.jsx(dn.span,{className:"bg-primary pointer-events-none absolute -top-1 -right-1 z-10 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[9px] leading-none font-bold text-white",animate:{opacity:1},transition:{duration:.15,delay:.2},children:m>9?"9+":m}),y.jsxs(dn.div,{layout:!0,className:`border-primary/30 bg-main overflow-hidden border shadow-lg ${h?"":"cursor-pointer"}`,style:{borderRadius:h?10:9999},transition:z2e,onClick:h?void 0:()=>s(!0),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[y.jsx(dn.div,{className:"absolute flex items-center justify-center",style:{width:40,height:40,top:0,left:0},animate:{opacity:h?0:1},transition:h?{duration:0}:{duration:0,delay:.2},"aria-hidden":h,children:y.jsx("img",{src:B2e,alt:"Rivet",style:{width:16,height:16}})}),!h&&y.jsx("div",{style:{width:40,height:40}}),y.jsxs(dn.div,{className:"flex items-center gap-1 p-2",style:{position:h?"relative":"absolute",inset:0,pointerEvents:h?"auto":"none"},animate:{opacity:h?1:0},transition:h?{duration:0,delay:.22}:{duration:0},children:[g("view","Select","V",y.jsx(aG,{className:"h-5 w-5",weight:"bold"}),"mode-select"),g("comment","Comment","C",y.jsx(o8,{className:"h-5 w-5",weight:"bold"}),"mode-comment"),u?g("edit","Refine","R",y.jsx(mG,{className:"h-5 w-5"}),"mode-design"):null,y.jsx("div",{className:"bg-primary/20 mx-1 h-4 w-px"}),y.jsx(Ys,{label:OT(r?"Disconnected":"Collapse",r?void 0:"X"),disabled:!h,children:y.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),t("view"),s(!1)},disabled:r,"aria-label":"Collapse",className:`text-content hover:bg-main-input rounded-md p-2 transition-colors ${r?"cursor-not-allowed opacity-50":""}`,"data-cy":"mode-view",children:y.jsx(Ho,{className:"h-5 w-5",weight:"bold"})})})]})]})]})},Z2e=async()=>{let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return Hm();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable"};let n;try{n=await e.json()}catch{return Hm()}const r=n.devServerHealth;return r?r.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable"}:r.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable"}:{isOk:!1,unavailableReason:r.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable"}:Hm()},Hm=async()=>{try{const e=await fetch("/");return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable"}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}},VT=$t("usePreviewUpstreamHealth"),W2e=500,G2e=4e3,q2e=15e3,K2e=(e,t={})=>{const n=f.useRef(null),r=f.useRef(null),i=t.probeMsWhileDown??W2e,s=t.probeMsWhileUp??G2e,o=t.firstUnreachableCaptureAfterMs??q2e,a=t.rerunProbeImmediatelyOnVersion,c=t.skip??!1,[u,h]=f.useState(e==="static"),[p,m]=f.useState(0),[g,b]=f.useState(null),[x,C]=f.useState(0),[w,E]=f.useState(!1),[_,T]=f.useState(!1),[I,P]=f.useState(e==="static"?null:"upstream_unreachable");return f.useEffect(()=>{if(e==="static"){h(!0),b(null),C(0),E(!1),T(!0),P(null);return}if(c){h(!1),b(null),C(0),E(!1),T(!0),P("upstream_unreachable"),n.current=null;return}let M=!0;const S=Date.now();b(S),C(0),E(!1),h(!1),T(!1),P("upstream_unreachable");const R={current:!1},$={current:!1},L={current:!1},j={current:null},O={current:!1};let H=null;const B=()=>{L.current||(L.current=!0,M&&T(!0))},Z=()=>{H!==null&&(clearTimeout(H),H=null)},K=(te,F)=>{Z(),H=setTimeout(F,te)},q=async()=>{if(!M)return;C(N=>N+1);const{isOk:te,unavailableReason:F}=await Z2e();if(!M)return;if(B(),te){const N=!O.current;O.current=!0,h(!0),P(null),j.current=null,$.current=!1,E(!1),R.current?N&&(yt==null||yt.capture("preview_upstream_restored",{framework:e})):(R.current=!0,yt==null||yt.capture("preview_dev_server_ready",{framework:e,ready_after_ms:Date.now()-S})),K(s,q);return}const V=O.current;O.current=!1,h(!1),P(F),j.current===null&&(j.current=Date.now(),$.current=!1,E(!1)),V&&(yt==null||yt.capture("preview_upstream_lost",{framework:e}),m(N=>N+1),VT.warn("Preview upstream became unavailable after it was ready"));const W=Date.now()-j.current;W>=o&&!$.current&&($.current=!0,E(!0),yt==null||yt.capture("preview_dev_server_unreachable",{framework:e,elapsed_ms:W}),VT.warn("Dev server did not become ready within timeout window")),K(i,q)};return n.current=()=>K(0,q),K(0,q),()=>{M=!1,n.current=null,Z()}},[e,i,s,o,c]),f.useEffect(()=>{var S;if(e==="static"||a===void 0)return;const M=r.current;r.current=a,M!==null&&M!==a&&((S=n.current)==null||S.call(n))},[e,a]),{isUpstreamReady:u,iframeRemountKey:p,probeStartedAt:g,probeAttemptCount:x,isFirstUnreachableWindowExceeded:w,initialProbeComplete:_,unavailableReason:I}};function Y2e(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const X2e=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Va(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let gu=null;function IV(e={}){return gu||(e.includeStyleProperties?(gu=e.includeStyleProperties,gu):(gu=Va(window.getComputedStyle(document.documentElement)),gu))}function $1(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Q2e(e){const t=$1(e,"border-left-width"),n=$1(e,"border-right-width");return e.clientWidth+t+n}function J2e(e){const t=$1(e,"border-top-width"),n=$1(e,"border-bottom-width");return e.clientHeight+t+n}function MV(e,t={}){const n=t.width||Q2e(e),r=t.height||J2e(e);return{width:n,height:r}}function ebe(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const gi=16384;function tbe(e){(e.width>gi||e.height>gi)&&(e.width>gi&&e.height>gi?e.width>e.height?(e.height*=gi/e.width,e.width=gi):(e.width*=gi/e.height,e.height=gi):e.width>gi?(e.height*=gi/e.width,e.width=gi):(e.width*=gi/e.height,e.height=gi))}function D1(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function nbe(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function rbe(e,t,n){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(e),nbe(i)}const oi=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||oi(n,t)};function ibe(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function sbe(e,t){return IV(t).map(n=>{const r=e.getPropertyValue(n),i=e.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function obe(e,t,n,r){const i=`.${e}:${t}`,s=n.cssText?ibe(n):sbe(n,r);return document.createTextNode(`${i}{${s}}`)}function HT(e,t,n,r){const i=window.getComputedStyle(e,n),s=i.getPropertyValue("content");if(s===""||s==="none")return;const o=X2e();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(obe(o,n,i,r)),t.appendChild(a)}function abe(e,t,n){HT(e,t,":before",n),HT(e,t,":after",n)}const BT="application/font-woff",zT="image/jpeg",lbe={woff:BT,woff2:BT,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:zT,jpeg:zT,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function cbe(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function Pk(e){const t=cbe(e).toLowerCase();return lbe[t]||""}function ube(e){return e.split(/,/)[1]}function S6(e){return e.search(/^(data:)/)!==-1}function dbe(e,t){return`data:${t};base64,${e}`}async function RV(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((s,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{s(n({res:r,result:a.result}))}catch(c){o(c)}},a.readAsDataURL(i)})}const xx={};function fbe(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Ik(e,t,n){const r=fbe(e,t,n.includeQueryParams);if(xx[r]!=null)return xx[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const s=await RV(e,n.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),ube(a)));i=dbe(s,t)}catch(s){i=n.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;s&&(o=typeof s=="string"?s:s.message),o&&console.warn(o)}return xx[r]=i,i}async function hbe(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):D1(t)}async function pbe(e,t){if(e.currentSrc){const s=document.createElement("canvas"),o=s.getContext("2d");s.width=e.clientWidth,s.height=e.clientHeight,o==null||o.drawImage(e,0,0,s.width,s.height);const a=s.toDataURL();return D1(a)}const n=e.poster,r=Pk(n),i=await Ik(n,r,t);return D1(i)}async function mbe(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await Hv(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function gbe(e,t){return oi(e,HTMLCanvasElement)?hbe(e):oi(e,HTMLVideoElement)?pbe(e,t):oi(e,HTMLIFrameElement)?mbe(e,t):e.cloneNode($V(e))}const vbe=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",$V=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function ybe(e,t,n){var r,i;if($V(t))return t;let s=[];return vbe(e)&&e.assignedNodes?s=Va(e.assignedNodes()):oi(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?s=Va(e.contentDocument.body.childNodes):s=Va(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),s.length===0||oi(e,HTMLVideoElement)||await s.reduce((o,a)=>o.then(()=>Hv(a,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function bbe(e,t,n){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):IV(n).forEach(s=>{let o=i.getPropertyValue(s);s==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),oi(e,HTMLIFrameElement)&&s==="display"&&o==="inline"&&(o="block"),s==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(s,o,i.getPropertyPriority(s))})}function xbe(e,t){oi(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),oi(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function wbe(e,t){if(oi(e,HTMLSelectElement)){const r=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function kbe(e,t,n){return oi(t,Element)&&(bbe(e,t,n),abe(e,t,n),xbe(e,t),wbe(e,t)),t}async function Cbe(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let s=0;s<n.length;s++){const a=n[s].getAttribute("xlink:href");if(a){const c=e.querySelector(a),u=document.querySelector(a);!c&&u&&!r[a]&&(r[a]=await Hv(u,t,!0))}}const i=Object.values(r);if(i.length){const s="http://www.w3.org/1999/xhtml",o=document.createElementNS(s,"svg");o.setAttribute("xmlns",s),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(s,"defs");o.appendChild(a);for(let c=0;c<i.length;c++)a.appendChild(i[c]);e.appendChild(o)}return e}async function Hv(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>gbe(r,t)).then(r=>ybe(e,r,t)).then(r=>kbe(e,r,t)).then(r=>Cbe(r,t))}const DV=/url\((['"]?)([^'"]+?)\1\)/g,Ebe=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Sbe=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function _be(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Abe(e){const t=[];return e.replace(DV,(n,r,i)=>(t.push(i),n)),t.filter(n=>!S6(n))}async function Tbe(e,t,n,r,i){try{const s=n?Y2e(t,n):t,o=Pk(t);let a;return i||(a=await Ik(s,o,r)),e.replace(_be(t),`$1${a}$3`)}catch{}return e}function Pbe(e,{preferredFontFormat:t}){return t?e.replace(Sbe,n=>{for(;;){const[r,,i]=Ebe.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function NV(e){return e.search(DV)!==-1}async function LV(e,t,n){if(!NV(e))return e;const r=Pbe(e,n);return Abe(r).reduce((s,o)=>s.then(a=>Tbe(a,o,t,n)),Promise.resolve(r))}async function vu(e,t,n){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const s=await LV(i,null,n);return t.style.setProperty(e,s,t.style.getPropertyPriority(e)),!0}return!1}async function Ibe(e,t){await vu("background",e,t)||await vu("background-image",e,t),await vu("mask",e,t)||await vu("-webkit-mask",e,t)||await vu("mask-image",e,t)||await vu("-webkit-mask-image",e,t)}async function Mbe(e,t){const n=oi(e,HTMLImageElement);if(!(n&&!S6(e.src))&&!(oi(e,SVGImageElement)&&!S6(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,i=await Ik(r,Pk(r),t);await new Promise((s,o)=>{e.onload=s,e.onerror=t.onImageErrorHandler?(...c)=>{try{s(t.onImageErrorHandler(...c))}catch(u){o(u)}}:o;const a=e;a.decode&&(a.decode=s),a.loading==="lazy"&&(a.loading="eager"),n?(e.srcset="",e.src=i):e.href.baseVal=i})}async function Rbe(e,t){const r=Va(e.childNodes).map(i=>jV(i,t));await Promise.all(r).then(()=>e)}async function jV(e,t){oi(e,Element)&&(await Ibe(e,t),await Mbe(e,t),await Rbe(e,t))}function $be(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),e}const UT={};async function ZT(e){let t=UT[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},UT[e]=t,t}async function WT(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,e.url).href),RV(a,t.fetchRequestInit,({result:c})=>(n=n.replace(o,`url(${c})`),[o,c]))});return Promise.all(s).then(()=>n)}function GT(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=i.exec(r);if(c===null)break;t.push(c[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let c=s.exec(r);if(c===null){if(c=a.exec(r),c===null)break;s.lastIndex=a.lastIndex}else a.lastIndex=s.lastIndex;t.push(c[0])}return t}async function Dbe(e,t){const n=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{Va(i.cssRules||[]).forEach((s,o)=>{if(s.type===CSSRule.IMPORT_RULE){let a=o+1;const c=s.href,u=ZT(c).then(h=>WT(h,t)).then(h=>GT(h).forEach(p=>{try{i.insertRule(p,p.startsWith("@import")?a+=1:i.cssRules.length)}catch(m){console.error("Error inserting rule from remote css",{rule:p,error:m})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(u)}})}catch(s){const o=e.find(a=>a.href==null)||document.styleSheets[0];i.href!=null&&r.push(ZT(i.href).then(a=>WT(a,t)).then(a=>GT(a).forEach(c=>{o.insertRule(c,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{Va(i.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),n))}function Nbe(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>NV(t.style.getPropertyValue("src")))}async function Lbe(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Va(e.ownerDocument.styleSheets),r=await Dbe(n,t);return Nbe(r)}function FV(e){return e.trim().replace(/["']/g,"")}function jbe(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(FV(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(e),t}async function Fbe(e,t){const n=await Lbe(e,t),r=jbe(e);return(await Promise.all(n.filter(s=>r.has(FV(s.style.fontFamily))).map(s=>{const o=s.parentStyleSheet?s.parentStyleSheet.href:null;return LV(s.cssText,o,t)}))).join(`
|
|
507
507
|
`)}async function Obe(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Fbe(e,t);if(n){const r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function Vbe(e,t={}){const{width:n,height:r}=MV(e,t),i=await Hv(e,t,!0);return await Obe(i,t),await jV(i,t),$be(i,t),await rbe(i,n,r)}async function Hbe(e,t={}){const{width:n,height:r}=MV(e,t),i=await Vbe(e,t),s=await D1(i),o=document.createElement("canvas"),a=o.getContext("2d"),c=t.pixelRatio||ebe(),u=t.canvasWidth||n,h=t.canvasHeight||r;return o.width=u*c,o.height=h*c,t.skipAutoScale||tbe(o),o.style.width=`${u}`,o.style.height=`${h}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(s,0,0,o.width,o.height),o}async function Bbe(e,t={}){return(await Hbe(e,t)).toDataURL()}const zbe=e=>{var n;const t=(n=e.ownerDocument)==null?void 0:n.defaultView;return t?e instanceof t.HTMLElement:e instanceof HTMLElement},Gf=async e=>{if(!zbe(e))return null;try{return await Bbe(e,{cacheBust:!0,filter:n=>!(n.id??"").startsWith("rivet-")})}catch{return null}},Bm=$t("component-search-api"),Ube=e=>e instanceof Error&&e.name==="AbortError",Zbe=async(e,{signal:t}={})=>{var n;Bm.debug("Searching component for element:",e.tagName);try{const r=await fetch("/api/search-components",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e]),signal:t});if(!r.ok)return Bm.error(`Component search failed: HTTP ${r.status}`),e;const s=(n=(await r.json()).elements)==null?void 0:n[0];return s||(Bm.debug(`No component file found for <${e.tagName}>${e.className?` class="${e.className}"`:""}${e.id?` id="${e.id}"`:""}`),e)}catch(r){if(Ube(r))throw r;return Bm.error("Component search error:",r),e}},zm=.8,Wbe=.5,N1=()=>{let e=null,t=null,n=null,r=null;const i=o=>{r&&(r.style.left=`${o.left}px`,r.style.top=`${o.top}px`,r.style.width=`${o.width}px`,r.style.height=`${o.height}px`)},s=()=>{if(!e||!t||!r)return;e.left+=(t.left-e.left)*zm,e.top+=(t.top-e.top)*zm,e.width+=(t.width-e.width)*zm,e.height+=(t.height-e.height)*zm,i(e),Math.max(Math.abs(t.left-e.left),Math.abs(t.top-e.top),Math.abs(t.width-e.width),Math.abs(t.height-e.height))>Wbe?n=requestAnimationFrame(s):(e={...t},i(t),n=null)};return{animateTo:(o,a,c=!1)=>{if(r=o,t={...a},c||!e){e={...a},i(a),n&&(cancelAnimationFrame(n),n=null);return}n||(n=requestAnimationFrame(s))},stop:()=>{n&&(cancelAnimationFrame(n),n=null)},reset:()=>{e=null,t=null,n&&(cancelAnimationFrame(n),n=null)}}},Gbe=32,qbe=24,qT=(e,t)=>{const n=t-e;if(n<=0)return[];const r=Math.min(qbe,Math.max(2,Math.ceil(n/Gbe)+1));return Array.from({length:r},(i,s)=>{const o=s/(r-1);return e+n*o})},Kbe=(e,t,n)=>{if(typeof e.elementsFromPoint=="function")return e.elementsFromPoint(t,n);if(typeof e.elementFromPoint!="function")return[];const r=e.elementFromPoint(t,n);return r?[r]:[]},Ybe=(e,t)=>{const n=new Set,r=qT(t.left,t.right),i=qT(t.top,t.bottom);return r.forEach(s=>{i.forEach(o=>{Kbe(e,s,o).forEach(a=>{let c=a;for(;c;)n.add(c),c=c.parentElement})})}),Array.from(n).sort((s,o)=>{var u;if(s===o)return 0;const a=((u=e.defaultView)==null?void 0:u.Node)??Node;return s.compareDocumentPosition(o)&a.DOCUMENT_POSITION_PRECEDING?1:-1})},OV=(e,t)=>Ybe(e,t).filter(r=>{const i=r.getBoundingClientRect();return i.left<t.right&&i.right>t.left&&i.top<t.bottom&&i.bottom>t.top&&i.width>0&&i.height>0}),wx=new WeakMap,Xbe=e=>{let t=null;return{schedule:()=>{t===null&&(t=window.requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(window.cancelAnimationFrame(t),t=null)}}},Qbe=e=>{var u;const t=wx.get(e);if(t)return t;const n=new Set,r=()=>{n.forEach(h=>h.handleChange())},i=()=>{n.forEach(h=>h.handleScroll())},s=new MutationObserver(r),o=e.body,a=((u=e.defaultView)==null?void 0:u.Node)??Node;if(o instanceof a)try{s.observe(o,{childList:!0,subtree:!0,attributes:!0})}catch{}e.addEventListener("scroll",i,!0);const c={subscribers:n,disconnect:()=>{s.disconnect(),e.removeEventListener("scroll",i,!0),wx.delete(e)}};return wx.set(e,c),c},Jbe=(e,t)=>{const n=Qbe(e);return n.subscribers.add(t),()=>{n.subscribers.delete(t),n.subscribers.size===0&&n.disconnect()}},VV=({iframe:e,onChange:t,onScroll:n})=>{const r=Xbe(t);let i=null,s=null;const o=()=>{r.schedule()},a=()=>{n==null||n(),r.schedule()},c=()=>{s==null||s(),s=null},u=p=>{c(),s=Jbe(p,{handleChange:o,handleScroll:a}),r.schedule()},h=()=>{const p=e==null?void 0:e.contentDocument;p&&u(p)};return e&&(i=new ResizeObserver(o),i.observe(e),e.contentDocument&&u(e.contentDocument),e.addEventListener("load",h)),()=>{e==null||e.removeEventListener("load",h),i==null||i.disconnect(),c(),r.cancel()}},pl={theme:{extend:{fontFamily:{main:["Satoshi","Inter","system-ui","-apple-system","Segoe UI","sans-serif"]},zIndex:{"resize-handle":"36","capture-overlay":"35","selection-overlay":"34","hover-overlay":"30","element-overlay":"25"},colors:{primary:{DEFAULT:"#FF3300",border:"#ff6b35"}}}}},Bv=pl.theme.extend.zIndex,zv=pl.theme.extend.colors,exe=e=>Array.from(e.childNodes).filter(n=>n.nodeType===Node.TEXT_NODE).map(n=>{var r;return((r=n.textContent)==null?void 0:r.trim())||""}).join("").length>0,txe=e=>{const t=e.tagName.toLowerCase();return!!(["path","g","circle","rect","line","polygon"].includes(t)||t==="i"&&e.className&&/\b(fa|icon|material)\b/.test(e.className))},nxe=(e,t,n=6)=>{const i=e.map(o=>{const a=o.getBoundingClientRect(),u=a.width*a.height/t,h=o.tagName.toLowerCase();let p=u>=.2&&u<=3?100:20;return["button","a","input","select","textarea"].includes(h)&&(p+=50),(u<.05||u>10)&&(p-=50),{element:o,score:p,ratio:u}}).filter(o=>o.score>30).filter(o=>!txe(o.element)).sort((o,a)=>a.score-o.score),s=[];for(const o of i)s.some(c=>c.element.contains(o.element))||s.push(o);return s.slice(0,n).map(o=>o.element)},rxe=(e,t,n=6)=>e.map(i=>{const s=i.boundingRect,a=s.width*s.height/t,c=i.tagName.toLowerCase();let u=a>=.2&&a<=3?100:20;return["button","a","input","select","textarea"].includes(c)&&(u+=50),(a<.05||a>10)&&(u-=50),{element:i,score:u,ratio:a}}).filter(({element:i,score:s})=>{const o=i.tagName.toLowerCase();return s>30&&!["path","g","circle","rect","line","polygon"].includes(o)}).sort((i,s)=>s.score-i.score).slice(0,n).map(({element:i})=>i),kx=!1,ixe=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H8.5L4 20V6a2 2 0 0 1 2-2z' fill='%23FF3300' stroke='white' stroke-width='1.5'/%3E%3Cpath d='M9 9h6M9 12h4' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") 4 20, auto`,HV="opacity 0.15s ease-out",Cx=8,Mk=e=>`rivet-hover-overlay--${e}`,Rk=e=>`rivet-selection-overlay--${e}`,BV=e=>`rivet-box-selection-overlay--${e}`,zV=e=>`rivet-mouse-capture--${e}`,_6="rivet-selection-overlay--",sxe="rivet-hover-overlay--",UV='[data-rivet-variant-root="true"]',oxe=`${UV} button[data-action]`,Um=e=>e.closest(UV)!=null,axe=(e,t,n)=>{const r=zr(e);if(!r)return null;const i=e.getBoundingClientRect(),s=t-i.left,o=n-i.top,a=Array.from(r.querySelectorAll(oxe));for(const c of a){const u=c.getBoundingClientRect();if(s>=u.left&&s<=u.right&&o>=u.top&&o<=u.bottom)return c}return null},lxe=e=>{const t=Mk(e);let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.style.cssText=`
|
|
508
508
|
position: fixed;
|
|
509
509
|
pointer-events: none;
|
|
@@ -604,7 +604,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
604
604
|
background: transparent;
|
|
605
605
|
pointer-events: none;
|
|
606
606
|
display: none;
|
|
607
|
-
`,this.iframeRef.parentElement.appendChild(t)),t}removeMouseCaptureOverlay(){var n;if(!((n=this.iframeRef)!=null&&n.parentElement))return;const t=this.iframeRef.parentElement.querySelector("#rivet-mouse-capture");t&&t.remove()}isOverlayInSidebar(t,n,r,i){const s=document.querySelector('[data-cy="element-inspector"]');if(!s)return!1;const o=s.getBoundingClientRect(),a=t+r,c=n+i;return!(a<=o.left||t>=o.right||c<=o.top||n>=o.bottom)}getComputedStyles(){if(!this.currentElement||!this.iframeRef)return Kf.warn("Attempt to get computed styles failed: currentElement ",this.currentElement,"iFrameRef:",this.iframeRef),{};const t=this.iframeRef.contentWindow;if(!t)return Kf.warn("Attempt to get computed styles failed: iFrameWindow not defined"),{};const n=t.getComputedStyle(this.currentElement),r={};for(let i=0;i<n.length;i++){const s=n[i];r[s]=n.getPropertyValue(s)}return r.background=TA(r),r}onStylesChanged(t){return this.onStylesChangedCallback=t,()=>{this.onStylesChangedCallback=null}}refreshStyles(){const t=this.getComputedStyles();this.notifyStylesChanged(t)}setCurrentElement(t){this.currentElement=t,t&&this.refreshStyles()}notifyStylesChanged(t){this.onStylesChangedCallback&&this.onStylesChangedCallback(t)}async applyStyle(t,n,r){const i=await this.findElement(t);if(!i.ok)return ti(i.error);const s=i.value;t.rivetId&&this.injectRivetId(s,t.rivetId);try{return s.style[n]=r,ls(void 0)}catch(o){return ti(new _J(n,r,o instanceof Error?o.message:String(o)))}}async getComputedStylesForElement(t){const n=await this.findElement(t);if(!n.ok)return ti(n.error);const r=n.value;if(!this.iframeRef)return ti(new iu(t,"Iframe ref is null"));const i=this.iframeRef.contentWindow;if(!i)return ti(new iu(t,"Iframe window is null"));try{const s=i.getComputedStyle(r),o={};for(let a=0;a<s.length;a++){const c=s[a];o[c]=s.getPropertyValue(c)}return o.background=TA(o),ls(o)}catch(s){return ti(new iu(t,s instanceof Error?s.message:String(s)))}}async findElement(t){if(!this.iframeRef)return ti(new iu(t,"Iframe ref is null"));const n=zr(this.iframeRef);if(!n)return ti(new iu(t,"Cannot access iframe document"));if(t.rivetId){const r=n.querySelector(`[data-rivet-id="${t.rivetId}"]`);if(r)return ls(r)}if(t.xpath){const r=Ou(n,t.xpath);if(r)return ls(r)}if(t.cssSelector)try{const r=n.querySelector(t.cssSelector);if(r)return ls(r)}catch(r){Kf.warn("Invalid CSS selector:",t.cssSelector,r)}return ti(new iu(t,"Element not found using any identifier strategy"))}injectRivetId(t,n){t.setAttribute("data-rivet-id",n)}createElementIdentifier(t){const n=t.getAttribute("data-rivet-id"),r=Q1(t);let i;if(t.id)i=`#${t.id}`;else if(t.className&&typeof t.className=="string"){const s=t.className.trim().split(/\s+/).join(".");s&&(i=`${t.tagName.toLowerCase()}.${s}`)}return{rivetId:n||"",xpath:r,cssSelector:i}}onHMR(t){var o;this.hmrCallbacks.push(t);let n=null,r=null;const i=()=>{r&&clearTimeout(r),r=setTimeout(()=>{this.handleIframeLoad()},1e3)};this.iframeRef&&this.hmrCallbacks.length===1&&this.iframeRef.addEventListener("load",this.handleIframeLoad);const s=this.iframeRef?zr(this.iframeRef):null;if(s){n=new MutationObserver(u=>{u.some(p=>{var g;const m=p.target;return!((g=m.closest)!=null&&g.call(m,'[id^="rivet-"]'))})&&i()});const a=s.body??s.documentElement??s,c=((o=s.defaultView)==null?void 0:o.Node)??Node;if(a instanceof c)try{n.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","src","href"],characterData:!0})}catch{}}return()=>{const a=this.hmrCallbacks.indexOf(t);a!==-1&&this.hmrCallbacks.splice(a,1),n==null||n.disconnect(),r&&clearTimeout(r),this.hmrCallbacks.length===0&&this.iframeRef&&this.iframeRef.removeEventListener("load",this.handleIframeLoad)}}forceReload(){return new Promise((t,n)=>{var a;if(!((a=this.iframeRef)!=null&&a.contentWindow)){t();return}let r,i=!1;const s=()=>{var c;i||(i=!0,clearTimeout(r),(c=this.iframeRef)==null||c.removeEventListener("load",o))},o=()=>{s(),t()};r=setTimeout(()=>{s(),n(new Error("Iframe reload timeout after 10s"))},1e4),this.iframeRef.addEventListener("load",o);try{this.iframeRef.contentWindow.location.reload()}catch(c){s(),n(c)}})}}class _xe extends GV{}const Axe={pending:"bg-primary",complete:"bg-accent-success",error:"bg-accent-error"},T6=36,P6=28,xg=10,I6=xg/2,a7=T6/2,l7=P6+I6,c7=8,Txe=.65,u7=200,d7=8,Pxe=(e,t)=>{const n=e-t/2,r=window.innerWidth-t-d7;return Math.max(d7,Math.min(n,r))},qV=({comment:e,index:t,position:n,stale:r=!1,onEdit:i,onHover:s,onHoverEnd:o})=>{var b;const[a,c]=f.useState(!1),u=f.useCallback(x=>{x.stopPropagation(),i(e.id)},[e.id,i]),h=n.y/window.innerHeight>Txe,p=e.instruction,g=Pxe(n.x,u7)-(n.x-a7);return y.jsxs("div",{className:"fixed",style:{top:h?n.y:n.y-l7,left:n.x-a7,zIndex:a?55:36,opacity:r?.5:1},onMouseEnter:()=>{c(!0),s==null||s()},onMouseLeave:()=>{c(!1),o==null||o()},children:[y.jsxs("div",{className:"relative cursor-pointer",style:{filter:"drop-shadow(0 1px 3px rgba(0,0,0,0.2))"},onClick:u,children:[y.jsx("div",{className:"absolute bg-main",style:{width:xg,height:xg,left:(T6-xg)/2,top:h?-I6:P6-I6,transform:"rotate(45deg)",borderRadius:3}}),y.jsxs("div",{className:"relative flex items-center justify-center rounded-lg bg-main",style:{width:T6,height:P6},children:[y.jsx("div",{className:`flex h-5 w-5 items-center justify-center rounded-full ${Axe[e.status]}`,children:y.jsx("span",{className:"text-[10px] font-bold leading-none text-white",children:t+1})}),e.variantRequest?y.jsx("div",{"aria-label":"Direction request","data-testid":"comment-marker-variant-glyph",className:"absolute -right-1 -top-1 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-primary text-white",children:y.jsx(NI,{className:"h-2.5 w-2.5",weight:"bold"})}):null]})]}),y.jsx(ds,{children:a&&(p||((b=e.images)==null?void 0:b.length))&&y.jsxs(dn.div,{className:"absolute rounded-lg bg-main px-3 py-2 shadow-lg",style:{left:g,top:h?-c7:l7+c7,transformOrigin:h?"bottom center":"top center",width:u7},initial:{scale:.96,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.96,opacity:0,transition:{duration:.06,ease:[.55,0,1,.45]}},transition:{duration:.08,ease:[.165,.84,.44,1]},children:[p?y.jsx("p",{className:"line-clamp-2 text-left text-xs leading-snug text-content",children:p}):null,e.images&&e.images.length>0?y.jsx("div",{className:`flex flex-wrap justify-center gap-1 ${p?"mt-1.5":""}`,children:e.images.map((x,C)=>y.jsx("img",{src:x,alt:`Reference ${C+1}`,className:"max-h-10 rounded border border-divider"},C))}):null]})})]})},Ixe=({onEditComment:e,target:t,iframeRef:n})=>{const[r,i]=Bn(Hi),[s,o]=f.useState(null),[,a]=f.useState(0),c=f.useRef(null),u=f.useRef(new Map),h=f.useRef(new Set),p=f.useRef(null),m=f.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null,a(S=>S+1)}))},[]);f.useEffect(()=>{const S=n==null?void 0:n.current;if(!S)return;let R=null;const $=()=>{const O=zr(S);!O||O===R||(R&&R.removeEventListener("scroll",m,!0),R=O,O.addEventListener("scroll",m,!0))},L=()=>{$(),m()};$(),S.addEventListener("load",L),window.addEventListener("resize",m);const j=new ResizeObserver(m);return j.observe(S),c.current=()=>{S.removeEventListener("load",L),window.removeEventListener("resize",m),j.disconnect(),R&&R.removeEventListener("scroll",m,!0),p.current!==null&&(cancelAnimationFrame(p.current),p.current=null)},()=>{var O;return(O=c.current)==null?void 0:O.call(c)}},[n,m]);const g=f.useCallback(S=>{const R=n==null?void 0:n.current;R&&Hu(R,r.values()),i($=>{const L=new Map($);return L.delete(S),L})},[i,n,r]),b=Array.from(r.values()).filter(S=>Gh(S.target??Qs,t));if(b.length===0)return null;const x=(n==null?void 0:n.current)??null,C=x?zr(x):null,w=(x==null?void 0:x.getBoundingClientRect())??null,E=(S,R,$,L)=>{const j=u.current.get(S);if(!w)return j?{position:j,stale:!0}:null;if(!C){const Z=R.boundingRect,K={x:w.left+Z.left+$*Z.width,y:w.top+Z.top+L*Z.height};return u.current.set(S,K),{position:K,stale:!0}}const O=Vu(C,R);if(!O){if(!h.current.has(S)){const Z=tD(C,R);console.warn("[CommentMarkerLayer] anchor unresolved",{commentId:S,xpath:R.xpath,rivetId:R.rivetId,byRivetHit:!!Z.byRivet,byXPathHit:!!Z.byXPath,fallback:j?"cached-position":"none"}),h.current.add(S)}return j?{position:j,stale:!0}:null}h.current.delete(S);const H=O.getBoundingClientRect();if(H.bottom<0||H.top>w.height)return null;const B={x:w.left+H.left+$*H.width,y:w.top+H.top+L*H.height};return u.current.set(S,B),{position:B,stale:!1}},_=S=>{if(!S.dragBox||!w)return null;const R=C?Vu(C,S.elementContext):null,$=(R==null?void 0:R.getBoundingClientRect())??S.elementContext.boundingRect,{leftPct:L,topPct:j,widthPct:O,heightPct:H}=S.dragBox;return{left:w.left+$.left+L*$.width,top:w.top+$.top+j*$.height,width:O*$.width,height:H*$.height}},T=S=>{if(!w)return null;const R=!S.finalizedVariant&&(S.selectedVariantIndex??0)===0;if(S.dragBox&&R)return _(S);const $=C?Vu(C,S.elementContext):null,L=($==null?void 0:$.getBoundingClientRect())??S.elementContext.boundingRect;return{left:w.left+L.left,top:w.top+L.top,width:L.width,height:L.height}},I=s!=null?r.get(s):void 0,P=I?T(I):null,M=!!(I!=null&&I.dragBox&&!I.finalizedVariant&&(I.selectedVariantIndex??0)===0);for(const S of u.current.keys())r.has(S)||u.current.delete(S);return y.jsxs(y.Fragment,{children:[b.map((S,R)=>{const $=E(S.id,S.elementContext,S.pin.elementXPct,S.pin.elementYPct);return $?y.jsx(qV,{comment:S,index:R,position:$.position,stale:$.stale,onDismiss:g,onEdit:e,onHover:()=>o(S.id),onHoverEnd:()=>o(null)},S.id):null}),P&&y.jsx("div",{"data-comment-hover-overlay":"true",style:{position:"fixed",pointerEvents:"none",zIndex:30,border:M?"1px dashed var(--color-primary, #FF3300)":"1px solid var(--color-primary-border, #ff6b35)",background:M?"rgba(255, 51, 0, 0.08)":"transparent",borderRadius:2,boxSizing:"border-box",left:P.left,top:P.top,width:P.width,height:P.height}})]})};function Mxe({reference:e,onRemove:t}){return y.jsxs("span",{className:"inline-flex max-w-[180px] items-center gap-1 rounded-full border border-divider bg-main-light px-2 py-0.5 text-[11px] text-content",children:[y.jsx($I,{className:"h-3 w-3 shrink-0 text-content-muted",weight:"bold"}),y.jsx("span",{className:"truncate",title:e.label,children:e.label}),y.jsx("button",{type:"button",onClick:t,"aria-label":`Remove reference to ${e.label}`,className:"-mr-0.5 rounded-full p-0.5 text-content-muted transition-colors hover:bg-divider hover:text-content",children:y.jsx(Ho,{className:"h-2.5 w-2.5",weight:"bold"})})]})}const Rxe=$t("CommentReferencePicker"),Wm=(e,t)=>`${e}:${t}`,KV=e=>`direction-reference-option-${e}`,f7=(e,t,n)=>e.kind==="variant"&&e.sessionId===t&&e.variantId===n;function $xe({attached:e,commentTarget:t,onChange:n,onClose:r}){const i=Ce(il),s=Ce(Y1),o=i.active&&i.projectContext.kind==="fresh"&&i.projectContext.workspaceRoot?i.projectContext.workspaceRoot:s,a=f.useRef(null),c=f.useRef([]),u=f.useRef(!1),h=f.useRef(0),p=f.useRef(void 0),m=f.useRef(null),g=f.useRef(r);g.current=r;const[b,x]=f.useState([]),[C,w]=f.useState(0),E=f.useCallback(async()=>{const B=h.current+1;h.current=B;const Z=o?`?projectPath=${encodeURIComponent(o)}`:"";try{const K=await fetch(`/api/variants/history${Z}`,{credentials:"same-origin"});if(!K.ok)return;const q=await K.json();if(B!==h.current)return;const te=(q.variants??[]).filter(F=>{var V;return((V=F.preview)==null?void 0:V.kind)==="static"});x(te)}catch(K){Rxe.warn("failed to load past directions for picker",K)}},[o]),_=f.useCallback(B=>{var q;if((q=m.current)==null||q.call(m),m.current=null,a.current=B,!B){h.current+=1,p.current=void 0;return}u.current||(u.current=!0,B.focus()),p.current!==o&&(p.current=o,E());const Z=te=>{const F=a.current;F&&(F.contains(te.target)||g.current())},K=te=>{te.key==="Escape"&&g.current()};window.addEventListener("pointerdown",Z),window.addEventListener("keydown",K),m.current=()=>{window.removeEventListener("pointerdown",Z),window.removeEventListener("keydown",K)}},[o,E]),T=f.useMemo(()=>new Set(e.map(B=>Wm(B.sessionId,B.variantId))),[e]),I=f.useMemo(()=>i.active?i.variants.filter(B=>B.status==="succeeded").filter(B=>!f7(t,i.sessionId,B.workItemId)).map(B=>({key:Wm(i.sessionId,B.workItemId),reference:{sessionId:i.sessionId,variantId:B.workItemId,label:B.label||"Direction",origin:"live"}})):[],[i,t]),P=f.useMemo(()=>b.filter(B=>!f7(t,B.sessionId,B.variantId)).map(B=>({key:Wm(B.sessionId,B.variantId),reference:{sessionId:B.sessionId,variantId:B.variantId,label:B.label||"Direction",origin:"history"},brief:B.brief})),[b,t]),M=f.useMemo(()=>{const B=new Set(I.map(Z=>Z.key));return P.filter(Z=>!B.has(Z.key))},[I,P]),S=f.useMemo(()=>{const B=[];return I.length>0&&B.push({heading:"This session",rows:I}),M.length>0&&B.push({heading:"Directions",rows:M}),B},[I,M]),R=f.useMemo(()=>S.flatMap(B=>B.rows),[S]),$=f.useMemo(()=>{const B=new Map;return R.forEach((Z,K)=>B.set(Z.key,K)),B},[R]),L=f.useCallback(B=>{const Z=B.key;T.has(Z)?n(e.filter(K=>Wm(K.sessionId,K.variantId)!==Z)):n([...e,B.reference])},[e,T,n]),j=C<R.length?C:0,O=B=>{var Z;w(B),(Z=c.current[B])==null||Z.scrollIntoView({block:"nearest"})},H=B=>{if(B.key==="Escape"){B.preventDefault(),r();return}const Z=R.length;if(Z!==0)switch(B.key){case"ArrowDown":{B.preventDefault(),O((j+1)%Z);break}case"ArrowUp":{B.preventDefault(),O((j-1+Z)%Z);break}case"Enter":case" ":{B.preventDefault();const K=R[j];K&&L(K);break}}};return y.jsx("div",{ref:_,tabIndex:-1,onKeyDown:H,className:"max-h-72 w-72 overflow-y-auto rounded-lg border border-divider bg-main shadow-2xl focus:outline-none",role:"listbox","aria-label":"Reference a direction","aria-activedescendant":R.length>0?KV(j):void 0,children:S.length===0?y.jsx("div",{className:"px-3 py-4 text-xs text-content-muted",children:"No directions available to reference yet."}):S.map(B=>y.jsx(Dxe,{section:B,attachedKeys:T,highlightedIndex:j,indexOf:Z=>$.get(Z)??-1,itemRefs:c,onToggle:L,onHover:w},B.heading))})}function Dxe({section:e,attachedKeys:t,highlightedIndex:n,indexOf:r,itemRefs:i,onToggle:s,onHover:o}){return y.jsxs("div",{children:[y.jsx("div",{className:"sticky top-0 z-10 border-b border-divider bg-main px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider text-content-muted",children:e.heading}),y.jsx("ul",{className:"py-1",children:e.rows.map(a=>{const c=t.has(a.key),u=r(a.key),h=u===n;return y.jsx("li",{children:y.jsxs("button",{type:"button",id:KV(u),ref:p=>{i.current[u]=p},role:"option",onClick:()=>s(a),onMouseEnter:()=>o(u),"aria-selected":c,className:`group flex w-full items-start gap-2 px-3 py-2 text-left transition-colors ${h?"bg-main-hover":"hover:bg-main-input"}`,children:[y.jsx("span",{className:`mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded border ${c?"border-primary bg-primary text-white":"border-divider text-transparent group-hover:border-content-muted"}`,children:y.jsx(za,{className:"h-2.5 w-2.5",weight:"bold"})}),y.jsxs("span",{className:"min-w-0 flex-1",children:[y.jsx("span",{className:"block truncate text-sm text-content",children:a.reference.label}),a.brief?y.jsx("span",{className:"block truncate text-[11px] leading-snug text-content-muted",children:a.brief}):null]})]})},a.key)})})]})}const h7=3,p7=2,m7=8,Nxe=[/\bvariants?\s*[:=]\s*(\d+)(?!\.\d)\b/i,/\b(\d+)(?!\.\d)\s*variants?\b/i,/\bvariants?\s+(\d+)(?!\.\d)\b/i],Lxe=e=>e<p7?p7:e>m7?m7:e,g7=e=>{if(!e)return h7;for(const t of Nxe){const n=t.exec(e);if(!n)continue;const r=n[1];if(!/^\d+$/.test(r))continue;const i=Number.parseInt(r,10);if(!(!Number.isInteger(i)||i<=0))return Lxe(i)}return h7},v7=8,y7=320,b7=8,x7=3,jxe=15e3,Fxe=1,Oxe="7.5rem",Vxe=.65,Hxe=({elementContext:e,target:t=Qs,pin:n,dragBox:r,position:i,onClose:s,existingCommentId:o,isMCPSession:a=!1,onInputChange:c,shake:u})=>{var Ht,Ut;const h=xs(),p=QQ(),[m,g]=Bn(Hi),b=Ce(kp),C=Ce(Ti).variants.isEnabled,w=ze(rl),E=ze(wp),_=ze(O8),T=ze(k$),I=wc(),{sendVariantRequestComment:P}=nD(),M=Ce(V8),S=o?m.get(o):void 0,R=(S==null?void 0:S.instruction)??"",[$,L]=f.useState(R),[j,O]=f.useState((S==null?void 0:S.images)??[]),[H,B]=f.useState((S==null?void 0:S.references)??[]),[Z,K]=f.useState(!1),q=f.useRef(null),te=f.useRef(null),F=f.useRef(null);f.useEffect(()=>{const ee=setTimeout(()=>{const Y=q.current;Y&&(Y.focus(),Y.selectionStart=Y.selectionEnd=Y.value.length)},150);return()=>clearTimeout(ee)},[]);const V=f.useCallback(()=>{F.current&&(clearTimeout(F.current),F.current=null)},[]);f.useEffect(()=>()=>{V()},[V]);const W=f.useRef(u);f.useEffect(()=>{u!==W.current&&p.start({x:[0,-5,5,-4,4,-2,2,0],y:[0,1.5,-1.5,1,-1,.5,-.5,0],transition:{duration:.45,ease:"easeInOut"}})},[u,p]);const N=$.trim()!==R.trim()&&$.trim()!==""||j.length!==(((Ht=S==null?void 0:S.images)==null?void 0:Ht.length)??0)||H.length!==(((Ut=S==null?void 0:S.references)==null?void 0:Ut.length)??0),z=o?N:$.trim()!=="",Q=f.useCallback(ee=>{B(ee),c==null||c($.trim()!==""||j.length>0||ee.length>0)},[$,j.length,c]),J=f.useCallback(ee=>{Q(H.filter(Y=>!(Y.sessionId===ee.sessionId&&Y.variantId===ee.variantId)))},[H,Q]),re=f.useCallback(ee=>{s(ee)},[s]),G=f.useCallback(ee=>{ee.style.height="auto",ee.style.height=`${ee.scrollHeight}px`},[]),X=f.useCallback(ee=>{I3(ee).then(Y=>{O(se=>[...se,Y])}).catch(()=>{console.warn("[CommentPopover] Failed to process image:",ee.name)})},[]),de=f.useCallback(ee=>{O(Y=>[...Y,ee]),c==null||c(!0)},[c]),{isDragOver:ve,dropHandlers:we}=cL(de),je=ee=>{const Y=ee.target.files;if(!Y)return;let se=!1;for(const ce of Array.from(Y))ce.type.startsWith("image/")&&(X(ce),se=!0);te.current&&(te.current.value=""),se&&(c==null||c(!0))},Ae=ee=>{var se;const Y=(se=ee.clipboardData)==null?void 0:se.items;if(Y){for(const ce of Array.from(Y))if(ce.type.startsWith("image/")){ee.preventDefault();const le=ce.getAsFile();le&&(X(le),c==null||c(!0))}}},Le=ee=>{const Y=j.filter((se,ce)=>ce!==ee);O(Y),c==null||c($.trim()!==""||Y.length>0)},tt=f.useCallback(async()=>{const ee=$.trim();if(ee){if(o)g(Y=>{const se=Y.get(o);if(!se)return Y;const ce=new Map(Y);return ce.set(o,{...se,instruction:ee,images:j.length>0?j:void 0,references:H.length>0?H:void 0,variantRequest:void 0}),ce}),h==null||h.capture("comment_edited",{instruction_length:ee.length,image_count:j.length,reference_count:H.length,has_variants:!1});else{const Y=crypto.randomUUID(),se={id:Y,target:t,elementContext:e,pin:n,dragBox:r,instruction:ee,images:j.length>0?j:void 0,references:H.length>0?H:void 0,status:"pending"};g(ce=>{const le=new Map(ce);return le.set(Y,se),le}),h==null||h.capture("comment_added",{instruction_length:ee.length,image_count:j.length,reference_count:H.length,has_variants:!1})}re({preserveSelection:!0})}},[$,j,H,o,e,t,n,r,g,h,re]),vt=f.useCallback(async ee=>{const Y=$.trim();if(!Y)return;const se=ee==="mcp"?g7($):x7,ce=o??crypto.randomUUID();if(o)g(ge=>{const ke=ge.get(o);if(!ke)return ge;const $e=new Map(ge);return $e.set(o,{...ke,instruction:Y,images:void 0,references:H.length>0?H:void 0,variantRequest:{count:se}}),$e}),h==null||h.capture("comment_edited",{instruction_length:Y.length,image_count:0,reference_count:H.length,has_variants:!1});else{const ge={id:ce,target:t,elementContext:e,pin:n,dragBox:r,instruction:Y,references:H.length>0?H:void 0,variantRequest:{count:se},status:"pending"};g(ke=>{const $e=new Map(ke);return $e.set(ce,ge),$e}),h==null||h.capture("comment_added",{instruction_length:Y.length,image_count:0,reference_count:H.length,has_variants:!1})}h==null||h.capture("comment_variant_trigger_started",{source:ee,requestedCount:se}),V(),T(!0),F.current=setTimeout(()=>{F.current=null,T(!1)},jxe),E(!0),w("comment"),_("directions"),re({preserveSelection:!0});const le=await P(ce,{transport:ee==="desktop"?"desktop":"mcp"});le.cancelled||le.success||(V(),T(!1),lt.error(le.error||"Failed to queue direction request"))},[$,H,o,e,t,n,r,g,h,re,w,E,_,T,P,V]),Je=tt,ye=f.useCallback(async()=>{var ee;if(o){Vte(o);const Y=(b==null?void 0:b.current)??null;Y&&Hu(Y,m.values());const se=I.get(qa);se&&se.commentId===o&&(await f1(se.diff),I.set(qa,null));const ce=m.get(o),le=(ee=ce==null?void 0:ce.finalizedVariant)==null?void 0:ee.codeDiff;le&&await f1(le),g(ge=>{const ke=new Map(ge);return ke.delete(o),ke}),h==null||h.capture("comment_deleted")}re()},[o,m,b,g,re,h,I]),Ke=f.useCallback(ee=>{if(ee.key==="Enter"&&(ee.metaKey||ee.ctrlKey)){ee.preventDefault(),ee.nativeEvent.stopImmediatePropagation(),Je();return}if(ee.key==="Enter"&&!ee.shiftKey){ee.preventDefault(),ee.nativeEvent.stopImmediatePropagation(),Je();return}ee.key==="Escape"&&(ee.preventDefault(),ee.nativeEvent.stopImmediatePropagation(),re({preserveSelection:!0}))},[Je,re]),Dt=window.innerHeight,Mt=i.y/Dt>Vxe,jt=o?"Save":"Add",bn=!o&&(a||C),nn=a?"mcp":"desktop",he=a?"mcp-variant-trigger":"desktop-variant-trigger",be=a?"Generate directions":"Generate 3 directions",Ue=(()=>{if($.trim()==="")return"empty_instruction";if(M.getStyleChanges().length>0||M.getTextChanges().length>0)return"mixed_batch";const Y=Array.from(m.values()).filter(le=>le.status==="pending"&&le.id!==o);return Y.some(le=>!!le.variantRequest)?"duplicate_variant_request":Y.some(le=>!le.variantRequest)?"mixed_batch":null})(),ot=a?g7($):x7,at=(()=>{switch(Ue){case"empty_instruction":return"Add an instruction";case"mixed_batch":return"Clear pending changes";case"duplicate_variant_request":return"Request already pending";default:return`Explore ${ot} directions`}})();return y.jsx("div",{className:"z-comment-preview fixed cursor-auto","data-testid":"comment-popover",style:{top:Mt?i.y-v7:i.y+v7,left:Math.max(b7,Math.min(i.x-y7/2,window.innerWidth-y7-b7)),transform:Mt?"translateY(-100%)":void 0},onClick:ee=>ee.stopPropagation(),onDoubleClick:ee=>{ee.stopPropagation(),re({preserveSelection:!0})},children:y.jsx(dn.div,{animate:p,children:y.jsxs(dn.div,{className:"bg-main relative flex w-80 flex-col gap-2 rounded-xl p-4 shadow-2xl",style:{transformOrigin:"center 24px"},initial:{scale:.82,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.82,opacity:0,transition:{duration:.1,ease:[.55,0,1,.45]}},transition:{type:"spring",stiffness:500,damping:28,mass:.8},...we,children:[ve?y.jsx("div",{className:"border-primary bg-primary/10 pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl border-2 border-dashed",children:y.jsx("span",{className:"text-content text-sm font-medium",children:"Drop image here"})}):null,H.length>0?y.jsx("div",{className:"flex flex-wrap gap-1.5",children:H.map(ee=>y.jsx(Mxe,{reference:ee,onRemove:()=>J(ee)},`${ee.sessionId}:${ee.variantId}`))}):null,y.jsx("textarea",{ref:ee=>{q.current=ee,ee&&G(ee)},value:$,onChange:ee=>{const Y=ee.target.value;L(ee.target.value),G(ee.target),c==null||c(Y.trim()!==""||j.length>0)},onKeyDown:Ke,onPaste:Ae,placeholder:"What should change?",rows:Fxe,style:{maxHeight:Oxe,overflowY:"auto"},className:"bg-main-light text-content placeholder:text-content-subtle w-full resize-none rounded-lg p-3 text-sm outline-none"}),j.length>0?y.jsx("div",{className:"max-h-40 overflow-y-auto rounded",children:y.jsx("div",{className:`grid gap-1.5 ${j.length===1?"grid-cols-1":"grid-cols-2"}`,children:j.map((ee,Y)=>y.jsxs("div",{className:"relative",children:[y.jsx("img",{src:ee,alt:`Reference ${Y+1}`,className:`border-divider w-full rounded border object-cover ${j.length===1?"max-h-32":"aspect-[4/3]"}`}),y.jsx("button",{onClick:()=>Le(Y),className:"absolute top-1 right-1 rounded-full bg-red-500/80 p-0.5 text-white backdrop-blur-sm hover:bg-red-600",children:y.jsx(Ho,{className:"h-2.5 w-2.5",weight:"bold"})})]},Y))})}):null,y.jsx("input",{ref:te,type:"file",accept:"image/*",multiple:!0,onChange:je,className:"hidden"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[o?y.jsx("button",{type:"button",onClick:ye,className:"text-content-subtle hover:text-accent-error p-1 transition-colors",title:"Delete comment",children:y.jsx(mM,{className:"h-4 w-4",weight:"bold"})}):null,y.jsx(Ys,{label:"Attach images",children:y.jsx("button",{type:"button","aria-label":"Attach images",onClick:()=>{var ee;return(ee=te.current)==null?void 0:ee.click()},className:"text-content-subtle hover:text-content p-1 transition-colors",children:y.jsx(KI,{className:"h-4 w-4",weight:"bold"})})}),y.jsx(Ys,{label:"Reference a direction",children:y.jsxs("div",{className:"relative",children:[y.jsx("button",{type:"button","aria-label":"Reference a direction","aria-haspopup":"listbox","aria-expanded":Z,onClick:()=>K(ee=>!ee),className:`p-1 transition-colors ${Z||H.length>0?"text-content":"text-content-subtle hover:text-content"}`,children:y.jsx($I,{className:"h-4 w-4",weight:"bold"})}),Z?y.jsx("div",{className:"absolute bottom-full left-0 z-20 mb-2",children:y.jsx($xe,{attached:H,commentTarget:t,onChange:Q,onClose:()=>K(!1)})}):null]})})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[bn?y.jsx(Ys,{label:at,children:y.jsxs("button",{type:"button","aria-label":be,"data-testid":he,onClick:()=>void vt(nn),disabled:Ue!==null,className:"border-main-border text-content hover:bg-main-input flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[y.jsx(NI,{className:"h-4 w-4",weight:"bold"}),y.jsx("span",{children:"Vary"})]})}):null,y.jsx("button",{onClick:()=>Je(),disabled:!z,className:"bg-primary hover:bg-primary-hover rounded-full px-5 py-1.5 text-sm font-medium text-white transition-colors disabled:opacity-50",children:jt})]})]})]})})})},Bxe="allow-scripts allow-same-origin allow-forms allow-popups allow-modals",zxe="allow-scripts allow-forms allow-popups allow-modals",Uxe=e=>e==="embedded"?zxe:Bxe,w7=$t("PreviewSurface"),YV=({target:e,src:t,framework:n,mode:r,isUpstreamReady:i,remountKey:s})=>{const o=No(e),a=ze(WJ),c=ze(GJ),u=ze(ps),h=Ce(Hi),p=ze(B8),m=Ce(Cp),g=Ce(X1),b=g==="embedded",x=ze(pc),[C,w]=Bn(_$),[E,_]=f.useState(null),T=f.useRef(null),I=wc(),[P,M]=Bn(r1),S=f.useCallback(()=>I.get(pc),[I]),R=P&&Gh(P.target,e)?P:null,$=f.useRef(null),{enterEditMode:L}=Exe({iframeRef:$}),j=Ce(Ti);Sxe({iframeRef:$,enabled:j.resize.isEnabled&&!b,surfaceId:o});const O=f.useCallback(G=>x(G),[x]),H=f.useCallback((G,X,de)=>{if(S()){w(ve=>ve+1);return}O(!1),p(null),u(e),M({key:crypto.randomUUID(),target:e,elementContext:G,pin:X,dragBox:de})},[S,w,O,p,u,M,e]),B=f.useCallback(()=>{if(S()){w(G=>G+1);return}M(null),p(null),O(!1)},[S,w,M,O,p]),Z=f.useCallback((G,X,de)=>{L(G,X,de)},[L]),{setupIframe:K,clearSelectionState:q,iframeRef:te}=Cxe({surfaceId:o,target:e,mode:r,isBoxModelVisible:!0,onTextEdit:Z,onCommentClick:H,onCommentSelectionClear:B,isPreviewBridgeEnabled:b}),F=f.useCallback(G=>{M(null),p(null),O(!1),G!=null&&G.preserveSelection||q()},[q,M,O,p]),V=f.useCallback(G=>{const X=h.get(G);X&&(O(!1),p(G),u(e),M({key:crypto.randomUUID(),target:e,elementContext:X.elementContext,pin:X.pin,dragBox:X.dragBox,existingCommentId:G}))},[h,O,p,u,M,e]),W=f.useCallback((G,X)=>{const de=te.current;if(!de)return null;const ve=de.getBoundingClientRect(),we=b?null:zr(de),je=we?Vu(we,G):null,Ae=(je==null?void 0:je.getBoundingClientRect())??G.boundingRect;return{x:ve.left+Ae.left+X.elementXPct*Ae.width,y:ve.top+Ae.top+X.elementYPct*Ae.height}},[b,te]),[,N]=f.useState(0),z=f.useCallback(()=>N(G=>G+1),[]);f.useEffect(()=>{const G=te.current;if(!R||!G)return;const X=b?null:zr(G);X&&X.addEventListener("scroll",z,!0);const de=new ResizeObserver(z);return de.observe(G),G.addEventListener("load",z),()=>{X&&X.removeEventListener("scroll",z,!0),de.disconnect(),G.removeEventListener("load",z)}},[R,te,z,b]);const Q=R?W(R.elementContext,R.pin):null,J=i&&!b;f.useEffect(()=>{if(b){E&&(T.current=null,_(null),c({surfaceId:o,adapter:null}));return}if(n!=="static"&&!i){E&&(T.current=null,_(null),c({surfaceId:o,adapter:null}));return}const G=te.current;if(E&&T.current!==G){T.current=null,_(null),c({surfaceId:o,adapter:null});return}if(G&&!E){const X=n==="static";w7.debug(`Creating ${X?"Static":""}IframeDisplayAdapter`);const de=r==="edit"?"edit":"view",ve=X?new _xe(G,{mode:de,isBoxModelVisible:!0}):new GV(G,{mode:de,isBoxModelVisible:!0});ve.initialize(),T.current=G,_(ve),c({surfaceId:o,adapter:ve})}},[E,n,i,b,r,te,c,o]);const re=f.useCallback(G=>{G?(K(G),$.current=G):$.current=null},[K]);return f.useEffect(()=>(a({surfaceId:o,ref:te}),()=>{a({surfaceId:o,ref:null}),c({surfaceId:o,adapter:null})}),[a,c,o,te]),f.useEffect(()=>{r==="comment"||r==="edit"||S()||(M(null),p(null),r==="view"&&q())},[r,S,q,M,p]),y.jsxs("div",{className:"relative h-full w-full",children:[y.jsx("iframe",{ref:re,src:t,className:"h-full w-full border-none",title:"Project Preview",sandbox:Uxe(g),onLoad:()=>{yt==null||yt.capture("preview_iframe_loaded",{framework:n,src:t})},onError:()=>{yt==null||yt.capture("preview_iframe_load_failed",{framework:n,src:t}),w7.warn("Preview iframe failed to load",{framework:n,src:t})}},s),J?y.jsx(Ixe,{onEditComment:V,target:e,iframeRef:te}):null,(R==null?void 0:R.dragBox)&&!R.existingCommentId&&te.current&&(()=>{const G=te.current,X=G.getBoundingClientRect(),de=b?null:zr(G),ve=de?Vu(de,R.elementContext):null,we=(ve==null?void 0:ve.getBoundingClientRect())??R.elementContext.boundingRect,{leftPct:je,topPct:Ae,widthPct:Le,heightPct:tt}=R.dragBox;return y.jsx("div",{"data-comment-drag-box":"true",style:{position:"fixed",pointerEvents:"none",zIndex:45,border:"1px dashed var(--color-primary, #FF3300)",background:"rgba(255, 51, 0, 0.08)",borderRadius:2,boxSizing:"border-box",left:X.left+we.left+je*we.width,top:X.top+we.top+Ae*we.height,width:Le*we.width,height:tt*we.height}})})(),R&&Q&&!R.existingCommentId&&y.jsx(qV,{comment:{id:"draft",elementContext:R.elementContext,pin:R.pin,instruction:"",status:"pending"},index:h.size,position:Q,onDismiss:()=>{},onEdit:()=>{}}),kc.createPortal(y.jsx(ds,{children:R&&Q?y.jsx(Hxe,{elementContext:R.elementContext,target:e,pin:R.pin,dragBox:R.dragBox,position:Q,onClose:F,existingCommentId:R.existingCommentId,isMCPSession:m,onInputChange:G=>{O(G)},shake:C},R.key):null}),document.body)]})},Zxe=({isInteractionDisabled:e=!1,framework:t,userPort:n,activeDemoSessionId:r=null,holdPreviewNavigation:i=!1})=>{var N;const s=Ce(rl),o=Ce(gw),a=ze(gw),c=Ce(i1),u=ze(i1),h=Ce(il),p=Ce(X1),m=Ce(vw),g=Ce(w$),b=Ce(Cc),x=ze(vw),C=h.active&&h.projectContext.kind==="fresh",w=Ce(yw),E=h.active?h.variants.find(z=>z.workItemId===w&&(z.status==="pending"||z.status==="running"))??null:null,_=h.active&&h.variants.some(z=>z.status==="pending"||z.status==="running"),T=C||_,I=h.active?h.variants.find(z=>z.workItemId===w&&z.status==="succeeded"&&!!z.previewUnavailable)??null:null;f.useEffect(()=>{h.active||x(!1)},[h.active,x]);const P=f.useMemo(()=>{var X;if(m||c||!h.active)return null;const{stage:z,variants:Q}=h,J=z==="ready"||z==="degraded",re=Q.some(de=>{var ve,we;return((ve=de.refinement)==null?void 0:ve.status)==="pending"||((we=de.refinement)==null?void 0:we.status)==="running"});if(!J&&!re)return null;const G=Q.find(de=>{var ve;return de.status==="succeeded"&&((ve=de.preview)==null?void 0:ve.kind)==="static_artifact"});return((X=G==null?void 0:G.preview)==null?void 0:X.kind)==="static_artifact"?G.preview.url:null},[c,m,h]),M=c??P,S=f.useMemo(()=>!h.active||!M?null:h.variants.find(z=>{var Q;return((Q=z.preview)==null?void 0:Q.kind)==="static_artifact"&&M.startsWith(z.preview.url)})??null,[M,h]),R=f.useMemo(()=>h.active?S?{kind:"variant",sessionId:h.sessionId,variantId:S.workItemId}:(!!!(b!=null&&b.left||b!=null&&b.right)||C)&&!M&&m&&g&&h.variants.some(Q=>Q.workItemId===g)?{kind:"variant",sessionId:h.sessionId,variantId:g}:Qs:Qs,[S,h,m,g,M,b,C]),$=f.useRef(null);f.useEffect(()=>{var re,G;if(!S||((re=S.preview)==null?void 0:re.kind)!=="static_artifact"||((G=S.refinement)==null?void 0:G.status)!=="succeeded")return;const z=`${S.workItemId}:${S.refinement.workItemId}`;if($.current===z)return;$.current=z;const Q=S.preview.url.includes("?")?"&":"?",J=`${S.preview.url}${Q}refinement=${encodeURIComponent(S.refinement.workItemId)}`;M!==J&&(u(J),a(X=>X+1))},[M,S,a,u,h]);const L=M!==null||C&&!m,{isUpstreamReady:j,iframeRemountKey:O,initialProbeComplete:H}=K2e(t,{rerunProbeImmediatelyOnVersion:o,skip:L}),B=!!M||j,Z=`${O}:${o}`,K=r?`/try/${encodeURIComponent(r)}`:"",q=t==="static"?`${K}/static/`:`${K}/`,te=p==="embedded"&&typeof window<"u"?`${window.location.protocol}//localhost:${window.location.port}`:"",F=E?"about:blank":M??(i||!B?"about:blank":`${te}${q}`),V=!!E||!!I||!B&&H;let W=null;if(E)W=y.jsxs(y.Fragment,{children:[y.jsx("div",{"aria-hidden":!0,className:"h-8 w-8 animate-spin rounded-full border-2 border-content-muted/30 border-t-content"}),y.jsxs("h2",{className:"text-3xl font-semibold text-content",children:["Building “",E.label||"this direction","”…"]}),y.jsx("p",{className:"text-base leading-relaxed text-content-muted",children:"This direction is still generating. It’ll load here the moment it’s ready."})]});else if(I){const z=((N=I.previewUnavailable)==null?void 0:N.portInUse)??!1;W=y.jsxs(y.Fragment,{children:[y.jsx("h2",{className:"text-3xl font-semibold text-content",children:"This direction’s preview couldn’t start"}),y.jsx("p",{className:"text-base leading-relaxed text-content-muted",children:z?"Rivet tried to start it on a free port, but this project’s dev server insists on a port that’s already taken (its dev script likely hardcodes the port). You can still pick this direction by reading its code, or reload to try again.":"Its preview server didn’t come up, so there’s nothing to show live. You can still pick this direction by reading its code, or reload to try again."}),y.jsx("button",{onClick:()=>window.location.reload(),className:"rounded-md bg-primary px-10 py-2.5 text-sm font-medium text-white transition-colors hover:bg-primary-hover",children:"Reload"})]})}else T?W=y.jsxs(y.Fragment,{children:[y.jsx("h2",{className:"text-3xl font-semibold text-content",children:"Directions will appear here"}),y.jsx("p",{className:"text-base leading-relaxed text-content-muted",children:"Select one from the panel to preview it."})]}):W=y.jsxs(y.Fragment,{children:[y.jsx("h2",{className:"text-3xl font-semibold text-content",children:"Preview isn't connected"}),y.jsx("p",{className:"text-base leading-relaxed text-content-muted",children:"The connection between Rivet and your project is offline. Try restarting Rivet, then click reload below."}),y.jsx("button",{onClick:()=>window.location.reload(),className:"rounded-md bg-primary px-10 py-2.5 text-sm font-medium text-white transition-colors hover:bg-primary-hover",children:"Reload"})]});return y.jsxs("div",{className:"relative h-full w-full",children:[V?y.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-main/90 px-6",children:y.jsx("div",{role:"alert","aria-live":"polite",className:"flex max-w-sm flex-col items-center gap-5 text-center",children:W})}):null,y.jsx(YV,{target:R,src:F,framework:t,mode:e?"view":s,isUpstreamReady:B,remountKey:Z})]})},Yf=10,Wxe=2,Gxe=.18,qxe=.013,k7=.6,C7=.0016,Kxe=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]],Yxe=e=>e*e*e,Xxe=e=>Math.min(1,Math.max(0,e)),XV=({collapsing:e=!1,onCollapsed:t})=>{const n=f.useRef(null),r=f.useRef(null),i=f.useRef(e),s=f.useRef(t);i.current=e,s.current=t;const o=ze(g$);return f.useEffect(()=>{var L;const a=n.current,c=r.current;if(!a||!c)return;o(j=>j+1);const u=a.getContext("2d"),h=Math.min(window.devicePixelRatio||1,2),p=((L=window.matchMedia)==null?void 0:L.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let m=0,g=0,b=0,x=0,C=0,w=1,E=null,_=!1;const T=()=>{b=c.clientWidth,x=c.clientHeight,a.width=Math.floor(b*h),a.height=Math.floor(x*h),u==null||u.setTransform(h,0,0,h,0,0),m=Math.ceil(b/Yf)+1,g=Math.ceil(x/Yf)+1,w=m+g||1},I=(j,O)=>{if(!u)return;u.clearRect(0,0,b,x);const H=Yf-Wxe;for(let B=0;B<g;B++)for(let Z=0;Z<m;Z++){const K=Z*Yf,q=B*Yf,te=.5+.5*Math.sin((K+q)*qxe-j*Gxe),F=(Kxe[B&3][Z&3]+.5)/16;if(te<=F)continue;let V=1;if(O>0&&(V=1-Yxe(Xxe((O-(Z+B)*C7)/k7))),V<=.001)continue;const W=H*V,N=(H-W)/2;u.fillStyle=te>.8?"#ff5a1e":"#ff3300",u.fillRect(K+N,q+N,W,W)}},P=()=>{var j;_||(_=!0,u==null||u.clearRect(0,0,b,x),(j=s.current)==null||j.call(s))},M=j=>{const O=p?0:j/1e3;if(i.current){if(p){P();return}E===null&&(E=j);const H=(j-E)/1e3;if(H-w*C7>=k7){P();return}I(O,H)}else I(O,0);C=requestAnimationFrame(M)};T(),p&&!i.current&&I(0,0),C=requestAnimationFrame(M);const S=()=>{const j=performance.now(),O=p?0:j/1e3,H=!p&&i.current&&E!==null?(j-E)/1e3:0;I(O,H)},R=()=>{_||(T(),S())};let $;return typeof ResizeObserver<"u"?($=new ResizeObserver(R),$.observe(c)):window.addEventListener("resize",R),()=>{o(j=>j-1),cancelAnimationFrame(C),$==null||$.disconnect(),window.removeEventListener("resize",R)}},[o]),y.jsx("div",{className:"relative flex h-full w-full items-center justify-center overflow-hidden bg-[#f3ede3]",children:y.jsx("div",{ref:r,"data-testid":"ascii-dither-stage",className:"aspect-square max-h-[90%] max-w-[90%] overflow-hidden rounded-[64px]",style:{width:"min(90%, 90vh)"},children:y.jsx("canvas",{ref:n,className:"block h-full w-full"})})})};function E7({side:e,sessionId:t,variantId:n,url:r,label:i,isFallback:s=!1}){var b;const o=ze(Cc),a=Ce(rl),c=Ce(il),u=f.useCallback(()=>{if(s){o(null);return}o(x=>{if(!x)return null;const C={...x};return delete C[e],C.left||C.right?C:null})},[o,e,s]),h=f.useMemo(()=>({kind:"variant",sessionId:t,variantId:n}),[t,n]),p=f.useMemo(()=>!c.active||c.sessionId!==t?null:c.variants.find(x=>x.workItemId===n)??null,[t,n,c]),m=f.useMemo(()=>{var C,w;if(((C=p==null?void 0:p.preview)==null?void 0:C.kind)!=="static_artifact"||((w=p.refinement)==null?void 0:w.status)!=="succeeded")return r;const x=p.preview.url.includes("?")?"&":"?";return`${p.preview.url}${x}refinement=${encodeURIComponent(p.refinement.workItemId)}`},[p,r]),g=((b=p==null?void 0:p.refinement)==null?void 0:b.status)==="succeeded"?`${n}:${p.refinement.workItemId}`:n;return y.jsxs("div",{className:"variant-split-secondary","data-cy":"variant-split-pane","data-variant-id":n,children:[y.jsxs("div",{className:"variant-split-secondary-toolbar",children:[y.jsx("span",{className:"variant-split-secondary-label",title:i,children:i}),y.jsx(Ys,{label:"Collapse",children:y.jsx("button",{type:"button",className:"variant-split-secondary-close",onClick:u,"aria-label":"Collapse split view",children:y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:y.jsx("path",{d:"M2.5 2.5 L9.5 9.5 M9.5 2.5 L2.5 9.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})})]}),y.jsx("div",{className:"variant-split-secondary-body relative min-h-0 flex-1",children:y.jsx(YV,{target:h,src:m,framework:"static",mode:a,isUpstreamReady:!0,remountKey:g})})]})}const S7=240;function Qxe(){const e=Ce(Kh),t=Ce(z8),n=f.useRef(null);return f.useEffect(()=>{if(!e||!t||!n.current)return;const r=t.x-S7/2,i=t.y-22;n.current.style.transform=`translate3d(${r}px, ${i}px, 0)`},[e,t]),!e||!t?null:y.jsx("div",{ref:n,"aria-hidden":"true",className:"variant-drag-ghost",style:{width:S7},children:y.jsxs("div",{className:"variant-drag-ghost-body",children:[y.jsxs("div",{className:"variant-drag-ghost-row",children:[y.jsx("div",{className:"variant-drag-ghost-title",children:e.label}),e.runLabel?y.jsx("div",{className:"variant-drag-ghost-tag",style:z$(e.runLabel),children:e.runLabel}):null]}),e.description?y.jsx("div",{className:"variant-drag-ghost-desc",children:e.description}):null]})})}function Jxe(){const e=Ce(Kh),t=Ce(z8),n=ze(Kh),r=ze(Cc),i=f.useRef(null),[s,o]=f.useState(null),[a,c]=f.useState("hidden");f.useEffect(()=>{if(!e){c("hidden"),o(null);return}const p=requestAnimationFrame(()=>c("visible"));return()=>cancelAnimationFrame(p)},[e]);const u=f.useCallback((p,m)=>{const g=i.current;if(!g)return null;const b=g.getBoundingClientRect();return p<b.left||p>b.right||m<b.top||m>b.bottom?null:p<(b.left+b.right)/2?"left":"right"},[]);if(f.useEffect(()=>{if(!e||!t)return;const p=u(t.x,t.y);o(m=>m===p?m:p)},[e,t,u]),f.useEffect(()=>{if(!e)return;const p=m=>{const g=u(m.clientX,m.clientY);if(g&&e.url){const b={sessionId:e.sessionId,variantId:e.variantId,label:e.label,url:e.url};r(x=>({...x??{},[g]:b})),c("exiting"),window.setTimeout(()=>n(null),220)}else c("exiting"),window.setTimeout(()=>n(null),220)};return window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),()=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p)}},[e,u,n,r]),!e)return null;const h=["variant-drop-zones",a==="visible"&&"is-visible",a==="exiting"&&"is-exiting"].filter(Boolean).join(" ");return y.jsxs("div",{ref:i,className:h,"aria-hidden":"true",children:[y.jsx(_7,{side:"left",hovered:s==="left",canDrop:!!e.url,label:e.label}),y.jsx(_7,{side:"right",hovered:s==="right",canDrop:!!e.url,label:e.label})]})}function _7({side:e,hovered:t,canDrop:n,label:r}){return y.jsxs("div",{className:["variant-drop-zone",`is-${e}`,t&&"is-hover",!n&&"is-disabled"].filter(Boolean).join(" "),children:[y.jsxs("div",{className:"variant-drop-zone-inner",children:[y.jsx("div",{className:`variant-drop-zone-icon is-${e}`}),y.jsx("div",{className:"variant-drop-zone-caption",children:n?`Add ${e} split`:"Split unavailable for this direction"})]}),y.jsx("div",{className:"variant-drop-zone-preview","aria-hidden":"true",children:y.jsx("div",{className:"variant-drop-zone-preview-label",children:r})}),y.jsx("div",{className:"variant-drop-zone-border"})]})}const QV=(e,t,n)=>{var s,o;if(!e.active||e.sessionId!==t)return null;const r=e.variants.find(a=>a.workItemId===n);if(((s=r==null?void 0:r.preview)==null?void 0:s.kind)!=="static_artifact")return null;if(((o=r.refinement)==null?void 0:o.status)!=="succeeded")return r.preview.url;const i=r.preview.url.includes("?")?"&":"?";return`${r.preview.url}${i}refinement=${encodeURIComponent(r.refinement.workItemId)}`},A7=(e,t)=>{if(!e)return;const n=QV(t,e.sessionId,e.variantId);return!n||n===e.url?e:{...e,url:n}},e4e=({isLoading:e=!1,isInteractionDisabled:t=!1,activeDemoSessionId:n=null,holdHostedTryoutPreviewNavigation:r=!1})=>{const{config:i,fetchConfig:s,isLoading:o,error:a}=H2e(),[c,u]=f.useState(!1),h=f.useRef(!1);o&&(h.current=!0);const m=!o&&!a&&!!i&&h.current;return f.useEffect(()=>{s().catch(g=>{yt==null||yt.capture("preview_config_load_failed",{message:g instanceof Error?g.message:"unknown_error"})})},[s]),o||m&&!c?o&&r?y.jsx("div",{className:"flex h-full min-h-0 w-full flex-1 bg-main","aria-busy":"true"}):y.jsx(XV,{collapsing:m,onCollapsed:()=>u(!0)}):a||!i?y.jsx("div",{className:"flex h-full w-full items-center justify-center bg-main px-6",children:y.jsxs("div",{className:"max-w-md rounded-lg border border-divider bg-main-light p-4 text-center shadow-lg",children:[y.jsx("p",{className:"text-sm font-medium text-content",children:"We couldn't load your app preview."}),y.jsx("p",{className:"mt-2 text-sm text-content-subtle",children:a||"Missing preview configuration from the server."}),y.jsx("p",{className:"mt-2 text-sm text-content-subtle",children:"If this keeps happening, restart your Rivet session and try again."}),y.jsx("button",{type:"button",className:"mt-4 rounded-md border border-divider px-3 py-1.5 text-xs text-content hover:bg-main/80",onClick:()=>{yt==null||yt.capture("preview_config_retry_clicked"),s().catch(g=>{yt==null||yt.capture("preview_config_load_failed",{message:g instanceof Error?g.message:"unknown_error"})})},children:"Retry preview"})]})}):y.jsx(t4e,{isLoading:e,isInteractionDisabled:t,framework:i.framework,userPort:i.userPort,activeDemoSessionId:n,holdHostedTryoutPreviewNavigation:r})};function t4e(e){const t=Ce(Cc),n=Ce(Kh),r=Ce(rl),i=ze(F8),s=Ce(il),o=Ce(i1),a=t==null?void 0:t.left,c=t==null?void 0:t.right,u=f.useMemo(()=>{var M,S;if(!s.active||s.projectContext.kind!=="fresh"||!(!!a!=!!c))return;const w=(M=a??c)==null?void 0:M.variantId,E=s.variants.filter(R=>{var $;return R.status==="succeeded"&&(($=R.preview)==null?void 0:$.kind)==="static_artifact"&&R.workItemId!==w}),_=o==null?void 0:o.replace(/[?&]refinement=[^&]*$/,""),I=E.find(R=>{var $;return(($=R.preview)==null?void 0:$.kind)==="static_artifact"&&R.preview.url===_})??E[0];if(((S=I==null?void 0:I.preview)==null?void 0:S.kind)!=="static_artifact")return;const P=QV(s,s.sessionId,I.workItemId);if(P)return{sessionId:s.sessionId,variantId:I.workItemId,label:I.label,url:P}},[s,a,c,o]),h=A7(a,s)??(c?u:void 0),p=A7(c,s)??(a?u:void 0),m=!a&&!!h,g=!c&&!!p,b=!!(h||p),x=y.jsx(Zxe,{isInteractionDisabled:e.isInteractionDisabled,framework:e.framework,userPort:e.userPort,activeDemoSessionId:e.activeDemoSessionId,holdPreviewNavigation:e.holdHostedTryoutPreviewNavigation});return y.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-1 flex-col",children:[y.jsxs("div",{className:`variant-preview-region relative flex h-full min-h-0 w-full flex-1 flex-col ${n?"is-dragging":""} ${b?"is-split":""}`,children:[y.jsxs("div",{className:"variant-preview-row flex h-full min-h-0 w-full flex-1",children:[h&&y.jsx(E7,{side:"left",sessionId:h.sessionId,variantId:h.variantId,url:h.url,label:h.label,isFallback:m},`left-${h.sessionId}:${h.variantId}:${h.url}`),!(h&&p)&&y.jsx("div",{className:"variant-preview-primary flex h-full min-h-0 flex-1 flex-col",children:x}),p&&y.jsx(E7,{side:"right",sessionId:p.sessionId,variantId:p.variantId,url:p.url,label:p.label,isFallback:g},`right-${p.sessionId}:${p.variantId}:${p.url}`)]}),y.jsx("div",{className:"variant-preview-atmosphere","aria-hidden":"true"}),y.jsx(Jxe,{}),y.jsx(Qxe,{})]}),e.isInteractionDisabled?null:y.jsx(U2e,{mode:r,onModeChange:i,isLoading:e.isLoading})]})}const JV=({message:e,isLoading:t=!0})=>y.jsxs("div",{className:"flex items-center gap-2 text-sm text-content",children:[t?y.jsx(Ua,{className:"h-4 w-4 shrink-0 animate-spin text-primary",weight:"bold"}):null,y.jsx("span",{className:"whitespace-pre-wrap font-sans",children:e})]}),eH="data:image/svg+xml,%3csvg%20width='94'%20height='24'%20viewBox='0%200%2094%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M-0.000156164%2023.832V7.704H5.11184L6.47984%208.424C7.58384%207.704%209.04784%207.344%2010.8718%207.344C12.0718%207.344%2013.1278%207.476%2014.0398%207.74C14.9518%207.98%2015.6838%208.244%2016.2358%208.532C16.8118%208.82%2017.1718%209.024%2017.3158%209.144L15.5158%2013.824C15.2758%2013.656%2014.8198%2013.428%2014.1478%2013.14C13.4998%2012.852%2012.7318%2012.588%2011.8438%2012.348C10.9558%2012.084%2010.0198%2011.952%209.03584%2011.952H8.63984C7.96784%2011.952%207.45184%2012.072%207.09184%2012.312C6.73184%2012.528%206.55184%2013.02%206.55184%2013.788V23.832H-0.000156164ZM23.464%206.156C21.04%206.156%2019.828%205.124%2019.828%203.06C19.828%201.908%2020.128%201.116%2020.728%200.684C21.352%200.227999%2022.264%20-1.43051e-06%2023.464%20-1.43051e-06C24.736%20-1.43051e-06%2025.66%200.227999%2026.236%200.684C26.836%201.116%2027.136%201.908%2027.136%203.06C27.136%205.124%2025.912%206.156%2023.464%206.156ZM20.152%2023.832V7.704H26.704V23.832H20.152ZM37.4767%2023.832L29.6647%207.704H36.9007L40.3207%2016.524L41.2567%2019.116H41.6167L42.5527%2016.524L46.0087%207.704H53.1727L52.5967%209.9L45.4327%2023.832H37.4767ZM61.1953%2023.832C59.6113%2023.832%2058.3873%2023.604%2057.5233%2023.148C56.6833%2022.692%2056.1073%2022.068%2055.7953%2021.276C55.4833%2020.46%2055.3273%2019.524%2055.3273%2018.468V13.032C55.3273%2012.072%2055.4833%2011.196%2055.7953%2010.404C56.1313%209.588%2056.7193%208.94%2057.5593%208.46C58.3993%207.956%2059.6113%207.704%2061.1953%207.704H68.6473C70.5193%207.704%2071.9473%207.932%2072.9313%208.388C73.9393%208.82%2074.6233%209.444%2074.9833%2010.26C75.3673%2011.052%2075.5593%2011.976%2075.5593%2013.032V17.64H69.2593C67.0993%2017.64%2065.4553%2017.592%2064.3273%2017.496C63.2233%2017.4%2062.4433%2017.34%2061.9873%2017.316V17.856C61.9633%2018.816%2062.5393%2019.296%2063.7153%2019.296H64.8313C66.7513%2019.296%2068.5273%2019.26%2070.1593%2019.188C71.7913%2019.092%2073.0033%2019.008%2073.7953%2018.936L75.9553%2022.356C75.9553%2022.596%2075.7513%2022.824%2075.3433%2023.04C74.9353%2023.256%2074.2153%2023.448%2073.1833%2023.616C72.1753%2023.76%2070.7353%2023.832%2068.8633%2023.832H61.1953ZM61.9873%2014.184H68.8993V13.68C68.8993%2013.2%2068.8513%2012.864%2068.7553%2012.672C68.6833%2012.48%2068.4313%2012.36%2067.9993%2012.312C67.5673%2012.264%2066.8353%2012.24%2065.8033%2012.24H63.7153C62.5633%2012.24%2061.9873%2012.72%2061.9873%2013.68V14.184ZM85.8224%2023.832C83.9984%2023.832%2082.7504%2023.448%2082.0784%2022.68C81.4064%2021.912%2081.0704%2020.76%2081.0704%2019.224V12.24H78.1184V7.704H79.6304C80.0384%207.704%2080.3624%207.632%2080.6024%207.488C80.8664%207.32%2081.0344%207.032%2081.1064%206.624L81.7904%202.772H87.6944V7.704H93.7064V12.24H87.6944V17.82C87.6944%2018.42%2087.8384%2018.816%2088.1264%2019.008C88.4144%2019.2%2088.8464%2019.296%2089.4224%2019.296H93.0224L93.7424%2023.472C93.2384%2023.544%2092.4704%2023.628%2091.4384%2023.724C90.4064%2023.796%2089.2784%2023.832%2088.0544%2023.832H85.8224Z'%20fill='%23FF3300'/%3e%3c/svg%3e",tH=({isSigningIn:e,onStartSignIn:t,errorMessage:n=null,isDesktopShell:r=!1,displayMode:i="full"})=>{const s=i==="modal";return y.jsxs("div",{className:s?"glass-panel relative w-full max-w-sm rounded-2xl border border-white/10 px-8 py-14 font-main text-white shadow-2xl":"relative flex min-h-screen flex-col items-center justify-center overflow-hidden bg-[#1c1c20] font-main text-white",children:[r&&!s?y.jsx("div",{className:"fixed left-0 right-0 top-0 z-10 h-8",style:{WebkitAppRegion:"drag"}}):null,y.jsxs("div",{className:"flex flex-col items-center gap-10",children:[y.jsx("img",{src:eH,alt:"Rivet",className:"h-8 w-auto object-contain"}),y.jsxs("div",{className:"text-center",children:[y.jsx("h1",{className:"mb-2 text-xl font-medium text-content",children:"Welcome to Rivet"}),y.jsx("p",{className:"text-sm text-content-muted",children:"Sign in to get started"})]}),y.jsx("button",{onClick:t,disabled:e,className:"glass-panel active-push flex items-center gap-3 rounded-xl px-8 py-3.5 text-sm font-medium transition-all hover:bg-white/10 disabled:opacity-50",children:e?y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"}),y.jsx("span",{children:"Signing in..."})]}):y.jsxs(y.Fragment,{children:[y.jsx("img",{src:"https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg",alt:"Google",className:"h-5 w-5 brightness-110"}),y.jsx("span",{children:"Sign in with Google"})]})}),n?y.jsx("p",{className:"text-center text-xs text-red-200",children:n}):null]})]})},n4e=({message:e})=>y.jsx("div",{className:"relative flex min-h-screen flex-col items-center justify-center overflow-hidden bg-[#1c1c20] font-main text-white",children:y.jsxs("div",{className:"flex flex-col items-center gap-10",children:[y.jsx("img",{src:eH,alt:"Rivet",className:"h-8 w-auto object-contain"}),y.jsxs("div",{className:"glass-panel flex items-center gap-3 rounded-xl px-8 py-3.5 text-sm font-medium",children:[y.jsx(Ua,{className:"h-5 w-5 shrink-0 animate-spin text-primary",weight:"bold"}),y.jsx("span",{children:e})]})]})}),T7=$t("useConfig"),r4e=()=>{var e;return typeof window>"u"?null:((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.queueAccessToken)??null},i4e=()=>{var e;return typeof window>"u"?null:((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.agentApplyMode)??null},s4e=e=>({...m$,...e??{}}),o4e=()=>{const e=Ce(Ti),t=ze(Ti),n=ze(Cp),r=ze(U8),i=ze(X1),s=ze(Z8),o=ze(E$),a=ze(C$),c=ze(v$),u=Wz({queryKey:["rivet-config"],queryFn:async()=>{const g=await fetch("/api/config");if(!g.ok)throw new Error(`Failed to fetch config: ${g.statusText}`);return await g.json()},staleTime:3e4}),{refetch:h}=u;f.useEffect(()=>{const g=u.data;g&&(o(g.agentModeAvailable),c({name:g.name??null,email:g.email??null}),t(s4e(g.featureFlags)),a(!0),g.isMCPSession&&n(!0),g.mcpEditor&&r(g.mcpEditor),i(g.agentApplyMode??i4e()??null),s(g.queueAccessToken??r4e()),T7.info("Config loaded:",g))},[u.data,i,o,t,a,n,r,s,c]),f.useEffect(()=>{u.error&&(a(!0),T7.warn("Failed to load config:",u.error instanceof Error?u.error.message:"Failed to load config"))},[u.error,a]);const p=f.useCallback(async()=>{const g=await h();return g.data?g.data:(a(!0),null)},[h,a]);let m=null;return u.error instanceof Error?m=u.error.message:u.error&&(m="Failed to load config"),{config:u.data??null,featureFlags:e,loading:u.isPending,error:m,refetchConfig:p}},yu=$t("useOAuthCallback"),a4e="https://rivet-proxy.onrender.com",l4e=()=>{const[e,t]=f.useState({isProcessing:!1,isComplete:!1,error:null});return f.useEffect(()=>{const n=new AbortController;let r=!1;return(async()=>{var a,c,u;const s=window.location.hash,o=window.location.search;if(!(!s||!s.includes("access_token"))&&!r){t({isProcessing:!0,isComplete:!1,error:null});try{yu.info("Processing OAuth callback...");const h=new URLSearchParams(s.substring(1)),p=h.get("access_token"),m=h.get("refresh_token"),b=new URLSearchParams(o).get("session");if(!p)throw new Error("No access token found in URL");if(!b)throw new Error("No session ID found in URL");yu.info(`Completing OAuth with session: ${b}`);const x=await fetch(`${a4e}/api/auth/google/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:b,accessToken:p,refreshToken:m}),signal:n.signal}),C=await x.json();if(!x.ok||!C.success)throw new Error(C.error||C.message||"Failed to complete authentication");if(yu.info("OAuth authentication completed successfully"),r)return;if((a=C.user)!=null&&a.id?(yt.identify(C.user.id,{...C.user.email?{email:C.user.email}:{}}),C.user.email&&yt.alias(C.user.email,C.user.id)):(c=C.user)!=null&&c.email&&yt.identify(C.user.email,{email:C.user.email}),(u=C.user)!=null&&u.email&&p)try{const E=await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:C.user.email,token:p,refreshToken:m,userId:C.user.id}),signal:n.signal});E.ok||yu.warn(`Local auth store returned ${E.status}`)}catch(E){if(r)return;yu.warn("Failed to store auth locally:",E)}if(r)return;const w=window.location.pathname;window.history.replaceState({},document.title,w),t({isProcessing:!1,isComplete:!0,error:null})}catch(h){if(r)return;const p=h instanceof Error?h.message:"Unknown error occurred";yu.warn("OAuth callback error:",h),t({isProcessing:!1,isComplete:!1,error:p})}}})(),()=>{r=!0,n.abort()}},[]),e},Ix=$t("useAgentVariantsSession"),c4e=()=>{const e=ze(il),t=ze(wp),n=ze(O8),r=ze(k$),i=ze(YJ),s=wc(),o=f.useRef(null);f.useEffect(()=>{const a=new EventSource("/api/variants/events");return a.onmessage=c=>{try{const u=JSON.parse(c.data),h=o.current;u.active?(r(!1),u.sessionId!==o.current&&(o.current=u.sessionId,t(!0),n("directions"))):(o.current=null,r(!1)),e(u);const p=!u.active&&h!==null,m=u.active&&u.sessionId!==h;if(m&&fetch(`/api/variants/${u.sessionId}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:null})}).catch(g=>Ix.warn("failed to reset preview-port on session switch",g)),p||m){const g=new Set;if(u.active)for(const x of u.variants)g.add(No({kind:"variant",sessionId:u.sessionId,variantId:x.workItemId}));const b=s.get(Cc);for(const x of[b==null?void 0:b.left,b==null?void 0:b.right])x&&g.add(No({kind:"variant",sessionId:x.sessionId,variantId:x.variantId}));i(g)}}catch(u){Ix.warn("failed to parse SSE event payload",u)}},a.onerror=c=>{Ix.warn("SSE error (auto-reconnects)",c),r(!1)},()=>{a.close()}},[e,t,n,r,i,s])},bu=$t("useTokenEditor"),u4e=()=>{const[e,t]=f.useState(null),[n,r]=f.useState(null),[i,s]=f.useState(new Map),[o,a]=f.useState(!0),[c,u]=f.useState(!1),[h,p]=f.useState(null),m=f.useCallback(async()=>{a(!0),p(null);try{const C=await fetch("/api/tokens");if(!C.ok)throw new Error(`Failed to fetch tokens: ${C.statusText}`);const w=await C.json();t(w.registry),r(w.framework),bu.info(`Loaded ${w.framework} tokens`)}catch(C){const w=C instanceof Error?C.message:"Unknown error";p(w),bu.warn("Failed to fetch tokens:",C)}finally{a(!1)}},[]);f.useEffect(()=>{m()},[m]);const g=f.useCallback((C,w,E,_)=>{const T=`${C}.${w}`;s(I=>{const P=new Map(I);return _===E?P.delete(T):P.set(T,{category:C,path:w,originalValue:E,newValue:_}),P})},[]),b=f.useCallback(async()=>{if(i.size===0)return!0;u(!0),p(null);const C=Array.from(i.values());let w=!0;for(const E of C)try{bu.info(`Saving ${E.category}.${E.path} = "${E.newValue}"`);const T=await(await fetch("/api/tokens/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:E.category,path:E.path,value:E.newValue})})).json();if(!T.success)throw new Error(T.error||"Update failed");bu.info(`Successfully saved ${E.category}.${E.path}`)}catch(_){const T=_ instanceof Error?_.message:"Unknown error";p(`Failed to update ${E.category}.${E.path}: ${T}`),bu.warn(`Failed to save ${E.category}.${E.path}:`,_),w=!1;break}return w&&(s(new Map),await m()),u(!1),w},[i,m]),x=f.useCallback(()=>{s(new Map),bu.info("Reverted all pending changes")},[]);return{tokens:e,framework:n,pendingChanges:i,isLoading:o,isSaving:c,error:h,updateToken:g,saveChanges:b,revertChanges:x,refetch:m}};var Mx="rovingFocusGroup.onEntryFocus",d4e={bubbles:!1,cancelable:!0},Vp="RovingFocusGroup",[M6,nH,f4e]=xv(Vp),[h4e,rH]=ws(Vp,[f4e]),[p4e,m4e]=h4e(Vp),iH=f.forwardRef((e,t)=>y.jsx(M6.Provider,{scope:e.__scopeRovingFocusGroup,children:y.jsx(M6.Slot,{scope:e.__scopeRovingFocusGroup,children:y.jsx(g4e,{...e,ref:t})})}));iH.displayName=Vp;var g4e=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:h=!1,...p}=e,m=f.useRef(null),g=Qt(t,m),b=Rp(s),[x,C]=ys({prop:o,defaultProp:a??null,onChange:c,caller:Vp}),[w,E]=f.useState(!1),_=Ya(u),T=nH(n),I=f.useRef(!1),[P,M]=f.useState(0);return f.useEffect(()=>{const S=m.current;if(S)return S.addEventListener(Mx,_),()=>S.removeEventListener(Mx,_)},[_]),y.jsx(p4e,{scope:n,orientation:r,dir:b,loop:i,currentTabStopId:x,onItemFocus:f.useCallback(S=>C(S),[C]),onItemShiftTab:f.useCallback(()=>E(!0),[]),onFocusableItemAdd:f.useCallback(()=>M(S=>S+1),[]),onFocusableItemRemove:f.useCallback(()=>M(S=>S-1),[]),children:y.jsx(Et.div,{tabIndex:w||P===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:dt(e.onMouseDown,()=>{I.current=!0}),onFocus:dt(e.onFocus,S=>{const R=!I.current;if(S.target===S.currentTarget&&R&&!w){const $=new CustomEvent(Mx,d4e);if(S.currentTarget.dispatchEvent($),!$.defaultPrevented){const L=T().filter(Z=>Z.focusable),j=L.find(Z=>Z.active),O=L.find(Z=>Z.id===x),B=[j,O,...L].filter(Boolean).map(Z=>Z.ref.current);aH(B,h)}}I.current=!1}),onBlur:dt(e.onBlur,()=>E(!1))})})}),sH="RovingFocusGroupItem",oH=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,c=Zi(),u=s||c,h=m4e(sH,n),p=h.currentTabStopId===u,m=nH(n),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:x}=h;return f.useEffect(()=>{if(r)return g(),()=>b()},[r,g,b]),y.jsx(M6.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:y.jsx(Et.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...a,ref:t,onMouseDown:dt(e.onMouseDown,C=>{r?h.onItemFocus(u):C.preventDefault()}),onFocus:dt(e.onFocus,()=>h.onItemFocus(u)),onKeyDown:dt(e.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){h.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const w=b4e(C,h.orientation,h.dir);if(w!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let _=m().filter(T=>T.focusable).map(T=>T.ref.current);if(w==="last")_.reverse();else if(w==="prev"||w==="next"){w==="prev"&&_.reverse();const T=_.indexOf(C.currentTarget);_=h.loop?x4e(_,T+1):_.slice(T+1)}setTimeout(()=>aH(_))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:x!=null}):o})})});oH.displayName=sH;var v4e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function y4e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function b4e(e,t,n){const r=y4e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return v4e[r]}function aH(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function x4e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var w4e=iH,k4e=oH,Uv="Tabs",[C4e]=ws(Uv,[rH]),lH=rH(),[E4e,$k]=C4e(Uv),cH=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:c="automatic",...u}=e,h=Rp(a),[p,m]=ys({prop:r,onChange:i,defaultProp:s??"",caller:Uv});return y.jsx(E4e,{scope:n,baseId:Zi(),value:p,onValueChange:m,orientation:o,dir:h,activationMode:c,children:y.jsx(Et.div,{dir:h,"data-orientation":o,...u,ref:t})})});cH.displayName=Uv;var uH="TabsList",dH=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,s=$k(uH,n),o=lH(n);return y.jsx(w4e,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:r,children:y.jsx(Et.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:t})})});dH.displayName=uH;var fH="TabsTrigger",hH=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=e,o=$k(fH,n),a=lH(n),c=gH(o.baseId,r),u=vH(o.baseId,r),h=r===o.value;return y.jsx(k4e,{asChild:!0,...a,focusable:!i,active:h,children:y.jsx(Et.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":u,"data-state":h?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...s,ref:t,onMouseDown:dt(e.onMouseDown,p=>{!i&&p.button===0&&p.ctrlKey===!1?o.onValueChange(r):p.preventDefault()}),onKeyDown:dt(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&o.onValueChange(r)}),onFocus:dt(e.onFocus,()=>{const p=o.activationMode!=="manual";!h&&!i&&p&&o.onValueChange(r)})})})});hH.displayName=fH;var pH="TabsContent",mH=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=e,a=$k(pH,n),c=gH(a.baseId,r),u=vH(a.baseId,r),h=r===a.value,p=f.useRef(h);return f.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),y.jsx(ks,{present:i||h,children:({present:m})=>y.jsx(Et.div,{"data-state":h?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:u,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&s})})});mH.displayName=pH;function gH(e,t){return`${e}-trigger-${t}`}function vH(e,t){return`${e}-content-${t}`}var S4e=cH,_4e=dH,A4e=hH,T4e=mH;const P4e=({tokens:e,pendingChanges:t,category:n,onUpdateToken:r,highlightToken:i})=>{const[s,o]=f.useState(null),[a,c]=f.useState(""),u=f.useRef(null);if(f.useEffect(()=>{i&&u.current&&setTimeout(()=>{var x;(x=u.current)==null||x.scrollIntoView({behavior:"smooth",block:"center"})},100)},[i]),!e||Object.keys(e).length===0)return y.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-gray-500",children:"No tokens defined for this category"});const h=(x,C)=>{const w=`${n}.${x}`,E=t.get(w);return E?E.newValue:C},p=x=>{if(x.includes("var(")||x.includes("--"))return{textClass:"text-white",mutedClass:"text-white/70"};let C=0,w=0,E=0,_=!1;if(x.startsWith("#")){const M=x.slice(1);M.length===3?(C=parseInt(M[0]+M[0],16),w=parseInt(M[1]+M[1],16),E=parseInt(M[2]+M[2],16),_=!0):M.length>=6&&(C=parseInt(M.slice(0,2),16),w=parseInt(M.slice(2,4),16),E=parseInt(M.slice(4,6),16),_=!0)}const T=x.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(T&&(C=parseInt(T[1],10),w=parseInt(T[2],10),E=parseInt(T[3],10),_=!0),!_){const M=x.match(/rgba?\(\s*(\d+)\s+(\d+)\s+(\d+)/);M&&(C=parseInt(M[1],10),w=parseInt(M[2],10),E=parseInt(M[3],10),_=!0)}if(!_){const M=x.match(/hsla?\(\s*(\d+)\s*,\s*(\d+)%?\s*,\s*(\d+)%?/);if(M){const S=AA(parseInt(M[1],10),parseInt(M[2],10),parseInt(M[3],10));C=S.r,w=S.g,E=S.b,_=!0}}if(!_){const M=x.match(/hsla?\(\s*(\d+)\s+(\d+)%?\s+(\d+)%?/);if(M){const S=AA(parseInt(M[1],10),parseInt(M[2],10),parseInt(M[3],10));C=S.r,w=S.g,E=S.b,_=!0}}if(!_){const M=x.match(/oklch\(\s*([\d.]+)(%?)/);if(M){const S=parseFloat(M[1]),$=(M[2]==="%"?S/100:S)>.5;return{textClass:$?"text-gray-900":"text-white",mutedClass:$?"text-gray-600":"text-white/70"}}}if(!_)return{textClass:"text-white",mutedClass:"text-white/70"};const P=rie(C,w,E)>.5;return{textClass:P?"text-gray-900":"text-white",mutedClass:P?"text-gray-600":"text-white/70"}},m=(x,C,w,E)=>{const _=h(C,w),T=s===C,I=T&&a?a:_,P=C.replace(/\./g,"-"),M=i===P||i===x,S=I.includes("rgba")||I.startsWith("#")&&I.length===9||/oklch\(/.test(I)&&I.includes("/"),{textClass:R}=p(I),$=H=>{c(H)},L=H=>{r(n,C,w,H),o(null),c("")},j=H=>{H?(o(C),c(_)):(a&&a!==_&&r(n,C,w,a),o(null),c(""))},O=E?"h-44":"h-52";return y.jsxs(Fo,{open:T,onOpenChange:j,children:[y.jsx(ul,{asChild:!0,children:y.jsxs("div",{ref:M?u:null,className:`group relative flex ${O} cursor-pointer flex-col justify-between overflow-hidden rounded-lg border border-white/10 p-4 transition-all ${M?"animate-token-highlight":""}`,children:[y.jsxs("div",{className:"absolute inset-0",children:[S&&y.jsx("div",{className:"absolute inset-0",style:{backgroundImage:`
|
|
607
|
+
`,this.iframeRef.parentElement.appendChild(t)),t}removeMouseCaptureOverlay(){var n;if(!((n=this.iframeRef)!=null&&n.parentElement))return;const t=this.iframeRef.parentElement.querySelector("#rivet-mouse-capture");t&&t.remove()}isOverlayInSidebar(t,n,r,i){const s=document.querySelector('[data-cy="element-inspector"]');if(!s)return!1;const o=s.getBoundingClientRect(),a=t+r,c=n+i;return!(a<=o.left||t>=o.right||c<=o.top||n>=o.bottom)}getComputedStyles(){if(!this.currentElement||!this.iframeRef)return Kf.warn("Attempt to get computed styles failed: currentElement ",this.currentElement,"iFrameRef:",this.iframeRef),{};const t=this.iframeRef.contentWindow;if(!t)return Kf.warn("Attempt to get computed styles failed: iFrameWindow not defined"),{};const n=t.getComputedStyle(this.currentElement),r={};for(let i=0;i<n.length;i++){const s=n[i];r[s]=n.getPropertyValue(s)}return r.background=TA(r),r}onStylesChanged(t){return this.onStylesChangedCallback=t,()=>{this.onStylesChangedCallback=null}}refreshStyles(){const t=this.getComputedStyles();this.notifyStylesChanged(t)}setCurrentElement(t){this.currentElement=t,t&&this.refreshStyles()}notifyStylesChanged(t){this.onStylesChangedCallback&&this.onStylesChangedCallback(t)}async applyStyle(t,n,r){const i=await this.findElement(t);if(!i.ok)return ti(i.error);const s=i.value;t.rivetId&&this.injectRivetId(s,t.rivetId);try{return s.style[n]=r,ls(void 0)}catch(o){return ti(new _J(n,r,o instanceof Error?o.message:String(o)))}}async getComputedStylesForElement(t){const n=await this.findElement(t);if(!n.ok)return ti(n.error);const r=n.value;if(!this.iframeRef)return ti(new iu(t,"Iframe ref is null"));const i=this.iframeRef.contentWindow;if(!i)return ti(new iu(t,"Iframe window is null"));try{const s=i.getComputedStyle(r),o={};for(let a=0;a<s.length;a++){const c=s[a];o[c]=s.getPropertyValue(c)}return o.background=TA(o),ls(o)}catch(s){return ti(new iu(t,s instanceof Error?s.message:String(s)))}}async findElement(t){if(!this.iframeRef)return ti(new iu(t,"Iframe ref is null"));const n=zr(this.iframeRef);if(!n)return ti(new iu(t,"Cannot access iframe document"));if(t.rivetId){const r=n.querySelector(`[data-rivet-id="${t.rivetId}"]`);if(r)return ls(r)}if(t.xpath){const r=Ou(n,t.xpath);if(r)return ls(r)}if(t.cssSelector)try{const r=n.querySelector(t.cssSelector);if(r)return ls(r)}catch(r){Kf.warn("Invalid CSS selector:",t.cssSelector,r)}return ti(new iu(t,"Element not found using any identifier strategy"))}injectRivetId(t,n){t.setAttribute("data-rivet-id",n)}createElementIdentifier(t){const n=t.getAttribute("data-rivet-id"),r=Q1(t);let i;if(t.id)i=`#${t.id}`;else if(t.className&&typeof t.className=="string"){const s=t.className.trim().split(/\s+/).join(".");s&&(i=`${t.tagName.toLowerCase()}.${s}`)}return{rivetId:n||"",xpath:r,cssSelector:i}}onHMR(t){var o;this.hmrCallbacks.push(t);let n=null,r=null;const i=()=>{r&&clearTimeout(r),r=setTimeout(()=>{this.handleIframeLoad()},1e3)};this.iframeRef&&this.hmrCallbacks.length===1&&this.iframeRef.addEventListener("load",this.handleIframeLoad);const s=this.iframeRef?zr(this.iframeRef):null;if(s){n=new MutationObserver(u=>{u.some(p=>{var g;const m=p.target;return!((g=m.closest)!=null&&g.call(m,'[id^="rivet-"]'))})&&i()});const a=s.body??s.documentElement??s,c=((o=s.defaultView)==null?void 0:o.Node)??Node;if(a instanceof c)try{n.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","src","href"],characterData:!0})}catch{}}return()=>{const a=this.hmrCallbacks.indexOf(t);a!==-1&&this.hmrCallbacks.splice(a,1),n==null||n.disconnect(),r&&clearTimeout(r),this.hmrCallbacks.length===0&&this.iframeRef&&this.iframeRef.removeEventListener("load",this.handleIframeLoad)}}forceReload(){return new Promise((t,n)=>{var a;if(!((a=this.iframeRef)!=null&&a.contentWindow)){t();return}let r,i=!1;const s=()=>{var c;i||(i=!0,clearTimeout(r),(c=this.iframeRef)==null||c.removeEventListener("load",o))},o=()=>{s(),t()};r=setTimeout(()=>{s(),n(new Error("Iframe reload timeout after 10s"))},1e4),this.iframeRef.addEventListener("load",o);try{this.iframeRef.contentWindow.location.reload()}catch(c){s(),n(c)}})}}class _xe extends GV{}const Axe={pending:"bg-primary",complete:"bg-accent-success",error:"bg-accent-error"},T6=36,P6=28,xg=10,I6=xg/2,a7=T6/2,l7=P6+I6,c7=8,Txe=.65,u7=200,d7=8,Pxe=(e,t)=>{const n=e-t/2,r=window.innerWidth-t-d7;return Math.max(d7,Math.min(n,r))},qV=({comment:e,index:t,position:n,stale:r=!1,onEdit:i,onHover:s,onHoverEnd:o})=>{var b;const[a,c]=f.useState(!1),u=f.useCallback(x=>{x.stopPropagation(),i(e.id)},[e.id,i]),h=n.y/window.innerHeight>Txe,p=e.instruction,g=Pxe(n.x,u7)-(n.x-a7);return y.jsxs("div",{className:"fixed",style:{top:h?n.y:n.y-l7,left:n.x-a7,zIndex:a?55:36,opacity:r?.5:1},onMouseEnter:()=>{c(!0),s==null||s()},onMouseLeave:()=>{c(!1),o==null||o()},children:[y.jsxs("div",{className:"relative cursor-pointer",style:{filter:"drop-shadow(0 1px 3px rgba(0,0,0,0.2))"},onClick:u,children:[y.jsx("div",{className:"absolute bg-main",style:{width:xg,height:xg,left:(T6-xg)/2,top:h?-I6:P6-I6,transform:"rotate(45deg)",borderRadius:3}}),y.jsxs("div",{className:"relative flex items-center justify-center rounded-lg bg-main",style:{width:T6,height:P6},children:[y.jsx("div",{className:`flex h-5 w-5 items-center justify-center rounded-full ${Axe[e.status]}`,children:y.jsx("span",{className:"text-[10px] font-bold leading-none text-white",children:t+1})}),e.variantRequest?y.jsx("div",{"aria-label":"Direction request","data-testid":"comment-marker-variant-glyph",className:"absolute -right-1 -top-1 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-primary text-white",children:y.jsx(NI,{className:"h-2.5 w-2.5",weight:"bold"})}):null]})]}),y.jsx(ds,{children:a&&(p||((b=e.images)==null?void 0:b.length))&&y.jsxs(dn.div,{className:"absolute rounded-lg bg-main px-3 py-2 shadow-lg",style:{left:g,top:h?-c7:l7+c7,transformOrigin:h?"bottom center":"top center",width:u7},initial:{scale:.96,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.96,opacity:0,transition:{duration:.06,ease:[.55,0,1,.45]}},transition:{duration:.08,ease:[.165,.84,.44,1]},children:[p?y.jsx("p",{className:"line-clamp-2 text-left text-xs leading-snug text-content",children:p}):null,e.images&&e.images.length>0?y.jsx("div",{className:`flex flex-wrap justify-center gap-1 ${p?"mt-1.5":""}`,children:e.images.map((x,C)=>y.jsx("img",{src:x,alt:`Reference ${C+1}`,className:"max-h-10 rounded border border-divider"},C))}):null]})})]})},Ixe=({onEditComment:e,target:t,iframeRef:n})=>{const[r,i]=Bn(Hi),[s,o]=f.useState(null),[,a]=f.useState(0),c=f.useRef(null),u=f.useRef(new Map),h=f.useRef(new Set),p=f.useRef(null),m=f.useCallback(()=>{p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null,a(S=>S+1)}))},[]);f.useEffect(()=>{const S=n==null?void 0:n.current;if(!S)return;let R=null;const $=()=>{const O=zr(S);!O||O===R||(R&&R.removeEventListener("scroll",m,!0),R=O,O.addEventListener("scroll",m,!0))},L=()=>{$(),m()};$(),S.addEventListener("load",L),window.addEventListener("resize",m);const j=new ResizeObserver(m);return j.observe(S),c.current=()=>{S.removeEventListener("load",L),window.removeEventListener("resize",m),j.disconnect(),R&&R.removeEventListener("scroll",m,!0),p.current!==null&&(cancelAnimationFrame(p.current),p.current=null)},()=>{var O;return(O=c.current)==null?void 0:O.call(c)}},[n,m]);const g=f.useCallback(S=>{const R=n==null?void 0:n.current;R&&Hu(R,r.values()),i($=>{const L=new Map($);return L.delete(S),L})},[i,n,r]),b=Array.from(r.values()).filter(S=>Gh(S.target??Qs,t));if(b.length===0)return null;const x=(n==null?void 0:n.current)??null,C=x?zr(x):null,w=(x==null?void 0:x.getBoundingClientRect())??null,E=(S,R,$,L)=>{const j=u.current.get(S);if(!w)return j?{position:j,stale:!0}:null;if(!C){const Z=R.boundingRect,K={x:w.left+Z.left+$*Z.width,y:w.top+Z.top+L*Z.height};return u.current.set(S,K),{position:K,stale:!0}}const O=Vu(C,R);if(!O){if(!h.current.has(S)){const Z=tD(C,R);console.warn("[CommentMarkerLayer] anchor unresolved",{commentId:S,xpath:R.xpath,rivetId:R.rivetId,byRivetHit:!!Z.byRivet,byXPathHit:!!Z.byXPath,fallback:j?"cached-position":"none"}),h.current.add(S)}return j?{position:j,stale:!0}:null}h.current.delete(S);const H=O.getBoundingClientRect();if(H.bottom<0||H.top>w.height)return null;const B={x:w.left+H.left+$*H.width,y:w.top+H.top+L*H.height};return u.current.set(S,B),{position:B,stale:!1}},_=S=>{if(!S.dragBox||!w)return null;const R=C?Vu(C,S.elementContext):null,$=(R==null?void 0:R.getBoundingClientRect())??S.elementContext.boundingRect,{leftPct:L,topPct:j,widthPct:O,heightPct:H}=S.dragBox;return{left:w.left+$.left+L*$.width,top:w.top+$.top+j*$.height,width:O*$.width,height:H*$.height}},T=S=>{if(!w)return null;const R=!S.finalizedVariant&&(S.selectedVariantIndex??0)===0;if(S.dragBox&&R)return _(S);const $=C?Vu(C,S.elementContext):null,L=($==null?void 0:$.getBoundingClientRect())??S.elementContext.boundingRect;return{left:w.left+L.left,top:w.top+L.top,width:L.width,height:L.height}},I=s!=null?r.get(s):void 0,P=I?T(I):null,M=!!(I!=null&&I.dragBox&&!I.finalizedVariant&&(I.selectedVariantIndex??0)===0);for(const S of u.current.keys())r.has(S)||u.current.delete(S);return y.jsxs(y.Fragment,{children:[b.map((S,R)=>{const $=E(S.id,S.elementContext,S.pin.elementXPct,S.pin.elementYPct);return $?y.jsx(qV,{comment:S,index:R,position:$.position,stale:$.stale,onDismiss:g,onEdit:e,onHover:()=>o(S.id),onHoverEnd:()=>o(null)},S.id):null}),P&&y.jsx("div",{"data-comment-hover-overlay":"true",style:{position:"fixed",pointerEvents:"none",zIndex:30,border:M?"1px dashed var(--color-primary, #FF3300)":"1px solid var(--color-primary-border, #ff6b35)",background:M?"rgba(255, 51, 0, 0.08)":"transparent",borderRadius:2,boxSizing:"border-box",left:P.left,top:P.top,width:P.width,height:P.height}})]})};function Mxe({reference:e,onRemove:t}){return y.jsxs("span",{className:"inline-flex max-w-[180px] items-center gap-1 rounded-full border border-divider bg-main-light px-2 py-0.5 text-[11px] text-content",children:[y.jsx($I,{className:"h-3 w-3 shrink-0 text-content-muted",weight:"bold"}),y.jsx("span",{className:"truncate",title:e.label,children:e.label}),y.jsx("button",{type:"button",onClick:t,"aria-label":`Remove reference to ${e.label}`,className:"-mr-0.5 rounded-full p-0.5 text-content-muted transition-colors hover:bg-divider hover:text-content",children:y.jsx(Ho,{className:"h-2.5 w-2.5",weight:"bold"})})]})}const Rxe=$t("CommentReferencePicker"),Wm=(e,t)=>`${e}:${t}`,KV=e=>`direction-reference-option-${e}`,f7=(e,t,n)=>e.kind==="variant"&&e.sessionId===t&&e.variantId===n;function $xe({attached:e,commentTarget:t,onChange:n,onClose:r}){const i=Ce(il),s=Ce(Y1),o=i.active&&i.projectContext.kind==="fresh"?i.projectContext.workspacePath:s,a=f.useRef(null),c=f.useRef([]),u=f.useRef(!1),h=f.useRef(0),p=f.useRef(void 0),m=f.useRef(null),g=f.useRef(r);g.current=r;const[b,x]=f.useState([]),[C,w]=f.useState(0),E=f.useCallback(async()=>{const B=h.current+1;h.current=B;const Z=o?`?projectPath=${encodeURIComponent(o)}`:"";try{const K=await fetch(`/api/variants/history${Z}`,{credentials:"same-origin"});if(!K.ok)return;const q=await K.json();if(B!==h.current)return;const te=(q.variants??[]).filter(F=>{var V;return((V=F.preview)==null?void 0:V.kind)==="static"});x(te)}catch(K){Rxe.warn("failed to load past directions for picker",K)}},[o]),_=f.useCallback(B=>{var q;if((q=m.current)==null||q.call(m),m.current=null,a.current=B,!B){h.current+=1,p.current=void 0;return}u.current||(u.current=!0,B.focus()),p.current!==o&&(p.current=o,E());const Z=te=>{const F=a.current;F&&(F.contains(te.target)||g.current())},K=te=>{te.key==="Escape"&&g.current()};window.addEventListener("pointerdown",Z),window.addEventListener("keydown",K),m.current=()=>{window.removeEventListener("pointerdown",Z),window.removeEventListener("keydown",K)}},[o,E]),T=f.useMemo(()=>new Set(e.map(B=>Wm(B.sessionId,B.variantId))),[e]),I=f.useMemo(()=>i.active?i.variants.filter(B=>B.status==="succeeded").filter(B=>!f7(t,i.sessionId,B.workItemId)).map(B=>({key:Wm(i.sessionId,B.workItemId),reference:{sessionId:i.sessionId,variantId:B.workItemId,label:B.label||"Direction",origin:"live"}})):[],[i,t]),P=f.useMemo(()=>b.filter(B=>!f7(t,B.sessionId,B.variantId)).map(B=>({key:Wm(B.sessionId,B.variantId),reference:{sessionId:B.sessionId,variantId:B.variantId,label:B.label||"Direction",origin:"history"},brief:B.brief})),[b,t]),M=f.useMemo(()=>{const B=new Set(I.map(Z=>Z.key));return P.filter(Z=>!B.has(Z.key))},[I,P]),S=f.useMemo(()=>{const B=[];return I.length>0&&B.push({heading:"This session",rows:I}),M.length>0&&B.push({heading:"Directions",rows:M}),B},[I,M]),R=f.useMemo(()=>S.flatMap(B=>B.rows),[S]),$=f.useMemo(()=>{const B=new Map;return R.forEach((Z,K)=>B.set(Z.key,K)),B},[R]),L=f.useCallback(B=>{const Z=B.key;T.has(Z)?n(e.filter(K=>Wm(K.sessionId,K.variantId)!==Z)):n([...e,B.reference])},[e,T,n]),j=C<R.length?C:0,O=B=>{var Z;w(B),(Z=c.current[B])==null||Z.scrollIntoView({block:"nearest"})},H=B=>{if(B.key==="Escape"){B.preventDefault(),r();return}const Z=R.length;if(Z!==0)switch(B.key){case"ArrowDown":{B.preventDefault(),O((j+1)%Z);break}case"ArrowUp":{B.preventDefault(),O((j-1+Z)%Z);break}case"Enter":case" ":{B.preventDefault();const K=R[j];K&&L(K);break}}};return y.jsx("div",{ref:_,tabIndex:-1,onKeyDown:H,className:"max-h-72 w-72 overflow-y-auto rounded-lg border border-divider bg-main shadow-2xl focus:outline-none",role:"listbox","aria-label":"Reference a direction","aria-activedescendant":R.length>0?KV(j):void 0,children:S.length===0?y.jsx("div",{className:"px-3 py-4 text-xs text-content-muted",children:"No directions available to reference yet."}):S.map(B=>y.jsx(Dxe,{section:B,attachedKeys:T,highlightedIndex:j,indexOf:Z=>$.get(Z)??-1,itemRefs:c,onToggle:L,onHover:w},B.heading))})}function Dxe({section:e,attachedKeys:t,highlightedIndex:n,indexOf:r,itemRefs:i,onToggle:s,onHover:o}){return y.jsxs("div",{children:[y.jsx("div",{className:"sticky top-0 z-10 border-b border-divider bg-main px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider text-content-muted",children:e.heading}),y.jsx("ul",{className:"py-1",children:e.rows.map(a=>{const c=t.has(a.key),u=r(a.key),h=u===n;return y.jsx("li",{children:y.jsxs("button",{type:"button",id:KV(u),ref:p=>{i.current[u]=p},role:"option",onClick:()=>s(a),onMouseEnter:()=>o(u),"aria-selected":c,className:`group flex w-full items-start gap-2 px-3 py-2 text-left transition-colors ${h?"bg-main-hover":"hover:bg-main-input"}`,children:[y.jsx("span",{className:`mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded border ${c?"border-primary bg-primary text-white":"border-divider text-transparent group-hover:border-content-muted"}`,children:y.jsx(za,{className:"h-2.5 w-2.5",weight:"bold"})}),y.jsxs("span",{className:"min-w-0 flex-1",children:[y.jsx("span",{className:"block truncate text-sm text-content",children:a.reference.label}),a.brief?y.jsx("span",{className:"block truncate text-[11px] leading-snug text-content-muted",children:a.brief}):null]})]})},a.key)})})]})}const h7=3,p7=2,m7=8,Nxe=[/\bvariants?\s*[:=]\s*(\d+)(?!\.\d)\b/i,/\b(\d+)(?!\.\d)\s*variants?\b/i,/\bvariants?\s+(\d+)(?!\.\d)\b/i],Lxe=e=>e<p7?p7:e>m7?m7:e,g7=e=>{if(!e)return h7;for(const t of Nxe){const n=t.exec(e);if(!n)continue;const r=n[1];if(!/^\d+$/.test(r))continue;const i=Number.parseInt(r,10);if(!(!Number.isInteger(i)||i<=0))return Lxe(i)}return h7},v7=8,y7=320,b7=8,x7=3,jxe=15e3,Fxe=1,Oxe="7.5rem",Vxe=.65,Hxe=({elementContext:e,target:t=Qs,pin:n,dragBox:r,position:i,onClose:s,existingCommentId:o,isMCPSession:a=!1,onInputChange:c,shake:u})=>{var Ht,Ut;const h=xs(),p=QQ(),[m,g]=Bn(Hi),b=Ce(kp),C=Ce(Ti).variants.isEnabled,w=ze(rl),E=ze(wp),_=ze(O8),T=ze(k$),I=wc(),{sendVariantRequestComment:P}=nD(),M=Ce(V8),S=o?m.get(o):void 0,R=(S==null?void 0:S.instruction)??"",[$,L]=f.useState(R),[j,O]=f.useState((S==null?void 0:S.images)??[]),[H,B]=f.useState((S==null?void 0:S.references)??[]),[Z,K]=f.useState(!1),q=f.useRef(null),te=f.useRef(null),F=f.useRef(null);f.useEffect(()=>{const ee=setTimeout(()=>{const Y=q.current;Y&&(Y.focus(),Y.selectionStart=Y.selectionEnd=Y.value.length)},150);return()=>clearTimeout(ee)},[]);const V=f.useCallback(()=>{F.current&&(clearTimeout(F.current),F.current=null)},[]);f.useEffect(()=>()=>{V()},[V]);const W=f.useRef(u);f.useEffect(()=>{u!==W.current&&p.start({x:[0,-5,5,-4,4,-2,2,0],y:[0,1.5,-1.5,1,-1,.5,-.5,0],transition:{duration:.45,ease:"easeInOut"}})},[u,p]);const N=$.trim()!==R.trim()&&$.trim()!==""||j.length!==(((Ht=S==null?void 0:S.images)==null?void 0:Ht.length)??0)||H.length!==(((Ut=S==null?void 0:S.references)==null?void 0:Ut.length)??0),z=o?N:$.trim()!=="",Q=f.useCallback(ee=>{B(ee),c==null||c($.trim()!==""||j.length>0||ee.length>0)},[$,j.length,c]),J=f.useCallback(ee=>{Q(H.filter(Y=>!(Y.sessionId===ee.sessionId&&Y.variantId===ee.variantId)))},[H,Q]),re=f.useCallback(ee=>{s(ee)},[s]),G=f.useCallback(ee=>{ee.style.height="auto",ee.style.height=`${ee.scrollHeight}px`},[]),X=f.useCallback(ee=>{I3(ee).then(Y=>{O(se=>[...se,Y])}).catch(()=>{console.warn("[CommentPopover] Failed to process image:",ee.name)})},[]),de=f.useCallback(ee=>{O(Y=>[...Y,ee]),c==null||c(!0)},[c]),{isDragOver:ve,dropHandlers:we}=cL(de),je=ee=>{const Y=ee.target.files;if(!Y)return;let se=!1;for(const ce of Array.from(Y))ce.type.startsWith("image/")&&(X(ce),se=!0);te.current&&(te.current.value=""),se&&(c==null||c(!0))},Ae=ee=>{var se;const Y=(se=ee.clipboardData)==null?void 0:se.items;if(Y){for(const ce of Array.from(Y))if(ce.type.startsWith("image/")){ee.preventDefault();const le=ce.getAsFile();le&&(X(le),c==null||c(!0))}}},Le=ee=>{const Y=j.filter((se,ce)=>ce!==ee);O(Y),c==null||c($.trim()!==""||Y.length>0)},tt=f.useCallback(async()=>{const ee=$.trim();if(ee){if(o)g(Y=>{const se=Y.get(o);if(!se)return Y;const ce=new Map(Y);return ce.set(o,{...se,instruction:ee,images:j.length>0?j:void 0,references:H.length>0?H:void 0,variantRequest:void 0}),ce}),h==null||h.capture("comment_edited",{instruction_length:ee.length,image_count:j.length,reference_count:H.length,has_variants:!1});else{const Y=crypto.randomUUID(),se={id:Y,target:t,elementContext:e,pin:n,dragBox:r,instruction:ee,images:j.length>0?j:void 0,references:H.length>0?H:void 0,status:"pending"};g(ce=>{const le=new Map(ce);return le.set(Y,se),le}),h==null||h.capture("comment_added",{instruction_length:ee.length,image_count:j.length,reference_count:H.length,has_variants:!1})}re({preserveSelection:!0})}},[$,j,H,o,e,t,n,r,g,h,re]),vt=f.useCallback(async ee=>{const Y=$.trim();if(!Y)return;const se=ee==="mcp"?g7($):x7,ce=o??crypto.randomUUID();if(o)g(ge=>{const ke=ge.get(o);if(!ke)return ge;const $e=new Map(ge);return $e.set(o,{...ke,instruction:Y,images:void 0,references:H.length>0?H:void 0,variantRequest:{count:se}}),$e}),h==null||h.capture("comment_edited",{instruction_length:Y.length,image_count:0,reference_count:H.length,has_variants:!1});else{const ge={id:ce,target:t,elementContext:e,pin:n,dragBox:r,instruction:Y,references:H.length>0?H:void 0,variantRequest:{count:se},status:"pending"};g(ke=>{const $e=new Map(ke);return $e.set(ce,ge),$e}),h==null||h.capture("comment_added",{instruction_length:Y.length,image_count:0,reference_count:H.length,has_variants:!1})}h==null||h.capture("comment_variant_trigger_started",{source:ee,requestedCount:se}),V(),T(!0),F.current=setTimeout(()=>{F.current=null,T(!1)},jxe),E(!0),w("comment"),_("directions"),re({preserveSelection:!0});const le=await P(ce,{transport:ee==="desktop"?"desktop":"mcp"});le.cancelled||le.success||(V(),T(!1),lt.error(le.error||"Failed to queue direction request"))},[$,H,o,e,t,n,r,g,h,re,w,E,_,T,P,V]),Je=tt,ye=f.useCallback(async()=>{var ee;if(o){Vte(o);const Y=(b==null?void 0:b.current)??null;Y&&Hu(Y,m.values());const se=I.get(qa);se&&se.commentId===o&&(await f1(se.diff),I.set(qa,null));const ce=m.get(o),le=(ee=ce==null?void 0:ce.finalizedVariant)==null?void 0:ee.codeDiff;le&&await f1(le),g(ge=>{const ke=new Map(ge);return ke.delete(o),ke}),h==null||h.capture("comment_deleted")}re()},[o,m,b,g,re,h,I]),Ke=f.useCallback(ee=>{if(ee.key==="Enter"&&(ee.metaKey||ee.ctrlKey)){ee.preventDefault(),ee.nativeEvent.stopImmediatePropagation(),Je();return}if(ee.key==="Enter"&&!ee.shiftKey){ee.preventDefault(),ee.nativeEvent.stopImmediatePropagation(),Je();return}ee.key==="Escape"&&(ee.preventDefault(),ee.nativeEvent.stopImmediatePropagation(),re({preserveSelection:!0}))},[Je,re]),Dt=window.innerHeight,Mt=i.y/Dt>Vxe,jt=o?"Save":"Add",bn=!o&&(a||C),nn=a?"mcp":"desktop",he=a?"mcp-variant-trigger":"desktop-variant-trigger",be=a?"Generate directions":"Generate 3 directions",Ue=(()=>{if($.trim()==="")return"empty_instruction";if(M.getStyleChanges().length>0||M.getTextChanges().length>0)return"mixed_batch";const Y=Array.from(m.values()).filter(le=>le.status==="pending"&&le.id!==o);return Y.some(le=>!!le.variantRequest)?"duplicate_variant_request":Y.some(le=>!le.variantRequest)?"mixed_batch":null})(),ot=a?g7($):x7,at=(()=>{switch(Ue){case"empty_instruction":return"Add an instruction";case"mixed_batch":return"Clear pending changes";case"duplicate_variant_request":return"Request already pending";default:return`Explore ${ot} directions`}})();return y.jsx("div",{className:"z-comment-preview fixed cursor-auto","data-testid":"comment-popover",style:{top:Mt?i.y-v7:i.y+v7,left:Math.max(b7,Math.min(i.x-y7/2,window.innerWidth-y7-b7)),transform:Mt?"translateY(-100%)":void 0},onClick:ee=>ee.stopPropagation(),onDoubleClick:ee=>{ee.stopPropagation(),re({preserveSelection:!0})},children:y.jsx(dn.div,{animate:p,children:y.jsxs(dn.div,{className:"bg-main relative flex w-80 flex-col gap-2 rounded-xl p-4 shadow-2xl",style:{transformOrigin:"center 24px"},initial:{scale:.82,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.82,opacity:0,transition:{duration:.1,ease:[.55,0,1,.45]}},transition:{type:"spring",stiffness:500,damping:28,mass:.8},...we,children:[ve?y.jsx("div",{className:"border-primary bg-primary/10 pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl border-2 border-dashed",children:y.jsx("span",{className:"text-content text-sm font-medium",children:"Drop image here"})}):null,H.length>0?y.jsx("div",{className:"flex flex-wrap gap-1.5",children:H.map(ee=>y.jsx(Mxe,{reference:ee,onRemove:()=>J(ee)},`${ee.sessionId}:${ee.variantId}`))}):null,y.jsx("textarea",{ref:ee=>{q.current=ee,ee&&G(ee)},value:$,onChange:ee=>{const Y=ee.target.value;L(ee.target.value),G(ee.target),c==null||c(Y.trim()!==""||j.length>0)},onKeyDown:Ke,onPaste:Ae,placeholder:"What should change?",rows:Fxe,style:{maxHeight:Oxe,overflowY:"auto"},className:"bg-main-light text-content placeholder:text-content-subtle w-full resize-none rounded-lg p-3 text-sm outline-none"}),j.length>0?y.jsx("div",{className:"max-h-40 overflow-y-auto rounded",children:y.jsx("div",{className:`grid gap-1.5 ${j.length===1?"grid-cols-1":"grid-cols-2"}`,children:j.map((ee,Y)=>y.jsxs("div",{className:"relative",children:[y.jsx("img",{src:ee,alt:`Reference ${Y+1}`,className:`border-divider w-full rounded border object-cover ${j.length===1?"max-h-32":"aspect-[4/3]"}`}),y.jsx("button",{onClick:()=>Le(Y),className:"absolute top-1 right-1 rounded-full bg-red-500/80 p-0.5 text-white backdrop-blur-sm hover:bg-red-600",children:y.jsx(Ho,{className:"h-2.5 w-2.5",weight:"bold"})})]},Y))})}):null,y.jsx("input",{ref:te,type:"file",accept:"image/*",multiple:!0,onChange:je,className:"hidden"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[o?y.jsx("button",{type:"button",onClick:ye,className:"text-content-subtle hover:text-accent-error p-1 transition-colors",title:"Delete comment",children:y.jsx(mM,{className:"h-4 w-4",weight:"bold"})}):null,y.jsx(Ys,{label:"Attach images",children:y.jsx("button",{type:"button","aria-label":"Attach images",onClick:()=>{var ee;return(ee=te.current)==null?void 0:ee.click()},className:"text-content-subtle hover:text-content p-1 transition-colors",children:y.jsx(KI,{className:"h-4 w-4",weight:"bold"})})}),y.jsx(Ys,{label:"Reference a direction",children:y.jsxs("div",{className:"relative",children:[y.jsx("button",{type:"button","aria-label":"Reference a direction","aria-haspopup":"listbox","aria-expanded":Z,onClick:()=>K(ee=>!ee),className:`p-1 transition-colors ${Z||H.length>0?"text-content":"text-content-subtle hover:text-content"}`,children:y.jsx($I,{className:"h-4 w-4",weight:"bold"})}),Z?y.jsx("div",{className:"absolute bottom-full left-0 z-20 mb-2",children:y.jsx($xe,{attached:H,commentTarget:t,onChange:Q,onClose:()=>K(!1)})}):null]})})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[bn?y.jsx(Ys,{label:at,children:y.jsxs("button",{type:"button","aria-label":be,"data-testid":he,onClick:()=>void vt(nn),disabled:Ue!==null,className:"border-main-border text-content hover:bg-main-input flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[y.jsx(NI,{className:"h-4 w-4",weight:"bold"}),y.jsx("span",{children:"Vary"})]})}):null,y.jsx("button",{onClick:()=>Je(),disabled:!z,className:"bg-primary hover:bg-primary-hover rounded-full px-5 py-1.5 text-sm font-medium text-white transition-colors disabled:opacity-50",children:jt})]})]})]})})})},Bxe="allow-scripts allow-same-origin allow-forms allow-popups allow-modals",zxe="allow-scripts allow-forms allow-popups allow-modals",Uxe=e=>e==="embedded"?zxe:Bxe,w7=$t("PreviewSurface"),YV=({target:e,src:t,framework:n,mode:r,isUpstreamReady:i,remountKey:s})=>{const o=No(e),a=ze(WJ),c=ze(GJ),u=ze(ps),h=Ce(Hi),p=ze(B8),m=Ce(Cp),g=Ce(X1),b=g==="embedded",x=ze(pc),[C,w]=Bn(_$),[E,_]=f.useState(null),T=f.useRef(null),I=wc(),[P,M]=Bn(r1),S=f.useCallback(()=>I.get(pc),[I]),R=P&&Gh(P.target,e)?P:null,$=f.useRef(null),{enterEditMode:L}=Exe({iframeRef:$}),j=Ce(Ti);Sxe({iframeRef:$,enabled:j.resize.isEnabled&&!b,surfaceId:o});const O=f.useCallback(G=>x(G),[x]),H=f.useCallback((G,X,de)=>{if(S()){w(ve=>ve+1);return}O(!1),p(null),u(e),M({key:crypto.randomUUID(),target:e,elementContext:G,pin:X,dragBox:de})},[S,w,O,p,u,M,e]),B=f.useCallback(()=>{if(S()){w(G=>G+1);return}M(null),p(null),O(!1)},[S,w,M,O,p]),Z=f.useCallback((G,X,de)=>{L(G,X,de)},[L]),{setupIframe:K,clearSelectionState:q,iframeRef:te}=Cxe({surfaceId:o,target:e,mode:r,isBoxModelVisible:!0,onTextEdit:Z,onCommentClick:H,onCommentSelectionClear:B,isPreviewBridgeEnabled:b}),F=f.useCallback(G=>{M(null),p(null),O(!1),G!=null&&G.preserveSelection||q()},[q,M,O,p]),V=f.useCallback(G=>{const X=h.get(G);X&&(O(!1),p(G),u(e),M({key:crypto.randomUUID(),target:e,elementContext:X.elementContext,pin:X.pin,dragBox:X.dragBox,existingCommentId:G}))},[h,O,p,u,M,e]),W=f.useCallback((G,X)=>{const de=te.current;if(!de)return null;const ve=de.getBoundingClientRect(),we=b?null:zr(de),je=we?Vu(we,G):null,Ae=(je==null?void 0:je.getBoundingClientRect())??G.boundingRect;return{x:ve.left+Ae.left+X.elementXPct*Ae.width,y:ve.top+Ae.top+X.elementYPct*Ae.height}},[b,te]),[,N]=f.useState(0),z=f.useCallback(()=>N(G=>G+1),[]);f.useEffect(()=>{const G=te.current;if(!R||!G)return;const X=b?null:zr(G);X&&X.addEventListener("scroll",z,!0);const de=new ResizeObserver(z);return de.observe(G),G.addEventListener("load",z),()=>{X&&X.removeEventListener("scroll",z,!0),de.disconnect(),G.removeEventListener("load",z)}},[R,te,z,b]);const Q=R?W(R.elementContext,R.pin):null,J=i&&!b;f.useEffect(()=>{if(b){E&&(T.current=null,_(null),c({surfaceId:o,adapter:null}));return}if(n!=="static"&&!i){E&&(T.current=null,_(null),c({surfaceId:o,adapter:null}));return}const G=te.current;if(E&&T.current!==G){T.current=null,_(null),c({surfaceId:o,adapter:null});return}if(G&&!E){const X=n==="static";w7.debug(`Creating ${X?"Static":""}IframeDisplayAdapter`);const de=r==="edit"?"edit":"view",ve=X?new _xe(G,{mode:de,isBoxModelVisible:!0}):new GV(G,{mode:de,isBoxModelVisible:!0});ve.initialize(),T.current=G,_(ve),c({surfaceId:o,adapter:ve})}},[E,n,i,b,r,te,c,o]);const re=f.useCallback(G=>{G?(K(G),$.current=G):$.current=null},[K]);return f.useEffect(()=>(a({surfaceId:o,ref:te}),()=>{a({surfaceId:o,ref:null}),c({surfaceId:o,adapter:null})}),[a,c,o,te]),f.useEffect(()=>{r==="comment"||r==="edit"||S()||(M(null),p(null),r==="view"&&q())},[r,S,q,M,p]),y.jsxs("div",{className:"relative h-full w-full",children:[y.jsx("iframe",{ref:re,src:t,className:"h-full w-full border-none",title:"Project Preview",sandbox:Uxe(g),onLoad:()=>{yt==null||yt.capture("preview_iframe_loaded",{framework:n,src:t})},onError:()=>{yt==null||yt.capture("preview_iframe_load_failed",{framework:n,src:t}),w7.warn("Preview iframe failed to load",{framework:n,src:t})}},s),J?y.jsx(Ixe,{onEditComment:V,target:e,iframeRef:te}):null,(R==null?void 0:R.dragBox)&&!R.existingCommentId&&te.current&&(()=>{const G=te.current,X=G.getBoundingClientRect(),de=b?null:zr(G),ve=de?Vu(de,R.elementContext):null,we=(ve==null?void 0:ve.getBoundingClientRect())??R.elementContext.boundingRect,{leftPct:je,topPct:Ae,widthPct:Le,heightPct:tt}=R.dragBox;return y.jsx("div",{"data-comment-drag-box":"true",style:{position:"fixed",pointerEvents:"none",zIndex:45,border:"1px dashed var(--color-primary, #FF3300)",background:"rgba(255, 51, 0, 0.08)",borderRadius:2,boxSizing:"border-box",left:X.left+we.left+je*we.width,top:X.top+we.top+Ae*we.height,width:Le*we.width,height:tt*we.height}})})(),R&&Q&&!R.existingCommentId&&y.jsx(qV,{comment:{id:"draft",elementContext:R.elementContext,pin:R.pin,instruction:"",status:"pending"},index:h.size,position:Q,onDismiss:()=>{},onEdit:()=>{}}),kc.createPortal(y.jsx(ds,{children:R&&Q?y.jsx(Hxe,{elementContext:R.elementContext,target:e,pin:R.pin,dragBox:R.dragBox,position:Q,onClose:F,existingCommentId:R.existingCommentId,isMCPSession:m,onInputChange:G=>{O(G)},shake:C},R.key):null}),document.body)]})},Zxe=({isInteractionDisabled:e=!1,framework:t,userPort:n,activeDemoSessionId:r=null,holdPreviewNavigation:i=!1})=>{var N;const s=Ce(rl),o=Ce(gw),a=ze(gw),c=Ce(i1),u=ze(i1),h=Ce(il),p=Ce(X1),m=Ce(vw),g=Ce(w$),b=Ce(Cc),x=ze(vw),C=h.active&&h.projectContext.kind==="fresh",w=Ce(yw),E=h.active?h.variants.find(z=>z.workItemId===w&&(z.status==="pending"||z.status==="running"))??null:null,_=h.active&&h.variants.some(z=>z.status==="pending"||z.status==="running"),T=C||_,I=h.active?h.variants.find(z=>z.workItemId===w&&z.status==="succeeded"&&!!z.previewUnavailable)??null:null;f.useEffect(()=>{h.active||x(!1)},[h.active,x]);const P=f.useMemo(()=>{var X;if(m||c||!h.active)return null;const{stage:z,variants:Q}=h,J=z==="ready"||z==="degraded",re=Q.some(de=>{var ve,we;return((ve=de.refinement)==null?void 0:ve.status)==="pending"||((we=de.refinement)==null?void 0:we.status)==="running"});if(!J&&!re)return null;const G=Q.find(de=>{var ve;return de.status==="succeeded"&&((ve=de.preview)==null?void 0:ve.kind)==="static_artifact"});return((X=G==null?void 0:G.preview)==null?void 0:X.kind)==="static_artifact"?G.preview.url:null},[c,m,h]),M=c??P,S=f.useMemo(()=>!h.active||!M?null:h.variants.find(z=>{var Q;return((Q=z.preview)==null?void 0:Q.kind)==="static_artifact"&&M.startsWith(z.preview.url)})??null,[M,h]),R=f.useMemo(()=>h.active?S?{kind:"variant",sessionId:h.sessionId,variantId:S.workItemId}:(!!!(b!=null&&b.left||b!=null&&b.right)||C)&&!M&&m&&g&&h.variants.some(Q=>Q.workItemId===g)?{kind:"variant",sessionId:h.sessionId,variantId:g}:Qs:Qs,[S,h,m,g,M,b,C]),$=f.useRef(null);f.useEffect(()=>{var re,G;if(!S||((re=S.preview)==null?void 0:re.kind)!=="static_artifact"||((G=S.refinement)==null?void 0:G.status)!=="succeeded")return;const z=`${S.workItemId}:${S.refinement.workItemId}`;if($.current===z)return;$.current=z;const Q=S.preview.url.includes("?")?"&":"?",J=`${S.preview.url}${Q}refinement=${encodeURIComponent(S.refinement.workItemId)}`;M!==J&&(u(J),a(X=>X+1))},[M,S,a,u,h]);const L=M!==null||C&&!m,{isUpstreamReady:j,iframeRemountKey:O,initialProbeComplete:H}=K2e(t,{rerunProbeImmediatelyOnVersion:o,skip:L}),B=!!M||j,Z=`${O}:${o}`,K=r?`/try/${encodeURIComponent(r)}`:"",q=t==="static"?`${K}/static/`:`${K}/`,te=p==="embedded"&&typeof window<"u"?`${window.location.protocol}//localhost:${window.location.port}`:"",F=E?"about:blank":M??(i||!B?"about:blank":`${te}${q}`),V=!!E||!!I||!B&&H;let W=null;if(E)W=y.jsxs(y.Fragment,{children:[y.jsx("div",{"aria-hidden":!0,className:"h-8 w-8 animate-spin rounded-full border-2 border-content-muted/30 border-t-content"}),y.jsxs("h2",{className:"text-3xl font-semibold text-content",children:["Building “",E.label||"this direction","”…"]}),y.jsx("p",{className:"text-base leading-relaxed text-content-muted",children:"This direction is still generating. It’ll load here the moment it’s ready."})]});else if(I){const z=((N=I.previewUnavailable)==null?void 0:N.portInUse)??!1;W=y.jsxs(y.Fragment,{children:[y.jsx("h2",{className:"text-3xl font-semibold text-content",children:"This direction’s preview couldn’t start"}),y.jsx("p",{className:"text-base leading-relaxed text-content-muted",children:z?"Rivet tried to start it on a free port, but this project’s dev server insists on a port that’s already taken (its dev script likely hardcodes the port). You can still pick this direction by reading its code, or reload to try again.":"Its preview server didn’t come up, so there’s nothing to show live. You can still pick this direction by reading its code, or reload to try again."}),y.jsx("button",{onClick:()=>window.location.reload(),className:"rounded-md bg-primary px-10 py-2.5 text-sm font-medium text-white transition-colors hover:bg-primary-hover",children:"Reload"})]})}else T?W=y.jsxs(y.Fragment,{children:[y.jsx("h2",{className:"text-3xl font-semibold text-content",children:"Directions will appear here"}),y.jsx("p",{className:"text-base leading-relaxed text-content-muted",children:"Select one from the panel to preview it."})]}):W=y.jsxs(y.Fragment,{children:[y.jsx("h2",{className:"text-3xl font-semibold text-content",children:"Preview isn't connected"}),y.jsx("p",{className:"text-base leading-relaxed text-content-muted",children:"The connection between Rivet and your project is offline. Try restarting Rivet, then click reload below."}),y.jsx("button",{onClick:()=>window.location.reload(),className:"rounded-md bg-primary px-10 py-2.5 text-sm font-medium text-white transition-colors hover:bg-primary-hover",children:"Reload"})]});return y.jsxs("div",{className:"relative h-full w-full",children:[V?y.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-main/90 px-6",children:y.jsx("div",{role:"alert","aria-live":"polite",className:"flex max-w-sm flex-col items-center gap-5 text-center",children:W})}):null,y.jsx(YV,{target:R,src:F,framework:t,mode:e?"view":s,isUpstreamReady:B,remountKey:Z})]})},Yf=10,Wxe=2,Gxe=.18,qxe=.013,k7=.6,C7=.0016,Kxe=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]],Yxe=e=>e*e*e,Xxe=e=>Math.min(1,Math.max(0,e)),XV=({collapsing:e=!1,onCollapsed:t})=>{const n=f.useRef(null),r=f.useRef(null),i=f.useRef(e),s=f.useRef(t);i.current=e,s.current=t;const o=ze(g$);return f.useEffect(()=>{var L;const a=n.current,c=r.current;if(!a||!c)return;o(j=>j+1);const u=a.getContext("2d"),h=Math.min(window.devicePixelRatio||1,2),p=((L=window.matchMedia)==null?void 0:L.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let m=0,g=0,b=0,x=0,C=0,w=1,E=null,_=!1;const T=()=>{b=c.clientWidth,x=c.clientHeight,a.width=Math.floor(b*h),a.height=Math.floor(x*h),u==null||u.setTransform(h,0,0,h,0,0),m=Math.ceil(b/Yf)+1,g=Math.ceil(x/Yf)+1,w=m+g||1},I=(j,O)=>{if(!u)return;u.clearRect(0,0,b,x);const H=Yf-Wxe;for(let B=0;B<g;B++)for(let Z=0;Z<m;Z++){const K=Z*Yf,q=B*Yf,te=.5+.5*Math.sin((K+q)*qxe-j*Gxe),F=(Kxe[B&3][Z&3]+.5)/16;if(te<=F)continue;let V=1;if(O>0&&(V=1-Yxe(Xxe((O-(Z+B)*C7)/k7))),V<=.001)continue;const W=H*V,N=(H-W)/2;u.fillStyle=te>.8?"#ff5a1e":"#ff3300",u.fillRect(K+N,q+N,W,W)}},P=()=>{var j;_||(_=!0,u==null||u.clearRect(0,0,b,x),(j=s.current)==null||j.call(s))},M=j=>{const O=p?0:j/1e3;if(i.current){if(p){P();return}E===null&&(E=j);const H=(j-E)/1e3;if(H-w*C7>=k7){P();return}I(O,H)}else I(O,0);C=requestAnimationFrame(M)};T(),p&&!i.current&&I(0,0),C=requestAnimationFrame(M);const S=()=>{const j=performance.now(),O=p?0:j/1e3,H=!p&&i.current&&E!==null?(j-E)/1e3:0;I(O,H)},R=()=>{_||(T(),S())};let $;return typeof ResizeObserver<"u"?($=new ResizeObserver(R),$.observe(c)):window.addEventListener("resize",R),()=>{o(j=>j-1),cancelAnimationFrame(C),$==null||$.disconnect(),window.removeEventListener("resize",R)}},[o]),y.jsx("div",{className:"relative flex h-full w-full items-center justify-center overflow-hidden bg-[#f3ede3]",children:y.jsx("div",{ref:r,"data-testid":"ascii-dither-stage",className:"aspect-square max-h-[90%] max-w-[90%] overflow-hidden rounded-[64px]",style:{width:"min(90%, 90vh)"},children:y.jsx("canvas",{ref:n,className:"block h-full w-full"})})})};function E7({side:e,sessionId:t,variantId:n,url:r,label:i,isFallback:s=!1}){var b;const o=ze(Cc),a=Ce(rl),c=Ce(il),u=f.useCallback(()=>{if(s){o(null);return}o(x=>{if(!x)return null;const C={...x};return delete C[e],C.left||C.right?C:null})},[o,e,s]),h=f.useMemo(()=>({kind:"variant",sessionId:t,variantId:n}),[t,n]),p=f.useMemo(()=>!c.active||c.sessionId!==t?null:c.variants.find(x=>x.workItemId===n)??null,[t,n,c]),m=f.useMemo(()=>{var C,w;if(((C=p==null?void 0:p.preview)==null?void 0:C.kind)!=="static_artifact"||((w=p.refinement)==null?void 0:w.status)!=="succeeded")return r;const x=p.preview.url.includes("?")?"&":"?";return`${p.preview.url}${x}refinement=${encodeURIComponent(p.refinement.workItemId)}`},[p,r]),g=((b=p==null?void 0:p.refinement)==null?void 0:b.status)==="succeeded"?`${n}:${p.refinement.workItemId}`:n;return y.jsxs("div",{className:"variant-split-secondary","data-cy":"variant-split-pane","data-variant-id":n,children:[y.jsxs("div",{className:"variant-split-secondary-toolbar",children:[y.jsx("span",{className:"variant-split-secondary-label",title:i,children:i}),y.jsx(Ys,{label:"Collapse",children:y.jsx("button",{type:"button",className:"variant-split-secondary-close",onClick:u,"aria-label":"Collapse split view",children:y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:y.jsx("path",{d:"M2.5 2.5 L9.5 9.5 M9.5 2.5 L2.5 9.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})})]}),y.jsx("div",{className:"variant-split-secondary-body relative min-h-0 flex-1",children:y.jsx(YV,{target:h,src:m,framework:"static",mode:a,isUpstreamReady:!0,remountKey:g})})]})}const S7=240;function Qxe(){const e=Ce(Kh),t=Ce(z8),n=f.useRef(null);return f.useEffect(()=>{if(!e||!t||!n.current)return;const r=t.x-S7/2,i=t.y-22;n.current.style.transform=`translate3d(${r}px, ${i}px, 0)`},[e,t]),!e||!t?null:y.jsx("div",{ref:n,"aria-hidden":"true",className:"variant-drag-ghost",style:{width:S7},children:y.jsxs("div",{className:"variant-drag-ghost-body",children:[y.jsxs("div",{className:"variant-drag-ghost-row",children:[y.jsx("div",{className:"variant-drag-ghost-title",children:e.label}),e.runLabel?y.jsx("div",{className:"variant-drag-ghost-tag",style:z$(e.runLabel),children:e.runLabel}):null]}),e.description?y.jsx("div",{className:"variant-drag-ghost-desc",children:e.description}):null]})})}function Jxe(){const e=Ce(Kh),t=Ce(z8),n=ze(Kh),r=ze(Cc),i=f.useRef(null),[s,o]=f.useState(null),[a,c]=f.useState("hidden");f.useEffect(()=>{if(!e){c("hidden"),o(null);return}const p=requestAnimationFrame(()=>c("visible"));return()=>cancelAnimationFrame(p)},[e]);const u=f.useCallback((p,m)=>{const g=i.current;if(!g)return null;const b=g.getBoundingClientRect();return p<b.left||p>b.right||m<b.top||m>b.bottom?null:p<(b.left+b.right)/2?"left":"right"},[]);if(f.useEffect(()=>{if(!e||!t)return;const p=u(t.x,t.y);o(m=>m===p?m:p)},[e,t,u]),f.useEffect(()=>{if(!e)return;const p=m=>{const g=u(m.clientX,m.clientY);if(g&&e.url){const b={sessionId:e.sessionId,variantId:e.variantId,label:e.label,url:e.url};r(x=>({...x??{},[g]:b})),c("exiting"),window.setTimeout(()=>n(null),220)}else c("exiting"),window.setTimeout(()=>n(null),220)};return window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),()=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p)}},[e,u,n,r]),!e)return null;const h=["variant-drop-zones",a==="visible"&&"is-visible",a==="exiting"&&"is-exiting"].filter(Boolean).join(" ");return y.jsxs("div",{ref:i,className:h,"aria-hidden":"true",children:[y.jsx(_7,{side:"left",hovered:s==="left",canDrop:!!e.url,label:e.label}),y.jsx(_7,{side:"right",hovered:s==="right",canDrop:!!e.url,label:e.label})]})}function _7({side:e,hovered:t,canDrop:n,label:r}){return y.jsxs("div",{className:["variant-drop-zone",`is-${e}`,t&&"is-hover",!n&&"is-disabled"].filter(Boolean).join(" "),children:[y.jsxs("div",{className:"variant-drop-zone-inner",children:[y.jsx("div",{className:`variant-drop-zone-icon is-${e}`}),y.jsx("div",{className:"variant-drop-zone-caption",children:n?`Add ${e} split`:"Split unavailable for this direction"})]}),y.jsx("div",{className:"variant-drop-zone-preview","aria-hidden":"true",children:y.jsx("div",{className:"variant-drop-zone-preview-label",children:r})}),y.jsx("div",{className:"variant-drop-zone-border"})]})}const QV=(e,t,n)=>{var s,o;if(!e.active||e.sessionId!==t)return null;const r=e.variants.find(a=>a.workItemId===n);if(((s=r==null?void 0:r.preview)==null?void 0:s.kind)!=="static_artifact")return null;if(((o=r.refinement)==null?void 0:o.status)!=="succeeded")return r.preview.url;const i=r.preview.url.includes("?")?"&":"?";return`${r.preview.url}${i}refinement=${encodeURIComponent(r.refinement.workItemId)}`},A7=(e,t)=>{if(!e)return;const n=QV(t,e.sessionId,e.variantId);return!n||n===e.url?e:{...e,url:n}},e4e=({isLoading:e=!1,isInteractionDisabled:t=!1,activeDemoSessionId:n=null,holdHostedTryoutPreviewNavigation:r=!1})=>{const{config:i,fetchConfig:s,isLoading:o,error:a}=H2e(),[c,u]=f.useState(!1),h=f.useRef(!1);o&&(h.current=!0);const m=!o&&!a&&!!i&&h.current;return f.useEffect(()=>{s().catch(g=>{yt==null||yt.capture("preview_config_load_failed",{message:g instanceof Error?g.message:"unknown_error"})})},[s]),o||m&&!c?o&&r?y.jsx("div",{className:"flex h-full min-h-0 w-full flex-1 bg-main","aria-busy":"true"}):y.jsx(XV,{collapsing:m,onCollapsed:()=>u(!0)}):a||!i?y.jsx("div",{className:"flex h-full w-full items-center justify-center bg-main px-6",children:y.jsxs("div",{className:"max-w-md rounded-lg border border-divider bg-main-light p-4 text-center shadow-lg",children:[y.jsx("p",{className:"text-sm font-medium text-content",children:"We couldn't load your app preview."}),y.jsx("p",{className:"mt-2 text-sm text-content-subtle",children:a||"Missing preview configuration from the server."}),y.jsx("p",{className:"mt-2 text-sm text-content-subtle",children:"If this keeps happening, restart your Rivet session and try again."}),y.jsx("button",{type:"button",className:"mt-4 rounded-md border border-divider px-3 py-1.5 text-xs text-content hover:bg-main/80",onClick:()=>{yt==null||yt.capture("preview_config_retry_clicked"),s().catch(g=>{yt==null||yt.capture("preview_config_load_failed",{message:g instanceof Error?g.message:"unknown_error"})})},children:"Retry preview"})]})}):y.jsx(t4e,{isLoading:e,isInteractionDisabled:t,framework:i.framework,userPort:i.userPort,activeDemoSessionId:n,holdHostedTryoutPreviewNavigation:r})};function t4e(e){const t=Ce(Cc),n=Ce(Kh),r=Ce(rl),i=ze(F8),s=Ce(il),o=Ce(i1),a=t==null?void 0:t.left,c=t==null?void 0:t.right,u=f.useMemo(()=>{var M,S;if(!s.active||s.projectContext.kind!=="fresh"||!(!!a!=!!c))return;const w=(M=a??c)==null?void 0:M.variantId,E=s.variants.filter(R=>{var $;return R.status==="succeeded"&&(($=R.preview)==null?void 0:$.kind)==="static_artifact"&&R.workItemId!==w}),_=o==null?void 0:o.replace(/[?&]refinement=[^&]*$/,""),I=E.find(R=>{var $;return(($=R.preview)==null?void 0:$.kind)==="static_artifact"&&R.preview.url===_})??E[0];if(((S=I==null?void 0:I.preview)==null?void 0:S.kind)!=="static_artifact")return;const P=QV(s,s.sessionId,I.workItemId);if(P)return{sessionId:s.sessionId,variantId:I.workItemId,label:I.label,url:P}},[s,a,c,o]),h=A7(a,s)??(c?u:void 0),p=A7(c,s)??(a?u:void 0),m=!a&&!!h,g=!c&&!!p,b=!!(h||p),x=y.jsx(Zxe,{isInteractionDisabled:e.isInteractionDisabled,framework:e.framework,userPort:e.userPort,activeDemoSessionId:e.activeDemoSessionId,holdPreviewNavigation:e.holdHostedTryoutPreviewNavigation});return y.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-1 flex-col",children:[y.jsxs("div",{className:`variant-preview-region relative flex h-full min-h-0 w-full flex-1 flex-col ${n?"is-dragging":""} ${b?"is-split":""}`,children:[y.jsxs("div",{className:"variant-preview-row flex h-full min-h-0 w-full flex-1",children:[h&&y.jsx(E7,{side:"left",sessionId:h.sessionId,variantId:h.variantId,url:h.url,label:h.label,isFallback:m},`left-${h.sessionId}:${h.variantId}:${h.url}`),!(h&&p)&&y.jsx("div",{className:"variant-preview-primary flex h-full min-h-0 flex-1 flex-col",children:x}),p&&y.jsx(E7,{side:"right",sessionId:p.sessionId,variantId:p.variantId,url:p.url,label:p.label,isFallback:g},`right-${p.sessionId}:${p.variantId}:${p.url}`)]}),y.jsx("div",{className:"variant-preview-atmosphere","aria-hidden":"true"}),y.jsx(Jxe,{}),y.jsx(Qxe,{})]}),e.isInteractionDisabled?null:y.jsx(U2e,{mode:r,onModeChange:i,isLoading:e.isLoading})]})}const JV=({message:e,isLoading:t=!0})=>y.jsxs("div",{className:"flex items-center gap-2 text-sm text-content",children:[t?y.jsx(Ua,{className:"h-4 w-4 shrink-0 animate-spin text-primary",weight:"bold"}):null,y.jsx("span",{className:"whitespace-pre-wrap font-sans",children:e})]}),eH="data:image/svg+xml,%3csvg%20width='94'%20height='24'%20viewBox='0%200%2094%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M-0.000156164%2023.832V7.704H5.11184L6.47984%208.424C7.58384%207.704%209.04784%207.344%2010.8718%207.344C12.0718%207.344%2013.1278%207.476%2014.0398%207.74C14.9518%207.98%2015.6838%208.244%2016.2358%208.532C16.8118%208.82%2017.1718%209.024%2017.3158%209.144L15.5158%2013.824C15.2758%2013.656%2014.8198%2013.428%2014.1478%2013.14C13.4998%2012.852%2012.7318%2012.588%2011.8438%2012.348C10.9558%2012.084%2010.0198%2011.952%209.03584%2011.952H8.63984C7.96784%2011.952%207.45184%2012.072%207.09184%2012.312C6.73184%2012.528%206.55184%2013.02%206.55184%2013.788V23.832H-0.000156164ZM23.464%206.156C21.04%206.156%2019.828%205.124%2019.828%203.06C19.828%201.908%2020.128%201.116%2020.728%200.684C21.352%200.227999%2022.264%20-1.43051e-06%2023.464%20-1.43051e-06C24.736%20-1.43051e-06%2025.66%200.227999%2026.236%200.684C26.836%201.116%2027.136%201.908%2027.136%203.06C27.136%205.124%2025.912%206.156%2023.464%206.156ZM20.152%2023.832V7.704H26.704V23.832H20.152ZM37.4767%2023.832L29.6647%207.704H36.9007L40.3207%2016.524L41.2567%2019.116H41.6167L42.5527%2016.524L46.0087%207.704H53.1727L52.5967%209.9L45.4327%2023.832H37.4767ZM61.1953%2023.832C59.6113%2023.832%2058.3873%2023.604%2057.5233%2023.148C56.6833%2022.692%2056.1073%2022.068%2055.7953%2021.276C55.4833%2020.46%2055.3273%2019.524%2055.3273%2018.468V13.032C55.3273%2012.072%2055.4833%2011.196%2055.7953%2010.404C56.1313%209.588%2056.7193%208.94%2057.5593%208.46C58.3993%207.956%2059.6113%207.704%2061.1953%207.704H68.6473C70.5193%207.704%2071.9473%207.932%2072.9313%208.388C73.9393%208.82%2074.6233%209.444%2074.9833%2010.26C75.3673%2011.052%2075.5593%2011.976%2075.5593%2013.032V17.64H69.2593C67.0993%2017.64%2065.4553%2017.592%2064.3273%2017.496C63.2233%2017.4%2062.4433%2017.34%2061.9873%2017.316V17.856C61.9633%2018.816%2062.5393%2019.296%2063.7153%2019.296H64.8313C66.7513%2019.296%2068.5273%2019.26%2070.1593%2019.188C71.7913%2019.092%2073.0033%2019.008%2073.7953%2018.936L75.9553%2022.356C75.9553%2022.596%2075.7513%2022.824%2075.3433%2023.04C74.9353%2023.256%2074.2153%2023.448%2073.1833%2023.616C72.1753%2023.76%2070.7353%2023.832%2068.8633%2023.832H61.1953ZM61.9873%2014.184H68.8993V13.68C68.8993%2013.2%2068.8513%2012.864%2068.7553%2012.672C68.6833%2012.48%2068.4313%2012.36%2067.9993%2012.312C67.5673%2012.264%2066.8353%2012.24%2065.8033%2012.24H63.7153C62.5633%2012.24%2061.9873%2012.72%2061.9873%2013.68V14.184ZM85.8224%2023.832C83.9984%2023.832%2082.7504%2023.448%2082.0784%2022.68C81.4064%2021.912%2081.0704%2020.76%2081.0704%2019.224V12.24H78.1184V7.704H79.6304C80.0384%207.704%2080.3624%207.632%2080.6024%207.488C80.8664%207.32%2081.0344%207.032%2081.1064%206.624L81.7904%202.772H87.6944V7.704H93.7064V12.24H87.6944V17.82C87.6944%2018.42%2087.8384%2018.816%2088.1264%2019.008C88.4144%2019.2%2088.8464%2019.296%2089.4224%2019.296H93.0224L93.7424%2023.472C93.2384%2023.544%2092.4704%2023.628%2091.4384%2023.724C90.4064%2023.796%2089.2784%2023.832%2088.0544%2023.832H85.8224Z'%20fill='%23FF3300'/%3e%3c/svg%3e",tH=({isSigningIn:e,onStartSignIn:t,errorMessage:n=null,isDesktopShell:r=!1,displayMode:i="full"})=>{const s=i==="modal";return y.jsxs("div",{className:s?"glass-panel relative w-full max-w-sm rounded-2xl border border-white/10 px-8 py-14 font-main text-white shadow-2xl":"relative flex min-h-screen flex-col items-center justify-center overflow-hidden bg-[#1c1c20] font-main text-white",children:[r&&!s?y.jsx("div",{className:"fixed left-0 right-0 top-0 z-10 h-8",style:{WebkitAppRegion:"drag"}}):null,y.jsxs("div",{className:"flex flex-col items-center gap-10",children:[y.jsx("img",{src:eH,alt:"Rivet",className:"h-8 w-auto object-contain"}),y.jsxs("div",{className:"text-center",children:[y.jsx("h1",{className:"mb-2 text-xl font-medium text-content",children:"Welcome to Rivet"}),y.jsx("p",{className:"text-sm text-content-muted",children:"Sign in to get started"})]}),y.jsx("button",{onClick:t,disabled:e,className:"glass-panel active-push flex items-center gap-3 rounded-xl px-8 py-3.5 text-sm font-medium transition-all hover:bg-white/10 disabled:opacity-50",children:e?y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"}),y.jsx("span",{children:"Signing in..."})]}):y.jsxs(y.Fragment,{children:[y.jsx("img",{src:"https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg",alt:"Google",className:"h-5 w-5 brightness-110"}),y.jsx("span",{children:"Sign in with Google"})]})}),n?y.jsx("p",{className:"text-center text-xs text-red-200",children:n}):null]})]})},n4e=({message:e})=>y.jsx("div",{className:"relative flex min-h-screen flex-col items-center justify-center overflow-hidden bg-[#1c1c20] font-main text-white",children:y.jsxs("div",{className:"flex flex-col items-center gap-10",children:[y.jsx("img",{src:eH,alt:"Rivet",className:"h-8 w-auto object-contain"}),y.jsxs("div",{className:"glass-panel flex items-center gap-3 rounded-xl px-8 py-3.5 text-sm font-medium",children:[y.jsx(Ua,{className:"h-5 w-5 shrink-0 animate-spin text-primary",weight:"bold"}),y.jsx("span",{children:e})]})]})}),T7=$t("useConfig"),r4e=()=>{var e;return typeof window>"u"?null:((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.queueAccessToken)??null},i4e=()=>{var e;return typeof window>"u"?null:((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.agentApplyMode)??null},s4e=e=>({...m$,...e??{}}),o4e=()=>{const e=Ce(Ti),t=ze(Ti),n=ze(Cp),r=ze(U8),i=ze(X1),s=ze(Z8),o=ze(E$),a=ze(C$),c=ze(v$),u=Wz({queryKey:["rivet-config"],queryFn:async()=>{const g=await fetch("/api/config");if(!g.ok)throw new Error(`Failed to fetch config: ${g.statusText}`);return await g.json()},staleTime:3e4}),{refetch:h}=u;f.useEffect(()=>{const g=u.data;g&&(o(g.agentModeAvailable),c({name:g.name??null,email:g.email??null}),t(s4e(g.featureFlags)),a(!0),g.isMCPSession&&n(!0),g.mcpEditor&&r(g.mcpEditor),i(g.agentApplyMode??i4e()??null),s(g.queueAccessToken??r4e()),T7.info("Config loaded:",g))},[u.data,i,o,t,a,n,r,s,c]),f.useEffect(()=>{u.error&&(a(!0),T7.warn("Failed to load config:",u.error instanceof Error?u.error.message:"Failed to load config"))},[u.error,a]);const p=f.useCallback(async()=>{const g=await h();return g.data?g.data:(a(!0),null)},[h,a]);let m=null;return u.error instanceof Error?m=u.error.message:u.error&&(m="Failed to load config"),{config:u.data??null,featureFlags:e,loading:u.isPending,error:m,refetchConfig:p}},yu=$t("useOAuthCallback"),a4e="https://rivet-proxy.onrender.com",l4e=()=>{const[e,t]=f.useState({isProcessing:!1,isComplete:!1,error:null});return f.useEffect(()=>{const n=new AbortController;let r=!1;return(async()=>{var a,c,u;const s=window.location.hash,o=window.location.search;if(!(!s||!s.includes("access_token"))&&!r){t({isProcessing:!0,isComplete:!1,error:null});try{yu.info("Processing OAuth callback...");const h=new URLSearchParams(s.substring(1)),p=h.get("access_token"),m=h.get("refresh_token"),b=new URLSearchParams(o).get("session");if(!p)throw new Error("No access token found in URL");if(!b)throw new Error("No session ID found in URL");yu.info(`Completing OAuth with session: ${b}`);const x=await fetch(`${a4e}/api/auth/google/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:b,accessToken:p,refreshToken:m}),signal:n.signal}),C=await x.json();if(!x.ok||!C.success)throw new Error(C.error||C.message||"Failed to complete authentication");if(yu.info("OAuth authentication completed successfully"),r)return;if((a=C.user)!=null&&a.id?(yt.identify(C.user.id,{...C.user.email?{email:C.user.email}:{}}),C.user.email&&yt.alias(C.user.email,C.user.id)):(c=C.user)!=null&&c.email&&yt.identify(C.user.email,{email:C.user.email}),(u=C.user)!=null&&u.email&&p)try{const E=await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:C.user.email,token:p,refreshToken:m,userId:C.user.id}),signal:n.signal});E.ok||yu.warn(`Local auth store returned ${E.status}`)}catch(E){if(r)return;yu.warn("Failed to store auth locally:",E)}if(r)return;const w=window.location.pathname;window.history.replaceState({},document.title,w),t({isProcessing:!1,isComplete:!0,error:null})}catch(h){if(r)return;const p=h instanceof Error?h.message:"Unknown error occurred";yu.warn("OAuth callback error:",h),t({isProcessing:!1,isComplete:!1,error:p})}}})(),()=>{r=!0,n.abort()}},[]),e},Ix=$t("useAgentVariantsSession"),c4e=()=>{const e=ze(il),t=ze(wp),n=ze(O8),r=ze(k$),i=ze(YJ),s=wc(),o=f.useRef(null);f.useEffect(()=>{const a=new EventSource("/api/variants/events");return a.onmessage=c=>{try{const u=JSON.parse(c.data),h=o.current;u.active?(r(!1),u.sessionId!==o.current&&(o.current=u.sessionId,t(!0),n("directions"))):(o.current=null,r(!1)),e(u);const p=!u.active&&h!==null,m=u.active&&u.sessionId!==h;if(m&&fetch(`/api/variants/${u.sessionId}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:null})}).catch(g=>Ix.warn("failed to reset preview-port on session switch",g)),p||m){const g=new Set;if(u.active)for(const x of u.variants)g.add(No({kind:"variant",sessionId:u.sessionId,variantId:x.workItemId}));const b=s.get(Cc);for(const x of[b==null?void 0:b.left,b==null?void 0:b.right])x&&g.add(No({kind:"variant",sessionId:x.sessionId,variantId:x.variantId}));i(g)}}catch(u){Ix.warn("failed to parse SSE event payload",u)}},a.onerror=c=>{Ix.warn("SSE error (auto-reconnects)",c),r(!1)},()=>{a.close()}},[e,t,n,r,i,s])},bu=$t("useTokenEditor"),u4e=()=>{const[e,t]=f.useState(null),[n,r]=f.useState(null),[i,s]=f.useState(new Map),[o,a]=f.useState(!0),[c,u]=f.useState(!1),[h,p]=f.useState(null),m=f.useCallback(async()=>{a(!0),p(null);try{const C=await fetch("/api/tokens");if(!C.ok)throw new Error(`Failed to fetch tokens: ${C.statusText}`);const w=await C.json();t(w.registry),r(w.framework),bu.info(`Loaded ${w.framework} tokens`)}catch(C){const w=C instanceof Error?C.message:"Unknown error";p(w),bu.warn("Failed to fetch tokens:",C)}finally{a(!1)}},[]);f.useEffect(()=>{m()},[m]);const g=f.useCallback((C,w,E,_)=>{const T=`${C}.${w}`;s(I=>{const P=new Map(I);return _===E?P.delete(T):P.set(T,{category:C,path:w,originalValue:E,newValue:_}),P})},[]),b=f.useCallback(async()=>{if(i.size===0)return!0;u(!0),p(null);const C=Array.from(i.values());let w=!0;for(const E of C)try{bu.info(`Saving ${E.category}.${E.path} = "${E.newValue}"`);const T=await(await fetch("/api/tokens/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:E.category,path:E.path,value:E.newValue})})).json();if(!T.success)throw new Error(T.error||"Update failed");bu.info(`Successfully saved ${E.category}.${E.path}`)}catch(_){const T=_ instanceof Error?_.message:"Unknown error";p(`Failed to update ${E.category}.${E.path}: ${T}`),bu.warn(`Failed to save ${E.category}.${E.path}:`,_),w=!1;break}return w&&(s(new Map),await m()),u(!1),w},[i,m]),x=f.useCallback(()=>{s(new Map),bu.info("Reverted all pending changes")},[]);return{tokens:e,framework:n,pendingChanges:i,isLoading:o,isSaving:c,error:h,updateToken:g,saveChanges:b,revertChanges:x,refetch:m}};var Mx="rovingFocusGroup.onEntryFocus",d4e={bubbles:!1,cancelable:!0},Vp="RovingFocusGroup",[M6,nH,f4e]=xv(Vp),[h4e,rH]=ws(Vp,[f4e]),[p4e,m4e]=h4e(Vp),iH=f.forwardRef((e,t)=>y.jsx(M6.Provider,{scope:e.__scopeRovingFocusGroup,children:y.jsx(M6.Slot,{scope:e.__scopeRovingFocusGroup,children:y.jsx(g4e,{...e,ref:t})})}));iH.displayName=Vp;var g4e=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:h=!1,...p}=e,m=f.useRef(null),g=Qt(t,m),b=Rp(s),[x,C]=ys({prop:o,defaultProp:a??null,onChange:c,caller:Vp}),[w,E]=f.useState(!1),_=Ya(u),T=nH(n),I=f.useRef(!1),[P,M]=f.useState(0);return f.useEffect(()=>{const S=m.current;if(S)return S.addEventListener(Mx,_),()=>S.removeEventListener(Mx,_)},[_]),y.jsx(p4e,{scope:n,orientation:r,dir:b,loop:i,currentTabStopId:x,onItemFocus:f.useCallback(S=>C(S),[C]),onItemShiftTab:f.useCallback(()=>E(!0),[]),onFocusableItemAdd:f.useCallback(()=>M(S=>S+1),[]),onFocusableItemRemove:f.useCallback(()=>M(S=>S-1),[]),children:y.jsx(Et.div,{tabIndex:w||P===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:dt(e.onMouseDown,()=>{I.current=!0}),onFocus:dt(e.onFocus,S=>{const R=!I.current;if(S.target===S.currentTarget&&R&&!w){const $=new CustomEvent(Mx,d4e);if(S.currentTarget.dispatchEvent($),!$.defaultPrevented){const L=T().filter(Z=>Z.focusable),j=L.find(Z=>Z.active),O=L.find(Z=>Z.id===x),B=[j,O,...L].filter(Boolean).map(Z=>Z.ref.current);aH(B,h)}}I.current=!1}),onBlur:dt(e.onBlur,()=>E(!1))})})}),sH="RovingFocusGroupItem",oH=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,c=Zi(),u=s||c,h=m4e(sH,n),p=h.currentTabStopId===u,m=nH(n),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:x}=h;return f.useEffect(()=>{if(r)return g(),()=>b()},[r,g,b]),y.jsx(M6.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:y.jsx(Et.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...a,ref:t,onMouseDown:dt(e.onMouseDown,C=>{r?h.onItemFocus(u):C.preventDefault()}),onFocus:dt(e.onFocus,()=>h.onItemFocus(u)),onKeyDown:dt(e.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){h.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const w=b4e(C,h.orientation,h.dir);if(w!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let _=m().filter(T=>T.focusable).map(T=>T.ref.current);if(w==="last")_.reverse();else if(w==="prev"||w==="next"){w==="prev"&&_.reverse();const T=_.indexOf(C.currentTarget);_=h.loop?x4e(_,T+1):_.slice(T+1)}setTimeout(()=>aH(_))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:x!=null}):o})})});oH.displayName=sH;var v4e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function y4e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function b4e(e,t,n){const r=y4e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return v4e[r]}function aH(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function x4e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var w4e=iH,k4e=oH,Uv="Tabs",[C4e]=ws(Uv,[rH]),lH=rH(),[E4e,$k]=C4e(Uv),cH=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:c="automatic",...u}=e,h=Rp(a),[p,m]=ys({prop:r,onChange:i,defaultProp:s??"",caller:Uv});return y.jsx(E4e,{scope:n,baseId:Zi(),value:p,onValueChange:m,orientation:o,dir:h,activationMode:c,children:y.jsx(Et.div,{dir:h,"data-orientation":o,...u,ref:t})})});cH.displayName=Uv;var uH="TabsList",dH=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,s=$k(uH,n),o=lH(n);return y.jsx(w4e,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:r,children:y.jsx(Et.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:t})})});dH.displayName=uH;var fH="TabsTrigger",hH=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=e,o=$k(fH,n),a=lH(n),c=gH(o.baseId,r),u=vH(o.baseId,r),h=r===o.value;return y.jsx(k4e,{asChild:!0,...a,focusable:!i,active:h,children:y.jsx(Et.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":u,"data-state":h?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...s,ref:t,onMouseDown:dt(e.onMouseDown,p=>{!i&&p.button===0&&p.ctrlKey===!1?o.onValueChange(r):p.preventDefault()}),onKeyDown:dt(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&o.onValueChange(r)}),onFocus:dt(e.onFocus,()=>{const p=o.activationMode!=="manual";!h&&!i&&p&&o.onValueChange(r)})})})});hH.displayName=fH;var pH="TabsContent",mH=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=e,a=$k(pH,n),c=gH(a.baseId,r),u=vH(a.baseId,r),h=r===a.value,p=f.useRef(h);return f.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),y.jsx(ks,{present:i||h,children:({present:m})=>y.jsx(Et.div,{"data-state":h?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:u,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&s})})});mH.displayName=pH;function gH(e,t){return`${e}-trigger-${t}`}function vH(e,t){return`${e}-content-${t}`}var S4e=cH,_4e=dH,A4e=hH,T4e=mH;const P4e=({tokens:e,pendingChanges:t,category:n,onUpdateToken:r,highlightToken:i})=>{const[s,o]=f.useState(null),[a,c]=f.useState(""),u=f.useRef(null);if(f.useEffect(()=>{i&&u.current&&setTimeout(()=>{var x;(x=u.current)==null||x.scrollIntoView({behavior:"smooth",block:"center"})},100)},[i]),!e||Object.keys(e).length===0)return y.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-gray-500",children:"No tokens defined for this category"});const h=(x,C)=>{const w=`${n}.${x}`,E=t.get(w);return E?E.newValue:C},p=x=>{if(x.includes("var(")||x.includes("--"))return{textClass:"text-white",mutedClass:"text-white/70"};let C=0,w=0,E=0,_=!1;if(x.startsWith("#")){const M=x.slice(1);M.length===3?(C=parseInt(M[0]+M[0],16),w=parseInt(M[1]+M[1],16),E=parseInt(M[2]+M[2],16),_=!0):M.length>=6&&(C=parseInt(M.slice(0,2),16),w=parseInt(M.slice(2,4),16),E=parseInt(M.slice(4,6),16),_=!0)}const T=x.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(T&&(C=parseInt(T[1],10),w=parseInt(T[2],10),E=parseInt(T[3],10),_=!0),!_){const M=x.match(/rgba?\(\s*(\d+)\s+(\d+)\s+(\d+)/);M&&(C=parseInt(M[1],10),w=parseInt(M[2],10),E=parseInt(M[3],10),_=!0)}if(!_){const M=x.match(/hsla?\(\s*(\d+)\s*,\s*(\d+)%?\s*,\s*(\d+)%?/);if(M){const S=AA(parseInt(M[1],10),parseInt(M[2],10),parseInt(M[3],10));C=S.r,w=S.g,E=S.b,_=!0}}if(!_){const M=x.match(/hsla?\(\s*(\d+)\s+(\d+)%?\s+(\d+)%?/);if(M){const S=AA(parseInt(M[1],10),parseInt(M[2],10),parseInt(M[3],10));C=S.r,w=S.g,E=S.b,_=!0}}if(!_){const M=x.match(/oklch\(\s*([\d.]+)(%?)/);if(M){const S=parseFloat(M[1]),$=(M[2]==="%"?S/100:S)>.5;return{textClass:$?"text-gray-900":"text-white",mutedClass:$?"text-gray-600":"text-white/70"}}}if(!_)return{textClass:"text-white",mutedClass:"text-white/70"};const P=rie(C,w,E)>.5;return{textClass:P?"text-gray-900":"text-white",mutedClass:P?"text-gray-600":"text-white/70"}},m=(x,C,w,E)=>{const _=h(C,w),T=s===C,I=T&&a?a:_,P=C.replace(/\./g,"-"),M=i===P||i===x,S=I.includes("rgba")||I.startsWith("#")&&I.length===9||/oklch\(/.test(I)&&I.includes("/"),{textClass:R}=p(I),$=H=>{c(H)},L=H=>{r(n,C,w,H),o(null),c("")},j=H=>{H?(o(C),c(_)):(a&&a!==_&&r(n,C,w,a),o(null),c(""))},O=E?"h-44":"h-52";return y.jsxs(Fo,{open:T,onOpenChange:j,children:[y.jsx(ul,{asChild:!0,children:y.jsxs("div",{ref:M?u:null,className:`group relative flex ${O} cursor-pointer flex-col justify-between overflow-hidden rounded-lg border border-white/10 p-4 transition-all ${M?"animate-token-highlight":""}`,children:[y.jsxs("div",{className:"absolute inset-0",children:[S&&y.jsx("div",{className:"absolute inset-0",style:{backgroundImage:`
|
|
608
608
|
linear-gradient(45deg, #e5e5e5 25%, transparent 25%),
|
|
609
609
|
linear-gradient(-45deg, #e5e5e5 25%, transparent 25%),
|
|
610
610
|
linear-gradient(45deg, transparent 75%, #e5e5e5 75%),
|
|
@@ -638,4 +638,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
638
638
|
<body>
|
|
639
639
|
<div class="panel">${R7}</div>
|
|
640
640
|
</body>
|
|
641
|
-
</html>`,lwe="Too many people are trying Rivet right now. Please try again in a few minutes.",kH="Failed to start an isolated demo session.",cwe=async e=>{if(e.status===429)return lwe;try{const t=await e.json();if(t.error)return t.error;if(t.message)return t.message}catch{}return kH},uwe=({projectPath:e,activeDemoSessionId:t=null,showLoginGate:n=!1,onStartLogin:r,isStartingLogin:i=!1,loginError:s=null,fullPageHostedLoginProgressMessage:o=null,holdHostedTryoutPreviewNavigation:a=!1,hostedTryoutPreviewHoldMessage:c=null,deferInspectorUntilPreviewReady:u=!1})=>{const[h,p]=Bn(Js),m=ze(Id),g=ze(H8),b=ze(F8),[x,C]=Bn(zJ),w=Ce(rl),E=Ce(g$)>0,[_,T]=Bn(wp),I=Ce(Ti).refineMode.isEnabled,[P,M]=Bn(Hi),S=Ce(pc),R=ze(_$),$=ze(r1),L=ze(B8),j=ze(pc),O=l4e();c4e();const H=O.isProcessing?"Completing authentication...":o,B=H!==null,Z=f.useRef((h==null?void 0:h.xpath)??null),K=f.useRef(!1),q=f.useRef(!1),te=ze(Y1),F=H4e();f.useEffect(()=>{te(e??null)},[e,te]),f.useEffect(()=>{if(!e||K.current)return;K.current=!0;const Q=z4e(e);Q.size>0&&(q.current=!0,M(Q));const J=V4e(e);J&&F(J)},[e,M,F]),f.useEffect(()=>{if(!(!e||!K.current)){if(q.current){q.current=!1;return}B4e(P,e)}},[P,e]),f.useEffect(()=>{(async()=>{try{const J=await fetch("/api/tokens");if(J.ok){const re=await J.json();m(re),re.framework&&Ir.info(`Loaded ${re.framework} design tokens`)}}catch(J){Ir.error("Failed to fetch design tokens:",J)}})()},[m]);const V=()=>{w==="edit"||S||($(null),L(null),j(!1),Rx())},W=f.useCallback(()=>{b("view"),Rx(),p(null),g(null)},[b,g,p]);f.useEffect(()=>{n&&(b("view"),Rx(),p(null),g(null),document.body.style.cursor="auto")},[n,b,g,p]);const N=f.useMemo(()=>[{key:"Escape",allowInTextField:!0,handler:Q=>{const J=Q.target,re=J.tagName.toLowerCase();if(!((re==="input"||re==="textarea"||re==="select"||J.getAttribute("contenteditable")==="true")&&w!=="comment")){if(J.closest("[data-radix-popper-content-wrapper]")){Ir.debug("Escape key pressed inside popover - letting Radix handle it");return}if(S){Ir.debug("Escape key pressed with dirty draft comment - closing draft"),$(null),L(null),j(!1);return}Ir.debug("Escape key pressed - switching to Select mode"),W()}},description:"Close inspector"},{key:"x",metaKey:!1,ctrlKey:!1,handler:()=>{if(S){Ir.debug("X key pressed with dirty draft comment - closing draft"),$(null),L(null),j(!1);return}Ir.debug("X key pressed - collapsing editor chrome"),W()},description:"Collapse editor chrome"},{key:"n",metaKey:!1,ctrlKey:!1,handler:()=>{if(S){Ir.debug("N key pressed with dirty draft comment - blocking mode switch"),R(Q=>Q+1);return}Ir.debug("N key pressed - switching to navigate mode"),W()},description:"Switch to navigate mode"},{key:"v",metaKey:!1,ctrlKey:!1,handler:()=>{if(S){Ir.debug("V key pressed with dirty draft comment - blocking mode switch"),R(Q=>Q+1);return}Ir.debug("V key pressed - switching to Select mode"),W()},description:"Switch to Select mode"},{key:"c",metaKey:!1,ctrlKey:!1,handler:()=>{Ir.debug("C key pressed - switching to comment mode"),b("comment")},description:"Switch to comment mode"},{key:"r",metaKey:!1,ctrlKey:!1,handler:()=>{I&&(Ir.debug("R key pressed - switching to refine mode"),T(!0),b("edit"))},description:"Switch to refine mode"}],[w,S,b,R,$,L,j,T,W,I]);J8({shortcuts:N}),f.useEffect(()=>{const Q=()=>{UD("window_resize")};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),f.useEffect(()=>{const Q=(h==null?void 0:h.xpath)??null,J=Z.current;Q&&Q!==J&&(Z.current=Q)},[h==null?void 0:h.xpath]);const z=Array.from(P.values()).some(Q=>Q.status==="pending");return f.useEffect(()=>{const Q=iwe(z);Q!==null&&T(Q)},[T,z]),y.jsxs(dn.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[H!==null?y.jsx("div",{className:"absolute inset-0 z-50",children:y.jsx(n4e,{message:H})}):null,n&&!B?y.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-black/45 backdrop-blur-[2px]",children:y.jsx(tH,{isSigningIn:i,onStartSignIn:()=>{r==null||r()},errorMessage:s,displayMode:"modal"})}):null,y.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col ${n?"pointer-events-none select-none":""}`,children:[y.jsx(e4e,{holdHostedTryoutPreviewNavigation:a,isInteractionDisabled:n,activeDemoSessionId:t}),a&&c?y.jsx("div",{className:"bg-main absolute inset-0 z-30 flex items-center justify-center",children:y.jsx("div",{className:"border-divider bg-main-light rounded-lg border p-6 shadow-lg",children:y.jsx(JV,{message:c})})}):null]}),n?null:y.jsx(y.Fragment,{children:!u&&!E?y.jsxs(y.Fragment,{children:[y.jsx(dn.div,{className:"h-full flex-shrink-0",initial:!1,animate:{width:_?"auto":0,opacity:_?1:0},transition:{ease:[.19,1,.22,1],duration:.45},style:{overflow:"hidden",willChange:"width"},onClickCapture:V,children:y.jsx(F2e,{chatMessages:x,setChatMessages:C,onClose:()=>T(!1)})}),y.jsx(ds,{children:!_&&y.jsx(Ys,{label:"Open chat",side:"left",children:y.jsx(dn.button,{initial:{opacity:0,x:8},animate:{opacity:1,x:0},exit:{opacity:0,x:8},transition:{duration:.15},onClick:()=>T(!0),className:"border-primary/30 bg-main text-content absolute top-4 right-0 z-50 rounded-l-lg border border-r-0 p-2 shadow-lg transition-colors","data-cy":"reopen-panel",children:y.jsx(Ug,{className:"h-4 w-4",weight:"bold"})})})})]}):null}),y.jsx(a$,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},dwe=()=>{const[e,t]=f.useState(window.location.hash),[n,r]=f.useState(0),{config:i,refetchConfig:s,loading:o,error:a}=o4e(),c=ze(pc),[u,h]=f.useState(!1),[p,m]=f.useState(null),[g,b]=f.useState(!1),[x,C]=f.useState(!1),[w,E]=f.useState(null),[_,T]=f.useState(!1),I=f.useRef(!1),P=f.useRef(!1),M=nwe(window.location.pathname),S=(i==null?void 0:i.activeDemoSessionId)??null,R=M??w??S,$=f.useMemo(()=>Q4e(i==null?void 0:i.demoMode,i==null?void 0:i.agentModeAvailable,R),[i==null?void 0:i.demoMode,i==null?void 0:i.agentModeAvailable,R]),L=f.useMemo(()=>X4e({configLoading:o,hasConfig:i!==null,demoMode:i==null?void 0:i.demoMode,agentModeAvailable:i==null?void 0:i.agentModeAvailable,pathnameDemoSessionId:M,activeDemoSessionId:w,configuredDemoSessionId:S}),[i,o,M,w,S]);f.useLayoutEffect(()=>{if(!L){T(!1);return}T(!0)},[L]);const j=_,O=f.useMemo(()=>J4e(j),[j]),H=(i==null?void 0:i.demoMode)===!0&&j,B=f.useRef(null);B.current=R;const Z=f.useCallback(async()=>{if(!I.current)return;E(null);const J=await s();if((J==null?void 0:J.demoMode)===!0&&J.agentModeAvailable!==!0){C(!1);return}(J==null?void 0:J.demoMode)===!0&&C(!0)},[s]);f.useEffect(()=>{if((i==null?void 0:i.demoMode)===!0)return G4e(()=>{Z()})},[i==null?void 0:i.demoMode,Z]),f.useEffect(()=>{if(I.current=(i==null?void 0:i.demoMode)===!0,(i==null?void 0:i.demoMode)!==!0)return;const J=window.fetch.bind(window);return Y4e({nativeFetch:J,pageOrigin:window.location.origin,getShouldIntercept:()=>I.current})},[i==null?void 0:i.demoMode]),f.useEffect(()=>{(i==null?void 0:i.agentModeAvailable)===!0&&C(!1)},[i==null?void 0:i.agentModeAvailable]);const K=f.useCallback(async J=>{const re=B.current;if(!(J!=null&&J.forceRefresh)&&re)return re;if(P.current)return"";P.current=!0;try{const G=await fetch("/api/demo/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!G.ok){const de=await cwe(G);throw new Error(de)}const X=await G.json();if(!X.sessionId)throw new Error("Demo session response missing session id.");return E(X.sessionId),X.sessionId}finally{P.current=!1}},[]);f.useEffect(()=>{S&&E(S)},[S]),f.useEffect(()=>{i!=null&&i.userId?(yt.identify(i.userId,{...i.email?{email:i.email}:{}}),i.email&&yt.alias(i.email,i.userId)):i!=null&&i.email&&yt.identify(i.email,{email:i.email})},[i==null?void 0:i.userId,i==null?void 0:i.email]),f.useEffect(()=>{if(!i)return;const J=!!i.demoMode,re=J?R:null;yt.register({source:J?"tryout":"core",demo_mode:J,...re?{demo_session_id:re}:{}})},[i,R]);const q=f.useCallback(async()=>{var re;h(!0),m(null);let J=null;try{if(J=window.open("","_blank"),!J)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{J.document.open(),J.document.write(awe),J.document.close()}catch(de){Ir.warn("Failed to render loading state in auth popup:",de)}const G=await fetch(`${$7}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"desktop"})}),X=await G.json();if(!G.ok||!X.success||!X.authUrl||!X.sessionId||!X.pollSecret)throw new Error(X.error||X.message||"Failed to start Google login");if(J.closed)throw new Error("Sign-in window was closed before Google login started.");J.location.href=X.authUrl;for(let de=0;de<owe;de+=1){if(J.closed)throw new Error("Sign-in window was closed before authentication completed.");const we=await(await fetch(`${$7}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:X.sessionId,pollSecret:X.pollSecret})})).json();if(we.success&&we.token&&((re=we.user)!=null&&re.email)){if(!(await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:we.user.email,token:we.token,refreshToken:we.refreshToken,userId:we.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");if(J.close(),(i==null?void 0:i.demoMode)===!0){await K({forceRefresh:!0}),window.location.reload();return}window.location.reload();return}if(we.error&&we.error!=="Pending")throw new Error(we.error||"Google login failed");await new Promise(je=>setTimeout(je,swe))}throw new Error("Authentication timed out. Please try again.")}catch(G){J&&!J.closed&&J.close();const X=G instanceof Error?G.message:"Failed to start login flow";Ir.warn("Hosted login failed:",X),m(X),h(!1)}},[i==null?void 0:i.demoMode,K]),te=(i==null?void 0:i.demoMode)===!0&&((i==null?void 0:i.agentModeAvailable)!==!0||x||u),F=i!=null&&i.demoMode!==!0&&i.agentModeAvailable!==!0,V=R6(e),W=f.useCallback(async()=>{b(!0);try{await s()}finally{b(!1)}},[s]);if(f.useEffect(()=>{if(!L)return;let J=!1;return K({forceRefresh:!0}).catch(re=>{const G=re instanceof Error?re.message:kH;Ir.warn("Hosted session bootstrap failed:",G),m(G),lt.error(G)}).finally(()=>{J||T(!1)}),()=>{J=!0}},[L,K]),f.useEffect(()=>{const J=()=>{const re=window.location.hash;c(!1),t(G=>(rwe(G,re)&&r(X=>X+1),re))};return window.addEventListener("hashchange",J),()=>window.removeEventListener("hashchange",J)},[c]),V==="tokens")return y.jsx(R4e,{});if(V==="design-system")return y.jsx(F4e,{});const N={pathname:window.location.pathname,configLoading:o,hasConfig:i!==null,isRetryingConfig:g},z=ewe(N),Q=twe(N);if(z)return y.jsx("div",{className:"h-screen w-full",children:y.jsx(XV,{})});if(Q){const J=a||"Could not load Rivet configuration.";return y.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:y.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[y.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),y.jsx("p",{className:"text-content-dim mt-2 text-xs",children:J}),y.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{W()},children:"Retry"})]})})}return F?y.jsx(tH,{isSigningIn:u,onStartSignIn:()=>{q()},errorMessage:p,displayMode:"full"}):y.jsx(uwe,{projectPath:i==null?void 0:i.projectPath,activeDemoSessionId:$,showLoginGate:te,onStartLogin:q,isStartingLogin:u,loginError:p,fullPageHostedLoginProgressMessage:(i==null?void 0:i.demoMode)===!0&&u?"Completing sign-in...":null,holdHostedTryoutPreviewNavigation:j,hostedTryoutPreviewHoldMessage:O,deferInspectorUntilPreviewReady:H},n)},fwe="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",hwe=new Rz,pwe=()=>y.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:y.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});mW.createRoot(document.getElementById("root")).render(y.jsx(xe.StrictMode,{children:y.jsx(sW,{apiKey:fwe,options:{api_host:"https://us.i.posthog.com",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",session_recording:{maskAllInputs:!1,maskInputOptions:{password:!0},maskTextSelector:null},mask_all_text:!1,mask_all_element_attributes:!1,loaded:e=>{e.register({source:"core",rivet_version:"0.11.3",env:"production"})}},children:y.jsx(cW,{fallback:y.jsx(pwe,{}),children:y.jsx(Dz,{client:hwe,children:y.jsx(lte,{defaultShape:"rounded",children:y.jsx(l1e,{defaultLibrary:"lucide",children:y.jsx(dwe,{})})})})})})}));
|
|
641
|
+
</html>`,lwe="Too many people are trying Rivet right now. Please try again in a few minutes.",kH="Failed to start an isolated demo session.",cwe=async e=>{if(e.status===429)return lwe;try{const t=await e.json();if(t.error)return t.error;if(t.message)return t.message}catch{}return kH},uwe=({projectPath:e,activeDemoSessionId:t=null,showLoginGate:n=!1,onStartLogin:r,isStartingLogin:i=!1,loginError:s=null,fullPageHostedLoginProgressMessage:o=null,holdHostedTryoutPreviewNavigation:a=!1,hostedTryoutPreviewHoldMessage:c=null,deferInspectorUntilPreviewReady:u=!1})=>{const[h,p]=Bn(Js),m=ze(Id),g=ze(H8),b=ze(F8),[x,C]=Bn(zJ),w=Ce(rl),E=Ce(g$)>0,[_,T]=Bn(wp),I=Ce(Ti).refineMode.isEnabled,[P,M]=Bn(Hi),S=Ce(pc),R=ze(_$),$=ze(r1),L=ze(B8),j=ze(pc),O=l4e();c4e();const H=O.isProcessing?"Completing authentication...":o,B=H!==null,Z=f.useRef((h==null?void 0:h.xpath)??null),K=f.useRef(!1),q=f.useRef(!1),te=ze(Y1),F=H4e();f.useEffect(()=>{te(e??null)},[e,te]),f.useEffect(()=>{if(!e||K.current)return;K.current=!0;const Q=z4e(e);Q.size>0&&(q.current=!0,M(Q));const J=V4e(e);J&&F(J)},[e,M,F]),f.useEffect(()=>{if(!(!e||!K.current)){if(q.current){q.current=!1;return}B4e(P,e)}},[P,e]),f.useEffect(()=>{(async()=>{try{const J=await fetch("/api/tokens");if(J.ok){const re=await J.json();m(re),re.framework&&Ir.info(`Loaded ${re.framework} design tokens`)}}catch(J){Ir.error("Failed to fetch design tokens:",J)}})()},[m]);const V=()=>{w==="edit"||S||($(null),L(null),j(!1),Rx())},W=f.useCallback(()=>{b("view"),Rx(),p(null),g(null)},[b,g,p]);f.useEffect(()=>{n&&(b("view"),Rx(),p(null),g(null),document.body.style.cursor="auto")},[n,b,g,p]);const N=f.useMemo(()=>[{key:"Escape",allowInTextField:!0,handler:Q=>{const J=Q.target,re=J.tagName.toLowerCase();if(!((re==="input"||re==="textarea"||re==="select"||J.getAttribute("contenteditable")==="true")&&w!=="comment")){if(J.closest("[data-radix-popper-content-wrapper]")){Ir.debug("Escape key pressed inside popover - letting Radix handle it");return}if(S){Ir.debug("Escape key pressed with dirty draft comment - closing draft"),$(null),L(null),j(!1);return}Ir.debug("Escape key pressed - switching to Select mode"),W()}},description:"Close inspector"},{key:"x",metaKey:!1,ctrlKey:!1,handler:()=>{if(S){Ir.debug("X key pressed with dirty draft comment - closing draft"),$(null),L(null),j(!1);return}Ir.debug("X key pressed - collapsing editor chrome"),W()},description:"Collapse editor chrome"},{key:"n",metaKey:!1,ctrlKey:!1,handler:()=>{if(S){Ir.debug("N key pressed with dirty draft comment - blocking mode switch"),R(Q=>Q+1);return}Ir.debug("N key pressed - switching to navigate mode"),W()},description:"Switch to navigate mode"},{key:"v",metaKey:!1,ctrlKey:!1,handler:()=>{if(S){Ir.debug("V key pressed with dirty draft comment - blocking mode switch"),R(Q=>Q+1);return}Ir.debug("V key pressed - switching to Select mode"),W()},description:"Switch to Select mode"},{key:"c",metaKey:!1,ctrlKey:!1,handler:()=>{Ir.debug("C key pressed - switching to comment mode"),b("comment")},description:"Switch to comment mode"},{key:"r",metaKey:!1,ctrlKey:!1,handler:()=>{I&&(Ir.debug("R key pressed - switching to refine mode"),T(!0),b("edit"))},description:"Switch to refine mode"}],[w,S,b,R,$,L,j,T,W,I]);J8({shortcuts:N}),f.useEffect(()=>{const Q=()=>{UD("window_resize")};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),f.useEffect(()=>{const Q=(h==null?void 0:h.xpath)??null,J=Z.current;Q&&Q!==J&&(Z.current=Q)},[h==null?void 0:h.xpath]);const z=Array.from(P.values()).some(Q=>Q.status==="pending");return f.useEffect(()=>{const Q=iwe(z);Q!==null&&T(Q)},[T,z]),y.jsxs(dn.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[H!==null?y.jsx("div",{className:"absolute inset-0 z-50",children:y.jsx(n4e,{message:H})}):null,n&&!B?y.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-black/45 backdrop-blur-[2px]",children:y.jsx(tH,{isSigningIn:i,onStartSignIn:()=>{r==null||r()},errorMessage:s,displayMode:"modal"})}):null,y.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col ${n?"pointer-events-none select-none":""}`,children:[y.jsx(e4e,{holdHostedTryoutPreviewNavigation:a,isInteractionDisabled:n,activeDemoSessionId:t}),a&&c?y.jsx("div",{className:"bg-main absolute inset-0 z-30 flex items-center justify-center",children:y.jsx("div",{className:"border-divider bg-main-light rounded-lg border p-6 shadow-lg",children:y.jsx(JV,{message:c})})}):null]}),n?null:y.jsx(y.Fragment,{children:!u&&!E?y.jsxs(y.Fragment,{children:[y.jsx(dn.div,{className:"h-full flex-shrink-0",initial:!1,animate:{width:_?"auto":0,opacity:_?1:0},transition:{ease:[.19,1,.22,1],duration:.45},style:{overflow:"hidden",willChange:"width"},onClickCapture:V,children:y.jsx(F2e,{chatMessages:x,setChatMessages:C,onClose:()=>T(!1)})}),y.jsx(ds,{children:!_&&y.jsx(Ys,{label:"Open chat",side:"left",children:y.jsx(dn.button,{initial:{opacity:0,x:8},animate:{opacity:1,x:0},exit:{opacity:0,x:8},transition:{duration:.15},onClick:()=>T(!0),className:"border-primary/30 bg-main text-content absolute top-4 right-0 z-50 rounded-l-lg border border-r-0 p-2 shadow-lg transition-colors","data-cy":"reopen-panel",children:y.jsx(Ug,{className:"h-4 w-4",weight:"bold"})})})})]}):null}),y.jsx(a$,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},dwe=()=>{const[e,t]=f.useState(window.location.hash),[n,r]=f.useState(0),{config:i,refetchConfig:s,loading:o,error:a}=o4e(),c=ze(pc),[u,h]=f.useState(!1),[p,m]=f.useState(null),[g,b]=f.useState(!1),[x,C]=f.useState(!1),[w,E]=f.useState(null),[_,T]=f.useState(!1),I=f.useRef(!1),P=f.useRef(!1),M=nwe(window.location.pathname),S=(i==null?void 0:i.activeDemoSessionId)??null,R=M??w??S,$=f.useMemo(()=>Q4e(i==null?void 0:i.demoMode,i==null?void 0:i.agentModeAvailable,R),[i==null?void 0:i.demoMode,i==null?void 0:i.agentModeAvailable,R]),L=f.useMemo(()=>X4e({configLoading:o,hasConfig:i!==null,demoMode:i==null?void 0:i.demoMode,agentModeAvailable:i==null?void 0:i.agentModeAvailable,pathnameDemoSessionId:M,activeDemoSessionId:w,configuredDemoSessionId:S}),[i,o,M,w,S]);f.useLayoutEffect(()=>{if(!L){T(!1);return}T(!0)},[L]);const j=_,O=f.useMemo(()=>J4e(j),[j]),H=(i==null?void 0:i.demoMode)===!0&&j,B=f.useRef(null);B.current=R;const Z=f.useCallback(async()=>{if(!I.current)return;E(null);const J=await s();if((J==null?void 0:J.demoMode)===!0&&J.agentModeAvailable!==!0){C(!1);return}(J==null?void 0:J.demoMode)===!0&&C(!0)},[s]);f.useEffect(()=>{if((i==null?void 0:i.demoMode)===!0)return G4e(()=>{Z()})},[i==null?void 0:i.demoMode,Z]),f.useEffect(()=>{if(I.current=(i==null?void 0:i.demoMode)===!0,(i==null?void 0:i.demoMode)!==!0)return;const J=window.fetch.bind(window);return Y4e({nativeFetch:J,pageOrigin:window.location.origin,getShouldIntercept:()=>I.current})},[i==null?void 0:i.demoMode]),f.useEffect(()=>{(i==null?void 0:i.agentModeAvailable)===!0&&C(!1)},[i==null?void 0:i.agentModeAvailable]);const K=f.useCallback(async J=>{const re=B.current;if(!(J!=null&&J.forceRefresh)&&re)return re;if(P.current)return"";P.current=!0;try{const G=await fetch("/api/demo/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!G.ok){const de=await cwe(G);throw new Error(de)}const X=await G.json();if(!X.sessionId)throw new Error("Demo session response missing session id.");return E(X.sessionId),X.sessionId}finally{P.current=!1}},[]);f.useEffect(()=>{S&&E(S)},[S]),f.useEffect(()=>{i!=null&&i.userId?(yt.identify(i.userId,{...i.email?{email:i.email}:{}}),i.email&&yt.alias(i.email,i.userId)):i!=null&&i.email&&yt.identify(i.email,{email:i.email})},[i==null?void 0:i.userId,i==null?void 0:i.email]),f.useEffect(()=>{if(!i)return;const J=!!i.demoMode,re=J?R:null;yt.register({source:J?"tryout":"core",demo_mode:J,...re?{demo_session_id:re}:{}})},[i,R]);const q=f.useCallback(async()=>{var re;h(!0),m(null);let J=null;try{if(J=window.open("","_blank"),!J)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{J.document.open(),J.document.write(awe),J.document.close()}catch(de){Ir.warn("Failed to render loading state in auth popup:",de)}const G=await fetch(`${$7}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"desktop"})}),X=await G.json();if(!G.ok||!X.success||!X.authUrl||!X.sessionId||!X.pollSecret)throw new Error(X.error||X.message||"Failed to start Google login");if(J.closed)throw new Error("Sign-in window was closed before Google login started.");J.location.href=X.authUrl;for(let de=0;de<owe;de+=1){if(J.closed)throw new Error("Sign-in window was closed before authentication completed.");const we=await(await fetch(`${$7}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:X.sessionId,pollSecret:X.pollSecret})})).json();if(we.success&&we.token&&((re=we.user)!=null&&re.email)){if(!(await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:we.user.email,token:we.token,refreshToken:we.refreshToken,userId:we.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");if(J.close(),(i==null?void 0:i.demoMode)===!0){await K({forceRefresh:!0}),window.location.reload();return}window.location.reload();return}if(we.error&&we.error!=="Pending")throw new Error(we.error||"Google login failed");await new Promise(je=>setTimeout(je,swe))}throw new Error("Authentication timed out. Please try again.")}catch(G){J&&!J.closed&&J.close();const X=G instanceof Error?G.message:"Failed to start login flow";Ir.warn("Hosted login failed:",X),m(X),h(!1)}},[i==null?void 0:i.demoMode,K]),te=(i==null?void 0:i.demoMode)===!0&&((i==null?void 0:i.agentModeAvailable)!==!0||x||u),F=i!=null&&i.demoMode!==!0&&i.agentModeAvailable!==!0,V=R6(e),W=f.useCallback(async()=>{b(!0);try{await s()}finally{b(!1)}},[s]);if(f.useEffect(()=>{if(!L)return;let J=!1;return K({forceRefresh:!0}).catch(re=>{const G=re instanceof Error?re.message:kH;Ir.warn("Hosted session bootstrap failed:",G),m(G),lt.error(G)}).finally(()=>{J||T(!1)}),()=>{J=!0}},[L,K]),f.useEffect(()=>{const J=()=>{const re=window.location.hash;c(!1),t(G=>(rwe(G,re)&&r(X=>X+1),re))};return window.addEventListener("hashchange",J),()=>window.removeEventListener("hashchange",J)},[c]),V==="tokens")return y.jsx(R4e,{});if(V==="design-system")return y.jsx(F4e,{});const N={pathname:window.location.pathname,configLoading:o,hasConfig:i!==null,isRetryingConfig:g},z=ewe(N),Q=twe(N);if(z)return y.jsx("div",{className:"h-screen w-full",children:y.jsx(XV,{})});if(Q){const J=a||"Could not load Rivet configuration.";return y.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:y.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[y.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),y.jsx("p",{className:"text-content-dim mt-2 text-xs",children:J}),y.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{W()},children:"Retry"})]})})}return F?y.jsx(tH,{isSigningIn:u,onStartSignIn:()=>{q()},errorMessage:p,displayMode:"full"}):y.jsx(uwe,{projectPath:i==null?void 0:i.projectPath,activeDemoSessionId:$,showLoginGate:te,onStartLogin:q,isStartingLogin:u,loginError:p,fullPageHostedLoginProgressMessage:(i==null?void 0:i.demoMode)===!0&&u?"Completing sign-in...":null,holdHostedTryoutPreviewNavigation:j,hostedTryoutPreviewHoldMessage:O,deferInspectorUntilPreviewReady:H},n)},fwe="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",hwe=new Rz,pwe=()=>y.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:y.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});mW.createRoot(document.getElementById("root")).render(y.jsx(xe.StrictMode,{children:y.jsx(sW,{apiKey:fwe,options:{api_host:"https://us.i.posthog.com",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",session_recording:{maskAllInputs:!1,maskInputOptions:{password:!0},maskTextSelector:null},mask_all_text:!1,mask_all_element_attributes:!1,loaded:e=>{e.register({source:"core",rivet_version:"0.11.4",env:"production"})}},children:y.jsx(cW,{fallback:y.jsx(pwe,{}),children:y.jsx(Dz,{client:hwe,children:y.jsx(lte,{defaultShape:"rounded",children:y.jsx(l1e,{defaultLibrary:"lucide",children:y.jsx(dwe,{})})})})})})}));
|