bloby-bot 0.47.11 → 0.47.12

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.
@@ -14,8 +14,8 @@ Error generating stack: `+e.message+`
14
14
  ${h}px !important;
15
15
  ${g}px !important;
16
16
  }
17
- `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),v.contains(_)&&v.removeChild(_)}},[t]),(0,W.jsx)(Uc,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:v.cloneElement(e,{ref:u})})}var Gc=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=D(Kc),d=(0,v.useId)(),f=!0,p=(0,v.useMemo)(()=>(f=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>u.delete(e))}),[n,u,r]);return a&&f&&(p={...p}),(0,v.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),v.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,W.jsx)(Wc,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,W.jsx)(_e.Provider,{value:p,children:e})};function Kc(){return new Map}function qc(e=!0){let t=(0,v.useContext)(_e);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,v.useId)();(0,v.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,v.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Jc=e=>e.key||``;function Yc(e){let t=[];return v.Children.forEach(e,e=>{(0,v.isValidElement)(e)&&t.push(e)}),t}var Xc=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=qc(o),f=(0,v.useMemo)(()=>Yc(e),[e]),p=o&&!u?[]:f.map(Jc),m=(0,v.useRef)(!0),h=(0,v.useRef)(f),g=D(()=>new Map),_=(0,v.useRef)(new Set),[y,b]=(0,v.useState)(f),[x,S]=(0,v.useState)(f);ge(()=>{m.current=!1,h.current=f;for(let e=0;e<x.length;e++){let t=Jc(x[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[x,p.length,p.join(`-`)]);let C=[];if(f!==y){let e=[...f];for(let t=0;t<x.length;t++){let n=x[t],r=Jc(n);p.includes(r)||(e.splice(t,0,n),C.push(n))}return a===`wait`&&C.length&&(e=C),S(Yc(e)),b(f),null}let{forceRender:w}=(0,v.useContext)(he);return(0,W.jsx)(W.Fragment,{children:x.map(e=>{let v=Jc(e),y=o&&!u?!1:f===x||p.includes(v);return(0,W.jsx)(Gc,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(w?.(),S(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},Zc=(0,v.createContext)({strict:!1}),Qc={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`]},$c=!1;function el(){if($c)return;let e={};for(let t in Qc)e[t]={isEnabled:e=>Qc[t].some(t=>!!e[t])};oo(e),$c=!0}function tl(){return el(),so()}function nl(e){let t=tl();for(let n in e)t[n]={...t[n],...e[n]};oo(t)}var rl=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`.split(`.`));function il(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||rl.has(e)}var al=i({default:()=>ol}),ol,sl=e((()=>{throw ol={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),G=e=>!il(e);function cl(e){typeof e==`function`&&(G=t=>t.startsWith(`on`)?!il(t):e(t))}try{cl((sl(),o(al)).default)}catch{}function ll(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||F(e[i])||(G(i)||n===!0&&il(i)||!t&&!il(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var ul=(0,v.createContext)({});function dl(e,t){if(Za(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Ja(t)?t:void 0,animate:Ja(n)?n:void 0}}return e.inherit===!1?{}:t}function fl(e){let{initial:t,animate:n}=dl(e,(0,v.useContext)(ul));return(0,v.useMemo)(()=>({initial:t,animate:n}),[pl(t),pl(n)])}function pl(e){return Array.isArray(e)?e.join(` `):e}var ml=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function hl(e,t,n){for(let r in t)!F(t[r])&&!zo(r,n)&&(e[r]=t[r])}function gl({transformTemplate:e},t){return(0,v.useMemo)(()=>{let n=ml();return No(n,t,e),Object.assign({},n.vars,n.style)},[t])}function _l(e,t){let n=e.style||{},r={};return hl(r,n,e),Object.assign(r,gl(e,t)),r}function vl(e,t){let n={},r=_l(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}var yl=()=>({...ml(),attrs:{}});function bl(e,t,n,r){let i=(0,v.useMemo)(()=>{let n=yl();return qo(n,t,Yo(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};hl(t,e.style,e),i.style={...t,...i.style}}return i}var xl=[`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 Sl(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(xl.indexOf(e)>-1||/[A-Z]/u.test(e))}function Cl(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Sl(e)?bl:vl)(t,r,i,e),c=ll(t,typeof e==`string`,a),l=e===v.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,v.useMemo)(()=>F(u)?u.get():u,[u]);return(0,v.createElement)(e,{...l,children:d})}function wl({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Tl(n,r,i,e),renderState:t()}}function Tl(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=nc(a[e]);let{initial:o,animate:s}=e,c=Za(e),l=Qa(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!qa(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=gi(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var El=e=>(t,n)=>{let r=(0,v.useContext)(ul),i=(0,v.useContext)(_e),a=()=>wl(e,t,r,i);return n?a():D(a)},Dl=El({scrapeMotionValuesFromProps:Bo,createRenderState:ml}),Ol=El({scrapeMotionValuesFromProps:Zo,createRenderState:yl}),kl=Symbol.for(`motionComponentSymbol`);function Al(e,t,n){let r=(0,v.useRef)(n);(0,v.useInsertionEffect)(()=>{r.current=n});let i=(0,v.useRef)(null);return(0,v.useCallback)(n=>{n&&e.onMount?.(n);let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n);t&&(n?t.mount(n):t.unmount())},[t])}var jl=(0,v.createContext)({});function Ml(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Nl(e,t,n,r,i,a){let{visualElement:o}=(0,v.useContext)(ul),s=(0,v.useContext)(Zc),c=(0,v.useContext)(_e),l=(0,v.useContext)(zc),u=l.reducedMotion,d=l.skipAnimations,f=(0,v.useRef)(null),p=(0,v.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,v.useContext)(jl);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Pl(f.current,n,i,h);let g=(0,v.useRef)(!1);(0,v.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[ji],y=(0,v.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return ge(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),y.current&&m.animationState&&m.animationState.animateChanges())}),(0,v.useEffect)(()=>{m&&(!y.current&&m.animationState&&m.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function Pl(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:Fl(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Ml(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Fl(e){if(e)return e.options.allowProjection===!1?Fl(e.parent):e.projection}function Il(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&nl(r);let a=n?n===`svg`:Sl(e),o=a?Ol:Dl;function s(n,s){let c,l={...(0,v.useContext)(zc),...n,layoutId:Ll(n)},{isStatic:u}=l,d=fl(n),f=o(n,u);if(!u&&typeof window<`u`){Rl(l,r);let t=K(l);c=t.MeasureLayout,d.visualElement=Nl(e,f,l,i,t.ProjectionNode,a)}return(0,W.jsxs)(ul.Provider,{value:d,children:[c&&d.visualElement?(0,W.jsx)(c,{visualElement:d.visualElement,...l}):null,Cl(e,n,Al(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,v.forwardRef)(s);return c[kl]=e,c}function Ll({layoutId:e}){let t=(0,v.useContext)(he).id;return t&&e!==void 0?t+`-`+e:e}function Rl(e,t){(0,v.useContext)(Zc).strict}function K(e){let{drag:t,layout:n}=tl();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function q(e,t){if(typeof Proxy>`u`)return Il;let n=new Map,r=(n,r)=>Il(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Il(a,void 0,e,t)),n.get(a))})}var J=(e,t)=>t.isSVG??Sl(e)?new Qo(t):new Ho(t,{allowProjection:e!==v.Fragment}),Y=class extends uo{constructor(e){super(e),e.animationState||=as(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();qa(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},X=0,zl={animation:{Feature:Y},exit:{Feature:class extends uo{constructor(){super(...arguments),this.id=X++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`){let n=_i(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Bl(e){return{point:{x:e.pageX,y:e.pageY}}}var Vl=e=>t=>pa(t)&&e(t,Bl(t));function Hl(e,t,n,r){return Qs(e,t,Vl(n),r)}var Ul=({current:e})=>e?e.ownerDocument.defaultView:null,Wl=(e,t)=>Math.abs(e-t);function Gl(e,t){let n=Wl(e.x,t.x),r=Wl(e.y,t.y);return Math.sqrt(n**2+r**2)}var Kl=new Set([`auto`,`scroll`]),ql=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){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=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Jl(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Xl(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Gl(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=A;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Jl(t,this.transformPagePoint),k.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=Xl(e.type===`pointercancel`?this.lastMoveEventInfo:Jl(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!pa(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Jl(Bl(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=A;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Xl(s,this.history)),this.removeListeners=Oe(Hl(this.contextWindow,`pointermove`,this.handlePointerMove),Hl(this.contextWindow,`pointerup`,this.handlePointerUp),Hl(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Kl.has(e.overflowX)||Kl.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.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(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),k.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ot(this.updatePoint)}};function Jl(e,t){return t?{point:t(e.point)}:e}function Yl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Xl({point:e},t){return{point:e,delta:Yl(e,Ql(t)),offset:Yl(e,Zl(t)),velocity:$l(t,.1)}}function Zl(e){return e[0]}function Ql(e){return e[e.length-1]}function $l(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Ql(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>je(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>je(t)*2&&(r=e[1]);let a=Me(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function eu(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?N(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?N(n,e,r.max):Math.min(e,n)),e}function tu(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function nu(e,{top:t,left:n,bottom:r,right:i}){return{x:tu(e.x,n,i),y:tu(e.y,t,r)}}function ru(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 iu(e,t){return{x:ru(e.x,t.x),y:ru(e.y,t.y)}}function au(e,t){let n=.5,r=vs(e),i=vs(t);return i>r?n=ke(t.min,t.max-r,e.min):r>i&&(n=ke(e.min,e.max-i,t.min)),be(0,1,n)}function ou(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var su=.35;function cu(e=su){return e===!1?e=0:e===!0&&(e=su),{x:lu(e,`left`,`right`),y:lu(e,`top`,`bottom`)}}function lu(e,t,n){return{min:uu(e,t),max:uu(e,n)}}function uu(e,t){return typeof e==`number`?e:e[t]||0}var du=new WeakMap,fu=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=R(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(Bl(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ca(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Bs(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Nt.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=vs(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&k.update(()=>i(e,t),!1,!0),ki(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=gu(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&k.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new ql(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:Ul(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&k.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!hu(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=eu(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&Ml(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=nu(n.layoutBox,e):this.constraints=!1,this.elastic=cu(t),r!==this.constraints&&!Ml(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Bs(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=ou(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Ml(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=ko(n,r.root,this.visualElement.getTransformPagePoint()),a=iu(r.layout.layoutBox,i);if(t){let e=t(po(a));this.hasMutatedConstraints=!!e,e&&(a=fo(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=Bs(o=>{if(!hu(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return ki(this.visualElement,e),n.start(mi(e,n,0,t,this.visualElement,!1))}stopAnimation(){Bs(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){Bs(t=>{let{drag:n}=this.getProps();if(!hu(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-N(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Ml(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};Bs(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=au({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Bs(t=>{if(!hu(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(N(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;du.set(this.visualElement,this);let e=this.visualElement.current,t=Hl(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&_a(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Ml(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=mu(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),k.read(r);let o=Qs(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(Bs(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=su,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function pu(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function mu(e,t,n){let r=za(e,pu(n)),i=za(t,pu(n));return()=>{r(),i()}}function hu(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function gu(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var _u=class extends uo{constructor(e){super(e),this.removeGroupControls=Ee,this.removeListeners=Ee,this.controls=new fu(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ee}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},vu=e=>(t,n)=>{e&&k.update(()=>e(t,n),!1,!0)},yu=class extends uo{constructor(){super(...arguments),this.removePointerDownListener=Ee}onPointerDown(e){this.session=new ql(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ul(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:vu(e),onStart:vu(t),onMove:vu(n),onEnd:(e,t)=>{delete this.session,r&&k.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Hl(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},bu=!1,xu=class extends v.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),bu&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ic.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),bu=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||k.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),ia.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;bu=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Su(e){let[t,n]=qc(),r=(0,v.useContext)(he);return(0,W.jsx)(xu,{...e,layoutGroup:r,switchLayoutGroup:(0,v.useContext)(jl),isPresent:t,safeToRemove:n})}var Cu={pan:{Feature:yu},drag:{Feature:_u,ProjectionNode:U,MeasureLayout:Su}};function wu(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&k.postRender(()=>i(t,Bl(t)))}var Tu=class extends uo{mount(){let{current:e}=this.node;e&&(this.unmount=da(e,(e,t)=>(wu(this.node,t,`Start`),e=>wu(this.node,e,`End`))))}unmount(){}},Eu=class extends uo{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!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=Oe(Qs(this.node.current,`focus`,()=>this.onFocus()),Qs(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Du(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&k.postRender(()=>i(t,Bl(t)))}var Ou=class extends uo{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=wa(e,(e,t)=>(Du(this.node,t,`Start`),(e,{success:t})=>Du(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},ku=new WeakMap,Au=new WeakMap,ju=e=>{let t=ku.get(e.target);t&&t(e)},Mu=e=>{e.forEach(ju)};function Nu({root:e,...t}){let n=e||document;Au.has(n)||Au.set(n,{});let r=Au.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Mu,{root:e,...t})),r[i]}function Pu(e,t,n){let r=Nu(t);return ku.set(e,n),r.observe(e),()=>{ku.delete(e),r.unobserve(e)}}var Fu={some:0,all:1},Iu=class extends uo{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:Fu[r]};this.stopObserver=Pu(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Lu(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Lu({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Ru={inView:{Feature:Iu},tap:{Feature:Ou},focus:{Feature:Eu},hover:{Feature:Tu}},zu={layout:{ProjectionNode:U,MeasureLayout:Su}},Bu=q({...zl,...Ru,...Cu,...zu},J),Vu=r();function Hu(e){let t=e.match(/^100\.(\d+)\./);if(t&&+t[1]>=64&&+t[1]<=127)return`tailscale`;if(/^192\.168\./.test(e)||/^10\./.test(e))return`lan`;let n=e.match(/^172\.(\d+)\./);return n&&+n[1]>=16&&+n[1]<=31?`lan`:e===`localhost`||e===`127.0.0.1`?`localhost`:e.endsWith(`.trycloudflare.com`)?`tunnel`:e.endsWith(`.bloby.bot`)?`relay`:`custom-domain`}function Uu(e){return e===`tailscale`||e===`lan`||e===`localhost`}var Wu={tailscale:`Tailscale`,lan:`Local network`,localhost:`Localhost`,tunnel:`Cloudflare tunnel`,relay:`Relay`,"custom-domain":`Custom domain`},Z=[{id:`pi`,name:`Pi`,subtitle:`Bring your
18
- own model`,icon:`/pi-logo.svg`,comingSoon:!1},{id:`bloby`,name:`Bloby`,subtitle:`Coming Soon..`,icon:`/bloby.png`,comingSoon:!0},{id:`anthropic`,name:`Claude`,subtitle:`By
19
- Anthropic`,icon:`/icons/claude.png`,comingSoon:!1},{id:`openai`,name:`Codex`,subtitle:`By
20
- OpenAI`,icon:`/codex.svg`,comingSoon:!1}],Gu={anthropic:[{id:`claude-opus-4-7[1m]`,label:`Opus 4.7 (1M context)`},{id:`claude-opus-4-7`,label:`Opus 4.7`},{id:`claude-sonnet-4-6`,label:`Sonnet 4.6 (1M context)`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`}],openai:[{id:`gpt-5.5:high`,label:`GPT-5.5 High`},{id:`gpt-5.5:medium`,label:`GPT-5.5 Medium`},{id:`gpt-5.5:xhigh`,label:`GPT-5.5 Extra High`},{id:`gpt-5.4:medium`,label:`GPT-5.4 Medium`},{id:`gpt-5.4:high`,label:`GPT-5.4 High`},{id:`gpt-5.4:xhigh`,label:`GPT-5.4 Extra High`},{id:`gpt-5.4-mini:medium`,label:`GPT-5.4-Mini Medium`},{id:`gpt-5.4-mini:high`,label:`GPT-5.4-Mini High`},{id:`gpt-5.4-mini:xhigh`,label:`GPT-5.4-Mini Extra High`}]};function Ku({models:e,value:t,onChange:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!r)return;let e=()=>{let e=s.current?.getBoundingClientRect();e&&o({top:e.bottom+4,left:e.left,width:e.width})};e();let t=e=>{let t=e.target;s.current?.contains(t)||c.current?.contains(t)||i(!1)};return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[r]);let l=e.find(e=>e.id===t);return(0,W.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,W.jsxs)(`button`,{ref:s,type:`button`,onClick:()=>i(e=>!e),className:`w-full flex items-center justify-between gap-2 bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none hover:border-white/15 focus:border-[#AF27E3]/30 transition-colors overflow-hidden`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-left ${l?`text-white`:`text-white/20`}`,children:l?l.label:`Choose a model...`}),(0,W.jsx)(te,{className:`h-4 w-4 shrink-0 text-white/30 transition-transform ${r?`rotate-180`:``}`})]}),r&&a&&(0,Vu.createPortal)((0,W.jsx)(`div`,{ref:c,style:{position:`fixed`,top:a.top,left:a.left,width:a.width,zIndex:1e3},className:`bg-[#222] border border-white/[0.08] rounded-xl shadow-xl py-1 max-h-[320px] overflow-y-auto`,children:e.map(e=>(0,W.jsx)(`button`,{onClick:()=>{n(e.id),i(!1)},className:`w-full text-left px-4 py-2 text-[13px] transition-colors ${t===e.id?`text-[#AF27E3] bg-[#AF27E3]/10`:`text-white/70 hover:bg-white/[0.04] hover:text-white`}`,children:e.label},e.id))}),document.body)]})}function qu({onComplete:e,isInitialSetup:t=!1,onSave:n,onTunnelSwitch:r}){let i=t?7:6,[a,o]=(0,v.useState)(0),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(`anthropic`),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)({anthropic:`idle`,openai:`idle`,pi:`idle`}),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(``),[S,te]=(0,v.useState)(``),[he,D]=(0,v.useState)(``),[ge,_e]=(0,v.useState)(``),[ve,ye]=(0,v.useState)(!1),[be,xe]=(0,v.useState)(!1),[Se,Ce]=(0,v.useState)(),[we,Te]=(0,v.useState)(null),[Ee,De]=(0,v.useState)(!1),[Oe,ke]=(0,v.useState)(``),[Ae,je]=(0,v.useState)(!1),[Me,Ne]=(0,v.useState)(),[Pe,Fe]=(0,v.useState)(!1),[Ie,Le]=(0,v.useState)(`device`),[Re,ze]=(0,v.useState)(`idle`),[Be,Ve]=(0,v.useState)(``),[He,Ue]=(0,v.useState)(``),[We,Ge]=(0,v.useState)(!1),[Ke,qe]=(0,v.useState)(!1),[Je,Ye]=(0,v.useState)(!1),[Xe,Ze]=(0,v.useState)(``),[Qe,$e]=(0,v.useState)(!1),[et,tt]=(0,v.useState)(),[nt,rt]=(0,v.useState)(!1),[O,it]=(0,v.useState)(``),[at,k]=(0,v.useState)(null),[ot,A]=(0,v.useState)(``),[st,ct]=(0,v.useState)({}),[lt,ut]=(0,v.useState)(``),[dt,ft]=(0,v.useState)(!1),[pt,j]=(0,v.useState)(!1),[mt,ht]=(0,v.useState)(``),gt=(0,v.useRef)(null),[_t,vt]=(0,v.useState)(`quick`),[yt,bt]=(0,v.useState)(``),[xt,St]=(0,v.useState)(``),[Ct,wt]=(0,v.useState)(`relay`),[Tt,Et]=(0,v.useState)(null),[Dt,Ot]=(0,v.useState)(!1),[kt,At]=(0,v.useState)(!1),[jt,Mt]=(0,v.useState)({}),[Nt,M]=(0,v.useState)(!1),[Pt,Ft]=(0,v.useState)(``),[It,Lt]=(0,v.useState)(``),[Rt,zt]=(0,v.useState)(!1),[Bt,Vt]=(0,v.useState)(`tunnel`),[Ht,Ut]=(0,v.useState)(!1),[Wt,Gt]=(0,v.useState)(``),[Kt,qt]=(0,v.useState)(!1),[Jt,Yt]=(0,v.useState)(``),[Xt,Zt]=(0,v.useState)(!1),[Qt,$t]=(0,v.useState)(!1),[en,tn]=(0,v.useState)(``),[nn,rn]=(0,v.useState)(`admin`),[N,an]=(0,v.useState)(``),[on,sn]=(0,v.useState)(``),[cn,ln]=(0,v.useState)(!1),[un,dn]=(0,v.useState)(!1),[fn,pn]=(0,v.useState)(!1),[mn,hn]=(0,v.useState)(!1),[gn,_n]=(0,v.useState)(``),[vn,yn]=(0,v.useState)(``),[bn,xn]=(0,v.useState)(!1),[Sn,Cn]=(0,v.useState)(!1),[P,wn]=(0,v.useState)(!1),[Tn,En]=(0,v.useState)(!1),[Dn,On]=(0,v.useState)(``),[kn,An]=(0,v.useState)(!1),[jn,Mn]=(0,v.useState)(``),[Nn,Pn]=(0,v.useState)(``),[Fn,In]=(0,v.useState)(``),[Ln,Rn]=(0,v.useState)(``),[zn,Bn]=(0,v.useState)(!1),[Vn,Hn]=(0,v.useState)(!1),[Un,Wn]=(0,v.useState)(``),[Gn,Kn]=(0,v.useState)([]),[qn,Jn]=(0,v.useState)(!1),[Yn,Xn]=(0,v.useState)(!1),[Zn,Qn]=(0,v.useState)(``),[$n,er]=(0,v.useState)(``),[tr,nr]=(0,v.useState)(!1),[rr,ir]=(0,v.useState)(`password`),[ar,or]=(0,v.useState)(!1),sr=(0,v.useRef)(!1),cr=h[l]===`connected`,lr=`bloby_totp_setup`;function ur(){try{sessionStorage.setItem(lr,JSON.stringify({secret:jn,qrUri:Nn,otpauthUri:Fn,phase:rr,portalPass:N,portalPassConfirm:on}))}catch{}}function dr(){try{let e=sessionStorage.getItem(lr);if(!e)return!1;let t=JSON.parse(e);if(t.secret&&t.phase===`totp-setup`)return Mn(t.secret),Pn(t.qrUri||``),In(t.otpauthUri||``),An(!0),ir(`totp-setup`),o(3),t.portalPass&&(an(t.portalPass),sn(t.portalPassConfirm||``)),!0}catch{}return!1}function fr(){try{sessionStorage.removeItem(lr)}catch{}}(0,v.useEffect)(()=>{fetch(`/api/onboard/status`).then(e=>e.json()).then(e=>{e.userName&&c(e.userName),e.handle&&(it(e.handle.username),ut(e.handle.tier||`at`),Et({username:e.handle.username,tier:e.handle.tier,url:e.handle.url}),j(!0),ht(e.handle.url)),e.portalUser&&rn(e.portalUser),e.portalConfigured&&dn(!0),e.provider&&u(e.provider),e.model&&f(e.model),e.whisperEnabled&&(En(!0),On(e.whisperKey||``)),e.totpEnabled&&(An(!0),Bn(!0)),e.tunnelMode&&vt(e.tunnelMode),e.tunnelDomain&&bt(e.tunnelDomain),e.tunnelUrl&&St(e.tunnelUrl),e.handle||wt(`tunnel`),sr.current=!0,e.totpEnabled||dr()}).catch(()=>{sr.current=!0})},[]),(0,v.useEffect)(()=>{Vt(Hu(window.location.hostname))},[]),(0,v.useEffect)(()=>{nr(window.matchMedia(`(max-width: 768px)`).matches||`ontouchstart`in window)},[]),(0,v.useEffect)(()=>{l!==`anthropic`||h.anthropic===`connected`||fetch(`/api/auth/claude/status`).then(e=>e.json()).then(e=>{e.authenticated&&g(e=>({...e,anthropic:`connected`}))}).catch(()=>{})},[l]),(0,v.useEffect)(()=>{l!==`openai`||h.openai===`connected`||fetch(`/api/auth/codex/status`).then(e=>e.json()).then(e=>{e.authenticated&&g(e=>({...e,openai:`connected`}))}).catch(()=>{})},[l]),(0,v.useEffect)(()=>{if(gt.current&&clearTimeout(gt.current),!sr.current||_t===`off`||Tt&&pt&&O===Tt.username)return;k(null),A(``),ct({}),Mt({}),M(!1),Ft(``),Lt(``),j(!1),ht(``);let e=O.trim();if(e){if(e.length<3){k(`invalid`),A(`At least 3 characters`);return}return k(`checking`),gt.current=setTimeout(async()=>{try{let t=await(await fetch(`/api/handle/check/${encodeURIComponent(e)}`)).json();if(!t.valid)k(`invalid`),A(t.error);else{let e={},n={};for(let r of t.handles)e[r.tier]=r.available,r.reserved&&(n[r.tier]=!0);ct(e),Mt(n),k(`ready`),ut(``)}}catch{k(null)}},400),()=>{gt.current&&clearTimeout(gt.current)}}},[O]),(0,v.useEffect)(()=>{if(!O||O.length<3||at!==`ready`)return;let e=async()=>{try{let e=await(await fetch(`/api/handle/check/${encodeURIComponent(O.trim())}`)).json();if(e.valid){let t={},n={};for(let r of e.handles)t[r.tier]=r.available,r.reserved&&(n[r.tier]=!0);ct(t),Mt(n)}}catch{}};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[O,at]);let pr=e=>{it(e.toLowerCase().replace(/[^a-z0-9-]/g,``))},mr=async()=>{if(!(!O||at!==`ready`||!st[lt])){ft(!0);try{let e=await(await fetch(`/api/handle/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:O,tier:lt})})).json();e.ok?(j(!0),ht(e.url)):(A(e.error||`Registration failed`),k(`invalid`))}catch{A(`Could not reach server`),k(`invalid`)}finally{ft(!1)}}},hr=async()=>{if(!(!O||at!==`ready`||!st[lt])){At(!0);try{let e=await(await fetch(`/api/handle/change`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:O,tier:lt})})).json();e.ok?(j(!0),ht(e.url),Et({username:O,tier:lt,url:e.url}),Ot(!1)):(A(e.error||`Handle change failed`),k(`invalid`))}catch{A(`Could not reach server`),k(`invalid`)}finally{At(!1)}}},gr=async()=>{if(!(!O||!Pt)){zt(!0),Lt(``);try{let e=await(await fetch(`/api/handle/claim-reserved`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({handle:O,hash:Pt})})).json();e.ok?(j(!0),ht(e.url),M(!1),Ft(``),ut(`premium`),wt(`relay`)):Lt(e.error||`Invalid activation code`)}catch{Lt(`Could not reach server`)}finally{zt(!1)}}},_r=e=>{l===`openai`&&e!==`openai`&&(Je&&fetch(`/api/auth/codex/cancel`,{method:`POST`}),Re===`pending`&&fetch(`/api/auth/codex/device/cancel`,{method:`POST`})),u(e),f(e===`openai`?`gpt-5.5:high`:``),De(!1),ke(``),Ne(void 0),Ye(!1),Ze(``),ze(`idle`),Ve(``),Ue(``),Le(`device`),tt(void 0),Ce(void 0)};(0,v.useEffect)(()=>{if(l!==`pi`)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([fetch(`/api/auth/pi/providers`),fetch(`/api/auth/pi/status`)]),r=await t.json(),i=await n.json();if(e)return;let a=r?.providers||[];y(a),i?.configured?(x(i.subProvider||``),_e(i.modelId||``),D(i.baseUrl||``),g(e=>({...e,pi:`connected`})),Te({subProvider:i.subProvider,modelId:i.modelId,baseUrl:i.baseUrl}),f(`${i.subProvider}/${i.modelId||``}`)):!b&&a[0]&&(x(a[0].id),D(a[0].baseUrl||``),_e(a[0].defaultModel||``))}catch(t){e||Ce(t?.message||`Failed to load Bloby providers`)}})(),()=>{e=!0}},[l]);let vr=_.find(e=>e.id===b),yr=e=>{let t=_.find(t=>t.id===e);x(e),D(t?.baseUrl||``),_e(t?.defaultModel||``),Ce(void 0),h.pi===`connected`&&(g(e=>({...e,pi:`idle`})),Te(null))},br=async()=>{if(b){Ce(void 0),xe(!0);try{let e={subProvider:b,apiKey:S.trim()||void 0,baseUrl:he.trim()||void 0,modelId:ge.trim()||void 0},t=await(await fetch(`/api/auth/pi/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();if(!t?.ok){Ce(t?.error||`Connection test failed`);return}let n=await(await fetch(`/api/auth/pi/save`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();if(!n?.ok){Ce(n?.error||`Failed to save credentials`);return}g(e=>({...e,pi:`connected`})),Te(n.status||null),f(`${b}/${ge||vr?.defaultModel||``}`),te(``)}catch(e){Ce(e?.message||`Connection failed`)}finally{xe(!1)}}},xr=async()=>{try{await fetch(`/api/auth/pi`,{method:`DELETE`})}catch{}g(e=>({...e,pi:`idle`})),Te(null),f(``)},Sr=e=>{if(window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}else window.open(e,`_blank`,`noopener,noreferrer`)},Cr=async()=>{Ne(void 0);try{let e=await(await fetch(`/api/auth/claude/start`,{method:`POST`})).json();e.success&&e.authUrl?(Sr(e.authUrl),De(!0)):Ne(e.error||`Failed to start authentication`)}catch(e){Ne(e.message)}},wr=async()=>{if(Oe.trim()){je(!0),Ne(void 0);try{let e=await(await fetch(`/api/auth/claude/exchange`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:Oe.trim()})})).json();e.success?g(e=>({...e,anthropic:`connected`})):Ne(e.error||`Code exchange failed`)}catch(e){Ne(e.message)}finally{je(!1)}}},Tr=async()=>{try{let e=await navigator.clipboard.readText();e&&ke(e.trim())}catch{}},Er=async()=>{Fe(!0),Ne(void 0);try{(await(await fetch(`/api/auth/claude/status`)).json()).authenticated?g(e=>({...e,anthropic:`connected`})):Ne(`No active session found. Please authenticate first.`)}catch{}finally{Fe(!1)}},Dr=async()=>{tt(void 0),Ge(!0),ze(`pending`);try{let e=await(await fetch(`/api/auth/codex/device/start`,{method:`POST`})).json();e.success?(Ve(e.userCode||``),Ue(e.verificationUrl||``),e.verificationUrl&&Sr(e.verificationUrl)):(ze(`error`),tt(e.error||`Failed to start device-code login`))}catch(e){ze(`error`),tt(e.message)}finally{Ge(!1)}},Or=async()=>{try{await fetch(`/api/auth/codex/device/cancel`,{method:`POST`})}catch{}ze(`idle`),Ve(``),Ue(``)},kr=async()=>{try{await navigator.clipboard.writeText(Be),qe(!0),setTimeout(()=>qe(!1),1500)}catch{}};(0,v.useEffect)(()=>{if(Re!==`pending`||!Be)return;let e=setInterval(async()=>{try{let e=await(await fetch(`/api/auth/codex/device/status`)).json();e.state===`success`?(ze(`success`),g(e=>({...e,openai:`connected`}))):e.state===`error`&&(ze(`error`),tt(e.error||`Device-code login failed`))}catch{}},2e3);return()=>clearInterval(e)},[Re,Be]);let Ar=async()=>{tt(void 0);try{let e=await(await fetch(`/api/auth/codex/start`,{method:`POST`})).json();e.success&&e.authUrl?(Sr(e.authUrl),Ye(!0)):tt(e.error||`Failed to start authentication`)}catch(e){tt(e.message)}},jr=async()=>{if(Xe.trim()){$e(!0),tt(void 0);try{let e=await(await fetch(`/api/auth/codex/exchange`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:Xe.trim()})})).json();e.success?(g(e=>({...e,openai:`connected`})),Ze(``)):tt(e.error||`Code exchange failed`)}catch(e){tt(e.message)}finally{$e(!1)}}},Mr=async()=>{try{let e=await navigator.clipboard.readText();e&&Ze(e.trim())}catch{}},Nr=async()=>{rt(!0),tt(void 0);try{(await(await fetch(`/api/auth/codex/status`)).json()).authenticated?g(e=>({...e,openai:`connected`})):tt(`No active session found. Please authenticate first.`)}catch{}finally{rt(!1)}},Pr=N===on,Fr=N.length>=6&&Pr,Ir=un?N.length===0||bn&&Fr:Fr,Lr=(()=>{switch(a){case 0:return!0;case 1:return s.trim().length>0;case 2:return Ht||Xt?!1:_t===`off`||_t===`named`||Ct===`tunnel`?O.trim().length>=3:pt;case 3:return!(rr!==`password`||!Ir||kn&&!zn);case 4:return!!(l&&d&&cr);case 5:return!0;default:return!1}})(),Rr=()=>{Lr&&a<i-1&&o(e=>e+1)},zr=()=>{a>0&&o(e=>e-1)},Br=e=>{e.key===`Enter`&&Lr&&Rr()},Vr=async()=>{m(!0);let r={userName:s.trim(),agentName:O.trim()||`Bloby`,provider:l,model:d,apiKey:``,whisperEnabled:Tn,whisperKey:Tn?Dn:``,portalUser:nn.trim(),portalPass:N};try{n?await n(r):await fetch(`/api/onboard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),t?(m(!1),o(6)):e()}catch(e){console.error(`[OnboardWizard] Onboard failed:`,e),m(!1)}},Hr=`w-full bg-white/[0.05] border border-white/[0.08] text-white rounded-xl px-4 py-3 text-base outline-none input-glow placeholder:text-white/20 transition-all`,Ur=`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none input-glow placeholder:text-white/20 transition-all`;return(0,W.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 bg-black/85 backdrop-blur-md`}),(0,W.jsxs)(Bu.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.3},className:`relative w-full max-w-[480px] bg-[#181818] border border-white/[0.06] rounded-[24px] shadow-2xl overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`flex justify-center gap-2 pt-6`,children:Array.from({length:i},(e,t)=>(0,W.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300 ${t===a?`w-7 bg-gradient-brand`:t<a?`w-1.5 bg-gradient-brand opacity-60`:`w-1.5 bg-white/10`}`},t))}),(0,W.jsx)(Xc,{mode:`wait`,children:(0,W.jsxs)(Bu.div,{initial:{opacity:0,x:30},animate:{opacity:1,x:0},exit:{opacity:0,x:-30},transition:{duration:.2,ease:`easeOut`},className:`px-8 pt-6 pb-8`,children:[a===0&&(0,W.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,W.jsxs)(`video`,{autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`h-[180px] mb-4`,children:[(0,W.jsx)(`source`,{src:`/bloby_say_hi.mov`,type:`video/mp4; codecs="hvc1"`}),(0,W.jsx)(`source`,{src:`/bloby_say_hi.webm`,type:`video/webm`})]}),(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-white tracking-tight`,children:`Welcome to Bloby`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[14px] mt-2 leading-relaxed max-w-[320px]`,children:`Let's set up your AI assistant in just a few steps.`}),(0,W.jsxs)(`button`,{onClick:Rr,className:`mt-6 px-7 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center gap-2`,children:[`Get Started`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]}),a===1&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`What's your name?`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is how your agent will address you.`}),(0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[(0,W.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:Br,placeholder:`Enter your name`,autoFocus:!0,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,className:Hr+` flex-1`}),(0,W.jsx)(`button`,{onClick:Rr,disabled:!Lr,className:`shrink-0 h-12 w-12 flex items-center justify-center rounded-full bg-gradient-brand hover:opacity-90 text-white transition-colors disabled:opacity-30`,children:(0,W.jsx)(w,{className:`h-5 w-5`})})]})]}),a===2&&_t===`off`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Bot Name & Access`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Give your bot a name. This is used throughout the app as your bot's identity.`}),(0,W.jsx)(`div`,{className:`relative mt-5`,children:(0,W.jsx)(`input`,{type:`text`,value:O,onChange:e=>pr(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,className:Hr+` pr-10 font-mono`})}),(0,W.jsx)(`div`,{className:`mt-4 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:(0,W.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:`Private network mode — your bot is only accessible via your local network or VPN. No public URL will be created.`})}),!t&&(0,W.jsx)(`div`,{className:`mt-3 flex items-center gap-2`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border ${Uu(Bt)?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-blue-500/10 text-blue-400 border-blue-500/20`}`,children:[Uu(Bt)?(0,W.jsx)(pe,{className:`h-3 w-3`}):(0,W.jsx)(se,{className:`h-3 w-3`}),`Accessing via `,Wu[Bt]]})}),!t&&!Xt&&(0,W.jsxs)(`button`,{onClick:()=>{Zt(!0),tn(``)},className:`w-full mt-4 flex items-center justify-between px-4 py-3 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:border-white/10 hover:bg-white/[0.04] transition-all text-left`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-[13px] text-white/70 font-medium`,children:`Re-enable public tunnel access`}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:`Start a Cloudflare tunnel to make your bot accessible from anywhere`})]}),(0,W.jsx)(se,{className:`h-4 w-4 text-white/30 shrink-0 ml-3`})]}),Xt&&(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(`div`,{className:`bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(fe,{className:`h-4 w-4 text-amber-400 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Enable public access?`}),(0,W.jsxs)(`p`,{className:`text-amber-400/60 text-[12px] mt-1 leading-relaxed`,children:[`This will start a Cloudflare tunnel, making your bot reachable from the internet.`,Tt&&` Your handle will reconnect automatically.`]})]})]})}),en&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[12px]`,children:en}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{onClick:async()=>{if(r){$t(!0),tn(``);try{await r(`quick`),vt(`quick`),Zt(!1)}catch(e){tn(e.message||`Failed to start tunnel`)}finally{$t(!1)}}},disabled:Qt||!r,className:`flex-1 py-2.5 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Qt?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}),`Starting tunnel...`]}):`Enable Tunnel`}),(0,W.jsx)(`button`,{onClick:()=>{Zt(!1),tn(``)},disabled:Qt,className:`px-5 py-2.5 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Cancel`})]})]}),(0,W.jsxs)(`button`,{onClick:Rr,disabled:!Lr,className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]}),a===2&&_t===`named`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Bot Name & Access`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is your bot's identity. Your named tunnel domain is already configured.`}),(0,W.jsx)(`div`,{className:`relative mt-5`,children:(0,W.jsx)(`input`,{type:`text`,value:O,onChange:e=>pr(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,className:Hr+` pr-10 font-mono`})}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsxs)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:[`https://`,yt]}),(0,W.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(`https://${yt}`),ln(!0),setTimeout(()=>ln(!1),2e3)},className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:cn?(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}):(0,W.jsx)(ne,{className:`h-4 w-4`})})]})]}),a===2&&_t===`quick`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Bot Name & Access`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is your bot's name and permanent handle — access it from anywhere.`}),Tt&&pt&&!Dt&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}),(0,W.jsx)(`p`,{className:`text-emerald-400/90 text-[13px] font-medium`,children:`Current handle`})]}),(0,W.jsx)(`p`,{className:`text-emerald-400/60 text-[12px] mt-1 font-mono`,children:mt})]}),(0,W.jsxs)(`div`,{className:`flex gap-2 mt-4`,children:[(0,W.jsxs)(`button`,{onClick:Rr,className:`flex-1 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]}),(0,W.jsx)(`button`,{onClick:()=>{Ot(!0),j(!1),it(``),k(null),ct({}),wt(`relay`)},className:`px-5 py-3 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Change`})]})]}),Dt&&!pt&&(0,W.jsxs)(`div`,{className:`mt-4 bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Changing your handle`}),(0,W.jsxs)(`p`,{className:`text-amber-400/60 text-[12px] mt-1`,children:[`Your current handle `,(0,W.jsx)(`span`,{className:`font-mono`,children:Tt?.url}),` will be released and become available for others.`]})]}),(!Tt||Dt||!pt)&&!(Tt&&pt&&!Dt)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`relative mt-5`,children:[(0,W.jsx)(`input`,{type:`text`,value:O,onChange:e=>pr(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,disabled:pt,className:Hr+` pr-10 font-mono`+(pt?` opacity-50`:``)}),at&&O.length>0&&!pt&&(0,W.jsxs)(`div`,{className:`absolute right-4 top-1/2 -translate-y-1/2`,children:[at===`checking`&&(0,W.jsx)(`div`,{className:`w-5 h-5 border-2 border-white/10 border-t-[#04D1FE] rounded-full animate-spin`}),at===`invalid`&&(0,W.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-amber-500/15 flex items-center justify-center`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5 text-amber-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:(0,W.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3m0 4h.01`})})})]})]}),at===`invalid`&&ot&&(0,W.jsx)(`p`,{className:`text-amber-400 text-[12px] mt-2`,children:ot}),at===`ready`&&O.length>0&&!pt&&(0,W.jsxs)(`div`,{className:`space-y-3 mt-4`,children:[(()=>{let e=st.at===!1,t=Ct===`relay`&&lt===`at`;return(0,W.jsxs)(`button`,{onClick:()=>{e||(ut(`at`),wt(`relay`))},disabled:e,className:`w-full rounded-xl border transition-all duration-200 text-left px-4 py-3 ${e?`border-white/[0.04] opacity-50 cursor-not-allowed`:t?`border-[#AF27E3]/30 bg-white/[0.04]`:`border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`Free`}),(0,W.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border ${e?`bg-red-500/10 text-red-400 border-red-500/20`:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`}`,children:e?`Taken`:`Available`})]}),(0,W.jsxs)(`p`,{className:`font-mono text-[13px] mt-1.5 ${t?`text-white/80`:`text-white/40`}`,children:[`open.bloby.bot/`,O]})]})})(),(()=>{let e=st.premium,t=e===!1,n=t&&jt.premium;return(0,W.jsxs)(`div`,{className:`rounded-xl border transition-all duration-200 text-left px-4 py-3 ${n?`border-[#AF27E3]/20`:`border-white/[0.06]`}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`Premium`}),(0,W.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border bg-[#AF27E3]/15 text-[#AF27E3] border-[#AF27E3]/20`,children:`$5`})]}),(0,W.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border ${n?`bg-[#AF27E3]/10 text-[#AF27E3] border-[#AF27E3]/20`:t?`bg-red-500/10 text-red-400 border-red-500/20`:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`}`,children:n?`Reserved`:t?`Taken`:`Available`})]}),(0,W.jsxs)(`p`,{className:`font-mono text-[13px] mt-1.5 text-white/40`,children:[`bloby.bot/`,O]}),e&&(0,W.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-white/[0.06] flex items-center justify-between`,children:[(0,W.jsx)(`p`,{className:`text-[12px] text-white/40`,children:`Purchase on bloby.bot`}),(0,W.jsx)(`a`,{href:`https://www.bloby.bot/#reserve`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[12px] font-medium text-[#AF27E3] hover:text-[#c44df7] transition-colors`,children:`Purchase`})]}),n&&(0,W.jsx)(`div`,{className:`mt-3 pt-3 border-t border-[#AF27E3]/10`,children:Nt?(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,W.jsxs)(`p`,{className:`text-[12px] text-white/40`,children:[`Enter the 5-character code from your `,(0,W.jsx)(`span`,{className:`text-white/60 font-medium`,children:`bloby.bot`}),` account`]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,value:Pt,onChange:e=>Ft(e.target.value.trim()),maxLength:5,placeholder:`e.g. a3Kx9`,spellCheck:!1,autoComplete:`off`,autoFocus:!0,className:`flex-1 bg-white/[0.05] border border-white/[0.08] text-white rounded-lg px-3 py-2 text-[13px] font-mono outline-none focus:border-[#AF27E3]/30 transition-colors placeholder:text-white/20 tracking-widest text-center`}),(0,W.jsx)(`button`,{onClick:gr,disabled:Rt||Pt.length<5,className:`px-4 py-2 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-semibold rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-40`,children:Rt?(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}):`Activate`})]}),It&&(0,W.jsx)(`p`,{className:`text-red-400 text-[12px]`,children:It}),(0,W.jsx)(`button`,{onClick:()=>{M(!1),Ft(``),Lt(``)},className:`text-[11px] text-white/25 hover:text-white/40 transition-colors`,children:`Cancel`})]}):(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`p`,{className:`text-[12px] text-white/40`,children:`Is that yours?`}),(0,W.jsx)(`button`,{onClick:()=>{M(!0),Ft(``),Lt(``)},className:`text-[12px] font-medium text-[#AF27E3] hover:text-[#c44df7] transition-colors`,children:`Activate`})]})})]})})(),(0,W.jsxs)(`button`,{onClick:()=>{wt(`tunnel`),ut(`skip`)},className:`w-full rounded-xl border transition-all duration-200 text-left px-4 py-3 ${lt===`skip`?`border-[#AF27E3]/30 bg-white/[0.04]`:`border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,W.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`No handle`}),(0,W.jsx)(`p`,{className:`text-[13px] mt-1.5 ${lt===`skip`?`text-white/60`:`text-white/30`}`,children:`I'll use the random tunnel URL`})]})]}),pt&&(0,W.jsxs)(`div`,{className:`mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}),(0,W.jsx)(`p`,{className:`text-emerald-400/90 text-[13px] font-medium`,children:`Handle claimed!`})]}),(0,W.jsx)(`p`,{className:`text-emerald-400/60 text-[12px] mt-1 font-mono`,children:mt})]}),at===`ready`&&O.length>0&&!pt&&(0,W.jsx)(`button`,{onClick:lt===`skip`?Rr:Ct===`relay`&&lt===`at`?Dt?hr:mr:void 0,disabled:!lt||dt||kt||lt===`at`&&!st.at,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:dt||kt?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}),Dt?`Changing...`:`Claiming...`]}):lt?lt===`skip`?(0,W.jsxs)(W.Fragment,{children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]}):(0,W.jsxs)(W.Fragment,{children:[Dt?`Change Handle`:`Claim & Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]}):(0,W.jsx)(W.Fragment,{children:`Select an option to continue`})}),pt&&(0,W.jsxs)(`button`,{onClick:Rr,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]}),Dt&&!pt&&(0,W.jsx)(`button`,{onClick:()=>{Ot(!1),it(Tt.username),j(!0),ht(Tt.url),ut(Tt.tier),wt(`relay`),k(null)},className:`w-full mt-2 py-2 text-white/25 hover:text-white/40 text-[12px] transition-colors`,children:`Cancel — keep current handle`})]}),!t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mt-5 flex items-center gap-2`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border ${Uu(Bt)?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-blue-500/10 text-blue-400 border-blue-500/20`}`,children:[Uu(Bt)?(0,W.jsx)(me,{className:`h-3 w-3`}):(0,W.jsx)(se,{className:`h-3 w-3`}),`Accessing via `,Wu[Bt]]})}),!Ht&&(0,W.jsxs)(`button`,{onClick:()=>{Uu(Bt)&&(Ut(!0),Gt(``),Yt(``))},disabled:!Uu(Bt),className:`w-full mt-3 flex items-center justify-between px-4 py-3 rounded-xl border transition-all text-left ${Uu(Bt)?`border-white/[0.06] bg-white/[0.02] hover:border-white/10 hover:bg-white/[0.04] cursor-pointer`:`border-white/[0.04] bg-transparent opacity-50 cursor-not-allowed`}`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-[13px] text-white/70 font-medium`,children:`Switch to private network only`}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:Uu(Bt)?`Stop the tunnel and relay — access only via Tailscale or LAN`:`Connect via Tailscale or private network to unlock`})]}),(0,W.jsx)(pe,{className:`h-4 w-4 text-white/30 shrink-0 ml-3`})]}),Ht&&(0,W.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,W.jsx)(`div`,{className:`bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(fe,{className:`h-4 w-4 text-amber-400 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Switch to private network only?`}),(0,W.jsx)(`p`,{className:`text-amber-400/60 text-[12px] mt-1 leading-relaxed`,children:`This will stop the Cloudflare tunnel and relay connection. Your bot will only be accessible via your private network.`}),Tt&&(0,W.jsx)(`p`,{className:`text-amber-400/50 text-[12px] mt-1.5`,children:`Your handle will be preserved and can be re-activated later.`})]})]})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:[`Type `,(0,W.jsx)(`span`,{className:`font-mono text-white/60`,children:`I confirm`}),` to proceed`]}),(0,W.jsx)(`input`,{type:`text`,value:Wt,onChange:e=>Gt(e.target.value),placeholder:`I confirm`,spellCheck:!1,autoFocus:!0,className:Ur})]}),Jt&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[12px]`,children:Jt}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{onClick:async()=>{if(!(!r||Wt.trim().toLowerCase()!==`i confirm`)){qt(!0),Yt(``);try{await r(`off`),vt(`off`),Ut(!1)}catch(e){Yt(e.message||`Failed to switch`)}finally{qt(!1)}}},disabled:Kt||Wt.trim().toLowerCase()!==`i confirm`||!r,className:`flex-1 py-2.5 bg-amber-600 hover:bg-amber-500 text-white text-[13px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Kt?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}),`Switching...`]}):`Confirm Switch`}),(0,W.jsx)(`button`,{onClick:()=>{Ut(!1),Gt(``),Yt(``)},disabled:Kt,className:`px-5 py-2.5 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Cancel`})]})]})]})]}),a===3&&(0,W.jsx)(`div`,{children:(0,W.jsxs)(Xc,{mode:`wait`,children:[rr===`password`&&(0,W.jsxs)(Bu.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.15},children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:un?`Password & 2FA`:`Set a password`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:un?`Your portal password is already set — you can keep it as-is or change it below.`:`You'll need this password to access your agent's chat. Keep it safe — anyone with your URL will need it to log in.`}),un&&!P&&(0,W.jsxs)(`div`,{className:`mt-5 flex items-center justify-between bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-white/70 text-[13px] font-medium`,children:`Bloby Chat Password`}),(0,W.jsx)(`p`,{className:`text-white/30 text-[11px] mt-0.5`,children:`Already configured.`})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{wn(!0),_n(``),yn(``),xn(!1),an(``),sn(``)},className:`shrink-0 px-3.5 py-2 bg-white/[0.04] hover:bg-white/[0.08] text-white/70 hover:text-white text-[12px] font-medium rounded-lg transition-colors`,children:`Change password`})]}),un&&P&&(0,W.jsxs)(`div`,{className:`mt-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium`,children:`Current password`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{wn(!1),_n(``),yn(``),xn(!1),an(``),sn(``)},className:`text-white/30 hover:text-white/60 text-[11px] transition-colors`,children:`Cancel`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`password`,value:gn,onChange:e=>{_n(e.target.value),yn(``),xn(!1)},placeholder:`Enter your current password`,autoComplete:`current-password`,className:Hr+` flex-1`}),gn.length>0&&!bn&&(0,W.jsx)(`button`,{onClick:async()=>{Cn(!0),yn(``);try{(await(await fetch(`/api/portal/verify-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:gn})})).json()).valid?xn(!0):yn(`Incorrect password`)}catch{yn(`Could not verify`)}finally{Cn(!1)}},disabled:Sn,className:`shrink-0 px-4 py-3 bg-white/[0.06] hover:bg-white/[0.1] text-white/60 text-[13px] font-medium rounded-xl transition-colors disabled:opacity-40`,children:Sn?(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}):`Verify`}),bn&&(0,W.jsx)(`div`,{className:`shrink-0 w-10 h-10 flex items-center justify-center`,children:(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`})})]}),vn&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:vn})]}),(!un||P&&bn)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:un?`mt-3`:`mt-5`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:un?`New password`:`Password`}),(0,W.jsx)(`input`,{type:`password`,value:N,onChange:e=>an(e.target.value),placeholder:`••••••••`,autoComplete:`new-password`,autoFocus:!un,onKeyDown:Br,className:Hr}),N.length>0&&N.length<6&&(0,W.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`At least 6 characters`})]}),(0,W.jsxs)(`div`,{className:`mt-3`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:un?`Confirm new password`:`Confirm password`}),(0,W.jsx)(`input`,{type:`password`,value:on,onChange:e=>sn(e.target.value),placeholder:`••••••••`,autoComplete:`new-password`,onKeyDown:Br,className:Hr}),on.length>0&&!Pr&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:`Passwords don't match`})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 border border-white/[0.06] rounded-xl overflow-hidden`,children:[(0,W.jsxs)(`button`,{onClick:async()=>{if(kn&&zn){Xn(!0);return}if(kn)An(!1),Pn(``),Mn(``),In(``);else{if(An(!0),Wn(``),Rn(``),un&&!bn){wn(!0),Wn(`Enter your current portal password above first, then toggle 2FA again.`),An(!1);return}if(Nn)ir(`totp-setup`);else try{let e=await fetch(`/api/portal/totp/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:un?gn:N})}),t=await e.json();e.ok?(Mn(t.secret),Pn(t.qrDataUri),In(t.otpauthUri),ir(`totp-setup`)):(Wn(t.error||`Setup failed`),An(!1))}catch{Wn(`Could not reach server`),An(!1)}}},type:`button`,className:`w-full flex items-center gap-3 px-4 py-3 text-left`,children:[(0,W.jsx)(`div`,{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${kn&&zn?`bg-emerald-500/10`:`bg-white/[0.04]`}`,children:kn&&zn?(0,W.jsx)(T,{className:`h-[18px] w-[18px] text-emerald-400`}):(0,W.jsx)(E,{className:`h-[18px] w-[18px] text-white/30`})}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(`span`,{className:`text-[13px] font-medium text-white block`,children:`Two-Factor Auth`}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:kn&&zn?(0,W.jsx)(`span`,{className:`text-emerald-400/70`,children:`Active — authenticator app required`}):_t===`quick`||_t===`named`?(0,W.jsx)(`span`,{children:`Recommended for public bots`}):(0,W.jsx)(`span`,{children:`Extra security with an authenticator app`})})]}),(0,W.jsx)(`div`,{className:`w-10 h-6 rounded-full transition-colors relative shrink-0 ${kn?`bg-emerald-500`:`bg-white/10`}`,children:(0,W.jsx)(`div`,{className:`absolute top-1 w-4 h-4 rounded-full bg-white shadow transition-transform ${kn?`translate-x-5`:`translate-x-1`}`})})]}),Yn&&(0,W.jsxs)(`div`,{className:`px-4 pb-3 border-t border-white/[0.06]`,children:[(0,W.jsx)(`p`,{className:`text-[12px] text-white/40 mt-3 mb-2`,children:`Enter your current TOTP code to disable 2FA:`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,value:Zn,onChange:e=>{Qn(e.target.value.replace(/\D/g,``)),er(``)},placeholder:`000000`,className:Ur+` flex-1 tracking-[0.3em] text-center font-mono`}),(0,W.jsx)(`button`,{onClick:async()=>{if(Zn.length===6)try{let e=await fetch(`/api/portal/totp/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:un?gn:N,code:Zn})}),t=await e.json();e.ok?(An(!1),Bn(!1),Mn(``),Pn(``),In(``),Xn(!1),Qn(``),Kn([]),Jn(!1)):er(t.error||`Failed to disable`)}catch{er(`Could not reach server`)}},disabled:Zn.length!==6,className:`shrink-0 px-4 py-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-400 text-[13px] font-medium rounded-xl transition-colors disabled:opacity-40`,children:`Disable`})]}),$n&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:$n}),(0,W.jsx)(`button`,{onClick:()=>{Xn(!1),Qn(``),er(``)},className:`text-[11px] text-white/30 hover:text-white/50 mt-2`,children:`Cancel`})]}),Un&&rr===`password`&&(0,W.jsx)(`div`,{className:`mx-4 mb-3 bg-red-500/8 border border-red-500/15 rounded-xl px-3 py-2`,children:(0,W.jsx)(`p`,{className:`text-red-400/90 text-[11px]`,children:Un})})]}),(0,W.jsxs)(`button`,{onClick:Rr,disabled:!Lr,className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]},`password`),rr===`totp-setup`&&(0,W.jsxs)(Bu.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,W.jsx)(`button`,{onClick:()=>{An(!1),Pn(``),Mn(``),In(``),Rn(``),Wn(``),ir(`password`),fr()},className:`w-7 h-7 rounded-full bg-white/[0.04] flex items-center justify-center text-white/40 hover:text-white/70 transition-colors shrink-0`,children:(0,W.jsx)(C,{className:`h-4 w-4`})}),(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Set up 2FA`})]}),Un&&(0,W.jsx)(`div`,{className:`mt-3 bg-red-500/8 border border-red-500/15 rounded-xl px-3 py-2`,children:(0,W.jsx)(`p`,{className:`text-red-400/90 text-[11px]`,children:Un})}),Nn&&(0,W.jsxs)(W.Fragment,{children:[tr?(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] leading-relaxed mb-4`,children:`Add Bloby to your authenticator app, then enter the 6-digit code below to confirm.`}),(0,W.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(jn),or(!0),setTimeout(()=>or(!1),3e3)},className:`w-full py-3 text-[14px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 ${ar?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-white/[0.05] text-white/70 hover:bg-white/[0.08] border border-white/[0.08]`}`,children:ar?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ee,{className:`h-4 w-4`}),`Secret key copied`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(re,{className:`h-4 w-4`}),`Copy secret key`]})}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/20 text-center mt-2`,children:`Paste it in your authenticator app → Add account → Enter key`}),(0,W.jsxs)(`a`,{href:Fn,onClick:()=>ur(),className:`w-full mt-3 py-2.5 text-[13px] text-white/30 hover:text-white/50 flex items-center justify-center gap-1.5 transition-colors`,children:[(0,W.jsx)(de,{className:`h-3.5 w-3.5`}),`Or open directly in authenticator`]})]}):(0,W.jsxs)(`div`,{className:`mt-4 flex gap-4 items-start`,children:[(0,W.jsx)(`div`,{className:`shrink-0`,children:(0,W.jsx)(`div`,{className:`bg-white rounded-xl p-1.5`,children:(0,W.jsx)(`img`,{src:Nn,alt:`TOTP QR Code`,className:`w-[140px] h-[140px]`})})}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] leading-relaxed`,children:`Scan this QR code with your authenticator app.`}),(0,W.jsx)(`p`,{className:`text-white/25 text-[11px] mt-2 leading-relaxed`,children:`Google Authenticator, Authy, 1Password, or any TOTP app.`}),(0,W.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(jn)},className:`mt-3 text-[11px] text-white/25 hover:text-white/40 flex items-center gap-1 transition-colors`,children:[(0,W.jsx)(re,{className:`h-3 w-3`}),`Copy secret key`]})]})]}),(0,W.jsxs)(`div`,{className:`mt-5`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`Enter the 6-digit code from your app`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,value:Ln,onChange:e=>{Rn(e.target.value.replace(/\D/g,``)),Wn(``)},placeholder:`000000`,autoFocus:!0,className:Hr+` tracking-[0.3em] text-center font-mono flex-1`}),(0,W.jsx)(`button`,{onClick:async()=>{if(Ln.length===6){Hn(!0),Wn(``);try{let e=await fetch(`/api/portal/totp/verify-setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:Ln,password:un?gn:N})}),t=await e.json();e.ok&&t.success?(Bn(!0),Kn(t.recoveryCodes||[]),ir(`recovery`),fr()):Wn(t.error||`Verification failed`)}catch{Wn(`Could not reach server`)}finally{Hn(!1)}}},disabled:Ln.length!==6||Vn,className:`shrink-0 px-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-xl transition-colors flex items-center gap-2 disabled:opacity-40`,children:Vn?(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}):`Verify`})]})]})]})]},`totp-setup`),rr===`recovery`&&(0,W.jsxs)(Bu.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,W.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-emerald-500/10 flex items-center justify-center shrink-0`,children:(0,W.jsx)(T,{className:`h-[18px] w-[18px] text-emerald-400`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`2FA enabled`}),(0,W.jsx)(`p`,{className:`text-emerald-400/70 text-[12px]`,children:`Save your recovery codes`})]})]}),(0,W.jsx)(`p`,{className:`text-white/35 text-[13px] mt-3 leading-relaxed`,children:`If you lose your authenticator app, you can use one of these codes to sign in. Each code works once. Store them somewhere safe.`}),(0,W.jsx)(`div`,{className:`mt-4 grid grid-cols-2 gap-1.5`,children:Gn.map((e,t)=>(0,W.jsx)(`div`,{className:`bg-white/[0.03] border border-white/[0.06] rounded-lg px-3 py-2 text-center`,children:(0,W.jsx)(`code`,{className:`text-[13px] text-white/60 font-mono tracking-wider`,children:e})},t))}),(0,W.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(Gn.join(`
21
- `)),Jn(!0)},className:`w-full mt-4 py-3 text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 ${qn?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-white/[0.05] text-white/60 hover:bg-white/[0.08] border border-white/[0.08]`}`,children:qn?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ee,{className:`h-4 w-4`}),`Copied`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(re,{className:`h-4 w-4`}),`Copy recovery codes`]})}),(0,W.jsxs)(`button`,{onClick:()=>{Kn([]),ir(`password`),fr()},disabled:!qn,className:`w-full mt-3 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Done`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]},`recovery`)]})}),a===4&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Choose your AI provider`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Pick one provider to power your bot, authenticate, and select a model.`}),(0,W.jsx)(`div`,{className:`flex gap-2.5 mt-4`,children:Z.map(e=>(0,W.jsxs)(`button`,{onClick:()=>_r(e.id),className:`flex-1 relative rounded-xl border transition-all duration-200 p-3 text-left ${l===e.id?`bg-white/[0.04] border-[#AF27E3]/40`:`bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 py-0.5`,children:[(0,W.jsx)(`div`,{className:`h-[30px] flex items-center justify-center`,children:e.icon?(0,W.jsx)(`img`,{src:e.icon,alt:e.name,className:`h-[30px] w-auto object-contain`}):(0,W.jsx)(`div`,{className:`h-[30px] w-[30px] rounded-lg bg-white/[0.06] flex items-center justify-center text-white/50 text-sm font-bold`,children:`O`})}),(0,W.jsxs)(`div`,{className:`text-center`,children:[(0,W.jsx)(`div`,{className:`text-[13px] font-medium text-white`,children:e.name}),(0,W.jsx)(`div`,{className:`text-[10px] text-white/30 whitespace-pre-line leading-tight`,children:e.subtitle})]})]}),h[e.id]===`connected`?(0,W.jsx)(`div`,{className:`absolute top-2 right-2 w-4 h-4 rounded-full bg-emerald-500/15 flex items-center justify-center`,children:(0,W.jsx)(ee,{className:`h-2.5 w-2.5 text-emerald-400`})}):l===e.id?(0,W.jsx)(`div`,{className:`absolute top-2 right-2 w-2 h-2 rounded-full bg-gradient-brand`}):null]},e.id))}),(0,W.jsx)(`div`,{className:`border-t border-white/[0.06] mt-4 mb-3`}),l===`pi`&&(0,W.jsx)(`div`,{className:`space-y-2`,children:h.pi===`connected`&&we?(0,W.jsxs)(`div`,{className:`flex items-center justify-between bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3 py-2`,children:[(0,W.jsxs)(`p`,{className:`text-emerald-400/90 text-[12px] truncate`,children:[`Connected — `,_.find(e=>e.id===we.subProvider)?.name||we.subProvider,we.modelId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`span`,{className:`font-mono`,children:we.modelId})]}):null]}),(0,W.jsxs)(`button`,{onClick:xr,className:`text-white/30 hover:text-white/60 text-[11px] flex items-center gap-1 shrink-0 ml-2`,children:[(0,W.jsx)(ue,{className:`h-3 w-3`}),`Change`]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[11px] text-white/40 font-medium mb-1 block`,children:`Provider`}),(0,W.jsx)(Ku,{models:_.map(e=>({id:e.id,label:e.name})),value:b,onChange:yr})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[11px] text-white/40 font-medium mb-1 block`,children:`Model`}),vr&&Array.isArray(vr.models)?(0,W.jsx)(Ku,{models:vr.models,value:ge,onChange:_e}):(0,W.jsx)(`input`,{type:`text`,value:ge,onChange:e=>_e(e.target.value),placeholder:vr?.defaultModel||`model-id`,className:Ur+` font-mono`})]})]}),vr?.needsBaseUrl&&(0,W.jsx)(`input`,{type:`text`,value:he,onChange:e=>D(e.target.value),placeholder:vr.baseUrl||`https://example.com/v1`,className:Ur+` font-mono`}),vr?.needsApiKey&&(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`input`,{type:ve?`text`:`password`,value:S,onChange:e=>te(e.target.value),onKeyDown:e=>e.key===`Enter`&&br(),placeholder:`API key…`,className:Ur+` pr-16 font-mono`}),(0,W.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1.5`,children:[vr.apiKeyUrl&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>Sr(vr.apiKeyUrl),className:`text-white/25 hover:text-white/55 transition-colors`,title:`Get a key`,children:(0,W.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>ye(e=>!e),className:`text-white/25 hover:text-white/55 transition-colors`,children:ve?(0,W.jsx)(ae,{className:`h-3.5 w-3.5`}):(0,W.jsx)(oe,{className:`h-3.5 w-3.5`})})]})]}),Se&&(0,W.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3 py-2`,children:(0,W.jsx)(`p`,{className:`text-[12px] text-red-400/90 break-words`,children:Se})}),(0,W.jsx)(`button`,{onClick:br,disabled:be||!b||!!vr?.needsApiKey&&!S.trim()||!!vr?.needsBaseUrl&&!he.trim()||!ge.trim(),className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:be?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),`Connecting…`]}):(0,W.jsxs)(W.Fragment,{children:[`Test & connect`,(0,W.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})})]})}),l===`bloby`&&(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(`p`,{className:`text-[12px] text-white/40 leading-relaxed`,children:`Bloby (managed) is on the way. Sign in with Google once it ships and your bot will be hosted, updated, and billed by us — no API keys to manage.`}),(0,W.jsxs)(`button`,{type:`button`,disabled:!0,title:`Coming soon`,className:`w-full py-2.5 px-4 bg-white/[0.04] border border-white/[0.06] text-white/35 text-[13px] font-medium rounded-xl flex items-center justify-center gap-2 cursor-not-allowed`,children:[(0,W.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 opacity-50`,fill:`currentColor`,children:(0,W.jsx)(`path`,{d:`M21.35 11.1h-9.17v2.96h5.27c-.23 1.39-1.62 4.08-5.27 4.08-3.17 0-5.76-2.62-5.76-5.85s2.59-5.85 5.76-5.85c1.81 0 3.02.77 3.71 1.43l2.53-2.43C16.85 3.91 14.74 3 12.18 3 7.03 3 2.86 7.17 2.86 12.29s4.17 9.29 9.32 9.29c5.38 0 8.94-3.79 8.94-9.12 0-.61-.07-1.08-.17-1.55Z`})}),`Login with Google`]}),(0,W.jsx)(`p`,{className:`text-[10.5px] text-white/25 text-center`,children:`Not available yet.`})]}),l===`anthropic`&&(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[cr&&(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,W.jsx)(`div`,{className:`bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5`,children:(0,W.jsx)(`p`,{className:`text-emerald-400/90 text-[12px]`,children:`Connected — Anthropic subscription is active.`})}),(0,W.jsxs)(`button`,{onClick:()=>{g(e=>({...e,anthropic:`idle`})),De(!1),ke(``),Ne(``)},className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5`,children:[(0,W.jsx)(ue,{className:`h-3 w-3`}),`Re-authenticate`]})]}),!cr&&(0,W.jsxs)(W.Fragment,{children:[Me&&(0,W.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5`,children:(0,W.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:Me})}),(0,W.jsx)(`div`,{className:`space-y-1.5`,children:[`Click the button below to open Anthropic's login page`,`Sign in with your Anthropic account — a code will be generated`,`Copy the code and paste it in the field below`].map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,W.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,W.jsx)(`button`,{onClick:Cr,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2`,children:Ee?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ie,{className:`h-3.5 w-3.5 opacity-60`}),`Open authentication page again`]}):(0,W.jsxs)(W.Fragment,{children:[`Authenticate with Anthropic`,(0,W.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`input`,{type:`text`,value:Oe,onChange:e=>ke(e.target.value),onKeyDown:e=>e.key===`Enter`&&wr(),placeholder:`Paste your code here...`,className:Ur+` pr-10 font-mono`}),(0,W.jsx)(`button`,{onClick:Tr,className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors`,children:(0,W.jsx)(ne,{className:`h-3.5 w-3.5`})})]}),(0,W.jsx)(`button`,{onClick:wr,disabled:!Oe.trim()||Ae,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Ae?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),`Verifying...`]}):`Connect`}),(0,W.jsxs)(`button`,{onClick:Er,disabled:Pe,className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5 disabled:opacity-50`,children:[Pe?(0,W.jsx)(ce,{className:`h-3 w-3 animate-spin`}):(0,W.jsx)(ue,{className:`h-3 w-3`}),Pe?`Checking...`:`I'm already authenticated`]})]})]}),l===`openai`&&(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[cr&&(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,W.jsx)(`div`,{className:`bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5`,children:(0,W.jsx)(`p`,{className:`text-emerald-400/90 text-[12px]`,children:`Connected — ChatGPT subscription is active.`})}),(0,W.jsxs)(`button`,{onClick:()=>{g(e=>({...e,openai:`idle`})),tt(``)},className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5`,children:[(0,W.jsx)(ue,{className:`h-3 w-3`}),`Re-authenticate`]})]}),!cr&&(0,W.jsxs)(W.Fragment,{children:[et&&(0,W.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5`,children:(0,W.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:et})}),Ie===`device`&&Re!==`pending`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`space-y-1.5`,children:[`Click below — we'll open auth.openai.com/codex/device for you`,`Sign in with your ChatGPT Plus or Pro account`,`Type the one-time code shown here on that page`].map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,W.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,W.jsx)(`button`,{onClick:Dr,disabled:We,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-60`,children:We?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),`Requesting code...`]}):(0,W.jsxs)(W.Fragment,{children:[`Sign in with ChatGPT`,(0,W.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})})]}),Ie===`device`&&Re===`pending`&&Be&&(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`bg-white/[0.03] border border-white/[0.06] rounded-xl p-4`,children:[(0,W.jsx)(`p`,{className:`text-[11px] text-white/40 mb-1`,children:`1. Open this URL in any browser`}),(0,W.jsxs)(`button`,{onClick:()=>Sr(He),className:`w-full text-left py-2 px-3 bg-white/[0.04] hover:bg-white/[0.07] rounded-lg text-[12px] font-mono text-white/80 flex items-center justify-between transition-colors`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:He}),(0,W.jsx)(ie,{className:`h-3.5 w-3.5 ml-2 opacity-60 shrink-0`})]}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/40 mt-3 mb-1`,children:`2. Enter this code`}),(0,W.jsxs)(`button`,{onClick:kr,className:`w-full py-3 px-3 bg-white/[0.04] hover:bg-white/[0.07] rounded-lg text-center transition-colors flex items-center justify-center gap-3 group`,children:[(0,W.jsx)(`span`,{className:`text-[20px] font-mono font-semibold text-white tracking-widest`,children:Be}),Ke?(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}):(0,W.jsx)(re,{className:`h-4 w-4 text-white/30 group-hover:text-white/60`})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-2 mt-3 text-[11px] text-white/40`,children:[(0,W.jsx)(ce,{className:`h-3 w-3 animate-spin`}),`Waiting for you to approve...`]})]}),(0,W.jsx)(`button`,{onClick:Or,className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors`,children:`Cancel`})]}),Ie===`paste`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`space-y-1.5`,children:[`Click below to open ChatGPT sign-in`,`Sign in with your ChatGPT Plus or Pro account`,`Your browser will say "site can't be reached" — that's expected. Copy the FULL URL from the address bar and paste it below.`].map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,W.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,W.jsx)(`button`,{onClick:Ar,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2`,children:Je?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ie,{className:`h-3.5 w-3.5 opacity-60`}),`Open authentication page again`]}):(0,W.jsxs)(W.Fragment,{children:[`Authenticate with ChatGPT`,(0,W.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`input`,{type:`text`,value:Xe,onChange:e=>Ze(e.target.value),onKeyDown:e=>e.key===`Enter`&&jr(),placeholder:`Paste callback URL or code here...`,className:Ur+` pr-10 font-mono`}),(0,W.jsx)(`button`,{onClick:Mr,className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors`,children:(0,W.jsx)(ne,{className:`h-3.5 w-3.5`})})]}),(0,W.jsx)(`button`,{onClick:jr,disabled:!Xe.trim()||Qe,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Qe?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),`Verifying...`]}):`Connect`})]}),Re!==`pending`&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,W.jsx)(`button`,{onClick:()=>{tt(void 0),Le(Ie===`device`?`paste`:`device`)},className:`text-white/25 text-[11px] hover:text-white/40 transition-colors`,children:Ie===`device`?`Use callback URL instead`:`Use device code instead`}),(0,W.jsxs)(`button`,{onClick:Nr,disabled:nt,className:`text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center gap-1.5 disabled:opacity-50`,children:[nt?(0,W.jsx)(ce,{className:`h-3 w-3 animate-spin`}):(0,W.jsx)(ue,{className:`h-3 w-3`}),nt?`Checking...`:`I'm already authenticated`]})]})]})]}),cr&&l!==`pi`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`border-t border-white/[0.06] mt-4 mb-3`}),(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`Select a model`}),(0,W.jsx)(Ku,{models:Gu[l]||[],value:d,onChange:f})]}),cr&&(0,W.jsxs)(`button`,{onClick:Rr,disabled:!Lr,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]}),a===5&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:`Voice Messages`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1 leading-relaxed`,children:`Voice input works out of the box using your browser's built-in speech recognition. For better accuracy, you can optionally enable OpenAI Whisper.`}),(0,W.jsx)(`div`,{className:`w-full mt-5 rounded-xl border border-emerald-500/20 bg-emerald-500/[0.04] p-4`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3.5`,children:[(0,W.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-emerald-500/10 flex items-center justify-center shrink-0`,children:(0,W.jsx)(le,{className:`h-5 w-5 text-emerald-400`})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-[14px] font-medium text-white`,children:`Browser Speech Recognition`}),(0,W.jsx)(`div`,{className:`text-[12px] text-white/35 mt-0.5 leading-relaxed`,children:`Built-in voice input — no setup needed. Works in Chrome, Edge, and Safari.`})]}),(0,W.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-emerald-500/20 shrink-0`,children:(0,W.jsx)(ee,{className:`h-3.5 w-3.5 text-emerald-400`})})]})}),(0,W.jsx)(`button`,{onClick:()=>En(e=>!e),className:`w-full mt-3 rounded-xl border transition-all duration-200 p-4 text-left ${Tn?`bg-white/[0.04] border-[#AF27E3]/40`:`bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3.5`,children:[(0,W.jsx)(`img`,{src:`/icons/openai.svg`,alt:`OpenAI`,className:`w-10 h-10 rounded-xl bg-white/[0.04] p-1.5`}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-[14px] font-medium text-white`,children:`OpenAI Whisper`}),(0,W.jsx)(`div`,{className:`text-[12px] text-white/35 mt-0.5 leading-relaxed`,children:`Upgrade to more accurate transcription that works in all browsers including Firefox.`})]}),(0,W.jsx)(`div`,{className:`w-10 h-[22px] rounded-full transition-colors duration-200 flex items-center px-0.5 shrink-0 ${Tn?`bg-gradient-brand`:`bg-white/[0.08]`}`,children:(0,W.jsx)(`div`,{className:`w-[18px] h-[18px] rounded-full bg-white shadow-sm transition-transform duration-200 ${Tn?`translate-x-[18px]`:`translate-x-0`}`})})]})}),Tn&&(0,W.jsxs)(`div`,{className:`mt-3`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`OpenAI API Key`}),(0,W.jsx)(`input`,{type:`password`,value:Dn,onChange:e=>On(e.target.value.trim()),placeholder:`sk-...`,autoComplete:`off`,className:Hr+` font-mono text-[13px]`}),Dn.length>0&&!Dn.startsWith(`sk-`)&&(0,W.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`Key should start with sk-`}),Dn.length>0&&Dn.startsWith(`sk-`)&&Dn.length<20&&(0,W.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`Key looks too short`}),(0,W.jsxs)(`div`,{className:`flex items-start gap-2.5 mt-3 bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsx)(le,{className:`h-4 w-4 text-[#AF27E3]/60 mt-0.5 shrink-0`}),(0,W.jsx)(`p`,{className:`text-white/35 text-[12px] leading-relaxed`,children:`Whisper provides more accurate transcription and works in all browsers including Firefox.`})]})]}),(0,W.jsx)(`button`,{onClick:Vr,disabled:p||Tn&&(!Dn.startsWith(`sk-`)||Dn.length<20),className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:p?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}),`Setting up...`]}):(0,W.jsxs)(W.Fragment,{children:[`Complete Setup`,(0,W.jsx)(w,{className:`h-4 w-4`})]})}),!Tn&&(0,W.jsx)(`p`,{className:`text-center text-white/20 text-[11px] mt-2.5`,children:`Voice input is active using your browser's built-in speech recognition.`})]}),a===6&&t&&(()=>{let e=_t===`off`,t=e?window.location.origin:_t===`named`?`https://${yt}`:Ct===`relay`&&mt?mt:xt||`http://localhost:3000`,n=t.startsWith(`http`)?t:`https://${t}`;return(0,W.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,W.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center mb-5`,children:(0,W.jsx)(ee,{className:`h-8 w-8 text-emerald-400`})}),(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-white tracking-tight`,children:`All Set!`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-2 leading-relaxed max-w-[340px]`,children:e?`Your agent is running on your private network. Access it from any device on your local network or VPN.`:_t===`named`?`Access your agent at your custom domain.`:Ct===`relay`&&mt?`Your agent is live and ready. From now on, access it using your custom URL below.`:`Your agent is live and ready. Your tunnel URL is shown below. Note: this URL changes on restart.`}),(0,W.jsxs)(`div`,{className:`w-full mt-6 flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:t}),(0,W.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(n),ln(!0),setTimeout(()=>ln(!1),2e3)},className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:cn?(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}):(0,W.jsxs)(`svg`,{className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:[(0,W.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,W.jsx)(`path`,{d:`M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1`})]})})]}),(0,W.jsxs)(`div`,{className:`w-full mt-3`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block text-left`,children:`Your password`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:fn?N:`•`.repeat(Math.max(N.length,8))}),(0,W.jsx)(`button`,{onClick:()=>pn(e=>!e),className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:fn?(0,W.jsx)(ae,{className:`h-4 w-4`}):(0,W.jsx)(oe,{className:`h-4 w-4`})})]})]}),(0,W.jsxs)(`label`,{className:`flex items-start gap-2.5 mt-6 cursor-pointer text-left select-none`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:mn,onChange:e=>hn(e.target.checked),className:`mt-0.5 h-4 w-4 rounded border-white/20 bg-white/5 accent-emerald-500 shrink-0`}),(0,W.jsxs)(`span`,{className:`text-[12px] text-white/50 leading-relaxed`,children:[`I accept the`,` `,(0,W.jsx)(`a`,{href:`https://www.bloby.bot/terms`,target:`_blank`,rel:`noopener noreferrer`,className:`text-white/70 underline hover:text-white/90`,children:`terms`}),` `,`and`,` `,(0,W.jsx)(`a`,{href:`https://www.bloby.bot/privacy`,target:`_blank`,rel:`noopener noreferrer`,className:`text-white/70 underline hover:text-white/90`,children:`privacy policy`})]})]}),(0,W.jsxs)(`button`,{disabled:!mn,onClick:()=>{e?(window.top||window).location.href=`/`:(window.top||window).location.href=n},className:`w-full mt-4 py-3 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 ${mn?`bg-gradient-brand hover:opacity-90`:`bg-white/10 cursor-not-allowed opacity-50`}`,children:[e?`Go to dashboard`:`Go to your agent`,(0,W.jsx)(ie,{className:`h-4 w-4`})]}),(0,W.jsx)(`p`,{className:`text-white/20 text-[11px] mt-3 leading-relaxed`,children:e?`Access from any device on your network using the URL above.`:`You'll be redirected to your ${_t===`named`?`custom domain`:Ct===`relay`?`custom URL`:`tunnel URL`}.`})]})})()]},a)}),a>0&&a<i-1&&!(a===6&&t)&&(0,W.jsx)(`div`,{className:`px-8 pb-5 -mt-3`,children:(0,W.jsx)(`button`,{onClick:zr,className:`text-white/25 hover:text-white/50 text-[12px] transition-colors`,children:`← Back`})})]})]})}export{le as a,re as c,C as d,S as f,E as i,ee as l,Bu as n,ce as o,d as p,Xc as r,ie as s,qu as t,w as u};
17
+ `),()=>{s.current?.removeAttribute(`data-motion-pop-id`),v.contains(_)&&v.removeChild(_)}},[t]),(0,W.jsx)(Uc,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:v.cloneElement(e,{ref:u})})}var Gc=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=D(Kc),d=(0,v.useId)(),f=!0,p=(0,v.useMemo)(()=>(f=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>u.delete(e))}),[n,u,r]);return a&&f&&(p={...p}),(0,v.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),v.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,W.jsx)(Wc,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,W.jsx)(_e.Provider,{value:p,children:e})};function Kc(){return new Map}function qc(e=!0){let t=(0,v.useContext)(_e);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,v.useId)();(0,v.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,v.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Jc=e=>e.key||``;function Yc(e){let t=[];return v.Children.forEach(e,e=>{(0,v.isValidElement)(e)&&t.push(e)}),t}var Xc=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=qc(o),f=(0,v.useMemo)(()=>Yc(e),[e]),p=o&&!u?[]:f.map(Jc),m=(0,v.useRef)(!0),h=(0,v.useRef)(f),g=D(()=>new Map),_=(0,v.useRef)(new Set),[y,b]=(0,v.useState)(f),[x,S]=(0,v.useState)(f);ge(()=>{m.current=!1,h.current=f;for(let e=0;e<x.length;e++){let t=Jc(x[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[x,p.length,p.join(`-`)]);let C=[];if(f!==y){let e=[...f];for(let t=0;t<x.length;t++){let n=x[t],r=Jc(n);p.includes(r)||(e.splice(t,0,n),C.push(n))}return a===`wait`&&C.length&&(e=C),S(Yc(e)),b(f),null}let{forceRender:w}=(0,v.useContext)(he);return(0,W.jsx)(W.Fragment,{children:x.map(e=>{let v=Jc(e),y=o&&!u?!1:f===x||p.includes(v);return(0,W.jsx)(Gc,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(w?.(),S(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},Zc=(0,v.createContext)({strict:!1}),Qc={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`]},$c=!1;function el(){if($c)return;let e={};for(let t in Qc)e[t]={isEnabled:e=>Qc[t].some(t=>!!e[t])};oo(e),$c=!0}function tl(){return el(),so()}function nl(e){let t=tl();for(let n in e)t[n]={...t[n],...e[n]};oo(t)}var rl=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`.split(`.`));function il(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||rl.has(e)}var al=i({default:()=>ol}),ol,sl=e((()=>{throw ol={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),G=e=>!il(e);function cl(e){typeof e==`function`&&(G=t=>t.startsWith(`on`)?!il(t):e(t))}try{cl((sl(),o(al)).default)}catch{}function ll(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||F(e[i])||(G(i)||n===!0&&il(i)||!t&&!il(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var ul=(0,v.createContext)({});function dl(e,t){if(Za(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Ja(t)?t:void 0,animate:Ja(n)?n:void 0}}return e.inherit===!1?{}:t}function fl(e){let{initial:t,animate:n}=dl(e,(0,v.useContext)(ul));return(0,v.useMemo)(()=>({initial:t,animate:n}),[pl(t),pl(n)])}function pl(e){return Array.isArray(e)?e.join(` `):e}var ml=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function hl(e,t,n){for(let r in t)!F(t[r])&&!zo(r,n)&&(e[r]=t[r])}function gl({transformTemplate:e},t){return(0,v.useMemo)(()=>{let n=ml();return No(n,t,e),Object.assign({},n.vars,n.style)},[t])}function _l(e,t){let n=e.style||{},r={};return hl(r,n,e),Object.assign(r,gl(e,t)),r}function vl(e,t){let n={},r=_l(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}var yl=()=>({...ml(),attrs:{}});function bl(e,t,n,r){let i=(0,v.useMemo)(()=>{let n=yl();return qo(n,t,Yo(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};hl(t,e.style,e),i.style={...t,...i.style}}return i}var xl=[`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 Sl(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(xl.indexOf(e)>-1||/[A-Z]/u.test(e))}function Cl(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Sl(e)?bl:vl)(t,r,i,e),c=ll(t,typeof e==`string`,a),l=e===v.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,v.useMemo)(()=>F(u)?u.get():u,[u]);return(0,v.createElement)(e,{...l,children:d})}function wl({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Tl(n,r,i,e),renderState:t()}}function Tl(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=nc(a[e]);let{initial:o,animate:s}=e,c=Za(e),l=Qa(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!qa(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=gi(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var El=e=>(t,n)=>{let r=(0,v.useContext)(ul),i=(0,v.useContext)(_e),a=()=>wl(e,t,r,i);return n?a():D(a)},Dl=El({scrapeMotionValuesFromProps:Bo,createRenderState:ml}),Ol=El({scrapeMotionValuesFromProps:Zo,createRenderState:yl}),kl=Symbol.for(`motionComponentSymbol`);function Al(e,t,n){let r=(0,v.useRef)(n);(0,v.useInsertionEffect)(()=>{r.current=n});let i=(0,v.useRef)(null);return(0,v.useCallback)(n=>{n&&e.onMount?.(n);let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n);t&&(n?t.mount(n):t.unmount())},[t])}var jl=(0,v.createContext)({});function Ml(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Nl(e,t,n,r,i,a){let{visualElement:o}=(0,v.useContext)(ul),s=(0,v.useContext)(Zc),c=(0,v.useContext)(_e),l=(0,v.useContext)(zc),u=l.reducedMotion,d=l.skipAnimations,f=(0,v.useRef)(null),p=(0,v.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,v.useContext)(jl);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Pl(f.current,n,i,h);let g=(0,v.useRef)(!1);(0,v.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[ji],y=(0,v.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return ge(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),y.current&&m.animationState&&m.animationState.animateChanges())}),(0,v.useEffect)(()=>{m&&(!y.current&&m.animationState&&m.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function Pl(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:Fl(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Ml(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Fl(e){if(e)return e.options.allowProjection===!1?Fl(e.parent):e.projection}function Il(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&nl(r);let a=n?n===`svg`:Sl(e),o=a?Ol:Dl;function s(n,s){let c,l={...(0,v.useContext)(zc),...n,layoutId:Ll(n)},{isStatic:u}=l,d=fl(n),f=o(n,u);if(!u&&typeof window<`u`){Rl(l,r);let t=K(l);c=t.MeasureLayout,d.visualElement=Nl(e,f,l,i,t.ProjectionNode,a)}return(0,W.jsxs)(ul.Provider,{value:d,children:[c&&d.visualElement?(0,W.jsx)(c,{visualElement:d.visualElement,...l}):null,Cl(e,n,Al(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,v.forwardRef)(s);return c[kl]=e,c}function Ll({layoutId:e}){let t=(0,v.useContext)(he).id;return t&&e!==void 0?t+`-`+e:e}function Rl(e,t){(0,v.useContext)(Zc).strict}function K(e){let{drag:t,layout:n}=tl();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function q(e,t){if(typeof Proxy>`u`)return Il;let n=new Map,r=(n,r)=>Il(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Il(a,void 0,e,t)),n.get(a))})}var J=(e,t)=>t.isSVG??Sl(e)?new Qo(t):new Ho(t,{allowProjection:e!==v.Fragment}),Y=class extends uo{constructor(e){super(e),e.animationState||=as(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();qa(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},X=0,zl={animation:{Feature:Y},exit:{Feature:class extends uo{constructor(){super(...arguments),this.id=X++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`){let n=_i(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Bl(e){return{point:{x:e.pageX,y:e.pageY}}}var Vl=e=>t=>pa(t)&&e(t,Bl(t));function Hl(e,t,n,r){return Qs(e,t,Vl(n),r)}var Ul=({current:e})=>e?e.ownerDocument.defaultView:null,Wl=(e,t)=>Math.abs(e-t);function Gl(e,t){let n=Wl(e.x,t.x),r=Wl(e.y,t.y);return Math.sqrt(n**2+r**2)}var Kl=new Set([`auto`,`scroll`]),ql=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){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=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Jl(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Xl(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Gl(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=A;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Jl(t,this.transformPagePoint),k.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=Xl(e.type===`pointercancel`?this.lastMoveEventInfo:Jl(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!pa(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Jl(Bl(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=A;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Xl(s,this.history)),this.removeListeners=Oe(Hl(this.contextWindow,`pointermove`,this.handlePointerMove),Hl(this.contextWindow,`pointerup`,this.handlePointerUp),Hl(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Kl.has(e.overflowX)||Kl.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.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(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),k.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ot(this.updatePoint)}};function Jl(e,t){return t?{point:t(e.point)}:e}function Yl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Xl({point:e},t){return{point:e,delta:Yl(e,Ql(t)),offset:Yl(e,Zl(t)),velocity:$l(t,.1)}}function Zl(e){return e[0]}function Ql(e){return e[e.length-1]}function $l(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Ql(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>je(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>je(t)*2&&(r=e[1]);let a=Me(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function eu(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?N(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?N(n,e,r.max):Math.min(e,n)),e}function tu(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function nu(e,{top:t,left:n,bottom:r,right:i}){return{x:tu(e.x,n,i),y:tu(e.y,t,r)}}function ru(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 iu(e,t){return{x:ru(e.x,t.x),y:ru(e.y,t.y)}}function au(e,t){let n=.5,r=vs(e),i=vs(t);return i>r?n=ke(t.min,t.max-r,e.min):r>i&&(n=ke(e.min,e.max-i,t.min)),be(0,1,n)}function ou(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var su=.35;function cu(e=su){return e===!1?e=0:e===!0&&(e=su),{x:lu(e,`left`,`right`),y:lu(e,`top`,`bottom`)}}function lu(e,t,n){return{min:uu(e,t),max:uu(e,n)}}function uu(e,t){return typeof e==`number`?e:e[t]||0}var du=new WeakMap,fu=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=R(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(Bl(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ca(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Bs(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Nt.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=vs(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&k.update(()=>i(e,t),!1,!0),ki(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=gu(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&k.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new ql(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:Ul(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&k.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!hu(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=eu(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&Ml(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=nu(n.layoutBox,e):this.constraints=!1,this.elastic=cu(t),r!==this.constraints&&!Ml(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Bs(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=ou(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Ml(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=ko(n,r.root,this.visualElement.getTransformPagePoint()),a=iu(r.layout.layoutBox,i);if(t){let e=t(po(a));this.hasMutatedConstraints=!!e,e&&(a=fo(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=Bs(o=>{if(!hu(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return ki(this.visualElement,e),n.start(mi(e,n,0,t,this.visualElement,!1))}stopAnimation(){Bs(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){Bs(t=>{let{drag:n}=this.getProps();if(!hu(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-N(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Ml(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};Bs(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=au({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Bs(t=>{if(!hu(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(N(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;du.set(this.visualElement,this);let e=this.visualElement.current,t=Hl(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&_a(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Ml(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=mu(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),k.read(r);let o=Qs(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(Bs(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=su,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function pu(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function mu(e,t,n){let r=za(e,pu(n)),i=za(t,pu(n));return()=>{r(),i()}}function hu(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function gu(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var _u=class extends uo{constructor(e){super(e),this.removeGroupControls=Ee,this.removeListeners=Ee,this.controls=new fu(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ee}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},vu=e=>(t,n)=>{e&&k.update(()=>e(t,n),!1,!0)},yu=class extends uo{constructor(){super(...arguments),this.removePointerDownListener=Ee}onPointerDown(e){this.session=new ql(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ul(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:vu(e),onStart:vu(t),onMove:vu(n),onEnd:(e,t)=>{delete this.session,r&&k.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Hl(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},bu=!1,xu=class extends v.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),bu&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ic.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),bu=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||k.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),ia.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;bu=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Su(e){let[t,n]=qc(),r=(0,v.useContext)(he);return(0,W.jsx)(xu,{...e,layoutGroup:r,switchLayoutGroup:(0,v.useContext)(jl),isPresent:t,safeToRemove:n})}var Cu={pan:{Feature:yu},drag:{Feature:_u,ProjectionNode:U,MeasureLayout:Su}};function wu(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&k.postRender(()=>i(t,Bl(t)))}var Tu=class extends uo{mount(){let{current:e}=this.node;e&&(this.unmount=da(e,(e,t)=>(wu(this.node,t,`Start`),e=>wu(this.node,e,`End`))))}unmount(){}},Eu=class extends uo{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!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=Oe(Qs(this.node.current,`focus`,()=>this.onFocus()),Qs(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Du(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&k.postRender(()=>i(t,Bl(t)))}var Ou=class extends uo{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=wa(e,(e,t)=>(Du(this.node,t,`Start`),(e,{success:t})=>Du(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},ku=new WeakMap,Au=new WeakMap,ju=e=>{let t=ku.get(e.target);t&&t(e)},Mu=e=>{e.forEach(ju)};function Nu({root:e,...t}){let n=e||document;Au.has(n)||Au.set(n,{});let r=Au.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Mu,{root:e,...t})),r[i]}function Pu(e,t,n){let r=Nu(t);return ku.set(e,n),r.observe(e),()=>{ku.delete(e),r.unobserve(e)}}var Fu={some:0,all:1},Iu=class extends uo{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:Fu[r]};this.stopObserver=Pu(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Lu(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Lu({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Ru={inView:{Feature:Iu},tap:{Feature:Ou},focus:{Feature:Eu},hover:{Feature:Tu}},zu={layout:{ProjectionNode:U,MeasureLayout:Su}},Bu=q({...zl,...Ru,...Cu,...zu},J),Vu=r();function Hu(e){let t=e.match(/^100\.(\d+)\./);if(t&&+t[1]>=64&&+t[1]<=127)return`tailscale`;if(/^192\.168\./.test(e)||/^10\./.test(e))return`lan`;let n=e.match(/^172\.(\d+)\./);return n&&+n[1]>=16&&+n[1]<=31?`lan`:e===`localhost`||e===`127.0.0.1`?`localhost`:e.endsWith(`.trycloudflare.com`)?`tunnel`:e.endsWith(`.bloby.bot`)?`relay`:`custom-domain`}function Uu(e){return e===`tailscale`||e===`lan`||e===`localhost`}var Wu={tailscale:`Tailscale`,lan:`Local network`,localhost:`Localhost`,tunnel:`Cloudflare tunnel`,relay:`Relay`,"custom-domain":`Custom domain`},Z=30,Gu=[{id:`bloby`,name:`Bloby`,subtitle:`Coming Soon..`,icon:`/bloby.png`,comingSoon:!0,iconHeight:30},{id:`anthropic`,name:`Claude`,subtitle:`By
18
+ Anthropic`,icon:`/icons/claude.png`,comingSoon:!1,iconHeight:30},{id:`openai`,name:`Codex`,subtitle:`By
19
+ OpenAI`,icon:`/codex.svg`,comingSoon:!1,iconHeight:34},{id:`pi`,name:`Pi`,subtitle:`Bring your
20
+ own model`,icon:`/pi-logo.svg`,comingSoon:!1,iconHeight:33}],Ku={anthropic:[{id:`claude-opus-4-7[1m]`,label:`Opus 4.7 (1M context)`},{id:`claude-opus-4-7`,label:`Opus 4.7`},{id:`claude-sonnet-4-6`,label:`Sonnet 4.6 (1M context)`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`}],openai:[{id:`gpt-5.5:high`,label:`GPT-5.5 High`},{id:`gpt-5.5:medium`,label:`GPT-5.5 Medium`},{id:`gpt-5.5:xhigh`,label:`GPT-5.5 Extra High`},{id:`gpt-5.4:medium`,label:`GPT-5.4 Medium`},{id:`gpt-5.4:high`,label:`GPT-5.4 High`},{id:`gpt-5.4:xhigh`,label:`GPT-5.4 Extra High`},{id:`gpt-5.4-mini:medium`,label:`GPT-5.4-Mini Medium`},{id:`gpt-5.4-mini:high`,label:`GPT-5.4-Mini High`},{id:`gpt-5.4-mini:xhigh`,label:`GPT-5.4-Mini Extra High`}]};function qu({models:e,value:t,onChange:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!r)return;let e=()=>{let e=s.current?.getBoundingClientRect();e&&o({top:e.bottom+4,left:e.left,width:e.width})};e();let t=e=>{let t=e.target;s.current?.contains(t)||c.current?.contains(t)||i(!1)};return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[r]);let l=e.find(e=>e.id===t);return(0,W.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,W.jsxs)(`button`,{ref:s,type:`button`,onClick:()=>i(e=>!e),className:`w-full flex items-center justify-between gap-2 bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none hover:border-white/15 focus:border-[#AF27E3]/30 transition-colors overflow-hidden`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-left ${l?`text-white`:`text-white/20`}`,children:l?l.label:`Choose a model...`}),(0,W.jsx)(te,{className:`h-4 w-4 shrink-0 text-white/30 transition-transform ${r?`rotate-180`:``}`})]}),r&&a&&(0,Vu.createPortal)((0,W.jsx)(`div`,{ref:c,style:{position:`fixed`,top:a.top,left:a.left,width:a.width,zIndex:1e3},className:`bg-[#222] border border-white/[0.08] rounded-xl shadow-xl py-1 max-h-[320px] overflow-y-auto`,children:e.map(e=>(0,W.jsx)(`button`,{onClick:()=>{n(e.id),i(!1)},className:`w-full text-left px-4 py-2 text-[13px] transition-colors ${t===e.id?`text-[#AF27E3] bg-[#AF27E3]/10`:`text-white/70 hover:bg-white/[0.04] hover:text-white`}`,children:e.label},e.id))}),document.body)]})}function Ju({onComplete:e,isInitialSetup:t=!1,onSave:n,onTunnelSwitch:r}){let i=t?7:6,[a,o]=(0,v.useState)(0),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(`anthropic`),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)({anthropic:`idle`,openai:`idle`,pi:`idle`}),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(``),[S,te]=(0,v.useState)(``),[he,D]=(0,v.useState)(``),[ge,_e]=(0,v.useState)(``),[ve,ye]=(0,v.useState)(!1),[be,xe]=(0,v.useState)(!1),[Se,Ce]=(0,v.useState)(),[we,Te]=(0,v.useState)(null),[Ee,De]=(0,v.useState)(!1),[Oe,ke]=(0,v.useState)(``),[Ae,je]=(0,v.useState)(!1),[Me,Ne]=(0,v.useState)(),[Pe,Fe]=(0,v.useState)(!1),[Ie,Le]=(0,v.useState)(`device`),[Re,ze]=(0,v.useState)(`idle`),[Be,Ve]=(0,v.useState)(``),[He,Ue]=(0,v.useState)(``),[We,Ge]=(0,v.useState)(!1),[Ke,qe]=(0,v.useState)(!1),[Je,Ye]=(0,v.useState)(!1),[Xe,Ze]=(0,v.useState)(``),[Qe,$e]=(0,v.useState)(!1),[et,tt]=(0,v.useState)(),[nt,rt]=(0,v.useState)(!1),[O,it]=(0,v.useState)(``),[at,k]=(0,v.useState)(null),[ot,A]=(0,v.useState)(``),[st,ct]=(0,v.useState)({}),[lt,ut]=(0,v.useState)(``),[dt,ft]=(0,v.useState)(!1),[pt,j]=(0,v.useState)(!1),[mt,ht]=(0,v.useState)(``),gt=(0,v.useRef)(null),[_t,vt]=(0,v.useState)(`quick`),[yt,bt]=(0,v.useState)(``),[xt,St]=(0,v.useState)(``),[Ct,wt]=(0,v.useState)(`relay`),[Tt,Et]=(0,v.useState)(null),[Dt,Ot]=(0,v.useState)(!1),[kt,At]=(0,v.useState)(!1),[jt,Mt]=(0,v.useState)({}),[Nt,M]=(0,v.useState)(!1),[Pt,Ft]=(0,v.useState)(``),[It,Lt]=(0,v.useState)(``),[Rt,zt]=(0,v.useState)(!1),[Bt,Vt]=(0,v.useState)(`tunnel`),[Ht,Ut]=(0,v.useState)(!1),[Wt,Gt]=(0,v.useState)(``),[Kt,qt]=(0,v.useState)(!1),[Jt,Yt]=(0,v.useState)(``),[Xt,Zt]=(0,v.useState)(!1),[Qt,$t]=(0,v.useState)(!1),[en,tn]=(0,v.useState)(``),[nn,rn]=(0,v.useState)(`admin`),[N,an]=(0,v.useState)(``),[on,sn]=(0,v.useState)(``),[cn,ln]=(0,v.useState)(!1),[un,dn]=(0,v.useState)(!1),[fn,pn]=(0,v.useState)(!1),[mn,hn]=(0,v.useState)(!1),[gn,_n]=(0,v.useState)(``),[vn,yn]=(0,v.useState)(``),[bn,xn]=(0,v.useState)(!1),[Sn,Cn]=(0,v.useState)(!1),[P,wn]=(0,v.useState)(!1),[Tn,En]=(0,v.useState)(!1),[Dn,On]=(0,v.useState)(``),[kn,An]=(0,v.useState)(!1),[jn,Mn]=(0,v.useState)(``),[Nn,Pn]=(0,v.useState)(``),[Fn,In]=(0,v.useState)(``),[Ln,Rn]=(0,v.useState)(``),[zn,Bn]=(0,v.useState)(!1),[Vn,Hn]=(0,v.useState)(!1),[Un,Wn]=(0,v.useState)(``),[Gn,Kn]=(0,v.useState)([]),[qn,Jn]=(0,v.useState)(!1),[Yn,Xn]=(0,v.useState)(!1),[Zn,Qn]=(0,v.useState)(``),[$n,er]=(0,v.useState)(``),[tr,nr]=(0,v.useState)(!1),[rr,ir]=(0,v.useState)(`password`),[ar,or]=(0,v.useState)(!1),sr=(0,v.useRef)(!1),cr=h[l]===`connected`,lr=`bloby_totp_setup`;function ur(){try{sessionStorage.setItem(lr,JSON.stringify({secret:jn,qrUri:Nn,otpauthUri:Fn,phase:rr,portalPass:N,portalPassConfirm:on}))}catch{}}function dr(){try{let e=sessionStorage.getItem(lr);if(!e)return!1;let t=JSON.parse(e);if(t.secret&&t.phase===`totp-setup`)return Mn(t.secret),Pn(t.qrUri||``),In(t.otpauthUri||``),An(!0),ir(`totp-setup`),o(3),t.portalPass&&(an(t.portalPass),sn(t.portalPassConfirm||``)),!0}catch{}return!1}function fr(){try{sessionStorage.removeItem(lr)}catch{}}(0,v.useEffect)(()=>{fetch(`/api/onboard/status`).then(e=>e.json()).then(e=>{e.userName&&c(e.userName),e.handle&&(it(e.handle.username),ut(e.handle.tier||`at`),Et({username:e.handle.username,tier:e.handle.tier,url:e.handle.url}),j(!0),ht(e.handle.url)),e.portalUser&&rn(e.portalUser),e.portalConfigured&&dn(!0),e.provider&&u(e.provider),e.model&&f(e.model),e.whisperEnabled&&(En(!0),On(e.whisperKey||``)),e.totpEnabled&&(An(!0),Bn(!0)),e.tunnelMode&&vt(e.tunnelMode),e.tunnelDomain&&bt(e.tunnelDomain),e.tunnelUrl&&St(e.tunnelUrl),e.handle||wt(`tunnel`),sr.current=!0,e.totpEnabled||dr()}).catch(()=>{sr.current=!0})},[]),(0,v.useEffect)(()=>{Vt(Hu(window.location.hostname))},[]),(0,v.useEffect)(()=>{nr(window.matchMedia(`(max-width: 768px)`).matches||`ontouchstart`in window)},[]),(0,v.useEffect)(()=>{l!==`anthropic`||h.anthropic===`connected`||fetch(`/api/auth/claude/status`).then(e=>e.json()).then(e=>{e.authenticated&&g(e=>({...e,anthropic:`connected`}))}).catch(()=>{})},[l]),(0,v.useEffect)(()=>{l!==`openai`||h.openai===`connected`||fetch(`/api/auth/codex/status`).then(e=>e.json()).then(e=>{e.authenticated&&g(e=>({...e,openai:`connected`}))}).catch(()=>{})},[l]),(0,v.useEffect)(()=>{if(gt.current&&clearTimeout(gt.current),!sr.current||_t===`off`||Tt&&pt&&O===Tt.username)return;k(null),A(``),ct({}),Mt({}),M(!1),Ft(``),Lt(``),j(!1),ht(``);let e=O.trim();if(e){if(e.length<3){k(`invalid`),A(`At least 3 characters`);return}return k(`checking`),gt.current=setTimeout(async()=>{try{let t=await(await fetch(`/api/handle/check/${encodeURIComponent(e)}`)).json();if(!t.valid)k(`invalid`),A(t.error);else{let e={},n={};for(let r of t.handles)e[r.tier]=r.available,r.reserved&&(n[r.tier]=!0);ct(e),Mt(n),k(`ready`),ut(``)}}catch{k(null)}},400),()=>{gt.current&&clearTimeout(gt.current)}}},[O]),(0,v.useEffect)(()=>{if(!O||O.length<3||at!==`ready`)return;let e=async()=>{try{let e=await(await fetch(`/api/handle/check/${encodeURIComponent(O.trim())}`)).json();if(e.valid){let t={},n={};for(let r of e.handles)t[r.tier]=r.available,r.reserved&&(n[r.tier]=!0);ct(t),Mt(n)}}catch{}};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[O,at]);let pr=e=>{it(e.toLowerCase().replace(/[^a-z0-9-]/g,``))},mr=async()=>{if(!(!O||at!==`ready`||!st[lt])){ft(!0);try{let e=await(await fetch(`/api/handle/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:O,tier:lt})})).json();e.ok?(j(!0),ht(e.url)):(A(e.error||`Registration failed`),k(`invalid`))}catch{A(`Could not reach server`),k(`invalid`)}finally{ft(!1)}}},hr=async()=>{if(!(!O||at!==`ready`||!st[lt])){At(!0);try{let e=await(await fetch(`/api/handle/change`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:O,tier:lt})})).json();e.ok?(j(!0),ht(e.url),Et({username:O,tier:lt,url:e.url}),Ot(!1)):(A(e.error||`Handle change failed`),k(`invalid`))}catch{A(`Could not reach server`),k(`invalid`)}finally{At(!1)}}},gr=async()=>{if(!(!O||!Pt)){zt(!0),Lt(``);try{let e=await(await fetch(`/api/handle/claim-reserved`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({handle:O,hash:Pt})})).json();e.ok?(j(!0),ht(e.url),M(!1),Ft(``),ut(`premium`),wt(`relay`)):Lt(e.error||`Invalid activation code`)}catch{Lt(`Could not reach server`)}finally{zt(!1)}}},_r=e=>{l===`openai`&&e!==`openai`&&(Je&&fetch(`/api/auth/codex/cancel`,{method:`POST`}),Re===`pending`&&fetch(`/api/auth/codex/device/cancel`,{method:`POST`})),u(e),f(e===`openai`?`gpt-5.5:high`:``),De(!1),ke(``),Ne(void 0),Ye(!1),Ze(``),ze(`idle`),Ve(``),Ue(``),Le(`device`),tt(void 0),Ce(void 0)};(0,v.useEffect)(()=>{if(l!==`pi`)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([fetch(`/api/auth/pi/providers`),fetch(`/api/auth/pi/status`)]),r=await t.json(),i=await n.json();if(e)return;let a=r?.providers||[];y(a),i?.configured?(x(i.subProvider||``),_e(i.modelId||``),D(i.baseUrl||``),g(e=>({...e,pi:`connected`})),Te({subProvider:i.subProvider,modelId:i.modelId,baseUrl:i.baseUrl}),f(`${i.subProvider}/${i.modelId||``}`)):!b&&a[0]&&(x(a[0].id),D(a[0].baseUrl||``),_e(a[0].defaultModel||``))}catch(t){e||Ce(t?.message||`Failed to load Bloby providers`)}})(),()=>{e=!0}},[l]);let vr=_.find(e=>e.id===b),yr=e=>{let t=_.find(t=>t.id===e);x(e),D(t?.baseUrl||``),_e(t?.defaultModel||``),Ce(void 0),h.pi===`connected`&&(g(e=>({...e,pi:`idle`})),Te(null))},br=async()=>{if(b){Ce(void 0),xe(!0);try{let e={subProvider:b,apiKey:S.trim()||void 0,baseUrl:he.trim()||void 0,modelId:ge.trim()||void 0},t=await(await fetch(`/api/auth/pi/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();if(!t?.ok){Ce(t?.error||`Connection test failed`);return}let n=await(await fetch(`/api/auth/pi/save`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();if(!n?.ok){Ce(n?.error||`Failed to save credentials`);return}g(e=>({...e,pi:`connected`})),Te(n.status||null),f(`${b}/${ge||vr?.defaultModel||``}`),te(``)}catch(e){Ce(e?.message||`Connection failed`)}finally{xe(!1)}}},xr=async()=>{try{await fetch(`/api/auth/pi`,{method:`DELETE`})}catch{}g(e=>({...e,pi:`idle`})),Te(null),f(``)},Sr=e=>{if(window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}else window.open(e,`_blank`,`noopener,noreferrer`)},Cr=async()=>{Ne(void 0);try{let e=await(await fetch(`/api/auth/claude/start`,{method:`POST`})).json();e.success&&e.authUrl?(Sr(e.authUrl),De(!0)):Ne(e.error||`Failed to start authentication`)}catch(e){Ne(e.message)}},wr=async()=>{if(Oe.trim()){je(!0),Ne(void 0);try{let e=await(await fetch(`/api/auth/claude/exchange`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:Oe.trim()})})).json();e.success?g(e=>({...e,anthropic:`connected`})):Ne(e.error||`Code exchange failed`)}catch(e){Ne(e.message)}finally{je(!1)}}},Tr=async()=>{try{let e=await navigator.clipboard.readText();e&&ke(e.trim())}catch{}},Er=async()=>{Fe(!0),Ne(void 0);try{(await(await fetch(`/api/auth/claude/status`)).json()).authenticated?g(e=>({...e,anthropic:`connected`})):Ne(`No active session found. Please authenticate first.`)}catch{}finally{Fe(!1)}},Dr=async()=>{tt(void 0),Ge(!0),ze(`pending`);try{let e=await(await fetch(`/api/auth/codex/device/start`,{method:`POST`})).json();e.success?(Ve(e.userCode||``),Ue(e.verificationUrl||``),e.verificationUrl&&Sr(e.verificationUrl)):(ze(`error`),tt(e.error||`Failed to start device-code login`))}catch(e){ze(`error`),tt(e.message)}finally{Ge(!1)}},Or=async()=>{try{await fetch(`/api/auth/codex/device/cancel`,{method:`POST`})}catch{}ze(`idle`),Ve(``),Ue(``)},kr=async()=>{try{await navigator.clipboard.writeText(Be),qe(!0),setTimeout(()=>qe(!1),1500)}catch{}};(0,v.useEffect)(()=>{if(Re!==`pending`||!Be)return;let e=setInterval(async()=>{try{let e=await(await fetch(`/api/auth/codex/device/status`)).json();e.state===`success`?(ze(`success`),g(e=>({...e,openai:`connected`}))):e.state===`error`&&(ze(`error`),tt(e.error||`Device-code login failed`))}catch{}},2e3);return()=>clearInterval(e)},[Re,Be]);let Ar=async()=>{tt(void 0);try{let e=await(await fetch(`/api/auth/codex/start`,{method:`POST`})).json();e.success&&e.authUrl?(Sr(e.authUrl),Ye(!0)):tt(e.error||`Failed to start authentication`)}catch(e){tt(e.message)}},jr=async()=>{if(Xe.trim()){$e(!0),tt(void 0);try{let e=await(await fetch(`/api/auth/codex/exchange`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:Xe.trim()})})).json();e.success?(g(e=>({...e,openai:`connected`})),Ze(``)):tt(e.error||`Code exchange failed`)}catch(e){tt(e.message)}finally{$e(!1)}}},Mr=async()=>{try{let e=await navigator.clipboard.readText();e&&Ze(e.trim())}catch{}},Nr=async()=>{rt(!0),tt(void 0);try{(await(await fetch(`/api/auth/codex/status`)).json()).authenticated?g(e=>({...e,openai:`connected`})):tt(`No active session found. Please authenticate first.`)}catch{}finally{rt(!1)}},Pr=N===on,Fr=N.length>=6&&Pr,Ir=un?N.length===0||bn&&Fr:Fr,Lr=(()=>{switch(a){case 0:return!0;case 1:return s.trim().length>0;case 2:return Ht||Xt?!1:_t===`off`||_t===`named`||Ct===`tunnel`?O.trim().length>=3:pt;case 3:return!(rr!==`password`||!Ir||kn&&!zn);case 4:return!!(l&&d&&cr);case 5:return!0;default:return!1}})(),Rr=()=>{Lr&&a<i-1&&o(e=>e+1)},zr=()=>{a>0&&o(e=>e-1)},Br=e=>{e.key===`Enter`&&Lr&&Rr()},Vr=async()=>{m(!0);let r={userName:s.trim(),agentName:O.trim()||`Bloby`,provider:l,model:d,apiKey:``,whisperEnabled:Tn,whisperKey:Tn?Dn:``,portalUser:nn.trim(),portalPass:N};try{n?await n(r):await fetch(`/api/onboard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),t?(m(!1),o(6)):e()}catch(e){console.error(`[OnboardWizard] Onboard failed:`,e),m(!1)}},Hr=`w-full bg-white/[0.05] border border-white/[0.08] text-white rounded-xl px-4 py-3 text-base outline-none input-glow placeholder:text-white/20 transition-all`,Ur=`w-full bg-white/[0.03] border border-white/[0.08] text-white rounded-xl px-4 py-2.5 text-[13px] outline-none input-glow placeholder:text-white/20 transition-all`;return(0,W.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 bg-black/85 backdrop-blur-md`}),(0,W.jsxs)(Bu.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.3},className:`relative w-full max-w-[480px] bg-[#181818] border border-white/[0.06] rounded-[24px] shadow-2xl overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`flex justify-center gap-2 pt-6`,children:Array.from({length:i},(e,t)=>(0,W.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300 ${t===a?`w-7 bg-gradient-brand`:t<a?`w-1.5 bg-gradient-brand opacity-60`:`w-1.5 bg-white/10`}`},t))}),(0,W.jsx)(Xc,{mode:`wait`,children:(0,W.jsxs)(Bu.div,{initial:{opacity:0,x:30},animate:{opacity:1,x:0},exit:{opacity:0,x:-30},transition:{duration:.2,ease:`easeOut`},className:`px-8 pt-6 pb-8`,children:[a===0&&(0,W.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,W.jsxs)(`video`,{autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`h-[180px] mb-4`,children:[(0,W.jsx)(`source`,{src:`/bloby_say_hi.mov`,type:`video/mp4; codecs="hvc1"`}),(0,W.jsx)(`source`,{src:`/bloby_say_hi.webm`,type:`video/webm`})]}),(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-white tracking-tight`,children:`Welcome to Bloby`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[14px] mt-2 leading-relaxed max-w-[320px]`,children:`Let's set up your AI assistant in just a few steps.`}),(0,W.jsxs)(`button`,{onClick:Rr,className:`mt-6 px-7 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center gap-2`,children:[`Get Started`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]}),a===1&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`What's your name?`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is how your agent will address you.`}),(0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[(0,W.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:Br,placeholder:`Enter your name`,autoFocus:!0,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,className:Hr+` flex-1`}),(0,W.jsx)(`button`,{onClick:Rr,disabled:!Lr,className:`shrink-0 h-12 w-12 flex items-center justify-center rounded-full bg-gradient-brand hover:opacity-90 text-white transition-colors disabled:opacity-30`,children:(0,W.jsx)(w,{className:`h-5 w-5`})})]})]}),a===2&&_t===`off`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Bot Name & Access`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Give your bot a name. This is used throughout the app as your bot's identity.`}),(0,W.jsx)(`div`,{className:`relative mt-5`,children:(0,W.jsx)(`input`,{type:`text`,value:O,onChange:e=>pr(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,className:Hr+` pr-10 font-mono`})}),(0,W.jsx)(`div`,{className:`mt-4 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:(0,W.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:`Private network mode — your bot is only accessible via your local network or VPN. No public URL will be created.`})}),!t&&(0,W.jsx)(`div`,{className:`mt-3 flex items-center gap-2`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border ${Uu(Bt)?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-blue-500/10 text-blue-400 border-blue-500/20`}`,children:[Uu(Bt)?(0,W.jsx)(pe,{className:`h-3 w-3`}):(0,W.jsx)(se,{className:`h-3 w-3`}),`Accessing via `,Wu[Bt]]})}),!t&&!Xt&&(0,W.jsxs)(`button`,{onClick:()=>{Zt(!0),tn(``)},className:`w-full mt-4 flex items-center justify-between px-4 py-3 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:border-white/10 hover:bg-white/[0.04] transition-all text-left`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-[13px] text-white/70 font-medium`,children:`Re-enable public tunnel access`}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:`Start a Cloudflare tunnel to make your bot accessible from anywhere`})]}),(0,W.jsx)(se,{className:`h-4 w-4 text-white/30 shrink-0 ml-3`})]}),Xt&&(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(`div`,{className:`bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(fe,{className:`h-4 w-4 text-amber-400 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Enable public access?`}),(0,W.jsxs)(`p`,{className:`text-amber-400/60 text-[12px] mt-1 leading-relaxed`,children:[`This will start a Cloudflare tunnel, making your bot reachable from the internet.`,Tt&&` Your handle will reconnect automatically.`]})]})]})}),en&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[12px]`,children:en}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{onClick:async()=>{if(r){$t(!0),tn(``);try{await r(`quick`),vt(`quick`),Zt(!1)}catch(e){tn(e.message||`Failed to start tunnel`)}finally{$t(!1)}}},disabled:Qt||!r,className:`flex-1 py-2.5 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Qt?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}),`Starting tunnel...`]}):`Enable Tunnel`}),(0,W.jsx)(`button`,{onClick:()=>{Zt(!1),tn(``)},disabled:Qt,className:`px-5 py-2.5 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Cancel`})]})]}),(0,W.jsxs)(`button`,{onClick:Rr,disabled:!Lr,className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]}),a===2&&_t===`named`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Bot Name & Access`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is your bot's identity. Your named tunnel domain is already configured.`}),(0,W.jsx)(`div`,{className:`relative mt-5`,children:(0,W.jsx)(`input`,{type:`text`,value:O,onChange:e=>pr(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,className:Hr+` pr-10 font-mono`})}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsxs)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:[`https://`,yt]}),(0,W.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(`https://${yt}`),ln(!0),setTimeout(()=>ln(!1),2e3)},className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:cn?(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}):(0,W.jsx)(ne,{className:`h-4 w-4`})})]})]}),a===2&&_t===`quick`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Bot Name & Access`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`This is your bot's name and permanent handle — access it from anywhere.`}),Tt&&pt&&!Dt&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}),(0,W.jsx)(`p`,{className:`text-emerald-400/90 text-[13px] font-medium`,children:`Current handle`})]}),(0,W.jsx)(`p`,{className:`text-emerald-400/60 text-[12px] mt-1 font-mono`,children:mt})]}),(0,W.jsxs)(`div`,{className:`flex gap-2 mt-4`,children:[(0,W.jsxs)(`button`,{onClick:Rr,className:`flex-1 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]}),(0,W.jsx)(`button`,{onClick:()=>{Ot(!0),j(!1),it(``),k(null),ct({}),wt(`relay`)},className:`px-5 py-3 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Change`})]})]}),Dt&&!pt&&(0,W.jsxs)(`div`,{className:`mt-4 bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Changing your handle`}),(0,W.jsxs)(`p`,{className:`text-amber-400/60 text-[12px] mt-1`,children:[`Your current handle `,(0,W.jsx)(`span`,{className:`font-mono`,children:Tt?.url}),` will be released and become available for others.`]})]}),(!Tt||Dt||!pt)&&!(Tt&&pt&&!Dt)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`relative mt-5`,children:[(0,W.jsx)(`input`,{type:`text`,value:O,onChange:e=>pr(e.target.value),maxLength:30,placeholder:`your-bot-name`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,autoFocus:!0,disabled:pt,className:Hr+` pr-10 font-mono`+(pt?` opacity-50`:``)}),at&&O.length>0&&!pt&&(0,W.jsxs)(`div`,{className:`absolute right-4 top-1/2 -translate-y-1/2`,children:[at===`checking`&&(0,W.jsx)(`div`,{className:`w-5 h-5 border-2 border-white/10 border-t-[#04D1FE] rounded-full animate-spin`}),at===`invalid`&&(0,W.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-amber-500/15 flex items-center justify-center`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5 text-amber-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:(0,W.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3m0 4h.01`})})})]})]}),at===`invalid`&&ot&&(0,W.jsx)(`p`,{className:`text-amber-400 text-[12px] mt-2`,children:ot}),at===`ready`&&O.length>0&&!pt&&(0,W.jsxs)(`div`,{className:`space-y-3 mt-4`,children:[(()=>{let e=st.at===!1,t=Ct===`relay`&&lt===`at`;return(0,W.jsxs)(`button`,{onClick:()=>{e||(ut(`at`),wt(`relay`))},disabled:e,className:`w-full rounded-xl border transition-all duration-200 text-left px-4 py-3 ${e?`border-white/[0.04] opacity-50 cursor-not-allowed`:t?`border-[#AF27E3]/30 bg-white/[0.04]`:`border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`Free`}),(0,W.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border ${e?`bg-red-500/10 text-red-400 border-red-500/20`:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`}`,children:e?`Taken`:`Available`})]}),(0,W.jsxs)(`p`,{className:`font-mono text-[13px] mt-1.5 ${t?`text-white/80`:`text-white/40`}`,children:[`open.bloby.bot/`,O]})]})})(),(()=>{let e=st.premium,t=e===!1,n=t&&jt.premium;return(0,W.jsxs)(`div`,{className:`rounded-xl border transition-all duration-200 text-left px-4 py-3 ${n?`border-[#AF27E3]/20`:`border-white/[0.06]`}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`Premium`}),(0,W.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border bg-[#AF27E3]/15 text-[#AF27E3] border-[#AF27E3]/20`,children:`$5`})]}),(0,W.jsx)(`span`,{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border ${n?`bg-[#AF27E3]/10 text-[#AF27E3] border-[#AF27E3]/20`:t?`bg-red-500/10 text-red-400 border-red-500/20`:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`}`,children:n?`Reserved`:t?`Taken`:`Available`})]}),(0,W.jsxs)(`p`,{className:`font-mono text-[13px] mt-1.5 text-white/40`,children:[`bloby.bot/`,O]}),e&&(0,W.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-white/[0.06] flex items-center justify-between`,children:[(0,W.jsx)(`p`,{className:`text-[12px] text-white/40`,children:`Purchase on bloby.bot`}),(0,W.jsx)(`a`,{href:`https://www.bloby.bot/#reserve`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[12px] font-medium text-[#AF27E3] hover:text-[#c44df7] transition-colors`,children:`Purchase`})]}),n&&(0,W.jsx)(`div`,{className:`mt-3 pt-3 border-t border-[#AF27E3]/10`,children:Nt?(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,W.jsxs)(`p`,{className:`text-[12px] text-white/40`,children:[`Enter the 5-character code from your `,(0,W.jsx)(`span`,{className:`text-white/60 font-medium`,children:`bloby.bot`}),` account`]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,value:Pt,onChange:e=>Ft(e.target.value.trim()),maxLength:5,placeholder:`e.g. a3Kx9`,spellCheck:!1,autoComplete:`off`,autoFocus:!0,className:`flex-1 bg-white/[0.05] border border-white/[0.08] text-white rounded-lg px-3 py-2 text-[13px] font-mono outline-none focus:border-[#AF27E3]/30 transition-colors placeholder:text-white/20 tracking-widest text-center`}),(0,W.jsx)(`button`,{onClick:gr,disabled:Rt||Pt.length<5,className:`px-4 py-2 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-semibold rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-40`,children:Rt?(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}):`Activate`})]}),It&&(0,W.jsx)(`p`,{className:`text-red-400 text-[12px]`,children:It}),(0,W.jsx)(`button`,{onClick:()=>{M(!1),Ft(``),Lt(``)},className:`text-[11px] text-white/25 hover:text-white/40 transition-colors`,children:`Cancel`})]}):(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`p`,{className:`text-[12px] text-white/40`,children:`Is that yours?`}),(0,W.jsx)(`button`,{onClick:()=>{M(!0),Ft(``),Lt(``)},className:`text-[12px] font-medium text-[#AF27E3] hover:text-[#c44df7] transition-colors`,children:`Activate`})]})})]})})(),(0,W.jsxs)(`button`,{onClick:()=>{wt(`tunnel`),ut(`skip`)},className:`w-full rounded-xl border transition-all duration-200 text-left px-4 py-3 ${lt===`skip`?`border-[#AF27E3]/30 bg-white/[0.04]`:`border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,W.jsx)(`span`,{className:`text-[12px] font-semibold text-white/60 uppercase tracking-wider`,children:`No handle`}),(0,W.jsx)(`p`,{className:`text-[13px] mt-1.5 ${lt===`skip`?`text-white/60`:`text-white/30`}`,children:`I'll use the random tunnel URL`})]})]}),pt&&(0,W.jsxs)(`div`,{className:`mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}),(0,W.jsx)(`p`,{className:`text-emerald-400/90 text-[13px] font-medium`,children:`Handle claimed!`})]}),(0,W.jsx)(`p`,{className:`text-emerald-400/60 text-[12px] mt-1 font-mono`,children:mt})]}),at===`ready`&&O.length>0&&!pt&&(0,W.jsx)(`button`,{onClick:lt===`skip`?Rr:Ct===`relay`&&lt===`at`?Dt?hr:mr:void 0,disabled:!lt||dt||kt||lt===`at`&&!st.at,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:dt||kt?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}),Dt?`Changing...`:`Claiming...`]}):lt?lt===`skip`?(0,W.jsxs)(W.Fragment,{children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]}):(0,W.jsxs)(W.Fragment,{children:[Dt?`Change Handle`:`Claim & Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]}):(0,W.jsx)(W.Fragment,{children:`Select an option to continue`})}),pt&&(0,W.jsxs)(`button`,{onClick:Rr,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]}),Dt&&!pt&&(0,W.jsx)(`button`,{onClick:()=>{Ot(!1),it(Tt.username),j(!0),ht(Tt.url),ut(Tt.tier),wt(`relay`),k(null)},className:`w-full mt-2 py-2 text-white/25 hover:text-white/40 text-[12px] transition-colors`,children:`Cancel — keep current handle`})]}),!t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mt-5 flex items-center gap-2`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border ${Uu(Bt)?`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`:`bg-blue-500/10 text-blue-400 border-blue-500/20`}`,children:[Uu(Bt)?(0,W.jsx)(me,{className:`h-3 w-3`}):(0,W.jsx)(se,{className:`h-3 w-3`}),`Accessing via `,Wu[Bt]]})}),!Ht&&(0,W.jsxs)(`button`,{onClick:()=>{Uu(Bt)&&(Ut(!0),Gt(``),Yt(``))},disabled:!Uu(Bt),className:`w-full mt-3 flex items-center justify-between px-4 py-3 rounded-xl border transition-all text-left ${Uu(Bt)?`border-white/[0.06] bg-white/[0.02] hover:border-white/10 hover:bg-white/[0.04] cursor-pointer`:`border-white/[0.04] bg-transparent opacity-50 cursor-not-allowed`}`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-[13px] text-white/70 font-medium`,children:`Switch to private network only`}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:Uu(Bt)?`Stop the tunnel and relay — access only via Tailscale or LAN`:`Connect via Tailscale or private network to unlock`})]}),(0,W.jsx)(pe,{className:`h-4 w-4 text-white/30 shrink-0 ml-3`})]}),Ht&&(0,W.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,W.jsx)(`div`,{className:`bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(fe,{className:`h-4 w-4 text-amber-400 shrink-0 mt-0.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-amber-400/90 text-[13px] font-medium`,children:`Switch to private network only?`}),(0,W.jsx)(`p`,{className:`text-amber-400/60 text-[12px] mt-1 leading-relaxed`,children:`This will stop the Cloudflare tunnel and relay connection. Your bot will only be accessible via your private network.`}),Tt&&(0,W.jsx)(`p`,{className:`text-amber-400/50 text-[12px] mt-1.5`,children:`Your handle will be preserved and can be re-activated later.`})]})]})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:[`Type `,(0,W.jsx)(`span`,{className:`font-mono text-white/60`,children:`I confirm`}),` to proceed`]}),(0,W.jsx)(`input`,{type:`text`,value:Wt,onChange:e=>Gt(e.target.value),placeholder:`I confirm`,spellCheck:!1,autoFocus:!0,className:Ur})]}),Jt&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[12px]`,children:Jt}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{onClick:async()=>{if(!(!r||Wt.trim().toLowerCase()!==`i confirm`)){qt(!0),Yt(``);try{await r(`off`),vt(`off`),Ut(!1)}catch(e){Yt(e.message||`Failed to switch`)}finally{qt(!1)}}},disabled:Kt||Wt.trim().toLowerCase()!==`i confirm`||!r,className:`flex-1 py-2.5 bg-amber-600 hover:bg-amber-500 text-white text-[13px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Kt?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}),`Switching...`]}):`Confirm Switch`}),(0,W.jsx)(`button`,{onClick:()=>{Ut(!1),Gt(``),Yt(``)},disabled:Kt,className:`px-5 py-2.5 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.08] text-white/60 text-[13px] font-medium rounded-full transition-colors`,children:`Cancel`})]})]})]})]}),a===3&&(0,W.jsx)(`div`,{children:(0,W.jsxs)(Xc,{mode:`wait`,children:[rr===`password`&&(0,W.jsxs)(Bu.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.15},children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:un?`Password & 2FA`:`Set a password`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:un?`Your portal password is already set — you can keep it as-is or change it below.`:`You'll need this password to access your agent's chat. Keep it safe — anyone with your URL will need it to log in.`}),un&&!P&&(0,W.jsxs)(`div`,{className:`mt-5 flex items-center justify-between bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-white/70 text-[13px] font-medium`,children:`Bloby Chat Password`}),(0,W.jsx)(`p`,{className:`text-white/30 text-[11px] mt-0.5`,children:`Already configured.`})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{wn(!0),_n(``),yn(``),xn(!1),an(``),sn(``)},className:`shrink-0 px-3.5 py-2 bg-white/[0.04] hover:bg-white/[0.08] text-white/70 hover:text-white text-[12px] font-medium rounded-lg transition-colors`,children:`Change password`})]}),un&&P&&(0,W.jsxs)(`div`,{className:`mt-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium`,children:`Current password`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{wn(!1),_n(``),yn(``),xn(!1),an(``),sn(``)},className:`text-white/30 hover:text-white/60 text-[11px] transition-colors`,children:`Cancel`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`password`,value:gn,onChange:e=>{_n(e.target.value),yn(``),xn(!1)},placeholder:`Enter your current password`,autoComplete:`current-password`,className:Hr+` flex-1`}),gn.length>0&&!bn&&(0,W.jsx)(`button`,{onClick:async()=>{Cn(!0),yn(``);try{(await(await fetch(`/api/portal/verify-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:gn})})).json()).valid?xn(!0):yn(`Incorrect password`)}catch{yn(`Could not verify`)}finally{Cn(!1)}},disabled:Sn,className:`shrink-0 px-4 py-3 bg-white/[0.06] hover:bg-white/[0.1] text-white/60 text-[13px] font-medium rounded-xl transition-colors disabled:opacity-40`,children:Sn?(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}):`Verify`}),bn&&(0,W.jsx)(`div`,{className:`shrink-0 w-10 h-10 flex items-center justify-center`,children:(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`})})]}),vn&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:vn})]}),(!un||P&&bn)&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:un?`mt-3`:`mt-5`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:un?`New password`:`Password`}),(0,W.jsx)(`input`,{type:`password`,value:N,onChange:e=>an(e.target.value),placeholder:`••••••••`,autoComplete:`new-password`,autoFocus:!un,onKeyDown:Br,className:Hr}),N.length>0&&N.length<6&&(0,W.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`At least 6 characters`})]}),(0,W.jsxs)(`div`,{className:`mt-3`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:un?`Confirm new password`:`Confirm password`}),(0,W.jsx)(`input`,{type:`password`,value:on,onChange:e=>sn(e.target.value),placeholder:`••••••••`,autoComplete:`new-password`,onKeyDown:Br,className:Hr}),on.length>0&&!Pr&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:`Passwords don't match`})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 border border-white/[0.06] rounded-xl overflow-hidden`,children:[(0,W.jsxs)(`button`,{onClick:async()=>{if(kn&&zn){Xn(!0);return}if(kn)An(!1),Pn(``),Mn(``),In(``);else{if(An(!0),Wn(``),Rn(``),un&&!bn){wn(!0),Wn(`Enter your current portal password above first, then toggle 2FA again.`),An(!1);return}if(Nn)ir(`totp-setup`);else try{let e=await fetch(`/api/portal/totp/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:un?gn:N})}),t=await e.json();e.ok?(Mn(t.secret),Pn(t.qrDataUri),In(t.otpauthUri),ir(`totp-setup`)):(Wn(t.error||`Setup failed`),An(!1))}catch{Wn(`Could not reach server`),An(!1)}}},type:`button`,className:`w-full flex items-center gap-3 px-4 py-3 text-left`,children:[(0,W.jsx)(`div`,{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${kn&&zn?`bg-emerald-500/10`:`bg-white/[0.04]`}`,children:kn&&zn?(0,W.jsx)(T,{className:`h-[18px] w-[18px] text-emerald-400`}):(0,W.jsx)(E,{className:`h-[18px] w-[18px] text-white/30`})}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(`span`,{className:`text-[13px] font-medium text-white block`,children:`Two-Factor Auth`}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/30 mt-0.5`,children:kn&&zn?(0,W.jsx)(`span`,{className:`text-emerald-400/70`,children:`Active — authenticator app required`}):_t===`quick`||_t===`named`?(0,W.jsx)(`span`,{children:`Recommended for public bots`}):(0,W.jsx)(`span`,{children:`Extra security with an authenticator app`})})]}),(0,W.jsx)(`div`,{className:`w-10 h-6 rounded-full transition-colors relative shrink-0 ${kn?`bg-emerald-500`:`bg-white/10`}`,children:(0,W.jsx)(`div`,{className:`absolute top-1 w-4 h-4 rounded-full bg-white shadow transition-transform ${kn?`translate-x-5`:`translate-x-1`}`})})]}),Yn&&(0,W.jsxs)(`div`,{className:`px-4 pb-3 border-t border-white/[0.06]`,children:[(0,W.jsx)(`p`,{className:`text-[12px] text-white/40 mt-3 mb-2`,children:`Enter your current TOTP code to disable 2FA:`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,value:Zn,onChange:e=>{Qn(e.target.value.replace(/\D/g,``)),er(``)},placeholder:`000000`,className:Ur+` flex-1 tracking-[0.3em] text-center font-mono`}),(0,W.jsx)(`button`,{onClick:async()=>{if(Zn.length===6)try{let e=await fetch(`/api/portal/totp/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:un?gn:N,code:Zn})}),t=await e.json();e.ok?(An(!1),Bn(!1),Mn(``),Pn(``),In(``),Xn(!1),Qn(``),Kn([]),Jn(!1)):er(t.error||`Failed to disable`)}catch{er(`Could not reach server`)}},disabled:Zn.length!==6,className:`shrink-0 px-4 py-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-400 text-[13px] font-medium rounded-xl transition-colors disabled:opacity-40`,children:`Disable`})]}),$n&&(0,W.jsx)(`p`,{className:`text-red-400/70 text-[11px] mt-1`,children:$n}),(0,W.jsx)(`button`,{onClick:()=>{Xn(!1),Qn(``),er(``)},className:`text-[11px] text-white/30 hover:text-white/50 mt-2`,children:`Cancel`})]}),Un&&rr===`password`&&(0,W.jsx)(`div`,{className:`mx-4 mb-3 bg-red-500/8 border border-red-500/15 rounded-xl px-3 py-2`,children:(0,W.jsx)(`p`,{className:`text-red-400/90 text-[11px]`,children:Un})})]}),(0,W.jsxs)(`button`,{onClick:Rr,disabled:!Lr,className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]},`password`),rr===`totp-setup`&&(0,W.jsxs)(Bu.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,W.jsx)(`button`,{onClick:()=>{An(!1),Pn(``),Mn(``),In(``),Rn(``),Wn(``),ir(`password`),fr()},className:`w-7 h-7 rounded-full bg-white/[0.04] flex items-center justify-center text-white/40 hover:text-white/70 transition-colors shrink-0`,children:(0,W.jsx)(C,{className:`h-4 w-4`})}),(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Set up 2FA`})]}),Un&&(0,W.jsx)(`div`,{className:`mt-3 bg-red-500/8 border border-red-500/15 rounded-xl px-3 py-2`,children:(0,W.jsx)(`p`,{className:`text-red-400/90 text-[11px]`,children:Un})}),Nn&&(0,W.jsxs)(W.Fragment,{children:[tr?(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] leading-relaxed mb-4`,children:`Add Bloby to your authenticator app, then enter the 6-digit code below to confirm.`}),(0,W.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(jn),or(!0),setTimeout(()=>or(!1),3e3)},className:`w-full py-3 text-[14px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 ${ar?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-white/[0.05] text-white/70 hover:bg-white/[0.08] border border-white/[0.08]`}`,children:ar?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ee,{className:`h-4 w-4`}),`Secret key copied`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(re,{className:`h-4 w-4`}),`Copy secret key`]})}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/20 text-center mt-2`,children:`Paste it in your authenticator app → Add account → Enter key`}),(0,W.jsxs)(`a`,{href:Fn,onClick:()=>ur(),className:`w-full mt-3 py-2.5 text-[13px] text-white/30 hover:text-white/50 flex items-center justify-center gap-1.5 transition-colors`,children:[(0,W.jsx)(de,{className:`h-3.5 w-3.5`}),`Or open directly in authenticator`]})]}):(0,W.jsxs)(`div`,{className:`mt-4 flex gap-4 items-start`,children:[(0,W.jsx)(`div`,{className:`shrink-0`,children:(0,W.jsx)(`div`,{className:`bg-white rounded-xl p-1.5`,children:(0,W.jsx)(`img`,{src:Nn,alt:`TOTP QR Code`,className:`w-[140px] h-[140px]`})})}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] leading-relaxed`,children:`Scan this QR code with your authenticator app.`}),(0,W.jsx)(`p`,{className:`text-white/25 text-[11px] mt-2 leading-relaxed`,children:`Google Authenticator, Authy, 1Password, or any TOTP app.`}),(0,W.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(jn)},className:`mt-3 text-[11px] text-white/25 hover:text-white/40 flex items-center gap-1 transition-colors`,children:[(0,W.jsx)(re,{className:`h-3 w-3`}),`Copy secret key`]})]})]}),(0,W.jsxs)(`div`,{className:`mt-5`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`Enter the 6-digit code from your app`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,value:Ln,onChange:e=>{Rn(e.target.value.replace(/\D/g,``)),Wn(``)},placeholder:`000000`,autoFocus:!0,className:Hr+` tracking-[0.3em] text-center font-mono flex-1`}),(0,W.jsx)(`button`,{onClick:async()=>{if(Ln.length===6){Hn(!0),Wn(``);try{let e=await fetch(`/api/portal/totp/verify-setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:Ln,password:un?gn:N})}),t=await e.json();e.ok&&t.success?(Bn(!0),Kn(t.recoveryCodes||[]),ir(`recovery`),fr()):Wn(t.error||`Verification failed`)}catch{Wn(`Could not reach server`)}finally{Hn(!1)}}},disabled:Ln.length!==6||Vn,className:`shrink-0 px-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-xl transition-colors flex items-center gap-2 disabled:opacity-40`,children:Vn?(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}):`Verify`})]})]})]})]},`totp-setup`),rr===`recovery`&&(0,W.jsxs)(Bu.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,W.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-emerald-500/10 flex items-center justify-center shrink-0`,children:(0,W.jsx)(T,{className:`h-[18px] w-[18px] text-emerald-400`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`2FA enabled`}),(0,W.jsx)(`p`,{className:`text-emerald-400/70 text-[12px]`,children:`Save your recovery codes`})]})]}),(0,W.jsx)(`p`,{className:`text-white/35 text-[13px] mt-3 leading-relaxed`,children:`If you lose your authenticator app, you can use one of these codes to sign in. Each code works once. Store them somewhere safe.`}),(0,W.jsx)(`div`,{className:`mt-4 grid grid-cols-2 gap-1.5`,children:Gn.map((e,t)=>(0,W.jsx)(`div`,{className:`bg-white/[0.03] border border-white/[0.06] rounded-lg px-3 py-2 text-center`,children:(0,W.jsx)(`code`,{className:`text-[13px] text-white/60 font-mono tracking-wider`,children:e})},t))}),(0,W.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(Gn.join(`
21
+ `)),Jn(!0)},className:`w-full mt-4 py-3 text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 ${qn?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-white/[0.05] text-white/60 hover:bg-white/[0.08] border border-white/[0.08]`}`,children:qn?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ee,{className:`h-4 w-4`}),`Copied`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(re,{className:`h-4 w-4`}),`Copy recovery codes`]})}),(0,W.jsxs)(`button`,{onClick:()=>{Kn([]),ir(`password`),fr()},disabled:!qn,className:`w-full mt-3 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Done`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]},`recovery`)]})}),a===4&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight`,children:`Choose your AI provider`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1.5 leading-relaxed`,children:`Pick one provider to power your bot, authenticate, and select a model.`}),(0,W.jsx)(`div`,{className:`flex gap-2.5 mt-4`,children:Gu.map(e=>(0,W.jsxs)(`button`,{onClick:()=>_r(e.id),className:`flex-1 relative rounded-xl border transition-all duration-200 p-3 text-left ${l===e.id?`bg-white/[0.04] border-[#AF27E3]/40`:`bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 py-0.5`,children:[(()=>{let t=e.iconHeight??Z;return(0,W.jsx)(`div`,{className:`flex items-center justify-center`,style:{height:`${Math.max(Z,t)}px`},children:e.icon?(0,W.jsx)(`img`,{src:e.icon,alt:e.name,className:`w-auto object-contain`,style:{height:`${t}px`}}):(0,W.jsx)(`div`,{className:`rounded-lg bg-white/[0.06] flex items-center justify-center text-white/50 text-sm font-bold`,style:{height:`${t}px`,width:`${t}px`}})})})(),(0,W.jsxs)(`div`,{className:`text-center`,children:[(0,W.jsx)(`div`,{className:`text-[13px] font-medium text-white`,children:e.name}),(0,W.jsx)(`div`,{className:`text-[10px] text-white/30 whitespace-pre-line leading-tight`,children:e.subtitle})]})]}),h[e.id]===`connected`?(0,W.jsx)(`div`,{className:`absolute top-2 right-2 w-4 h-4 rounded-full bg-emerald-500/15 flex items-center justify-center`,children:(0,W.jsx)(ee,{className:`h-2.5 w-2.5 text-emerald-400`})}):l===e.id?(0,W.jsx)(`div`,{className:`absolute top-2 right-2 w-2 h-2 rounded-full bg-gradient-brand`}):null]},e.id))}),(0,W.jsx)(`div`,{className:`border-t border-white/[0.06] mt-4 mb-3`}),l===`pi`&&(0,W.jsx)(`div`,{className:`space-y-2`,children:h.pi===`connected`&&we?(0,W.jsxs)(`div`,{className:`flex items-center justify-between bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3 py-2`,children:[(0,W.jsxs)(`p`,{className:`text-emerald-400/90 text-[12px] truncate`,children:[`Connected — `,_.find(e=>e.id===we.subProvider)?.name||we.subProvider,we.modelId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`span`,{className:`font-mono`,children:we.modelId})]}):null]}),(0,W.jsxs)(`button`,{onClick:xr,className:`text-white/30 hover:text-white/60 text-[11px] flex items-center gap-1 shrink-0 ml-2`,children:[(0,W.jsx)(ue,{className:`h-3 w-3`}),`Change`]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[11px] text-white/40 font-medium mb-1 block`,children:`Provider`}),(0,W.jsx)(qu,{models:_.map(e=>({id:e.id,label:e.name})),value:b,onChange:yr})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[11px] text-white/40 font-medium mb-1 block`,children:`Model`}),vr&&Array.isArray(vr.models)?(0,W.jsx)(qu,{models:vr.models,value:ge,onChange:_e}):(0,W.jsx)(`input`,{type:`text`,value:ge,onChange:e=>_e(e.target.value),placeholder:vr?.defaultModel||`model-id`,className:Ur+` font-mono`})]})]}),vr?.needsBaseUrl&&(0,W.jsx)(`input`,{type:`text`,value:he,onChange:e=>D(e.target.value),placeholder:vr.baseUrl||`https://example.com/v1`,className:Ur+` font-mono`}),vr?.needsApiKey&&(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`input`,{type:ve?`text`:`password`,value:S,onChange:e=>te(e.target.value),onKeyDown:e=>e.key===`Enter`&&br(),placeholder:`API key…`,className:Ur+` pr-16 font-mono`}),(0,W.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1.5`,children:[vr.apiKeyUrl&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>Sr(vr.apiKeyUrl),className:`text-white/25 hover:text-white/55 transition-colors`,title:`Get a key`,children:(0,W.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>ye(e=>!e),className:`text-white/25 hover:text-white/55 transition-colors`,children:ve?(0,W.jsx)(ae,{className:`h-3.5 w-3.5`}):(0,W.jsx)(oe,{className:`h-3.5 w-3.5`})})]})]}),Se&&(0,W.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3 py-2`,children:(0,W.jsx)(`p`,{className:`text-[12px] text-red-400/90 break-words`,children:Se})}),(0,W.jsx)(`button`,{onClick:br,disabled:be||!b||!!vr?.needsApiKey&&!S.trim()||!!vr?.needsBaseUrl&&!he.trim()||!ge.trim(),className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:be?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),`Connecting…`]}):(0,W.jsxs)(W.Fragment,{children:[`Test & connect`,(0,W.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})})]})}),l===`bloby`&&(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(`p`,{className:`text-[12px] text-white/40 leading-relaxed`,children:`Bloby (managed) is on the way. Sign in with Google once it ships and your bot will be hosted, updated, and billed by us — no API keys to manage.`}),(0,W.jsxs)(`button`,{type:`button`,disabled:!0,title:`Coming soon`,className:`w-full py-2.5 px-4 bg-white/[0.04] border border-white/[0.06] text-white/35 text-[13px] font-medium rounded-xl flex items-center justify-center gap-2 cursor-not-allowed`,children:[(0,W.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`h-4 w-4 opacity-50`,fill:`currentColor`,children:(0,W.jsx)(`path`,{d:`M21.35 11.1h-9.17v2.96h5.27c-.23 1.39-1.62 4.08-5.27 4.08-3.17 0-5.76-2.62-5.76-5.85s2.59-5.85 5.76-5.85c1.81 0 3.02.77 3.71 1.43l2.53-2.43C16.85 3.91 14.74 3 12.18 3 7.03 3 2.86 7.17 2.86 12.29s4.17 9.29 9.32 9.29c5.38 0 8.94-3.79 8.94-9.12 0-.61-.07-1.08-.17-1.55Z`})}),`Login with Google`]}),(0,W.jsx)(`p`,{className:`text-[10.5px] text-white/25 text-center`,children:`Not available yet.`})]}),l===`anthropic`&&(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[cr&&(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,W.jsx)(`div`,{className:`bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5`,children:(0,W.jsx)(`p`,{className:`text-emerald-400/90 text-[12px]`,children:`Connected — Anthropic subscription is active.`})}),(0,W.jsxs)(`button`,{onClick:()=>{g(e=>({...e,anthropic:`idle`})),De(!1),ke(``),Ne(``)},className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5`,children:[(0,W.jsx)(ue,{className:`h-3 w-3`}),`Re-authenticate`]})]}),!cr&&(0,W.jsxs)(W.Fragment,{children:[Me&&(0,W.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5`,children:(0,W.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:Me})}),(0,W.jsx)(`div`,{className:`space-y-1.5`,children:[`Click the button below to open Anthropic's login page`,`Sign in with your Anthropic account — a code will be generated`,`Copy the code and paste it in the field below`].map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,W.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,W.jsx)(`button`,{onClick:Cr,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2`,children:Ee?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ie,{className:`h-3.5 w-3.5 opacity-60`}),`Open authentication page again`]}):(0,W.jsxs)(W.Fragment,{children:[`Authenticate with Anthropic`,(0,W.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`input`,{type:`text`,value:Oe,onChange:e=>ke(e.target.value),onKeyDown:e=>e.key===`Enter`&&wr(),placeholder:`Paste your code here...`,className:Ur+` pr-10 font-mono`}),(0,W.jsx)(`button`,{onClick:Tr,className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors`,children:(0,W.jsx)(ne,{className:`h-3.5 w-3.5`})})]}),(0,W.jsx)(`button`,{onClick:wr,disabled:!Oe.trim()||Ae,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Ae?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),`Verifying...`]}):`Connect`}),(0,W.jsxs)(`button`,{onClick:Er,disabled:Pe,className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5 disabled:opacity-50`,children:[Pe?(0,W.jsx)(ce,{className:`h-3 w-3 animate-spin`}):(0,W.jsx)(ue,{className:`h-3 w-3`}),Pe?`Checking...`:`I'm already authenticated`]})]})]}),l===`openai`&&(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[cr&&(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,W.jsx)(`div`,{className:`bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5`,children:(0,W.jsx)(`p`,{className:`text-emerald-400/90 text-[12px]`,children:`Connected — ChatGPT subscription is active.`})}),(0,W.jsxs)(`button`,{onClick:()=>{g(e=>({...e,openai:`idle`})),tt(``)},className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5`,children:[(0,W.jsx)(ue,{className:`h-3 w-3`}),`Re-authenticate`]})]}),!cr&&(0,W.jsxs)(W.Fragment,{children:[et&&(0,W.jsx)(`div`,{className:`bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5`,children:(0,W.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:et})}),Ie===`device`&&Re!==`pending`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`space-y-1.5`,children:[`Click below — we'll open auth.openai.com/codex/device for you`,`Sign in with your ChatGPT Plus or Pro account`,`Type the one-time code shown here on that page`].map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,W.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,W.jsx)(`button`,{onClick:Dr,disabled:We,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-60`,children:We?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),`Requesting code...`]}):(0,W.jsxs)(W.Fragment,{children:[`Sign in with ChatGPT`,(0,W.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})})]}),Ie===`device`&&Re===`pending`&&Be&&(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`bg-white/[0.03] border border-white/[0.06] rounded-xl p-4`,children:[(0,W.jsx)(`p`,{className:`text-[11px] text-white/40 mb-1`,children:`1. Open this URL in any browser`}),(0,W.jsxs)(`button`,{onClick:()=>Sr(He),className:`w-full text-left py-2 px-3 bg-white/[0.04] hover:bg-white/[0.07] rounded-lg text-[12px] font-mono text-white/80 flex items-center justify-between transition-colors`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:He}),(0,W.jsx)(ie,{className:`h-3.5 w-3.5 ml-2 opacity-60 shrink-0`})]}),(0,W.jsx)(`p`,{className:`text-[11px] text-white/40 mt-3 mb-1`,children:`2. Enter this code`}),(0,W.jsxs)(`button`,{onClick:kr,className:`w-full py-3 px-3 bg-white/[0.04] hover:bg-white/[0.07] rounded-lg text-center transition-colors flex items-center justify-center gap-3 group`,children:[(0,W.jsx)(`span`,{className:`text-[20px] font-mono font-semibold text-white tracking-widest`,children:Be}),Ke?(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}):(0,W.jsx)(re,{className:`h-4 w-4 text-white/30 group-hover:text-white/60`})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-2 mt-3 text-[11px] text-white/40`,children:[(0,W.jsx)(ce,{className:`h-3 w-3 animate-spin`}),`Waiting for you to approve...`]})]}),(0,W.jsx)(`button`,{onClick:Or,className:`w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors`,children:`Cancel`})]}),Ie===`paste`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`space-y-1.5`,children:[`Click below to open ChatGPT sign-in`,`Sign in with your ChatGPT Plus or Pro account`,`Your browser will say "site can't be reached" — that's expected. Copy the FULL URL from the address bar and paste it below.`].map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`span`,{className:`flex-shrink-0 w-[18px] h-[18px] rounded-full bg-white/[0.06] text-white/30 text-[10px] font-medium flex items-center justify-center mt-px`,children:t+1}),(0,W.jsx)(`p`,{className:`text-white/40 text-[12px] leading-relaxed`,children:e})]},t))}),(0,W.jsx)(`button`,{onClick:Ar,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2`,children:Je?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ie,{className:`h-3.5 w-3.5 opacity-60`}),`Open authentication page again`]}):(0,W.jsxs)(W.Fragment,{children:[`Authenticate with ChatGPT`,(0,W.jsx)(w,{className:`h-3.5 w-3.5 opacity-60`})]})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`input`,{type:`text`,value:Xe,onChange:e=>Ze(e.target.value),onKeyDown:e=>e.key===`Enter`&&jr(),placeholder:`Paste callback URL or code here...`,className:Ur+` pr-10 font-mono`}),(0,W.jsx)(`button`,{onClick:Mr,className:`absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors`,children:(0,W.jsx)(ne,{className:`h-3.5 w-3.5`})})]}),(0,W.jsx)(`button`,{onClick:jr,disabled:!Xe.trim()||Qe,className:`w-full py-2.5 px-4 bg-gradient-brand hover:opacity-90 text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:Qe?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),`Verifying...`]}):`Connect`})]}),Re!==`pending`&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,W.jsx)(`button`,{onClick:()=>{tt(void 0),Le(Ie===`device`?`paste`:`device`)},className:`text-white/25 text-[11px] hover:text-white/40 transition-colors`,children:Ie===`device`?`Use callback URL instead`:`Use device code instead`}),(0,W.jsxs)(`button`,{onClick:Nr,disabled:nt,className:`text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center gap-1.5 disabled:opacity-50`,children:[nt?(0,W.jsx)(ce,{className:`h-3 w-3 animate-spin`}):(0,W.jsx)(ue,{className:`h-3 w-3`}),nt?`Checking...`:`I'm already authenticated`]})]})]})]}),cr&&l!==`pi`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`border-t border-white/[0.06] mt-4 mb-3`}),(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`Select a model`}),(0,W.jsx)(qu,{models:Ku[l]||[],value:d,onChange:f})]}),cr&&(0,W.jsxs)(`button`,{onClick:Rr,disabled:!Lr,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:[`Continue`,(0,W.jsx)(w,{className:`h-4 w-4`})]})]}),a===5&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:`Voice Messages`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-1 leading-relaxed`,children:`Voice input works out of the box using your browser's built-in speech recognition. For better accuracy, you can optionally enable OpenAI Whisper.`}),(0,W.jsx)(`div`,{className:`w-full mt-5 rounded-xl border border-emerald-500/20 bg-emerald-500/[0.04] p-4`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3.5`,children:[(0,W.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-emerald-500/10 flex items-center justify-center shrink-0`,children:(0,W.jsx)(le,{className:`h-5 w-5 text-emerald-400`})}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-[14px] font-medium text-white`,children:`Browser Speech Recognition`}),(0,W.jsx)(`div`,{className:`text-[12px] text-white/35 mt-0.5 leading-relaxed`,children:`Built-in voice input — no setup needed. Works in Chrome, Edge, and Safari.`})]}),(0,W.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-emerald-500/20 shrink-0`,children:(0,W.jsx)(ee,{className:`h-3.5 w-3.5 text-emerald-400`})})]})}),(0,W.jsx)(`button`,{onClick:()=>En(e=>!e),className:`w-full mt-3 rounded-xl border transition-all duration-200 p-4 text-left ${Tn?`bg-white/[0.04] border-[#AF27E3]/40`:`bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]`}`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3.5`,children:[(0,W.jsx)(`img`,{src:`/icons/openai.svg`,alt:`OpenAI`,className:`w-10 h-10 rounded-xl bg-white/[0.04] p-1.5`}),(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-[14px] font-medium text-white`,children:`OpenAI Whisper`}),(0,W.jsx)(`div`,{className:`text-[12px] text-white/35 mt-0.5 leading-relaxed`,children:`Upgrade to more accurate transcription that works in all browsers including Firefox.`})]}),(0,W.jsx)(`div`,{className:`w-10 h-[22px] rounded-full transition-colors duration-200 flex items-center px-0.5 shrink-0 ${Tn?`bg-gradient-brand`:`bg-white/[0.08]`}`,children:(0,W.jsx)(`div`,{className:`w-[18px] h-[18px] rounded-full bg-white shadow-sm transition-transform duration-200 ${Tn?`translate-x-[18px]`:`translate-x-0`}`})})]})}),Tn&&(0,W.jsxs)(`div`,{className:`mt-3`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block`,children:`OpenAI API Key`}),(0,W.jsx)(`input`,{type:`password`,value:Dn,onChange:e=>On(e.target.value.trim()),placeholder:`sk-...`,autoComplete:`off`,className:Hr+` font-mono text-[13px]`}),Dn.length>0&&!Dn.startsWith(`sk-`)&&(0,W.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`Key should start with sk-`}),Dn.length>0&&Dn.startsWith(`sk-`)&&Dn.length<20&&(0,W.jsx)(`p`,{className:`text-amber-400/70 text-[11px] mt-1`,children:`Key looks too short`}),(0,W.jsxs)(`div`,{className:`flex items-start gap-2.5 mt-3 bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsx)(le,{className:`h-4 w-4 text-[#AF27E3]/60 mt-0.5 shrink-0`}),(0,W.jsx)(`p`,{className:`text-white/35 text-[12px] leading-relaxed`,children:`Whisper provides more accurate transcription and works in all browsers including Firefox.`})]})]}),(0,W.jsx)(`button`,{onClick:Vr,disabled:p||Tn&&(!Dn.startsWith(`sk-`)||Dn.length<20),className:`w-full mt-5 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:p?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{className:`h-4 w-4 animate-spin`}),`Setting up...`]}):(0,W.jsxs)(W.Fragment,{children:[`Complete Setup`,(0,W.jsx)(w,{className:`h-4 w-4`})]})}),!Tn&&(0,W.jsx)(`p`,{className:`text-center text-white/20 text-[11px] mt-2.5`,children:`Voice input is active using your browser's built-in speech recognition.`})]}),a===6&&t&&(()=>{let e=_t===`off`,t=e?window.location.origin:_t===`named`?`https://${yt}`:Ct===`relay`&&mt?mt:xt||`http://localhost:3000`,n=t.startsWith(`http`)?t:`https://${t}`;return(0,W.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,W.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center mb-5`,children:(0,W.jsx)(ee,{className:`h-8 w-8 text-emerald-400`})}),(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-white tracking-tight`,children:`All Set!`}),(0,W.jsx)(`p`,{className:`text-white/40 text-[13px] mt-2 leading-relaxed max-w-[340px]`,children:e?`Your agent is running on your private network. Access it from any device on your local network or VPN.`:_t===`named`?`Access your agent at your custom domain.`:Ct===`relay`&&mt?`Your agent is live and ready. From now on, access it using your custom URL below.`:`Your agent is live and ready. Your tunnel URL is shown below. Note: this URL changes on restart.`}),(0,W.jsxs)(`div`,{className:`w-full mt-6 flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:t}),(0,W.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(n),ln(!0),setTimeout(()=>ln(!1),2e3)},className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:cn?(0,W.jsx)(ee,{className:`h-4 w-4 text-emerald-400`}):(0,W.jsxs)(`svg`,{className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:[(0,W.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,W.jsx)(`path`,{d:`M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1`})]})})]}),(0,W.jsxs)(`div`,{className:`w-full mt-3`,children:[(0,W.jsx)(`label`,{className:`text-[12px] text-white/40 font-medium mb-1.5 block text-left`,children:`Your password`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[13px] text-white/70 truncate flex-1 text-left`,children:fn?N:`•`.repeat(Math.max(N.length,8))}),(0,W.jsx)(`button`,{onClick:()=>pn(e=>!e),className:`shrink-0 text-white/30 hover:text-white/60 transition-colors`,children:fn?(0,W.jsx)(ae,{className:`h-4 w-4`}):(0,W.jsx)(oe,{className:`h-4 w-4`})})]})]}),(0,W.jsxs)(`label`,{className:`flex items-start gap-2.5 mt-6 cursor-pointer text-left select-none`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:mn,onChange:e=>hn(e.target.checked),className:`mt-0.5 h-4 w-4 rounded border-white/20 bg-white/5 accent-emerald-500 shrink-0`}),(0,W.jsxs)(`span`,{className:`text-[12px] text-white/50 leading-relaxed`,children:[`I accept the`,` `,(0,W.jsx)(`a`,{href:`https://www.bloby.bot/terms`,target:`_blank`,rel:`noopener noreferrer`,className:`text-white/70 underline hover:text-white/90`,children:`terms`}),` `,`and`,` `,(0,W.jsx)(`a`,{href:`https://www.bloby.bot/privacy`,target:`_blank`,rel:`noopener noreferrer`,className:`text-white/70 underline hover:text-white/90`,children:`privacy policy`})]})]}),(0,W.jsxs)(`button`,{disabled:!mn,onClick:()=>{e?(window.top||window).location.href=`/`:(window.top||window).location.href=n},className:`w-full mt-4 py-3 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 ${mn?`bg-gradient-brand hover:opacity-90`:`bg-white/10 cursor-not-allowed opacity-50`}`,children:[e?`Go to dashboard`:`Go to your agent`,(0,W.jsx)(ie,{className:`h-4 w-4`})]}),(0,W.jsx)(`p`,{className:`text-white/20 text-[11px] mt-3 leading-relaxed`,children:e?`Access from any device on your network using the URL above.`:`You'll be redirected to your ${_t===`named`?`custom domain`:Ct===`relay`?`custom URL`:`tunnel URL`}.`})]})})()]},a)}),a>0&&a<i-1&&!(a===6&&t)&&(0,W.jsx)(`div`,{className:`px-8 pb-5 -mt-3`,children:(0,W.jsx)(`button`,{onClick:zr,className:`text-white/25 hover:text-white/50 text-[12px] transition-colors`,children:`← Back`})})]})]})}export{le as a,re as c,C as d,S as f,E as i,ee as l,Bu as n,ce as o,d as p,Xc as r,ie as s,Ju as t,w as u};