@rubytech/create-maxy 1.0.684 → 1.0.686
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +49 -203
- package/dist/pinned-binaries.js +10 -41
- package/dist/uninstall.js +47 -19
- package/package.json +1 -1
- package/payload/platform/config/brand.json +1 -0
- package/payload/platform/plugins/cloudflare/scripts/setup-tunnel.sh +35 -9
- package/payload/platform/plugins/docs/PLUGIN.md +2 -0
- package/payload/platform/plugins/docs/references/cloudflare.md +1 -1
- package/payload/platform/plugins/docs/references/deployment.md +19 -6
- package/payload/platform/plugins/docs/references/graph.md +38 -0
- package/payload/platform/plugins/docs/references/platform.md +10 -7
- package/payload/platform/plugins/docs/references/troubleshooting.md +23 -13
- package/payload/platform/scripts/vnc.sh +7 -7
- package/payload/platform/templates/systemd/{maxy-edge.service → edge.service.template} +9 -6
- package/payload/server/maxy-edge.js +7 -369
- package/payload/server/public/assets/admin-BqLtaMVu.js +352 -0
- package/payload/server/public/assets/{data-DUSyrydY.js → data-BZ7v-zug.js} +1 -1
- package/payload/server/public/assets/{file-CDJ6dUV3.js → file-CScYkZq5.js} +1 -1
- package/payload/server/public/assets/graph-tjXdtwk-.js +50 -0
- package/payload/server/public/assets/{house-CNP_bwvT.js → house-CdFRNujU.js} +1 -1
- package/payload/server/public/assets/{jsx-runtime-BFFQvkdQ.css → jsx-runtime-Og0q7dXg.css} +1 -1
- package/payload/server/public/assets/{public-sHoAccvb.js → public-CrkQJek6.js} +2 -2
- package/payload/server/public/assets/{share-2-DBcb9j6E.js → share-2-Ev-D4Lm9.js} +1 -1
- package/payload/server/public/assets/{useVoiceRecorder-CtSgpc95.js → useVoiceRecorder-DyDXH7EA.js} +2 -2
- package/payload/server/public/assets/{x-CTVJaC_u.js → x-D5W7ddgP.js} +1 -1
- package/payload/server/public/data.html +6 -6
- package/payload/server/public/graph.html +6 -6
- package/payload/server/public/index.html +7 -8
- package/payload/server/public/public.html +4 -4
- package/payload/server/server.js +830 -258
- package/payload/platform/templates/dotfiles/.tmux.conf +0 -1
- package/payload/platform/templates/systemd/maxy-ttyd.service +0 -25
- package/payload/server/public/assets/admin-WQxJgaus.js +0 -362
- package/payload/server/public/assets/admin-kHJ-D0s7.css +0 -1
- package/payload/server/public/assets/graph-CWcYp5bE.js +0 -50
- /package/payload/server/public/assets/{jsx-runtime-BVKWELH6.js → jsx-runtime-CHqDsKlc.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DD-I1_y5.js";import{i as t,o as n,r,t as i}from"./jsx-runtime-BVKWELH6.js";import{A as a,C as o,D as s,M as c,N as l,O as u,S as d,_ as f,a as p,c as m,g as h,h as g,i as _,j as v,n as y,o as b,r as x,s as S,t as C,u as w,v as T,w as E,x as D,y as O}from"./useVoiceRecorder-CtSgpc95.js";var k=r(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),A=t(),j=e(n(),1),M=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar`,N=new Set(M.split(`,`)),P=20*1024*1024,F=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function I(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function L(){let e=window.location.pathname;if(e.startsWith(`/g/`))return;let t=e.match(/^\/([a-z][a-z0-9-]{2,49})$/);return t?t[1]:void 0}function R(){let e=window.location.pathname.match(/^\/g\/([a-z0-9][a-z0-9-]{0,49})$/);return e?e[1]:void 0}function z(e){return[{key:`length`,label:`At least 8 characters`,met:e.length>=8},{key:`number`,label:`Contains a number`,met:/\d/.test(e)},{key:`special`,label:`Contains a special character`,met:/[^A-Za-z0-9]/.test(e)},{key:`whitespace`,label:`No spaces`,met:e.length>0&&!/\s/.test(e)}]}function B(e,t){if(t===`phone`)return e.length>4?e.slice(0,e.length-4).replace(/\d/g,`•`)+` `+e.slice(-4):e;let n=e.indexOf(`@`);return n<=2?e:e.slice(0,2)+`•••`+e.slice(n)}function ee(e){let[t,n]=(0,j.useState)(null),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(`loading`),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(null),[d,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null),_=(0,j.useMemo)(()=>L(),[]),v=(0,j.useMemo)(()=>R(),[]),[y,b]=(0,j.useState)(null),x=(0,j.useRef)(_||``),S=(0,j.useRef)(null),C=(0,j.useRef)(null),w=(0,j.useRef)(!1),T=(0,j.useRef)(null),[E,D]=(0,j.useState)(`sign-in`),[O,k]=(0,j.useState)(null),A=(0,j.useRef)(null),M=(0,j.useRef)(null);(0,j.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(M.current=e)}catch{}},[]);let N=(0,j.useCallback)(t=>{S.current=t,n(t);try{sessionStorage.setItem(`maxy_session`,t)}catch{}o(`chat`),e(t)},[e]),P=(0,j.useCallback)(()=>{S.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}n(null),o(`auth-required`),D(`sign-in`)},[]),z=(0,j.useCallback)(async e=>{try{let t=x.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})}),r=await n.json();n.ok?(A.current=r.session_key,k(r.grant),D(`set-password`),window.history.replaceState({},``,window.location.pathname)):D(`link-expired`)}catch{D(`sign-in`)}},[]),B=(0,j.useCallback)(async()=>{if(S.current)return S.current;if(C.current)return C.current;let e=(async()=>{try{let e=M.current,t=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:I(),..._?{agent:_}:{},...v?{group_slug:v}:{},...e?{session_key:e}:{}})});if(!t.ok){let e=await t.json().catch(()=>({error:``}));return F&&console.error(`[session] POST /api/session failed: ${t.status} ${t.statusText}`,e),t.status===404?i(e.error||`Agent not found`):t.status===503&&i(e.error||`Service unavailable`),null}let r=await t.json();if(r.auth_required){r.agent_id&&(x.current=r.agent_id),c(r.displayName||``),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?z(e):D(`sign-in`),null}S.current=r.session_key,n(r.session_key),r.displayName&&c(r.displayName),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`chat`),r.resumed&&r.messages&&(w.current=!0,T.current=r.messages),r.group&&b({groupSlug:r.groupSlug,groupName:r.groupName,participants:r.participants??[]});try{sessionStorage.setItem(`maxy_session`,r.session_key)}catch{}return r.session_key}catch(e){return F&&console.error(`[session] fetch /api/session threw:`,e),i(`Unable to connect. Please check your connection and try again.`),null}finally{C.current=null}})();return C.current=e,e},[_,v,z]);return{sessionId:t,sessionKeyRef:S,sessionError:r,pageState:a,setPageState:o,agentDisplayName:s,agentImage:l,agentImageShape:d,showAgentName:p,agentSlug:_,branding:h,resolvedSlugRef:x,ensureSession:B,startNewSession:(0,j.useCallback)(async()=>{S.current=null,C.current=null,M.current=null,w.current=!1,T.current=null,n(null),i(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}let t=await B();t&&e(t)},[B,e]),enterChat:N,enterGate:P,resumedRef:w,resumeMessagesRef:T,gateState:E,setGateState:D,grantInfo:O,setGrantInfo:k,gateSessionKeyRef:A,groupContext:y,groupSlug:v}}function te({sessionKeyRef:e,ensureSession:t,sessionError:n,pageState:r,inputRef:i}){let[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!1),l=(0,j.useRef)(!1),u=e=>{l.current=e,c(e)},d=(0,j.useCallback)(async a=>{if(!l.current){u(!0),o([{role:`maxy`,content:``,timestamp:Date.now()}]);try{let n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:a})});if(n.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}F&&console.warn(`[greeting] stale session, retrying with fresh session`);let r=await t();if(!r)return;n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:r})})}if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let r=``,i=``,s=()=>{i&&(r+=i,i=``,o(e=>{let t=[...e];return t[0]={...t[0],content:r},t}))},c=setInterval(s,60);try{for await(let e of D(n)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(i+=e.text),e.type===`component`&&(s(),o(t=>{let n=[...t],r={...n[0]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[0]={...r,components:i},n}))}}finally{clearInterval(c),s()}}catch(e){if(F&&console.error(`[chat] greeting failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e);o([{role:`maxy`,content:e instanceof Error&&e.fromSSE?t:n??`I'm having trouble connecting right now. Try refreshing the page.`,timestamp:Date.now()}])}finally{u(!1),r===`chat`&&i.current?.focus()}}},[e,t,n,r,i]),f=(0,j.useCallback)(async(a,s)=>{let c=s?.hidden??!1,d=s?.files??[];if(!a&&d.length===0||l.current)return;u(!0);let f=d.map(e=>({filename:e.name,mimeType:e.type})),p={role:`visitor`,content:a,attachments:f.length>0?f:void 0,timestamp:Date.now(),hidden:c},m;o(e=>{let t=[...e,p,{role:`maxy`,content:``,timestamp:Date.now()}];return m=t.length-1,t});try{let n=await t();if(!n)throw Error(`session`);let r=e=>{if(d.length>0){let t=new FormData;t.append(`message`,a),t.append(`session_key`,e);for(let e of d)t.append(`attachments`,e);return{body:t,headers:{}}}return{body:JSON.stringify({message:a,session_key:e}),headers:{"Content-Type":`application/json`}}},{body:i,headers:s}=r(n),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i});if(c.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}F&&console.warn(`[session-expired] stale key cleared, retrying with fresh session`);let n=await t();if(!n)throw Error(`session`);({body:i,headers:s}=r(n)),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i})}if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let l=``,u=``,f=()=>{u&&(l+=u,u=``,o(e=>{let t=[...e];return t[m]={...t[m],content:l},t}))},p=setInterval(f,60);try{for await(let e of D(c)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(u+=e.text),e.type===`component`&&(f(),o(t=>{let n=[...t],r={...n[m]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[m]={...r,components:i},n}))}}finally{clearInterval(p),f()}}catch(e){if(F&&console.error(`[chat] sendMessage failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e),i=e instanceof Error&&e.fromSSE;o(e=>{let r=[...e];return r[m]={...r[m],content:i?t:t===`session`?n??`I'm having trouble connecting right now. Try refreshing the page.`:`Sorry, I hit a snag. Try again in a moment.`},r})}finally{u(!1),r===`chat`&&i.current?.focus()}},[e,t,n,r,i]);return{messages:a,setMessages:o,isStreaming:s,sendMessage:f,sendGreeting:d,handleComponentSubmit:(0,j.useCallback)((e,t,n)=>{o(n=>{let r=[...n],i={...r[e]},a=[...i.components||[]];return a[t]={...a[t],submitted:!0},r[e]={...i,components:a},r}),f(n,{hidden:!0})},[f])}}function ne({sessionKeyRef:e,groupSlug:t,isStreaming:n,setMessages:r}){let i=(0,j.useRef)(new Date().toISOString()),a=(0,j.useRef)(!0);(0,j.useEffect)(()=>{let e=()=>{a.current=document.visibilityState===`visible`};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let o=(0,j.useCallback)(async()=>{let n=e.current;if(!(!n||!t))try{let e=await fetch(`/api/group/messages?session_key=${encodeURIComponent(n)}&since=${encodeURIComponent(i.current)}`);if(!e.ok)return;let t=await e.json();if(!t.messages||t.messages.length===0)return;let a=t.messages[t.messages.length-1];a.timestamp&&(i.current=new Date(a.timestamp).toISOString()),r(e=>{let n=new Set(e.filter(e=>e.messageId).map(e=>e.messageId)),r=t.messages.filter(e=>!n.has(e.messageId)).map(e=>({role:e.role,content:e.content,timestamp:e.timestamp,senderName:e.senderName??void 0,senderVisitorId:e.senderVisitorId??void 0,messageId:e.messageId}));return r.length===0?e:[...e,...r]})}catch{}},[e,t,r]);(0,j.useEffect)(()=>{if(!t)return;let e,r=!1;function i(){if(r)return;let t=a.current?3e3:3e4;e=setTimeout(async()=>{n||await o(),i()},t)}return i(),()=>{r=!0,clearTimeout(e)}},[t,n,o])}var V=i();function H({value:e,onChange:t,onComplete:n,disabled:r}){let i=(0,j.useRef)([]);function a(n,r){r.key===`Backspace`?(r.preventDefault(),e[n]?t(e.slice(0,n)+e.slice(n+1)):n>0&&(t(e.slice(0,n-1)+e.slice(n)),i.current[n-1]?.focus())):r.key===`ArrowLeft`&&n>0?i.current[n-1]?.focus():r.key===`ArrowRight`&&n<5&&i.current[n+1]?.focus()}function o(r,a){let o=a.nativeEvent.data;if(!o||!/^\d$/.test(o))return;let s=e.split(``);for(s[r]=o;s.length<r;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);t(c),c.length===6?n(c):r<5&&i.current[r+1]?.focus()}function s(e){e.preventDefault();let r=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);r&&(t(r),r.length===6?n(r):i.current[r.length]?.focus())}return(0,V.jsx)(`div`,{className:`gate-otp-field`,children:Array.from({length:6}).map((t,n)=>(0,V.jsx)(`input`,{ref:e=>{i.current[n]=e},type:`text`,inputMode:`numeric`,className:`pin-box${e[n]?` pin-box-filled`:``}`,value:e[n]||``,onKeyDown:e=>a(n,e),onInput:e=>o(n,e),onPaste:s,onFocus:e=>e.target.select(),autoFocus:n===0,autoComplete:`off`,maxLength:1,disabled:r,"aria-label":`Code digit ${n+1}`},n))})}function U({gateState:e,setGateState:t,grantInfo:n,setGrantInfo:r,gateSessionKeyRef:i,resolvedSlugRef:a,onAuthenticated:o}){let[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(``),[p,m]=(0,j.useState)(!1),[_,v]=(0,j.useState)(``),[y,b]=(0,j.useState)(``),[x,S]=(0,j.useState)(!1),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)(null),[D,O]=(0,j.useState)(!1);async function k(e){if(e.preventDefault(),!D){w(null),O(!0);try{let e=a.current,n=await fetch(`/api/access/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,password:l,agentSlug:e})}),i=await n.json();n.ok?o(i.session_key):n.status===401?i.error?.includes(`setup not complete`)||i.error?.includes(`invitation link`)?(t(`private-agent`),w(null)):w(i.error||`Invalid credentials`):n.status===403?(t(`access-expired`),i.expiresAt&&r(e=>e?{...e,expiresAt:i.expiresAt}:{displayName:null,contactValue:s,contactMethod:`email`,expiresAt:i.expiresAt,status:`expired`})):n.status===429?w(i.error||`Too many attempts. Please try again later.`):w(i.error||`Something went wrong`)}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function A(e){if(!D){w(null),O(!0);try{let n=a.current,o=await fetch(`/api/access/verify-otp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({phone:y,code:e,agentSlug:n})}),s=await o.json();o.ok?(i.current=s.session_key,r(s.grant),t(`set-password`)):o.status===429?t(`otp-failed`):(w(s.error||`Invalid code`),v(``))}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function M(e){if(e.preventDefault(),!D){if(w(null),l!==d){w(`Passwords do not match`);return}if(!z(l).every(e=>e.met)){w(`Password does not meet requirements`);return}O(!0);try{let e=i.current;if(!e){w(`Session expired. Please use your invitation link again.`);return}let t=await fetch(`/api/access/create-credentials`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:e,password:l})}),n=await t.json();t.ok?o(n.session_key):t.status===400&&n.requirements?w(n.requirements.filter(e=>!e.met).map(e=>e.label).join(`, `)):w(n.error||`Something went wrong`)}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function N(e){if(e.preventDefault(),!(D||!s)){w(null),O(!0);try{let e=a.current,t=await fetch(`/api/access/forgot-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,agentSlug:e})});t.status===429?w((await t.json()).error||`Too many attempts. Please try again later.`):(E(`If an account exists, a reset link has been sent.`),setTimeout(()=>{S(!1),E(null)},4e3))}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}switch(e){case`set-password`:{let e=z(l),t=e.every(e=>e.met),r=l===d,i=t&&r&&d.length>0;return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[n?.expiresAt&&(0,V.jsxs)(`div`,{className:`gate-expiry-badge`,children:[`Access until `,new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`})]}),(0,V.jsxs)(`h2`,{className:`gate-title`,children:[`Welcome, `,n?.displayName||`there`]}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`Create a password to access this agent in the future.`}),(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:M,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-display-name`,children:`Display name`}),(0,V.jsx)(`input`,{id:`gate-display-name`,type:`text`,value:n?.displayName||``,disabled:!0})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(h,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoFocus:!0,autoComplete:`new-password`}),l.length>0&&(0,V.jsx)(`div`,{className:`gate-strength`,children:e.map(e=>(0,V.jsxs)(`span`,{className:`gate-strength-item${e.met?` met`:``}`,children:[e.met?`✓`:`○`,` `,e.label]},e.key))})]}),(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw-confirm`,children:`Confirm password`}),(0,V.jsx)(`input`,{id:`gate-pw-confirm`,type:p?`text`:`password`,value:d,onChange:e=>f(e.target.value),placeholder:`Confirm your password`,autoComplete:`new-password`}),d.length>0&&!r&&(0,V.jsx)(`div`,{className:`gate-error`,children:`Passwords do not match`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!i||D,loading:D,children:`Create account & enter chat`})})]})]})})}case`enter-otp`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:`Enter your code`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[`Enter the 6-digit code sent to `,B(y,`phone`)]}),(0,V.jsx)(H,{value:_,onChange:v,onComplete:A,disabled:D}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),D&&(0,V.jsxs)(`div`,{className:`gate-loading`,children:[(0,V.jsx)(`span`,{className:`spinner`}),`Verifying...`]}),(0,V.jsx)(`div`,{className:`gate-resend`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{t(`sign-in`),v(``),w(null)},children:`Use a different number`})})]})});case`sign-in`:case`private-agent`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:e===`private-agent`?`Private Agent`:`Welcome back`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:e===`private-agent`?`This agent is invitation-only. If you have an account, sign in below.`:`Sign in to continue your conversation.`}),x?(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:N,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-forgot-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-forgot-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),T&&(0,V.jsx)(`div`,{className:`gate-success`,children:T}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||D,loading:D,children:`Send reset link`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{S(!1),w(null),E(null)},children:`Back to sign in`})})]}):(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:k,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-login-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(h,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-login-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoComplete:`current-password`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||!l||D,loading:D,children:`Sign in`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{S(!0),w(null)},children:`Forgot password?`})})]}),e===`private-agent`&&(0,V.jsx)(`p`,{className:`gate-hint`,children:`No account? You need an invitation from the agent owner.`})]})});case`access-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⏰`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Access expired`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[n?.expiresAt?`Your access expired on ${new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`long`,year:`numeric`})}.`:`Your access to this agent has expired.`,` `,`Contact the agent owner to renew.`]}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),w(null),u(``)},children:`Sign in with a different account`})})]})});case`link-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⚠️`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Link expired`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`This invitation link has expired or has already been used. If you already set your password, sign in below. Otherwise, ask the agent owner to send a new invitation.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`primary`,onClick:()=>{t(`sign-in`),w(null)},children:`Go to sign in`})})]})});case`otp-failed`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⛔`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Too many attempts`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`You've entered the wrong code too many times. Ask the agent owner to send a new code.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),w(null),v(``)},children:`Back to sign in`})})]})})}}var W={"single-select":m,"multi-select":S,"action-buttons":b};function G({name:e,data:t,onSubmit:n,submitted:r}){let i=W[e];return i?(0,V.jsx)(i,{data:t,onSubmit:n,submitted:r}):(console.warn(`[PublicComponentRenderer] Unknown component: "${e}". Registered: ${Object.keys(W).join(`, `)}`),(0,V.jsx)(`div`,{className:`component-card component-card--error`,children:(0,V.jsxs)(`p`,{style:{fontFamily:`var(--font-body)`,fontSize:12,color:`var(--text-secondary)`},children:[`Component “`,e,`” is not available. This may require a platform update.`]})}))}function re({messages:e,isStreaming:t,sessionError:n,selectionMode:r,selectedItems:i,toggleSelectItem:o,onComponentSubmit:s,remainingSuggestions:c,onSuggestionClick:u,isAtBottom:d,setIsAtBottom:f,isGroup:m}){let[_,y]=(0,j.useState)(new Set),[b,x]=(0,j.useState)(new Set),S=(0,j.useRef)(null),C=(0,j.useRef)(null),T=(0,j.useRef)(null),E=(0,j.useRef)(!1),D=(0,j.useRef)(!1),O=(0,j.useRef)(!1),k=(0,j.useRef)(0),A=(0,j.useRef)(!1),M=(0,j.useRef)(new Map);A.current=t,(0,j.useEffect)(()=>{t&&!E.current&&d&&(D.current=!0)},[t,d]),(0,j.useEffect)(()=>{if(!D.current&&!d){E.current=t,O.current=!1;return}if(E.current&&!t&&T.current&&C.current){let e=T.current;if(e.offsetHeight>C.current.clientHeight){D.current=!1,O.current=!0,e.scrollIntoView({behavior:`smooth`,block:`start`}),E.current=t;return}}(d||D.current)&&!O.current&&S.current?.scrollIntoView({behavior:`smooth`}),E.current&&!t&&(D.current=!1),E.current=t},[e,d,t]),(0,j.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{let t=e.scrollTop;A.current&&t<k.current&&(D.current=!1),k.current=t,f(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[f]),(0,j.useEffect)(()=>{function e(){x(e=>{let t=new Set;return M.current.forEach((n,r)=>{n.isConnected&&(_.has(r)?e.has(r)&&t.add(r):n.scrollHeight>n.clientHeight+2&&t.add(r))}),e.size===t.size&&[...e].every(e=>t.has(e))?e:t})}e();let t=new ResizeObserver(e);return M.current.forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length,_]);let N=e.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,V.jsxs)(`div`,{className:`chat-messages-wrap`,children:[r&&(0,V.jsx)(`div`,{className:`selection-overlay-band`}),(0,V.jsxs)(`div`,{className:`chat-messages`,ref:C,children:[n&&e.length===0&&(0,V.jsx)(`div`,{className:`session-error`,children:(0,V.jsx)(`p`,{children:n})}),e.map((n,c)=>{if(n.hidden)return null;let u=t&&c===e.length-1,d=`${n.timestamp}_${n.role}`,f=i.has(d);return(0,V.jsxs)(`div`,{ref:c===N?T:void 0,className:`message ${n.role}${f?` selected`:``}`,children:[r&&!u&&(0,V.jsx)(`div`,{className:`message-select-check`,children:(0,V.jsx)(h,{checked:f,onChange:()=>o(d)})}),(0,V.jsxs)(`div`,{className:`bubble`,children:[m&&n.role===`visitor`&&n.senderName&&(0,V.jsx)(`span`,{className:`bubble-sender`,children:n.senderName}),n.role===`visitor`&&n.content?(()=>{let e=_.has(c),t=b.has(c);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:e=>{e?M.current.set(c,e):M.current.delete(c)},className:e?`bubble-content`:`bubble-content clamped${t?` overflowing`:``}`,children:n.content}),t&&(0,V.jsx)(`div`,{className:`bubble-expand`,children:(0,V.jsx)(g,{variant:`icon`,className:e?`expanded`:``,onClick:()=>y(e=>{let t=new Set(e);return t.has(c)?t.delete(c):t.add(c),t}),"aria-label":e?`Collapse message`:`Expand message`,children:(0,V.jsx)(l,{size:14})})})]})})():n.content?(0,V.jsx)(w,{content:n.content,timestamp:p(n.timestamp)}):(0,V.jsxs)(`span`,{className:`typing-indicator`,children:[(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`})]}),n.attachments&&n.attachments.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:n.attachments.map((e,t)=>(0,V.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.mimeType===`application/pdf`?(0,V.jsx)(a,{size:12}):e.mimeType.startsWith(`text/`)?(0,V.jsx)(v,{size:12}):null,(0,V.jsx)(`span`,{children:e.filename})]},t))}),n.role===`visitor`&&(0,V.jsx)(`span`,{className:`message-timestamp`,children:p(n.timestamp)})]}),n.role===`maxy`&&n.components&&n.components.length>0&&(0,V.jsx)(`div`,{className:`public-components`,children:n.components.map((e,t)=>(0,V.jsx)(`div`,{className:`public-component-enter`,children:(0,V.jsx)(G,{name:e.name,data:e.data,onSubmit:e=>s(c,t,e),submitted:e.submitted})},t))})]},c)}),!t&&c.length>0&&(0,V.jsx)(`div`,{className:`chat-suggestions`,children:c.map(e=>(0,V.jsx)(g,{variant:`suggestion`,onClick:()=>u(e),children:e},e))}),(0,V.jsx)(`div`,{ref:S})]}),!d&&(0,V.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>S.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,V.jsx)(l,{size:18})})]})}function ie({selectedItems:e,messages:t,copySelected:n,exitSelection:r,showCopyToast:i}){let[a,o]=(0,j.useState)(!1),s=(0,j.useRef)(null),l=(0,j.useRef)(!1);function u(e){let n=e.lastIndexOf(`_`),r=e.slice(0,n),i=e.slice(n+1),a=parseInt(r,10);return t.find(e=>e.timestamp===a&&e.role===i)?.content??``}function f(e,t){return parseInt(e.slice(0,e.lastIndexOf(`_`)),10)-parseInt(t.slice(0,t.lastIndexOf(`_`)),10)}function p(){let e=[...t].sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let t of e){if(t.hidden||!t.content)continue;let e=t.role===`visitor`?`Visitor`:`Maxy`;n.push(`${e}:\n${t.content}`)}return n.join(`
|
|
1
|
+
import{o as e}from"./chunk-DD-I1_y5.js";import{i as t,o as n,r,t as i}from"./jsx-runtime-CHqDsKlc.js";import{C as a,M as o,N as s,O as c,P as l,S as u,T as d,_ as f,a as p,c as m,g as h,h as g,i as _,j as v,k as y,n as b,o as x,r as S,s as C,t as w,u as T,v as E,x as D,y as O}from"./useVoiceRecorder-DyDXH7EA.js";var k=r(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),A=t(),j=e(n(),1),M=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar`,N=new Set(M.split(`,`)),P=20*1024*1024,F=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function I(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function L(){let e=window.location.pathname;if(e.startsWith(`/g/`))return;let t=e.match(/^\/([a-z][a-z0-9-]{2,49})$/);return t?t[1]:void 0}function R(){let e=window.location.pathname.match(/^\/g\/([a-z0-9][a-z0-9-]{0,49})$/);return e?e[1]:void 0}function z(e){return[{key:`length`,label:`At least 8 characters`,met:e.length>=8},{key:`number`,label:`Contains a number`,met:/\d/.test(e)},{key:`special`,label:`Contains a special character`,met:/[^A-Za-z0-9]/.test(e)},{key:`whitespace`,label:`No spaces`,met:e.length>0&&!/\s/.test(e)}]}function B(e,t){if(t===`phone`)return e.length>4?e.slice(0,e.length-4).replace(/\d/g,`•`)+` `+e.slice(-4):e;let n=e.indexOf(`@`);return n<=2?e:e.slice(0,2)+`•••`+e.slice(n)}function ee(e){let[t,n]=(0,j.useState)(null),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(`loading`),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(null),[d,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null),_=(0,j.useMemo)(()=>L(),[]),v=(0,j.useMemo)(()=>R(),[]),[y,b]=(0,j.useState)(null),x=(0,j.useRef)(_||``),S=(0,j.useRef)(null),C=(0,j.useRef)(null),w=(0,j.useRef)(!1),T=(0,j.useRef)(null),[E,D]=(0,j.useState)(`sign-in`),[O,k]=(0,j.useState)(null),A=(0,j.useRef)(null),M=(0,j.useRef)(null);(0,j.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(M.current=e)}catch{}},[]);let N=(0,j.useCallback)(t=>{S.current=t,n(t);try{sessionStorage.setItem(`maxy_session`,t)}catch{}o(`chat`),e(t)},[e]),P=(0,j.useCallback)(()=>{S.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}n(null),o(`auth-required`),D(`sign-in`)},[]),z=(0,j.useCallback)(async e=>{try{let t=x.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})}),r=await n.json();n.ok?(A.current=r.session_key,k(r.grant),D(`set-password`),window.history.replaceState({},``,window.location.pathname)):D(`link-expired`)}catch{D(`sign-in`)}},[]),B=(0,j.useCallback)(async()=>{if(S.current)return S.current;if(C.current)return C.current;let e=(async()=>{try{let e=M.current,t=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:I(),..._?{agent:_}:{},...v?{group_slug:v}:{},...e?{session_key:e}:{}})});if(!t.ok){let e=await t.json().catch(()=>({error:``}));return F&&console.error(`[session] POST /api/session failed: ${t.status} ${t.statusText}`,e),t.status===404?i(e.error||`Agent not found`):t.status===503&&i(e.error||`Service unavailable`),null}let r=await t.json();if(r.auth_required){r.agent_id&&(x.current=r.agent_id),c(r.displayName||``),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?z(e):D(`sign-in`),null}S.current=r.session_key,n(r.session_key),r.displayName&&c(r.displayName),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`chat`),r.resumed&&r.messages&&(w.current=!0,T.current=r.messages),r.group&&b({groupSlug:r.groupSlug,groupName:r.groupName,participants:r.participants??[]});try{sessionStorage.setItem(`maxy_session`,r.session_key)}catch{}return r.session_key}catch(e){return F&&console.error(`[session] fetch /api/session threw:`,e),i(`Unable to connect. Please check your connection and try again.`),null}finally{C.current=null}})();return C.current=e,e},[_,v,z]);return{sessionId:t,sessionKeyRef:S,sessionError:r,pageState:a,setPageState:o,agentDisplayName:s,agentImage:l,agentImageShape:d,showAgentName:p,agentSlug:_,branding:h,resolvedSlugRef:x,ensureSession:B,startNewSession:(0,j.useCallback)(async()=>{S.current=null,C.current=null,M.current=null,w.current=!1,T.current=null,n(null),i(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}let t=await B();t&&e(t)},[B,e]),enterChat:N,enterGate:P,resumedRef:w,resumeMessagesRef:T,gateState:E,setGateState:D,grantInfo:O,setGrantInfo:k,gateSessionKeyRef:A,groupContext:y,groupSlug:v}}function te({sessionKeyRef:e,ensureSession:t,sessionError:n,pageState:r,inputRef:i}){let[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!1),l=(0,j.useRef)(!1),u=e=>{l.current=e,c(e)},d=(0,j.useCallback)(async a=>{if(!l.current){u(!0),o([{role:`maxy`,content:``,timestamp:Date.now()}]);try{let n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:a})});if(n.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}F&&console.warn(`[greeting] stale session, retrying with fresh session`);let r=await t();if(!r)return;n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:r})})}if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let r=``,i=``,s=()=>{i&&(r+=i,i=``,o(e=>{let t=[...e];return t[0]={...t[0],content:r},t}))},c=setInterval(s,60);try{for await(let e of D(n)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(i+=e.text),e.type===`component`&&(s(),o(t=>{let n=[...t],r={...n[0]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[0]={...r,components:i},n}))}}finally{clearInterval(c),s()}}catch(e){if(F&&console.error(`[chat] greeting failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e);o([{role:`maxy`,content:e instanceof Error&&e.fromSSE?t:n??`I'm having trouble connecting right now. Try refreshing the page.`,timestamp:Date.now()}])}finally{u(!1),r===`chat`&&i.current?.focus()}}},[e,t,n,r,i]),f=(0,j.useCallback)(async(a,s)=>{let c=s?.hidden??!1,d=s?.files??[];if(!a&&d.length===0||l.current)return;u(!0);let f=d.map(e=>({filename:e.name,mimeType:e.type})),p={role:`visitor`,content:a,attachments:f.length>0?f:void 0,timestamp:Date.now(),hidden:c},m;o(e=>{let t=[...e,p,{role:`maxy`,content:``,timestamp:Date.now()}];return m=t.length-1,t});try{let n=await t();if(!n)throw Error(`session`);let r=e=>{if(d.length>0){let t=new FormData;t.append(`message`,a),t.append(`session_key`,e);for(let e of d)t.append(`attachments`,e);return{body:t,headers:{}}}return{body:JSON.stringify({message:a,session_key:e}),headers:{"Content-Type":`application/json`}}},{body:i,headers:s}=r(n),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i});if(c.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}F&&console.warn(`[session-expired] stale key cleared, retrying with fresh session`);let n=await t();if(!n)throw Error(`session`);({body:i,headers:s}=r(n)),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i})}if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let l=``,u=``,f=()=>{u&&(l+=u,u=``,o(e=>{let t=[...e];return t[m]={...t[m],content:l},t}))},p=setInterval(f,60);try{for await(let e of D(c)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(u+=e.text),e.type===`component`&&(f(),o(t=>{let n=[...t],r={...n[m]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[m]={...r,components:i},n}))}}finally{clearInterval(p),f()}}catch(e){if(F&&console.error(`[chat] sendMessage failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e),i=e instanceof Error&&e.fromSSE;o(e=>{let r=[...e];return r[m]={...r[m],content:i?t:t===`session`?n??`I'm having trouble connecting right now. Try refreshing the page.`:`Sorry, I hit a snag. Try again in a moment.`},r})}finally{u(!1),r===`chat`&&i.current?.focus()}},[e,t,n,r,i]);return{messages:a,setMessages:o,isStreaming:s,sendMessage:f,sendGreeting:d,handleComponentSubmit:(0,j.useCallback)((e,t,n)=>{o(n=>{let r=[...n],i={...r[e]},a=[...i.components||[]];return a[t]={...a[t],submitted:!0},r[e]={...i,components:a},r}),f(n,{hidden:!0})},[f])}}function ne({sessionKeyRef:e,groupSlug:t,isStreaming:n,setMessages:r}){let i=(0,j.useRef)(new Date().toISOString()),a=(0,j.useRef)(!0);(0,j.useEffect)(()=>{let e=()=>{a.current=document.visibilityState===`visible`};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let o=(0,j.useCallback)(async()=>{let n=e.current;if(!(!n||!t))try{let e=await fetch(`/api/group/messages?session_key=${encodeURIComponent(n)}&since=${encodeURIComponent(i.current)}`);if(!e.ok)return;let t=await e.json();if(!t.messages||t.messages.length===0)return;let a=t.messages[t.messages.length-1];a.timestamp&&(i.current=new Date(a.timestamp).toISOString()),r(e=>{let n=new Set(e.filter(e=>e.messageId).map(e=>e.messageId)),r=t.messages.filter(e=>!n.has(e.messageId)).map(e=>({role:e.role,content:e.content,timestamp:e.timestamp,senderName:e.senderName??void 0,senderVisitorId:e.senderVisitorId??void 0,messageId:e.messageId}));return r.length===0?e:[...e,...r]})}catch{}},[e,t,r]);(0,j.useEffect)(()=>{if(!t)return;let e,r=!1;function i(){if(r)return;let t=a.current?3e3:3e4;e=setTimeout(async()=>{n||await o(),i()},t)}return i(),()=>{r=!0,clearTimeout(e)}},[t,n,o])}var V=i();function H({value:e,onChange:t,onComplete:n,disabled:r}){let i=(0,j.useRef)([]);function a(n,r){r.key===`Backspace`?(r.preventDefault(),e[n]?t(e.slice(0,n)+e.slice(n+1)):n>0&&(t(e.slice(0,n-1)+e.slice(n)),i.current[n-1]?.focus())):r.key===`ArrowLeft`&&n>0?i.current[n-1]?.focus():r.key===`ArrowRight`&&n<5&&i.current[n+1]?.focus()}function o(r,a){let o=a.nativeEvent.data;if(!o||!/^\d$/.test(o))return;let s=e.split(``);for(s[r]=o;s.length<r;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);t(c),c.length===6?n(c):r<5&&i.current[r+1]?.focus()}function s(e){e.preventDefault();let r=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);r&&(t(r),r.length===6?n(r):i.current[r.length]?.focus())}return(0,V.jsx)(`div`,{className:`gate-otp-field`,children:Array.from({length:6}).map((t,n)=>(0,V.jsx)(`input`,{ref:e=>{i.current[n]=e},type:`text`,inputMode:`numeric`,className:`pin-box${e[n]?` pin-box-filled`:``}`,value:e[n]||``,onKeyDown:e=>a(n,e),onInput:e=>o(n,e),onPaste:s,onFocus:e=>e.target.select(),autoFocus:n===0,autoComplete:`off`,maxLength:1,disabled:r,"aria-label":`Code digit ${n+1}`},n))})}function U({gateState:e,setGateState:t,grantInfo:n,setGrantInfo:r,gateSessionKeyRef:i,resolvedSlugRef:a,onAuthenticated:o}){let[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(``),[p,m]=(0,j.useState)(!1),[_,v]=(0,j.useState)(``),[y,b]=(0,j.useState)(``),[x,S]=(0,j.useState)(!1),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)(null),[D,O]=(0,j.useState)(!1);async function k(e){if(e.preventDefault(),!D){w(null),O(!0);try{let e=a.current,n=await fetch(`/api/access/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,password:l,agentSlug:e})}),i=await n.json();n.ok?o(i.session_key):n.status===401?i.error?.includes(`setup not complete`)||i.error?.includes(`invitation link`)?(t(`private-agent`),w(null)):w(i.error||`Invalid credentials`):n.status===403?(t(`access-expired`),i.expiresAt&&r(e=>e?{...e,expiresAt:i.expiresAt}:{displayName:null,contactValue:s,contactMethod:`email`,expiresAt:i.expiresAt,status:`expired`})):n.status===429?w(i.error||`Too many attempts. Please try again later.`):w(i.error||`Something went wrong`)}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function A(e){if(!D){w(null),O(!0);try{let n=a.current,o=await fetch(`/api/access/verify-otp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({phone:y,code:e,agentSlug:n})}),s=await o.json();o.ok?(i.current=s.session_key,r(s.grant),t(`set-password`)):o.status===429?t(`otp-failed`):(w(s.error||`Invalid code`),v(``))}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function M(e){if(e.preventDefault(),!D){if(w(null),l!==d){w(`Passwords do not match`);return}if(!z(l).every(e=>e.met)){w(`Password does not meet requirements`);return}O(!0);try{let e=i.current;if(!e){w(`Session expired. Please use your invitation link again.`);return}let t=await fetch(`/api/access/create-credentials`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:e,password:l})}),n=await t.json();t.ok?o(n.session_key):t.status===400&&n.requirements?w(n.requirements.filter(e=>!e.met).map(e=>e.label).join(`, `)):w(n.error||`Something went wrong`)}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function N(e){if(e.preventDefault(),!(D||!s)){w(null),O(!0);try{let e=a.current,t=await fetch(`/api/access/forgot-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,agentSlug:e})});t.status===429?w((await t.json()).error||`Too many attempts. Please try again later.`):(E(`If an account exists, a reset link has been sent.`),setTimeout(()=>{S(!1),E(null)},4e3))}catch{w(`Unable to connect. Please try again.`)}finally{O(!1)}}}switch(e){case`set-password`:{let e=z(l),t=e.every(e=>e.met),r=l===d,i=t&&r&&d.length>0;return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[n?.expiresAt&&(0,V.jsxs)(`div`,{className:`gate-expiry-badge`,children:[`Access until `,new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`})]}),(0,V.jsxs)(`h2`,{className:`gate-title`,children:[`Welcome, `,n?.displayName||`there`]}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`Create a password to access this agent in the future.`}),(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:M,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-display-name`,children:`Display name`}),(0,V.jsx)(`input`,{id:`gate-display-name`,type:`text`,value:n?.displayName||``,disabled:!0})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(h,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoFocus:!0,autoComplete:`new-password`}),l.length>0&&(0,V.jsx)(`div`,{className:`gate-strength`,children:e.map(e=>(0,V.jsxs)(`span`,{className:`gate-strength-item${e.met?` met`:``}`,children:[e.met?`✓`:`○`,` `,e.label]},e.key))})]}),(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw-confirm`,children:`Confirm password`}),(0,V.jsx)(`input`,{id:`gate-pw-confirm`,type:p?`text`:`password`,value:d,onChange:e=>f(e.target.value),placeholder:`Confirm your password`,autoComplete:`new-password`}),d.length>0&&!r&&(0,V.jsx)(`div`,{className:`gate-error`,children:`Passwords do not match`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!i||D,loading:D,children:`Create account & enter chat`})})]})]})})}case`enter-otp`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:`Enter your code`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[`Enter the 6-digit code sent to `,B(y,`phone`)]}),(0,V.jsx)(H,{value:_,onChange:v,onComplete:A,disabled:D}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),D&&(0,V.jsxs)(`div`,{className:`gate-loading`,children:[(0,V.jsx)(`span`,{className:`spinner`}),`Verifying...`]}),(0,V.jsx)(`div`,{className:`gate-resend`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{t(`sign-in`),v(``),w(null)},children:`Use a different number`})})]})});case`sign-in`:case`private-agent`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:e===`private-agent`?`Private Agent`:`Welcome back`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:e===`private-agent`?`This agent is invitation-only. If you have an account, sign in below.`:`Sign in to continue your conversation.`}),x?(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:N,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-forgot-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-forgot-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),T&&(0,V.jsx)(`div`,{className:`gate-success`,children:T}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||D,loading:D,children:`Send reset link`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{S(!1),w(null),E(null)},children:`Back to sign in`})})]}):(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:k,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-login-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(h,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-login-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoComplete:`current-password`})]}),C&&(0,V.jsx)(`div`,{className:`gate-error`,children:C}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||!l||D,loading:D,children:`Sign in`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{S(!0),w(null)},children:`Forgot password?`})})]}),e===`private-agent`&&(0,V.jsx)(`p`,{className:`gate-hint`,children:`No account? You need an invitation from the agent owner.`})]})});case`access-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⏰`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Access expired`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[n?.expiresAt?`Your access expired on ${new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`long`,year:`numeric`})}.`:`Your access to this agent has expired.`,` `,`Contact the agent owner to renew.`]}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),w(null),u(``)},children:`Sign in with a different account`})})]})});case`link-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⚠️`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Link expired`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`This invitation link has expired or has already been used. If you already set your password, sign in below. Otherwise, ask the agent owner to send a new invitation.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`primary`,onClick:()=>{t(`sign-in`),w(null)},children:`Go to sign in`})})]})});case`otp-failed`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⛔`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Too many attempts`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`You've entered the wrong code too many times. Ask the agent owner to send a new code.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),w(null),v(``)},children:`Back to sign in`})})]})})}}var W={"single-select":m,"multi-select":C,"action-buttons":x};function G({name:e,data:t,onSubmit:n,submitted:r}){let i=W[e];return i?(0,V.jsx)(i,{data:t,onSubmit:n,submitted:r}):(console.warn(`[PublicComponentRenderer] Unknown component: "${e}". Registered: ${Object.keys(W).join(`, `)}`),(0,V.jsx)(`div`,{className:`component-card component-card--error`,children:(0,V.jsxs)(`p`,{style:{fontFamily:`var(--font-body)`,fontSize:12,color:`var(--text-secondary)`},children:[`Component “`,e,`” is not available. This may require a platform update.`]})}))}function re({messages:e,isStreaming:t,sessionError:n,selectionMode:r,selectedItems:i,toggleSelectItem:a,onComponentSubmit:s,remainingSuggestions:c,onSuggestionClick:u,isAtBottom:d,setIsAtBottom:f,isGroup:m}){let[_,y]=(0,j.useState)(new Set),[b,x]=(0,j.useState)(new Set),S=(0,j.useRef)(null),C=(0,j.useRef)(null),w=(0,j.useRef)(null),E=(0,j.useRef)(!1),D=(0,j.useRef)(!1),O=(0,j.useRef)(!1),k=(0,j.useRef)(0),A=(0,j.useRef)(!1),M=(0,j.useRef)(new Map);A.current=t,(0,j.useEffect)(()=>{t&&!E.current&&d&&(D.current=!0)},[t,d]),(0,j.useEffect)(()=>{if(!D.current&&!d){E.current=t,O.current=!1;return}if(E.current&&!t&&w.current&&C.current){let e=w.current;if(e.offsetHeight>C.current.clientHeight){D.current=!1,O.current=!0,e.scrollIntoView({behavior:`smooth`,block:`start`}),E.current=t;return}}(d||D.current)&&!O.current&&S.current?.scrollIntoView({behavior:`smooth`}),E.current&&!t&&(D.current=!1),E.current=t},[e,d,t]),(0,j.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{let t=e.scrollTop;A.current&&t<k.current&&(D.current=!1),k.current=t,f(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[f]),(0,j.useEffect)(()=>{function e(){x(e=>{let t=new Set;return M.current.forEach((n,r)=>{n.isConnected&&(_.has(r)?e.has(r)&&t.add(r):n.scrollHeight>n.clientHeight+2&&t.add(r))}),e.size===t.size&&[...e].every(e=>t.has(e))?e:t})}e();let t=new ResizeObserver(e);return M.current.forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length,_]);let N=e.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,V.jsxs)(`div`,{className:`chat-messages-wrap`,children:[r&&(0,V.jsx)(`div`,{className:`selection-overlay-band`}),(0,V.jsxs)(`div`,{className:`chat-messages`,ref:C,children:[n&&e.length===0&&(0,V.jsx)(`div`,{className:`session-error`,children:(0,V.jsx)(`p`,{children:n})}),e.map((n,c)=>{if(n.hidden)return null;let u=t&&c===e.length-1,d=`${n.timestamp}_${n.role}`,f=i.has(d);return(0,V.jsxs)(`div`,{ref:c===N?w:void 0,className:`message ${n.role}${f?` selected`:``}`,children:[r&&!u&&(0,V.jsx)(`div`,{className:`message-select-check`,children:(0,V.jsx)(h,{checked:f,onChange:()=>a(d)})}),(0,V.jsxs)(`div`,{className:`bubble`,children:[m&&n.role===`visitor`&&n.senderName&&(0,V.jsx)(`span`,{className:`bubble-sender`,children:n.senderName}),n.role===`visitor`&&n.content?(()=>{let e=_.has(c),t=b.has(c);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:e=>{e?M.current.set(c,e):M.current.delete(c)},className:e?`bubble-content`:`bubble-content clamped${t?` overflowing`:``}`,children:n.content}),t&&(0,V.jsx)(`div`,{className:`bubble-expand`,children:(0,V.jsx)(g,{variant:`icon`,className:e?`expanded`:``,onClick:()=>y(e=>{let t=new Set(e);return t.has(c)?t.delete(c):t.add(c),t}),"aria-label":e?`Collapse message`:`Expand message`,children:(0,V.jsx)(l,{size:14})})})]})})():n.content?(0,V.jsx)(T,{content:n.content,timestamp:p(n.timestamp)}):(0,V.jsxs)(`span`,{className:`typing-indicator`,children:[(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`})]}),n.attachments&&n.attachments.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:n.attachments.map((e,t)=>(0,V.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.mimeType===`application/pdf`?(0,V.jsx)(v,{size:12}):e.mimeType.startsWith(`text/`)?(0,V.jsx)(o,{size:12}):null,(0,V.jsx)(`span`,{children:e.filename})]},t))}),n.role===`visitor`&&(0,V.jsx)(`span`,{className:`message-timestamp`,children:p(n.timestamp)})]}),n.role===`maxy`&&n.components&&n.components.length>0&&(0,V.jsx)(`div`,{className:`public-components`,children:n.components.map((e,t)=>(0,V.jsx)(`div`,{className:`public-component-enter`,children:(0,V.jsx)(G,{name:e.name,data:e.data,onSubmit:e=>s(c,t,e),submitted:e.submitted})},t))})]},c)}),!t&&c.length>0&&(0,V.jsx)(`div`,{className:`chat-suggestions`,children:c.map(e=>(0,V.jsx)(g,{variant:`suggestion`,onClick:()=>u(e),children:e},e))}),(0,V.jsx)(`div`,{ref:S})]}),!d&&(0,V.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>S.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,V.jsx)(l,{size:18})})]})}function ie({selectedItems:e,messages:t,copySelected:n,exitSelection:r,showCopyToast:i}){let[a,o]=(0,j.useState)(!1),c=(0,j.useRef)(null),l=(0,j.useRef)(!1);function d(e){let n=e.lastIndexOf(`_`),r=e.slice(0,n),i=e.slice(n+1),a=parseInt(r,10);return t.find(e=>e.timestamp===a&&e.role===i)?.content??``}function f(e,t){return parseInt(e.slice(0,e.lastIndexOf(`_`)),10)-parseInt(t.slice(0,t.lastIndexOf(`_`)),10)}function p(){let e=[...t].sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let t of e){if(t.hidden||!t.content)continue;let e=t.role===`visitor`?`Visitor`:`Maxy`;n.push(`${e}:\n${t.content}`)}return n.join(`
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
`)}j.useEffect(()=>{if(!a)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]);function m(){
|
|
5
|
+
`)}j.useEffect(()=>{if(!a)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]);function m(){c.current!==null&&(clearTimeout(c.current),c.current=null)}return(0,V.jsx)(`div`,{className:`chat-input-area`,children:(0,V.jsxs)(`div`,{className:`selection-bar`,children:[(0,V.jsxs)(`span`,{className:`selection-count`,children:[e.size,` Selected`]}),(0,V.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(a){o(!1);return}l.current=!1,c.current=setTimeout(()=>{l.current=!0,o(!0),c.current=null},500)},onPointerUp:m,onPointerLeave:m,onPointerCancel:m,onClick:async()=>{l.current||await n(d,f)},children:[(0,V.jsx)(s,{size:18}),(0,V.jsx)(`span`,{children:`Copy`})]}),a&&(0,V.jsx)(`div`,{className:`copy-menu`,children:(0,V.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let e=p();e&&i(await u(e)),r()},children:`Copy all`})})]}),(0,V.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:r,children:`Cancel`})]})})}function ae({input:e,setInput:t,isStreaming:n,pendingFiles:r,setPendingFiles:i,attachError:a,setAttachError:s,isDragOver:l,setIsDragOver:u,inputRef:d,onSubmit:f,onSendVoiceNote:p}){let m=(0,j.useRef)(null),h=w(),x=h.state===`recording`||h.state===`paused`||h.state===`sending`,C=!x&&!n&&!e.trim()&&r.length===0;async function T(){let e=await h.send();if(!e)return;let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`;p(new File([e],`voice-note${t}`,{type:e.type}))}function E(e){s(null);let t=e.find(e=>!N.has(e.type));if(t){s(`Unsupported file type: "${t.type}". Supported: images, PDF, plain text, markdown, CSV, calendar.`);return}let n=e.find(e=>e.size>P);if(n){s(`"${n.name}" exceeds the 20 MB limit.`);return}i(t=>[...t,...e].slice(0,5))}function D(e){e.preventDefault(),u(!0)}function O(){u(!1)}function k(e){e.preventDefault(),u(!1),E([...e.dataTransfer.files])}return(0,V.jsxs)(`div`,{className:`chat-input-area`,children:[(0,V.jsx)(`input`,{ref:m,type:`file`,multiple:!0,accept:M,style:{display:`none`},onChange:e=>{e.target.files&&E([...e.target.files]),e.target.value=``}}),r.length>0&&(0,V.jsx)(`div`,{className:`attachment-strip`,children:r.map((e,t)=>(0,V.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,V.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type===`application/pdf`?(0,V.jsx)(v,{size:14}):(0,V.jsx)(o,{size:14}),(0,V.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,V.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>i(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),a&&(0,V.jsx)(`p`,{className:`attach-error`,children:a}),h.state===`error`&&h.errorMessage&&(0,V.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,V.jsx)(y,{size:14}),h.errorMessage]}),(0,V.jsx)(_,{inputRef:d}),x?(0,V.jsx)(`div`,{className:`chat-form voice-active`,children:(0,V.jsx)(b,{state:h.state,elapsedSeconds:h.elapsedSeconds,waveform:h.waveform,onTogglePause:h.togglePause,onDiscard:h.discard,onSend:T})}):(0,V.jsxs)(`form`,{className:`chat-form${l?` drag-over`:``}`,onSubmit:f,onDragOver:D,onDragLeave:O,onDrop:k,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&E(n)},children:[(0,V.jsx)(g,{variant:`icon`,type:`button`,onClick:()=>m.current?.click(),disabled:n,"aria-label":`Attach file`,children:(0,V.jsx)(c,{size:14})}),(0,V.jsx)(S,{ref:d,value:e,onChange:t}),C?(0,V.jsx)(g,{variant:`send`,type:`button`,onClick:h.start,disabled:n,"aria-label":`Record voice note`,children:(0,V.jsx)(y,{size:14})}):(0,V.jsx)(g,{variant:`send`,type:`submit`,disabled:n||!e.trim()&&r.length===0,"aria-label":`Send message`,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})]})}var K=[];function q(){let[e,t]=(0,j.useState)(``),[n,r]=(0,j.useState)([]),[i,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(null),[l,u]=(0,j.useState)(K),[p,m]=(0,j.useState)(!0),h=(0,j.useRef)(null),{selectionMode:g,selectedItems:_,copyToast:v,exitSelection:y,enterSelection:b,toggleSelectItem:x,copySelected:S,showCopyToast:C}=a(),w=(0,j.useRef)(()=>{}),T=ee((0,j.useCallback)(e=>{w.current(e)},[])),{sessionId:D,sessionKeyRef:A,sessionError:M,pageState:N,agentDisplayName:P,agentImage:F,agentImageShape:I,showAgentName:L,branding:R,ensureSession:z,startNewSession:B,resumedRef:H,resumeMessagesRef:W,groupContext:G,groupSlug:q}=T,{messages:J,setMessages:Y,isStreaming:X,sendMessage:Z,sendGreeting:Q,handleComponentSubmit:oe}=te({sessionKeyRef:A,ensureSession:z,sessionError:M,pageState:N,inputRef:h});(0,j.useEffect)(()=>{w.current=Q},[Q]),ne({sessionKeyRef:A,groupSlug:q,isStreaming:X,setMessages:Y}),(0,j.useEffect)(()=>{let e=!1;return(async()=>{let t=await z();if(!e&&t){if(H.current&&W.current&&W.current.length>0){Y(W.current.map(e=>({role:e.role,content:e.content,timestamp:e.timestamp}))),W.current=null;return}Q(t)}})(),()=>{e=!0}},[]),(0,j.useEffect)(()=>{N===`chat`&&h.current?.focus()},[N]),(0,j.useEffect)(()=>{if(N!==`chat`)return;history.pushState({maxyChat:!0},``);function e(){history.pushState({maxyChat:!0},``)}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[N]),(0,j.useEffect)(()=>{if(!R)return;let e=document.documentElement;if(R.primaryColor&&(e.style.setProperty(`--sage`,R.primaryColor),e.style.setProperty(`--sage-hover`,R.primaryColor),e.style.setProperty(`--sage-subtle`,R.primaryColor+`14`),e.style.setProperty(`--sage-glow`,R.primaryColor+`26`)),R.accentColor&&e.style.setProperty(`--visitor-bubble`,R.accentColor),R.backgroundColor&&e.style.setProperty(`--bg`,R.backgroundColor),document.title=R.name,R.primaryColor){let e=document.querySelector(`meta[name="theme-color"]`);e||(e=document.createElement(`meta`),e.name=`theme-color`,document.head.appendChild(e)),e.content=R.primaryColor}if(R.faviconUrl){let e=document.querySelector(`link[rel="icon"]`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.appendChild(e)),e.href=R.faviconUrl}},[R]),(0,j.useEffect)(()=>{function e(e){e.key===`Escape`&&g&&y()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,y]);function se(){X||(Y([]),u(K),B())}function $(e){if(!e&&n.length===0||X)return;Y(e=>e.map(e=>e.components?.some(e=>!e.submitted)?{...e,components:e.components.map(e=>e.submitted?e:{...e,submitted:!0})}:e)),u(t=>t.filter(t=>t!==e)),m(!0);let i=[...n];t(``),r([]),c(null),Z(e,{files:i})}function ce(t){t.preventDefault(),$(e.trim()),h.current?.resetHeight()}return(0,V.jsxs)(`div`,{className:`chat-page`,children:[(0,V.jsxs)(`header`,{className:`chat-header`,children:[(0,V.jsx)(`img`,{src:F||R?.logoUrl||O,alt:R?.name||f.productName,className:`chat-logo${F&&I===`circle`?` chat-logo--circle`:``}${F&&I===`rounded`?` chat-logo--rounded`:``}`,onError:e=>{e.target.src=R?.logoUrl||O}}),(0,V.jsxs)(`div`,{className:`chat-header-text`,children:[L!==`none`&&(0,V.jsx)(`h1`,{className:`chat-tagline`,children:G?.groupName||L&&P||R?.name||f.productName}),(0,V.jsx)(`p`,{className:`chat-intro`,children:G?`${G.participants.length} participants`:R?.tagline||``}),(0,V.jsx)(`p`,{className:`chat-ai-indicator`,children:`AI assistant`})]}),N===`chat`&&!g&&(0,V.jsxs)(`div`,{className:`chat-header-actions`,children:[(0,V.jsx)(`button`,{className:`chat-header-action`,onClick:se,disabled:X,title:`New conversation`,"aria-label":`New conversation`,children:(0,V.jsx)(k,{size:16})}),(0,V.jsx)(`button`,{className:`chat-header-action`,onClick:b,title:`Select messages`,"aria-label":`Select messages`,children:(0,V.jsx)(d,{size:16})})]})]}),N===`loading`&&(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsx)(`div`,{className:`gate-loading`,children:(0,V.jsx)(`span`,{className:`spinner`})})}),N===`auth-required`&&(0,V.jsx)(U,{gateState:T.gateState,setGateState:T.setGateState,grantInfo:T.grantInfo,setGrantInfo:T.setGrantInfo,gateSessionKeyRef:T.gateSessionKeyRef,resolvedSlugRef:T.resolvedSlugRef,onAuthenticated:T.enterChat}),N===`chat`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(re,{messages:J,isStreaming:X,sessionError:M,selectionMode:g,selectedItems:_,toggleSelectItem:x,onComponentSubmit:oe,remainingSuggestions:l,onSuggestionClick:$,isAtBottom:p,setIsAtBottom:m,isGroup:!!G}),g?(0,V.jsx)(ie,{selectedItems:_,messages:J,copySelected:S,exitSelection:y,showCopyToast:C}):(0,V.jsx)(ae,{input:e,setInput:t,isStreaming:X,pendingFiles:n,setPendingFiles:r,attachError:s,setAttachError:c,isDragOver:i,setIsDragOver:o,inputRef:h,onSubmit:ce,onSendVoiceNote:e=>{t(``),r([]),c(null),Z(`[Voice note]`,{files:[e]})}})]}),v&&(0,V.jsx)(`span`,{className:`copy-toast${v===`failed`?` copy-toast-failed`:``}`,children:v===`copied`?`Copied`:`Copy failed`}),(0,V.jsxs)(`footer`,{className:`chat-footer`,children:[(0,V.jsxs)(`a`,{href:E,children:[f.domain,` `,`↗`]}),D&&(0,V.jsxs)(`span`,{style:{opacity:.35,fontSize:`10px`,fontFamily:`monospace`,marginLeft:`1rem`},children:[`Conversation · `,D.slice(0,8)]})]})]})}(0,A.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(q,{}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./jsx-runtime-
|
|
1
|
+
import{r as e}from"./jsx-runtime-CHqDsKlc.js";var t=e(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),n=e(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),r=e(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),i=e(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),a=e(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),o=e(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]);export{n as a,r as i,a as n,t as o,i as r,o as t};
|
package/payload/server/public/assets/{useVoiceRecorder-CtSgpc95.js → useVoiceRecorder-DyDXH7EA.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-CCUSwZB_.js","assets/preload-helper-qlgyTAkD.js","assets/dist-CrzV1W3-.js","assets/chunk-DD-I1_y5.js","assets/chunk-U2HBQHQK-BZnA7c4T.js","assets/src-Bo15iQ7w.js","assets/chunk-5PVQY5BW-RhIfPCRB.js","assets/chunk-ICPOFSXX-Di63NBur.js","assets/_baseFor-Dn4GSmI6.js","assets/isEmpty-h-wRi_o9.js","assets/chunk-336JU56O-BpATJiGl.js","assets/chunk-5FUZZQ4R-BoTfWHuW.js","assets/chunk-X2U36JSP-DpQ2OA_c.js","assets/chunk-ZZ45TVLE-DBSm41oP.js","assets/rough.esm-NLRoWnq-.js","assets/chunk-ENJZ2VHE-CNHjq5xK.js","assets/line-DlKKhwkO.js","assets/path-7vUsG-o2.js","assets/array-DJN9YAVf.js","assets/chunk-BSJP7CBP-CTsYuARh.js","assets/chunk-426QAEUC-Wz6Bpsil.js","assets/chunk-XPW4576I-BccP1mlQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e,r as t,t as n}from"./chunk-DD-I1_y5.js";import{n as r,o as i,r as a,t as o}from"./jsx-runtime-
|
|
2
|
+
import{o as e,r as t,t as n}from"./chunk-DD-I1_y5.js";import{n as r,o as i,r as a,t as o}from"./jsx-runtime-CHqDsKlc.js";import{t as s}from"./preload-helper-qlgyTAkD.js";var c=a(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),l=a(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),u=a(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),d=a(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),f=a(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),p=a(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),m=a(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),h=a(`paperclip`,[[`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`}]]),g=a(`pause`,[[`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`}]]),_=a(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),v=a(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),y=a(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),b=e(i(),1);async function x(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function S(){let[e,t]=(0,b.useState)(!1),[n,r]=(0,b.useState)(new Set),[i,a]=(0,b.useState)(!1),o=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);let s=(0,b.useCallback)(()=>{t(!0),r(new Set)},[]),c=(0,b.useCallback)(()=>{t(!1),r(new Set)},[]),l=(0,b.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),u=(0,b.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),d=(0,b.useCallback)(e=>({onPointerDown:()=>{o.current=setTimeout(()=>{t(!0),r(new Set([e])),o.current=null},500)},onPointerUp:u,onPointerLeave:u,onPointerCancel:u}),[u]),f=(0,b.useCallback)(e=>{a(e?`copied`:`failed`),setTimeout(()=>a(!1),1500)},[]);return{selectionMode:e,selectedItems:n,copyToast:i,longPressProps:d,enterSelection:s,exitSelection:c,toggleSelectItem:l,copySelected:(0,b.useCallback)(async(e,t)=>{let r=[...n].sort(t).map(t=>e(t)).filter(Boolean);r.length>0&&f(await x(r.join(`
|
|
3
3
|
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -33,4 +33,4 @@ import{o as e,r as t,t as n}from"./chunk-DD-I1_y5.js";import{n as r,o as i,r as
|
|
|
33
33
|
`,...a.current()});return/^[\t ]/.test(l)&&(l=As(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Is.peek=Ls;function Is(e){return e.value||``}function Ls(){return`<`}Rs.peek=zs;function Rs(e,t,n,r){let i=Ds(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function zs(){return`!`}Bs.peek=Vs;function Bs(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Vs(){return`!`}Hs.peek=Us;function Hs(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Us(){return"`"}function Ws(e,t){let n=Et(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Gs.peek=Ks;function Gs(e,t,n,r){let i=Ds(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Ws(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Ks(e,t,n){return Ws(e,n)?`<`:`[`}qs.peek=Js;function qs(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Js(){return`[`}function Ys(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Xs(e){let t=Ys(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Zs(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Qs(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function $s(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Zs(n):Ys(n),s=e.ordered?o===`.`?`)`:`.`:Xs(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Qs(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function ec(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function tc(e,t,n,r){let i=ec(n),a=n.bulletCurrent||Ys(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function nc(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var rc=ua([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function ic(e,t,n,r){return(e.children.some(function(e){return rc(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function ac(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}oc.peek=sc;function oc(e,t,n,r){let i=ac(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=js(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=As(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=js(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+As(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function sc(e,t,n){return n.options.strong||`*`}function cc(e,t,n,r){return n.safe(e.value,r)}function lc(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function uc(e,t,n){let r=(Qs(n)+(n.options.ruleSpaces?` `:``)).repeat(lc(n));return n.options.ruleSpaces?r.slice(0,-1):r}var dc={blockquote:_s,break:xs,code:Ts,definition:Os,emphasis:Ms,hardBreak:xs,heading:Fs,html:Is,image:Rs,imageReference:Bs,inlineCode:Hs,link:Gs,linkReference:qs,list:$s,listItem:tc,paragraph:nc,root:ic,strong:oc,text:cc,thematicBreak:uc};function fc(){return{enter:{table:pc,tableData:_c,tableHeader:_c,tableRow:hc},exit:{codeText:vc,table:mc,tableData:gc,tableHeader:gc,tableRow:gc}}}function pc(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function mc(e){this.exit(e),this.data.inTable=void 0}function hc(e){this.enter({type:`tableRow`,children:[]},e)}function gc(e){this.exit(e)}function _c(e){this.enter({type:`tableCell`,children:[]},e)}function vc(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,yc));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function yc(e,t){return t===`|`?t:e}function bc(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
34
34
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
35
35
|
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return ms(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=dc.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function xc(){return{exit:{taskListCheckValueChecked:Cc,taskListCheckValueUnchecked:Cc,paragraph:wc}}}function Sc(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Tc}}}function Cc(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function wc(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Tc(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=dc.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Ec(){return[Mo(),ns(),ss(),fc(),xc()]}function Dc(e){return{extensions:[No(),rs(e),cs(),bc(e),Sc()]}}var Oc={tokenize:Bc,partial:!0},kc={tokenize:Vc,partial:!0},Ac={tokenize:Hc,partial:!0},jc={tokenize:Uc,partial:!0},Mc={tokenize:Wc,partial:!0},Nc={name:`wwwAutolink`,tokenize:Rc,previous:Gc},Pc={name:`protocolAutolink`,tokenize:zc,previous:Kc},Q={name:`emailAutolink`,tokenize:Lc,previous:qc},$={};function Fc(){return{text:$}}for(var Ic=48;Ic<123;)$[Ic]=Q,Ic++,Ic===58?Ic=65:Ic===91&&(Ic=97);$[43]=Q,$[45]=Q,$[46]=Q,$[95]=Q,$[72]=[Q,Pc],$[104]=[Q,Pc],$[87]=[Q,Nc],$[119]=[Q,Nc];function Lc(e,t,n){let r=this,i,a;return o;function o(t){return!Jc(t)||!qc.call(r,r.previous)||Yc(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Jc(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Mc,u,l)(t):t===45||t===95||G(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&W(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Rc(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Gc.call(r,r.previous)||Yc(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Oc,e.attempt(kc,e.attempt(Ac,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function zc(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Kc.call(r,r.previous)&&!Yc(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(W(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Rt(t)||q(t)||Ut(t)||Ht(t)?n(t):e.attempt(kc,e.attempt(Ac,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Bc(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Vc(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(jc,c,s)(t):t===null||q(t)||Ut(t)||t!==45&&Ht(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Hc(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(jc,t,a)(o):o===null||q(o)||Ut(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Uc(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||q(o)||Ut(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||q(e)||Ut(e)?t(e):r(e)}function a(e){return W(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):W(t)?(e.consume(t),o):n(t)}}function Wc(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return G(e)?n(e):t(e)}}function Gc(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||q(e)}function Kc(e){return!W(e)}function qc(e){return!(e===47||Jc(e))}function Jc(e){return e===43||e===45||e===46||e===95||G(e)}function Yc(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Xc={tokenize:il,partial:!0};function Zc(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:tl,continuation:{tokenize:nl},exit:rl}},text:{91:{name:`gfmFootnoteCall`,tokenize:el},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Qc,resolveTo:$c}}}}function Qc(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=U(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function $c(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function el(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||q(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(U(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return q(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function tl(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||q(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=U(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return q(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Y(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function nl(e,t,n){return e.check(sn,t,e.attempt(Xc,t,n))}function rl(e){e.exit(`gfmFootnoteDefinition`)}function il(e,t,n){let r=this;return Y(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function al(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&V(o,o.length,0,$t(s,e.slice(r+1,n),t)),V(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),V(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Qt(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Qt(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var ol=class{constructor(){this.map=[]}add(e,t,n){sl(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function sl(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function cl(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function ll(){return{flow:{null:{name:`table`,tokenize:ul,resolveAll:dl}}}}function ul(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):K(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):J(t)?Y(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||q(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,J(t)?Y(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return J(t)?Y(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||K(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return J(t)?Y(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||K(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||K(n)?(e.exit(`tableRow`),t(n)):J(n)?Y(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||q(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function dl(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new ol;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(pl(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=fl(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=fl(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=fl(f,t,o,i,n,d)):(o[0]=o[1],d=fl(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&pl(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=cl(t.events,n))}return e}function fl(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},ml(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=ml(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=ml(t.events,n[2]),a=ml(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},ml(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function pl(e,t,n,r,i){let a=[],o=ml(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function ml(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var hl={name:`tasklistCheck`,tokenize:_l};function gl(){return{text:{91:hl}}}function _l(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return q(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return K(r)?t(r):J(r)?e.check({tokenize:vl},t,n)(r):n(r)}}function vl(e,t,n){return Y(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function yl(e){return Nt([Fc(),Zc(),al(e),ll(),gl()])}var bl={};function xl(e){let t=this,n=e||bl,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(yl(n)),a.push(Ec()),o.push(Dc(n))}var Sl=100;function Cl(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,reason:`invalid JSON: ${e instanceof Error?e.message:String(e)}`}}if(typeof t!=`object`||!t||Array.isArray(t))return{ok:!1,reason:`payload is not a JSON object`};let n=t;if(typeof n.url!=`string`||n.url.length===0)return{ok:!1,reason:`url is required`};let r;try{r=new URL(n.url)}catch{return{ok:!1,reason:`url is not a valid URL`}}if(r.protocol!==`http:`&&r.protocol!==`https:`)return{ok:!1,reason:`url scheme ${r.protocol} is not permitted (http/https only)`};if(typeof n.intent!=`string`||n.intent.length===0)return{ok:!1,reason:`intent is required`};if(n.intent.length>Sl)return{ok:!1,reason:`intent exceeds ${Sl} chars`};let i;if(n.hostname!==void 0){if(typeof n.hostname!=`string`)return{ok:!1,reason:`hostname must be a string when provided`};i=n.hostname}return{ok:!0,payload:i?{url:n.url,intent:n.intent,hostname:i}:{url:n.url,intent:n.intent}}}var wl=(0,b.createContext)(null);function Tl({value:e,children:t}){return(0,O.jsx)(wl.Provider,{value:e,children:t})}function El(){return(0,b.useContext)(wl)}var Dl={ok:`succeeded`,timeout:`navigation timed out`,"cdp-unreachable":`device browser is not responding`,error:`navigation error`};async function Ol(e,t){try{await fetch(`/api/admin/events`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:e,fields:t})})}catch(t){console.error(`[device-url:event] failed to post event`,e,t)}}function kl({raw:e,reason:t}){return(0,b.useEffect)(()=>{Ol(`device-url:malformed`,{reason:t.slice(0,200),length:e.length})},[e,t]),(0,O.jsx)(`pre`,{className:`md-pre md-device-url-malformed`,children:(0,O.jsxs)(`code`,{className:`md-code`,children:[(0,O.jsxs)(`span`,{className:`md-device-url-malformed-label`,children:[(0,O.jsx)(y,{size:12}),` device-URL block is malformed: `,t]}),`
|
|
36
|
-
`,e]})})}function Al({payload:e,reason:t}){let[n,r]=(0,b.useState)(`idle`);(0,b.useEffect)(()=>{Ol(`device-url:fallback-shown`,{intent:e.intent,reason:t,hostname:e.hostname??``})},[e.intent,e.hostname,t]);let i=async()=>{try{await navigator.clipboard.writeText(e.url),r(`copied`),window.setTimeout(()=>r(`idle`),2e3)}catch(t){r(`failed`),Ol(`device-url:fallback-shown`,{intent:e.intent,reason:`clipboard-api-unavailable`,hostname:e.hostname??``,detail:t instanceof Error?t.message.slice(0,200):String(t).slice(0,200)})}},a=e.hostname?` on the device (${e.hostname})`:` on the device`;return(0,O.jsxs)(`div`,{className:`md-device-url md-device-url-fallback`,role:`group`,children:[(0,O.jsxs)(`div`,{className:`md-device-url-fallback-message`,children:[(0,O.jsx)(y,{size:14}),(0,O.jsxs)(`span`,{children:[`Could not open `,(0,O.jsx)(`strong`,{children:e.intent}),a,` automatically (`,t,`). Copy the URL and open it in a browser on the device:`]})]}),(0,O.jsxs)(`div`,{className:`md-device-url-fallback-url`,children:[(0,O.jsx)(`code`,{children:e.url}),(0,O.jsxs)(`button`,{type:`button`,className:`md-device-url-fallback-copy`,onClick:i,"aria-label":`Copy URL`,children:[n===`copied`?(0,O.jsx)(c,{size:14}):(0,O.jsx)(u,{size:14}),n===`copied`?`Copied`:n===`failed`?`Copy failed`:`Copy`]})]}),n===`failed`&&(0,O.jsx)(`div`,{className:`md-device-url-fallback-copy-failed`,children:`Your browser blocked the copy action. Select the URL text above manually to copy it.`})]})}function jl({payload:e}){let t=El(),[n,r]=(0,b.useState)({phase:`idle`});(0,b.useEffect)(()=>{Ol(`device-url:render`,{intent:e.intent,url:e.url,hostname:e.hostname??``,origin:`tool`})},[e.intent,e.url,e.hostname]);let i=async()=>{if(n.phase!==`navigating`){r({phase:`navigating`});try{let n=await fetch(`/api/admin/device-browser/navigate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),i=await n.json().catch(()=>({}));if(n.ok&&i.ok){r({phase:`succeeded`}),t&&(t.onShowVnc(),Ol(`device-url:vnc-surface-shown`,{intent:e.intent})),window.setTimeout(()=>r({phase:`idle`}),2500);return}r({phase:`fallback`,reason:i.navigateResult?Dl[i.navigateResult]:i.detail?i.detail.slice(0,80):`navigation failed`})}catch(e){r({phase:`fallback`,reason:(e instanceof Error?e.message:String(e)).slice(0,80)})}}},a=n.phase===`navigating`,o=n.phase===`succeeded`;return(0,O.jsxs)(`div`,{className:`md-device-url`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`md-device-url-button`,onClick:i,disabled:a,"aria-label":`Open ${e.intent} on the device's browser`,title:e.hostname?`Opens on device: ${e.hostname}`:`Opens on the device running Maxy`,children:[(0,O.jsx)(p,{size:16,className:`md-device-url-icon`}),(0,O.jsx)(`span`,{className:`md-device-url-label`,children:a?`Opening…`:o?`Opened on device`:`Open ${e.intent} on device`})]}),n.phase===`fallback`&&(0,O.jsx)(Al,{payload:e,reason:n.reason})]})}function Ml({source:e}){let t=Cl(e.trim());return t.ok?(0,O.jsx)(jl,{payload:t.payload}):(0,O.jsx)(kl,{raw:e,reason:t.reason})}var Nl=null;function Pl(){return Nl||=s(async()=>{let{default:e}=await import(`./mermaid.core-CCUSwZB_.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({default:e})=>(e.initialize({startOnLoad:!1,theme:`neutral`}),e)),Nl}function Fl({source:e}){let t=(0,b.useRef)(null),[n,r]=(0,b.useState)(null);return(0,b.useEffect)(()=>{let n=!1,i=`mermaid-${Math.random().toString(36).slice(2,9)}`;return Pl().then(t=>t.render(i,e)).then(({svg:e})=>{!n&&t.current&&(t.current.innerHTML=e)}).catch(t=>{n||(console.error(`[MermaidBlock] render failed:`,e,t),r(t instanceof Error?t.message:`Diagram render failed`))}),()=>{n=!0}},[e]),n?(0,O.jsxs)(`div`,{className:`md-mermaid md-mermaid-error`,children:[(0,O.jsx)(`div`,{className:`md-mermaid-error-label`,children:`Diagram render error`}),(0,O.jsx)(`pre`,{className:`md-pre`,children:(0,O.jsx)(`code`,{className:`md-code`,children:e})})]}):(0,O.jsx)(`div`,{className:`md-mermaid`,ref:t})}var Il=/\.(mp4|webm|mov)(\?.*)?$/i,Ll=/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/,Rl=/vimeo\.com\/(\d+)/;function zl(e){return!!e&&Il.test(e)}function Bl(e){if(!e)return null;let t=e.match(Ll);return t?t[1]:null}function Vl(e){if(!e)return null;let t=e.match(Rl);return t?t[1]:null}function Hl({src:e}){return(0,O.jsx)(`video`,{className:`md-video`,controls:!0,playsInline:!0,preload:`metadata`,children:(0,O.jsx)(`source`,{src:e})})}function Ul({videoId:e}){return(0,O.jsx)(`div`,{className:`md-video-iframe`,children:(0,O.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${e}`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function Wl({videoId:e}){return(0,O.jsx)(`div`,{className:`md-video-iframe`,children:(0,O.jsx)(`iframe`,{src:`https://player.vimeo.com/video/${e}`,allow:`autoplay; fullscreen; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function Gl(e){if(zl(e))return(0,O.jsx)(Hl,{src:e});let t=Bl(e);if(t)return(0,O.jsx)(Ul,{videoId:t});let n=Vl(e);return n?(0,O.jsx)(Wl,{videoId:n}):null}var Kl={p:({children:e})=>(0,O.jsx)(`p`,{className:`md-p`,children:e}),h1:({children:e})=>(0,O.jsx)(`h1`,{className:`md-heading`,children:e}),h2:({children:e})=>(0,O.jsx)(`h2`,{className:`md-heading`,children:e}),h3:({children:e})=>(0,O.jsx)(`h3`,{className:`md-heading`,children:e}),code:({children:e,className:t})=>t===`language-mermaid`?(0,O.jsx)(Fl,{source:String(e).replace(/\n$/,``)}):t===`language-maxy-device-url`?(0,O.jsx)(Ml,{source:String(e).replace(/\n$/,``)}):(0,O.jsx)(`code`,{className:`md-code ${t||``}`.trim(),children:e}),pre:({children:e,node:t})=>{let n=t?.children?.[0];if(n?.type===`element`&&n.tagName===`code`){let t=n.properties?.className??[];if(t.includes(`language-mermaid`)||t.includes(`language-maxy-device-url`))return(0,O.jsx)(O.Fragment,{children:e})}return(0,O.jsx)(`pre`,{className:`md-pre`,children:e})},ul:({children:e})=>(0,O.jsx)(`ul`,{className:`md-list`,children:e}),ol:({children:e})=>(0,O.jsx)(`ol`,{className:`md-list md-list-ordered`,children:e}),li:({children:e})=>(0,O.jsx)(`li`,{className:`md-list-item`,children:e}),hr:()=>(0,O.jsx)(`hr`,{className:`md-hr`}),strong:({children:e})=>(0,O.jsx)(`strong`,{className:`md-strong`,children:e}),img:({src:e,alt:t})=>Gl(e)||(0,O.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:(0,O.jsx)(`img`,{className:`md-img`,src:e,alt:t||``,loading:`lazy`})}),a:({href:e,children:t})=>Gl(e)||(0,O.jsx)(`a`,{href:e,className:`md-link`,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({children:e})=>(0,O.jsx)(`table`,{className:`md-table`,children:e}),thead:({children:e})=>(0,O.jsx)(`thead`,{className:`md-thead`,children:e}),tbody:({children:e})=>(0,O.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,O.jsx)(`tr`,{className:`md-tr`,children:e}),th:({children:e})=>(0,O.jsx)(`th`,{className:`md-th`,children:e}),td:({children:e})=>(0,O.jsx)(`td`,{className:`md-td`,children:e})};function ql({content:e,elapsedSeconds:t,timestamp:n}){return(0,O.jsxs)(`div`,{className:`markdown-message`,children:[(0,O.jsx)(yo,{remarkPlugins:[xl],components:Kl,children:e}),t!==void 0&&(0,O.jsxs)(`div`,{className:`message-meta`,children:[t,`s`]}),n&&(0,O.jsx)(`span`,{className:`message-timestamp`,children:n})]})}function Jl({submitted:e,submittedLabel:t=`Submitted`,actions:n,children:r}){return(0,O.jsxs)(`div`,{className:`component-card${e?` component-card--submitted`:``}`,children:[r,(0,O.jsx)(`div`,{className:`component-card__actions`,children:e?(0,O.jsx)(`span`,{className:`component-card__done-label`,children:t}):n.map((e,t)=>(0,O.jsx)(A,{variant:e.variant,size:`sm`,disabled:e.disabled,onClick:e.onClick,children:e.label},t))})]})}function Yl({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.options)?r.options:[],[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(`Submitted`);if(i.length===0)return null;let l=e=>{n||o(e)},u=()=>{if(!a||n)return;let e=i.find(e=>e.value===a);c(e?.label??`Submitted`),t((r?.submitMessage??`Selected: {{value}}`).replace(`{{value}}`,a).replace(`{{label}}`,e?.label??a))},d=()=>{n||(c(r?.backLabel??`Back`),t(r?.backMessage??``))},f=(e,t)=>{if(!n)if(e.key===`ArrowDown`||e.key===`ArrowRight`){e.preventDefault();let n=(t+1)%i.length;l(i[n].value),(e.currentTarget.parentElement?.children[n])?.focus()}else if(e.key===`ArrowUp`||e.key===`ArrowLeft`){e.preventDefault();let n=(t-1+i.length)%i.length;l(i[n].value),(e.currentTarget.parentElement?.children[n])?.focus()}else (e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(i[t].value))};return(0,O.jsx)(Jl,{submitted:n,submittedLabel:s,actions:[...r?.backLabel&&r?.backMessage?[{label:r.backLabel,variant:`ghost`,onClick:d}]:[],{label:r?.submitLabel??`Confirm`,variant:`primary`,disabled:!a,onClick:u}],children:(0,O.jsxs)(`div`,{className:`single-select`,role:`radiogroup`,"aria-label":r?.title??`Select one`,children:[r?.title&&(0,O.jsx)(`div`,{className:`single-select__title`,children:r.title}),i.map((e,t)=>(0,O.jsxs)(`div`,{className:`single-select__row${a===e.value?` single-select__row--selected`:``}`,role:`radio`,"aria-checked":a===e.value,tabIndex:a===e.value||!a&&t===0?0:-1,onClick:()=>l(e.value),onKeyDown:e=>f(e,t),children:[(0,O.jsx)(`span`,{className:`single-select__radio${a===e.value?` single-select__radio--checked`:``}`}),(0,O.jsxs)(`div`,{className:`single-select__info`,children:[(0,O.jsxs)(`span`,{className:`single-select__label`,children:[e.icon&&(0,O.jsx)(`span`,{className:`single-select__icon`,children:e.icon}),e.label]}),e.description&&(0,O.jsx)(`span`,{className:`single-select__desc`,children:e.description})]})]},e.value))]})})}function Xl({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.options)?r.options:[],[a,o]=(0,b.useState)(i.map(e=>!!e.locked||!!e.defaultSelected)),[s,c]=(0,b.useState)(`Submitted`);if(i.length===0)return null;let l=i.some(e=>e.locked),u=i.every((e,t)=>e.locked||a[t]),d=e=>{n||i[e].locked||o(t=>t.map((t,n)=>n===e?!t:t))},f=()=>{n||o(i.map((e,t)=>e.locked?a[t]:!u))},p=i.filter((e,t)=>!e.locked&&a[t]).map(e=>e.value),m=p.length>0||l,h=()=>{if(!(!m||n)){if(c(`Submitted`),p.length===0){t(`No optional plugins selected`);return}t((r?.submitMessage??`Selected: {{values}}`).replace(`{{values}}`,p.join(`, `)))}},g=()=>{n||(c(`Skipped`),t(r?.skipMessage??`Skipped`))},_=()=>{n||(c(r?.backLabel??`Back`),t(r?.backMessage??``))},v=[];return r?.backLabel&&r?.backMessage&&v.push({label:r.backLabel,variant:`ghost`,onClick:_}),r?.skipLabel&&v.push({label:r.skipLabel,variant:`ghost`,onClick:g}),v.push({label:r?.submitLabel??`Confirm`,variant:`primary`,disabled:!m,onClick:h}),(0,O.jsx)(Jl,{submitted:n,submittedLabel:s,actions:v,children:(0,O.jsxs)(`div`,{className:`multi-select`,children:[r?.title&&(0,O.jsx)(`div`,{className:`multi-select__title`,children:r.title}),r?.selectAll&&(0,O.jsx)(`div`,{className:`multi-select__header`,children:(0,O.jsx)(k,{checked:u,onChange:f,label:`Select all`,disabled:n})}),(0,O.jsx)(`div`,{className:`multi-select__list`,role:`group`,"aria-label":r?.title??`Select options`,children:i.map((e,t)=>{let r=e.group&&(t===0||e.group!==i[t-1].group),o=!!e.locked;return(0,O.jsxs)(b.Fragment,{children:[r&&(0,O.jsx)(`div`,{className:`multi-select__group-header`,children:e.group}),(0,O.jsxs)(`div`,{className:`multi-select__row${o?` multi-select__row--locked`:``}`,role:`checkbox`,"aria-checked":a[t],"aria-disabled":o||void 0,tabIndex:o?-1:0,onClick:()=>d(t),onKeyDown:e=>{n||o||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t))},children:[(0,O.jsx)(k,{checked:a[t],onChange:()=>d(t),disabled:n||o}),(0,O.jsxs)(`div`,{className:`multi-select__info`,children:[(0,O.jsxs)(`span`,{className:`multi-select__label`,children:[e.label,e.badge&&(0,O.jsx)(`span`,{className:`multi-select__badge`,children:e.badge})]}),e.description&&(0,O.jsx)(`span`,{className:`multi-select__desc`,children:e.description})]})]})]},e.value)})})]})})}function Zl({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.buttons)?r.buttons:[],[a,o]=(0,b.useState)(`Submitted`);if(i.length===0)return null;let s=e=>{n||(o(e.label),t(e.value))};return(0,O.jsx)(Jl,{submitted:n,submittedLabel:a,actions:i.map(e=>({label:e.label,variant:`primary`,onClick:()=>s(e)})),children:(0,O.jsx)(O.Fragment,{})})}function Ql(e){let t=new Date(e),n=new Date,r=String(t.getHours()).padStart(2,`0`),i=String(t.getMinutes()).padStart(2,`0`);return t.toDateString()===n.toDateString()?`${r}:${i}`:`${String(t.getDate()).padStart(2,`0`)}-${String(t.getMonth()+1).padStart(2,`0`)}-${t.getFullYear()} ${r}:${i}`}var $l=44,eu=(0,b.forwardRef)(function({value:e,onChange:t,placeholder:n,disabled:r},i){let a=(0,b.useRef)(null),o=(0,b.useRef)(!1),s=(0,b.useCallback)((e,t)=>{let n=e.closest(`.chat-form`);n&&(n.dataset.expanded=t>$l?`true`:``)},[]),c=(0,b.useCallback)(e=>{if(o.current)return;let t=window.innerHeight*.75;e.style.height=`auto`;let n=Math.min(e.scrollHeight,t);e.style.height=`${n}px`,e.style.overflowY=e.scrollHeight>t?`auto`:`hidden`,s(e,n)},[s]);return(0,b.useImperativeHandle)(i,()=>({focus(){a.current?.focus()},resetHeight(){if(!a.current)return;o.current=!1,a.current.style.height=``,a.current.style.overflowY=``;let e=a.current.closest(`.chat-form`);e&&(e.dataset.expanded=``)},getOffsetHeight(){return a.current?.offsetHeight??36},setHeight(e){a.current&&(o.current=!0,a.current.style.height=`${e}px`,s(a.current,e))}})),(0,O.jsx)(`textarea`,{ref:a,className:`chat-input`,rows:1,value:e,onChange:e=>{t(e.target.value),c(e.target)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.closest(`form`)?.requestSubmit())},placeholder:n,disabled:r,"aria-label":n||`Type a message...`})});function tu({inputRef:e}){let t=(0,b.useRef)(null);function n(n){e.current&&(n.preventDefault(),n.target.setPointerCapture(n.pointerId),t.current={startY:n.clientY,startH:e.current.getOffsetHeight()})}function r(n){if(!t.current||!e.current)return;let r=t.current.startY-n.clientY,i=window.innerHeight*.75,a=Math.max(36,Math.min(i,t.current.startH+r));e.current.setHeight(a)}function i(){t.current=null}return(0,O.jsx)(`div`,{className:`chat-resize-handle`,onPointerDown:n,onPointerMove:r,onPointerUp:i,"aria-label":`Resize input`,children:(0,O.jsx)(`div`,{className:`chat-resize-handle-bar`})})}function nu(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function ru({data:e,active:t}){let n=[];if(e&&e.length>0&&t){let t=Math.floor(e.length/24);for(let r=0;r<24;r++){let i=e[r*t]??128,a=Math.abs(i-128)/128;n.push(Math.max(.15,a))}}else for(let e=0;e<24;e++)n.push(.15);return(0,O.jsx)(`div`,{className:`voice-waveform`,"aria-hidden":`true`,children:n.map((e,t)=>(0,O.jsx)(`div`,{className:`voice-waveform-bar`,style:{height:`${Math.round(e*100)}%`}},t))})}function iu({state:e,elapsedSeconds:t,waveform:n,onTogglePause:i,onDiscard:a,onSend:o}){if(e===`idle`||e===`error`)return null;let s=e===`recording`,c=e===`paused`,l=e===`sending`;return(0,O.jsxs)(`div`,{className:`voice-recorder`,role:`region`,"aria-label":`Voice recording`,"aria-live":`polite`,children:[(0,O.jsx)(`button`,{type:`button`,className:`voice-trash`,onClick:a,disabled:l,"aria-label":`Discard recording`,children:(0,O.jsx)(r,{size:16})}),(0,O.jsx)(`span`,{className:`voice-timer`,"aria-live":`polite`,"aria-atomic":`true`,children:nu(t)}),(0,O.jsx)(ru,{data:n,active:s}),(0,O.jsx)(`button`,{type:`button`,className:`voice-pause`,onClick:i,disabled:l,"aria-label":c?`Resume recording`:`Pause recording`,children:c?(0,O.jsx)(_,{size:14}):(0,O.jsx)(g,{size:14})}),(0,O.jsx)(A,{variant:`send`,type:`button`,onClick:o,disabled:l,loading:l,"aria-label":`Send voice note`,children:(0,O.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,O.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,O.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})}var au=[`audio/ogg;codecs=opus`,`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`];function ou(){for(let e of au)if(MediaRecorder.isTypeSupported(e))return e;return``}function su(e){return e.split(`;`)[0]}function cu(){let[e,t]=(0,b.useState)(`idle`),[n,r]=(0,b.useState)(0),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(null),u=(0,b.useRef)([]),d=(0,b.useRef)(``),f=(0,b.useRef)(null),p=(0,b.useRef)(0),m=(0,b.useRef)(0),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(0,b.useRef)(0),v=(0,b.useCallback)(()=>{if(f.current&&=(clearInterval(f.current),null),_.current&&=(cancelAnimationFrame(_.current),0),c.current&&c.current.state!==`inactive`)try{c.current.stop()}catch{}c.current=null,u.current=[],l.current&&=(l.current.getTracks().forEach(e=>e.stop()),null),h.current&&(h.current.close().catch(()=>{}),h.current=null,g.current=null),m.current=0,p.current=0},[]);(0,b.useEffect)(()=>v,[v]);let y=(0,b.useCallback)(()=>{p.current=Date.now(),f.current=setInterval(()=>{let e=Date.now()-p.current,t=m.current+e;r(Math.floor(t/1e3))},200)},[]),x=(0,b.useCallback)(()=>{f.current&&=(clearInterval(f.current),null);let e=Date.now()-p.current;m.current+=e},[]),S=(0,b.useCallback)(()=>{let e=g.current;if(!e)return;let t=new Uint8Array(e.frequencyBinCount),n=()=>{e.getByteTimeDomainData(t),a(new Uint8Array(t)),_.current=requestAnimationFrame(n)};n()},[]),C=(0,b.useCallback)(()=>{_.current&&=(cancelAnimationFrame(_.current),0)},[]),w=(0,b.useCallback)(async()=>{if(!(e!==`idle`&&e!==`error`)){if(s(null),typeof window<`u`&&!window.isSecureContext){t(`error`),s(`Voice recording requires a secure connection (HTTPS). Use your tunnel URL for voice notes.`);return}if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia){t(`error`),s(`Voice recording is not supported in this browser.`);return}if(typeof MediaRecorder>`u`){t(`error`),s(`Voice recording is not supported in this browser.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});l.current=e;let n=new AudioContext;h.current=n;let i=n.createMediaStreamSource(e),o=n.createAnalyser();o.fftSize=256,i.connect(o),g.current=o;let s=ou();d.current=s;let f=new MediaRecorder(e,s?{mimeType:s}:void 0);c.current=f,u.current=[],f.ondataavailable=e=>{e.data.size>0&&u.current.push(e.data)},e.getAudioTracks()[0]?.addEventListener(`ended`,()=>{v(),t(`idle`),r(0),a(null)}),f.start(1e3),t(`recording`),r(0),y(),S()}catch(e){v(),t(`error`),e instanceof DOMException?e.name===`NotAllowedError`?s(`Microphone access was denied. Check your browser permissions to enable voice recording.`):e.name===`NotFoundError`?s(`No microphone found. Connect a microphone to use voice recording.`):s(`Microphone error: ${e.message}`):s(`Could not start recording.`)}}},[e,v,y,S]),T=(0,b.useCallback)(()=>{let n=c.current;n&&(e===`recording`&&n.state===`recording`?(n.pause(),x(),C(),t(`paused`)):e===`paused`&&n.state===`paused`&&(n.resume(),y(),S(),t(`recording`)))},[e,x,y,S,C]),E=(0,b.useCallback)(()=>{e!==`recording`&&e!==`paused`||(v(),t(`idle`),r(0),a(null))},[e,v]),D=(0,b.useCallback)(async()=>{if(e!==`recording`&&e!==`paused`)return null;let n=c.current;if(!n)return null;let i=e===`recording`?Date.now()-p.current:0;return m.current+i<1e3?(E(),null):(t(`sending`),x(),C(),new Promise(e=>{n.onstop=()=>{let i=d.current||n.mimeType||`audio/webm`,o=new Blob(u.current,{type:su(i)});v(),t(`idle`),r(0),a(null),e(o.size>0?o:null)},n.stop()}))},[e,E,x,C,v]);return(0,b.useEffect)(()=>{if(e!==`error`)return;let n=setTimeout(()=>{t(`idle`),s(null)},8e3);return()=>clearTimeout(n)},[e]),{state:e,elapsedSeconds:n,waveform:i,errorMessage:o,start:w,togglePause:T,discard:E,send:D}}export{f as A,S as C,h as D,g as E,u as M,l as N,m as O,c as P,x as S,_ as T,w as _,Ql as a,T as b,Yl as c,Ml as d,Tl as f,k as g,A as h,tu as i,d as j,p as k,Jl as l,yo as m,iu as n,Zl as o,xl as p,eu as r,Xl as s,cu as t,ql as u,D as v,v as w,C as x,E as y};
|
|
36
|
+
`,e]})})}function Al({payload:e,reason:t}){let[n,r]=(0,b.useState)(`idle`);(0,b.useEffect)(()=>{Ol(`device-url:fallback-shown`,{intent:e.intent,reason:t,hostname:e.hostname??``})},[e.intent,e.hostname,t]);let i=async()=>{try{await navigator.clipboard.writeText(e.url),r(`copied`),window.setTimeout(()=>r(`idle`),2e3)}catch(t){r(`failed`),Ol(`device-url:fallback-shown`,{intent:e.intent,reason:`clipboard-api-unavailable`,hostname:e.hostname??``,detail:t instanceof Error?t.message.slice(0,200):String(t).slice(0,200)})}},a=e.hostname?` on the device (${e.hostname})`:` on the device`;return(0,O.jsxs)(`div`,{className:`md-device-url md-device-url-fallback`,role:`group`,children:[(0,O.jsxs)(`div`,{className:`md-device-url-fallback-message`,children:[(0,O.jsx)(y,{size:14}),(0,O.jsxs)(`span`,{children:[`Could not open `,(0,O.jsx)(`strong`,{children:e.intent}),a,` automatically (`,t,`). Copy the URL and open it in a browser on the device:`]})]}),(0,O.jsxs)(`div`,{className:`md-device-url-fallback-url`,children:[(0,O.jsx)(`code`,{children:e.url}),(0,O.jsxs)(`button`,{type:`button`,className:`md-device-url-fallback-copy`,onClick:i,"aria-label":`Copy URL`,children:[n===`copied`?(0,O.jsx)(c,{size:14}):(0,O.jsx)(u,{size:14}),n===`copied`?`Copied`:n===`failed`?`Copy failed`:`Copy`]})]}),n===`failed`&&(0,O.jsx)(`div`,{className:`md-device-url-fallback-copy-failed`,children:`Your browser blocked the copy action. Select the URL text above manually to copy it.`})]})}function jl({payload:e}){let t=El(),[n,r]=(0,b.useState)({phase:`idle`});(0,b.useEffect)(()=>{Ol(`device-url:render`,{intent:e.intent,url:e.url,hostname:e.hostname??``,origin:`tool`})},[e.intent,e.url,e.hostname]);let i=async()=>{if(n.phase!==`navigating`){r({phase:`navigating`});try{let n=await fetch(`/api/admin/device-browser/navigate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),i=await n.json().catch(()=>({}));if(n.ok&&i.ok){r({phase:`succeeded`}),t&&(t.onShowVnc(),Ol(`device-url:vnc-surface-shown`,{intent:e.intent})),window.setTimeout(()=>r({phase:`idle`}),2500);return}r({phase:`fallback`,reason:i.navigateResult?Dl[i.navigateResult]:i.detail?i.detail.slice(0,80):`navigation failed`})}catch(e){r({phase:`fallback`,reason:(e instanceof Error?e.message:String(e)).slice(0,80)})}}},a=n.phase===`navigating`,o=n.phase===`succeeded`;return(0,O.jsxs)(`div`,{className:`md-device-url`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`md-device-url-button`,onClick:i,disabled:a,"aria-label":`Open ${e.intent} on the device's browser`,title:e.hostname?`Opens on device: ${e.hostname}`:`Opens on the device running Maxy`,children:[(0,O.jsx)(p,{size:16,className:`md-device-url-icon`}),(0,O.jsx)(`span`,{className:`md-device-url-label`,children:a?`Opening…`:o?`Opened on device`:`Open ${e.intent} on device`})]}),n.phase===`fallback`&&(0,O.jsx)(Al,{payload:e,reason:n.reason})]})}function Ml({source:e}){let t=Cl(e.trim());return t.ok?(0,O.jsx)(jl,{payload:t.payload}):(0,O.jsx)(kl,{raw:e,reason:t.reason})}var Nl=null;function Pl(){return Nl||=s(async()=>{let{default:e}=await import(`./mermaid.core-CCUSwZB_.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({default:e})=>(e.initialize({startOnLoad:!1,theme:`neutral`}),e)),Nl}function Fl({source:e}){let t=(0,b.useRef)(null),[n,r]=(0,b.useState)(null);return(0,b.useEffect)(()=>{let n=!1,i=`mermaid-${Math.random().toString(36).slice(2,9)}`;return Pl().then(t=>t.render(i,e)).then(({svg:e})=>{!n&&t.current&&(t.current.innerHTML=e)}).catch(t=>{n||(console.error(`[MermaidBlock] render failed:`,e,t),r(t instanceof Error?t.message:`Diagram render failed`))}),()=>{n=!0}},[e]),n?(0,O.jsxs)(`div`,{className:`md-mermaid md-mermaid-error`,children:[(0,O.jsx)(`div`,{className:`md-mermaid-error-label`,children:`Diagram render error`}),(0,O.jsx)(`pre`,{className:`md-pre`,children:(0,O.jsx)(`code`,{className:`md-code`,children:e})})]}):(0,O.jsx)(`div`,{className:`md-mermaid`,ref:t})}var Il=/\.(mp4|webm|mov)(\?.*)?$/i,Ll=/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/,Rl=/vimeo\.com\/(\d+)/;function zl(e){return!!e&&Il.test(e)}function Bl(e){if(!e)return null;let t=e.match(Ll);return t?t[1]:null}function Vl(e){if(!e)return null;let t=e.match(Rl);return t?t[1]:null}function Hl({src:e}){return(0,O.jsx)(`video`,{className:`md-video`,controls:!0,playsInline:!0,preload:`metadata`,children:(0,O.jsx)(`source`,{src:e})})}function Ul({videoId:e}){return(0,O.jsx)(`div`,{className:`md-video-iframe`,children:(0,O.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${e}`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function Wl({videoId:e}){return(0,O.jsx)(`div`,{className:`md-video-iframe`,children:(0,O.jsx)(`iframe`,{src:`https://player.vimeo.com/video/${e}`,allow:`autoplay; fullscreen; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function Gl(e){if(zl(e))return(0,O.jsx)(Hl,{src:e});let t=Bl(e);if(t)return(0,O.jsx)(Ul,{videoId:t});let n=Vl(e);return n?(0,O.jsx)(Wl,{videoId:n}):null}var Kl={p:({children:e})=>(0,O.jsx)(`p`,{className:`md-p`,children:e}),h1:({children:e})=>(0,O.jsx)(`h1`,{className:`md-heading`,children:e}),h2:({children:e})=>(0,O.jsx)(`h2`,{className:`md-heading`,children:e}),h3:({children:e})=>(0,O.jsx)(`h3`,{className:`md-heading`,children:e}),code:({children:e,className:t})=>t===`language-mermaid`?(0,O.jsx)(Fl,{source:String(e).replace(/\n$/,``)}):t===`language-maxy-device-url`?(0,O.jsx)(Ml,{source:String(e).replace(/\n$/,``)}):(0,O.jsx)(`code`,{className:`md-code ${t||``}`.trim(),children:e}),pre:({children:e,node:t})=>{let n=t?.children?.[0];if(n?.type===`element`&&n.tagName===`code`){let t=n.properties?.className??[];if(t.includes(`language-mermaid`)||t.includes(`language-maxy-device-url`))return(0,O.jsx)(O.Fragment,{children:e})}return(0,O.jsx)(`pre`,{className:`md-pre`,children:e})},ul:({children:e})=>(0,O.jsx)(`ul`,{className:`md-list`,children:e}),ol:({children:e})=>(0,O.jsx)(`ol`,{className:`md-list md-list-ordered`,children:e}),li:({children:e})=>(0,O.jsx)(`li`,{className:`md-list-item`,children:e}),hr:()=>(0,O.jsx)(`hr`,{className:`md-hr`}),strong:({children:e})=>(0,O.jsx)(`strong`,{className:`md-strong`,children:e}),img:({src:e,alt:t})=>Gl(e)||(0,O.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:(0,O.jsx)(`img`,{className:`md-img`,src:e,alt:t||``,loading:`lazy`})}),a:({href:e,children:t})=>Gl(e)||(0,O.jsx)(`a`,{href:e,className:`md-link`,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({children:e})=>(0,O.jsx)(`table`,{className:`md-table`,children:e}),thead:({children:e})=>(0,O.jsx)(`thead`,{className:`md-thead`,children:e}),tbody:({children:e})=>(0,O.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,O.jsx)(`tr`,{className:`md-tr`,children:e}),th:({children:e})=>(0,O.jsx)(`th`,{className:`md-th`,children:e}),td:({children:e})=>(0,O.jsx)(`td`,{className:`md-td`,children:e})};function ql({content:e,elapsedSeconds:t,timestamp:n}){return(0,O.jsxs)(`div`,{className:`markdown-message`,children:[(0,O.jsx)(yo,{remarkPlugins:[xl],components:Kl,children:e}),t!==void 0&&(0,O.jsxs)(`div`,{className:`message-meta`,children:[t,`s`]}),n&&(0,O.jsx)(`span`,{className:`message-timestamp`,children:n})]})}function Jl({submitted:e,submittedLabel:t=`Submitted`,actions:n,children:r}){return(0,O.jsxs)(`div`,{className:`component-card${e?` component-card--submitted`:``}`,children:[r,(0,O.jsx)(`div`,{className:`component-card__actions`,children:e?(0,O.jsx)(`span`,{className:`component-card__done-label`,children:t}):n.map((e,t)=>(0,O.jsx)(A,{variant:e.variant,size:`sm`,disabled:e.disabled,onClick:e.onClick,children:e.label},t))})]})}function Yl({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.options)?r.options:[],[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(`Submitted`);if(i.length===0)return null;let l=e=>{n||o(e)},u=()=>{if(!a||n)return;let e=i.find(e=>e.value===a);c(e?.label??`Submitted`),t((r?.submitMessage??`Selected: {{value}}`).replace(`{{value}}`,a).replace(`{{label}}`,e?.label??a))},d=()=>{n||(c(r?.backLabel??`Back`),t(r?.backMessage??``))},f=(e,t)=>{if(!n)if(e.key===`ArrowDown`||e.key===`ArrowRight`){e.preventDefault();let n=(t+1)%i.length;l(i[n].value),(e.currentTarget.parentElement?.children[n])?.focus()}else if(e.key===`ArrowUp`||e.key===`ArrowLeft`){e.preventDefault();let n=(t-1+i.length)%i.length;l(i[n].value),(e.currentTarget.parentElement?.children[n])?.focus()}else (e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(i[t].value))};return(0,O.jsx)(Jl,{submitted:n,submittedLabel:s,actions:[...r?.backLabel&&r?.backMessage?[{label:r.backLabel,variant:`ghost`,onClick:d}]:[],{label:r?.submitLabel??`Confirm`,variant:`primary`,disabled:!a,onClick:u}],children:(0,O.jsxs)(`div`,{className:`single-select`,role:`radiogroup`,"aria-label":r?.title??`Select one`,children:[r?.title&&(0,O.jsx)(`div`,{className:`single-select__title`,children:r.title}),i.map((e,t)=>(0,O.jsxs)(`div`,{className:`single-select__row${a===e.value?` single-select__row--selected`:``}`,role:`radio`,"aria-checked":a===e.value,tabIndex:a===e.value||!a&&t===0?0:-1,onClick:()=>l(e.value),onKeyDown:e=>f(e,t),children:[(0,O.jsx)(`span`,{className:`single-select__radio${a===e.value?` single-select__radio--checked`:``}`}),(0,O.jsxs)(`div`,{className:`single-select__info`,children:[(0,O.jsxs)(`span`,{className:`single-select__label`,children:[e.icon&&(0,O.jsx)(`span`,{className:`single-select__icon`,children:e.icon}),e.label]}),e.description&&(0,O.jsx)(`span`,{className:`single-select__desc`,children:e.description})]})]},e.value))]})})}function Xl({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.options)?r.options:[],[a,o]=(0,b.useState)(i.map(e=>!!e.locked||!!e.defaultSelected)),[s,c]=(0,b.useState)(`Submitted`);if(i.length===0)return null;let l=i.some(e=>e.locked),u=i.every((e,t)=>e.locked||a[t]),d=e=>{n||i[e].locked||o(t=>t.map((t,n)=>n===e?!t:t))},f=()=>{n||o(i.map((e,t)=>e.locked?a[t]:!u))},p=i.filter((e,t)=>!e.locked&&a[t]).map(e=>e.value),m=p.length>0||l,h=()=>{if(!(!m||n)){if(c(`Submitted`),p.length===0){t(`No optional plugins selected`);return}t((r?.submitMessage??`Selected: {{values}}`).replace(`{{values}}`,p.join(`, `)))}},g=()=>{n||(c(`Skipped`),t(r?.skipMessage??`Skipped`))},_=()=>{n||(c(r?.backLabel??`Back`),t(r?.backMessage??``))},v=[];return r?.backLabel&&r?.backMessage&&v.push({label:r.backLabel,variant:`ghost`,onClick:_}),r?.skipLabel&&v.push({label:r.skipLabel,variant:`ghost`,onClick:g}),v.push({label:r?.submitLabel??`Confirm`,variant:`primary`,disabled:!m,onClick:h}),(0,O.jsx)(Jl,{submitted:n,submittedLabel:s,actions:v,children:(0,O.jsxs)(`div`,{className:`multi-select`,children:[r?.title&&(0,O.jsx)(`div`,{className:`multi-select__title`,children:r.title}),r?.selectAll&&(0,O.jsx)(`div`,{className:`multi-select__header`,children:(0,O.jsx)(k,{checked:u,onChange:f,label:`Select all`,disabled:n})}),(0,O.jsx)(`div`,{className:`multi-select__list`,role:`group`,"aria-label":r?.title??`Select options`,children:i.map((e,t)=>{let r=e.group&&(t===0||e.group!==i[t-1].group),o=!!e.locked;return(0,O.jsxs)(b.Fragment,{children:[r&&(0,O.jsx)(`div`,{className:`multi-select__group-header`,children:e.group}),(0,O.jsxs)(`div`,{className:`multi-select__row${o?` multi-select__row--locked`:``}`,role:`checkbox`,"aria-checked":a[t],"aria-disabled":o||void 0,tabIndex:o?-1:0,onClick:()=>d(t),onKeyDown:e=>{n||o||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t))},children:[(0,O.jsx)(k,{checked:a[t],onChange:()=>d(t),disabled:n||o}),(0,O.jsxs)(`div`,{className:`multi-select__info`,children:[(0,O.jsxs)(`span`,{className:`multi-select__label`,children:[e.label,e.badge&&(0,O.jsx)(`span`,{className:`multi-select__badge`,children:e.badge})]}),e.description&&(0,O.jsx)(`span`,{className:`multi-select__desc`,children:e.description})]})]})]},e.value)})})]})})}function Zl({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.buttons)?r.buttons:[],[a,o]=(0,b.useState)(`Submitted`);if(i.length===0)return null;let s=e=>{n||(o(e.label),t(e.value))};return(0,O.jsx)(Jl,{submitted:n,submittedLabel:a,actions:i.map(e=>({label:e.label,variant:`primary`,onClick:()=>s(e)})),children:(0,O.jsx)(O.Fragment,{})})}function Ql(e){let t=new Date(e),n=new Date,r=String(t.getHours()).padStart(2,`0`),i=String(t.getMinutes()).padStart(2,`0`);return t.toDateString()===n.toDateString()?`${r}:${i}`:`${String(t.getDate()).padStart(2,`0`)}-${String(t.getMonth()+1).padStart(2,`0`)}-${t.getFullYear()} ${r}:${i}`}var $l=44,eu=(0,b.forwardRef)(function({value:e,onChange:t,placeholder:n,disabled:r},i){let a=(0,b.useRef)(null),o=(0,b.useRef)(!1),s=(0,b.useCallback)((e,t)=>{let n=e.closest(`.chat-form`);n&&(n.dataset.expanded=t>$l?`true`:``)},[]),c=(0,b.useCallback)(e=>{if(o.current)return;let t=window.innerHeight*.75;e.style.height=`auto`;let n=Math.min(e.scrollHeight,t);e.style.height=`${n}px`,e.style.overflowY=e.scrollHeight>t?`auto`:`hidden`,s(e,n)},[s]);return(0,b.useImperativeHandle)(i,()=>({focus(){a.current?.focus()},resetHeight(){if(!a.current)return;o.current=!1,a.current.style.height=``,a.current.style.overflowY=``;let e=a.current.closest(`.chat-form`);e&&(e.dataset.expanded=``)},getOffsetHeight(){return a.current?.offsetHeight??36},setHeight(e){a.current&&(o.current=!0,a.current.style.height=`${e}px`,s(a.current,e))}})),(0,O.jsx)(`textarea`,{ref:a,className:`chat-input`,rows:1,value:e,onChange:e=>{t(e.target.value),c(e.target)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.closest(`form`)?.requestSubmit())},placeholder:n,disabled:r,"aria-label":n||`Type a message...`})});function tu({inputRef:e}){let t=(0,b.useRef)(null);function n(n){e.current&&(n.preventDefault(),n.target.setPointerCapture(n.pointerId),t.current={startY:n.clientY,startH:e.current.getOffsetHeight()})}function r(n){if(!t.current||!e.current)return;let r=t.current.startY-n.clientY,i=window.innerHeight*.75,a=Math.max(36,Math.min(i,t.current.startH+r));e.current.setHeight(a)}function i(){t.current=null}return(0,O.jsx)(`div`,{className:`chat-resize-handle`,onPointerDown:n,onPointerMove:r,onPointerUp:i,"aria-label":`Resize input`,children:(0,O.jsx)(`div`,{className:`chat-resize-handle-bar`})})}function nu(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function ru({data:e,active:t}){let n=[];if(e&&e.length>0&&t){let t=Math.floor(e.length/24);for(let r=0;r<24;r++){let i=e[r*t]??128,a=Math.abs(i-128)/128;n.push(Math.max(.15,a))}}else for(let e=0;e<24;e++)n.push(.15);return(0,O.jsx)(`div`,{className:`voice-waveform`,"aria-hidden":`true`,children:n.map((e,t)=>(0,O.jsx)(`div`,{className:`voice-waveform-bar`,style:{height:`${Math.round(e*100)}%`}},t))})}function iu({state:e,elapsedSeconds:t,waveform:n,onTogglePause:i,onDiscard:a,onSend:o}){if(e===`idle`||e===`error`)return null;let s=e===`recording`,c=e===`paused`,l=e===`sending`;return(0,O.jsxs)(`div`,{className:`voice-recorder`,role:`region`,"aria-label":`Voice recording`,"aria-live":`polite`,children:[(0,O.jsx)(`button`,{type:`button`,className:`voice-trash`,onClick:a,disabled:l,"aria-label":`Discard recording`,children:(0,O.jsx)(r,{size:16})}),(0,O.jsx)(`span`,{className:`voice-timer`,"aria-live":`polite`,"aria-atomic":`true`,children:nu(t)}),(0,O.jsx)(ru,{data:n,active:s}),(0,O.jsx)(`button`,{type:`button`,className:`voice-pause`,onClick:i,disabled:l,"aria-label":c?`Resume recording`:`Pause recording`,children:c?(0,O.jsx)(_,{size:14}):(0,O.jsx)(g,{size:14})}),(0,O.jsx)(A,{variant:`send`,type:`button`,onClick:o,disabled:l,loading:l,"aria-label":`Send voice note`,children:(0,O.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,O.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,O.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})}var au=[`audio/ogg;codecs=opus`,`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`];function ou(){for(let e of au)if(MediaRecorder.isTypeSupported(e))return e;return``}function su(e){return e.split(`;`)[0]}function cu(){let[e,t]=(0,b.useState)(`idle`),[n,r]=(0,b.useState)(0),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(null),u=(0,b.useRef)([]),d=(0,b.useRef)(``),f=(0,b.useRef)(null),p=(0,b.useRef)(0),m=(0,b.useRef)(0),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(0,b.useRef)(0),v=(0,b.useCallback)(()=>{if(f.current&&=(clearInterval(f.current),null),_.current&&=(cancelAnimationFrame(_.current),0),c.current&&c.current.state!==`inactive`)try{c.current.stop()}catch{}c.current=null,u.current=[],l.current&&=(l.current.getTracks().forEach(e=>e.stop()),null),h.current&&(h.current.close().catch(()=>{}),h.current=null,g.current=null),m.current=0,p.current=0},[]);(0,b.useEffect)(()=>v,[v]);let y=(0,b.useCallback)(()=>{p.current=Date.now(),f.current=setInterval(()=>{let e=Date.now()-p.current,t=m.current+e;r(Math.floor(t/1e3))},200)},[]),x=(0,b.useCallback)(()=>{f.current&&=(clearInterval(f.current),null);let e=Date.now()-p.current;m.current+=e},[]),S=(0,b.useCallback)(()=>{let e=g.current;if(!e)return;let t=new Uint8Array(e.frequencyBinCount),n=()=>{e.getByteTimeDomainData(t),a(new Uint8Array(t)),_.current=requestAnimationFrame(n)};n()},[]),C=(0,b.useCallback)(()=>{_.current&&=(cancelAnimationFrame(_.current),0)},[]),w=(0,b.useCallback)(async()=>{if(!(e!==`idle`&&e!==`error`)){if(s(null),typeof window<`u`&&!window.isSecureContext){t(`error`),s(`Voice recording requires a secure connection (HTTPS). Use your tunnel URL for voice notes.`);return}if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia){t(`error`),s(`Voice recording is not supported in this browser.`);return}if(typeof MediaRecorder>`u`){t(`error`),s(`Voice recording is not supported in this browser.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});l.current=e;let n=new AudioContext;h.current=n;let i=n.createMediaStreamSource(e),o=n.createAnalyser();o.fftSize=256,i.connect(o),g.current=o;let s=ou();d.current=s;let f=new MediaRecorder(e,s?{mimeType:s}:void 0);c.current=f,u.current=[],f.ondataavailable=e=>{e.data.size>0&&u.current.push(e.data)},e.getAudioTracks()[0]?.addEventListener(`ended`,()=>{v(),t(`idle`),r(0),a(null)}),f.start(1e3),t(`recording`),r(0),y(),S()}catch(e){v(),t(`error`),e instanceof DOMException?e.name===`NotAllowedError`?s(`Microphone access was denied. Check your browser permissions to enable voice recording.`):e.name===`NotFoundError`?s(`No microphone found. Connect a microphone to use voice recording.`):s(`Microphone error: ${e.message}`):s(`Could not start recording.`)}}},[e,v,y,S]),T=(0,b.useCallback)(()=>{let n=c.current;n&&(e===`recording`&&n.state===`recording`?(n.pause(),x(),C(),t(`paused`)):e===`paused`&&n.state===`paused`&&(n.resume(),y(),S(),t(`recording`)))},[e,x,y,S,C]),E=(0,b.useCallback)(()=>{e!==`recording`&&e!==`paused`||(v(),t(`idle`),r(0),a(null))},[e,v]),D=(0,b.useCallback)(async()=>{if(e!==`recording`&&e!==`paused`)return null;let n=c.current;if(!n)return null;let i=e===`recording`?Date.now()-p.current:0;return m.current+i<1e3?(E(),null):(t(`sending`),x(),C(),new Promise(e=>{n.onstop=()=>{let i=d.current||n.mimeType||`audio/webm`,o=new Blob(u.current,{type:su(i)});v(),t(`idle`),r(0),a(null),e(o.size>0?o:null)},n.stop()}))},[e,E,x,C,v]);return(0,b.useEffect)(()=>{if(e!==`error`)return;let n=setTimeout(()=>{t(`idle`),s(null)},8e3);return()=>clearTimeout(n)},[e]),{state:e,elapsedSeconds:n,waveform:i,errorMessage:o,start:w,togglePause:T,discard:E,send:D}}export{p as A,S as C,g as D,_ as E,c as F,d as M,u as N,h as O,l as P,x as S,v as T,w as _,Ql as a,T as b,Yl as c,Ml as d,Tl as f,k as g,A as h,tu as i,f as j,m as k,Jl as l,yo as m,iu as n,Zl as o,xl as p,eu as r,Xl as s,cu as t,ql as u,D as v,y as w,C as x,E as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./jsx-runtime-
|
|
1
|
+
import{r as e}from"./jsx-runtime-CHqDsKlc.js";var t=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),n=e(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t as n,n as t};
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Data — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/data-
|
|
8
|
+
<script type="module" crossorigin src="/assets/data-BZ7v-zug.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/share-2-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/file-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/house-
|
|
14
|
-
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-CHqDsKlc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/share-2-Ev-D4Lm9.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/file-CScYkZq5.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/house-CdFRNujU.js">
|
|
14
|
+
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Og0q7dXg.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Graph — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/graph-
|
|
8
|
+
<script type="module" crossorigin src="/assets/graph-tjXdtwk-.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/share-2-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/house-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/x-
|
|
14
|
-
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-CHqDsKlc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/share-2-Ev-D4Lm9.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/house-CdFRNujU.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/x-D5W7ddgP.js">
|
|
14
|
+
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Og0q7dXg.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|
|
@@ -5,16 +5,15 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/admin-
|
|
8
|
+
<script type="module" crossorigin src="/assets/admin-BqLtaMVu.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-CHqDsKlc.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/share-2-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/file-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/assets/x-
|
|
16
|
-
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-
|
|
17
|
-
<link rel="stylesheet" crossorigin href="/assets/admin-kHJ-D0s7.css">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-DyDXH7EA.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/share-2-Ev-D4Lm9.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/file-CScYkZq5.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/x-D5W7ddgP.js">
|
|
16
|
+
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Og0q7dXg.css">
|
|
18
17
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
19
18
|
</head>
|
|
20
19
|
<body>
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/public-
|
|
8
|
+
<script type="module" crossorigin src="/assets/public-CrkQJek6.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-CHqDsKlc.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-DyDXH7EA.js">
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Og0q7dXg.css">
|
|
14
14
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|