lua-ai-chat 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var react=require('react'),luaniverse=require('@lua-ai-global/luaniverse'),jsxRuntime=require('react/jsx-runtime'),reactVisuallyHidden=require('@radix-ui/react-visually-hidden'),St=require('react-markdown'),prismReactRenderer=require('prism-react-renderer'),reactLeaflet=require('react-leaflet');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var St__default=/*#__PURE__*/_interopDefault(St);function $l({onAudioRecorded:t,onClose:e,inputMessage:a}){let[l,r]=react.useState(false),[s,d]=react.useState(0),[u,n]=react.useState([]),[p,f]=react.useState(null),[o,i]=react.useState(null),h=react.useRef(null),c=react.useRef(null),v=react.useRef([]),g=react.useRef(null),C=react.useRef(null),x=react.useRef(null),N=react.useRef(null),m=react.useRef(false),w=react.useRef(false),U=react.useRef(null);react.useEffect(()=>{if(!l||!p)return;let P=setInterval(()=>{let k=Math.floor((Date.now()-p)/1e3);d(k);},1e3);return ()=>clearInterval(P)},[l,p]),react.useEffect(()=>((async()=>{if(!(m.current||w.current))try{m.current=!0;let k=await navigator.mediaDevices.getUserMedia({audio:!0});h.current=k,g.current=new AudioContext,C.current=g.current.createAnalyser(),C.current.fftSize=256,g.current.createMediaStreamSource(k).connect(C.current),x.current=new Uint8Array(C.current.frequencyBinCount);let q=()=>{if(!C.current||!x.current)return;C.current.getByteFrequencyData(x.current);let Wt=Array.from(x.current).map(Xt=>Xt/255);n(Wt),N.current=requestAnimationFrame(q);};q(),_t();}catch(k){console.error("Error accessing microphone:",k),e();}finally{m.current=false;}})(),()=>{B();}),[]);let B=()=>{if(!w.current)try{if(w.current=!0,l&&c.current&&(c.current.stop(),r(!1),f(null)),h.current){let P=h.current.getAudioTracks(),k=h.current.getVideoTracks();P.forEach(A=>{A.stop(),A.enabled=!1;}),k.forEach(A=>{A.stop(),A.enabled=!1;});}N.current&&cancelAnimationFrame(N.current),g.current&&g.current.close(),h.current=null,c.current=null,v.current=[],g.current=null,C.current=null,x.current=null,N.current=null;}finally{w.current=false;}},_t=()=>{if(!h.current)return;let k=["audio/webm","audio/mp4","audio/ogg","audio/wav"].find(q=>MediaRecorder.isTypeSupported(q));if(!k){console.error("No supported MIME type found for MediaRecorder"),e();return}U.current=k;let A=new MediaRecorder(h.current,{mimeType:k});c.current=A,v.current=[],A.ondataavailable=q=>{q.data.size>0&&v.current.push(q.data);},A.start(),r(true),f(Date.now()),d(0);},jt=async()=>{if(!c.current||!h.current)return;r(false),i(s),f(null),c.current.stop(),await new Promise(k=>{c.current&&(c.current.onstop=()=>k());});let P=new Blob(v.current,{type:U.current||"audio/webm"});t(P,a),B(),e();},mt=P=>{let k=Math.floor(P/60),A=P%60;return `${k.toString().padStart(2,"0")}:${A.toString().padStart(2,"0")}`};return jsxRuntime.jsxs("div",{className:"audio-recorder-container lua:bg-gray-100 lua:rounded-lg lua:p-2 lua:flex lua:items-center lua:gap-4",children:[jsxRuntime.jsx(luaniverse.IconButton,{variant:"muted",onClick:async()=>{B(),e();},className:"audio-recorder-close-button lua:flex-shrink-0",children:jsxRuntime.jsx(luaniverse.XIcon,{className:"audio-recorder-close-icon",color:"#00000099"})}),jsxRuntime.jsxs("div",{className:"audio-recorder-status lua:flex lua:items-center lua:gap-2",children:[jsxRuntime.jsx("div",{className:`audio-recorder-indicator lua:w-3 lua:h-3 lua:rounded-full ${l?"lua:bg-red-500 lua:animate-pulse":"lua:bg-gray-400"}`}),jsxRuntime.jsx("span",{className:"audio-recorder-time lua:text-gray-700 lua:text-sm",children:mt(l?s:o||0)})]}),jsxRuntime.jsx("div",{className:"audio-recorder-visualizer lua:flex-1","data-testid":"audio-visualizer-bar",children:u.length>0&&jsxRuntime.jsx("div",{className:"audio-recorder-bars lua:h-8 lua:flex lua:items-center lua:w-full lua:gap-px sm:lua:gap-0.5 md:lua:gap-1",children:u.slice(0,50).map((P,k)=>jsxRuntime.jsx("div",{className:"audio-recorder-bar lua:flex-1 lua:bg-blue-500",style:{height:`${P*100}%`}},k))})}),jsxRuntime.jsx(luaniverse.IconButton,{onClick:jt,className:"audio-recorder-send-button lua:flex-shrink-0 lua:mr-1","data-testid":"send-audio-button",children:jsxRuntime.jsx(luaniverse.ArrowUp,{className:"audio-recorder-send-icon",color:"white"})})]})}function aa(t){let e=Math.floor(t/60),a=t%60;return `${e.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function Xl({videoRef:t,isRecording:e,recordingTime:a,loading:l,onStartRecording:r,onStopRecording:s,onClose:d,open:u}){return jsxRuntime.jsx(luaniverse.Dialog,{open:u,onOpenChange:d,children:jsxRuntime.jsxs(luaniverse.DialogContent,{className:"lua:w-full lua:max-w-2xl lua:p-2.5",showClose:false,children:[jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden,{children:jsxRuntime.jsx(luaniverse.DialogTitle,{})}),jsxRuntime.jsxs("div",{className:"lua:relative lua:aspect-[4/3] lua:bg-black lua:rounded-xl lua:overflow-hidden lua:mb-8",children:[jsxRuntime.jsx("video",{ref:t,autoPlay:true,playsInline:true,muted:true,className:"lua:absolute lua:inset-0 lua:w-full lua:h-full lua:object-cover",style:{backgroundColor:"black"}}),e&&jsxRuntime.jsxs("div",{className:"lua:absolute lua:top-4 lua:left-4 lua:flex lua:items-center lua:gap-2 lua:bg-black lua:bg-opacity-50 lua:px-3 lua:py-1 lua:rounded-full",children:[jsxRuntime.jsx("div",{className:"lua:w-2 lua:h-2 lua:rounded-full lua:bg-red-500 lua:animate-pulse"}),jsxRuntime.jsx("span",{className:"lua:text-sm lua:font-medium lua:text-white",children:aa(a)})]})]}),jsxRuntime.jsx("div",{className:"lua:flex lua:justify-center lua:items-center lua:gap-5 lua:mb-2.5",children:e?jsxRuntime.jsx(luaniverse.IconButton,{"data-testid":"stop-recording-button",onClick:s,disabled:l,variant:"secondary",children:jsxRuntime.jsx(luaniverse.XIcon,{color:"#000000"})}):jsxRuntime.jsxs("svg",{onClick:r,"data-testid":"start-recording-button",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"cursor-pointer",children:[jsxRuntime.jsx("rect",{x:"2",y:"2",width:"36",height:"36",rx:"18",stroke:"#FF0342",strokeWidth:"4"}),jsxRuntime.jsx("rect",{x:"6",y:"6",width:"28",height:"28",rx:"14",fill:"#FF0342"})]})})]})})}function vt({url:t,alt:e,open:a,onClose:l}){return jsxRuntime.jsxs(luaniverse.Dialog,{open:a,onOpenChange:l,children:[jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden,{children:jsxRuntime.jsx(luaniverse.DialogTitle,{})}),jsxRuntime.jsx(luaniverse.DialogContent,{className:"lua:w-full lua:fixed lua:inset-0 lua:h-full lua:max-w-none lua:p-0 lua:bg-transparent lua:shadow-none lua:translate-x-0 lua:translate-y-0 lua:m-0 lua:rounded-none",showClose:false,children:jsxRuntime.jsxs("div",{className:"lua:relative lua:w-full lua:h-full",children:[jsxRuntime.jsx("button",{onClick:l,className:"lua:cursor-pointer lua:absolute lua:top-4 lua:left-4 lua:z-10 lua:p-2 lua:bg-black/50 lua:rounded-full lua:hover:bg-black/70 lua:transition-colors",children:jsxRuntime.jsx(luaniverse.XIcon,{color:"white",className:"lua:w-6 lua:h-6"})}),jsxRuntime.jsx("div",{className:"lua:w-full lua:h-full lua:flex lua:items-center lua:justify-center",children:jsxRuntime.jsx("img",{src:t,alt:e,className:"sm:lua:aspect-[16/9] lua:object-contain lua:rounded-none sm:lua:rounded-lg"})})]})})]})}function yt({images:t,initialIndex:e=0,open:a,onClose:l}){let[r,s]=react.useState(),[d,u]=react.useState(0);return react.useEffect(()=>{if(!r)return;e>0&&e<t.length&&(r.scrollTo(e),u(e));let n=()=>{u(r.selectedScrollSnap());};return r.on("select",n),n(),()=>{r?.off("select",n);}},[r,e,t.length]),jsxRuntime.jsxs(luaniverse.Dialog,{open:a,onOpenChange:l,children:[jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden,{children:jsxRuntime.jsx(luaniverse.DialogTitle,{})}),jsxRuntime.jsx(luaniverse.DialogContent,{className:"lua:w-full lua:m-0",showClose:false,children:jsxRuntime.jsxs("div",{className:"lua:relative lua:w-full lua:h-full",children:[jsxRuntime.jsx("button",{onClick:l,className:"lua:cursor-pointer lua:absolute lua:top-4 lua:left-4 lua:z-10 lua:p-2 lua:bg-black/50 lua:rounded-full lua:hover:bg-black/70 lua:transition-colors",children:jsxRuntime.jsx(luaniverse.XIcon,{color:"white",className:"lua:w-6 lua:h-6"})}),t.length>1&&jsxRuntime.jsxs("div",{className:"lua:absolute lua:top-4 lua:right-4 lua:z-10 lua:px-3 lua:py-1 lua:bg-black/50 lua:rounded-full lua:text-white lua:text-sm",children:[d+1," / ",t.length]}),jsxRuntime.jsx("div",{className:"lua:w-full lua:h-full lua:flex lua:items-center lua:justify-center lua:px-16",children:jsxRuntime.jsxs(luaniverse.Carousel,{setApi:s,className:"lua:w-full lua:max-w-5xl",opts:{align:"center",loop:t.length>1},children:[jsxRuntime.jsx(luaniverse.CarouselContent,{children:t.map((n,p)=>jsxRuntime.jsx(luaniverse.CarouselItem,{className:"lua:flex lua:items-center lua:justify-center",children:jsxRuntime.jsx("img",{src:n.src,alt:n.alt||`Image ${p+1}`,className:"lua:max-w-full lua:max-h-screen lua:object-contain lua:rounded-none sm:lua:rounded-lg",draggable:false})},p))}),t.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(luaniverse.CarouselPrevious,{className:"lua:left-4 lua:bg-black/50 lua:border-none lua:text-white lua:hover:bg-black/70 lua:hover:text-white-white/70"}),jsxRuntime.jsx(luaniverse.CarouselNext,{className:"lua:right-4 lua:bg-black/50 lua:border-none lua:text-white lua:hover:bg-black/70 lua:hover:text-white-white/70"})]})]})})]})})]})}function ir({videoRef:t,canvasRef:e,onCapture:a,onClose:l,open:r}){return jsxRuntime.jsxs(luaniverse.Dialog,{open:r,onOpenChange:l,children:[jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden,{children:jsxRuntime.jsx(luaniverse.DialogTitle,{})}),jsxRuntime.jsxs(luaniverse.DialogContent,{className:"lua:w-full lua:max-w-2xl lua:p-2.5",showClose:false,children:[jsxRuntime.jsxs("div",{className:"lua:relative lua:aspect-[16/9] lua:bg-black lua:rounded-xl lua:overflow-hidden",children:[jsxRuntime.jsx("video",{ref:t,autoPlay:true,playsInline:true,muted:true,className:"lua:absolute lua:inset-0 lua:w-full lua:h-full lua:object-cover",style:{backgroundColor:"black"}}),jsxRuntime.jsx("canvas",{ref:e,className:"lua:hidden"})]}),jsxRuntime.jsxs("div",{className:"lua:flex lua:justify-center lua:items-center lua:gap-5 lua:mb-2.5 lua:mt-6",children:[jsxRuntime.jsx(luaniverse.IconButton,{onClick:a,"data-testid":"capture-button",children:jsxRuntime.jsx(luaniverse.Camera,{color:"#FFFFFF"})}),jsxRuntime.jsx(luaniverse.IconButton,{onClick:l,variant:"secondary",children:jsxRuntime.jsx(luaniverse.XIcon,{color:"#000000"})})]})]})]})}function cr({locationError:t,currentLocation:e,loading:a,onShare:l,onClose:r}){return jsxRuntime.jsx("div",{className:"lua:fixed lua:inset-0 lua:bg-black lua:bg-opacity-75 lua:flex lua:items-center lua:justify-center lua:z-50",children:jsxRuntime.jsxs("div",{className:"lua:bg-white lua:rounded-lg lua:p-4 lua:max-w-2xl lua:w-full lua:mx-4",children:[jsxRuntime.jsxs("div",{className:"lua:flex lua:justify-between lua:items-center lua:mb-4",children:[jsxRuntime.jsx("h3",{className:"lua:text-lg lua:font-semibold",children:"Share Location"}),jsxRuntime.jsx("button",{onClick:r,className:"lua:text-gray-500 lua:hover:text-gray-700",children:jsxRuntime.jsx("svg",{className:"lua:w-6 lua:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t?jsxRuntime.jsx("div",{className:"lua:bg-red-50 lua:text-red-500 lua:p-4 lua:rounded-lg lua:mb-4",children:t}):e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"lua:mb-4",children:[jsxRuntime.jsx("div",{className:"lua:text-sm lua:text-gray-500 lua:mb-2",children:"Current Location:"}),jsxRuntime.jsx("div",{className:"lua:text-gray-700 lua:mb-2",children:e.address}),jsxRuntime.jsxs("div",{className:"lua:text-sm lua:text-gray-500",children:[e.latitude.toFixed(6),","," ",e.longitude.toFixed(6)]})]})}):jsxRuntime.jsx("div",{className:"lua:flex lua:justify-center lua:items-center lua:h-48",children:jsxRuntime.jsx("div",{className:"lua:animate-spin lua:rounded-full lua:h-8 lua:w-8 lua:border-b-2 lua:border-blue-500"})}),jsxRuntime.jsx("div",{className:"lua:flex lua:justify-center",children:e&&jsxRuntime.jsxs("button",{onClick:l,disabled:a,className:`lua:px-4 lua:py-2 lua:rounded-full ${a?"lua:bg-blue-300 lua:cursor-not-allowed":"lua:bg-blue-500 lua:hover:bg-blue-600"} lua:text-white lua:flex lua:items-center lua:gap-2`,children:[jsxRuntime.jsx("svg",{className:"lua:w-5 lua:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"})}),a?"Sharing...":"Share Location"]})})]})})}function Ct({children:t,language:e=""}){let[a,l]=react.useState(false),r=typeof t=="string"?t:String(t),s=e||"javascript";return jsxRuntime.jsxs("div",{className:"lua:relative lua:my-4 lua:rounded-lg lua:overflow-hidden lua:mx-4 lua:sm:mx-5 lua:grid",children:[jsxRuntime.jsxs("div",{className:"lua:flex lua:items-center lua:justify-between lua:bg-gray-800 lua:text-gray-200 lua:px-4 lua:py-2",children:[jsxRuntime.jsx("span",{className:"lua:text-xs lua:font-mono",children:s}),jsxRuntime.jsx("button",{onClick:()=>{navigator.clipboard.writeText(r),l(true),setTimeout(()=>l(false),2e3);},className:"lua:text-xs lua:bg-gray-700 lua:hover:bg-gray-600 lua:rounded lua:px-2 lua:py-1 lua:transition-colors","aria-label":"Copy code",children:a?"Copied!":"Copy"})]}),jsxRuntime.jsx(prismReactRenderer.Highlight,{theme:prismReactRenderer.themes.vsDark,code:r,language:s,children:({className:u,style:n,tokens:p,getLineProps:f,getTokenProps:o})=>jsxRuntime.jsx("pre",{className:`${u} lua:p-4 lua:overflow-x-auto`,style:n,children:p.map((i,h)=>jsxRuntime.jsx("div",{...f({line:i}),children:i.map((c,v)=>jsxRuntime.jsx("span",{...o({token:c})},v))},h))})})]})}var L={p:"lua:mb-2 lua:last:mb-0 lua:mx-4 lua:sm:mx-5 lua-paragraph-markdown",h1:"lua:text-2xl lua:font-bold lua:mb-2 lua:mx-4 lua:sm:mx-5",h2:"lua:text-xl lua:font-semibold lua:mb-2 lua:text-gray-700 lua:mx-4 lua:sm:mx-5",h3:"lua:text-lg lua:font-medium lua:mb-2 lua:mx-4 lua:sm:mx-5",h4:"lua:mx-4 lua:sm:mx-5",ul:"lua:list-disc lua:pl-6 lua:mb-4",ol:"lua:list-decimal lua:pl-6 lua:mb-4 lua:mx-4 lua:sm:mx-5",li:"lua:mb-1 lua:mx-4 lua:sm:mx-5",a:"lua:text-blue-500 lua:hover:underline",blockquote:"lua:border-l-4 lua:border-gray-200 lua:pl-4 lua:italic lua:my-4",pre:"lua:contents lua:bg-gray-100 lua:rounded lua:px-1 lua:text-gray-700 lua:mx-4 lua:sm:mx-5",code:"lua:bg-gray-100 lua:rounded lua:px-1 lua:mx-4 lua:sm:mx-5",img:"lua:max-w-full lua:h-auto lua:rounded-lg lua:mb-2",table:"lua:min-w-full lua:border lua:border-gray-200 lua:my-4",th:"lua:bg-gray-100 lua:border lua:border-gray-200 lua:px-4 lua:py-2",td:"lua:border lua:border-gray-200 lua:px-4 lua:py-2"};var Ra=t=>({code({children:e,className:a,...l}){let r=a?.replace("language-","")||"";return typeof e=="string"&&!e.includes(`
1
+ 'use strict';var luaniverse=require('luaniverse'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactVisuallyHidden=require('@radix-ui/react-visually-hidden'),St=require('react-markdown'),prismReactRenderer=require('prism-react-renderer'),reactLeaflet=require('react-leaflet');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var St__default=/*#__PURE__*/_interopDefault(St);function $l({onAudioRecorded:t,onClose:e,inputMessage:a}){let[l,r]=react.useState(false),[s,d]=react.useState(0),[u,n]=react.useState([]),[p,f]=react.useState(null),[o,i]=react.useState(null),h=react.useRef(null),c=react.useRef(null),v=react.useRef([]),g=react.useRef(null),C=react.useRef(null),x=react.useRef(null),N=react.useRef(null),m=react.useRef(false),w=react.useRef(false),U=react.useRef(null);react.useEffect(()=>{if(!l||!p)return;let P=setInterval(()=>{let k=Math.floor((Date.now()-p)/1e3);d(k);},1e3);return ()=>clearInterval(P)},[l,p]),react.useEffect(()=>((async()=>{if(!(m.current||w.current))try{m.current=!0;let k=await navigator.mediaDevices.getUserMedia({audio:!0});h.current=k,g.current=new AudioContext,C.current=g.current.createAnalyser(),C.current.fftSize=256,g.current.createMediaStreamSource(k).connect(C.current),x.current=new Uint8Array(C.current.frequencyBinCount);let q=()=>{if(!C.current||!x.current)return;C.current.getByteFrequencyData(x.current);let Wt=Array.from(x.current).map(Xt=>Xt/255);n(Wt),N.current=requestAnimationFrame(q);};q(),_t();}catch(k){console.error("Error accessing microphone:",k),e();}finally{m.current=false;}})(),()=>{B();}),[]);let B=()=>{if(!w.current)try{if(w.current=!0,l&&c.current&&(c.current.stop(),r(!1),f(null)),h.current){let P=h.current.getAudioTracks(),k=h.current.getVideoTracks();P.forEach(A=>{A.stop(),A.enabled=!1;}),k.forEach(A=>{A.stop(),A.enabled=!1;});}N.current&&cancelAnimationFrame(N.current),g.current&&g.current.close(),h.current=null,c.current=null,v.current=[],g.current=null,C.current=null,x.current=null,N.current=null;}finally{w.current=false;}},_t=()=>{if(!h.current)return;let k=["audio/webm","audio/mp4","audio/ogg","audio/wav"].find(q=>MediaRecorder.isTypeSupported(q));if(!k){console.error("No supported MIME type found for MediaRecorder"),e();return}U.current=k;let A=new MediaRecorder(h.current,{mimeType:k});c.current=A,v.current=[],A.ondataavailable=q=>{q.data.size>0&&v.current.push(q.data);},A.start(),r(true),f(Date.now()),d(0);},jt=async()=>{if(!c.current||!h.current)return;r(false),i(s),f(null),c.current.stop(),await new Promise(k=>{c.current&&(c.current.onstop=()=>k());});let P=new Blob(v.current,{type:U.current||"audio/webm"});t(P,a),B(),e();},mt=P=>{let k=Math.floor(P/60),A=P%60;return `${k.toString().padStart(2,"0")}:${A.toString().padStart(2,"0")}`};return jsxRuntime.jsxs("div",{className:"audio-recorder-container lua:bg-gray-100 lua:rounded-lg lua:p-2 lua:flex lua:items-center lua:gap-4",children:[jsxRuntime.jsx(luaniverse.IconButton,{variant:"muted",onClick:async()=>{B(),e();},className:"audio-recorder-close-button lua:flex-shrink-0",children:jsxRuntime.jsx(luaniverse.XIcon,{className:"audio-recorder-close-icon",color:"#00000099"})}),jsxRuntime.jsxs("div",{className:"audio-recorder-status lua:flex lua:items-center lua:gap-2",children:[jsxRuntime.jsx("div",{className:`audio-recorder-indicator lua:w-3 lua:h-3 lua:rounded-full ${l?"lua:bg-red-500 lua:animate-pulse":"lua:bg-gray-400"}`}),jsxRuntime.jsx("span",{className:"audio-recorder-time lua:text-gray-700 lua:text-sm",children:mt(l?s:o||0)})]}),jsxRuntime.jsx("div",{className:"audio-recorder-visualizer lua:flex-1","data-testid":"audio-visualizer-bar",children:u.length>0&&jsxRuntime.jsx("div",{className:"audio-recorder-bars lua:h-8 lua:flex lua:items-center lua:w-full lua:gap-px sm:lua:gap-0.5 md:lua:gap-1",children:u.slice(0,50).map((P,k)=>jsxRuntime.jsx("div",{className:"audio-recorder-bar lua:flex-1 lua:bg-blue-500",style:{height:`${P*100}%`}},k))})}),jsxRuntime.jsx(luaniverse.IconButton,{onClick:jt,className:"audio-recorder-send-button lua:flex-shrink-0 lua:mr-1","data-testid":"send-audio-button",children:jsxRuntime.jsx(luaniverse.ArrowUp,{className:"audio-recorder-send-icon",color:"white"})})]})}function aa(t){let e=Math.floor(t/60),a=t%60;return `${e.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function Xl({videoRef:t,isRecording:e,recordingTime:a,loading:l,onStartRecording:r,onStopRecording:s,onClose:d,open:u}){return jsxRuntime.jsx(luaniverse.Dialog,{open:u,onOpenChange:d,children:jsxRuntime.jsxs(luaniverse.DialogContent,{className:"lua:w-full lua:max-w-2xl lua:p-2.5",showClose:false,children:[jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden,{children:jsxRuntime.jsx(luaniverse.DialogTitle,{})}),jsxRuntime.jsxs("div",{className:"lua:relative lua:aspect-[4/3] lua:bg-black lua:rounded-xl lua:overflow-hidden lua:mb-8",children:[jsxRuntime.jsx("video",{ref:t,autoPlay:true,playsInline:true,muted:true,className:"lua:absolute lua:inset-0 lua:w-full lua:h-full lua:object-cover",style:{backgroundColor:"black"}}),e&&jsxRuntime.jsxs("div",{className:"lua:absolute lua:top-4 lua:left-4 lua:flex lua:items-center lua:gap-2 lua:bg-black lua:bg-opacity-50 lua:px-3 lua:py-1 lua:rounded-full",children:[jsxRuntime.jsx("div",{className:"lua:w-2 lua:h-2 lua:rounded-full lua:bg-red-500 lua:animate-pulse"}),jsxRuntime.jsx("span",{className:"lua:text-sm lua:font-medium lua:text-white",children:aa(a)})]})]}),jsxRuntime.jsx("div",{className:"lua:flex lua:justify-center lua:items-center lua:gap-5 lua:mb-2.5",children:e?jsxRuntime.jsx(luaniverse.IconButton,{"data-testid":"stop-recording-button",onClick:s,disabled:l,variant:"secondary",children:jsxRuntime.jsx(luaniverse.XIcon,{color:"#000000"})}):jsxRuntime.jsxs("svg",{onClick:r,"data-testid":"start-recording-button",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"cursor-pointer",children:[jsxRuntime.jsx("rect",{x:"2",y:"2",width:"36",height:"36",rx:"18",stroke:"#FF0342",strokeWidth:"4"}),jsxRuntime.jsx("rect",{x:"6",y:"6",width:"28",height:"28",rx:"14",fill:"#FF0342"})]})})]})})}function vt({url:t,alt:e,open:a,onClose:l}){return jsxRuntime.jsxs(luaniverse.Dialog,{open:a,onOpenChange:l,children:[jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden,{children:jsxRuntime.jsx(luaniverse.DialogTitle,{})}),jsxRuntime.jsx(luaniverse.DialogContent,{className:"lua:w-full lua:fixed lua:inset-0 lua:h-full lua:max-w-none lua:p-0 lua:bg-transparent lua:shadow-none lua:translate-x-0 lua:translate-y-0 lua:m-0 lua:rounded-none",showClose:false,children:jsxRuntime.jsxs("div",{className:"lua:relative lua:w-full lua:h-full",children:[jsxRuntime.jsx("button",{onClick:l,className:"lua:cursor-pointer lua:absolute lua:top-4 lua:left-4 lua:z-10 lua:p-2 lua:bg-black/50 lua:rounded-full lua:hover:bg-black/70 lua:transition-colors",children:jsxRuntime.jsx(luaniverse.XIcon,{color:"white",className:"lua:w-6 lua:h-6"})}),jsxRuntime.jsx("div",{className:"lua:w-full lua:h-full lua:flex lua:items-center lua:justify-center",children:jsxRuntime.jsx("img",{src:t,alt:e,className:"sm:lua:aspect-[16/9] lua:object-contain lua:rounded-none sm:lua:rounded-lg"})})]})})]})}function yt({images:t,initialIndex:e=0,open:a,onClose:l}){let[r,s]=react.useState(),[d,u]=react.useState(0);return react.useEffect(()=>{if(!r)return;e>0&&e<t.length&&(r.scrollTo(e),u(e));let n=()=>{u(r.selectedScrollSnap());};return r.on("select",n),n(),()=>{r?.off("select",n);}},[r,e,t.length]),jsxRuntime.jsxs(luaniverse.Dialog,{open:a,onOpenChange:l,children:[jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden,{children:jsxRuntime.jsx(luaniverse.DialogTitle,{})}),jsxRuntime.jsx(luaniverse.DialogContent,{className:"lua:w-full lua:m-0",showClose:false,children:jsxRuntime.jsxs("div",{className:"lua:relative lua:w-full lua:h-full",children:[jsxRuntime.jsx("button",{onClick:l,className:"lua:cursor-pointer lua:absolute lua:top-4 lua:left-4 lua:z-10 lua:p-2 lua:bg-black/50 lua:rounded-full lua:hover:bg-black/70 lua:transition-colors",children:jsxRuntime.jsx(luaniverse.XIcon,{color:"white",className:"lua:w-6 lua:h-6"})}),t.length>1&&jsxRuntime.jsxs("div",{className:"lua:absolute lua:top-4 lua:right-4 lua:z-10 lua:px-3 lua:py-1 lua:bg-black/50 lua:rounded-full lua:text-white lua:text-sm",children:[d+1," / ",t.length]}),jsxRuntime.jsx("div",{className:"lua:w-full lua:h-full lua:flex lua:items-center lua:justify-center lua:px-16",children:jsxRuntime.jsxs(luaniverse.Carousel,{setApi:s,className:"lua:w-full lua:max-w-5xl",opts:{align:"center",loop:t.length>1},children:[jsxRuntime.jsx(luaniverse.CarouselContent,{children:t.map((n,p)=>jsxRuntime.jsx(luaniverse.CarouselItem,{className:"lua:flex lua:items-center lua:justify-center",children:jsxRuntime.jsx("img",{src:n.src,alt:n.alt||`Image ${p+1}`,className:"lua:max-w-full lua:max-h-screen lua:object-contain lua:rounded-none sm:lua:rounded-lg",draggable:false})},p))}),t.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(luaniverse.CarouselPrevious,{className:"lua:left-4 lua:bg-black/50 lua:border-none lua:text-white lua:hover:bg-black/70 lua:hover:text-white-white/70"}),jsxRuntime.jsx(luaniverse.CarouselNext,{className:"lua:right-4 lua:bg-black/50 lua:border-none lua:text-white lua:hover:bg-black/70 lua:hover:text-white-white/70"})]})]})})]})})]})}function ir({videoRef:t,canvasRef:e,onCapture:a,onClose:l,open:r}){return jsxRuntime.jsxs(luaniverse.Dialog,{open:r,onOpenChange:l,children:[jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden,{children:jsxRuntime.jsx(luaniverse.DialogTitle,{})}),jsxRuntime.jsxs(luaniverse.DialogContent,{className:"lua:w-full lua:max-w-2xl lua:p-2.5",showClose:false,children:[jsxRuntime.jsxs("div",{className:"lua:relative lua:aspect-[16/9] lua:bg-black lua:rounded-xl lua:overflow-hidden",children:[jsxRuntime.jsx("video",{ref:t,autoPlay:true,playsInline:true,muted:true,className:"lua:absolute lua:inset-0 lua:w-full lua:h-full lua:object-cover",style:{backgroundColor:"black"}}),jsxRuntime.jsx("canvas",{ref:e,className:"lua:hidden"})]}),jsxRuntime.jsxs("div",{className:"lua:flex lua:justify-center lua:items-center lua:gap-5 lua:mb-2.5 lua:mt-6",children:[jsxRuntime.jsx(luaniverse.IconButton,{onClick:a,"data-testid":"capture-button",children:jsxRuntime.jsx(luaniverse.Camera,{color:"#FFFFFF"})}),jsxRuntime.jsx(luaniverse.IconButton,{onClick:l,variant:"secondary",children:jsxRuntime.jsx(luaniverse.XIcon,{color:"#000000"})})]})]})]})}function cr({locationError:t,currentLocation:e,loading:a,onShare:l,onClose:r}){return jsxRuntime.jsx("div",{className:"lua:fixed lua:inset-0 lua:bg-black lua:bg-opacity-75 lua:flex lua:items-center lua:justify-center lua:z-50",children:jsxRuntime.jsxs("div",{className:"lua:bg-white lua:rounded-lg lua:p-4 lua:max-w-2xl lua:w-full lua:mx-4",children:[jsxRuntime.jsxs("div",{className:"lua:flex lua:justify-between lua:items-center lua:mb-4",children:[jsxRuntime.jsx("h3",{className:"lua:text-lg lua:font-semibold",children:"Share Location"}),jsxRuntime.jsx("button",{onClick:r,className:"lua:text-gray-500 lua:hover:text-gray-700",children:jsxRuntime.jsx("svg",{className:"lua:w-6 lua:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t?jsxRuntime.jsx("div",{className:"lua:bg-red-50 lua:text-red-500 lua:p-4 lua:rounded-lg lua:mb-4",children:t}):e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"lua:mb-4",children:[jsxRuntime.jsx("div",{className:"lua:text-sm lua:text-gray-500 lua:mb-2",children:"Current Location:"}),jsxRuntime.jsx("div",{className:"lua:text-gray-700 lua:mb-2",children:e.address}),jsxRuntime.jsxs("div",{className:"lua:text-sm lua:text-gray-500",children:[e.latitude.toFixed(6),","," ",e.longitude.toFixed(6)]})]})}):jsxRuntime.jsx("div",{className:"lua:flex lua:justify-center lua:items-center lua:h-48",children:jsxRuntime.jsx("div",{className:"lua:animate-spin lua:rounded-full lua:h-8 lua:w-8 lua:border-b-2 lua:border-blue-500"})}),jsxRuntime.jsx("div",{className:"lua:flex lua:justify-center",children:e&&jsxRuntime.jsxs("button",{onClick:l,disabled:a,className:`lua:px-4 lua:py-2 lua:rounded-full ${a?"lua:bg-blue-300 lua:cursor-not-allowed":"lua:bg-blue-500 lua:hover:bg-blue-600"} lua:text-white lua:flex lua:items-center lua:gap-2`,children:[jsxRuntime.jsx("svg",{className:"lua:w-5 lua:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"})}),a?"Sharing...":"Share Location"]})})]})})}function Ct({children:t,language:e=""}){let[a,l]=react.useState(false),r=typeof t=="string"?t:String(t),s=e||"javascript";return jsxRuntime.jsxs("div",{className:"lua:relative lua:my-4 lua:rounded-lg lua:overflow-hidden lua:mx-4 lua:sm:mx-5 lua:grid",children:[jsxRuntime.jsxs("div",{className:"lua:flex lua:items-center lua:justify-between lua:bg-gray-800 lua:text-gray-200 lua:px-4 lua:py-2",children:[jsxRuntime.jsx("span",{className:"lua:text-xs lua:font-mono",children:s}),jsxRuntime.jsx("button",{onClick:()=>{navigator.clipboard.writeText(r),l(true),setTimeout(()=>l(false),2e3);},className:"lua:text-xs lua:bg-gray-700 lua:hover:bg-gray-600 lua:rounded lua:px-2 lua:py-1 lua:transition-colors","aria-label":"Copy code",children:a?"Copied!":"Copy"})]}),jsxRuntime.jsx(prismReactRenderer.Highlight,{theme:prismReactRenderer.themes.vsDark,code:r,language:s,children:({className:u,style:n,tokens:p,getLineProps:f,getTokenProps:o})=>jsxRuntime.jsx("pre",{className:`${u} lua:p-4 lua:overflow-x-auto`,style:n,children:p.map((i,h)=>jsxRuntime.jsx("div",{...f({line:i}),children:i.map((c,v)=>jsxRuntime.jsx("span",{...o({token:c})},v))},h))})})]})}var L={p:"lua:mb-2 lua:last:mb-0 lua:mx-4 lua:sm:mx-5 lua-paragraph-markdown",h1:"lua:text-2xl lua:font-bold lua:mb-2 lua:mx-4 lua:sm:mx-5",h2:"lua:text-xl lua:font-semibold lua:mb-2 lua:text-gray-700 lua:mx-4 lua:sm:mx-5",h3:"lua:text-lg lua:font-medium lua:mb-2 lua:mx-4 lua:sm:mx-5",h4:"lua:mx-4 lua:sm:mx-5",ul:"lua:list-disc lua:pl-6 lua:mb-4",ol:"lua:list-decimal lua:pl-6 lua:mb-4 lua:mx-4 lua:sm:mx-5",li:"lua:mb-1 lua:mx-4 lua:sm:mx-5",a:"lua:text-blue-500 lua:hover:underline",blockquote:"lua:border-l-4 lua:border-gray-200 lua:pl-4 lua:italic lua:my-4",pre:"lua:contents lua:bg-gray-100 lua:rounded lua:px-1 lua:text-gray-700 lua:mx-4 lua:sm:mx-5",code:"lua:bg-gray-100 lua:rounded lua:px-1 lua:mx-4 lua:sm:mx-5",img:"lua:max-w-full lua:h-auto lua:rounded-lg lua:mb-2",table:"lua:min-w-full lua:border lua:border-gray-200 lua:my-4",th:"lua:bg-gray-100 lua:border lua:border-gray-200 lua:px-4 lua:py-2",td:"lua:border lua:border-gray-200 lua:px-4 lua:py-2"};var Ra=t=>({code({children:e,className:a,...l}){let r=a?.replace("language-","")||"";return typeof e=="string"&&!e.includes(`
2
2
  `)?jsxRuntime.jsx("code",{className:L.code,...l,children:e}):jsxRuntime.jsx(Ct,{language:r,className:a,children:e})},p({children:e,...a}){return jsxRuntime.jsx("p",{className:L.p,...a,children:e})},h1({children:e,...a}){return jsxRuntime.jsx("h1",{className:L.h1,...a,children:e})},h2({children:e,...a}){return jsxRuntime.jsx("h2",{className:L.h2,...a,children:e})},h3({children:e,...a}){return jsxRuntime.jsx("h3",{className:L.h3,...a,children:e})},h4({children:e,...a}){return jsxRuntime.jsx("h4",{className:L.h4,...a,children:e})},img({src:e,alt:a}){return jsxRuntime.jsx("img",{src:e,alt:a,className:"lua:w-full lua:h-48 lua:object-cover lua:rounded-lg lua:mb-3"})},ul({children:e,...a}){return jsxRuntime.jsx("ul",{className:L.ul,...a,children:e})},ol({children:e,...a}){return jsxRuntime.jsx("ol",{className:L.ol,...a,children:e})},li({children:e,...a}){return jsxRuntime.jsx("li",{className:`${L.li} cursor-pointer hover:bg-gray-50 rounded px-2 -mx-2 transition-colors`,onClick:()=>t(e),...a,children:e})},a({href:e,children:a,...l}){return jsxRuntime.jsx("a",{href:e,className:L.a,target:"_blank",rel:"noopener noreferrer",...l,children:a})},blockquote({children:e,...a}){return jsxRuntime.jsx("blockquote",{className:L.blockquote,...a,children:e})},pre({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})},table({children:e,...a}){return jsxRuntime.jsx("table",{className:L.table,...a,children:e})},th({children:e,...a}){return jsxRuntime.jsx("th",{className:L.th,...a,children:e})},td({children:e,...a}){return jsxRuntime.jsx("td",{className:L.td,...a,children:e})}}),be=Ra;function Ua(t){let e=new URL(t,"http://lua"),a=decodeURIComponent(e.pathname),l={};for(let[r,s]of e.searchParams.entries())l[r]=decodeURIComponent(s);return {pathname:a,queryParams:l}}var we=Ua;function Da(t){let e=t.match(/\[navigate\]\(([^)]+)\)/);return e?e[1]:null}var Nt=Da;var Fa=react.memo(function({block:e,onCardClick:a,onListItemClick:l,onNavigate:r}){let s=e.content.match(/^#\s+(.+)$/m),d=e.content.match(/!\[.*?]\((.*)\)/),u=s?s[1]:"",n=d?d[1]:null,p=Nt(e.content),f=e.content.replace(/^#\s+.+$/m,"").replace(/!\[.*?]\(.*?\)/g,"").replace(/\[.*?]\(.*?\)/g,"").trim(),o=be(l);return jsxRuntime.jsxs("div",{onClick:()=>{if(r&&p){let h=we(p);r(h.pathname,{...h.queryParams&&{query:h.queryParams}});}else a(e.content);},className:"chat-list-item group",children:[jsxRuntime.jsx("div",{className:"lua:absolute lua:inset-0 lua:bg-blue-500 lua:opacity-0 group-hover:lua:opacity-5 lua:rounded-lg lua:transition-opacity lua:duration-200"}),jsxRuntime.jsxs("div",{className:"chat-list-item-content",children:[n?jsxRuntime.jsx("div",{className:"chat-list-item-image-wrapper",children:jsxRuntime.jsx("img",{className:"chat-list-item-image",src:n,alt:u})}):null,jsxRuntime.jsxs("div",{className:"content-container",children:[jsxRuntime.jsx("h1",{className:"lua:text-base lua:leading-6 lua:font-semibold lua:text-gray-900 lua:mb-0",children:u}),jsxRuntime.jsx("div",{className:"lua:text-sm lua:leading-6 lua:font-normal lua:text-gray-600",children:jsxRuntime.jsx(St__default.default,{components:o,children:f})})]})]})]})}),re=Fa;var Ba=react.memo(function({group:e,onCardClick:a,onListItemClick:l,onNavigate:r}){return jsxRuntime.jsx("div",{className:"lua:w-full",children:jsxRuntime.jsx("div",{className:"chat-list-item-container",children:e.map((s,d)=>jsxRuntime.jsx(re,{block:s,onCardClick:a,onListItemClick:l,onNavigate:r},d))})})}),kt=Ba;function Oa(t){return {icon:()=>null}}function Ne({documents:t}){return t.map(e=>{let l=Oa(new File([],"",{type:e.mimeType})).icon;return jsxRuntime.jsx("a",{"data-testid":"chat-file-message",href:e.url,target:"_blank",rel:"noopener noreferrer",className:"chat-file-message lua:mx-4 lua:sm:mx-5",children:jsxRuntime.jsx("div",{className:"lua:flex lua:flex-col lua:gap-8",children:jsxRuntime.jsxs("div",{className:"chat-file-card lua:flex lua:items-center lua:justify-start lua:p-3 lua:border lua:border-gray-200 lua:rounded-lg lua:bg-white lua:w-80",children:[jsxRuntime.jsx(l,{className:"lua:w-12 lua:h-12 lua:text-gray-500"}),jsxRuntime.jsxs("div",{className:"lua:flex lua:flex-col lua:gap-1 lua:pl-2",children:[e.fileName||"File",jsxRuntime.jsx("span",{className:"lua:text-gray-500 lua:text-sm",children:e.mimeType})]})]})})},e.url)})}function $a(t){let e=[],a=t.split(`
3
3
  `).filter(l=>l.trim()!=="");for(let l of a){let r=/\[([^\]]+)\]\(([^)]+)\)\s+filename:([^\s]+)\s+mime:([^\s]+)/g,s;for(;(s=r.exec(l))!==null;){let[,d,u,n,p]=s;e.push({fileName:d.trim(),url:u.trim(),filename:n.trim(),mimeType:p.trim()});}}return e}var De=$a;function Lt({message:t}){return jsxRuntime.jsx("div",{className:"chat-audio-message lua:flex lua:flex-col lua:mx-4 lua:sm:mx-5","data-testid":"audio-preview",children:jsxRuntime.jsx("div",{className:"chat-audio-container audio-playback-container lua:relative",children:jsxRuntime.jsxs("div",{className:"chat-audio-controls lua:flex lua:items-center lua:gap-2 lua:min-w-full",children:[jsxRuntime.jsx("audio",{src:t.url,controls:true,className:"chat-audio-player lua:h-8",style:{backgroundColor:"transparent",border:"none"}}),t.isUploading&&jsxRuntime.jsx("div",{className:"chat-audio-upload-overlay lua:absolute lua:inset-0 lua:bg-black lua:bg-opacity-50 lua:rounded-lg lua:flex lua:items-center lua:justify-center",children:jsxRuntime.jsx("div",{className:"lua:text-white lua:text-sm",children:"Uploading..."})})]})})})}function Ee({url:t}){return jsxRuntime.jsxs(luaniverse.Button,{onClick:a=>{if(a.preventDefault(),/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)){window.open(t,"_blank","noopener,noreferrer");return}let r=500,s=600,d=window.screen.width/2-r/2,u=window.screen.height/2-s/2,n=window.open(t,"Payment",`width=${r},height=${s},left=${d},top=${u},toolbar=no,menubar=no,scrollbars=yes,resizable=yes`);(!n||n.closed||typeof n.closed>"u")&&window.open(t,"_blank","noopener,noreferrer");},className:"chat-payment-button lua:rounded-xl",children:[jsxRuntime.jsx(luaniverse.CreditCard,{size:16}),jsxRuntime.jsx("span",{children:"Open payment"})]})}var ja=t=>t.split(`
4
4
  `).filter(a=>a.trim()).filter(a=>a.trim().startsWith("-")).map(a=>({text:a.trim().substring(1).trim(),onClick:a.trim().substring(1).trim()})),Se=ja;var Wa=t=>{let e=/!\[(.*?)\]\((.*)\)/g,a=[],l;for(;(l=e.exec(t))!==null;)l[1]&&l[2]&&a.push({alt:l[1],src:l[2]});return a},Fe=Wa;var Xa=t=>{let e=/\[.*?\]\((.*?)\)/g,a=[],l;for(;(l=e.exec(t))!==null;)l[1]&&a.push(l[1]);return a},He=Xa;function Be(t){let e=t.match(/!\[([^\]]+)\]\(([^)]+)\)/);if(!e)return null;let[,a,l]=e;return {text:a,url:l}}var Ga=t=>{let e=/\[.*?\]\((.*?)\)/,a=t.match(e);return a?a[1]:null},Oe=Ga;var $e=t=>typeof t=="string"?t:Array.isArray(t)?t.map($e).join(""):typeof t=="object"&&t!==null&&"props"in t?$e(t.props.children):"",Pt=$e;function Ka(t){return t.replace(/([^\n]):::/g,`$1