fluxy-bot 0.3.7 → 0.3.9

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.
@@ -1,4 +1,4 @@
1
- import{c as fe,r as B,j as _,L as Gc,A as jc,g as cu,R as xe,a as wn,m as Ot,M as cl,b as Hc,O as Vc}from"./globals-BARUsBoX.js";const Wc=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],qc=fe("arrow-left",Wc);const Yc=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Kc=fe("camera",Yc);const Xc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Zc=fe("chevron-left",Xc);const Qc=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Jc=fe("chevron-right",Qc);const ed=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],td=fe("ellipsis-vertical",ed);const nd=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],rd=fe("lock",nd);const ad=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Tn=fe("paperclip",ad);const id=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],od=fe("pause",id);const sd=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ld=fe("play",sd);const ud=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],cd=fe("send-horizontal",ud);const dd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],pd=fe("square",dd);const gd=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],du=fe("trash-2",gd);const fd=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],md=fe("wand-sparkles",fd);const bd=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],pu=fe("x",bd);class $n{ws=null;handlers=new Map;statusHandlers=new Set;reconnectTimer=null;heartbeatTimer=null;url;queue=[];intentionalClose=!1;reconnectDelay=1e3;static MAX_RECONNECT_DELAY=8e3;tokenGetter=null;constructor(t,n){const r=location.protocol==="https:"?"wss:":"ws:",a=location.host;this.url=t??`${r}//${a}/ws`,this.tokenGetter=n??null}connect(){this.intentionalClose=!1;let t=this.url;if(this.tokenGetter){const n=this.tokenGetter();if(n){const r=t.includes("?")?"&":"?";t=`${t}${r}token=${n}`}}this.ws=new WebSocket(t),this.ws.onopen=()=>{this.reconnectDelay=1e3,this.notifyStatus(!0),this.flushQueue(),this.startHeartbeat()},this.ws.onmessage=n=>{if(n.data==="pong")return;const r=JSON.parse(n.data);this.handlers.get(r.type)?.forEach(i=>i(r.data))},this.ws.onclose=()=>{this.stopHeartbeat(),this.notifyStatus(!1),this.intentionalClose||(this.reconnectTimer=setTimeout(()=>{this.reconnectDelay=Math.min(this.reconnectDelay*2,$n.MAX_RECONNECT_DELAY),this.connect()},this.reconnectDelay))},this.ws.onerror=()=>this.ws?.close()}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.stopHeartbeat(),this.ws?.close(),this.ws=null}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>this.handlers.get(t)?.delete(n)}onStatus(t){return this.statusHandlers.add(t),()=>this.statusHandlers.delete(t)}send(t,n){const r={type:t,data:n};this.ws?.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(r)):this.queue.push(r)}get connected(){return this.ws?.readyState===WebSocket.OPEN}flushQueue(){for(;this.queue.length>0&&this.ws?.readyState===WebSocket.OPEN;){const t=this.queue.shift();this.ws.send(JSON.stringify(t))}}notifyStatus(t){this.statusHandlers.forEach(n=>n(t))}startHeartbeat(){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send("ping")},25e3)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}}const zn="fluxy_token";let gu=null;function An(){return localStorage.getItem(zn)}function hd(e){localStorage.setItem(zn,e)}function fu(){localStorage.removeItem(zn)}function Ed(e){gu=e}async function Ft(e,t={}){const n=An(),r=new Headers(t.headers);n&&r.set("Authorization",`Bearer ${n}`);const a=await fetch(e,{...t,headers:r});return a.status===401&&n&&(fu(),gu?.()),a}function yd(e,t,n=!0){const[r,a]=B.useState([]),[i,o]=B.useState(null),[s,l]=B.useState(!1),[u,d]=B.useState(""),[c,p]=B.useState([]),g=B.useRef(!1),m=B.useCallback(async()=>{try{const A=await Ft("/api/context/current").then(R=>R.json());if(!A.conversationId)return;o(A.conversationId);const S=await Ft(`/api/conversations/${A.conversationId}`);if(!S.ok)return;const I=await S.json();if(!I.messages?.length)return;a(I.messages.filter(R=>R.role==="user"||R.role==="assistant").map(R=>{let w;R.audio_data&&(R.audio_data.startsWith("data:")?w=R.audio_data:R.audio_data.includes("/")?w=`/api/files/${R.audio_data}`:w=`data:audio/webm;base64,${R.audio_data}`);let C;if(R.attachments)try{C=JSON.parse(R.attachments)}catch{}return{id:R.id,role:R.role,content:R.content,timestamp:R.created_at,audioData:w,hasAttachments:!!(C&&C.length>0),attachments:C}}))}catch{}},[]);B.useEffect(()=>{!n||g.current||(g.current=!0,m())},[n,m]),B.useEffect(()=>{n&&t&&t>0&&m()},[n,t,m]),B.useEffect(()=>{if(!e)return;const A=[e.on("bot:typing",()=>{l(!0),p([])}),e.on("bot:token",S=>{d(I=>I+S.token)}),e.on("bot:tool",S=>{p(I=>I.find(w=>w.name===S.name&&w.status==="running")?I:[...I,{name:S.name,status:"running"}])}),e.on("bot:response",S=>{o(S.conversationId),a(I=>[...I,{id:S.messageId||Date.now().toString(),role:"assistant",content:S.content,timestamp:new Date().toISOString()}]),d(""),l(!1),p([])}),e.on("bot:error",S=>{d(""),l(!1),p([]),a(I=>[...I,{id:Date.now().toString(),role:"assistant",content:`Error: ${S.error}`,timestamp:new Date().toISOString()}])}),e.on("chat:sync",S=>{i&&S.conversationId!==i||a(I=>[...I,{id:Date.now().toString(),role:S.message.role,content:S.message.content,timestamp:S.message.timestamp}])}),e.on("chat:conversation-created",S=>{o(S.conversationId)}),e.on("chat:cleared",()=>{a([]),o(null),d(""),l(!1),p([]),g.current=!1})];return()=>A.forEach(S=>S())},[e,i]);const y=B.useCallback((A,S,I)=>{if(!e||!A.trim()&&(!S||S.length===0))return;const R={id:Date.now().toString(),role:"user",content:A,timestamp:new Date().toISOString(),hasAttachments:!!(S&&S.length>0),audioData:I?I.startsWith("data:")?I:`data:audio/webm;base64,${I}`:void 0};a(C=>[...C,R]);const w={conversationId:i,content:A};I&&(w.audioData=I.includes(",")?I.split(",")[1]:I),S?.length&&(w.attachments=S.map(C=>{const F=C.preview.match(/^data:([^;]+);base64,(.+)$/);return{type:C.type,name:C.name,mediaType:F?.[1]||"application/octet-stream",data:F?.[2]||""}})),e.send("user:message",w)},[e,i]),k=B.useCallback(()=>{e&&(e.send("user:stop",{conversationId:i}),l(!1),d(""),p([]))},[e,i]),E=B.useCallback(()=>{e&&e.send("user:clear-context",{}),a([]),o(null),d(""),l(!1),p([]),g.current=!1},[e]);return{messages:r,streaming:s,streamBuffer:u,conversationId:i,tools:c,sendMessage:y,stopStreaming:k,clearContext:E}}function Sd({onLogin:e}){const[t,n]=B.useState(""),[r,a]=B.useState(""),[i,o]=B.useState(""),[s,l]=B.useState(!1),u=async()=>{if(!(!t.trim()||!r.trim()||s)){l(!0),o("");try{const p=btoa(`${t.trim()}:${r}`),g=await fetch("/api/portal/login",{headers:{Authorization:`Basic ${p}`}}),m=await g.json();g.ok&&m.token?e(m.token):o(m.error||"Invalid credentials")}catch{o("Could not reach server")}finally{l(!1)}}},d=p=>{p.key==="Enter"&&u()},c="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";return _.jsx("div",{className:"flex flex-col items-center justify-center h-dvh px-6",children:_.jsxs("div",{className:"w-full max-w-[320px] flex flex-col items-center",children:[_.jsx("div",{className:"w-14 h-14 rounded-2xl bg-white/[0.04] border border-white/[0.08] flex items-center justify-center mb-5",children:_.jsx(rd,{className:"h-6 w-6 text-white/40"})}),_.jsx("h1",{className:"text-xl font-bold text-white tracking-tight mb-1",children:"Welcome back"}),_.jsx("p",{className:"text-white/40 text-[13px] mb-6",children:"Enter your portal credentials to continue."}),i&&_.jsx("div",{className:"w-full bg-red-500/8 border border-red-500/15 rounded-xl px-4 py-2.5 mb-4",children:_.jsx("p",{className:"text-red-400/90 text-[12px]",children:i})}),_.jsx("input",{type:"text",value:t,onChange:p=>n(p.target.value),onKeyDown:d,placeholder:"Username",autoFocus:!0,autoComplete:"username",autoCapitalize:"none",autoCorrect:"off",className:c}),_.jsx("input",{type:"password",value:r,onChange:p=>a(p.target.value),onKeyDown:d,placeholder:"Password",autoComplete:"current-password",className:c+" mt-3"}),_.jsx("button",{onClick:u,disabled:!t.trim()||!r.trim()||s,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:s?_.jsxs(_.Fragment,{children:[_.jsx(Gc,{className:"h-4 w-4 animate-spin"}),"Signing in..."]}):_.jsxs(_.Fragment,{children:["Sign In",_.jsx(jc,{className:"h-4 w-4"})]})})]})})}function dl(e){const t=[],n=String(e||"");let r=n.indexOf(","),a=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const o=n.slice(a,r).trim();(o||!i)&&t.push(o),a=r+1,r=n.indexOf(",",a)}return t}function kd(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const wd=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Td=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ad={};function pl(e,t){return(Ad.jsx?Td:wd).test(e)}const _d=/[ \t\n\f\r]/g;function Id(e){return typeof e=="object"?e.type==="text"?gl(e.value):!1:gl(e)}function gl(e){return e.replace(_d,"")===""}class Et{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Et.prototype.normal={};Et.prototype.property={};Et.prototype.space=void 0;function mu(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Et(n,r,t)}function gt(e){return e.toLowerCase()}class me{constructor(t,n){this.attribute=n,this.property=t}}me.prototype.attribute="";me.prototype.booleanish=!1;me.prototype.boolean=!1;me.prototype.commaOrSpaceSeparated=!1;me.prototype.commaSeparated=!1;me.prototype.defined=!1;me.prototype.mustUseProperty=!1;me.prototype.number=!1;me.prototype.overloadedBoolean=!1;me.prototype.property="";me.prototype.spaceSeparated=!1;me.prototype.space=void 0;let Rd=0;const W=Pe(),ae=Pe(),_n=Pe(),D=Pe(),re=Pe(),qe=Pe(),ye=Pe();function Pe(){return 2**++Rd}const In=Object.freeze(Object.defineProperty({__proto__:null,boolean:W,booleanish:ae,commaOrSpaceSeparated:ye,commaSeparated:qe,number:D,overloadedBoolean:_n,spaceSeparated:re},Symbol.toStringTag,{value:"Module"})),nn=Object.keys(In);class Gn extends me{constructor(t,n,r,a){let i=-1;if(super(t,n),fl(this,"space",a),typeof r=="number")for(;++i<nn.length;){const o=nn[i];fl(this,nn[i],(r&In[o])===In[o])}}}Gn.prototype.defined=!0;function fl(e,t,n){n&&(e[t]=n)}function Ke(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new Gn(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[gt(r)]=r,n[gt(i.attribute)]=r}return new Et(t,n,e.space)}const bu=Ke({properties:{ariaActiveDescendant:null,ariaAtomic:ae,ariaAutoComplete:null,ariaBusy:ae,ariaChecked:ae,ariaColCount:D,ariaColIndex:D,ariaColSpan:D,ariaControls:re,ariaCurrent:null,ariaDescribedBy:re,ariaDetails:null,ariaDisabled:ae,ariaDropEffect:re,ariaErrorMessage:null,ariaExpanded:ae,ariaFlowTo:re,ariaGrabbed:ae,ariaHasPopup:null,ariaHidden:ae,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:re,ariaLevel:D,ariaLive:null,ariaModal:ae,ariaMultiLine:ae,ariaMultiSelectable:ae,ariaOrientation:null,ariaOwns:re,ariaPlaceholder:null,ariaPosInSet:D,ariaPressed:ae,ariaReadOnly:ae,ariaRelevant:null,ariaRequired:ae,ariaRoleDescription:re,ariaRowCount:D,ariaRowIndex:D,ariaRowSpan:D,ariaSelected:ae,ariaSetSize:D,ariaSort:null,ariaValueMax:D,ariaValueMin:D,ariaValueNow:D,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function hu(e,t){return t in e?e[t]:t}function Eu(e,t){return hu(e,t.toLowerCase())}const Nd=Ke({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qe,acceptCharset:re,accessKey:re,action:null,allow:null,allowFullScreen:W,allowPaymentRequest:W,allowUserMedia:W,alt:null,as:null,async:W,autoCapitalize:null,autoComplete:re,autoFocus:W,autoPlay:W,blocking:re,capture:null,charSet:null,checked:W,cite:null,className:re,cols:D,colSpan:null,content:null,contentEditable:ae,controls:W,controlsList:re,coords:D|qe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:W,defer:W,dir:null,dirName:null,disabled:W,download:_n,draggable:ae,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:W,formTarget:null,headers:re,height:D,hidden:_n,high:D,href:null,hrefLang:null,htmlFor:re,httpEquiv:re,id:null,imageSizes:null,imageSrcSet:null,inert:W,inputMode:null,integrity:null,is:null,isMap:W,itemId:null,itemProp:re,itemRef:re,itemScope:W,itemType:re,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:W,low:D,manifest:null,max:null,maxLength:D,media:null,method:null,min:null,minLength:D,multiple:W,muted:W,name:null,nonce:null,noModule:W,noValidate:W,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:W,optimum:D,pattern:null,ping:re,placeholder:null,playsInline:W,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:W,referrerPolicy:null,rel:re,required:W,reversed:W,rows:D,rowSpan:D,sandbox:re,scope:null,scoped:W,seamless:W,selected:W,shadowRootClonable:W,shadowRootDelegatesFocus:W,shadowRootMode:null,shape:null,size:D,sizes:null,slot:null,span:D,spellCheck:ae,src:null,srcDoc:null,srcLang:null,srcSet:null,start:D,step:null,style:null,tabIndex:D,target:null,title:null,translate:null,type:null,typeMustMatch:W,useMap:null,value:ae,width:D,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:re,axis:null,background:null,bgColor:null,border:D,borderColor:null,bottomMargin:D,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:W,declare:W,event:null,face:null,frame:null,frameBorder:null,hSpace:D,leftMargin:D,link:null,longDesc:null,lowSrc:null,marginHeight:D,marginWidth:D,noResize:W,noHref:W,noShade:W,noWrap:W,object:null,profile:null,prompt:null,rev:null,rightMargin:D,rules:null,scheme:null,scrolling:ae,standby:null,summary:null,text:null,topMargin:D,valueType:null,version:null,vAlign:null,vLink:null,vSpace:D,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:W,disableRemotePlayback:W,prefix:null,property:null,results:D,security:null,unselectable:null},space:"html",transform:Eu}),vd=Ke({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ye,accentHeight:D,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:D,amplitude:D,arabicForm:null,ascent:D,attributeName:null,attributeType:null,azimuth:D,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:D,by:null,calcMode:null,capHeight:D,className:re,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:D,diffuseConstant:D,direction:null,display:null,dur:null,divisor:D,dominantBaseline:null,download:W,dx:null,dy:null,edgeMode:null,editable:null,elevation:D,enableBackground:null,end:null,event:null,exponent:D,externalResourcesRequired:null,fill:null,fillOpacity:D,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qe,g2:qe,glyphName:qe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:D,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:D,horizOriginX:D,horizOriginY:D,id:null,ideographic:D,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:D,k:D,k1:D,k2:D,k3:D,k4:D,kernelMatrix:ye,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:D,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:D,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:D,overlineThickness:D,paintOrder:null,panose1:null,path:null,pathLength:D,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:re,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:D,pointsAtY:D,pointsAtZ:D,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ye,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ye,rev:ye,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ye,requiredFeatures:ye,requiredFonts:ye,requiredFormats:ye,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:D,specularExponent:D,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:D,strikethroughThickness:D,string:null,stroke:null,strokeDashArray:ye,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:D,strokeOpacity:D,strokeWidth:null,style:null,surfaceScale:D,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ye,tabIndex:D,tableValues:null,target:null,targetX:D,targetY:D,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ye,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:D,underlineThickness:D,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:D,values:null,vAlphabetic:D,vMathematical:D,vectorEffect:null,vHanging:D,vIdeographic:D,version:null,vertAdvY:D,vertOriginX:D,vertOriginY:D,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:D,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:hu}),yu=Ke({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Su=Ke({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Eu}),ku=Ke({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),xd={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Cd=/[A-Z]/g,ml=/-[a-z]/g,Od=/^data[-\w.:]+$/i;function wu(e,t){const n=gt(t);let r=t,a=me;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Od.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(ml,Dd);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!ml.test(i)){let o=i.replace(Cd,Ld);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=Gn}return new a(r,t)}function Ld(e){return"-"+e.toLowerCase()}function Dd(e){return e.charAt(1).toUpperCase()}const Tu=mu([bu,Nd,yu,Su,ku],"html"),zt=mu([bu,vd,yu,Su,ku],"svg");function bl(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Md(e){return e.join(" ").trim()}var je={},rn,hl;function Fd(){if(hl)return rn;hl=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,s=/^\s+|\s+$/g,l=`
1
+ import{c as fe,r as B,j as _,L as Gc,A as jc,g as cu,R as xe,a as wn,m as Ot,M as cl,b as Hc,O as Vc}from"./globals-BcC_NUiS.js";const Wc=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],qc=fe("arrow-left",Wc);const Yc=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Kc=fe("camera",Yc);const Xc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Zc=fe("chevron-left",Xc);const Qc=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Jc=fe("chevron-right",Qc);const ed=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],td=fe("ellipsis-vertical",ed);const nd=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],rd=fe("lock",nd);const ad=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Tn=fe("paperclip",ad);const id=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],od=fe("pause",id);const sd=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ld=fe("play",sd);const ud=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],cd=fe("send-horizontal",ud);const dd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],pd=fe("square",dd);const gd=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],du=fe("trash-2",gd);const fd=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],md=fe("wand-sparkles",fd);const bd=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],pu=fe("x",bd);class $n{ws=null;handlers=new Map;statusHandlers=new Set;reconnectTimer=null;heartbeatTimer=null;url;queue=[];intentionalClose=!1;reconnectDelay=1e3;static MAX_RECONNECT_DELAY=8e3;tokenGetter=null;constructor(t,n){const r=location.protocol==="https:"?"wss:":"ws:",a=location.host;this.url=t??`${r}//${a}/ws`,this.tokenGetter=n??null}connect(){this.intentionalClose=!1;let t=this.url;if(this.tokenGetter){const n=this.tokenGetter();if(n){const r=t.includes("?")?"&":"?";t=`${t}${r}token=${n}`}}this.ws=new WebSocket(t),this.ws.onopen=()=>{this.reconnectDelay=1e3,this.notifyStatus(!0),this.flushQueue(),this.startHeartbeat()},this.ws.onmessage=n=>{if(n.data==="pong")return;const r=JSON.parse(n.data);this.handlers.get(r.type)?.forEach(i=>i(r.data))},this.ws.onclose=()=>{this.stopHeartbeat(),this.notifyStatus(!1),this.intentionalClose||(this.reconnectTimer=setTimeout(()=>{this.reconnectDelay=Math.min(this.reconnectDelay*2,$n.MAX_RECONNECT_DELAY),this.connect()},this.reconnectDelay))},this.ws.onerror=()=>this.ws?.close()}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.stopHeartbeat(),this.ws?.close(),this.ws=null}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>this.handlers.get(t)?.delete(n)}onStatus(t){return this.statusHandlers.add(t),()=>this.statusHandlers.delete(t)}send(t,n){const r={type:t,data:n};this.ws?.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(r)):this.queue.push(r)}get connected(){return this.ws?.readyState===WebSocket.OPEN}flushQueue(){for(;this.queue.length>0&&this.ws?.readyState===WebSocket.OPEN;){const t=this.queue.shift();this.ws.send(JSON.stringify(t))}}notifyStatus(t){this.statusHandlers.forEach(n=>n(t))}startHeartbeat(){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send("ping")},25e3)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}}const zn="fluxy_token";let gu=null;function An(){return localStorage.getItem(zn)}function hd(e){localStorage.setItem(zn,e)}function fu(){localStorage.removeItem(zn)}function Ed(e){gu=e}async function Ft(e,t={}){const n=An(),r=new Headers(t.headers);n&&r.set("Authorization",`Bearer ${n}`);const a=await fetch(e,{...t,headers:r});return a.status===401&&n&&(fu(),gu?.()),a}function yd(e,t,n=!0){const[r,a]=B.useState([]),[i,o]=B.useState(null),[s,l]=B.useState(!1),[u,d]=B.useState(""),[c,p]=B.useState([]),g=B.useRef(!1),m=B.useCallback(async()=>{try{const A=await Ft("/api/context/current").then(R=>R.json());if(!A.conversationId)return;o(A.conversationId);const S=await Ft(`/api/conversations/${A.conversationId}`);if(!S.ok)return;const I=await S.json();if(!I.messages?.length)return;a(I.messages.filter(R=>R.role==="user"||R.role==="assistant").map(R=>{let w;R.audio_data&&(R.audio_data.startsWith("data:")?w=R.audio_data:R.audio_data.includes("/")?w=`/api/files/${R.audio_data}`:w=`data:audio/webm;base64,${R.audio_data}`);let C;if(R.attachments)try{C=JSON.parse(R.attachments)}catch{}return{id:R.id,role:R.role,content:R.content,timestamp:R.created_at,audioData:w,hasAttachments:!!(C&&C.length>0),attachments:C}}))}catch{}},[]);B.useEffect(()=>{!n||g.current||(g.current=!0,m())},[n,m]),B.useEffect(()=>{n&&t&&t>0&&m()},[n,t,m]),B.useEffect(()=>{if(!e)return;const A=[e.on("bot:typing",()=>{l(!0),p([])}),e.on("bot:token",S=>{d(I=>I+S.token)}),e.on("bot:tool",S=>{p(I=>I.find(w=>w.name===S.name&&w.status==="running")?I:[...I,{name:S.name,status:"running"}])}),e.on("bot:response",S=>{o(S.conversationId),a(I=>[...I,{id:S.messageId||Date.now().toString(),role:"assistant",content:S.content,timestamp:new Date().toISOString()}]),d(""),l(!1),p([])}),e.on("bot:error",S=>{d(""),l(!1),p([]),a(I=>[...I,{id:Date.now().toString(),role:"assistant",content:`Error: ${S.error}`,timestamp:new Date().toISOString()}])}),e.on("chat:sync",S=>{i&&S.conversationId!==i||a(I=>[...I,{id:Date.now().toString(),role:S.message.role,content:S.message.content,timestamp:S.message.timestamp}])}),e.on("chat:conversation-created",S=>{o(S.conversationId)}),e.on("chat:cleared",()=>{a([]),o(null),d(""),l(!1),p([]),g.current=!1})];return()=>A.forEach(S=>S())},[e,i]);const y=B.useCallback((A,S,I)=>{if(!e||!A.trim()&&(!S||S.length===0))return;const R={id:Date.now().toString(),role:"user",content:A,timestamp:new Date().toISOString(),hasAttachments:!!(S&&S.length>0),audioData:I?I.startsWith("data:")?I:`data:audio/webm;base64,${I}`:void 0};a(C=>[...C,R]);const w={conversationId:i,content:A};I&&(w.audioData=I.includes(",")?I.split(",")[1]:I),S?.length&&(w.attachments=S.map(C=>{const F=C.preview.match(/^data:([^;]+);base64,(.+)$/);return{type:C.type,name:C.name,mediaType:F?.[1]||"application/octet-stream",data:F?.[2]||""}})),e.send("user:message",w)},[e,i]),k=B.useCallback(()=>{e&&(e.send("user:stop",{conversationId:i}),l(!1),d(""),p([]))},[e,i]),E=B.useCallback(()=>{e&&e.send("user:clear-context",{}),a([]),o(null),d(""),l(!1),p([]),g.current=!1},[e]);return{messages:r,streaming:s,streamBuffer:u,conversationId:i,tools:c,sendMessage:y,stopStreaming:k,clearContext:E}}function Sd({onLogin:e}){const[t,n]=B.useState(""),[r,a]=B.useState(""),[i,o]=B.useState(!1),s=async()=>{if(!(!t.trim()||i)){o(!0),a("");try{const d=btoa(`admin:${t}`),c=await fetch("/api/portal/login",{headers:{Authorization:`Basic ${d}`}}),p=await c.json();c.ok&&p.token?e(p.token):a(p.error||"Invalid password")}catch{a("Could not reach server")}finally{o(!1)}}},l=d=>{d.key==="Enter"&&s()};return _.jsx("div",{className:"flex flex-col items-center justify-center h-dvh px-6",children:_.jsxs("div",{className:"w-full max-w-[320px] flex flex-col items-center",children:[_.jsx("div",{className:"w-14 h-14 rounded-2xl bg-white/[0.04] border border-white/[0.08] flex items-center justify-center mb-5",children:_.jsx(rd,{className:"h-6 w-6 text-white/40"})}),_.jsx("h1",{className:"text-xl font-bold text-white tracking-tight mb-1",children:"Welcome back"}),_.jsx("p",{className:"text-white/40 text-[13px] mb-6",children:"Enter your password to continue."}),r&&_.jsx("div",{className:"w-full bg-red-500/8 border border-red-500/15 rounded-xl px-4 py-2.5 mb-4",children:_.jsx("p",{className:"text-red-400/90 text-[12px]",children:r})}),_.jsx("input",{type:"password",value:t,onChange:d=>n(d.target.value),onKeyDown:l,placeholder:"Password",autoFocus:!0,autoComplete:"current-password",className:"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"}),_.jsx("button",{onClick:s,disabled:!t.trim()||i,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:i?_.jsxs(_.Fragment,{children:[_.jsx(Gc,{className:"h-4 w-4 animate-spin"}),"Signing in..."]}):_.jsxs(_.Fragment,{children:["Sign In",_.jsx(jc,{className:"h-4 w-4"})]})})]})})}function dl(e){const t=[],n=String(e||"");let r=n.indexOf(","),a=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const o=n.slice(a,r).trim();(o||!i)&&t.push(o),a=r+1,r=n.indexOf(",",a)}return t}function kd(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const wd=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Td=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ad={};function pl(e,t){return(Ad.jsx?Td:wd).test(e)}const _d=/[ \t\n\f\r]/g;function Id(e){return typeof e=="object"?e.type==="text"?gl(e.value):!1:gl(e)}function gl(e){return e.replace(_d,"")===""}class Et{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Et.prototype.normal={};Et.prototype.property={};Et.prototype.space=void 0;function mu(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Et(n,r,t)}function gt(e){return e.toLowerCase()}class me{constructor(t,n){this.attribute=n,this.property=t}}me.prototype.attribute="";me.prototype.booleanish=!1;me.prototype.boolean=!1;me.prototype.commaOrSpaceSeparated=!1;me.prototype.commaSeparated=!1;me.prototype.defined=!1;me.prototype.mustUseProperty=!1;me.prototype.number=!1;me.prototype.overloadedBoolean=!1;me.prototype.property="";me.prototype.spaceSeparated=!1;me.prototype.space=void 0;let Rd=0;const W=Pe(),ae=Pe(),_n=Pe(),D=Pe(),re=Pe(),qe=Pe(),ye=Pe();function Pe(){return 2**++Rd}const In=Object.freeze(Object.defineProperty({__proto__:null,boolean:W,booleanish:ae,commaOrSpaceSeparated:ye,commaSeparated:qe,number:D,overloadedBoolean:_n,spaceSeparated:re},Symbol.toStringTag,{value:"Module"})),nn=Object.keys(In);class Gn extends me{constructor(t,n,r,a){let i=-1;if(super(t,n),fl(this,"space",a),typeof r=="number")for(;++i<nn.length;){const o=nn[i];fl(this,nn[i],(r&In[o])===In[o])}}}Gn.prototype.defined=!0;function fl(e,t,n){n&&(e[t]=n)}function Ke(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new Gn(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[gt(r)]=r,n[gt(i.attribute)]=r}return new Et(t,n,e.space)}const bu=Ke({properties:{ariaActiveDescendant:null,ariaAtomic:ae,ariaAutoComplete:null,ariaBusy:ae,ariaChecked:ae,ariaColCount:D,ariaColIndex:D,ariaColSpan:D,ariaControls:re,ariaCurrent:null,ariaDescribedBy:re,ariaDetails:null,ariaDisabled:ae,ariaDropEffect:re,ariaErrorMessage:null,ariaExpanded:ae,ariaFlowTo:re,ariaGrabbed:ae,ariaHasPopup:null,ariaHidden:ae,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:re,ariaLevel:D,ariaLive:null,ariaModal:ae,ariaMultiLine:ae,ariaMultiSelectable:ae,ariaOrientation:null,ariaOwns:re,ariaPlaceholder:null,ariaPosInSet:D,ariaPressed:ae,ariaReadOnly:ae,ariaRelevant:null,ariaRequired:ae,ariaRoleDescription:re,ariaRowCount:D,ariaRowIndex:D,ariaRowSpan:D,ariaSelected:ae,ariaSetSize:D,ariaSort:null,ariaValueMax:D,ariaValueMin:D,ariaValueNow:D,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function hu(e,t){return t in e?e[t]:t}function Eu(e,t){return hu(e,t.toLowerCase())}const Nd=Ke({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:qe,acceptCharset:re,accessKey:re,action:null,allow:null,allowFullScreen:W,allowPaymentRequest:W,allowUserMedia:W,alt:null,as:null,async:W,autoCapitalize:null,autoComplete:re,autoFocus:W,autoPlay:W,blocking:re,capture:null,charSet:null,checked:W,cite:null,className:re,cols:D,colSpan:null,content:null,contentEditable:ae,controls:W,controlsList:re,coords:D|qe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:W,defer:W,dir:null,dirName:null,disabled:W,download:_n,draggable:ae,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:W,formTarget:null,headers:re,height:D,hidden:_n,high:D,href:null,hrefLang:null,htmlFor:re,httpEquiv:re,id:null,imageSizes:null,imageSrcSet:null,inert:W,inputMode:null,integrity:null,is:null,isMap:W,itemId:null,itemProp:re,itemRef:re,itemScope:W,itemType:re,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:W,low:D,manifest:null,max:null,maxLength:D,media:null,method:null,min:null,minLength:D,multiple:W,muted:W,name:null,nonce:null,noModule:W,noValidate:W,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:W,optimum:D,pattern:null,ping:re,placeholder:null,playsInline:W,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:W,referrerPolicy:null,rel:re,required:W,reversed:W,rows:D,rowSpan:D,sandbox:re,scope:null,scoped:W,seamless:W,selected:W,shadowRootClonable:W,shadowRootDelegatesFocus:W,shadowRootMode:null,shape:null,size:D,sizes:null,slot:null,span:D,spellCheck:ae,src:null,srcDoc:null,srcLang:null,srcSet:null,start:D,step:null,style:null,tabIndex:D,target:null,title:null,translate:null,type:null,typeMustMatch:W,useMap:null,value:ae,width:D,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:re,axis:null,background:null,bgColor:null,border:D,borderColor:null,bottomMargin:D,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:W,declare:W,event:null,face:null,frame:null,frameBorder:null,hSpace:D,leftMargin:D,link:null,longDesc:null,lowSrc:null,marginHeight:D,marginWidth:D,noResize:W,noHref:W,noShade:W,noWrap:W,object:null,profile:null,prompt:null,rev:null,rightMargin:D,rules:null,scheme:null,scrolling:ae,standby:null,summary:null,text:null,topMargin:D,valueType:null,version:null,vAlign:null,vLink:null,vSpace:D,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:W,disableRemotePlayback:W,prefix:null,property:null,results:D,security:null,unselectable:null},space:"html",transform:Eu}),vd=Ke({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ye,accentHeight:D,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:D,amplitude:D,arabicForm:null,ascent:D,attributeName:null,attributeType:null,azimuth:D,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:D,by:null,calcMode:null,capHeight:D,className:re,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:D,diffuseConstant:D,direction:null,display:null,dur:null,divisor:D,dominantBaseline:null,download:W,dx:null,dy:null,edgeMode:null,editable:null,elevation:D,enableBackground:null,end:null,event:null,exponent:D,externalResourcesRequired:null,fill:null,fillOpacity:D,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:qe,g2:qe,glyphName:qe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:D,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:D,horizOriginX:D,horizOriginY:D,id:null,ideographic:D,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:D,k:D,k1:D,k2:D,k3:D,k4:D,kernelMatrix:ye,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:D,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:D,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:D,overlineThickness:D,paintOrder:null,panose1:null,path:null,pathLength:D,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:re,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:D,pointsAtY:D,pointsAtZ:D,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ye,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ye,rev:ye,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ye,requiredFeatures:ye,requiredFonts:ye,requiredFormats:ye,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:D,specularExponent:D,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:D,strikethroughThickness:D,string:null,stroke:null,strokeDashArray:ye,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:D,strokeOpacity:D,strokeWidth:null,style:null,surfaceScale:D,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ye,tabIndex:D,tableValues:null,target:null,targetX:D,targetY:D,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ye,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:D,underlineThickness:D,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:D,values:null,vAlphabetic:D,vMathematical:D,vectorEffect:null,vHanging:D,vIdeographic:D,version:null,vertAdvY:D,vertOriginX:D,vertOriginY:D,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:D,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:hu}),yu=Ke({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Su=Ke({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Eu}),ku=Ke({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),xd={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Cd=/[A-Z]/g,ml=/-[a-z]/g,Od=/^data[-\w.:]+$/i;function wu(e,t){const n=gt(t);let r=t,a=me;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Od.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(ml,Dd);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!ml.test(i)){let o=i.replace(Cd,Ld);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=Gn}return new a(r,t)}function Ld(e){return"-"+e.toLowerCase()}function Dd(e){return e.charAt(1).toUpperCase()}const Tu=mu([bu,Nd,yu,Su,ku],"html"),zt=mu([bu,vd,yu,Su,ku],"svg");function bl(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Md(e){return e.join(" ").trim()}var je={},rn,hl;function Fd(){if(hl)return rn;hl=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,s=/^\s+|\s+$/g,l=`
2
2
  `,u="/",d="*",c="",p="comment",g="declaration";function m(k,E){if(typeof k!="string")throw new TypeError("First argument must be a string");if(!k)return[];E=E||{};var A=1,S=1;function I(M){var x=M.match(t);x&&(A+=x.length);var j=M.lastIndexOf(l);S=~j?M.length-j:S+M.length}function R(){var M={line:A,column:S};return function(x){return x.position=new w(M),$(),x}}function w(M){this.start=M,this.end={line:A,column:S},this.source=E.source}w.prototype.content=k;function C(M){var x=new Error(E.source+":"+A+":"+S+": "+M);if(x.reason=M,x.filename=E.source,x.line=A,x.column=S,x.source=k,!E.silent)throw x}function F(M){var x=M.exec(k);if(x){var j=x[0];return I(j),k=k.slice(j.length),x}}function $(){F(n)}function T(M){var x;for(M=M||[];x=O();)x!==!1&&M.push(x);return M}function O(){var M=R();if(!(u!=k.charAt(0)||d!=k.charAt(1))){for(var x=2;c!=k.charAt(x)&&(d!=k.charAt(x)||u!=k.charAt(x+1));)++x;if(x+=2,c===k.charAt(x-1))return C("End of comment missing");var j=k.slice(2,x-2);return S+=2,I(j),k=k.slice(x),S+=2,M({type:p,comment:j})}}function L(){var M=R(),x=F(r);if(x){if(O(),!F(a))return C("property missing ':'");var j=F(i),V=M({type:g,property:y(x[0].replace(e,c)),value:j?y(j[0].replace(e,c)):c});return F(o),V}}function v(){var M=[];T(M);for(var x;x=L();)x!==!1&&(M.push(x),T(M));return M}return $(),v()}function y(k){return k?k.replace(s,c):c}return rn=m,rn}var El;function Ud(){if(El)return je;El=1;var e=je&&je.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(je,"__esModule",{value:!0}),je.default=n;const t=e(Fd());function n(r,a){let i=null;if(!r||typeof r!="string")return i;const o=(0,t.default)(r),s=typeof a=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:d}=l;s?a(u,d,l):d&&(i=i||{},i[u]=d)}),i}return je}var it={},yl;function Bd(){if(yl)return it;yl=1,Object.defineProperty(it,"__esModule",{value:!0}),it.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,i=function(u){return!u||n.test(u)||e.test(u)},o=function(u,d){return d.toUpperCase()},s=function(u,d){return"".concat(d,"-")},l=function(u,d){return d===void 0&&(d={}),i(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(a,s):u=u.replace(r,s),u.replace(t,o))};return it.camelCase=l,it}var ot,Sl;function Pd(){if(Sl)return ot;Sl=1;var e=ot&&ot.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(Ud()),n=Bd();function r(a,i){var o={};return!a||typeof a!="string"||(0,t.default)(a,function(s,l){s&&l&&(o[(0,n.camelCase)(s,i)]=l)}),o}return r.default=r,ot=r,ot}var $d=Pd();const zd=cu($d),Au=_u("end"),jn=_u("start");function _u(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Gd(e){const t=jn(e),n=Au(e);if(t&&n)return{start:t,end:n}}function ut(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?kl(e.position):"start"in e||"end"in e?kl(e):"line"in e||"column"in e?Rn(e):""}function Rn(e){return wl(e&&e.line)+":"+wl(e&&e.column)}function kl(e){return Rn(e&&e.start)+"-"+Rn(e&&e.end)}function wl(e){return e&&typeof e=="number"?e:1}class ue extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",i={},o=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?a=t:!i.cause&&t&&(o=!0,a=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?i.ruleId=r:(i.source=r.slice(0,l),i.ruleId=r.slice(l+1))}if(!i.place&&i.ancestors&&i.ancestors){const l=i.ancestors[i.ancestors.length-1];l&&(i.place=l.position)}const s=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=s?s.line:void 0,this.name=ut(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ue.prototype.file="";ue.prototype.name="";ue.prototype.reason="";ue.prototype.message="";ue.prototype.stack="";ue.prototype.column=void 0;ue.prototype.line=void 0;ue.prototype.ancestors=void 0;ue.prototype.cause=void 0;ue.prototype.fatal=void 0;ue.prototype.place=void 0;ue.prototype.ruleId=void 0;ue.prototype.source=void 0;const Hn={}.hasOwnProperty,jd=new Map,Hd=/[A-Z]/g,Vd=new Set(["table","tbody","thead","tfoot","tr"]),Wd=new Set(["td","th"]),Iu="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function qd(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=tp(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=ep(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?zt:Tu,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=Ru(a,e,void 0);return i&&typeof i!="string"?i:a.create(e,a.Fragment,{children:i||void 0},void 0)}function Ru(e,t,n){if(t.type==="element")return Yd(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Kd(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Zd(e,t,n);if(t.type==="mdxjsEsm")return Xd(e,t);if(t.type==="root")return Qd(e,t,n);if(t.type==="text")return Jd(e,t)}function Yd(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=zt,e.schema=a),e.ancestors.push(t);const i=vu(e,t.tagName,!1),o=np(e,t);let s=Wn(e,t);return Vd.has(t.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!Id(l):!0})),Nu(e,o,i,t),Vn(o,s),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function Kd(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ft(e,t.position)}function Xd(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ft(e,t.position)}function Zd(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=zt,e.schema=a),e.ancestors.push(t);const i=t.name===null?e.Fragment:vu(e,t.name,!0),o=rp(e,t),s=Wn(e,t);return Nu(e,o,i,t),Vn(o,s),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function Qd(e,t,n){const r={};return Vn(r,Wn(e,t)),e.create(t,e.Fragment,r,n)}function Jd(e,t){return t.value}function Nu(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Vn(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function ep(e,t,n){return r;function r(a,i,o,s){const u=Array.isArray(o.children)?n:t;return s?u(i,o,s):u(i,o)}}function tp(e,t){return n;function n(r,a,i,o){const s=Array.isArray(i.children),l=jn(r);return t(a,i,o,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function np(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&Hn.call(t.properties,a)){const i=ap(e,a,t.properties[a]);if(i){const[o,s]=i;e.tableCellAlignToStyle&&o==="align"&&typeof s=="string"&&Wd.has(t.tagName)?r=s:n[o]=s}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function rp(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const o=i.expression;o.type;const s=o.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else ft(e,t.position);else{const a=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,i=e.evaluater.evaluateExpression(s.expression)}else ft(e,t.position);else i=r.value===null?!0:r.value;n[a]=i}return n}function Wn(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:jd;for(;++r<t.children.length;){const i=t.children[r];let o;if(e.passKeys){const l=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(l){const u=a.get(l)||0;o=l+"-"+u,a.set(l,u+1)}}const s=Ru(e,i,o);s!==void 0&&n.push(s)}return n}function ap(e,t,n){const r=wu(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?kd(n):Md(n)),r.property==="style"){let a=typeof n=="object"?n:ip(e,String(n));return e.stylePropertyNameCase==="css"&&(a=op(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?xd[r.property]||r.property:r.attribute,n]}}function ip(e,t){try{return zd(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new ue("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=Iu+"#cannot-parse-style-attribute",a}}function vu(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let i=-1,o;for(;++i<a.length;){const s=pl(a[i])?{type:"Identifier",name:a[i]}:{type:"Literal",value:a[i]};o=o?{type:"MemberExpression",object:o,property:s,computed:!!(i&&s.type==="Literal"),optional:!1}:s}r=o}else r=pl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return Hn.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);ft(e)}function ft(e,t){const n=new ue("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Iu+"#cannot-handle-mdx-estrees-without-createevaluater",n}function op(e){const t={};let n;for(n in e)Hn.call(e,n)&&(t[sp(n)]=e[n]);return t}function sp(e){let t=e.replace(Hd,lp);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function lp(e){return"-"+e.toLowerCase()}const an={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},up={};function qn(e,t){const n=up,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return xu(e,r,a)}function xu(e,t,n){if(cp(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Tl(e.children,t,n)}return Array.isArray(e)?Tl(e,t,n):""}function Tl(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=xu(e[a],t,n);return r.join("")}function cp(e){return!!(e&&typeof e=="object")}const Al=document.createElement("i");function mt(e){const t="&"+e+";";Al.innerHTML=t;const n=Al.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Se(e,t,n,r){const a=e.length;let i=0,o;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);i<r.length;)o=r.slice(i,i+1e4),o.unshift(t,0),e.splice(...o),i+=1e4,t+=1e4}function ke(e,t){return e.length>0?(Se(e,e.length,0,t),e):t}const _l={}.hasOwnProperty;function Cu(e){const t={};let n=-1;for(;++n<e.length;)dp(t,e[n]);return t}function dp(e,t){let n;for(n in t){const a=(_l.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let o;if(i)for(o in i){_l.call(a,o)||(a[o]=[]);const s=i[o];pp(a[o],Array.isArray(s)?s:s?[s]:[])}}}function pp(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Se(e,0,0,r)}function Ou(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ae(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const pe=Me(/[A-Za-z]/),le=Me(/[\dA-Za-z]/),gp=Me(/[#-'*+\--9=?A-Z^-~]/);function Ut(e){return e!==null&&(e<32||e===127)}const Nn=Me(/\d/),fp=Me(/[\dA-Fa-f]/),mp=Me(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function q(e){return e===-2||e===-1||e===32}const Gt=Me(new RegExp("\\p{P}|\\p{S}","u")),Be=Me(/\s/);function Me(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Xe(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const i=e.charCodeAt(n);let o="";if(i===37&&le(e.charCodeAt(n+1))&&le(e.charCodeAt(n+2)))a=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(o=String.fromCharCode(i));else if(i>55295&&i<57344){const s=e.charCodeAt(n+1);i<56320&&s>56319&&s<57344?(o=String.fromCharCode(i,s),a=1):o="�"}else o=String.fromCharCode(i);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+a+1,o=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function X(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(l){return q(l)?(e.enter(n),s(l)):t(l)}function s(l){return q(l)&&i++<a?(e.consume(l),s):(e.exit(n),t(l))}}const bp={tokenize:hp};function hp(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),X(e,t,"linePrefix")}function a(s){return e.enter("paragraph"),i(s)}function i(s){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(s)}function o(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return z(s)?(e.consume(s),e.exit("chunkText"),i):(e.consume(s),o)}}const Ep={tokenize:yp},Il={tokenize:Sp};function yp(e){const t=this,n=[];let r=0,a,i,o;return s;function s(S){if(r<n.length){const I=n[r];return t.containerState=I[1],e.attempt(I[0].continuation,l,u)(S)}return u(S)}function l(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&A();const I=t.events.length;let R=I,w;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){w=t.events[R][1].end;break}E(r);let C=I;for(;C<t.events.length;)t.events[C][1].end={...w},C++;return Se(t.events,R+1,0,t.events.slice(I)),t.events.length=C,u(S)}return s(S)}function u(S){if(r===n.length){if(!a)return p(S);if(a.currentConstruct&&a.currentConstruct.concrete)return m(S);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Il,d,c)(S)}function d(S){return a&&A(),E(r),p(S)}function c(S){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(S)}function p(S){return t.containerState={},e.attempt(Il,g,m)(S)}function g(S){return r++,n.push([t.currentConstruct,t.containerState]),p(S)}function m(S){if(S===null){a&&A(),E(0),e.consume(S);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:i}),y(S)}function y(S){if(S===null){k(e.exit("chunkFlow"),!0),E(0),e.consume(S);return}return z(S)?(e.consume(S),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,s):(e.consume(S),y)}function k(S,I){const R=t.sliceStream(S);if(I&&R.push(null),S.previous=i,i&&(i.next=S),i=S,a.defineSkip(S.start),a.write(R),t.parser.lazy[S.start.line]){let w=a.events.length;for(;w--;)if(a.events[w][1].start.offset<o&&(!a.events[w][1].end||a.events[w][1].end.offset>o))return;const C=t.events.length;let F=C,$,T;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if($){T=t.events[F][1].end;break}$=!0}for(E(r),w=C;w<t.events.length;)t.events[w][1].end={...T},w++;Se(t.events,F+1,0,t.events.slice(C)),t.events.length=w}}function E(S){let I=n.length;for(;I-- >S;){const R=n[I];t.containerState=R[1],R[0].exit.call(t,e)}n.length=S}function A(){a.write([null]),i=void 0,a=void 0,t.containerState._closeFlow=void 0}}function Sp(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ye(e){if(e===null||te(e)||Be(e))return 1;if(Gt(e))return 2}function jt(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const i=e[a].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const vn={name:"attention",resolveAll:kp,tokenize:wp};function kp(e,t){let n=-1,r,a,i,o,s,l,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},p={...e[n][1].start};Rl(c,-l),Rl(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},i={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:l>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=ke(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=ke(u,[["enter",a,t],["enter",o,t],["exit",o,t],["enter",i,t]]),u=ke(u,jt(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=ke(u,[["exit",i,t],["enter",s,t],["exit",s,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=ke(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Se(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function wp(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Ye(r);let i;return o;function o(l){return i=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===i)return e.consume(l),s;const u=e.exit("attentionSequence"),d=Ye(l),c=!d||d===2&&a||n.includes(l),p=!a||a===2&&d||n.includes(r);return u._open=!!(i===42?c:c&&(a||!p)),u._close=!!(i===42?p:p&&(d||!c)),t(l)}}function Rl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Tp={name:"autolink",tokenize:Ap};function Ap(e,t,n){let r=0;return a;function a(g){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(g){return pe(g)?(e.consume(g),o):g===64?n(g):u(g)}function o(g){return g===43||g===45||g===46||le(g)?(r=1,s(g)):u(g)}function s(g){return g===58?(e.consume(g),r=0,l):(g===43||g===45||g===46||le(g))&&r++<32?(e.consume(g),s):(r=0,u(g))}function l(g){return g===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):g===null||g===32||g===60||Ut(g)?n(g):(e.consume(g),l)}function u(g){return g===64?(e.consume(g),d):gp(g)?(e.consume(g),u):n(g)}function d(g){return le(g)?c(g):n(g)}function c(g){return g===46?(e.consume(g),r=0,d):g===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):p(g)}function p(g){if((g===45||le(g))&&r++<63){const m=g===45?p:c;return e.consume(g),m}return n(g)}}const yt={partial:!0,tokenize:_p};function _p(e,t,n){return r;function r(i){return q(i)?X(e,a,"linePrefix")(i):a(i)}function a(i){return i===null||z(i)?t(i):n(i)}}const Lu={continuation:{tokenize:Rp},exit:Np,name:"blockQuote",tokenize:Ip};function Ip(e,t,n){const r=this;return a;function a(o){if(o===62){const s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),i}return n(o)}function i(o){return q(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Rp(e,t,n){const r=this;return a;function a(o){return q(o)?X(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return e.attempt(Lu,t,n)(o)}}function Np(e){e.exit("blockQuote")}const Du={name:"characterEscape",tokenize:vp};function vp(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),a}function a(i){return mp(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const Mu={name:"characterReference",tokenize:xp};function xp(e,t,n){const r=this;let a=0,i,o;return s;function s(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),l}function l(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,o=le,d(c))}function u(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,o=fp,d):(e.enter("characterReferenceValue"),i=7,o=Nn,d(c))}function d(c){if(c===59&&a){const p=e.exit("characterReferenceValue");return o===le&&!mt(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(c)&&a++<i?(e.consume(c),d):n(c)}}const Nl={partial:!0,tokenize:Op},vl={concrete:!0,name:"codeFenced",tokenize:Cp};function Cp(e,t,n){const r=this,a={partial:!0,tokenize:R};let i=0,o=0,s;return l;function l(w){return u(w)}function u(w){const C=r.events[r.events.length-1];return i=C&&C[1].type==="linePrefix"?C[2].sliceSerialize(C[1],!0).length:0,s=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===s?(o++,e.consume(w),d):o<3?n(w):(e.exit("codeFencedFenceSequence"),q(w)?X(e,c,"whitespace")(w):c(w))}function c(w){return w===null||z(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(Nl,y,I)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||z(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(w)):q(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),X(e,g,"whitespace")(w)):w===96&&w===s?n(w):(e.consume(w),p)}function g(w){return w===null||z(w)?c(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||z(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(w)):w===96&&w===s?n(w):(e.consume(w),m)}function y(w){return e.attempt(a,I,k)(w)}function k(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),E}function E(w){return i>0&&q(w)?X(e,A,"linePrefix",i+1)(w):A(w)}function A(w){return w===null||z(w)?e.check(Nl,y,I)(w):(e.enter("codeFlowValue"),S(w))}function S(w){return w===null||z(w)?(e.exit("codeFlowValue"),A(w)):(e.consume(w),S)}function I(w){return e.exit("codeFenced"),t(w)}function R(w,C,F){let $=0;return T;function T(x){return w.enter("lineEnding"),w.consume(x),w.exit("lineEnding"),O}function O(x){return w.enter("codeFencedFence"),q(x)?X(w,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):L(x)}function L(x){return x===s?(w.enter("codeFencedFenceSequence"),v(x)):F(x)}function v(x){return x===s?($++,w.consume(x),v):$>=o?(w.exit("codeFencedFenceSequence"),q(x)?X(w,M,"whitespace")(x):M(x)):F(x)}function M(x){return x===null||z(x)?(w.exit("codeFencedFence"),C(x)):F(x)}}}function Op(e,t,n){const r=this;return a;function a(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const on={name:"codeIndented",tokenize:Dp},Lp={partial:!0,tokenize:Mp};function Dp(e,t,n){const r=this;return a;function a(u){return e.enter("codeIndented"),X(e,i,"linePrefix",5)(u)}function i(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):z(u)?e.attempt(Lp,o,l)(u):(e.enter("codeFlowValue"),s(u))}function s(u){return u===null||z(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),s)}function l(u){return e.exit("codeIndented"),t(u)}}function Mp(e,t,n){const r=this;return a;function a(o){return r.parser.lazy[r.now().line]?n(o):z(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):X(e,i,"linePrefix",5)(o)}function i(o){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):z(o)?a(o):n(o)}}const Fp={name:"codeText",previous:Bp,resolve:Up,tokenize:Pp};function Up(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function Bp(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Pp(e,t,n){let r=0,a,i;return o;function o(c){return e.enter("codeText"),e.enter("codeTextSequence"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit("codeTextSequence"),l(c))}function l(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),l):c===96?(i=e.enter("codeTextSequence"),a=0,d(c)):z(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(c))}function u(c){return c===null||c===32||c===96||z(c)?(e.exit("codeTextData"),l(c)):(e.consume(c),u)}function d(c){return c===96?(e.consume(c),a++,d):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(i.type="codeTextData",u(c))}}class $p{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&st(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),st(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),st(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);st(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);st(this.left,n.reverse())}}}function st(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Fu(e){const t={};let n=-1,r,a,i,o,s,l,u;const d=new $p(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,i=0,i<l.length&&l[i][1].type==="lineEndingBlank"&&(i+=2),i<l.length&&l[i][1].type==="content"))for(;++i<l.length&&l[i][1].type!=="content";)l[i][1].type==="chunkText"&&(l[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,zp(d,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,a=void 0;i--;)if(o=d.get(i),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(a&&(d.get(a)[1].type="lineEndingBlank"),o[1].type="lineEnding",a=i);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;a&&(r[1].end={...d.get(a)[1].start},s=d.slice(a,n),s.unshift(r),d.splice(a,n-a+1,s))}}return Se(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function zp(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const i=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,l=[],u={};let d,c,p=-1,g=n,m=0,y=0;const k=[y];for(;g;){for(;e.get(++a)[1]!==g;);i.push(a),g._tokenizer||(d=r.sliceStream(g),g.next||d.push(null),c&&o.defineSkip(g.start),g._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),g._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=g,g=g.next}for(g=n;++p<s.length;)s[p][0]==="exit"&&s[p-1][0]==="enter"&&s[p][1].type===s[p-1][1].type&&s[p][1].start.line!==s[p][1].end.line&&(y=p+1,k.push(y),g._tokenizer=void 0,g.previous=void 0,g=g.next);for(o.events=[],g?(g._tokenizer=void 0,g.previous=void 0):k.pop(),p=k.length;p--;){const E=s.slice(k[p],k[p+1]),A=i.pop();l.push([A,A+E.length-1]),e.splice(A,2,E)}for(l.reverse(),p=-1;++p<l.length;)u[m+l[p][0]]=m+l[p][1],m+=l[p][1]-l[p][0]-1;return u}const Gp={resolve:Hp,tokenize:Vp},jp={partial:!0,tokenize:Wp};function Hp(e){return Fu(e),e}function Vp(e,t){let n;return r;function r(s){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(s)}function a(s){return s===null?i(s):z(s)?e.check(jp,o,i)(s):(e.consume(s),a)}function i(s){return e.exit("chunkContent"),e.exit("content"),t(s)}function o(s){return e.consume(s),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function Wp(e,t,n){const r=this;return a;function a(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),X(e,i,"linePrefix")}function i(o){if(o===null||z(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Uu(e,t,n,r,a,i,o,s,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return c;function c(E){return E===60?(e.enter(r),e.enter(a),e.enter(i),e.consume(E),e.exit(i),p):E===null||E===32||E===41||Ut(E)?n(E):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),y(E))}function p(E){return E===62?(e.enter(i),e.consume(E),e.exit(i),e.exit(a),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),g(E))}function g(E){return E===62?(e.exit("chunkString"),e.exit(s),p(E)):E===null||E===60||z(E)?n(E):(e.consume(E),E===92?m:g)}function m(E){return E===60||E===62||E===92?(e.consume(E),g):g(E)}function y(E){return!d&&(E===null||E===41||te(E))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(E)):d<u&&E===40?(e.consume(E),d++,y):E===41?(e.consume(E),d--,y):E===null||E===32||E===40||Ut(E)?n(E):(e.consume(E),E===92?k:y)}function k(E){return E===40||E===41||E===92?(e.consume(E),y):y(E)}}function Bu(e,t,n,r,a,i){const o=this;let s=0,l;return u;function u(g){return e.enter(r),e.enter(a),e.consume(g),e.exit(a),e.enter(i),d}function d(g){return s>999||g===null||g===91||g===93&&!l||g===94&&!s&&"_hiddenFootnoteSupport"in o.parser.constructs?n(g):g===93?(e.exit(i),e.enter(a),e.consume(g),e.exit(a),e.exit(r),t):z(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),c(g))}function c(g){return g===null||g===91||g===93||z(g)||s++>999?(e.exit("chunkString"),d(g)):(e.consume(g),l||(l=!q(g)),g===92?p:c)}function p(g){return g===91||g===92||g===93?(e.consume(g),s++,c):c(g)}}function Pu(e,t,n,r,a,i){let o;return s;function s(p){return p===34||p===39||p===40?(e.enter(r),e.enter(a),e.consume(p),e.exit(a),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(a),e.consume(p),e.exit(a),e.exit(r),t):(e.enter(i),u(p))}function u(p){return p===o?(e.exit(i),l(o)):p===null?n(p):z(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),X(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===o||p===null||z(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?c:d)}function c(p){return p===o||p===92?(e.consume(p),d):d(p)}}function ct(e,t){let n;return r;function r(a){return z(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):q(a)?X(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const qp={name:"definition",tokenize:Kp},Yp={partial:!0,tokenize:Xp};function Kp(e,t,n){const r=this;let a;return i;function i(g){return e.enter("definition"),o(g)}function o(g){return Bu.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(g)}function s(g){return a=Ae(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),l):n(g)}function l(g){return te(g)?ct(e,u)(g):u(g)}function u(g){return Uu(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(g)}function d(g){return e.attempt(Yp,c,c)(g)}function c(g){return q(g)?X(e,p,"whitespace")(g):p(g)}function p(g){return g===null||z(g)?(e.exit("definition"),r.parser.defined.push(a),t(g)):n(g)}}function Xp(e,t,n){return r;function r(s){return te(s)?ct(e,a)(s):n(s)}function a(s){return Pu(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function i(s){return q(s)?X(e,o,"whitespace")(s):o(s)}function o(s){return s===null||z(s)?t(s):n(s)}}const Zp={name:"hardBreakEscape",tokenize:Qp};function Qp(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),a}function a(i){return z(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const Jp={name:"headingAtx",resolve:eg,tokenize:tg};function eg(e,t){let n=e.length-2,r=3,a,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Se(e,r,n-r+1,[["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t]])),e}function tg(e,t,n){let r=0;return a;function a(d){return e.enter("atxHeading"),i(d)}function i(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||te(d)?(e.exit("atxHeadingSequence"),s(d)):n(d)}function s(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||z(d)?(e.exit("atxHeading"),t(d)):q(d)?X(e,s,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),s(d))}function u(d){return d===null||d===35||te(d)?(e.exit("atxHeadingText"),s(d)):(e.consume(d),u)}}const ng=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],xl=["pre","script","style","textarea"],rg={concrete:!0,name:"htmlFlow",resolveTo:og,tokenize:sg},ag={partial:!0,tokenize:ug},ig={partial:!0,tokenize:lg};function og(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function sg(e,t,n){const r=this;let a,i,o,s,l;return u;function u(h){return d(h)}function d(h){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(h),c}function c(h){return h===33?(e.consume(h),p):h===47?(e.consume(h),i=!0,y):h===63?(e.consume(h),a=3,r.interrupt?t:b):pe(h)?(e.consume(h),o=String.fromCharCode(h),k):n(h)}function p(h){return h===45?(e.consume(h),a=2,g):h===91?(e.consume(h),a=5,s=0,m):pe(h)?(e.consume(h),a=4,r.interrupt?t:b):n(h)}function g(h){return h===45?(e.consume(h),r.interrupt?t:b):n(h)}function m(h){const Z="CDATA[";return h===Z.charCodeAt(s++)?(e.consume(h),s===Z.length?r.interrupt?t:L:m):n(h)}function y(h){return pe(h)?(e.consume(h),o=String.fromCharCode(h),k):n(h)}function k(h){if(h===null||h===47||h===62||te(h)){const Z=h===47,ie=o.toLowerCase();return!Z&&!i&&xl.includes(ie)?(a=1,r.interrupt?t(h):L(h)):ng.includes(o.toLowerCase())?(a=6,Z?(e.consume(h),E):r.interrupt?t(h):L(h)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(h):i?A(h):S(h))}return h===45||le(h)?(e.consume(h),o+=String.fromCharCode(h),k):n(h)}function E(h){return h===62?(e.consume(h),r.interrupt?t:L):n(h)}function A(h){return q(h)?(e.consume(h),A):T(h)}function S(h){return h===47?(e.consume(h),T):h===58||h===95||pe(h)?(e.consume(h),I):q(h)?(e.consume(h),S):T(h)}function I(h){return h===45||h===46||h===58||h===95||le(h)?(e.consume(h),I):R(h)}function R(h){return h===61?(e.consume(h),w):q(h)?(e.consume(h),R):S(h)}function w(h){return h===null||h===60||h===61||h===62||h===96?n(h):h===34||h===39?(e.consume(h),l=h,C):q(h)?(e.consume(h),w):F(h)}function C(h){return h===l?(e.consume(h),l=null,$):h===null||z(h)?n(h):(e.consume(h),C)}function F(h){return h===null||h===34||h===39||h===47||h===60||h===61||h===62||h===96||te(h)?R(h):(e.consume(h),F)}function $(h){return h===47||h===62||q(h)?S(h):n(h)}function T(h){return h===62?(e.consume(h),O):n(h)}function O(h){return h===null||z(h)?L(h):q(h)?(e.consume(h),O):n(h)}function L(h){return h===45&&a===2?(e.consume(h),j):h===60&&a===1?(e.consume(h),V):h===62&&a===4?(e.consume(h),P):h===63&&a===3?(e.consume(h),b):h===93&&a===5?(e.consume(h),ne):z(h)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(ag,G,v)(h)):h===null||z(h)?(e.exit("htmlFlowData"),v(h)):(e.consume(h),L)}function v(h){return e.check(ig,M,G)(h)}function M(h){return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),x}function x(h){return h===null||z(h)?v(h):(e.enter("htmlFlowData"),L(h))}function j(h){return h===45?(e.consume(h),b):L(h)}function V(h){return h===47?(e.consume(h),o="",J):L(h)}function J(h){if(h===62){const Z=o.toLowerCase();return xl.includes(Z)?(e.consume(h),P):L(h)}return pe(h)&&o.length<8?(e.consume(h),o+=String.fromCharCode(h),J):L(h)}function ne(h){return h===93?(e.consume(h),b):L(h)}function b(h){return h===62?(e.consume(h),P):h===45&&a===2?(e.consume(h),b):L(h)}function P(h){return h===null||z(h)?(e.exit("htmlFlowData"),G(h)):(e.consume(h),P)}function G(h){return e.exit("htmlFlow"),t(h)}}function lg(e,t,n){const r=this;return a;function a(o){return z(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):n(o)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function ug(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(yt,t,n)}}const cg={name:"htmlText",tokenize:dg};function dg(e,t,n){const r=this;let a,i,o;return s;function s(b){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(b),l}function l(b){return b===33?(e.consume(b),u):b===47?(e.consume(b),R):b===63?(e.consume(b),S):pe(b)?(e.consume(b),F):n(b)}function u(b){return b===45?(e.consume(b),d):b===91?(e.consume(b),i=0,m):pe(b)?(e.consume(b),A):n(b)}function d(b){return b===45?(e.consume(b),g):n(b)}function c(b){return b===null?n(b):b===45?(e.consume(b),p):z(b)?(o=c,V(b)):(e.consume(b),c)}function p(b){return b===45?(e.consume(b),g):c(b)}function g(b){return b===62?j(b):b===45?p(b):c(b)}function m(b){const P="CDATA[";return b===P.charCodeAt(i++)?(e.consume(b),i===P.length?y:m):n(b)}function y(b){return b===null?n(b):b===93?(e.consume(b),k):z(b)?(o=y,V(b)):(e.consume(b),y)}function k(b){return b===93?(e.consume(b),E):y(b)}function E(b){return b===62?j(b):b===93?(e.consume(b),E):y(b)}function A(b){return b===null||b===62?j(b):z(b)?(o=A,V(b)):(e.consume(b),A)}function S(b){return b===null?n(b):b===63?(e.consume(b),I):z(b)?(o=S,V(b)):(e.consume(b),S)}function I(b){return b===62?j(b):S(b)}function R(b){return pe(b)?(e.consume(b),w):n(b)}function w(b){return b===45||le(b)?(e.consume(b),w):C(b)}function C(b){return z(b)?(o=C,V(b)):q(b)?(e.consume(b),C):j(b)}function F(b){return b===45||le(b)?(e.consume(b),F):b===47||b===62||te(b)?$(b):n(b)}function $(b){return b===47?(e.consume(b),j):b===58||b===95||pe(b)?(e.consume(b),T):z(b)?(o=$,V(b)):q(b)?(e.consume(b),$):j(b)}function T(b){return b===45||b===46||b===58||b===95||le(b)?(e.consume(b),T):O(b)}function O(b){return b===61?(e.consume(b),L):z(b)?(o=O,V(b)):q(b)?(e.consume(b),O):$(b)}function L(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),a=b,v):z(b)?(o=L,V(b)):q(b)?(e.consume(b),L):(e.consume(b),M)}function v(b){return b===a?(e.consume(b),a=void 0,x):b===null?n(b):z(b)?(o=v,V(b)):(e.consume(b),v)}function M(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||te(b)?$(b):(e.consume(b),M)}function x(b){return b===47||b===62||te(b)?$(b):n(b)}function j(b){return b===62?(e.consume(b),e.exit("htmlTextData"),e.exit("htmlText"),t):n(b)}function V(b){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),J}function J(b){return q(b)?X(e,ne,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):ne(b)}function ne(b){return e.enter("htmlTextData"),o(b)}}const Yn={name:"labelEnd",resolveAll:mg,resolveTo:bg,tokenize:hg},pg={tokenize:Eg},gg={tokenize:yg},fg={tokenize:Sg};function mg(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&Se(e,0,e.length,n),e}function bg(e,t){let n=e.length,r=0,a,i,o,s;for(;n--;)if(a=e[n][1],i){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(i=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(o=n);const l={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[o-2][1].start}};return s=[["enter",l,t],["enter",u,t]],s=ke(s,e.slice(i+1,i+r+3)),s=ke(s,[["enter",d,t]]),s=ke(s,jt(t.parser.constructs.insideSpan.null,e.slice(i+r+4,o-3),t)),s=ke(s,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),s=ke(s,e.slice(o+1)),s=ke(s,[["exit",l,t]]),Se(e,i,e.length,s),e}function hg(e,t,n){const r=this;let a=r.events.length,i,o;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){i=r.events[a][1];break}return s;function s(p){return i?i._inactive?c(p):(o=r.parser.defined.includes(Ae(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(pg,d,o?d:c)(p):p===91?e.attempt(gg,d,o?u:c)(p):o?d(p):c(p)}function u(p){return e.attempt(fg,d,c)(p)}function d(p){return t(p)}function c(p){return i._balanced=!0,n(p)}}function Eg(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),a}function a(c){return te(c)?ct(e,i)(c):i(c)}function i(c){return c===41?d(c):Uu(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function o(c){return te(c)?ct(e,l)(c):d(c)}function s(c){return n(c)}function l(c){return c===34||c===39||c===40?Pu(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):d(c)}function u(c){return te(c)?ct(e,d)(c):d(c)}function d(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function yg(e,t,n){const r=this;return a;function a(s){return Bu.call(r,e,i,o,"reference","referenceMarker","referenceString")(s)}function i(s){return r.parser.defined.includes(Ae(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Sg(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),a}function a(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const kg={name:"labelStartImage",resolveAll:Yn.resolveAll,tokenize:wg};function wg(e,t,n){const r=this;return a;function a(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),i}function i(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),o):n(s)}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}const Tg={name:"labelStartLink",resolveAll:Yn.resolveAll,tokenize:Ag};function Ag(e,t,n){const r=this;return a;function a(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),i}function i(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const sn={name:"lineEnding",tokenize:_g};function _g(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),X(e,t,"linePrefix")}}const Lt={name:"thematicBreak",tokenize:Ig};function Ig(e,t,n){let r=0,a;return i;function i(u){return e.enter("thematicBreak"),o(u)}function o(u){return a=u,s(u)}function s(u){return u===a?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||z(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===a?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),q(u)?X(e,s,"whitespace")(u):s(u))}}const ge={continuation:{tokenize:xg},exit:Og,name:"list",tokenize:vg},Rg={partial:!0,tokenize:Lg},Ng={partial:!0,tokenize:Cg};function vg(e,t,n){const r=this,a=r.events[r.events.length-1];let i=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,o=0;return s;function s(g){const m=r.containerState.type||(g===42||g===43||g===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||g===r.containerState.marker:Nn(g)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),g===42||g===45?e.check(Lt,n,u)(g):u(g);if(!r.interrupt||g===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(g)}return n(g)}function l(g){return Nn(g)&&++o<10?(e.consume(g),l):(!r.interrupt||o<2)&&(r.containerState.marker?g===r.containerState.marker:g===41||g===46)?(e.exit("listItemValue"),u(g)):n(g)}function u(g){return e.enter("listItemMarker"),e.consume(g),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||g,e.check(yt,r.interrupt?n:d,e.attempt(Rg,p,c))}function d(g){return r.containerState.initialBlankLine=!0,i++,p(g)}function c(g){return q(g)?(e.enter("listItemPrefixWhitespace"),e.consume(g),e.exit("listItemPrefixWhitespace"),p):n(g)}function p(g){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(g)}}function xg(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(yt,a,i);function a(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,"listItemIndent",r.containerState.size+1)(s)}function i(s){return r.containerState.furtherBlankLines||!q(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ng,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(ge,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Cg(e,t,n){const r=this;return X(e,a,"listItemIndent",r.containerState.size+1);function a(i){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(i):n(i)}}function Og(e){e.exit(this.containerState.type)}function Lg(e,t,n){const r=this;return X(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(i){const o=r.events[r.events.length-1];return!q(i)&&o&&o[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const Cl={name:"setextUnderline",resolveTo:Dg,tokenize:Mg};function Dg(e,t){let n=e.length,r,a,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",i?(e.splice(a,0,["enter",o,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Mg(e,t,n){const r=this;let a;return i;function i(u){let d=r.events.length,c;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){c=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),a=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),s(u)}function s(u){return u===a?(e.consume(u),s):(e.exit("setextHeadingLineSequence"),q(u)?X(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||z(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Fg={tokenize:Ug};function Ug(e){const t=this,n=e.attempt(yt,r,e.attempt(this.parser.constructs.flowInitial,a,X(e,e.attempt(this.parser.constructs.flow,a,e.attempt(Gp,a)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Bg={resolveAll:zu()},Pg=$u("string"),$g=$u("text");function $u(e){return{resolveAll:zu(e==="text"?zg:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],i=n.attempt(a,o,s);return o;function o(d){return u(d)?i(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return u(d)?(n.exit("data"),i(d)):(n.consume(d),l)}function u(d){if(d===null)return!0;const c=a[d];let p=-1;if(c)for(;++p<c.length;){const g=c[p];if(!g.previous||g.previous.call(r,r.previous))return!0}return!1}}}function zu(e){return t;function t(n,r){let a=-1,i;for(;++a<=n.length;)i===void 0?n[a]&&n[a][1].type==="data"&&(i=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==i+2&&(n[i][1].end=n[a-1][1].end,n.splice(i+2,a-i-2),a=i+2),i=void 0);return e?e(n,r):n}}function zg(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let i=a.length,o=-1,s=0,l;for(;i--;){const u=a[i];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(u===-2)l=!0,s++;else if(u!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const u={type:n===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:r.start._bufferIndex+o,_index:r.start._index+i,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Gg={42:ge,43:ge,45:ge,48:ge,49:ge,50:ge,51:ge,52:ge,53:ge,54:ge,55:ge,56:ge,57:ge,62:Lu},jg={91:qp},Hg={[-2]:on,[-1]:on,32:on},Vg={35:Jp,42:Lt,45:[Cl,Lt],60:rg,61:Cl,95:Lt,96:vl,126:vl},Wg={38:Mu,92:Du},qg={[-5]:sn,[-4]:sn,[-3]:sn,33:kg,38:Mu,42:vn,60:[Tp,cg],91:Tg,92:[Zp,Du],93:Yn,95:vn,96:Fp},Yg={null:[vn,Bg]},Kg={null:[42,95]},Xg={null:[]},Zg=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Kg,contentInitial:jg,disable:Xg,document:Gg,flow:Vg,flowInitial:Hg,insideSpan:Yg,string:Wg,text:qg},Symbol.toStringTag,{value:"Module"}));function Qg(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},i=[];let o=[],s=[];const l={attempt:C(R),check:C(w),consume:A,enter:S,exit:I,interrupt:C(w,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:g,write:c};let d=t.tokenize.call(u,l);return t.resolveAll&&i.push(t),u;function c(O){return o=ke(o,O),k(),o[o.length-1]!==null?[]:(F(t,0),u.events=jt(i,u.events,u),u.events)}function p(O,L){return ef(g(O),L)}function g(O){return Jg(o,O)}function m(){const{_bufferIndex:O,_index:L,line:v,column:M,offset:x}=r;return{_bufferIndex:O,_index:L,line:v,column:M,offset:x}}function y(O){a[O.line]=O.column,T()}function k(){let O;for(;r._index<o.length;){const L=o[r._index];if(typeof L=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<L.length;)E(L.charCodeAt(r._bufferIndex));else E(L)}}function E(O){d=d(O)}function A(O){z(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,T()):O!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=O}function S(O,L){const v=L||{};return v.type=O,v.start=m(),u.events.push(["enter",v,u]),s.push(v),v}function I(O){const L=s.pop();return L.end=m(),u.events.push(["exit",L,u]),L}function R(O,L){F(O,L.from)}function w(O,L){L.restore()}function C(O,L){return v;function v(M,x,j){let V,J,ne,b;return Array.isArray(M)?G(M):"tokenize"in M?G([M]):P(M);function P(Q){return be;function be(he){const we=he!==null&&Q[he],Oe=he!==null&&Q.null,ze=[...Array.isArray(we)?we:we?[we]:[],...Array.isArray(Oe)?Oe:Oe?[Oe]:[]];return G(ze)(he)}}function G(Q){return V=Q,J=0,Q.length===0?j:h(Q[J])}function h(Q){return be;function be(he){return b=$(),ne=Q,Q.partial||(u.currentConstruct=Q),Q.name&&u.parser.constructs.disable.null.includes(Q.name)?ie():Q.tokenize.call(L?Object.assign(Object.create(u),L):u,l,Z,ie)(he)}}function Z(Q){return O(ne,b),x}function ie(Q){return b.restore(),++J<V.length?h(V[J]):j}}}function F(O,L){O.resolveAll&&!i.includes(O)&&i.push(O),O.resolve&&Se(u.events,L,u.events.length-L,O.resolve(u.events.slice(L),u)),O.resolveTo&&(u.events=O.resolveTo(u.events,u))}function $(){const O=m(),L=u.previous,v=u.currentConstruct,M=u.events.length,x=Array.from(s);return{from:M,restore:j};function j(){r=O,u.previous=L,u.currentConstruct=v,u.events.length=M,s=x,T()}}function T(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function Jg(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,i=t.end._bufferIndex;let o;if(n===a)o=[e[n].slice(r,i)];else{if(o=e.slice(n,a),r>-1){const s=o[0];typeof s=="string"?o[0]=s.slice(r):o.shift()}i>0&&o.push(e[a].slice(0,i))}return o}function ef(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const i=e[n];let o;if(typeof i=="string")o=i;else switch(i){case-5:{o="\r";break}case-4:{o=`
3
3
  `;break}case-3:{o=`\r
4
4
  `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&a)continue;o=" ";break}default:o=String.fromCharCode(i)}a=i===-2,r.push(o)}return r.join("")}function tf(e){const r={constructs:Cu([Zg,...(e||{}).extensions||[]]),content:a(bp),defined:[],document:a(Ep),flow:a(Fg),lazy:{},string:a(Pg),text:a($g)};return r;function a(i){return o;function o(s){return Qg(r,i,s)}}}function nf(e){for(;!Fu(e););return e}const Ol=/[\0\t\n\r]/g;function rf(){let e=1,t="",n=!0,r;return a;function a(i,o,s){const l=[];let u,d,c,p,g;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(o||void 0).decode(i)),c=0,t="",n&&(i.charCodeAt(0)===65279&&c++,n=void 0);c<i.length;){if(Ol.lastIndex=c,u=Ol.exec(i),p=u&&u.index!==void 0?u.index:i.length,g=i.charCodeAt(p),!u){t=i.slice(c);break}if(g===10&&c===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),c<p&&(l.push(i.slice(c,p)),e+=p-c),g){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return s&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const af=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function of(e){return e.replace(af,sf)}function sf(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),i=a===120||a===88;return Ou(n.slice(i?2:1),i?16:10)}return mt(n)||e}const Gu={}.hasOwnProperty;function lf(e,t,n){return typeof t!="string"&&(n=t,t=void 0),uf(n)(nf(tf(n).document().write(rf()(e,t,!0))))}function uf(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(ll),autolinkProtocol:$,autolinkEmail:$,atxHeading:i(il),blockQuote:i(Oe),characterEscape:$,characterReference:$,codeFenced:i(ze),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i(ze,o),codeText:i(Lc,o),codeTextData:$,data:$,codeFlowValue:$,definition:i(Dc),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(Mc),hardBreakEscape:i(ol),hardBreakTrailing:i(ol),htmlFlow:i(sl,o),htmlFlowData:$,htmlText:i(sl,o),htmlTextData:$,image:i(Fc),label:o,link:i(ll),listItem:i(Uc),listItemValue:p,listOrdered:i(ul,c),listUnordered:i(ul),paragraph:i(Bc),reference:h,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(il),strong:i(Pc),thematicBreak:i(zc)},exit:{atxHeading:l(),atxHeadingSequence:R,autolink:l(),autolinkEmail:we,autolinkProtocol:he,blockQuote:l(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:Q,characterReference:be,codeFenced:l(k),codeFencedFence:y,codeFencedFenceInfo:g,codeFencedFenceMeta:m,codeFlowValue:T,codeIndented:l(E),codeText:l(x),codeTextData:T,data:T,definition:l(),definitionDestinationString:I,definitionLabelString:A,definitionTitleString:S,emphasis:l(),hardBreakEscape:l(L),hardBreakTrailing:l(L),htmlFlow:l(v),htmlFlowData:T,htmlText:l(M),htmlTextData:T,image:l(V),label:ne,labelText:J,lineEnding:O,link:l(j),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Z,resourceDestinationString:b,resourceTitleString:P,resource:G,setextHeading:l(F),setextHeadingLineSequence:C,setextHeadingText:w,strong:l(),thematicBreak:l()}};ju(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(N){let U={type:"root",children:[]};const H={stack:[U],tokenStack:[],config:t,enter:s,exit:u,buffer:o,resume:d,data:n},K=[];let ee=-1;for(;++ee<N.length;)if(N[ee][1].type==="listOrdered"||N[ee][1].type==="listUnordered")if(N[ee][0]==="enter")K.push(ee);else{const Te=K.pop();ee=a(N,Te,ee)}for(ee=-1;++ee<N.length;){const Te=t[N[ee][0]];Gu.call(Te,N[ee][1].type)&&Te[N[ee][1].type].call(Object.assign({sliceSerialize:N[ee][2].sliceSerialize},H),N[ee][1])}if(H.tokenStack.length>0){const Te=H.tokenStack[H.tokenStack.length-1];(Te[1]||Ll).call(H,void 0,Te[0])}for(U.position={start:Le(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:Le(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},ee=-1;++ee<t.transforms.length;)U=t.transforms[ee](U)||U;return U}function a(N,U,H){let K=U-1,ee=-1,Te=!1,Fe,Ne,rt,at;for(;++K<=H;){const Ee=N[K];switch(Ee[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ee[0]==="enter"?ee++:ee--,at=void 0;break}case"lineEndingBlank":{Ee[0]==="enter"&&(Fe&&!at&&!ee&&!rt&&(rt=K),at=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:at=void 0}if(!ee&&Ee[0]==="enter"&&Ee[1].type==="listItemPrefix"||ee===-1&&Ee[0]==="exit"&&(Ee[1].type==="listUnordered"||Ee[1].type==="listOrdered")){if(Fe){let Ge=K;for(Ne=void 0;Ge--;){const ve=N[Ge];if(ve[1].type==="lineEnding"||ve[1].type==="lineEndingBlank"){if(ve[0]==="exit")continue;Ne&&(N[Ne][1].type="lineEndingBlank",Te=!0),ve[1].type="lineEnding",Ne=Ge}else if(!(ve[1].type==="linePrefix"||ve[1].type==="blockQuotePrefix"||ve[1].type==="blockQuotePrefixWhitespace"||ve[1].type==="blockQuoteMarker"||ve[1].type==="listItemIndent"))break}rt&&(!Ne||rt<Ne)&&(Fe._spread=!0),Fe.end=Object.assign({},Ne?N[Ne][1].start:Ee[1].end),N.splice(Ne||K,0,["exit",Fe,Ee[2]]),K++,H++}if(Ee[1].type==="listItemPrefix"){const Ge={type:"listItem",_spread:!1,start:Object.assign({},Ee[1].start),end:void 0};Fe=Ge,N.splice(K,0,["enter",Ge,Ee[2]]),K++,H++,rt=void 0,at=!0}}}return N[U][1]._spread=Te,H}function i(N,U){return H;function H(K){s.call(this,N(K),K),U&&U.call(this,K)}}function o(){this.stack.push({type:"fragment",children:[]})}function s(N,U,H){this.stack[this.stack.length-1].children.push(N),this.stack.push(N),this.tokenStack.push([U,H||void 0]),N.position={start:Le(U.start),end:void 0}}function l(N){return U;function U(H){N&&N.call(this,H),u.call(this,H)}}function u(N,U){const H=this.stack.pop(),K=this.tokenStack.pop();if(K)K[0].type!==N.type&&(U?U.call(this,N,K[0]):(K[1]||Ll).call(this,N,K[0]));else throw new Error("Cannot close `"+N.type+"` ("+ut({start:N.start,end:N.end})+"): it’s not open");H.position.end=Le(N.end)}function d(){return qn(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(N){if(this.data.expectingFirstListItemValue){const U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(N),10),this.data.expectingFirstListItemValue=void 0}}function g(){const N=this.resume(),U=this.stack[this.stack.length-1];U.lang=N}function m(){const N=this.resume(),U=this.stack[this.stack.length-1];U.meta=N}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const N=this.resume(),U=this.stack[this.stack.length-1];U.value=N.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const N=this.resume(),U=this.stack[this.stack.length-1];U.value=N.replace(/(\r?\n|\r)$/g,"")}function A(N){const U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Ae(this.sliceSerialize(N)).toLowerCase()}function S(){const N=this.resume(),U=this.stack[this.stack.length-1];U.title=N}function I(){const N=this.resume(),U=this.stack[this.stack.length-1];U.url=N}function R(N){const U=this.stack[this.stack.length-1];if(!U.depth){const H=this.sliceSerialize(N).length;U.depth=H}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function C(N){const U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(N).codePointAt(0)===61?1:2}function F(){this.data.setextHeadingSlurpLineEnding=void 0}function $(N){const H=this.stack[this.stack.length-1].children;let K=H[H.length-1];(!K||K.type!=="text")&&(K=$c(),K.position={start:Le(N.start),end:void 0},H.push(K)),this.stack.push(K)}function T(N){const U=this.stack.pop();U.value+=this.sliceSerialize(N),U.position.end=Le(N.end)}function O(N){const U=this.stack[this.stack.length-1];if(this.data.atHardBreak){const H=U.children[U.children.length-1];H.position.end=Le(N.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(U.type)&&($.call(this,N),T.call(this,N))}function L(){this.data.atHardBreak=!0}function v(){const N=this.resume(),U=this.stack[this.stack.length-1];U.value=N}function M(){const N=this.resume(),U=this.stack[this.stack.length-1];U.value=N}function x(){const N=this.resume(),U=this.stack[this.stack.length-1];U.value=N}function j(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=U,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function V(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=U,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function J(N){const U=this.sliceSerialize(N),H=this.stack[this.stack.length-2];H.label=of(U),H.identifier=Ae(U).toLowerCase()}function ne(){const N=this.stack[this.stack.length-1],U=this.resume(),H=this.stack[this.stack.length-1];if(this.data.inReference=!0,H.type==="link"){const K=N.children;H.children=K}else H.alt=U}function b(){const N=this.resume(),U=this.stack[this.stack.length-1];U.url=N}function P(){const N=this.resume(),U=this.stack[this.stack.length-1];U.title=N}function G(){this.data.inReference=void 0}function h(){this.data.referenceType="collapsed"}function Z(N){const U=this.resume(),H=this.stack[this.stack.length-1];H.label=U,H.identifier=Ae(this.sliceSerialize(N)).toLowerCase(),this.data.referenceType="full"}function ie(N){this.data.characterReferenceType=N.type}function Q(N){const U=this.sliceSerialize(N),H=this.data.characterReferenceType;let K;H?(K=Ou(U,H==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):K=mt(U);const ee=this.stack[this.stack.length-1];ee.value+=K}function be(N){const U=this.stack.pop();U.position.end=Le(N.end)}function he(N){T.call(this,N);const U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(N)}function we(N){T.call(this,N);const U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(N)}function Oe(){return{type:"blockquote",children:[]}}function ze(){return{type:"code",lang:null,meta:null,value:""}}function Lc(){return{type:"inlineCode",value:""}}function Dc(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Mc(){return{type:"emphasis",children:[]}}function il(){return{type:"heading",depth:0,children:[]}}function ol(){return{type:"break"}}function sl(){return{type:"html",value:""}}function Fc(){return{type:"image",title:null,url:"",alt:null}}function ll(){return{type:"link",title:null,url:"",children:[]}}function ul(N){return{type:"list",ordered:N.type==="listOrdered",start:null,spread:N._spread,children:[]}}function Uc(N){return{type:"listItem",spread:N._spread,checked:null,children:[]}}function Bc(){return{type:"paragraph",children:[]}}function Pc(){return{type:"strong",children:[]}}function $c(){return{type:"text",value:""}}function zc(){return{type:"thematicBreak"}}}function Le(e){return{line:e.line,column:e.column,offset:e.offset}}function ju(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ju(e,r):cf(e,r)}}function cf(e,t){let n;for(n in t)if(Gu.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Ll(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ut({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ut({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ut({start:t.start,end:t.end})+") is still open")}function df(e){const t=this;t.parser=n;function n(r){return lf(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function pf(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function gf(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -14,4 +14,4 @@ Error generating stack: `+a.message+`
14
14
  ${K}px !important;
15
15
  ${X}px !important;
16
16
  }
17
- `),()=>{Z.contains(J)&&Z.removeChild(J)}},[l]),b.jsx(s2,{isPresent:l,childRef:m,sizeRef:g,pop:d,children:d===!1?i:_.cloneElement(i,{ref:x})})}const o2=({children:i,initial:l,isPresent:u,onExitComplete:o,custom:c,presenceAffectsLayout:d,mode:h,anchorX:m,anchorY:g,root:p})=>{const v=tf(r2),x=_.useId();let T=!0,N=_.useMemo(()=>(T=!1,{id:x,initial:l,isPresent:u,custom:c,onExitComplete:z=>{v.set(z,!0);for(const q of v.values())if(!q)return;o&&o()},register:z=>(v.set(z,!1),()=>v.delete(z))}),[u,v,o]);return d&&T&&(N={...N}),_.useMemo(()=>{v.forEach((z,q)=>v.set(q,!1))},[u]),_.useEffect(()=>{!u&&!v.size&&o&&o()},[u]),i=b.jsx(u2,{pop:h==="popLayout",isPresent:u,anchorX:m,anchorY:g,root:p,children:i}),b.jsx(qu.Provider,{value:N,children:i})};function r2(){return new Map}function Cg(i=!0){const l=_.useContext(qu);if(l===null)return[!0,null];const{isPresent:u,onExitComplete:o,register:c}=l,d=_.useId();_.useEffect(()=>{if(i)return c(d)},[i]);const h=_.useCallback(()=>i&&o&&o(d),[d,o,i]);return!u&&o?[!1,h]:[!0]}const Eu=i=>i.key||"";function Vy(i){const l=[];return _.Children.forEach(i,u=>{_.isValidElement(u)&&l.push(u)}),l}const c2=({children:i,custom:l,initial:u=!0,onExitComplete:o,presenceAffectsLayout:c=!0,mode:d="sync",propagate:h=!1,anchorX:m="left",anchorY:g="top",root:p})=>{const[v,x]=Cg(h),T=_.useMemo(()=>Vy(i),[i]),N=h&&!v?[]:T.map(Eu),z=_.useRef(!0),q=_.useRef(T),G=tf(()=>new Map),H=_.useRef(new Set),[K,X]=_.useState(T),[J,Z]=_.useState(T);Iy(()=>{z.current=!1,q.current=T;for(let F=0;F<J.length;F++){const lt=Eu(J[F]);N.includes(lt)?(G.delete(lt),H.current.delete(lt)):G.get(lt)!==!0&&G.set(lt,!1)}},[J,N.length,N.join("-")]);const nt=[];if(T!==K){let F=[...T];for(let lt=0;lt<J.length;lt++){const xt=J[lt],_t=Eu(xt);N.includes(_t)||(F.splice(lt,0,xt),nt.push(xt))}return d==="wait"&&nt.length&&(F=nt),Z(Vy(F)),X(T),null}const{forceRender:I}=_.useContext(Ic);return b.jsx(b.Fragment,{children:J.map(F=>{const lt=Eu(F),xt=h&&!v?!1:T===J||N.includes(lt),_t=()=>{if(H.current.has(lt))return;if(H.current.add(lt),G.has(lt))G.set(lt,!0);else return;let zt=!0;G.forEach(jt=>{jt||(zt=!1)}),zt&&(I?.(),Z(q.current),h&&x?.(),o&&o())};return b.jsx(o2,{isPresent:xt,initial:!z.current||u?void 0:!1,custom:l,presenceAffectsLayout:c,mode:d,root:p,onExitComplete:xt?void 0:_t,anchorX:m,anchorY:g,children:F},lt)})})},Mg=_.createContext({strict:!1}),_y={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Uy=!1;function f2(){if(Uy)return;const i={};for(const l in _y)i[l]={isEnabled:u=>_y[l].some(o=>!!u[o])};eg(i),Uy=!0}function Dg(){return f2(),PS()}function h2(i){const l=Dg();for(const u in i)l[u]={...l[u],...i[u]};eg(l)}const d2=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Yu(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||d2.has(i)}let wg=i=>!Yu(i);function m2(i){typeof i=="function"&&(wg=l=>l.startsWith("on")?!Yu(l):i(l))}try{m2(require("@emotion/is-prop-valid").default)}catch{}function p2(i,l,u){const o={};for(const c in i)c==="values"&&typeof i.values=="object"||(wg(c)||u===!0&&Yu(c)||!l&&!Yu(c)||i.draggable&&c.startsWith("onDrag"))&&(o[c]=i[c]);return o}const Ku=_.createContext({});function y2(i,l){if(Xu(i)){const{initial:u,animate:o}=i;return{initial:u===!1||$l(u)?u:void 0,animate:$l(o)?o:void 0}}return i.inherit!==!1?l:{}}function g2(i){const{initial:l,animate:u}=y2(i,_.useContext(Ku));return _.useMemo(()=>({initial:l,animate:u}),[By(l),By(u)])}function By(i){return Array.isArray(i)?i.join(" "):i}const Nf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ng(i,l,u){for(const o in l)!he(l[o])&&!og(o,u)&&(i[o]=l[o])}function v2({transformTemplate:i},l){return _.useMemo(()=>{const u=Nf();return Mf(u,l,i),Object.assign({},u.vars,u.style)},[l])}function x2(i,l){const u=i.style||{},o={};return Ng(o,u,i),Object.assign(o,v2(i,l)),o}function b2(i,l){const u={},o=x2(i,l);return i.drag&&i.dragListener!==!1&&(u.draggable=!1,o.userSelect=o.WebkitUserSelect=o.WebkitTouchCallout="none",o.touchAction=i.drag===!0?"none":`pan-${i.drag==="x"?"y":"x"}`),i.tabIndex===void 0&&(i.onTap||i.onTapStart||i.whileTap)&&(u.tabIndex=0),u.style=o,u}const jg=()=>({...Nf(),attrs:{}});function S2(i,l,u,o){const c=_.useMemo(()=>{const d=jg();return rg(d,l,fg(o),i.transformTemplate,i.style),{...d.attrs,style:{...d.style}}},[l]);if(i.style){const d={};Ng(d,i.style,i),c.style={...d,...c.style}}return c}const T2=["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 jf(i){return typeof i!="string"||i.includes("-")?!1:!!(T2.indexOf(i)>-1||/[A-Z]/u.test(i))}function A2(i,l,u,{latestValues:o},c,d=!1,h){const g=(h??jf(i)?S2:b2)(l,o,c,i),p=p2(l,typeof i=="string",d),v=i!==_.Fragment?{...p,...g,ref:u}:{},{children:x}=l,T=_.useMemo(()=>he(x)?x.get():x,[x]);return _.createElement(i,{...v,children:T})}function E2({scrapeMotionValuesFromProps:i,createRenderState:l},u,o,c){return{latestValues:C2(u,o,c,i),renderState:l()}}function C2(i,l,u,o){const c={},d=o(i,{});for(const T in d)c[T]=Ou(d[T]);let{initial:h,animate:m}=i;const g=Xu(i),p=I0(i);l&&p&&!g&&i.inherit!==!1&&(h===void 0&&(h=l.initial),m===void 0&&(m=l.animate));let v=u?u.initial===!1:!1;v=v||h===!1;const x=v?m:h;if(x&&typeof x!="boolean"&&!Gu(x)){const T=Array.isArray(x)?x:[x];for(let N=0;N<T.length;N++){const z=vf(i,T[N]);if(z){const{transitionEnd:q,transition:G,...H}=z;for(const K in H){let X=H[K];if(Array.isArray(X)){const J=v?X.length-1:0;X=X[J]}X!==null&&(c[K]=X)}for(const K in q)c[K]=q[K]}}}return c}const Og=i=>(l,u)=>{const o=_.useContext(Ku),c=_.useContext(qu),d=()=>E2(i,l,o,c);return u?d():tf(d)},M2=Og({scrapeMotionValuesFromProps:Df,createRenderState:Nf}),D2=Og({scrapeMotionValuesFromProps:hg,createRenderState:jg}),w2=Symbol.for("motionComponentSymbol");function N2(i,l,u){const o=_.useRef(u);_.useInsertionEffect(()=>{o.current=u});const c=_.useRef(null);return _.useCallback(d=>{d&&i.onMount?.(d),l&&(d?l.mount(d):l.unmount());const h=o.current;if(typeof h=="function")if(d){const m=h(d);typeof m=="function"&&(c.current=m)}else c.current?(c.current(),c.current=null):h(d);else h&&(h.current=d)},[l])}const zg=_.createContext({});function zi(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}function j2(i,l,u,o,c,d){const{visualElement:h}=_.useContext(Ku),m=_.useContext(Mg),g=_.useContext(qu),p=_.useContext(wf),v=p.reducedMotion,x=p.skipAnimations,T=_.useRef(null),N=_.useRef(!1);o=o||m.renderer,!T.current&&o&&(T.current=o(i,{visualState:l,parent:h,props:u,presenceContext:g,blockInitialAnimation:g?g.initial===!1:!1,reducedMotionConfig:v,skipAnimations:x,isSVG:d}),N.current&&T.current&&(T.current.manuallyAnimateOnMount=!0));const z=T.current,q=_.useContext(zg);z&&!z.projection&&c&&(z.type==="html"||z.type==="svg")&&O2(T.current,u,c,q);const G=_.useRef(!1);_.useInsertionEffect(()=>{z&&G.current&&z.update(u,g)});const H=u[Y0],K=_.useRef(!!H&&!window.MotionHandoffIsComplete?.(H)&&window.MotionHasOptimisedAnimation?.(H));return Iy(()=>{N.current=!0,z&&(G.current=!0,window.MotionIsMounted=!0,z.updateFeatures(),z.scheduleRenderMicrotask(),K.current&&z.animationState&&z.animationState.animateChanges())}),_.useEffect(()=>{z&&(!K.current&&z.animationState&&z.animationState.animateChanges(),K.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(H)}),K.current=!1),z.enteringChildren=void 0)}),z}function O2(i,l,u,o){const{layoutId:c,layout:d,drag:h,dragConstraints:m,layoutScroll:g,layoutRoot:p,layoutCrossfade:v}=l;i.projection=new u(i.latestValues,l["data-framer-portal-id"]?void 0:Rg(i.parent)),i.projection.setOptions({layoutId:c,layout:d,alwaysMeasureLayout:!!h||m&&zi(m),visualElement:i,animationType:typeof d=="string"?d:"both",initialPromotionConfig:o,crossfade:v,layoutScroll:g,layoutRoot:p})}function Rg(i){if(i)return i.options.allowProjection!==!1?i.projection:Rg(i.parent)}function Tc(i,{forwardMotionProps:l=!1,type:u}={},o,c){o&&h2(o);const d=u?u==="svg":jf(i),h=d?D2:M2;function m(p,v){let x;const T={..._.useContext(wf),...p,layoutId:z2(p)},{isStatic:N}=T,z=g2(p),q=h(p,N);if(!N&&$y){R2();const G=V2(T);x=G.MeasureLayout,z.visualElement=j2(i,q,T,c,G.ProjectionNode,d)}return b.jsxs(Ku.Provider,{value:z,children:[x&&z.visualElement?b.jsx(x,{visualElement:z.visualElement,...T}):null,A2(i,p,N2(q,z.visualElement,v),q,N,l,d)]})}m.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const g=_.forwardRef(m);return g[w2]=i,g}function z2({layoutId:i}){const l=_.useContext(Ic).id;return l&&i!==void 0?l+"-"+i:i}function R2(i,l){_.useContext(Mg).strict}function V2(i){const l=Dg(),{drag:u,layout:o}=l;if(!u&&!o)return{};const c={...u,...o};return{MeasureLayout:u?.isEnabled(i)||o?.isEnabled(i)?c.MeasureLayout:void 0,ProjectionNode:c.ProjectionNode}}function _2(i,l){if(typeof Proxy>"u")return Tc;const u=new Map,o=(d,h)=>Tc(d,h,i,l),c=(d,h)=>o(d,h);return new Proxy(c,{get:(d,h)=>h==="create"?o:(u.has(h)||u.set(h,Tc(h,void 0,i,l)),u.get(h))})}const U2=(i,l)=>l.isSVG??jf(i)?new dT(l):new uT(l,{allowProjection:i!==_.Fragment});class B2 extends da{constructor(l){super(l),l.animationState||(l.animationState=vT(l))}updateAnimationControlsSubscription(){const{animate:l}=this.node.getProps();Gu(l)&&(this.unmountControls=l.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:l}=this.node.getProps(),{animate:u}=this.node.prevProps||{};l!==u&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let L2=0;class H2 extends da{constructor(){super(...arguments),this.id=L2++}update(){if(!this.node.presenceContext)return;const{isPresent:l,onExitComplete:u}=this.node.presenceContext,{isPresent:o}=this.node.prevPresenceContext||{};if(!this.node.animationState||l===o)return;const c=this.node.animationState.setActive("exit",!l);u&&!l&&c.then(()=>{u(this.id)})}mount(){const{register:l,onExitComplete:u}=this.node.presenceContext||{};u&&u(this.id),l&&(this.unmount=l(this.id))}unmount(){}}const Y2={animation:{Feature:B2},exit:{Feature:H2}};function as(i){return{point:{x:i.pageX,y:i.pageY}}}const q2=i=>l=>Tf(l)&&i(l,as(l));function Jl(i,l,u,o){return Il(i,l,q2(u),o)}const Vg=({current:i})=>i?i.ownerDocument.defaultView:null,Ly=(i,l)=>Math.abs(i-l);function G2(i,l){const u=Ly(i.x,l.x),o=Ly(i.y,l.y);return Math.sqrt(u**2+o**2)}const Hy=new Set(["auto","scroll"]);class _g{constructor(l,u,{transformPagePoint:o,contextWindow:c=window,dragSnapToOrigin:d=!1,distanceThreshold:h=3,element:m}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=N=>{this.handleScroll(N.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const N=Ec(this.lastMoveEventInfo,this.history),z=this.startEvent!==null,q=G2(N.offset,{x:0,y:0})>=this.distanceThreshold;if(!z&&!q)return;const{point:G}=N,{timestamp:H}=re;this.history.push({...G,timestamp:H});const{onStart:K,onMove:X}=this.handlers;z||(K&&K(this.lastMoveEvent,N),this.startEvent=this.lastMoveEvent),X&&X(this.lastMoveEvent,N)},this.handlePointerMove=(N,z)=>{this.lastMoveEvent=N,this.lastMoveEventInfo=Ac(z,this.transformPagePoint),Ot.update(this.updatePoint,!0)},this.handlePointerUp=(N,z)=>{this.end();const{onEnd:q,onSessionEnd:G,resumeAnimation:H}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&H&&H(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const K=Ec(N.type==="pointercancel"?this.lastMoveEventInfo:Ac(z,this.transformPagePoint),this.history);this.startEvent&&q&&q(N,K),G&&G(N,K)},!Tf(l))return;this.dragSnapToOrigin=d,this.handlers=u,this.transformPagePoint=o,this.distanceThreshold=h,this.contextWindow=c||window;const g=as(l),p=Ac(g,this.transformPagePoint),{point:v}=p,{timestamp:x}=re;this.history=[{...v,timestamp:x}];const{onSessionStart:T}=u;T&&T(l,Ec(p,this.history)),this.removeListeners=ts(Jl(this.contextWindow,"pointermove",this.handlePointerMove),Jl(this.contextWindow,"pointerup",this.handlePointerUp),Jl(this.contextWindow,"pointercancel",this.handlePointerUp)),m&&this.startScrollTracking(m)}startScrollTracking(l){let u=l.parentElement;for(;u;){const o=getComputedStyle(u);(Hy.has(o.overflowX)||Hy.has(o.overflowY))&&this.scrollPositions.set(u,{x:u.scrollLeft,y:u.scrollTop}),u=u.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(l){const u=this.scrollPositions.get(l);if(!u)return;const o=l===window,c=o?{x:window.scrollX,y:window.scrollY}:{x:l.scrollLeft,y:l.scrollTop},d={x:c.x-u.x,y:c.y-u.y};d.x===0&&d.y===0||(o?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=d.x,this.lastMoveEventInfo.point.y+=d.y):this.history.length>0&&(this.history[0].x-=d.x,this.history[0].y-=d.y),this.scrollPositions.set(l,c),Ot.update(this.updatePoint,!0))}updateHandlers(l){this.handlers=l}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ha(this.updatePoint)}}function Ac(i,l){return l?{point:l(i.point)}:i}function Yy(i,l){return{x:i.x-l.x,y:i.y-l.y}}function Ec({point:i},l){return{point:i,delta:Yy(i,Ug(l)),offset:Yy(i,X2(l)),velocity:K2(l,.1)}}function X2(i){return i[0]}function Ug(i){return i[i.length-1]}function K2(i,l){if(i.length<2)return{x:0,y:0};let u=i.length-1,o=null;const c=Ug(i);for(;u>=0&&(o=i[u],!(c.timestamp-o.timestamp>tn(l)));)u--;if(!o)return{x:0,y:0};o===i[0]&&i.length>2&&c.timestamp-o.timestamp>tn(l)*2&&(o=i[1]);const d=Qe(c.timestamp-o.timestamp);if(d===0)return{x:0,y:0};const h={x:(c.x-o.x)/d,y:(c.y-o.y)/d};return h.x===1/0&&(h.x=0),h.y===1/0&&(h.y=0),h}function Q2(i,{min:l,max:u},o){return l!==void 0&&i<l?i=o?Lt(l,i,o.min):Math.max(i,l):u!==void 0&&i>u&&(i=o?Lt(u,i,o.max):Math.min(i,u)),i}function qy(i,l,u){return{min:l!==void 0?i.min+l:void 0,max:u!==void 0?i.max+u-(i.max-i.min):void 0}}function Z2(i,{top:l,left:u,bottom:o,right:c}){return{x:qy(i.x,u,c),y:qy(i.y,l,o)}}function Gy(i,l){let u=l.min-i.min,o=l.max-i.max;return l.max-l.min<i.max-i.min&&([u,o]=[o,u]),{min:u,max:o}}function k2(i,l){return{x:Gy(i.x,l.x),y:Gy(i.y,l.y)}}function J2(i,l){let u=.5;const o=ge(i),c=ge(l);return c>o?u=Fl(l.min,l.max-o,i.min):o>c&&(u=Fl(i.min,i.max-c,l.min)),hn(0,1,u)}function F2(i,l){const u={};return l.min!==void 0&&(u.min=l.min-i.min),l.max!==void 0&&(u.max=l.max-i.min),u}const Pc=.35;function P2(i=Pc){return i===!1?i=0:i===!0&&(i=Pc),{x:Xy(i,"left","right"),y:Xy(i,"top","bottom")}}function Xy(i,l,u){return{min:Ky(i,l),max:Ky(i,u)}}function Ky(i,l){return typeof i=="number"?i:i[l]||0}const W2=new WeakMap;class $2{constructor(l){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ee(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=l}start(l,{snapToCursor:u=!1,distanceThreshold:o}={}){const{presenceContext:c}=this.visualElement;if(c&&c.isPresent===!1)return;const d=x=>{u&&this.snapToCursor(as(x).point),this.stopAnimation()},h=(x,T)=>{const{drag:N,dragPropagation:z,onDragStart:q}=this.getProps();if(N&&!z&&(this.openDragLock&&this.openDragLock(),this.openDragLock=MS(N),!this.openDragLock))return;this.latestPointerEvent=x,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),cn(H=>{let K=this.getAxisMotionValue(H).get()||0;if(fn.test(K)){const{projection:X}=this.visualElement;if(X&&X.layout){const J=X.layout.layoutBox[H];J&&(K=ge(J)*(parseFloat(K)/100))}}this.originPoint[H]=K}),q&&Ot.update(()=>q(x,T),!1,!0),qc(this.visualElement,"transform");const{animationState:G}=this.visualElement;G&&G.setActive("whileDrag",!0)},m=(x,T)=>{this.latestPointerEvent=x,this.latestPanInfo=T;const{dragPropagation:N,dragDirectionLock:z,onDirectionLock:q,onDrag:G}=this.getProps();if(!N&&!this.openDragLock)return;const{offset:H}=T;if(z&&this.currentDirection===null){this.currentDirection=tA(H),this.currentDirection!==null&&q&&q(this.currentDirection);return}this.updateAxis("x",T.point,H),this.updateAxis("y",T.point,H),this.visualElement.render(),G&&Ot.update(()=>G(x,T),!1,!0)},g=(x,T)=>{this.latestPointerEvent=x,this.latestPanInfo=T,this.stop(x,T),this.latestPointerEvent=null,this.latestPanInfo=null},p=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:v}=this.getProps();this.panSession=new _g(l,{onSessionStart:d,onStart:h,onMove:m,onSessionEnd:g,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:v,distanceThreshold:o,contextWindow:Vg(this.visualElement),element:this.visualElement.current})}stop(l,u){const o=l||this.latestPointerEvent,c=u||this.latestPanInfo,d=this.isDragging;if(this.cancel(),!d||!c||!o)return;const{velocity:h}=c;this.startAnimation(h);const{onDragEnd:m}=this.getProps();m&&Ot.postRender(()=>m(o,c))}cancel(){this.isDragging=!1;const{projection:l,animationState:u}=this.visualElement;l&&(l.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:o}=this.getProps();!o&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),u&&u.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(l,u,o){const{drag:c}=this.getProps();if(!o||!Cu(l,c,this.currentDirection))return;const d=this.getAxisMotionValue(l);let h=this.originPoint[l]+o[l];this.constraints&&this.constraints[l]&&(h=Q2(h,this.constraints[l],this.elastic[l])),d.set(h)}resolveConstraints(){const{dragConstraints:l,dragElastic:u}=this.getProps(),o=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,c=this.constraints;l&&zi(l)?this.constraints||(this.constraints=this.resolveRefConstraints()):l&&o?this.constraints=Z2(o.layoutBox,l):this.constraints=!1,this.elastic=P2(u),c!==this.constraints&&!zi(l)&&o&&this.constraints&&!this.hasMutatedConstraints&&cn(d=>{this.constraints!==!1&&this.getAxisMotionValue(d)&&(this.constraints[d]=F2(o.layoutBox[d],this.constraints[d]))})}resolveRefConstraints(){const{dragConstraints:l,onMeasureDragConstraints:u}=this.getProps();if(!l||!zi(l))return!1;const o=l.current,{projection:c}=this.visualElement;if(!c||!c.layout)return!1;const d=eT(o,c.root,this.visualElement.getTransformPagePoint());let h=k2(c.layout.layoutBox,d);if(u){const m=u($S(h));this.hasMutatedConstraints=!!m,m&&(h=ag(m))}return h}startAnimation(l){const{drag:u,dragMomentum:o,dragElastic:c,dragTransition:d,dragSnapToOrigin:h,onDragTransitionEnd:m}=this.getProps(),g=this.constraints||{},p=cn(v=>{if(!Cu(v,u,this.currentDirection))return;let x=g&&g[v]||{};h&&(x={min:0,max:0});const T=c?200:1e6,N=c?40:1e7,z={type:"inertia",velocity:o?l[v]:0,bounceStiffness:T,bounceDamping:N,timeConstant:750,restDelta:1,restSpeed:10,...d,...x};return this.startAxisValueAnimation(v,z)});return Promise.all(p).then(m)}startAxisValueAnimation(l,u){const o=this.getAxisMotionValue(l);return qc(this.visualElement,l),o.start(gf(l,o,0,u,this.visualElement,!1))}stopAnimation(){cn(l=>this.getAxisMotionValue(l).stop())}getAxisMotionValue(l){const u=`_drag${l.toUpperCase()}`,o=this.visualElement.getProps(),c=o[u];return c||this.visualElement.getValue(l,(o.initial?o.initial[l]:void 0)||0)}snapToCursor(l){cn(u=>{const{drag:o}=this.getProps();if(!Cu(u,o,this.currentDirection))return;const{projection:c}=this.visualElement,d=this.getAxisMotionValue(u);if(c&&c.layout){const{min:h,max:m}=c.layout.layoutBox[u],g=d.get()||0;d.set(l[u]-Lt(h,m,.5)+g)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:l,dragConstraints:u}=this.getProps(),{projection:o}=this.visualElement;if(!zi(u)||!o||!this.constraints)return;this.stopAnimation();const c={x:0,y:0};cn(h=>{const m=this.getAxisMotionValue(h);if(m&&this.constraints!==!1){const g=m.get();c[h]=J2({min:g,max:g},this.constraints[h])}});const{transformTemplate:d}=this.visualElement.getProps();this.visualElement.current.style.transform=d?d({},""):"none",o.root&&o.root.updateScroll(),o.updateLayout(),this.constraints=!1,this.resolveConstraints(),cn(h=>{if(!Cu(h,l,null))return;const m=this.getAxisMotionValue(h),{min:g,max:p}=this.constraints[h];m.set(Lt(g,p,c[h]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;W2.set(this.visualElement,this);const l=this.visualElement.current,u=Jl(l,"pointerdown",p=>{const{drag:v,dragListener:x=!0}=this.getProps(),T=p.target,N=T!==l&&zS(T);v&&x&&!N&&this.start(p)});let o;const c=()=>{const{dragConstraints:p}=this.getProps();zi(p)&&p.current&&(this.constraints=this.resolveRefConstraints(),o||(o=I2(l,p.current,()=>this.scalePositionWithinConstraints())))},{projection:d}=this.visualElement,h=d.addEventListener("measure",c);d&&!d.layout&&(d.root&&d.root.updateScroll(),d.updateLayout()),Ot.read(c);const m=Il(window,"resize",()=>this.scalePositionWithinConstraints()),g=d.addEventListener("didUpdate",(({delta:p,hasLayoutChanged:v})=>{this.isDragging&&v&&(cn(x=>{const T=this.getAxisMotionValue(x);T&&(this.originPoint[x]+=p[x].translate,T.set(T.get()+p[x].translate))}),this.visualElement.render())}));return()=>{m(),u(),h(),g&&g(),o&&o()}}getProps(){const l=this.visualElement.getProps(),{drag:u=!1,dragDirectionLock:o=!1,dragPropagation:c=!1,dragConstraints:d=!1,dragElastic:h=Pc,dragMomentum:m=!0}=l;return{...l,drag:u,dragDirectionLock:o,dragPropagation:c,dragConstraints:d,dragElastic:h,dragMomentum:m}}}function Qy(i){let l=!0;return()=>{if(l){l=!1;return}i()}}function I2(i,l,u){const o=$p(i,Qy(u)),c=$p(l,Qy(u));return()=>{o(),c()}}function Cu(i,l,u){return(l===!0||l===i)&&(u===null||u===i)}function tA(i,l=10){let u=null;return Math.abs(i.y)>l?u="y":Math.abs(i.x)>l&&(u="x"),u}class eA extends da{constructor(l){super(l),this.removeGroupControls=Ze,this.removeListeners=Ze,this.controls=new $2(l)}mount(){const{dragControls:l}=this.node.getProps();l&&(this.removeGroupControls=l.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ze}update(){const{dragControls:l}=this.node.getProps(),{dragControls:u}=this.node.prevProps||{};l!==u&&(this.removeGroupControls(),l&&(this.removeGroupControls=l.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Cc=i=>(l,u)=>{i&&Ot.update(()=>i(l,u),!1,!0)};class nA extends da{constructor(){super(...arguments),this.removePointerDownListener=Ze}onPointerDown(l){this.session=new _g(l,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Vg(this.node)})}createPanHandlers(){const{onPanSessionStart:l,onPanStart:u,onPan:o,onPanEnd:c}=this.node.getProps();return{onSessionStart:Cc(l),onStart:Cc(u),onMove:Cc(o),onEnd:(d,h)=>{delete this.session,c&&Ot.postRender(()=>c(d,h))}}}mount(){this.removePointerDownListener=Jl(this.node.current,"pointerdown",l=>this.onPointerDown(l))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Mc=!1;class aA extends _.Component{componentDidMount(){const{visualElement:l,layoutGroup:u,switchLayoutGroup:o,layoutId:c}=this.props,{projection:d}=l;d&&(u.group&&u.group.add(d),o&&o.register&&c&&o.register(d),Mc&&d.root.didUpdate(),d.addEventListener("animationComplete",()=>{this.safeToRemove()}),d.setOptions({...d.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),zu.hasEverUpdated=!0}getSnapshotBeforeUpdate(l){const{layoutDependency:u,visualElement:o,drag:c,isPresent:d}=this.props,{projection:h}=o;return h&&(h.isPresent=d,l.layoutDependency!==u&&h.setOptions({...h.options,layoutDependency:u}),Mc=!0,c||l.layoutDependency!==u||u===void 0||l.isPresent!==d?h.willUpdate():this.safeToRemove(),l.isPresent!==d&&(d?h.promote():h.relegate()||Ot.postRender(()=>{const m=h.getStack();(!m||!m.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:l}=this.props.visualElement;l&&(l.root.didUpdate(),Sf.postRender(()=>{!l.currentAnimation&&l.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:l,layoutGroup:u,switchLayoutGroup:o}=this.props,{projection:c}=l;Mc=!0,c&&(c.scheduleCheckAfterUnmount(),u&&u.group&&u.group.remove(c),o&&o.deregister&&o.deregister(c))}safeToRemove(){const{safeToRemove:l}=this.props;l&&l()}render(){return null}}function Bg(i){const[l,u]=Cg(),o=_.useContext(Ic);return b.jsx(aA,{...i,layoutGroup:o,switchLayoutGroup:_.useContext(zg),isPresent:l,safeToRemove:u})}const iA={pan:{Feature:nA},drag:{Feature:eA,ProjectionNode:Eg,MeasureLayout:Bg}};function Zy(i,l,u){const{props:o}=i;i.animationState&&o.whileHover&&i.animationState.setActive("whileHover",u==="Start");const c="onHover"+u,d=o[c];d&&Ot.postRender(()=>d(l,as(l)))}class lA extends da{mount(){const{current:l}=this.node;l&&(this.unmount=wS(l,(u,o)=>(Zy(this.node,o,"Start"),c=>Zy(this.node,c,"End"))))}unmount(){}}class sA extends da{constructor(){super(...arguments),this.isActive=!1}onFocus(){let l=!1;try{l=this.node.current.matches(":focus-visible")}catch{l=!0}!l||!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=ts(Il(this.node.current,"focus",()=>this.onFocus()),Il(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ky(i,l,u){const{props:o}=i;if(i.current instanceof HTMLButtonElement&&i.current.disabled)return;i.animationState&&o.whileTap&&i.animationState.setActive("whileTap",u==="Start");const c="onTap"+(u==="End"?"":u),d=o[c];d&&Ot.postRender(()=>d(l,as(l)))}class uA extends da{mount(){const{current:l}=this.node;if(!l)return;const{globalTapTarget:u,propagate:o}=this.node.props;this.unmount=VS(l,(c,d)=>(ky(this.node,d,"Start"),(h,{success:m})=>ky(this.node,h,m?"End":"Cancel")),{useGlobalTarget:u,stopPropagation:o?.tap===!1})}unmount(){}}const Wc=new WeakMap,Dc=new WeakMap,oA=i=>{const l=Wc.get(i.target);l&&l(i)},rA=i=>{i.forEach(oA)};function cA({root:i,...l}){const u=i||document;Dc.has(u)||Dc.set(u,{});const o=Dc.get(u),c=JSON.stringify(l);return o[c]||(o[c]=new IntersectionObserver(rA,{root:i,...l})),o[c]}function fA(i,l,u){const o=cA(l);return Wc.set(i,u),o.observe(i),()=>{Wc.delete(i),o.unobserve(i)}}const hA={some:0,all:1};class dA extends da{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:l={}}=this.node.getProps(),{root:u,margin:o,amount:c="some",once:d}=l,h={root:u?u.current:void 0,rootMargin:o,threshold:typeof c=="number"?c:hA[c]},m=g=>{const{isIntersecting:p}=g;if(this.isInView===p||(this.isInView=p,d&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:v,onViewportLeave:x}=this.node.getProps(),T=p?v:x;T&&T(g)};return fA(this.node.current,h,m)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:l,prevProps:u}=this.node;["amount","margin","root"].some(mA(l,u))&&this.startObserver()}unmount(){}}function mA({viewport:i={}},{viewport:l={}}={}){return u=>i[u]!==l[u]}const pA={inView:{Feature:dA},tap:{Feature:uA},focus:{Feature:sA},hover:{Feature:lA}},yA={layout:{ProjectionNode:Eg,MeasureLayout:Bg}},gA={...Y2,...pA,...iA,...yA},Jy=_2(gA,U2),vA=[{id:"anthropic",name:"Claude",subtitle:"by Anthropic",icon:"/icons/claude.png"},{id:"openai",name:"OpenAI Codex",subtitle:"ChatGPT Plus / Pro",icon:"/icons/codex.png"}],xA={anthropic:[{id:"claude-opus-4-6",label:"Opus 4.6"},{id:"claude-sonnet-4-6",label:"Sonnet 4.6"},{id:"claude-haiku-4-5-20251001",label:"Haiku 4.5"}],openai:[{id:"gpt-5.2-codex:medium",label:"GPT-5.2 Codex Medium"},{id:"gpt-5.2-codex:high",label:"GPT-5.2 Codex High"},{id:"gpt-5.2-codex:xhigh",label:"GPT-5.2 Codex Extra High"},{id:"gpt-5.3-codex:medium",label:"GPT-5.3 Codex Medium (Pro)"},{id:"gpt-5.3-codex:high",label:"GPT-5.3 Codex High (Pro)"},{id:"gpt-5.3-codex:xhigh",label:"GPT-5.3 Codex Extra High (Pro)"}]},Fy=[{tier:"premium",label:i=>`${i}.fluxy.bot`,badge:"$5",badgeCls:"bg-[#AF27E3]/15 text-[#AF27E3] border-[#AF27E3]/20",highlight:!0},{tier:"at",label:i=>`${i}.at.fluxy.bot`,badge:"Free",badgeCls:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",highlight:!1}];function bA({models:i,value:l,onChange:u}){const[o,c]=_.useState(!1),d=_.useRef(null);_.useEffect(()=>{if(!o)return;const m=g=>{d.current&&!d.current.contains(g.target)&&c(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]);const h=i.find(m=>m.id===l);return b.jsxs("div",{className:"relative",ref:d,children:[b.jsxs("button",{type:"button",onClick:()=>c(m=>!m),className:"w-full flex items-center justify-between 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",children:[b.jsx("span",{className:h?"text-white":"text-white/20",children:h?h.label:"Choose a model..."}),b.jsx(fx,{className:`h-4 w-4 text-white/30 transition-transform ${o?"rotate-180":""}`})]}),o&&b.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[#222] border border-white/[0.08] rounded-xl shadow-xl py-1 z-10 max-h-48 overflow-y-auto",children:i.map(m=>b.jsx("button",{onClick:()=>{u(m.id),c(!1)},className:`w-full text-left px-4 py-2 text-[13px] transition-colors ${l===m.id?"text-[#AF27E3] bg-[#AF27E3]/10":"text-white/70 hover:bg-white/[0.04] hover:text-white"}`,children:m.label},m.id))})]})}function EA({onComplete:i,isInitialSetup:l=!1}){const u=l?7:6,[o,c]=_.useState(0),[d,h]=_.useState(""),[m,g]=_.useState("anthropic"),[p,v]=_.useState(""),[x,T]=_.useState(!1),[N,z]=_.useState({anthropic:"idle",openai:"idle"}),[q,G]=_.useState(!1),[H,K]=_.useState(""),[X,J]=_.useState(!1),[Z,nt]=_.useState(),[I,F]=_.useState(!1),[lt,xt]=_.useState(!1),[_t,zt]=_.useState(),[jt,ie]=_.useState(""),[Bt,O]=_.useState(null),[Y,k]=_.useState(""),[ct,dt]=_.useState({}),[A,U]=_.useState("at"),[Q,P]=_.useState(!1),[et,st]=_.useState(!1),[ht,Kt]=_.useState(""),wt=_.useRef(null),[de,ma]=_.useState(null),[Oe,qa]=_.useState(!1),[nn,Ga]=_.useState(!1),[Xi,Qu]=_.useState("admin"),[ze,Ki]=_.useState(""),[pa,Qi]=_.useState(""),[Zu,is]=_.useState(!1),[Ht,ku]=_.useState(!1),[Zi,ls]=_.useState(!1),[Un,Ju]=_.useState(""),[ki,Xa]=_.useState(""),[Ka,Bn]=_.useState(!1),[ce,ke]=_.useState(!1),[Yt,ss]=_.useState(!1),[Je,us]=_.useState(""),Ln=_.useRef(!1),Re=N[m]==="connected";_.useEffect(()=>{fetch("/api/onboard/status").then(B=>B.json()).then(B=>{B.userName&&h(B.userName),B.handle&&(ie(B.handle.username),U(B.handle.tier||"at"),ma({username:B.handle.username,tier:B.handle.tier,url:B.handle.url}),st(!0),Kt(B.handle.url)),B.portalUser&&Qu(B.portalUser),B.portalConfigured&&ku(!0),B.provider&&g(B.provider),B.model&&v(B.model),B.whisperEnabled&&(ss(!0),us(B.whisperKey||"")),Ln.current=!0}).catch(()=>{Ln.current=!0})},[]),_.useEffect(()=>{m!=="anthropic"||N.anthropic==="connected"||fetch("/api/auth/claude/status").then(B=>B.json()).then(B=>{B.authenticated&&z(ot=>({...ot,anthropic:"connected"}))}).catch(()=>{})},[m]),_.useEffect(()=>{m!=="openai"||N.openai==="connected"||fetch("/api/auth/codex/status").then(B=>B.json()).then(B=>{B.authenticated&&z(ot=>({...ot,openai:"connected"}))}).catch(()=>{})},[m]),_.useEffect(()=>{if(!lt)return;const B=setInterval(async()=>{try{(await(await fetch("/api/auth/codex/status")).json()).authenticated&&(xt(!1),z(yn=>({...yn,openai:"connected"})))}catch{}},2e3);return()=>clearInterval(B)},[lt]),_.useEffect(()=>{if(wt.current&&clearTimeout(wt.current),!Ln.current||de&&et&&jt===de.username)return;O(null),k(""),dt({}),st(!1),Kt("");const B=jt.trim();if(B){if(B.length<3){O("invalid"),k("At least 3 characters");return}return O("checking"),wt.current=setTimeout(async()=>{try{const me=await(await fetch(`/api/handle/check/${encodeURIComponent(B)}`)).json();if(!me.valid)O("invalid"),k(me.error);else{const yn={};for(const Yn of me.handles)yn[Yn.tier]=Yn.available;dt(yn),O("ready");const Hn=Fy.find(Yn=>yn[Yn.tier]);Hn&&!yn[A]&&U(Hn.tier)}}catch{O(null)}},400),()=>{wt.current&&clearTimeout(wt.current)}}},[jt]);const Qa=B=>{ie(B.toLowerCase().replace(/[^a-z0-9-]/g,""))},mn=async()=>{if(!(!jt||Bt!=="ready"||!ct[A])){P(!0);try{const ot=await(await fetch("/api/handle/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:jt,tier:A})})).json();ot.ok?(st(!0),Kt(ot.url)):(k(ot.error||"Registration failed"),O("invalid"))}catch{k("Could not reach server"),O("invalid")}finally{P(!1)}}},Za=async()=>{if(!(!jt||Bt!=="ready"||!ct[A])){Ga(!0);try{const ot=await(await fetch("/api/handle/change",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:jt,tier:A})})).json();ot.ok?(st(!0),Kt(ot.url),ma({username:jt,tier:A,url:ot.url}),qa(!1)):(k(ot.error||"Handle change failed"),O("invalid"))}catch{k("Could not reach server"),O("invalid")}finally{Ga(!1)}}},ya=B=>{m==="openai"&&B!=="openai"&&lt&&(fetch("/api/auth/codex/cancel",{method:"POST"}),xt(!1)),g(B),v(""),G(!1),K(""),nt(void 0),xt(!1),zt(void 0)},Fu=async()=>{nt(void 0);try{const ot=await(await fetch("/api/auth/claude/start",{method:"POST"})).json();ot.success&&ot.authUrl?(window.open(ot.authUrl,"_blank"),G(!0)):nt(ot.error||"Failed to start authentication")}catch(B){nt(B.message)}},Ji=async()=>{if(H.trim()){J(!0),nt(void 0);try{const ot=await(await fetch("/api/auth/claude/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:H.trim()})})).json();ot.success?z(me=>({...me,anthropic:"connected"})):nt(ot.error||"Code exchange failed")}catch(B){nt(B.message)}finally{J(!1)}}},Fi=async()=>{try{const B=await navigator.clipboard.readText();B&&K(B.trim())}catch{}},ga=async()=>{F(!0),nt(void 0);try{(await(await fetch("/api/auth/claude/status")).json()).authenticated?z(me=>({...me,anthropic:"connected"})):nt("No active session found. Please authenticate first.")}catch{}finally{F(!1)}},Pu=async()=>{xt(!0),zt(void 0);try{const ot=await(await fetch("/api/auth/codex/start",{method:"POST"})).json();ot.success&&ot.authUrl?window.open(ot.authUrl,"_blank"):(xt(!1),zt(ot.error||"Failed to start authentication"))}catch(B){xt(!1),zt(B.message)}},os=()=>{xt(!1),fetch("/api/auth/codex/cancel",{method:"POST"})},Pi=ze===pa,Wi=ze.length>=6&&Pi,$i=Ht?ze.length===0||Ka&&Wi:Wi,pn=(()=>{switch(o){case 0:return!0;case 1:return d.trim().length>0;case 2:return et;case 3:return $i;case 4:return!!(m&&p&&Re);case 5:return!0;default:return!1}})(),an=()=>{pn&&o<u-1&&c(B=>B+1)},rs=()=>{o>0&&c(B=>B-1)},Ve=B=>{B.key==="Enter"&&pn&&an()},It=async()=>{T(!0);try{await fetch("/api/onboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userName:d.trim(),agentName:jt.trim()||"Fluxy",provider:m,model:p,apiKey:"",whisperEnabled:Yt,whisperKey:Yt?Je:"",portalUser:Xi.trim(),portalPass:ze})}),l?(T(!1),c(6)):i()}catch(B){console.error("Onboard failed:",B),T(!1)}},Qt="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";return b.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4",children:[b.jsx("div",{className:"absolute inset-0 bg-black/85 backdrop-blur-md"}),b.jsxs(Jy.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:[b.jsx("div",{className:"flex justify-center gap-2 pt-6",children:Array.from({length:u},(B,ot)=>b.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${ot===o?"w-7 bg-gradient-brand":ot<o?"w-1.5 bg-gradient-brand opacity-60":"w-1.5 bg-white/10"}`},ot))}),b.jsx(c2,{mode:"wait",children:b.jsxs(Jy.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:[o===0&&b.jsxs("div",{className:"flex flex-col items-center text-center",children:[b.jsx("video",{src:"/fluxy_say_hi.webm",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"h-[180px] mb-4"}),b.jsx("h1",{className:"text-2xl font-bold text-white tracking-tight",children:"Welcome to Fluxy"}),b.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."}),b.jsxs("button",{onClick:an,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",b.jsx(rn,{className:"h-4 w-4"})]})]}),o===1&&b.jsxs("div",{children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"What's your name?"}),b.jsx("p",{className:"text-white/40 text-[13px] mt-1.5 leading-relaxed",children:"This is how your agent will address you."}),b.jsxs("div",{className:"mt-5 flex items-center gap-3",children:[b.jsx("input",{type:"text",value:d,onChange:B=>h(B.target.value),onKeyDown:Ve,placeholder:"Enter your name",autoFocus:!0,className:Qt+" flex-1"}),b.jsx("button",{onClick:an,disabled:!pn,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:b.jsx(rn,{className:"h-5 w-5"})})]})]}),o===2&&b.jsxs("div",{children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Name your bot"}),b.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."}),de&&et&&!Oe&&b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(ji,{className:"h-4 w-4 text-emerald-400"}),b.jsx("p",{className:"text-emerald-400/90 text-[13px] font-medium",children:"Current handle"})]}),b.jsx("p",{className:"text-emerald-400/60 text-[12px] mt-1 font-mono",children:ht})]}),b.jsxs("div",{className:"flex gap-2 mt-4",children:[b.jsxs("button",{onClick:an,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",b.jsx(rn,{className:"h-4 w-4"})]}),b.jsx("button",{onClick:()=>{qa(!0),st(!1),ie(""),O(null),dt({})},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"})]})]}),Oe&&!et&&b.jsxs("div",{className:"mt-4 bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3",children:[b.jsx("p",{className:"text-amber-400/90 text-[13px] font-medium",children:"Changing your handle"}),b.jsxs("p",{className:"text-amber-400/60 text-[12px] mt-1",children:["Your current handle ",b.jsx("span",{className:"font-mono",children:de?.url})," will be released and become available for others."]})]}),(!de||Oe||!et)&&!(de&&et&&!Oe)&&b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"relative mt-5",children:[b.jsx("input",{type:"text",value:jt,onChange:B=>Qa(B.target.value),maxLength:30,placeholder:"your-bot-name",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",autoFocus:!0,disabled:et,className:Qt+" pr-10 font-mono"+(et?" opacity-50":"")}),Bt&&jt.length>0&&!et&&b.jsxs("div",{className:"absolute right-4 top-1/2 -translate-y-1/2",children:[Bt==="checking"&&b.jsx("div",{className:"w-5 h-5 border-2 border-white/10 border-t-[#04D1FE] rounded-full animate-spin"}),Bt==="invalid"&&b.jsx("div",{className:"w-6 h-6 rounded-full bg-amber-500/15 flex items-center justify-center",children:b.jsx("svg",{className:"w-3.5 h-3.5 text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3m0 4h.01"})})})]})]}),Bt==="invalid"&&Y&&b.jsx("p",{className:"text-amber-400 text-[12px] mt-2",children:Y}),Bt==="ready"&&jt.length>0&&!et&&b.jsx("div",{className:"space-y-2 mt-4",children:Fy.map(B=>{const me=ct[B.tier]===!1;return b.jsxs("button",{onClick:()=>!me&&U(B.tier),disabled:me,className:`w-full flex items-center justify-between px-4 py-3 rounded-xl border transition-all duration-200 text-left ${me?"border-white/[0.04] bg-transparent opacity-50 cursor-not-allowed":A===B.tier?B.highlight?"border-[#AF27E3]/40 bg-[#AF27E3]/[0.06]":"border-[#AF27E3]/30 bg-white/[0.04]":"border-white/[0.06] bg-transparent hover:border-white/10 hover:bg-white/[0.02]"}`,children:[b.jsx("span",{className:"font-mono text-[13px] text-white/70",children:B.label(jt)}),me?b.jsx("span",{className:"text-[11px] font-medium px-2.5 py-0.5 rounded-full border bg-red-500/10 text-red-400 border-red-500/20",children:"Taken"}):b.jsx("span",{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border ${B.badgeCls}`,children:B.badge})]},B.tier)})}),et&&b.jsxs("div",{className:"mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(ji,{className:"h-4 w-4 text-emerald-400"}),b.jsx("p",{className:"text-emerald-400/90 text-[13px] font-medium",children:"Handle claimed!"})]}),b.jsx("p",{className:"text-emerald-400/60 text-[12px] mt-1 font-mono",children:ht})]}),Bt==="ready"&&ct[A]&&jt.length>0&&!et&&b.jsx("button",{onClick:Oe?Za:mn,disabled:Q||nn,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:Q||nn?b.jsxs(b.Fragment,{children:[b.jsx(Oi,{className:"h-4 w-4 animate-spin"}),Oe?"Changing...":"Claiming..."]}):b.jsxs(b.Fragment,{children:[Oe?"Change Handle":"Claim & Continue",b.jsx(rn,{className:"h-4 w-4"})]})}),et&&b.jsxs("button",{onClick:an,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",b.jsx(rn,{className:"h-4 w-4"})]}),Oe&&!et&&b.jsx("button",{onClick:()=>{qa(!1),ie(de.username),st(!0),Kt(de.url),U(de.tier),O(null)},className:"w-full mt-2 py-2 text-white/25 hover:text-white/40 text-[12px] transition-colors",children:"Cancel — keep current handle"})]})]}),o===3&&b.jsxs("div",{children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Set a password"}),b.jsx("p",{className:"text-white/40 text-[13px] mt-1.5 leading-relaxed",children:"You'll need this password to access your agent's chat. Keep it safe — anyone with your URL will need it to log in."}),Ht&&b.jsx("div",{className:"mt-4 bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-2.5",children:b.jsx("p",{className:"text-white/40 text-[12px]",children:"Password already set. Leave fields empty to keep your current password, or enter your current password to change it."})}),Ht&&b.jsxs("div",{className:"mt-5",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:"Current password"}),b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("input",{type:"password",value:Un,onChange:B=>{Ju(B.target.value),Xa(""),Bn(!1)},placeholder:"Enter current password to change it",autoComplete:"current-password",autoFocus:!0,className:Qt+" flex-1"}),Un.length>0&&!Ka&&b.jsx("button",{onClick:async()=>{ke(!0),Xa("");try{(await(await fetch("/api/portal/verify-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:Un})})).json()).valid?Bn(!0):Xa("Incorrect password")}catch{Xa("Could not verify")}finally{ke(!1)}},disabled:ce,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:ce?b.jsx(Oi,{className:"h-4 w-4 animate-spin"}):"Verify"}),Ka&&b.jsx("div",{className:"shrink-0 w-10 h-10 flex items-center justify-center",children:b.jsx(ji,{className:"h-4 w-4 text-emerald-400"})})]}),ki&&b.jsx("p",{className:"text-red-400/70 text-[11px] mt-1",children:ki})]}),(!Ht||Ka)&&b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:Ht?"mt-3":"mt-5",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:Ht?"New password":"Password"}),b.jsx("input",{type:"password",value:ze,onChange:B=>Ki(B.target.value),placeholder:"••••••••",autoComplete:"new-password",autoFocus:!Ht,onKeyDown:Ve,className:Qt}),ze.length>0&&ze.length<6&&b.jsx("p",{className:"text-amber-400/70 text-[11px] mt-1",children:"At least 6 characters"})]}),b.jsxs("div",{className:"mt-3",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:Ht?"Confirm new password":"Confirm password"}),b.jsx("input",{type:"password",value:pa,onChange:B=>Qi(B.target.value),placeholder:"••••••••",autoComplete:"new-password",onKeyDown:Ve,className:Qt}),pa.length>0&&!Pi&&b.jsx("p",{className:"text-red-400/70 text-[11px] mt-1",children:"Passwords don't match"})]})]}),b.jsxs("button",{onClick:an,disabled:!pn,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",b.jsx(rn,{className:"h-4 w-4"})]})]}),o===4&&b.jsxs("div",{children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Choose your AI provider"}),b.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."}),b.jsx("div",{className:"flex gap-2.5 mt-4",children:vA.map(B=>b.jsxs("button",{onClick:()=>ya(B.id),className:`flex-1 relative rounded-xl border transition-all duration-200 p-3 text-left ${m===B.id?"bg-white/[0.04] border-[#AF27E3]/40":"bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]"}`,children:[b.jsxs("div",{className:"flex flex-col items-center gap-1.5 py-0.5",children:[B.icon?b.jsx("img",{src:B.icon,alt:B.name,className:"w-8 h-8 rounded-lg"}):b.jsx("div",{className:"w-8 h-8 rounded-lg bg-white/[0.06] flex items-center justify-center text-white/50 text-sm font-bold",children:"O"}),b.jsxs("div",{className:"text-center",children:[b.jsx("div",{className:"text-[13px] font-medium text-white",children:B.name}),b.jsx("div",{className:"text-[10px] text-white/30",children:B.subtitle})]})]}),N[B.id]==="connected"?b.jsx("div",{className:"absolute top-2 right-2 w-4 h-4 rounded-full bg-emerald-500/15 flex items-center justify-center",children:b.jsx(ji,{className:"h-2.5 w-2.5 text-emerald-400"})}):m===B.id?b.jsx("div",{className:"absolute top-2 right-2 w-2 h-2 rounded-full bg-gradient-brand"}):null]},B.id))}),b.jsx("div",{className:"border-t border-white/[0.06] mt-4 mb-3"}),m==="anthropic"&&b.jsxs("div",{className:"space-y-2.5",children:[Re&&b.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5",children:b.jsx("p",{className:"text-emerald-400/90 text-[12px]",children:"Connected — Anthropic subscription is active."})}),!Re&&b.jsxs(b.Fragment,{children:[Z&&b.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5",children:b.jsx("p",{className:"text-red-400/90 text-[12px]",children:Z})}),b.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((B,ot)=>b.jsxs("div",{className:"flex items-start gap-2",children:[b.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:ot+1}),b.jsx("p",{className:"text-white/40 text-[12px] leading-relaxed",children:B})]},ot))}),b.jsx("button",{onClick:Fu,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:q?b.jsxs(b.Fragment,{children:[b.jsx(Op,{className:"h-3.5 w-3.5 opacity-60"}),"Open authentication page again"]}):b.jsxs(b.Fragment,{children:["Authenticate with Anthropic",b.jsx(rn,{className:"h-3.5 w-3.5 opacity-60"})]})}),b.jsxs("div",{className:"relative",children:[b.jsx("input",{type:"text",value:H,onChange:B=>K(B.target.value),onKeyDown:B=>B.key==="Enter"&&Ji(),placeholder:"Paste your code here...",className:"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"+" pr-10 font-mono"}),b.jsx("button",{onClick:Fi,className:"absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors",children:b.jsx(dx,{className:"h-3.5 w-3.5"})})]}),b.jsx("button",{onClick:Ji,disabled:!H.trim()||X,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:X?b.jsxs(b.Fragment,{children:[b.jsx(Oi,{className:"h-3.5 w-3.5 animate-spin"}),"Verifying..."]}):"Connect"}),b.jsxs("button",{onClick:ga,disabled:I,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:[I?b.jsx(Oi,{className:"h-3 w-3 animate-spin"}):b.jsx(Ax,{className:"h-3 w-3"}),I?"Checking...":"I'm already authenticated"]})]})]}),m==="openai"&&b.jsxs("div",{className:"space-y-2.5",children:[Re&&b.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5",children:b.jsx("p",{className:"text-emerald-400/90 text-[12px]",children:"Connected — ChatGPT subscription is active."})}),!Re&&b.jsxs(b.Fragment,{children:[_t&&b.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5",children:b.jsx("p",{className:"text-red-400/90 text-[12px]",children:_t})}),b.jsx("div",{className:"space-y-1.5",children:["Click the button below — your browser will open for ChatGPT sign-in","Sign in with your ChatGPT Plus or Pro account","Authentication completes automatically — no code to copy"].map((B,ot)=>b.jsxs("div",{className:"flex items-start gap-2",children:[b.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:ot+1}),b.jsx("p",{className:"text-white/40 text-[12px] leading-relaxed",children:B})]},ot))}),b.jsx("button",{onClick:Pu,disabled:lt,className:"w-full py-2.5 px-4 bg-white/[0.06] hover:bg-white/[0.09] text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-60",children:lt?b.jsxs(b.Fragment,{children:[b.jsx(Oi,{className:"h-3.5 w-3.5 animate-spin opacity-60"}),"Waiting for sign-in..."]}):b.jsxs(b.Fragment,{children:["Authenticate with ChatGPT",b.jsx(rn,{className:"h-3.5 w-3.5 opacity-60"})]})}),lt&&b.jsx("button",{onClick:os,className:"w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors",children:"Cancel"})]})]}),Re&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"border-t border-white/[0.06] mt-4 mb-3"}),b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:"Select a model"}),b.jsx(bA,{models:xA[m]||[],value:p,onChange:v})]}),Re&&b.jsxs("button",{onClick:an,disabled:!pn,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",b.jsx(rn,{className:"h-4 w-4"})]})]}),o===5&&b.jsxs("div",{children:[b.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Voice Messages"}),b.jsx("span",{className:"text-[11px] text-white/25 font-medium bg-white/[0.04] border border-white/[0.06] rounded-full px-2.5 py-0.5",children:"Optional"})]}),b.jsx("p",{className:"text-white/40 text-[13px] mt-1 leading-relaxed",children:"Allow users to send audio messages that are automatically transcribed."}),b.jsx("button",{onClick:()=>ss(B=>!B),className:`w-full mt-5 rounded-xl border transition-all duration-200 p-4 text-left ${Yt?"bg-white/[0.04] border-[#AF27E3]/40":"bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]"}`,children:b.jsxs("div",{className:"flex items-center gap-3.5",children:[b.jsx("img",{src:"/icons/openai.svg",alt:"OpenAI",className:"w-10 h-10 rounded-xl bg-white/[0.04] p-1.5"}),b.jsxs("div",{className:"flex-1",children:[b.jsx("div",{className:"text-[14px] font-medium text-white",children:"OpenAI Whisper"}),b.jsx("div",{className:"text-[12px] text-white/35 mt-0.5 leading-relaxed",children:"Speech-to-text powered by OpenAI. Requires an OpenAI API key."})]}),b.jsx("div",{className:`w-10 h-[22px] rounded-full transition-colors duration-200 flex items-center px-0.5 shrink-0 ${Yt?"bg-gradient-brand":"bg-white/[0.08]"}`,children:b.jsx("div",{className:`w-[18px] h-[18px] rounded-full bg-white shadow-sm transition-transform duration-200 ${Yt?"translate-x-[18px]":"translate-x-0"}`})})]})}),Yt&&b.jsxs("div",{className:"mt-3",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:"OpenAI API Key"}),b.jsx("input",{type:"password",value:Je,onChange:B=>us(B.target.value.trim()),placeholder:"sk-...",autoComplete:"off",className:Qt+" font-mono text-[13px]"}),Je.length>0&&!Je.startsWith("sk-")&&b.jsx("p",{className:"text-amber-400/70 text-[11px] mt-1",children:"Key should start with sk-"}),Je.length>0&&Je.startsWith("sk-")&&Je.length<20&&b.jsx("p",{className:"text-amber-400/70 text-[11px] mt-1",children:"Key looks too short"}),b.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:[b.jsx(Sx,{className:"h-4 w-4 text-[#AF27E3]/60 mt-0.5 shrink-0"}),b.jsx("p",{className:"text-white/35 text-[12px] leading-relaxed",children:"Users will see a microphone button in the chat. Audio is sent to OpenAI's Whisper API for transcription, then processed as a regular text message."})]})]}),b.jsx("button",{onClick:It,disabled:x||Yt&&(!Je.startsWith("sk-")||Je.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:x?b.jsxs(b.Fragment,{children:[b.jsx(Oi,{className:"h-4 w-4 animate-spin"}),"Setting up..."]}):b.jsxs(b.Fragment,{children:["Complete Setup",b.jsx(rn,{className:"h-4 w-4"})]})}),!Yt&&b.jsx("p",{className:"text-center text-white/20 text-[11px] mt-2.5",children:"You can enable this later in Settings."})]}),o===6&&l&&b.jsxs("div",{className:"flex flex-col items-center text-center",children:[b.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:b.jsx(ji,{className:"h-8 w-8 text-emerald-400"})}),b.jsx("h1",{className:"text-2xl font-bold text-white tracking-tight",children:"All Set!"}),b.jsx("p",{className:"text-white/40 text-[13px] mt-2 leading-relaxed max-w-[340px]",children:"Your agent is live and ready. From now on, access it using your custom URL below."}),b.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:[b.jsx("span",{className:"font-mono text-[13px] text-white/70 truncate flex-1 text-left",children:ht}),b.jsx("button",{onClick:()=>{const B=ht.startsWith("http")?ht:`https://${ht}`;navigator.clipboard.writeText(B),is(!0),setTimeout(()=>is(!1),2e3)},className:"shrink-0 text-white/30 hover:text-white/60 transition-colors",children:Zu?b.jsx(ji,{className:"h-4 w-4 text-emerald-400"}):b.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[b.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),b.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})]}),b.jsxs("div",{className:"w-full mt-3",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block text-left",children:"Your password"}),b.jsxs("div",{className:"flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3",children:[b.jsx("span",{className:"font-mono text-[13px] text-white/70 truncate flex-1 text-left",children:Zi?ze:"•".repeat(Math.max(ze.length,8))}),b.jsx("button",{onClick:()=>ls(B=>!B),className:"shrink-0 text-white/30 hover:text-white/60 transition-colors",children:Zi?b.jsx(yx,{className:"h-4 w-4"}):b.jsx(vx,{className:"h-4 w-4"})})]})]}),b.jsxs("button",{onClick:()=>{const B=ht.startsWith("http")?ht:`https://${ht}`;window.location.href=B},className:"w-full mt-6 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:["Go to your agent",b.jsx(Op,{className:"h-4 w-4"})]}),b.jsx("p",{className:"text-white/20 text-[11px] mt-3 leading-relaxed",children:"You'll be redirected to your custom URL."})]})]},o)}),o>0&&o<u-1&&!(o===6&&l)&&b.jsx("div",{className:"px-8 pb-5 -mt-3",children:b.jsx("button",{onClick:rs,className:"text-white/25 hover:text-white/50 text-[12px] transition-colors",children:"← Back"})})]})]})}export{rn as A,Oi as L,Sx as M,EA as O,SA as R,c2 as a,TA as b,dn as c,Py as g,b as j,Jy as m,_ as r};
17
+ `),()=>{Z.contains(J)&&Z.removeChild(J)}},[l]),b.jsx(s2,{isPresent:l,childRef:m,sizeRef:g,pop:d,children:d===!1?i:_.cloneElement(i,{ref:x})})}const o2=({children:i,initial:l,isPresent:u,onExitComplete:o,custom:c,presenceAffectsLayout:d,mode:h,anchorX:m,anchorY:g,root:p})=>{const v=tf(r2),x=_.useId();let T=!0,N=_.useMemo(()=>(T=!1,{id:x,initial:l,isPresent:u,custom:c,onExitComplete:z=>{v.set(z,!0);for(const q of v.values())if(!q)return;o&&o()},register:z=>(v.set(z,!1),()=>v.delete(z))}),[u,v,o]);return d&&T&&(N={...N}),_.useMemo(()=>{v.forEach((z,q)=>v.set(q,!1))},[u]),_.useEffect(()=>{!u&&!v.size&&o&&o()},[u]),i=b.jsx(u2,{pop:h==="popLayout",isPresent:u,anchorX:m,anchorY:g,root:p,children:i}),b.jsx(qu.Provider,{value:N,children:i})};function r2(){return new Map}function Cg(i=!0){const l=_.useContext(qu);if(l===null)return[!0,null];const{isPresent:u,onExitComplete:o,register:c}=l,d=_.useId();_.useEffect(()=>{if(i)return c(d)},[i]);const h=_.useCallback(()=>i&&o&&o(d),[d,o,i]);return!u&&o?[!1,h]:[!0]}const Eu=i=>i.key||"";function Vy(i){const l=[];return _.Children.forEach(i,u=>{_.isValidElement(u)&&l.push(u)}),l}const c2=({children:i,custom:l,initial:u=!0,onExitComplete:o,presenceAffectsLayout:c=!0,mode:d="sync",propagate:h=!1,anchorX:m="left",anchorY:g="top",root:p})=>{const[v,x]=Cg(h),T=_.useMemo(()=>Vy(i),[i]),N=h&&!v?[]:T.map(Eu),z=_.useRef(!0),q=_.useRef(T),G=tf(()=>new Map),H=_.useRef(new Set),[K,X]=_.useState(T),[J,Z]=_.useState(T);Iy(()=>{z.current=!1,q.current=T;for(let F=0;F<J.length;F++){const lt=Eu(J[F]);N.includes(lt)?(G.delete(lt),H.current.delete(lt)):G.get(lt)!==!0&&G.set(lt,!1)}},[J,N.length,N.join("-")]);const nt=[];if(T!==K){let F=[...T];for(let lt=0;lt<J.length;lt++){const xt=J[lt],_t=Eu(xt);N.includes(_t)||(F.splice(lt,0,xt),nt.push(xt))}return d==="wait"&&nt.length&&(F=nt),Z(Vy(F)),X(T),null}const{forceRender:I}=_.useContext(Ic);return b.jsx(b.Fragment,{children:J.map(F=>{const lt=Eu(F),xt=h&&!v?!1:T===J||N.includes(lt),_t=()=>{if(H.current.has(lt))return;if(H.current.add(lt),G.has(lt))G.set(lt,!0);else return;let zt=!0;G.forEach(jt=>{jt||(zt=!1)}),zt&&(I?.(),Z(q.current),h&&x?.(),o&&o())};return b.jsx(o2,{isPresent:xt,initial:!z.current||u?void 0:!1,custom:l,presenceAffectsLayout:c,mode:d,root:p,onExitComplete:xt?void 0:_t,anchorX:m,anchorY:g,children:F},lt)})})},Mg=_.createContext({strict:!1}),_y={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Uy=!1;function f2(){if(Uy)return;const i={};for(const l in _y)i[l]={isEnabled:u=>_y[l].some(o=>!!u[o])};eg(i),Uy=!0}function Dg(){return f2(),PS()}function h2(i){const l=Dg();for(const u in i)l[u]={...l[u],...i[u]};eg(l)}const d2=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Yu(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||d2.has(i)}let wg=i=>!Yu(i);function m2(i){typeof i=="function"&&(wg=l=>l.startsWith("on")?!Yu(l):i(l))}try{m2(require("@emotion/is-prop-valid").default)}catch{}function p2(i,l,u){const o={};for(const c in i)c==="values"&&typeof i.values=="object"||(wg(c)||u===!0&&Yu(c)||!l&&!Yu(c)||i.draggable&&c.startsWith("onDrag"))&&(o[c]=i[c]);return o}const Ku=_.createContext({});function y2(i,l){if(Xu(i)){const{initial:u,animate:o}=i;return{initial:u===!1||$l(u)?u:void 0,animate:$l(o)?o:void 0}}return i.inherit!==!1?l:{}}function g2(i){const{initial:l,animate:u}=y2(i,_.useContext(Ku));return _.useMemo(()=>({initial:l,animate:u}),[By(l),By(u)])}function By(i){return Array.isArray(i)?i.join(" "):i}const Nf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ng(i,l,u){for(const o in l)!he(l[o])&&!og(o,u)&&(i[o]=l[o])}function v2({transformTemplate:i},l){return _.useMemo(()=>{const u=Nf();return Mf(u,l,i),Object.assign({},u.vars,u.style)},[l])}function x2(i,l){const u=i.style||{},o={};return Ng(o,u,i),Object.assign(o,v2(i,l)),o}function b2(i,l){const u={},o=x2(i,l);return i.drag&&i.dragListener!==!1&&(u.draggable=!1,o.userSelect=o.WebkitUserSelect=o.WebkitTouchCallout="none",o.touchAction=i.drag===!0?"none":`pan-${i.drag==="x"?"y":"x"}`),i.tabIndex===void 0&&(i.onTap||i.onTapStart||i.whileTap)&&(u.tabIndex=0),u.style=o,u}const jg=()=>({...Nf(),attrs:{}});function S2(i,l,u,o){const c=_.useMemo(()=>{const d=jg();return rg(d,l,fg(o),i.transformTemplate,i.style),{...d.attrs,style:{...d.style}}},[l]);if(i.style){const d={};Ng(d,i.style,i),c.style={...d,...c.style}}return c}const T2=["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 jf(i){return typeof i!="string"||i.includes("-")?!1:!!(T2.indexOf(i)>-1||/[A-Z]/u.test(i))}function A2(i,l,u,{latestValues:o},c,d=!1,h){const g=(h??jf(i)?S2:b2)(l,o,c,i),p=p2(l,typeof i=="string",d),v=i!==_.Fragment?{...p,...g,ref:u}:{},{children:x}=l,T=_.useMemo(()=>he(x)?x.get():x,[x]);return _.createElement(i,{...v,children:T})}function E2({scrapeMotionValuesFromProps:i,createRenderState:l},u,o,c){return{latestValues:C2(u,o,c,i),renderState:l()}}function C2(i,l,u,o){const c={},d=o(i,{});for(const T in d)c[T]=Ou(d[T]);let{initial:h,animate:m}=i;const g=Xu(i),p=I0(i);l&&p&&!g&&i.inherit!==!1&&(h===void 0&&(h=l.initial),m===void 0&&(m=l.animate));let v=u?u.initial===!1:!1;v=v||h===!1;const x=v?m:h;if(x&&typeof x!="boolean"&&!Gu(x)){const T=Array.isArray(x)?x:[x];for(let N=0;N<T.length;N++){const z=vf(i,T[N]);if(z){const{transitionEnd:q,transition:G,...H}=z;for(const K in H){let X=H[K];if(Array.isArray(X)){const J=v?X.length-1:0;X=X[J]}X!==null&&(c[K]=X)}for(const K in q)c[K]=q[K]}}}return c}const Og=i=>(l,u)=>{const o=_.useContext(Ku),c=_.useContext(qu),d=()=>E2(i,l,o,c);return u?d():tf(d)},M2=Og({scrapeMotionValuesFromProps:Df,createRenderState:Nf}),D2=Og({scrapeMotionValuesFromProps:hg,createRenderState:jg}),w2=Symbol.for("motionComponentSymbol");function N2(i,l,u){const o=_.useRef(u);_.useInsertionEffect(()=>{o.current=u});const c=_.useRef(null);return _.useCallback(d=>{d&&i.onMount?.(d),l&&(d?l.mount(d):l.unmount());const h=o.current;if(typeof h=="function")if(d){const m=h(d);typeof m=="function"&&(c.current=m)}else c.current?(c.current(),c.current=null):h(d);else h&&(h.current=d)},[l])}const zg=_.createContext({});function zi(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}function j2(i,l,u,o,c,d){const{visualElement:h}=_.useContext(Ku),m=_.useContext(Mg),g=_.useContext(qu),p=_.useContext(wf),v=p.reducedMotion,x=p.skipAnimations,T=_.useRef(null),N=_.useRef(!1);o=o||m.renderer,!T.current&&o&&(T.current=o(i,{visualState:l,parent:h,props:u,presenceContext:g,blockInitialAnimation:g?g.initial===!1:!1,reducedMotionConfig:v,skipAnimations:x,isSVG:d}),N.current&&T.current&&(T.current.manuallyAnimateOnMount=!0));const z=T.current,q=_.useContext(zg);z&&!z.projection&&c&&(z.type==="html"||z.type==="svg")&&O2(T.current,u,c,q);const G=_.useRef(!1);_.useInsertionEffect(()=>{z&&G.current&&z.update(u,g)});const H=u[Y0],K=_.useRef(!!H&&!window.MotionHandoffIsComplete?.(H)&&window.MotionHasOptimisedAnimation?.(H));return Iy(()=>{N.current=!0,z&&(G.current=!0,window.MotionIsMounted=!0,z.updateFeatures(),z.scheduleRenderMicrotask(),K.current&&z.animationState&&z.animationState.animateChanges())}),_.useEffect(()=>{z&&(!K.current&&z.animationState&&z.animationState.animateChanges(),K.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(H)}),K.current=!1),z.enteringChildren=void 0)}),z}function O2(i,l,u,o){const{layoutId:c,layout:d,drag:h,dragConstraints:m,layoutScroll:g,layoutRoot:p,layoutCrossfade:v}=l;i.projection=new u(i.latestValues,l["data-framer-portal-id"]?void 0:Rg(i.parent)),i.projection.setOptions({layoutId:c,layout:d,alwaysMeasureLayout:!!h||m&&zi(m),visualElement:i,animationType:typeof d=="string"?d:"both",initialPromotionConfig:o,crossfade:v,layoutScroll:g,layoutRoot:p})}function Rg(i){if(i)return i.options.allowProjection!==!1?i.projection:Rg(i.parent)}function Tc(i,{forwardMotionProps:l=!1,type:u}={},o,c){o&&h2(o);const d=u?u==="svg":jf(i),h=d?D2:M2;function m(p,v){let x;const T={..._.useContext(wf),...p,layoutId:z2(p)},{isStatic:N}=T,z=g2(p),q=h(p,N);if(!N&&$y){R2();const G=V2(T);x=G.MeasureLayout,z.visualElement=j2(i,q,T,c,G.ProjectionNode,d)}return b.jsxs(Ku.Provider,{value:z,children:[x&&z.visualElement?b.jsx(x,{visualElement:z.visualElement,...T}):null,A2(i,p,N2(q,z.visualElement,v),q,N,l,d)]})}m.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const g=_.forwardRef(m);return g[w2]=i,g}function z2({layoutId:i}){const l=_.useContext(Ic).id;return l&&i!==void 0?l+"-"+i:i}function R2(i,l){_.useContext(Mg).strict}function V2(i){const l=Dg(),{drag:u,layout:o}=l;if(!u&&!o)return{};const c={...u,...o};return{MeasureLayout:u?.isEnabled(i)||o?.isEnabled(i)?c.MeasureLayout:void 0,ProjectionNode:c.ProjectionNode}}function _2(i,l){if(typeof Proxy>"u")return Tc;const u=new Map,o=(d,h)=>Tc(d,h,i,l),c=(d,h)=>o(d,h);return new Proxy(c,{get:(d,h)=>h==="create"?o:(u.has(h)||u.set(h,Tc(h,void 0,i,l)),u.get(h))})}const U2=(i,l)=>l.isSVG??jf(i)?new dT(l):new uT(l,{allowProjection:i!==_.Fragment});class B2 extends da{constructor(l){super(l),l.animationState||(l.animationState=vT(l))}updateAnimationControlsSubscription(){const{animate:l}=this.node.getProps();Gu(l)&&(this.unmountControls=l.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:l}=this.node.getProps(),{animate:u}=this.node.prevProps||{};l!==u&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let L2=0;class H2 extends da{constructor(){super(...arguments),this.id=L2++}update(){if(!this.node.presenceContext)return;const{isPresent:l,onExitComplete:u}=this.node.presenceContext,{isPresent:o}=this.node.prevPresenceContext||{};if(!this.node.animationState||l===o)return;const c=this.node.animationState.setActive("exit",!l);u&&!l&&c.then(()=>{u(this.id)})}mount(){const{register:l,onExitComplete:u}=this.node.presenceContext||{};u&&u(this.id),l&&(this.unmount=l(this.id))}unmount(){}}const Y2={animation:{Feature:B2},exit:{Feature:H2}};function as(i){return{point:{x:i.pageX,y:i.pageY}}}const q2=i=>l=>Tf(l)&&i(l,as(l));function Jl(i,l,u,o){return Il(i,l,q2(u),o)}const Vg=({current:i})=>i?i.ownerDocument.defaultView:null,Ly=(i,l)=>Math.abs(i-l);function G2(i,l){const u=Ly(i.x,l.x),o=Ly(i.y,l.y);return Math.sqrt(u**2+o**2)}const Hy=new Set(["auto","scroll"]);class _g{constructor(l,u,{transformPagePoint:o,contextWindow:c=window,dragSnapToOrigin:d=!1,distanceThreshold:h=3,element:m}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=N=>{this.handleScroll(N.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const N=Ec(this.lastMoveEventInfo,this.history),z=this.startEvent!==null,q=G2(N.offset,{x:0,y:0})>=this.distanceThreshold;if(!z&&!q)return;const{point:G}=N,{timestamp:H}=re;this.history.push({...G,timestamp:H});const{onStart:K,onMove:X}=this.handlers;z||(K&&K(this.lastMoveEvent,N),this.startEvent=this.lastMoveEvent),X&&X(this.lastMoveEvent,N)},this.handlePointerMove=(N,z)=>{this.lastMoveEvent=N,this.lastMoveEventInfo=Ac(z,this.transformPagePoint),Ot.update(this.updatePoint,!0)},this.handlePointerUp=(N,z)=>{this.end();const{onEnd:q,onSessionEnd:G,resumeAnimation:H}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&H&&H(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const K=Ec(N.type==="pointercancel"?this.lastMoveEventInfo:Ac(z,this.transformPagePoint),this.history);this.startEvent&&q&&q(N,K),G&&G(N,K)},!Tf(l))return;this.dragSnapToOrigin=d,this.handlers=u,this.transformPagePoint=o,this.distanceThreshold=h,this.contextWindow=c||window;const g=as(l),p=Ac(g,this.transformPagePoint),{point:v}=p,{timestamp:x}=re;this.history=[{...v,timestamp:x}];const{onSessionStart:T}=u;T&&T(l,Ec(p,this.history)),this.removeListeners=ts(Jl(this.contextWindow,"pointermove",this.handlePointerMove),Jl(this.contextWindow,"pointerup",this.handlePointerUp),Jl(this.contextWindow,"pointercancel",this.handlePointerUp)),m&&this.startScrollTracking(m)}startScrollTracking(l){let u=l.parentElement;for(;u;){const o=getComputedStyle(u);(Hy.has(o.overflowX)||Hy.has(o.overflowY))&&this.scrollPositions.set(u,{x:u.scrollLeft,y:u.scrollTop}),u=u.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(l){const u=this.scrollPositions.get(l);if(!u)return;const o=l===window,c=o?{x:window.scrollX,y:window.scrollY}:{x:l.scrollLeft,y:l.scrollTop},d={x:c.x-u.x,y:c.y-u.y};d.x===0&&d.y===0||(o?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=d.x,this.lastMoveEventInfo.point.y+=d.y):this.history.length>0&&(this.history[0].x-=d.x,this.history[0].y-=d.y),this.scrollPositions.set(l,c),Ot.update(this.updatePoint,!0))}updateHandlers(l){this.handlers=l}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ha(this.updatePoint)}}function Ac(i,l){return l?{point:l(i.point)}:i}function Yy(i,l){return{x:i.x-l.x,y:i.y-l.y}}function Ec({point:i},l){return{point:i,delta:Yy(i,Ug(l)),offset:Yy(i,X2(l)),velocity:K2(l,.1)}}function X2(i){return i[0]}function Ug(i){return i[i.length-1]}function K2(i,l){if(i.length<2)return{x:0,y:0};let u=i.length-1,o=null;const c=Ug(i);for(;u>=0&&(o=i[u],!(c.timestamp-o.timestamp>tn(l)));)u--;if(!o)return{x:0,y:0};o===i[0]&&i.length>2&&c.timestamp-o.timestamp>tn(l)*2&&(o=i[1]);const d=Qe(c.timestamp-o.timestamp);if(d===0)return{x:0,y:0};const h={x:(c.x-o.x)/d,y:(c.y-o.y)/d};return h.x===1/0&&(h.x=0),h.y===1/0&&(h.y=0),h}function Q2(i,{min:l,max:u},o){return l!==void 0&&i<l?i=o?Lt(l,i,o.min):Math.max(i,l):u!==void 0&&i>u&&(i=o?Lt(u,i,o.max):Math.min(i,u)),i}function qy(i,l,u){return{min:l!==void 0?i.min+l:void 0,max:u!==void 0?i.max+u-(i.max-i.min):void 0}}function Z2(i,{top:l,left:u,bottom:o,right:c}){return{x:qy(i.x,u,c),y:qy(i.y,l,o)}}function Gy(i,l){let u=l.min-i.min,o=l.max-i.max;return l.max-l.min<i.max-i.min&&([u,o]=[o,u]),{min:u,max:o}}function k2(i,l){return{x:Gy(i.x,l.x),y:Gy(i.y,l.y)}}function J2(i,l){let u=.5;const o=ge(i),c=ge(l);return c>o?u=Fl(l.min,l.max-o,i.min):o>c&&(u=Fl(i.min,i.max-c,l.min)),hn(0,1,u)}function F2(i,l){const u={};return l.min!==void 0&&(u.min=l.min-i.min),l.max!==void 0&&(u.max=l.max-i.min),u}const Pc=.35;function P2(i=Pc){return i===!1?i=0:i===!0&&(i=Pc),{x:Xy(i,"left","right"),y:Xy(i,"top","bottom")}}function Xy(i,l,u){return{min:Ky(i,l),max:Ky(i,u)}}function Ky(i,l){return typeof i=="number"?i:i[l]||0}const W2=new WeakMap;class $2{constructor(l){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ee(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=l}start(l,{snapToCursor:u=!1,distanceThreshold:o}={}){const{presenceContext:c}=this.visualElement;if(c&&c.isPresent===!1)return;const d=x=>{u&&this.snapToCursor(as(x).point),this.stopAnimation()},h=(x,T)=>{const{drag:N,dragPropagation:z,onDragStart:q}=this.getProps();if(N&&!z&&(this.openDragLock&&this.openDragLock(),this.openDragLock=MS(N),!this.openDragLock))return;this.latestPointerEvent=x,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),cn(H=>{let K=this.getAxisMotionValue(H).get()||0;if(fn.test(K)){const{projection:X}=this.visualElement;if(X&&X.layout){const J=X.layout.layoutBox[H];J&&(K=ge(J)*(parseFloat(K)/100))}}this.originPoint[H]=K}),q&&Ot.update(()=>q(x,T),!1,!0),qc(this.visualElement,"transform");const{animationState:G}=this.visualElement;G&&G.setActive("whileDrag",!0)},m=(x,T)=>{this.latestPointerEvent=x,this.latestPanInfo=T;const{dragPropagation:N,dragDirectionLock:z,onDirectionLock:q,onDrag:G}=this.getProps();if(!N&&!this.openDragLock)return;const{offset:H}=T;if(z&&this.currentDirection===null){this.currentDirection=tA(H),this.currentDirection!==null&&q&&q(this.currentDirection);return}this.updateAxis("x",T.point,H),this.updateAxis("y",T.point,H),this.visualElement.render(),G&&Ot.update(()=>G(x,T),!1,!0)},g=(x,T)=>{this.latestPointerEvent=x,this.latestPanInfo=T,this.stop(x,T),this.latestPointerEvent=null,this.latestPanInfo=null},p=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:v}=this.getProps();this.panSession=new _g(l,{onSessionStart:d,onStart:h,onMove:m,onSessionEnd:g,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:v,distanceThreshold:o,contextWindow:Vg(this.visualElement),element:this.visualElement.current})}stop(l,u){const o=l||this.latestPointerEvent,c=u||this.latestPanInfo,d=this.isDragging;if(this.cancel(),!d||!c||!o)return;const{velocity:h}=c;this.startAnimation(h);const{onDragEnd:m}=this.getProps();m&&Ot.postRender(()=>m(o,c))}cancel(){this.isDragging=!1;const{projection:l,animationState:u}=this.visualElement;l&&(l.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:o}=this.getProps();!o&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),u&&u.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(l,u,o){const{drag:c}=this.getProps();if(!o||!Cu(l,c,this.currentDirection))return;const d=this.getAxisMotionValue(l);let h=this.originPoint[l]+o[l];this.constraints&&this.constraints[l]&&(h=Q2(h,this.constraints[l],this.elastic[l])),d.set(h)}resolveConstraints(){const{dragConstraints:l,dragElastic:u}=this.getProps(),o=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,c=this.constraints;l&&zi(l)?this.constraints||(this.constraints=this.resolveRefConstraints()):l&&o?this.constraints=Z2(o.layoutBox,l):this.constraints=!1,this.elastic=P2(u),c!==this.constraints&&!zi(l)&&o&&this.constraints&&!this.hasMutatedConstraints&&cn(d=>{this.constraints!==!1&&this.getAxisMotionValue(d)&&(this.constraints[d]=F2(o.layoutBox[d],this.constraints[d]))})}resolveRefConstraints(){const{dragConstraints:l,onMeasureDragConstraints:u}=this.getProps();if(!l||!zi(l))return!1;const o=l.current,{projection:c}=this.visualElement;if(!c||!c.layout)return!1;const d=eT(o,c.root,this.visualElement.getTransformPagePoint());let h=k2(c.layout.layoutBox,d);if(u){const m=u($S(h));this.hasMutatedConstraints=!!m,m&&(h=ag(m))}return h}startAnimation(l){const{drag:u,dragMomentum:o,dragElastic:c,dragTransition:d,dragSnapToOrigin:h,onDragTransitionEnd:m}=this.getProps(),g=this.constraints||{},p=cn(v=>{if(!Cu(v,u,this.currentDirection))return;let x=g&&g[v]||{};h&&(x={min:0,max:0});const T=c?200:1e6,N=c?40:1e7,z={type:"inertia",velocity:o?l[v]:0,bounceStiffness:T,bounceDamping:N,timeConstant:750,restDelta:1,restSpeed:10,...d,...x};return this.startAxisValueAnimation(v,z)});return Promise.all(p).then(m)}startAxisValueAnimation(l,u){const o=this.getAxisMotionValue(l);return qc(this.visualElement,l),o.start(gf(l,o,0,u,this.visualElement,!1))}stopAnimation(){cn(l=>this.getAxisMotionValue(l).stop())}getAxisMotionValue(l){const u=`_drag${l.toUpperCase()}`,o=this.visualElement.getProps(),c=o[u];return c||this.visualElement.getValue(l,(o.initial?o.initial[l]:void 0)||0)}snapToCursor(l){cn(u=>{const{drag:o}=this.getProps();if(!Cu(u,o,this.currentDirection))return;const{projection:c}=this.visualElement,d=this.getAxisMotionValue(u);if(c&&c.layout){const{min:h,max:m}=c.layout.layoutBox[u],g=d.get()||0;d.set(l[u]-Lt(h,m,.5)+g)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:l,dragConstraints:u}=this.getProps(),{projection:o}=this.visualElement;if(!zi(u)||!o||!this.constraints)return;this.stopAnimation();const c={x:0,y:0};cn(h=>{const m=this.getAxisMotionValue(h);if(m&&this.constraints!==!1){const g=m.get();c[h]=J2({min:g,max:g},this.constraints[h])}});const{transformTemplate:d}=this.visualElement.getProps();this.visualElement.current.style.transform=d?d({},""):"none",o.root&&o.root.updateScroll(),o.updateLayout(),this.constraints=!1,this.resolveConstraints(),cn(h=>{if(!Cu(h,l,null))return;const m=this.getAxisMotionValue(h),{min:g,max:p}=this.constraints[h];m.set(Lt(g,p,c[h]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;W2.set(this.visualElement,this);const l=this.visualElement.current,u=Jl(l,"pointerdown",p=>{const{drag:v,dragListener:x=!0}=this.getProps(),T=p.target,N=T!==l&&zS(T);v&&x&&!N&&this.start(p)});let o;const c=()=>{const{dragConstraints:p}=this.getProps();zi(p)&&p.current&&(this.constraints=this.resolveRefConstraints(),o||(o=I2(l,p.current,()=>this.scalePositionWithinConstraints())))},{projection:d}=this.visualElement,h=d.addEventListener("measure",c);d&&!d.layout&&(d.root&&d.root.updateScroll(),d.updateLayout()),Ot.read(c);const m=Il(window,"resize",()=>this.scalePositionWithinConstraints()),g=d.addEventListener("didUpdate",(({delta:p,hasLayoutChanged:v})=>{this.isDragging&&v&&(cn(x=>{const T=this.getAxisMotionValue(x);T&&(this.originPoint[x]+=p[x].translate,T.set(T.get()+p[x].translate))}),this.visualElement.render())}));return()=>{m(),u(),h(),g&&g(),o&&o()}}getProps(){const l=this.visualElement.getProps(),{drag:u=!1,dragDirectionLock:o=!1,dragPropagation:c=!1,dragConstraints:d=!1,dragElastic:h=Pc,dragMomentum:m=!0}=l;return{...l,drag:u,dragDirectionLock:o,dragPropagation:c,dragConstraints:d,dragElastic:h,dragMomentum:m}}}function Qy(i){let l=!0;return()=>{if(l){l=!1;return}i()}}function I2(i,l,u){const o=$p(i,Qy(u)),c=$p(l,Qy(u));return()=>{o(),c()}}function Cu(i,l,u){return(l===!0||l===i)&&(u===null||u===i)}function tA(i,l=10){let u=null;return Math.abs(i.y)>l?u="y":Math.abs(i.x)>l&&(u="x"),u}class eA extends da{constructor(l){super(l),this.removeGroupControls=Ze,this.removeListeners=Ze,this.controls=new $2(l)}mount(){const{dragControls:l}=this.node.getProps();l&&(this.removeGroupControls=l.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ze}update(){const{dragControls:l}=this.node.getProps(),{dragControls:u}=this.node.prevProps||{};l!==u&&(this.removeGroupControls(),l&&(this.removeGroupControls=l.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Cc=i=>(l,u)=>{i&&Ot.update(()=>i(l,u),!1,!0)};class nA extends da{constructor(){super(...arguments),this.removePointerDownListener=Ze}onPointerDown(l){this.session=new _g(l,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Vg(this.node)})}createPanHandlers(){const{onPanSessionStart:l,onPanStart:u,onPan:o,onPanEnd:c}=this.node.getProps();return{onSessionStart:Cc(l),onStart:Cc(u),onMove:Cc(o),onEnd:(d,h)=>{delete this.session,c&&Ot.postRender(()=>c(d,h))}}}mount(){this.removePointerDownListener=Jl(this.node.current,"pointerdown",l=>this.onPointerDown(l))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Mc=!1;class aA extends _.Component{componentDidMount(){const{visualElement:l,layoutGroup:u,switchLayoutGroup:o,layoutId:c}=this.props,{projection:d}=l;d&&(u.group&&u.group.add(d),o&&o.register&&c&&o.register(d),Mc&&d.root.didUpdate(),d.addEventListener("animationComplete",()=>{this.safeToRemove()}),d.setOptions({...d.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),zu.hasEverUpdated=!0}getSnapshotBeforeUpdate(l){const{layoutDependency:u,visualElement:o,drag:c,isPresent:d}=this.props,{projection:h}=o;return h&&(h.isPresent=d,l.layoutDependency!==u&&h.setOptions({...h.options,layoutDependency:u}),Mc=!0,c||l.layoutDependency!==u||u===void 0||l.isPresent!==d?h.willUpdate():this.safeToRemove(),l.isPresent!==d&&(d?h.promote():h.relegate()||Ot.postRender(()=>{const m=h.getStack();(!m||!m.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:l}=this.props.visualElement;l&&(l.root.didUpdate(),Sf.postRender(()=>{!l.currentAnimation&&l.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:l,layoutGroup:u,switchLayoutGroup:o}=this.props,{projection:c}=l;Mc=!0,c&&(c.scheduleCheckAfterUnmount(),u&&u.group&&u.group.remove(c),o&&o.deregister&&o.deregister(c))}safeToRemove(){const{safeToRemove:l}=this.props;l&&l()}render(){return null}}function Bg(i){const[l,u]=Cg(),o=_.useContext(Ic);return b.jsx(aA,{...i,layoutGroup:o,switchLayoutGroup:_.useContext(zg),isPresent:l,safeToRemove:u})}const iA={pan:{Feature:nA},drag:{Feature:eA,ProjectionNode:Eg,MeasureLayout:Bg}};function Zy(i,l,u){const{props:o}=i;i.animationState&&o.whileHover&&i.animationState.setActive("whileHover",u==="Start");const c="onHover"+u,d=o[c];d&&Ot.postRender(()=>d(l,as(l)))}class lA extends da{mount(){const{current:l}=this.node;l&&(this.unmount=wS(l,(u,o)=>(Zy(this.node,o,"Start"),c=>Zy(this.node,c,"End"))))}unmount(){}}class sA extends da{constructor(){super(...arguments),this.isActive=!1}onFocus(){let l=!1;try{l=this.node.current.matches(":focus-visible")}catch{l=!0}!l||!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=ts(Il(this.node.current,"focus",()=>this.onFocus()),Il(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ky(i,l,u){const{props:o}=i;if(i.current instanceof HTMLButtonElement&&i.current.disabled)return;i.animationState&&o.whileTap&&i.animationState.setActive("whileTap",u==="Start");const c="onTap"+(u==="End"?"":u),d=o[c];d&&Ot.postRender(()=>d(l,as(l)))}class uA extends da{mount(){const{current:l}=this.node;if(!l)return;const{globalTapTarget:u,propagate:o}=this.node.props;this.unmount=VS(l,(c,d)=>(ky(this.node,d,"Start"),(h,{success:m})=>ky(this.node,h,m?"End":"Cancel")),{useGlobalTarget:u,stopPropagation:o?.tap===!1})}unmount(){}}const Wc=new WeakMap,Dc=new WeakMap,oA=i=>{const l=Wc.get(i.target);l&&l(i)},rA=i=>{i.forEach(oA)};function cA({root:i,...l}){const u=i||document;Dc.has(u)||Dc.set(u,{});const o=Dc.get(u),c=JSON.stringify(l);return o[c]||(o[c]=new IntersectionObserver(rA,{root:i,...l})),o[c]}function fA(i,l,u){const o=cA(l);return Wc.set(i,u),o.observe(i),()=>{Wc.delete(i),o.unobserve(i)}}const hA={some:0,all:1};class dA extends da{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:l={}}=this.node.getProps(),{root:u,margin:o,amount:c="some",once:d}=l,h={root:u?u.current:void 0,rootMargin:o,threshold:typeof c=="number"?c:hA[c]},m=g=>{const{isIntersecting:p}=g;if(this.isInView===p||(this.isInView=p,d&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:v,onViewportLeave:x}=this.node.getProps(),T=p?v:x;T&&T(g)};return fA(this.node.current,h,m)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:l,prevProps:u}=this.node;["amount","margin","root"].some(mA(l,u))&&this.startObserver()}unmount(){}}function mA({viewport:i={}},{viewport:l={}}={}){return u=>i[u]!==l[u]}const pA={inView:{Feature:dA},tap:{Feature:uA},focus:{Feature:sA},hover:{Feature:lA}},yA={layout:{ProjectionNode:Eg,MeasureLayout:Bg}},gA={...Y2,...pA,...iA,...yA},Jy=_2(gA,U2),vA=[{id:"anthropic",name:"Claude",subtitle:"by Anthropic",icon:"/icons/claude.png"},{id:"openai",name:"OpenAI Codex",subtitle:"ChatGPT Plus / Pro",icon:"/icons/codex.png"}],xA={anthropic:[{id:"claude-opus-4-6",label:"Opus 4.6"},{id:"claude-sonnet-4-6",label:"Sonnet 4.6"},{id:"claude-haiku-4-5-20251001",label:"Haiku 4.5"}],openai:[{id:"gpt-5.2-codex:medium",label:"GPT-5.2 Codex Medium"},{id:"gpt-5.2-codex:high",label:"GPT-5.2 Codex High"},{id:"gpt-5.2-codex:xhigh",label:"GPT-5.2 Codex Extra High"},{id:"gpt-5.3-codex:medium",label:"GPT-5.3 Codex Medium (Pro)"},{id:"gpt-5.3-codex:high",label:"GPT-5.3 Codex High (Pro)"},{id:"gpt-5.3-codex:xhigh",label:"GPT-5.3 Codex Extra High (Pro)"}]},Fy=[{tier:"premium",label:i=>`${i}.fluxy.bot`,badge:"$5",badgeCls:"bg-[#AF27E3]/15 text-[#AF27E3] border-[#AF27E3]/20",highlight:!0},{tier:"at",label:i=>`${i}.at.fluxy.bot`,badge:"Free",badgeCls:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",highlight:!1}];function bA({models:i,value:l,onChange:u}){const[o,c]=_.useState(!1),d=_.useRef(null);_.useEffect(()=>{if(!o)return;const m=g=>{d.current&&!d.current.contains(g.target)&&c(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]);const h=i.find(m=>m.id===l);return b.jsxs("div",{className:"relative",ref:d,children:[b.jsxs("button",{type:"button",onClick:()=>c(m=>!m),className:"w-full flex items-center justify-between 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",children:[b.jsx("span",{className:h?"text-white":"text-white/20",children:h?h.label:"Choose a model..."}),b.jsx(fx,{className:`h-4 w-4 text-white/30 transition-transform ${o?"rotate-180":""}`})]}),o&&b.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[#222] border border-white/[0.08] rounded-xl shadow-xl py-1 z-10 max-h-48 overflow-y-auto",children:i.map(m=>b.jsx("button",{onClick:()=>{u(m.id),c(!1)},className:`w-full text-left px-4 py-2 text-[13px] transition-colors ${l===m.id?"text-[#AF27E3] bg-[#AF27E3]/10":"text-white/70 hover:bg-white/[0.04] hover:text-white"}`,children:m.label},m.id))})]})}function EA({onComplete:i,isInitialSetup:l=!1}){const u=l?7:6,[o,c]=_.useState(0),[d,h]=_.useState(""),[m,g]=_.useState("anthropic"),[p,v]=_.useState(""),[x,T]=_.useState(!1),[N,z]=_.useState({anthropic:"idle",openai:"idle"}),[q,G]=_.useState(!1),[H,K]=_.useState(""),[X,J]=_.useState(!1),[Z,nt]=_.useState(),[I,F]=_.useState(!1),[lt,xt]=_.useState(!1),[_t,zt]=_.useState(),[jt,ie]=_.useState(""),[Bt,O]=_.useState(null),[Y,k]=_.useState(""),[ct,dt]=_.useState({}),[A,U]=_.useState("at"),[Q,P]=_.useState(!1),[et,st]=_.useState(!1),[ht,Kt]=_.useState(""),wt=_.useRef(null),[de,ma]=_.useState(null),[Oe,qa]=_.useState(!1),[nn,Ga]=_.useState(!1),[Xi,Qu]=_.useState("admin"),[ze,Ki]=_.useState(""),[pa,Qi]=_.useState(""),[Zu,is]=_.useState(!1),[Ht,ku]=_.useState(!1),[Zi,ls]=_.useState(!1),[Un,Ju]=_.useState(""),[ki,Xa]=_.useState(""),[Ka,Bn]=_.useState(!1),[ce,ke]=_.useState(!1),[Yt,ss]=_.useState(!1),[Je,us]=_.useState(""),Ln=_.useRef(!1),Re=N[m]==="connected";_.useEffect(()=>{fetch("/api/onboard/status").then(B=>B.json()).then(B=>{B.userName&&h(B.userName),B.handle&&(ie(B.handle.username),U(B.handle.tier||"at"),ma({username:B.handle.username,tier:B.handle.tier,url:B.handle.url}),st(!0),Kt(B.handle.url)),B.portalUser&&Qu(B.portalUser),B.portalConfigured&&ku(!0),B.provider&&g(B.provider),B.model&&v(B.model),B.whisperEnabled&&(ss(!0),us(B.whisperKey||"")),Ln.current=!0}).catch(()=>{Ln.current=!0})},[]),_.useEffect(()=>{m!=="anthropic"||N.anthropic==="connected"||fetch("/api/auth/claude/status").then(B=>B.json()).then(B=>{B.authenticated&&z(ot=>({...ot,anthropic:"connected"}))}).catch(()=>{})},[m]),_.useEffect(()=>{m!=="openai"||N.openai==="connected"||fetch("/api/auth/codex/status").then(B=>B.json()).then(B=>{B.authenticated&&z(ot=>({...ot,openai:"connected"}))}).catch(()=>{})},[m]),_.useEffect(()=>{if(!lt)return;const B=setInterval(async()=>{try{(await(await fetch("/api/auth/codex/status")).json()).authenticated&&(xt(!1),z(yn=>({...yn,openai:"connected"})))}catch{}},2e3);return()=>clearInterval(B)},[lt]),_.useEffect(()=>{if(wt.current&&clearTimeout(wt.current),!Ln.current||de&&et&&jt===de.username)return;O(null),k(""),dt({}),st(!1),Kt("");const B=jt.trim();if(B){if(B.length<3){O("invalid"),k("At least 3 characters");return}return O("checking"),wt.current=setTimeout(async()=>{try{const me=await(await fetch(`/api/handle/check/${encodeURIComponent(B)}`)).json();if(!me.valid)O("invalid"),k(me.error);else{const yn={};for(const Yn of me.handles)yn[Yn.tier]=Yn.available;dt(yn),O("ready");const Hn=Fy.find(Yn=>yn[Yn.tier]);Hn&&!yn[A]&&U(Hn.tier)}}catch{O(null)}},400),()=>{wt.current&&clearTimeout(wt.current)}}},[jt]);const Qa=B=>{ie(B.toLowerCase().replace(/[^a-z0-9-]/g,""))},mn=async()=>{if(!(!jt||Bt!=="ready"||!ct[A])){P(!0);try{const ot=await(await fetch("/api/handle/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:jt,tier:A})})).json();ot.ok?(st(!0),Kt(ot.url)):(k(ot.error||"Registration failed"),O("invalid"))}catch{k("Could not reach server"),O("invalid")}finally{P(!1)}}},Za=async()=>{if(!(!jt||Bt!=="ready"||!ct[A])){Ga(!0);try{const ot=await(await fetch("/api/handle/change",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:jt,tier:A})})).json();ot.ok?(st(!0),Kt(ot.url),ma({username:jt,tier:A,url:ot.url}),qa(!1)):(k(ot.error||"Handle change failed"),O("invalid"))}catch{k("Could not reach server"),O("invalid")}finally{Ga(!1)}}},ya=B=>{m==="openai"&&B!=="openai"&&lt&&(fetch("/api/auth/codex/cancel",{method:"POST"}),xt(!1)),g(B),v(""),G(!1),K(""),nt(void 0),xt(!1),zt(void 0)},Fu=async()=>{nt(void 0);try{const ot=await(await fetch("/api/auth/claude/start",{method:"POST"})).json();ot.success&&ot.authUrl?(window.open(ot.authUrl,"_blank"),G(!0)):nt(ot.error||"Failed to start authentication")}catch(B){nt(B.message)}},Ji=async()=>{if(H.trim()){J(!0),nt(void 0);try{const ot=await(await fetch("/api/auth/claude/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:H.trim()})})).json();ot.success?z(me=>({...me,anthropic:"connected"})):nt(ot.error||"Code exchange failed")}catch(B){nt(B.message)}finally{J(!1)}}},Fi=async()=>{try{const B=await navigator.clipboard.readText();B&&K(B.trim())}catch{}},ga=async()=>{F(!0),nt(void 0);try{(await(await fetch("/api/auth/claude/status")).json()).authenticated?z(me=>({...me,anthropic:"connected"})):nt("No active session found. Please authenticate first.")}catch{}finally{F(!1)}},Pu=async()=>{xt(!0),zt(void 0);try{const ot=await(await fetch("/api/auth/codex/start",{method:"POST"})).json();ot.success&&ot.authUrl?window.open(ot.authUrl,"_blank"):(xt(!1),zt(ot.error||"Failed to start authentication"))}catch(B){xt(!1),zt(B.message)}},os=()=>{xt(!1),fetch("/api/auth/codex/cancel",{method:"POST"})},Pi=ze===pa,Wi=ze.length>=6&&Pi,$i=Ht?ze.length===0||Ka&&Wi:Wi,pn=(()=>{switch(o){case 0:return!0;case 1:return d.trim().length>0;case 2:return et;case 3:return $i;case 4:return!!(m&&p&&Re);case 5:return!0;default:return!1}})(),an=()=>{pn&&o<u-1&&c(B=>B+1)},rs=()=>{o>0&&c(B=>B-1)},Ve=B=>{B.key==="Enter"&&pn&&an()},It=async()=>{T(!0);try{await fetch("/api/onboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userName:d.trim(),agentName:jt.trim()||"Fluxy",provider:m,model:p,apiKey:"",whisperEnabled:Yt,whisperKey:Yt?Je:"",portalUser:Xi.trim(),portalPass:ze})}),l?(T(!1),c(6)):i()}catch(B){console.error("Onboard failed:",B),T(!1)}},Qt="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";return b.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4",children:[b.jsx("div",{className:"absolute inset-0 bg-black/85 backdrop-blur-md"}),b.jsxs(Jy.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:[b.jsx("div",{className:"flex justify-center gap-2 pt-6",children:Array.from({length:u},(B,ot)=>b.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${ot===o?"w-7 bg-gradient-brand":ot<o?"w-1.5 bg-gradient-brand opacity-60":"w-1.5 bg-white/10"}`},ot))}),b.jsx(c2,{mode:"wait",children:b.jsxs(Jy.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:[o===0&&b.jsxs("div",{className:"flex flex-col items-center text-center",children:[b.jsx("video",{src:"/fluxy_say_hi.webm",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"h-[180px] mb-4"}),b.jsx("h1",{className:"text-2xl font-bold text-white tracking-tight",children:"Welcome to Fluxy"}),b.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."}),b.jsxs("button",{onClick:an,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",b.jsx(rn,{className:"h-4 w-4"})]})]}),o===1&&b.jsxs("div",{children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"What's your name?"}),b.jsx("p",{className:"text-white/40 text-[13px] mt-1.5 leading-relaxed",children:"This is how your agent will address you."}),b.jsxs("div",{className:"mt-5 flex items-center gap-3",children:[b.jsx("input",{type:"text",value:d,onChange:B=>h(B.target.value),onKeyDown:Ve,placeholder:"Enter your name",autoFocus:!0,className:Qt+" flex-1"}),b.jsx("button",{onClick:an,disabled:!pn,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:b.jsx(rn,{className:"h-5 w-5"})})]})]}),o===2&&b.jsxs("div",{children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Name your bot"}),b.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."}),de&&et&&!Oe&&b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(ji,{className:"h-4 w-4 text-emerald-400"}),b.jsx("p",{className:"text-emerald-400/90 text-[13px] font-medium",children:"Current handle"})]}),b.jsx("p",{className:"text-emerald-400/60 text-[12px] mt-1 font-mono",children:ht})]}),b.jsxs("div",{className:"flex gap-2 mt-4",children:[b.jsxs("button",{onClick:an,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",b.jsx(rn,{className:"h-4 w-4"})]}),b.jsx("button",{onClick:()=>{qa(!0),st(!1),ie(""),O(null),dt({})},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"})]})]}),Oe&&!et&&b.jsxs("div",{className:"mt-4 bg-amber-500/8 border border-amber-500/20 rounded-xl px-4 py-3",children:[b.jsx("p",{className:"text-amber-400/90 text-[13px] font-medium",children:"Changing your handle"}),b.jsxs("p",{className:"text-amber-400/60 text-[12px] mt-1",children:["Your current handle ",b.jsx("span",{className:"font-mono",children:de?.url})," will be released and become available for others."]})]}),(!de||Oe||!et)&&!(de&&et&&!Oe)&&b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"relative mt-5",children:[b.jsx("input",{type:"text",value:jt,onChange:B=>Qa(B.target.value),maxLength:30,placeholder:"your-bot-name",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",autoFocus:!0,disabled:et,className:Qt+" pr-10 font-mono"+(et?" opacity-50":"")}),Bt&&jt.length>0&&!et&&b.jsxs("div",{className:"absolute right-4 top-1/2 -translate-y-1/2",children:[Bt==="checking"&&b.jsx("div",{className:"w-5 h-5 border-2 border-white/10 border-t-[#04D1FE] rounded-full animate-spin"}),Bt==="invalid"&&b.jsx("div",{className:"w-6 h-6 rounded-full bg-amber-500/15 flex items-center justify-center",children:b.jsx("svg",{className:"w-3.5 h-3.5 text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3m0 4h.01"})})})]})]}),Bt==="invalid"&&Y&&b.jsx("p",{className:"text-amber-400 text-[12px] mt-2",children:Y}),Bt==="ready"&&jt.length>0&&!et&&b.jsx("div",{className:"space-y-2 mt-4",children:Fy.map(B=>{const me=ct[B.tier]===!1;return b.jsxs("button",{onClick:()=>!me&&U(B.tier),disabled:me,className:`w-full flex items-center justify-between px-4 py-3 rounded-xl border transition-all duration-200 text-left ${me?"border-white/[0.04] bg-transparent opacity-50 cursor-not-allowed":A===B.tier?B.highlight?"border-[#AF27E3]/40 bg-[#AF27E3]/[0.06]":"border-[#AF27E3]/30 bg-white/[0.04]":"border-white/[0.06] bg-transparent hover:border-white/10 hover:bg-white/[0.02]"}`,children:[b.jsx("span",{className:"font-mono text-[13px] text-white/70",children:B.label(jt)}),me?b.jsx("span",{className:"text-[11px] font-medium px-2.5 py-0.5 rounded-full border bg-red-500/10 text-red-400 border-red-500/20",children:"Taken"}):b.jsx("span",{className:`text-[11px] font-medium px-2.5 py-0.5 rounded-full border ${B.badgeCls}`,children:B.badge})]},B.tier)})}),et&&b.jsxs("div",{className:"mt-4 bg-emerald-500/8 border border-emerald-500/15 rounded-xl px-4 py-3",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(ji,{className:"h-4 w-4 text-emerald-400"}),b.jsx("p",{className:"text-emerald-400/90 text-[13px] font-medium",children:"Handle claimed!"})]}),b.jsx("p",{className:"text-emerald-400/60 text-[12px] mt-1 font-mono",children:ht})]}),Bt==="ready"&&ct[A]&&jt.length>0&&!et&&b.jsx("button",{onClick:Oe?Za:mn,disabled:Q||nn,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:Q||nn?b.jsxs(b.Fragment,{children:[b.jsx(Oi,{className:"h-4 w-4 animate-spin"}),Oe?"Changing...":"Claiming..."]}):b.jsxs(b.Fragment,{children:[Oe?"Change Handle":"Claim & Continue",b.jsx(rn,{className:"h-4 w-4"})]})}),et&&b.jsxs("button",{onClick:an,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",b.jsx(rn,{className:"h-4 w-4"})]}),Oe&&!et&&b.jsx("button",{onClick:()=>{qa(!1),ie(de.username),st(!0),Kt(de.url),U(de.tier),O(null)},className:"w-full mt-2 py-2 text-white/25 hover:text-white/40 text-[12px] transition-colors",children:"Cancel — keep current handle"})]})]}),o===3&&b.jsxs("div",{children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Set a password"}),b.jsx("p",{className:"text-white/40 text-[13px] mt-1.5 leading-relaxed",children:"You'll need this password to access your agent's chat. Keep it safe — anyone with your URL will need it to log in."}),Ht&&b.jsx("div",{className:"mt-4 bg-white/[0.02] border border-white/[0.06] rounded-xl px-4 py-2.5",children:b.jsx("p",{className:"text-white/40 text-[12px]",children:"Password already set. Leave fields empty to keep your current password, or enter your current password to change it."})}),Ht&&b.jsxs("div",{className:"mt-5",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:"Current password"}),b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("input",{type:"password",value:Un,onChange:B=>{Ju(B.target.value),Xa(""),Bn(!1)},placeholder:"Enter current password to change it",autoComplete:"current-password",autoFocus:!0,className:Qt+" flex-1"}),Un.length>0&&!Ka&&b.jsx("button",{onClick:async()=>{ke(!0),Xa("");try{(await(await fetch("/api/portal/verify-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:Un})})).json()).valid?Bn(!0):Xa("Incorrect password")}catch{Xa("Could not verify")}finally{ke(!1)}},disabled:ce,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:ce?b.jsx(Oi,{className:"h-4 w-4 animate-spin"}):"Verify"}),Ka&&b.jsx("div",{className:"shrink-0 w-10 h-10 flex items-center justify-center",children:b.jsx(ji,{className:"h-4 w-4 text-emerald-400"})})]}),ki&&b.jsx("p",{className:"text-red-400/70 text-[11px] mt-1",children:ki})]}),(!Ht||Ka)&&b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:Ht?"mt-3":"mt-5",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:Ht?"New password":"Password"}),b.jsx("input",{type:"password",value:ze,onChange:B=>Ki(B.target.value),placeholder:"••••••••",autoComplete:"new-password",autoFocus:!Ht,onKeyDown:Ve,className:Qt}),ze.length>0&&ze.length<6&&b.jsx("p",{className:"text-amber-400/70 text-[11px] mt-1",children:"At least 6 characters"})]}),b.jsxs("div",{className:"mt-3",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:Ht?"Confirm new password":"Confirm password"}),b.jsx("input",{type:"password",value:pa,onChange:B=>Qi(B.target.value),placeholder:"••••••••",autoComplete:"new-password",onKeyDown:Ve,className:Qt}),pa.length>0&&!Pi&&b.jsx("p",{className:"text-red-400/70 text-[11px] mt-1",children:"Passwords don't match"})]})]}),b.jsxs("button",{onClick:an,disabled:!pn,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",b.jsx(rn,{className:"h-4 w-4"})]})]}),o===4&&b.jsxs("div",{children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Choose your AI provider"}),b.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."}),b.jsx("div",{className:"flex gap-2.5 mt-4",children:vA.map(B=>b.jsxs("button",{onClick:()=>ya(B.id),className:`flex-1 relative rounded-xl border transition-all duration-200 p-3 text-left ${m===B.id?"bg-white/[0.04] border-[#AF27E3]/40":"bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]"}`,children:[b.jsxs("div",{className:"flex flex-col items-center gap-1.5 py-0.5",children:[B.icon?b.jsx("img",{src:B.icon,alt:B.name,className:"w-8 h-8 rounded-lg"}):b.jsx("div",{className:"w-8 h-8 rounded-lg bg-white/[0.06] flex items-center justify-center text-white/50 text-sm font-bold",children:"O"}),b.jsxs("div",{className:"text-center",children:[b.jsx("div",{className:"text-[13px] font-medium text-white",children:B.name}),b.jsx("div",{className:"text-[10px] text-white/30",children:B.subtitle})]})]}),N[B.id]==="connected"?b.jsx("div",{className:"absolute top-2 right-2 w-4 h-4 rounded-full bg-emerald-500/15 flex items-center justify-center",children:b.jsx(ji,{className:"h-2.5 w-2.5 text-emerald-400"})}):m===B.id?b.jsx("div",{className:"absolute top-2 right-2 w-2 h-2 rounded-full bg-gradient-brand"}):null]},B.id))}),b.jsx("div",{className:"border-t border-white/[0.06] mt-4 mb-3"}),m==="anthropic"&&b.jsxs("div",{className:"space-y-2.5",children:[Re&&b.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5",children:b.jsx("p",{className:"text-emerald-400/90 text-[12px]",children:"Connected — Anthropic subscription is active."})}),!Re&&b.jsxs(b.Fragment,{children:[Z&&b.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5",children:b.jsx("p",{className:"text-red-400/90 text-[12px]",children:Z})}),b.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((B,ot)=>b.jsxs("div",{className:"flex items-start gap-2",children:[b.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:ot+1}),b.jsx("p",{className:"text-white/40 text-[12px] leading-relaxed",children:B})]},ot))}),b.jsx("button",{onClick:Fu,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:q?b.jsxs(b.Fragment,{children:[b.jsx(Op,{className:"h-3.5 w-3.5 opacity-60"}),"Open authentication page again"]}):b.jsxs(b.Fragment,{children:["Authenticate with Anthropic",b.jsx(rn,{className:"h-3.5 w-3.5 opacity-60"})]})}),b.jsxs("div",{className:"relative",children:[b.jsx("input",{type:"text",value:H,onChange:B=>K(B.target.value),onKeyDown:B=>B.key==="Enter"&&Ji(),placeholder:"Paste your code here...",className:"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"+" pr-10 font-mono"}),b.jsx("button",{onClick:Fi,className:"absolute right-3 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/50 transition-colors",children:b.jsx(dx,{className:"h-3.5 w-3.5"})})]}),b.jsx("button",{onClick:Ji,disabled:!H.trim()||X,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:X?b.jsxs(b.Fragment,{children:[b.jsx(Oi,{className:"h-3.5 w-3.5 animate-spin"}),"Verifying..."]}):"Connect"}),b.jsxs("button",{onClick:ga,disabled:I,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:[I?b.jsx(Oi,{className:"h-3 w-3 animate-spin"}):b.jsx(Ax,{className:"h-3 w-3"}),I?"Checking...":"I'm already authenticated"]})]})]}),m==="openai"&&b.jsxs("div",{className:"space-y-2.5",children:[Re&&b.jsx("div",{className:"bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5",children:b.jsx("p",{className:"text-emerald-400/90 text-[12px]",children:"Connected — ChatGPT subscription is active."})}),!Re&&b.jsxs(b.Fragment,{children:[_t&&b.jsx("div",{className:"bg-red-500/8 border border-red-500/15 rounded-lg px-3.5 py-2.5",children:b.jsx("p",{className:"text-red-400/90 text-[12px]",children:_t})}),b.jsx("div",{className:"space-y-1.5",children:["Click the button below — your browser will open for ChatGPT sign-in","Sign in with your ChatGPT Plus or Pro account","Authentication completes automatically — no code to copy"].map((B,ot)=>b.jsxs("div",{className:"flex items-start gap-2",children:[b.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:ot+1}),b.jsx("p",{className:"text-white/40 text-[12px] leading-relaxed",children:B})]},ot))}),b.jsx("button",{onClick:Pu,disabled:lt,className:"w-full py-2.5 px-4 bg-white/[0.06] hover:bg-white/[0.09] text-white text-[13px] font-medium rounded-xl transition-colors flex items-center justify-center gap-2 disabled:opacity-60",children:lt?b.jsxs(b.Fragment,{children:[b.jsx(Oi,{className:"h-3.5 w-3.5 animate-spin opacity-60"}),"Waiting for sign-in..."]}):b.jsxs(b.Fragment,{children:["Authenticate with ChatGPT",b.jsx(rn,{className:"h-3.5 w-3.5 opacity-60"})]})}),lt&&b.jsx("button",{onClick:os,className:"w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors",children:"Cancel"})]})]}),Re&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"border-t border-white/[0.06] mt-4 mb-3"}),b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:"Select a model"}),b.jsx(bA,{models:xA[m]||[],value:p,onChange:v})]}),Re&&b.jsxs("button",{onClick:an,disabled:!pn,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",b.jsx(rn,{className:"h-4 w-4"})]})]}),o===5&&b.jsxs("div",{children:[b.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[b.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Voice Messages"}),b.jsx("span",{className:"text-[11px] text-white/25 font-medium bg-white/[0.04] border border-white/[0.06] rounded-full px-2.5 py-0.5",children:"Optional"})]}),b.jsx("p",{className:"text-white/40 text-[13px] mt-1 leading-relaxed",children:"Allow users to send audio messages that are automatically transcribed."}),b.jsx("button",{onClick:()=>ss(B=>!B),className:`w-full mt-5 rounded-xl border transition-all duration-200 p-4 text-left ${Yt?"bg-white/[0.04] border-[#AF27E3]/40":"bg-transparent border-white/[0.06] hover:border-white/10 hover:bg-white/[0.02]"}`,children:b.jsxs("div",{className:"flex items-center gap-3.5",children:[b.jsx("img",{src:"/icons/openai.svg",alt:"OpenAI",className:"w-10 h-10 rounded-xl bg-white/[0.04] p-1.5"}),b.jsxs("div",{className:"flex-1",children:[b.jsx("div",{className:"text-[14px] font-medium text-white",children:"OpenAI Whisper"}),b.jsx("div",{className:"text-[12px] text-white/35 mt-0.5 leading-relaxed",children:"Speech-to-text powered by OpenAI. Requires an OpenAI API key."})]}),b.jsx("div",{className:`w-10 h-[22px] rounded-full transition-colors duration-200 flex items-center px-0.5 shrink-0 ${Yt?"bg-gradient-brand":"bg-white/[0.08]"}`,children:b.jsx("div",{className:`w-[18px] h-[18px] rounded-full bg-white shadow-sm transition-transform duration-200 ${Yt?"translate-x-[18px]":"translate-x-0"}`})})]})}),Yt&&b.jsxs("div",{className:"mt-3",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block",children:"OpenAI API Key"}),b.jsx("input",{type:"password",value:Je,onChange:B=>us(B.target.value.trim()),placeholder:"sk-...",autoComplete:"off",className:Qt+" font-mono text-[13px]"}),Je.length>0&&!Je.startsWith("sk-")&&b.jsx("p",{className:"text-amber-400/70 text-[11px] mt-1",children:"Key should start with sk-"}),Je.length>0&&Je.startsWith("sk-")&&Je.length<20&&b.jsx("p",{className:"text-amber-400/70 text-[11px] mt-1",children:"Key looks too short"}),b.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:[b.jsx(Sx,{className:"h-4 w-4 text-[#AF27E3]/60 mt-0.5 shrink-0"}),b.jsx("p",{className:"text-white/35 text-[12px] leading-relaxed",children:"Users will see a microphone button in the chat. Audio is sent to OpenAI's Whisper API for transcription, then processed as a regular text message."})]})]}),b.jsx("button",{onClick:It,disabled:x||Yt&&(!Je.startsWith("sk-")||Je.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:x?b.jsxs(b.Fragment,{children:[b.jsx(Oi,{className:"h-4 w-4 animate-spin"}),"Setting up..."]}):b.jsxs(b.Fragment,{children:["Complete Setup",b.jsx(rn,{className:"h-4 w-4"})]})}),!Yt&&b.jsx("p",{className:"text-center text-white/20 text-[11px] mt-2.5",children:"You can enable this later in Settings."})]}),o===6&&l&&b.jsxs("div",{className:"flex flex-col items-center text-center",children:[b.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:b.jsx(ji,{className:"h-8 w-8 text-emerald-400"})}),b.jsx("h1",{className:"text-2xl font-bold text-white tracking-tight",children:"All Set!"}),b.jsx("p",{className:"text-white/40 text-[13px] mt-2 leading-relaxed max-w-[340px]",children:"Your agent is live and ready. From now on, access it using your custom URL below."}),b.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:[b.jsx("span",{className:"font-mono text-[13px] text-white/70 truncate flex-1 text-left",children:ht}),b.jsx("button",{onClick:()=>{const B=ht.startsWith("http")?ht:`https://${ht}`;navigator.clipboard.writeText(B),is(!0),setTimeout(()=>is(!1),2e3)},className:"shrink-0 text-white/30 hover:text-white/60 transition-colors",children:Zu?b.jsx(ji,{className:"h-4 w-4 text-emerald-400"}):b.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[b.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),b.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})]}),b.jsxs("div",{className:"w-full mt-3",children:[b.jsx("label",{className:"text-[12px] text-white/40 font-medium mb-1.5 block text-left",children:"Your password"}),b.jsxs("div",{className:"flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3",children:[b.jsx("span",{className:"font-mono text-[13px] text-white/70 truncate flex-1 text-left",children:Zi?ze:"•".repeat(Math.max(ze.length,8))}),b.jsx("button",{onClick:()=>ls(B=>!B),className:"shrink-0 text-white/30 hover:text-white/60 transition-colors",children:Zi?b.jsx(yx,{className:"h-4 w-4"}):b.jsx(vx,{className:"h-4 w-4"})})]})]}),b.jsxs("button",{onClick:()=>{const B=ht.startsWith("http")?ht:`https://${ht}`;(window.top||window).location.href=B},className:"w-full mt-6 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:["Go to your agent",b.jsx(Op,{className:"h-4 w-4"})]}),b.jsx("p",{className:"text-white/20 text-[11px] mt-3 leading-relaxed",children:"You'll be redirected to your custom URL."})]})]},o)}),o>0&&o<u-1&&!(o===6&&l)&&b.jsx("div",{className:"px-8 pb-5 -mt-3",children:b.jsx("button",{onClick:rs,className:"text-white/25 hover:text-white/50 text-[12px] transition-colors",children:"← Back"})})]})]})}export{rn as A,Oi as L,Sx as M,EA as O,SA as R,c2 as a,TA as b,dn as c,Py as g,b as j,Jy as m,_ as r};
@@ -1 +1 @@
1
- import{b as o,j as e,R as n,O as r}from"./globals-BARUsBoX.js";function a(){const t=()=>{window.parent?.postMessage({type:"fluxy:onboard-complete"},"*")};return e.jsx(r,{onComplete:t,isInitialSetup:!0})}o.createRoot(document.getElementById("root")).render(e.jsx(n.StrictMode,{children:e.jsx(a,{})}));
1
+ import{b as o,j as e,R as n,O as r}from"./globals-BcC_NUiS.js";function a(){const t=()=>{window.parent?.postMessage({type:"fluxy:onboard-complete"},"*")};return e.jsx(r,{onComplete:t,isInitialSetup:!0})}o.createRoot(document.getElementById("root")).render(e.jsx(n.StrictMode,{children:e.jsx(a,{})}));
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, interactive-widget=resizes-content" />
6
6
  <title>Fluxy Chat</title>
7
- <script type="module" crossorigin src="/fluxy/assets/fluxy-BpmZluJ3.js"></script>
8
- <link rel="modulepreload" crossorigin href="/fluxy/assets/globals-BARUsBoX.js">
7
+ <script type="module" crossorigin src="/fluxy/assets/fluxy-B-IdduV1.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/fluxy/assets/globals-BcC_NUiS.js">
9
9
  <link rel="stylesheet" crossorigin href="/fluxy/assets/globals-DAbB5zRE.css">
10
10
  </head>
11
11
  <body class="bg-background text-foreground">
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, interactive-widget=resizes-content" />
6
6
  <title>Fluxy Setup</title>
7
- <script type="module" crossorigin src="/fluxy/assets/onboard-jn_UMLma.js"></script>
8
- <link rel="modulepreload" crossorigin href="/fluxy/assets/globals-BARUsBoX.js">
7
+ <script type="module" crossorigin src="/fluxy/assets/onboard-Ccsu5HQz.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/fluxy/assets/globals-BcC_NUiS.js">
9
9
  <link rel="stylesheet" crossorigin href="/fluxy/assets/globals-DAbB5zRE.css">
10
10
  </head>
11
11
  <body class="bg-background text-foreground">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxy-bot",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Self-hosted AI bot — run your own AI assistant from anywhere",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1253,7 +1253,8 @@ export default function OnboardWizard({ onComplete, isInitialSetup = false }: Pr
1253
1253
  <button
1254
1254
  onClick={() => {
1255
1255
  const url = registeredUrl.startsWith('http') ? registeredUrl : `https://${registeredUrl}`;
1256
- window.location.href = url;
1256
+ // Navigate the top-level window (escapes iframe if embedded)
1257
+ (window.top || window).location.href = url;
1257
1258
  }}
1258
1259
  className="w-full mt-6 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"
1259
1260
  >
@@ -6,19 +6,18 @@ interface Props {
6
6
  }
7
7
 
8
8
  export default function LoginScreen({ onLogin }: Props) {
9
- const [username, setUsername] = useState('');
10
9
  const [password, setPassword] = useState('');
11
10
  const [error, setError] = useState('');
12
11
  const [loading, setLoading] = useState(false);
13
12
 
14
13
  const handleSubmit = async () => {
15
- if (!username.trim() || !password.trim() || loading) return;
14
+ if (!password.trim() || loading) return;
16
15
  setLoading(true);
17
16
  setError('');
18
17
 
19
18
  try {
20
19
  // Use GET + Basic Auth header (relay proxies don't forward POST bodies)
21
- const credentials = btoa(`${username.trim()}:${password}`);
20
+ const credentials = btoa(`admin:${password}`);
22
21
  const res = await fetch('/api/portal/login', {
23
22
  headers: { 'Authorization': `Basic ${credentials}` },
24
23
  });
@@ -27,7 +26,7 @@ export default function LoginScreen({ onLogin }: Props) {
27
26
  if (res.ok && data.token) {
28
27
  onLogin(data.token);
29
28
  } else {
30
- setError(data.error || 'Invalid credentials');
29
+ setError(data.error || 'Invalid password');
31
30
  }
32
31
  } catch {
33
32
  setError('Could not reach server');
@@ -53,7 +52,7 @@ export default function LoginScreen({ onLogin }: Props) {
53
52
  Welcome back
54
53
  </h1>
55
54
  <p className="text-white/40 text-[13px] mb-6">
56
- Enter your portal credentials to continue.
55
+ Enter your password to continue.
57
56
  </p>
58
57
 
59
58
  {error && (
@@ -62,32 +61,20 @@ export default function LoginScreen({ onLogin }: Props) {
62
61
  </div>
63
62
  )}
64
63
 
65
- <input
66
- type="text"
67
- value={username}
68
- onChange={(e) => setUsername(e.target.value)}
69
- onKeyDown={handleKeyDown}
70
- placeholder="Username"
71
- autoFocus
72
- autoComplete="username"
73
- autoCapitalize="none"
74
- autoCorrect="off"
75
- className={inputCls}
76
- />
77
-
78
64
  <input
79
65
  type="password"
80
66
  value={password}
81
67
  onChange={(e) => setPassword(e.target.value)}
82
68
  onKeyDown={handleKeyDown}
83
69
  placeholder="Password"
70
+ autoFocus
84
71
  autoComplete="current-password"
85
- className={inputCls + ' mt-3'}
72
+ className={inputCls}
86
73
  />
87
74
 
88
75
  <button
89
76
  onClick={handleSubmit}
90
- disabled={!username.trim() || !password.trim() || loading}
77
+ disabled={!password.trim() || loading}
91
78
  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"
92
79
  >
93
80
  {loading ? (
@@ -85,4 +85,22 @@
85
85
  toggle();
86
86
  }
87
87
  } catch (e) {}
88
+
89
+ // Hide widget during initial onboard
90
+ try {
91
+ fetch('/api/settings')
92
+ .then(function (r) { return r.json(); })
93
+ .then(function (s) {
94
+ if (s.onboard_complete !== 'true') {
95
+ bubble.style.display = 'none';
96
+ window.addEventListener('message', function onMsg(e) {
97
+ if (e.data && e.data.type === 'fluxy:onboard-complete') {
98
+ bubble.style.display = 'flex';
99
+ window.removeEventListener('message', onMsg);
100
+ }
101
+ });
102
+ }
103
+ })
104
+ .catch(function () {});
105
+ } catch (e) {}
88
106
  })();
package/worker/index.ts CHANGED
@@ -253,12 +253,10 @@ app.post('/api/portal/verify-password', (req, res) => {
253
253
 
254
254
  // Shared login logic (used by both POST and GET handlers)
255
255
  function handleLogin(username: string | undefined, password: string | undefined, res: any) {
256
- if (!username || !password) { res.status(400).json({ error: 'Username and password required' }); return; }
257
- const storedUser = getSetting('portal_user');
256
+ if (!password) { res.status(400).json({ error: 'Password required' }); return; }
258
257
  const storedPass = getSetting('portal_pass');
259
258
  if (!storedPass) { res.status(400).json({ error: 'No password set' }); return; }
260
- if (username.trim().toLowerCase() !== storedUser) { res.status(401).json({ error: 'Invalid credentials' }); return; }
261
- if (!verifyPassword(password, storedPass)) { res.status(401).json({ error: 'Invalid credentials' }); return; }
259
+ if (!verifyPassword(password, storedPass)) { res.status(401).json({ error: 'Invalid password' }); return; }
262
260
 
263
261
  deleteExpiredSessions();
264
262
  const token = crypto.randomBytes(64).toString('hex');
Binary file