UNPKG

voicebot-react-native-expo

Version:

This is a voicebot-react-native package of Kipps AI voice bot for React Native Expo

1 lines 52.1 kB
"use strict";const w=require("livekit-client"),N=require("react"),E=require("./shared-D_Ks7MZc.js"),p=require("./shared-C9EfKMR-.js");function at(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const e=at(N);function rt(t){const n=o=>typeof window<"u"?window.matchMedia(o).matches:!1,[a,r]=e.useState(n(t));function c(){r(n(t))}return e.useEffect(()=>{const o=window.matchMedia(t);return c(),o.addListener?o.addListener(c):o.addEventListener("change",c),()=>{o.removeListener?o.removeListener(c):o.removeEventListener("change",c)}},[t]),a}const pe=e.createContext(void 0);function Ee(t){const n=e.useContext(pe);if(t===!0){if(n)return n;throw Error("tried to access feature context, but none is present")}return n}const Y=e.forwardRef(function(n,a){const{mergedProps:r}=p.useChatToggle({props:n});return e.createElement("button",{ref:a,...r},n.children)}),ee=e.forwardRef(function(n,a){const{buttonProps:r}=p.useDisconnectButton(n);return e.createElement("button",{ref:a,...r},n.children)}),ke=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708L11 10.293V4.5A1.5 1.5 0 0 0 9.5 3H3.707zM0 4.5a1.5 1.5 0 0 1 .943-1.393l9.532 9.533c-.262.224-.603.36-.975.36h-8A1.5 1.5 0 0 1 0 11.5z"}),e.createElement("path",{d:"m15.2 3.6-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z"})),Se=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M0 4.5A1.5 1.5 0 0 1 1.5 3h8A1.5 1.5 0 0 1 11 4.5v7A1.5 1.5 0 0 1 9.5 13h-8A1.5 1.5 0 0 1 0 11.5zM15.2 3.6l-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z"})),we=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,viewBox:"0 0 24 24",...t},e.createElement("path",{fill:"#FFF",d:"M4.99 3.99a1 1 0 0 0-.697 1.717L10.586 12l-6.293 6.293a1 1 0 1 0 1.414 1.414L12 13.414l6.293 6.293a1 1 0 1 0 1.414-1.414L13.414 12l6.293-6.293a1 1 0 0 0-.727-1.717 1 1 0 0 0-.687.303L12 10.586 5.707 4.293a1 1 0 0 0-.717-.303z"})),be=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:18,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M0 2.75A2.75 2.75 0 0 1 2.75 0h10.5A2.75 2.75 0 0 1 16 2.75v13.594a.75.75 0 0 1-1.234.572l-3.691-3.12a1.25 1.25 0 0 0-.807-.296H2.75A2.75 2.75 0 0 1 0 10.75v-8ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v8c0 .69.56 1.25 1.25 1.25h7.518c.65 0 1.279.23 1.775.65l2.457 2.077V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M3 4.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Z",clipRule:"evenodd"})),K=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M5.293 2.293a1 1 0 0 1 1.414 0l4.823 4.823a1.25 1.25 0 0 1 0 1.768l-4.823 4.823a1 1 0 0 1-1.414-1.414L9.586 8 5.293 3.707a1 1 0 0 1 0-1.414z",clipRule:"evenodd"})),Ce=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5},e.createElement("path",{d:"M10 1.75h4.25m0 0V6m0-4.25L9 7M6 14.25H1.75m0 0V10m0 4.25L7 9"}))),ye=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M8.961.894C8.875-.298 7.125-.298 7.04.894c-.066.912-1.246 1.228-1.76.472-.67-.99-2.186-.115-1.664.96.399.824-.465 1.688-1.288 1.289-1.076-.522-1.95.994-.961 1.665.756.513.44 1.693-.472 1.759-1.192.086-1.192 1.836 0 1.922.912.066 1.228 1.246.472 1.76-.99.67-.115 2.186.96 1.664.824-.399 1.688.465 1.289 1.288-.522 1.076.994 1.95 1.665.961.513-.756 1.693-.44 1.759.472.086 1.192 1.836 1.192 1.922 0 .066-.912 1.246-1.228 1.76-.472.67.99 2.186.115 1.664-.96-.399-.824.465-1.688 1.288-1.289 1.076.522 1.95-.994.961-1.665-.756-.513-.44-1.693.472-1.759 1.192-.086 1.192-1.836 0-1.922-.912-.066-1.228-1.246-.472-1.76.99-.67.115-2.186-.96-1.664-.824.399-1.688-.465-1.289-1.288.522-1.076-.994-1.95-1.665-.961-.513.756-1.693.44-1.759-.472ZM8 13A5 5 0 1 0 8 3a5 5 0 0 0 0 10Z",clipRule:"evenodd"})),Me=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M2 2.75A2.75 2.75 0 0 1 4.75 0h6.5A2.75 2.75 0 0 1 14 2.75v10.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-.5a.75.75 0 0 1 1.5 0v.5c0 .69.56 1.25 1.25 1.25h6.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25h-6.5c-.69 0-1.25.56-1.25 1.25v.5a.75.75 0 0 1-1.5 0v-.5Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8.78 7.47a.75.75 0 0 1 0 1.06l-2.25 2.25a.75.75 0 1 1-1.06-1.06l.97-.97H1.75a.75.75 0 0 1 0-1.5h4.69l-.97-.97a.75.75 0 0 1 1.06-1.06l2.25 2.25Z",clipRule:"evenodd"})),Te=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M4 6.104V4a4 4 0 1 1 8 0v2.104c1.154.326 2 1.387 2 2.646v4.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-4.5c0-1.259.846-2.32 2-2.646ZM5.5 4a2.5 2.5 0 0 1 5 0v2h-5V4Z",clipRule:"evenodd"})),Re=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M12.227 11.52a5.477 5.477 0 0 0 1.246-2.97.5.5 0 0 0-.995-.1 4.478 4.478 0 0 1-.962 2.359l-1.07-1.07C10.794 9.247 11 8.647 11 8V3a3 3 0 0 0-6 0v1.293L1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708zM8 12.5c.683 0 1.33-.152 1.911-.425l.743.743c-.649.359-1.378.59-2.154.66V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .995-.098A4.5 4.5 0 0 0 8 12.5z"}),e.createElement("path",{d:"M8.743 10.907 5 7.164V8a3 3 0 0 0 3.743 2.907z"})),Ie=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{fillRule:"evenodd",d:"M2.975 8.002a.5.5 0 0 1 .547.449 4.5 4.5 0 0 0 8.956 0 .5.5 0 1 1 .995.098A5.502 5.502 0 0 1 8.5 13.478V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .448-.547z",clipRule:"evenodd"}),e.createElement("path",{d:"M5 3a3 3 0 1 1 6 0v5a3 3 0 0 1-6 0z"})),Pe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"})),Ne=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("g",{opacity:.25},e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}))),Ae=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("g",{opacity:.25},e.createElement("path",{d:"M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}))),Le=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("g",{opacity:.25},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z"}))),te=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M0 2.75A2.75 2.75 0 0 1 2.75 0h14.5A2.75 2.75 0 0 1 20 2.75v10.5A2.75 2.75 0 0 1 17.25 16H2.75A2.75 2.75 0 0 1 0 13.25V2.75ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h14.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M9.47 4.22a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1-1.06 1.06l-.97-.97v4.69a.75.75 0 0 1-1.5 0V6.56l-.97.97a.75.75 0 0 1-1.06-1.06l2.25-2.25Z",clipRule:"evenodd"})),xe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:16,fill:"none",...t},e.createElement("g",{fill:"currentColor"},e.createElement("path",{d:"M7.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L10 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L11.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L10 6.94z"}),e.createElement("path",{fillRule:"evenodd",d:"M2.75 0A2.75 2.75 0 0 0 0 2.75v10.5A2.75 2.75 0 0 0 2.75 16h14.5A2.75 2.75 0 0 0 20 13.25V2.75A2.75 2.75 0 0 0 17.25 0zM1.5 2.75c0-.69.56-1.25 1.25-1.25h14.5c.69 0 1.25.56 1.25 1.25v10.5c0 .69-.56 1.25-1.25 1.25H2.75c-.69 0-1.25-.56-1.25-1.25z",clipRule:"evenodd"}))),J=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8 12a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5A.75.75 0 0 1 8 12Z",clipRule:"evenodd",opacity:.7}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 1.072a.75.75 0 0 1 .274 1.024l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 12 1.072Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M6 11.464a.75.75 0 0 1 .274 1.025l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 6 11.464Z",clipRule:"evenodd",opacity:.6}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M14.928 4a.75.75 0 0 1-.274 1.025l-2.165 1.25a.75.75 0 1 1-.75-1.3l2.165-1.25A.75.75 0 0 1 14.928 4Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4.536 10a.75.75 0 0 1-.275 1.024l-2.165 1.25a.75.75 0 0 1-.75-1.298l2.165-1.25A.75.75 0 0 1 4.536 10Z",clipRule:"evenodd",opacity:.5}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M16 8a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 16 8Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 4 8Z",clipRule:"evenodd",opacity:.4}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M14.928 12a.75.75 0 0 1-1.024.274l-2.165-1.25a.75.75 0 0 1 .75-1.299l2.165 1.25A.75.75 0 0 1 14.928 12Z",clipRule:"evenodd",opacity:.9}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4.536 6a.75.75 0 0 1-1.025.275l-2.165-1.25a.75.75 0 1 1 .75-1.3l2.165 1.25A.75.75 0 0 1 4.536 6Z",clipRule:"evenodd",opacity:.3}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 14.928a.75.75 0 0 1-1.024-.274l-1.25-2.165a.75.75 0 0 1 1.298-.75l1.25 2.165A.75.75 0 0 1 12 14.928Z",clipRule:"evenodd",opacity:.8}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M6 4.536a.75.75 0 0 1-1.024-.275l-1.25-2.165a.75.75 0 1 1 1.299-.75l1.25 2.165A.75.75 0 0 1 6 4.536Z",clipRule:"evenodd",opacity:.2})),Ve=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5},e.createElement("path",{d:"M13.25 7H9m0 0V2.75M9 7l5.25-5.25M2.75 9H7m0 0v4.25M7 9l-5.25 5.25"}))),De=e.forwardRef(function({trackRef:n,...a},r){const c=p.useMaybeTrackRefContext(),{mergedProps:o,inFocus:u}=p.useFocusToggle({trackRef:n??c,props:a});return e.createElement(p.LayoutContext.Consumer,null,l=>l!==void 0&&e.createElement("button",{ref:r,...o},a.children?a.children:u?e.createElement(Ve,null):e.createElement(Ce,null)))});function ct(t){return t!==void 0}function V(...t){return p.mergeProps(...t.filter(ct))}function H(t,n,a){return e.Children.map(t,r=>e.isValidElement(r)&&e.Children.only(t)?(r.props.class&&(n??(n={}),n.class=p.clsx(r.props.class,n.class),n.style={...r.props.style,...n.style}),e.cloneElement(r,{...n,key:a})):r)}function lt(t){var n,a;if(typeof window<"u"&&typeof process<"u"&&(((n=process==null?void 0:process.env)==null?void 0:n.NODE_ENV)==="dev"||((a=process==null?void 0:process.env)==null?void 0:a.NODE_ENV)==="development")){const r=document.querySelector(".lk-room-container");r&&!getComputedStyle(r).getPropertyValue("--lk-has-imported-styles")&&E.log.warn("It looks like you're not using the `@livekit/components-styles package`. To render the UI with the default styling, please import it in your layout or page.")}}const _=e.forwardRef(function({kind:n,initialSelection:a,onActiveDeviceChange:r,onDeviceListChange:c,onDeviceSelectError:o,exactMatch:u,track:l,requestPermissions:i,onError:m,...s},f){const d=E.useMaybeRoomContext(),k=e.useCallback(T=>{d&&d.emit(w.RoomEvent.MediaDevicesError,T),m==null||m(T)},[d,m]),{devices:g,activeDeviceId:v,setActiveMediaDevice:h,className:b}=p.useMediaDeviceSelect({kind:n,room:d,track:l,requestPermissions:i,onError:k});e.useEffect(()=>{a!==void 0&&h(a)},[h]),e.useEffect(()=>{typeof c=="function"&&c(g)},[c,g]),e.useEffect(()=>{v&&v!==""&&(r==null||r(v))},[v]);const C=async T=>{try{await h(T,{exact:u})}catch(S){if(S instanceof Error)o==null||o(S);else throw S}},y=e.useMemo(()=>V(s,{className:b},{className:"lk-list"}),[b,s]);function M(T,S,P){return T===S||P===0&&S==="default"}return e.createElement("ul",{ref:f,...y},g.map((T,S)=>e.createElement("li",{key:T.deviceId,id:T.deviceId,"data-lk-active":M(T.deviceId,v,S),"aria-selected":M(T.deviceId,v,S),role:"option"},e.createElement("button",{className:"lk-button",onClick:()=>C(T.deviceId)},T.label))))}),ne=e.forwardRef(function({label:n,...a},r){const c=E.useRoomContext(),{mergedProps:o,canPlayAudio:u}=p.useStartAudio({room:c,props:a}),{mergedProps:l,canPlayVideo:i}=p.useStartVideo({room:c,props:o}),{style:m,...s}=l;return m.display=u&&i?"none":"block",e.createElement("button",{ref:r,style:m,...s},n??`Start ${u?"Video":"Audio"}`)});function Fe(t,n){switch(t){case w.Track.Source.Microphone:return n?e.createElement(Ie,null):e.createElement(Re,null);case w.Track.Source.Camera:return n?e.createElement(Se,null):e.createElement(ke,null);case w.Track.Source.ScreenShare:return n?e.createElement(xe,null):e.createElement(te,null);default:return}}function it(t){switch(t){case w.ConnectionQuality.Excellent:return e.createElement(Pe,null);case w.ConnectionQuality.Good:return e.createElement(Ne,null);case w.ConnectionQuality.Poor:return e.createElement(Ae,null);default:return e.createElement(Le,null)}}const z=e.forwardRef(function({showIcon:n,...a},r){const{buttonProps:c,enabled:o}=p.useTrackToggle(a);return e.createElement("button",{ref:r,...c},(n??!0)&&Fe(a.source,o),a.children)}),ae=e.forwardRef(function(n,a){const{className:r,quality:c}=p.useConnectionQualityIndicator(n),o=e.useMemo(()=>({...V(n,{className:r}),"data-lk-quality":c}),[c,n,r]);return e.createElement("div",{ref:a,...o},n.children??it(c))}),B=e.forwardRef(function({participant:n,...a},r){const c=p.useEnsureParticipant(n),{className:o,infoObserver:u}=e.useMemo(()=>E.setupParticipantName(c),[c]),{identity:l,name:i}=p.useObservableState(u,{name:c.name,identity:c.identity,metadata:c.metadata}),m=e.useMemo(()=>V(a,{className:o,"data-lk-participant-name":i}),[a,o,i]);return e.createElement("span",{ref:r,...m},i!==""?i:l,a.children)}),re=e.forwardRef(function({trackRef:n,show:a="always",...r},c){const{className:o,isMuted:u}=p.useTrackMutedIndicator(n),l=a==="always"||a==="muted"&&u||a==="unmuted"&&!u,i=e.useMemo(()=>V(r,{className:o}),[o,r]);return l?e.createElement("div",{ref:c,...i,"data-lk-muted":u},r.children??Fe(n.source,!u)):null}),ce=t=>e.createElement("svg",{width:320,height:320,viewBox:"0 0 320 320",preserveAspectRatio:"xMidYMid meet",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{d:"M160 180C204.182 180 240 144.183 240 100C240 55.8172 204.182 20 160 20C115.817 20 79.9997 55.8172 79.9997 100C79.9997 144.183 115.817 180 160 180Z",fill:"white",fillOpacity:.25}),e.createElement("path",{d:"M97.6542 194.614C103.267 191.818 109.841 192.481 115.519 195.141C129.025 201.466 144.1 205 159.999 205C175.899 205 190.973 201.466 204.48 195.141C210.158 192.481 216.732 191.818 222.345 194.614C262.703 214.719 291.985 253.736 298.591 300.062C300.15 310.997 291.045 320 280 320H39.9997C28.954 320 19.8495 310.997 21.4087 300.062C28.014 253.736 57.2966 214.72 97.6542 194.614Z",fill:"white",fillOpacity:.25}));function ze(t,n={}){const[a,r]=e.useState(E.getTrackByIdentifier(t)),[c,o]=e.useState(a==null?void 0:a.isMuted),[u,l]=e.useState(a==null?void 0:a.isSubscribed),[i,m]=e.useState(a==null?void 0:a.track),[s,f]=e.useState("landscape"),d=e.useRef(),{className:k,trackObserver:g}=e.useMemo(()=>E.setupMediaTrack(t),[t.participant.sid??t.participant.identity,t.source,E.isTrackReference(t)&&t.publication.trackSid]);return e.useEffect(()=>{const v=g.subscribe(h=>{E.log.debug("update track",h),r(h),o(h==null?void 0:h.isMuted),l(h==null?void 0:h.isSubscribed),m(h==null?void 0:h.track)});return()=>v==null?void 0:v.unsubscribe()},[g]),e.useEffect(()=>{var v,h;return i&&(d.current&&i.detach(d.current),(v=n.element)!=null&&v.current&&!(E.isLocal(t.participant)&&(i==null?void 0:i.kind)==="audio")&&i.attach(n.element.current)),d.current=(h=n.element)==null?void 0:h.current,()=>{d.current&&(i==null||i.detach(d.current))}},[i,n.element]),e.useEffect(()=>{var v,h;if(typeof((v=a==null?void 0:a.dimensions)==null?void 0:v.width)=="number"&&typeof((h=a==null?void 0:a.dimensions)==null?void 0:h.height)=="number"){const b=a.dimensions.width>a.dimensions.height?"landscape":"portrait";f(b)}},[a]),{publication:a,isMuted:c,isSubscribed:u,track:i,elementProps:V(n.props,{className:k,"data-lk-local-participant":t.participant.isLocal,"data-lk-source":a==null?void 0:a.source,...(a==null?void 0:a.kind)==="video"&&{"data-lk-orientation":s}})}}var ot="Expected a function",me=NaN,st="[object Symbol]",ut=/^\s+|\s+$/g,dt=/^[-+]0x[0-9a-f]+$/i,mt=/^0b[01]+$/i,ft=/^0o[0-7]+$/i,ht=parseInt,gt=typeof E.commonjsGlobal=="object"&&E.commonjsGlobal&&E.commonjsGlobal.Object===Object&&E.commonjsGlobal,vt=typeof self=="object"&&self&&self.Object===Object&&self,pt=gt||vt||Function("return this")(),Et=Object.prototype,kt=Et.toString,St=Math.max,wt=Math.min,W=function(){return pt.Date.now()};function bt(t,n,a){var r,c,o,u,l,i,m=0,s=!1,f=!1,d=!0;if(typeof t!="function")throw new TypeError(ot);n=fe(n)||0,X(a)&&(s=!!a.leading,f="maxWait"in a,o=f?St(fe(a.maxWait)||0,n):o,d="trailing"in a?!!a.trailing:d);function k(S){var P=r,A=c;return r=c=void 0,m=S,u=t.apply(A,P),u}function g(S){return m=S,l=setTimeout(b,n),s?k(S):u}function v(S){var P=S-i,A=S-m,F=n-P;return f?wt(F,o-A):F}function h(S){var P=S-i,A=S-m;return i===void 0||P>=n||P<0||f&&A>=o}function b(){var S=W();if(h(S))return C(S);l=setTimeout(b,v(S))}function C(S){return l=void 0,d&&r?k(S):(r=c=void 0,u)}function y(){l!==void 0&&clearTimeout(l),m=0,r=i=c=l=void 0}function M(){return l===void 0?u:C(W())}function T(){var S=W(),P=h(S);if(r=arguments,c=this,i=S,P){if(l===void 0)return g(i);if(f)return l=setTimeout(b,n),k(i)}return l===void 0&&(l=setTimeout(b,n)),u}return T.cancel=y,T.flush=M,T}function X(t){var n=typeof t;return!!t&&(n=="object"||n=="function")}function Ct(t){return!!t&&typeof t=="object"}function yt(t){return typeof t=="symbol"||Ct(t)&&kt.call(t)==st}function fe(t){if(typeof t=="number")return t;if(yt(t))return me;if(X(t)){var n=typeof t.valueOf=="function"?t.valueOf():t;t=X(n)?n+"":n}if(typeof t!="string")return t===0?t:+t;t=t.replace(ut,"");var a=mt.test(t);return a||ft.test(t)?ht(t.slice(2),a?2:8):dt.test(t)?me:+t}var Mt=bt;const he=E.getDefaultExportFromCjs(Mt);function Tt(t){const n=N.useRef(t);n.current=t,N.useEffect(()=>()=>{n.current()},[])}function Rt(t,n=500,a){const r=N.useRef();Tt(()=>{r.current&&r.current.cancel()});const c=N.useMemo(()=>{const o=he(t,n,a),u=(...l)=>o(...l);return u.cancel=()=>{o.cancel()},u.isPending=()=>!!r.current,u.flush=()=>o.flush(),u},[t,n,a]);return N.useEffect(()=>{r.current=he(t,n,a)},[t,n,a]),c}function It(t,n,a){const r=(m,s)=>m===s,c=t instanceof Function?t():t,[o,u]=N.useState(c),l=N.useRef(c),i=Rt(u,n,a);return r(l.current,c)||(i(c),l.current=c),[o,i]}function Pt({threshold:t=0,root:n=null,rootMargin:a="0%",freezeOnceVisible:r=!1,initialIsIntersecting:c=!1,onChange:o}={}){var u;const[l,i]=N.useState(null),[m,s]=N.useState(()=>({isIntersecting:c,entry:void 0})),f=N.useRef();f.current=o;const d=((u=m.entry)==null?void 0:u.isIntersecting)&&r;N.useEffect(()=>{if(!l||!("IntersectionObserver"in window)||d)return;let v;const h=new IntersectionObserver(b=>{const C=Array.isArray(h.thresholds)?h.thresholds:[h.thresholds];b.forEach(y=>{const M=y.isIntersecting&&C.some(T=>y.intersectionRatio>=T);s({isIntersecting:M,entry:y}),f.current&&f.current(M,y),M&&r&&v&&(v(),v=void 0)})},{threshold:t,root:n,rootMargin:a});return h.observe(l),()=>{h.disconnect()}},[l,JSON.stringify(t),n,a,d,r]);const k=N.useRef(null);N.useEffect(()=>{var v;!l&&((v=m.entry)!=null&&v.target)&&!r&&!d&&k.current!==m.entry.target&&(k.current=m.entry.target,s({isIntersecting:c,entry:void 0}))},[l,m.entry,r,d,c]);const g=[i,!!m.isIntersecting,m.entry];return g.ref=g[0],g.isIntersecting=g[1],g.entry=g[2],g}const Oe=e.forwardRef(function({onTrackClick:n,onClick:a,onSubscriptionStatusChanged:r,trackRef:c,manageSubscription:o,...u},l){const i=p.useEnsureTrackRef(c),m=e.useRef(null);e.useImperativeHandle(l,()=>m.current);const s=Pt({root:m.current}),[f]=It(s,3e3);e.useEffect(()=>{o&&i.publication instanceof w.RemoteTrackPublication&&(f==null?void 0:f.isIntersecting)===!1&&(s==null?void 0:s.isIntersecting)===!1&&i.publication.setSubscribed(!1)},[f,i,o]),e.useEffect(()=>{o&&i.publication instanceof w.RemoteTrackPublication&&(s==null?void 0:s.isIntersecting)===!0&&i.publication.setSubscribed(!0)},[s,i,o]);const{elementProps:d,publication:k,isSubscribed:g}=ze(i,{element:m,props:u});e.useEffect(()=>{r==null||r(!!g)},[g,r]);const v=h=>{a==null||a(h),n==null||n({participant:i==null?void 0:i.participant,track:k})};return e.createElement("video",{ref:m,...d,muted:!0,onClick:v})}),$=e.forwardRef(function({trackRef:n,onSubscriptionStatusChanged:a,volume:r,muted:c,...o},u){const l=p.useEnsureTrackRef(n),i=e.useRef(null);e.useImperativeHandle(u,()=>i.current);const{elementProps:m,isSubscribed:s,track:f,publication:d}=ze(l,{element:i,props:o});return e.useEffect(()=>{a==null||a(!!s)},[s,a]),e.useEffect(()=>{f===void 0||r===void 0||(f instanceof w.RemoteAudioTrack?f.setVolume(r):E.log.warn("Volume can only be set on remote audio tracks."))},[r,f]),e.useEffect(()=>{d===void 0||c===void 0||(d instanceof w.RemoteTrackPublication?d.setEnabled(!c):E.log.warn("Can only call setEnabled on remote track publications."))},[c,d,f]),e.createElement("audio",{ref:i,...m})});function Ze(t){const n=!!p.useMaybeParticipantContext();return t.participant&&!n?e.createElement(p.ParticipantContext.Provider,{value:t.participant},t.children):e.createElement(e.Fragment,null,t.children)}function _e(t){const n=!!p.useMaybeTrackRefContext();return t.trackRef&&!n?e.createElement(p.TrackRefContext.Provider,{value:t.trackRef},t.children):e.createElement(e.Fragment,null,t.children)}const j=e.forwardRef(function({trackRef:n,children:a,onParticipantClick:r,disableSpeakingIndicator:c,...o},u){var k,g;const l=p.useEnsureTrackRef(n),{elementProps:i}=p.useParticipantTile({htmlProps:o,disableSpeakingIndicator:c,onParticipantClick:r,trackRef:l}),m=p.useIsEncrypted(l.participant),s=p.useMaybeLayoutContext(),f=(k=Ee())==null?void 0:k.autoSubscription,d=e.useCallback(v=>{l.source&&!v&&s&&s.pin.dispatch&&E.isTrackReferencePinned(l,s.pin.state)&&s.pin.dispatch({msg:"clear_pin"})},[l,s]);return e.createElement("div",{ref:u,style:{position:"relative"},...i},e.createElement(_e,{trackRef:l},e.createElement(Ze,{participant:l.participant},a??e.createElement(e.Fragment,null,E.isTrackReference(l)&&(((g=l.publication)==null?void 0:g.kind)==="video"||l.source===w.Track.Source.Camera||l.source===w.Track.Source.ScreenShare)?e.createElement(Oe,{trackRef:l,onSubscriptionStatusChanged:d,manageSubscription:f}):E.isTrackReference(l)&&e.createElement($,{trackRef:l,onSubscriptionStatusChanged:d}),e.createElement("div",{className:"lk-participant-placeholder"},e.createElement(ce,null)),e.createElement("div",{className:"lk-participant-metadata"},e.createElement("div",{className:"lk-participant-metadata-item"},l.source===w.Track.Source.Camera?e.createElement(e.Fragment,null,m&&e.createElement(Te,{style:{marginRight:"0.25rem"}}),e.createElement(re,{trackRef:{participant:l.participant,source:w.Track.Source.Microphone},show:"muted"}),e.createElement(B,null)):e.createElement(e.Fragment,null,e.createElement(te,{style:{marginRight:"0.25rem"}}),e.createElement(B,null,"'s screen"))),e.createElement(ae,{className:"lk-participant-metadata-item"}))),e.createElement(De,{trackRef:l}))))});function Be(t){const n=V(t,{className:"lk-focus-layout"});return e.createElement("div",{...n},t.children)}function je({trackRef:t,...n}){return e.createElement(j,{trackRef:t,...n})}function U({tracks:t,...n}){return e.createElement(e.Fragment,null,t.map(a=>e.createElement(p.TrackRefContext.Provider,{value:a,key:E.getTrackReferenceId(a)},H(n.children))))}function Nt({totalPageCount:t,nextPage:n,prevPage:a,currentPage:r,pagesContainer:c}){const[o,u]=e.useState(!1);return e.useEffect(()=>{let l;return c&&(l=E.createInteractingObservable(c.current,2e3).subscribe(u)),()=>{l&&l.unsubscribe()}},[c]),e.createElement("div",{className:"lk-pagination-control","data-lk-user-interaction":o},e.createElement("button",{className:"lk-button",onClick:a},e.createElement(K,null)),e.createElement("span",{className:"lk-pagination-count"},`${r} of ${t}`),e.createElement("button",{className:"lk-button",onClick:n},e.createElement(K,null)))}const At=e.forwardRef(function({totalPageCount:n,currentPage:a},r){const c=new Array(n).fill("").map((o,u)=>u+1===a?e.createElement("span",{"data-lk-active":!0,key:u}):e.createElement("span",{key:u}));return e.createElement("div",{ref:r,className:"lk-pagination-indicator"},c)});function He({tracks:t,...n}){const a=e.createRef(),r=e.useMemo(()=>V(n,{className:"lk-grid-layout"}),[n]),{layout:c}=p.useGridLayout(a,t.length),o=p.usePagination(c.maxTiles,t);return p.useSwipe(a,{onLeftSwipe:o.nextPage,onRightSwipe:o.prevPage}),e.createElement("div",{ref:a,"data-lk-pagination":o.totalPageCount>1,...r},e.createElement(U,{tracks:o.tracks},n.children),t.length>c.maxTiles&&e.createElement(e.Fragment,null,e.createElement(At,{totalPageCount:o.totalPageCount,currentPage:o.currentPage}),e.createElement(Nt,{pagesContainer:a,...o})))}const Lt=130,xt=140,ge=1,$e=16/10,Vt=(1-$e)*-1;function Ue({tracks:t,orientation:n,...a}){const r=e.useRef(null),[c,o]=e.useState(0),{width:u,height:l}=p.useSize(r),i=n||(l>=u?"vertical":"horizontal"),m=i==="vertical"?Math.max(u*Vt,Lt):Math.max(l*$e,xt),s=E.getScrollBarWidth(),f=Math.max(i==="vertical"?(l-s)/m:(u-s)/m,ge);let d=Math.round(f);Math.abs(f-c)<.5?d=Math.round(c):c!==f&&o(f);const k=p.useVisualStableUpdate(t,d);return e.useLayoutEffect(()=>{r.current&&(r.current.dataset.lkOrientation=i,r.current.style.setProperty("--lk-max-visible-tiles",d.toString()))},[d,i]),e.createElement("aside",{key:i,className:"lk-carousel",ref:r,...a},e.createElement(U,{tracks:k},a.children))}function le({value:t,onPinChange:n,onWidgetChange:a,children:r}){const c=p.useEnsureCreateLayoutContext(t);return e.useEffect(()=>{E.log.debug("PinState Updated",{state:c.pin.state}),n&&c.pin.state&&n(c.pin.state)},[c.pin.state,n]),e.useEffect(()=>{E.log.debug("Widget Updated",{widgetState:c.widget.state}),a&&c.widget.state&&a(c.widget.state)},[a,c.widget.state]),e.createElement(p.LayoutContext.Provider,{value:c},r)}function qe({volume:t,muted:n}){const a=p.useTracks([w.Track.Source.Microphone,w.Track.Source.ScreenShareAudio,w.Track.Source.Unknown],{updateOnlyOn:[],onlySubscribed:!0}).filter(r=>!E.isLocal(r.participant)&&r.publication.kind===w.Track.Kind.Audio);return e.createElement("div",{style:{display:"none"}},a.map(r=>e.createElement($,{key:E.getTrackReferenceId(r),trackRef:r,volume:t,muted:n})))}function Qe(t){const n=e.useMemo(()=>V(t,{className:"lk-toast"}),[t]);return e.createElement("div",{...n},t.children)}const Dt=t=>{const n=[];for(let a=0;a<t;a++)n.push([a,t-1-a]);return n},ve=t=>[[Math.floor(t/2)],[-1]],Ft=(t,n,a)=>{const[r,c]=N.useState(0),[o,u]=N.useState([[]]);N.useEffect(()=>{if(t==="thinking")u(ve(n));else if(t==="connecting"||t==="initializing"){const i=[...Dt(n)];u(i)}else u(t==="listening"?ve(n):t===void 0?[new Array(n).fill(0).map((i,m)=>m)]:[[]]);c(0)},[t,n]);const l=N.useRef(null);return N.useEffect(()=>{let i=performance.now();const m=s=>{s-i>=a&&(c(d=>d+1),i=s),l.current=requestAnimationFrame(m)};return l.current=requestAnimationFrame(m),()=>{l.current!==null&&cancelAnimationFrame(l.current)}},[a,n,t,o.length]),o[r%o.length]},zt=new Map([["connecting",2e3],["initializing",2e3],["listening",500],["thinking",150]]),Ot=(t,n)=>{if(t===void 0)return 1e3;let a=zt.get(t);if(a)switch(t){case"connecting":a/=n;break}return a},ie=e.forwardRef(function({state:n,options:a,barCount:r=15,trackRef:c,children:o,...u},l){const i=V(u,{className:"lk-audio-bar-visualizer"});let m=p.useMaybeTrackRefContext();c&&(m=c);const s=p.useMultibandTrackVolume(m,{bands:r,loPass:100,hiPass:200}),f=(a==null?void 0:a.minHeight)??20,d=(a==null?void 0:a.maxHeight)??100,k=Ft(n,r,Ot(n,r)??100);return e.createElement("div",{ref:l,...i,"data-lk-va-state":n},s.map((g,v)=>o?H(o,{"data-lk-highlighted":k.includes(v),"data-lk-bar-index":v,class:"lk-audio-bar",style:{height:`${Math.min(d,Math.max(f,g*100+5))}%`}}):e.createElement("span",{key:v,"data-lk-highlighted":k.includes(v),"data-lk-bar-index":v,className:`lk-audio-bar ${k.includes(v)&&"lk-highlighted"}`,style:{height:`${Math.min(d,Math.max(f,g*100+5))}%`}})))}),Ge=e.forwardRef(function({children:n,disableSpeakingIndicator:a,onParticipantClick:r,trackRef:c,...o},u){const l=p.useEnsureTrackRef(c),{elementProps:i}=p.useParticipantTile({trackRef:l,htmlProps:o,disableSpeakingIndicator:a,onParticipantClick:r});return e.createElement("div",{ref:u,style:{position:"relative",minHeight:"160px"},...i},e.createElement(p.TrackRefContext.Provider,{value:l},n??e.createElement(e.Fragment,null,E.isTrackReference(l)&&e.createElement($,{trackRef:l}),e.createElement(ie,{barCount:7,options:{minHeight:8}}),e.createElement("div",{className:"lk-participant-metadata"},e.createElement("div",{className:"lk-participant-metadata-item"},e.createElement(re,{trackRef:l}),e.createElement(B,null)),e.createElement(ae,{className:"lk-participant-metadata-item"})))))});function We(t){const[n,a]=e.useState(void 0),r=p.useConnectionState(t.room);return e.useEffect(()=>{switch(r){case w.ConnectionState.Reconnecting:a(e.createElement(e.Fragment,null,e.createElement(J,{className:"lk-spinner"})," Reconnecting"));break;case w.ConnectionState.Connecting:a(e.createElement(e.Fragment,null,e.createElement(J,{className:"lk-spinner"})," Connecting"));break;case w.ConnectionState.Disconnected:a(e.createElement(e.Fragment,null,"Disconnected"));break;default:a(void 0);break}},[r]),n?e.createElement(Qe,{className:"lk-toast-connection-state"},n):e.createElement(e.Fragment,null)}const Ke=e.forwardRef(function({entry:n,hideName:a=!1,hideTimestamp:r=!1,messageFormatter:c,...o},u){var f,d,k;const l=e.useMemo(()=>c?c(n.message):n.message,[n.message,c]),i=!!n.editTimestamp,m=new Date(n.timestamp),s=navigator?navigator.language:"en-US";return e.createElement("li",{ref:u,className:"lk-chat-entry",title:m.toLocaleTimeString(s,{timeStyle:"full"}),"data-lk-message-origin":(f=n.from)!=null&&f.isLocal?"local":"remote",...o},(!r||!a||i)&&e.createElement("span",{className:"lk-meta-data"},!a&&e.createElement("strong",{className:"lk-participant-name"},((d=n.from)==null?void 0:d.name)??((k=n.from)==null?void 0:k.identity)),(!r||i)&&e.createElement("span",{className:"lk-timestamp"},i&&"edited ",m.toLocaleTimeString(s,{timeStyle:"short"}))),e.createElement("span",{className:"lk-message-body"},l))});function Zt(t){return E.tokenize(t,E.createDefaultGrammar()).map((n,a)=>{if(typeof n=="string")return n;{const r=n.content.toString(),c=n.type==="url"?/^http(s?):\/\//.test(r)?r:`https://${r}`:`mailto:${r}`;return e.createElement("a",{className:"lk-chat-link",key:a,href:c,target:"_blank",rel:"noreferrer"},r)}})}function oe({messageFormatter:t,messageDecoder:n,messageEncoder:a,channelTopic:r,...c}){const o=e.useRef(null),u=e.useRef(null),l=e.useMemo(()=>({messageDecoder:n,messageEncoder:a,channelTopic:r}),[n,a,r]),{send:i,chatMessages:m,isSending:s}=p.useChat(l),f=p.useMaybeLayoutContext(),d=e.useRef(0);async function k(g){g.preventDefault(),o.current&&o.current.value.trim()!==""&&i&&(await i(o.current.value),o.current.value="",o.current.focus())}return e.useEffect(()=>{var g;u&&((g=u.current)==null||g.scrollTo({top:u.current.scrollHeight}))},[u,m]),e.useEffect(()=>{var h,b,C,y,M;if(!f||m.length===0)return;if((h=f.widget.state)!=null&&h.showChat&&m.length>0&&d.current!==((b=m[m.length-1])==null?void 0:b.timestamp)){d.current=(C=m[m.length-1])==null?void 0:C.timestamp;return}const g=m.filter(T=>!d.current||T.timestamp>d.current).length,{widget:v}=f;g>0&&((y=v.state)==null?void 0:y.unreadMessages)!==g&&((M=v.dispatch)==null||M.call(v,{msg:"unread_msg",count:g}))},[m,f==null?void 0:f.widget]),e.createElement("div",{...c,className:"lk-chat"},e.createElement("div",{className:"lk-chat-header"},"Messages",e.createElement(Y,{className:"lk-close-button"},e.createElement(we,null))),e.createElement("ul",{className:"lk-list lk-chat-messages",ref:u},c.children?m.map((g,v)=>H(c.children,{entry:g,key:g.id??v,messageFormatter:t})):m.map((g,v,h)=>{const b=v>=1&&h[v-1].from===g.from,C=v>=1&&g.timestamp-h[v-1].timestamp<6e4;return e.createElement(Ke,{key:g.id??v,hideName:b,hideTimestamp:b===!1?!1:C,entry:g,messageFormatter:t})})),e.createElement("form",{className:"lk-chat-form",onSubmit:k},e.createElement("input",{className:"lk-form-control lk-chat-form-input",disabled:s,ref:o,type:"text",placeholder:"Enter a message...",onInput:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),onKeyUp:g=>g.stopPropagation()}),e.createElement("button",{type:"submit",className:"lk-button lk-chat-form-button",disabled:s},"Send")))}function O({kind:t,initialSelection:n,onActiveDeviceChange:a,tracks:r,requestPermissions:c=!1,...o}){const[u,l]=e.useState(!1),[i,m]=e.useState([]),[s,f]=e.useState(!0),[d,k]=e.useState(c),g=(C,y)=>{E.log.debug("handle device change"),l(!1),a==null||a(C,y)},v=e.useRef(null),h=e.useRef(null);e.useLayoutEffect(()=>{u&&k(!0)},[u]),e.useLayoutEffect(()=>{v.current&&h.current&&(i||s)&&E.computeMenuPosition(v.current,h.current).then(({x:C,y})=>{h.current&&Object.assign(h.current.style,{left:`${C}px`,top:`${y}px`})}),f(!1)},[v,h,i,s]);const b=e.useCallback(C=>{h.current&&C.target!==v.current&&u&&E.wasClickOutside(h.current,C)&&l(!1)},[u,h,v]);return e.useEffect(()=>(document.addEventListener("click",b),window.addEventListener("resize",()=>f(!0)),()=>{document.removeEventListener("click",b),window.removeEventListener("resize",()=>f(!0))}),[b,f]),e.createElement(e.Fragment,null,e.createElement("button",{className:"lk-button lk-button-menu","aria-pressed":u,...o,onClick:()=>l(!u),ref:v},o.children),!o.disabled&&e.createElement("div",{className:"lk-device-menu",ref:h,style:{visibility:u?"visible":"hidden"}},t?e.createElement(_,{initialSelection:n,onActiveDeviceChange:C=>g(t,C),onDeviceListChange:m,kind:t,track:r==null?void 0:r[t],requestPermissions:d}):e.createElement(e.Fragment,null,e.createElement("div",{className:"lk-device-menu-heading"},"Audio inputs"),e.createElement(_,{kind:"audioinput",onActiveDeviceChange:C=>g("audioinput",C),onDeviceListChange:m,track:r==null?void 0:r.audioinput,requestPermissions:d}),e.createElement("div",{className:"lk-device-menu-heading"},"Video inputs"),e.createElement(_,{kind:"videoinput",onActiveDeviceChange:C=>g("videoinput",C),onDeviceListChange:m,track:r==null?void 0:r.videoinput,requestPermissions:d}))))}function se(){e.useEffect(()=>{lt()},[])}function Je(t,n){const[a,r]=e.useState(),c=e.useMemo(()=>new w.Mutex,[]);return e.useEffect(()=>{let o=!1,u=[];return c.lock().then(async l=>{try{(t.audio||t.video)&&(u=await w.createLocalTracks(t),o?u.forEach(i=>i.stop()):r(u))}catch(i){n&&i instanceof Error?n(i):E.log.error(i)}finally{l()}}),()=>{o=!0,u.forEach(l=>{l.stop()})}},[JSON.stringify(t),n,c]),a}function _t(t,n,a){const[r,c]=e.useState(null),[o,u]=e.useState(!1),l=p.useMediaDevices({kind:a}),[i,m]=e.useState(void 0),[s,f]=e.useState(),[d,k]=e.useState(n);e.useEffect(()=>{k(n)},[n]);const g=async(b,C)=>{try{const y=C==="videoinput"?await w.createLocalVideoTrack({deviceId:b,resolution:w.VideoPresets.h720.resolution}):await w.createLocalAudioTrack({deviceId:b}),M=await y.getDeviceId();M&&b!==M&&(h.current=M,k(M)),f(y)}catch(y){y instanceof Error&&c(y)}},v=async(b,C)=>{await b.setDeviceId(C),h.current=C},h=e.useRef(d);return e.useEffect(()=>{t&&!s&&!r&&!o&&(E.log.debug("creating track",a),u(!0),g(d,a).finally(()=>{u(!1)}))},[t,s,r,o]),e.useEffect(()=>{s&&(t?i!=null&&i.deviceId&&h.current!==(i==null?void 0:i.deviceId)?(E.log.debug(`switching ${a} device from`,h.current,i.deviceId),v(s,i.deviceId)):(E.log.debug(`unmuting local ${a} track`),s.unmute()):(E.log.debug(`muting ${a} track`),s.mute().then(()=>E.log.debug(s.mediaStreamTrack))))},[s,i,t,a]),e.useEffect(()=>()=>{s&&(E.log.debug(`stopping local ${a} track`),s.stop(),s.mute())},[]),e.useEffect(()=>{m(l==null?void 0:l.find(b=>b.deviceId===d))},[d,l]),{selectedDevice:i,localTrack:s,deviceError:r}}function Bt({defaults:t={},onValidate:n,onSubmit:a,onError:r,debug:c,joinLabel:o="Join Room",micLabel:u="Microphone",camLabel:l="Camera",userLabel:i="Username",persistUserChoices:m=!0,...s}){const[f,d]=e.useState(E.defaultUserChoices),k={...t.audioDeviceId!==void 0&&{audioDeviceId:t.audioDeviceId},...t.videoDeviceId!==void 0&&{videoDeviceId:t.videoDeviceId},...t.audioEnabled!==void 0&&{audioEnabled:t.audioEnabled},...t.videoEnabled!==void 0&&{videoEnabled:t.videoEnabled},...t.username!==void 0&&{username:t.username}},{userChoices:g,saveAudioInputDeviceId:v,saveAudioInputEnabled:h,saveVideoInputDeviceId:b,saveVideoInputEnabled:C,saveUsername:y}=p.usePersistentUserChoices({defaults:k,preventSave:!m,preventLoad:!m}),[M,T]=e.useState(g.audioEnabled),[S,P]=e.useState(g.videoEnabled),[A,F]=e.useState(g.audioDeviceId),[R,x]=e.useState(g.videoDeviceId),[Z,Xe]=e.useState(g.username);e.useEffect(()=>{h(M)},[M,h]),e.useEffect(()=>{C(S)},[S,C]),e.useEffect(()=>{v(A)},[A,v]),e.useEffect(()=>{b(R)},[R,b]),e.useEffect(()=>{y(Z)},[Z,y]);const D=Je({audio:M?{deviceId:g.audioDeviceId}:!1,video:S?{deviceId:g.videoDeviceId}:!1},r),q=e.useRef(null),L=e.useMemo(()=>D==null?void 0:D.filter(I=>I.kind===w.Track.Kind.Video)[0],[D]),Ye=e.useMemo(()=>{if(L){const{facingMode:I}=w.facingModeFromLocalTrack(L);return I}else return"undefined"},[L]),de=e.useMemo(()=>D==null?void 0:D.filter(I=>I.kind===w.Track.Kind.Audio)[0],[D]);e.useEffect(()=>(q.current&&L&&(L.unmute(),L.attach(q.current)),()=>{L==null||L.detach()}),[L]);const[et,tt]=e.useState(),Q=e.useCallback(I=>typeof n=="function"?n(I):I.username!=="",[n]);e.useEffect(()=>{const I={username:Z,videoEnabled:S,videoDeviceId:R,audioEnabled:M,audioDeviceId:A};d(I),tt(Q(I))},[Z,S,Q,M,A,R]);function nt(I){I.preventDefault(),Q(f)?typeof a=="function"&&a(f):E.log.warn("Validation failed with: ",f)}return se(),e.createElement("div",{className:"lk-prejoin",...s},e.createElement("div",{className:"lk-video-container"},L&&e.createElement("video",{ref:q,width:"1280",height:"720","data-lk-facing-mode":Ye}),(!L||!S)&&e.createElement("div",{className:"lk-camera-off-note"},e.createElement(ce,null))),e.createElement("div",{className:"lk-button-group-container"},e.createElement("div",{className:"lk-button-group audio"},e.createElement(z,{initialState:M,source:w.Track.Source.Microphone,onChange:I=>T(I)},u),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(O,{initialSelection:A,kind:"audioinput",disabled:!de,tracks:{audioinput:de},onActiveDeviceChange:(I,G)=>F(G)}))),e.createElement("div",{className:"lk-button-group video"},e.createElement(z,{initialState:S,source:w.Track.Source.Camera,onChange:I=>P(I)},l),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(O,{initialSelection:R,kind:"videoinput",disabled:!L,tracks:{videoinput:L},onActiveDeviceChange:(I,G)=>x(G)})))),e.createElement("form",{className:"lk-username-container"},e.createElement("input",{className:"lk-form-control",id:"username",name:"username",type:"text",defaultValue:Z,placeholder:i,onChange:I=>Xe(I.target.value),autoComplete:"off"}),e.createElement("button",{className:"lk-button lk-join-button",type:"submit",onClick:nt,disabled:!et},o)),c&&e.createElement(e.Fragment,null,e.createElement("strong",null,"User Choices:"),e.createElement("ul",{className:"lk-list",style:{overflow:"hidden",maxWidth:"15rem"}},e.createElement("li",null,"Username: ",`${f.username}`),e.createElement("li",null,"Video Enabled: ",`${f.videoEnabled}`),e.createElement("li",null,"Audio Enabled: ",`${f.audioEnabled}`),e.createElement("li",null,"Video Device: ",`${f.videoDeviceId}`),e.createElement("li",null,"Audio Device: ",`${f.audioDeviceId}`))))}function jt({props:t}){const{dispatch:n,state:a}=p.useLayoutContext().widget,r="lk-button lk-settings-toggle";return{mergedProps:e.useMemo(()=>p.mergeProps(t,{className:r,onClick:()=>{n&&n({msg:"toggle_settings"})},"aria-pressed":a!=null&&a.showSettings?"true":"false"}),[t,r,n,a])}}const Ht=e.forwardRef(function(n,a){const{mergedProps:r}=jt({props:n});return e.createElement("button",{ref:a,...r},n.children)});function ue({variation:t,controls:n,saveUserChoices:a=!0,onDeviceError:r,...c}){var F;const[o,u]=e.useState(!1),l=p.useMaybeLayoutContext();e.useEffect(()=>{var R,x;((R=l==null?void 0:l.widget.state)==null?void 0:R.showChat)!==void 0&&u((x=l==null?void 0:l.widget.state)==null?void 0:x.showChat)},[(F=l==null?void 0:l.widget.state)==null?void 0:F.showChat]);const m=rt(`(max-width: ${o?1e3:760}px)`)?"minimal":"verbose";t??(t=m);const s={leave:!0,...n},f=p.useLocalParticipantPermissions();f?(s.camera??(s.camera=f.canPublish),s.microphone??(s.microphone=f.canPublish),s.screenShare??(s.screenShare=f.canPublish),s.chat??(s.chat=f.canPublishData&&(n==null?void 0:n.chat))):(s.camera=!1,s.chat=!1,s.microphone=!1,s.screenShare=!1);const d=e.useMemo(()=>t==="minimal"||t==="verbose",[t]),k=e.useMemo(()=>t==="textOnly"||t==="verbose",[t]),g=E.supportsScreenSharing(),[v,h]=e.useState(!1),b=e.useCallback(R=>{h(R)},[h]),C=V({className:"lk-control-bar"},c),{saveAudioInputEnabled:y,saveVideoInputEnabled:M,saveAudioInputDeviceId:T,saveVideoInputDeviceId:S}=p.usePersistentUserChoices({preventSave:!a}),P=e.useCallback((R,x)=>x?y(R):null,[y]),A=e.useCallback((R,x)=>x?M(R):null,[M]);return e.createElement("div",{...C},s.microphone&&e.createElement("div",{className:"lk-button-group"},e.createElement(z,{source:w.Track.Source.Microphone,showIcon:d,onChange:P,onDeviceError:R=>r==null?void 0:r({source:w.Track.Source.Microphone,error:R})},k&&"Microphone"),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(O,{kind:"audioinput",onActiveDeviceChange:(R,x)=>T(x??"")}))),s.camera&&e.createElement("div",{className:"lk-button-group"},e.createElement(z,{source:w.Track.Source.Camera,showIcon:d,onChange:A,onDeviceError:R=>r==null?void 0:r({source:w.Track.Source.Camera,error:R})},k&&"Camera"),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(O,{kind:"videoinput",onActiveDeviceChange:(R,x)=>S(x??"")}))),s.screenShare&&g&&e.createElement(z,{source:w.Track.Source.ScreenShare,captureOptions:{audio:!0,selfBrowserSurface:"include"},showIcon:d,onChange:b,onDeviceError:R=>r==null?void 0:r({source:w.Track.Source.ScreenShare,error:R})},k&&(v?"Stop screen share":"Share screen")),s.chat&&e.createElement(Y,null,d&&e.createElement(be,null),k&&"Chat"),s.settings&&e.createElement(Ht,null,d&&e.createElement(ye,null),k&&"Settings"),s.leave&&e.createElement(ee,null,d&&e.createElement(Me,null),k&&"Leave"),e.createElement(ne,null))}function $t({chatMessageFormatter:t,chatMessageDecoder:n,chatMessageEncoder:a,SettingsComponent:r,...c}){var g,v;const[o,u]=e.useState({showChat:!1,unreadMessages:0,showSettings:!1}),l=e.useRef(null),i=p.useTracks([{source:w.Track.Source.Camera,withPlaceholder:!0},{source:w.Track.Source.ScreenShare,withPlaceholder:!1}],{updateOnlyOn:[w.RoomEvent.ActiveSpeakersChanged],onlySubscribed:!1}),m=h=>{E.log.debug("updating widget state",h),u(h)},s=p.useCreateLayoutContext(),f=i.filter(E.isTrackReference).filter(h=>h.publication.source===w.Track.Source.ScreenShare),d=(g=p.usePinnedTracks(s))==null?void 0:g[0],k=i.filter(h=>!E.isEqualTrackRef(h,d));return e.useEffect(()=>{var h,b,C,y,M,T;if(f.some(S=>S.publication.isSubscribed)&&l.current===null?(E.log.debug("Auto set screen share focus:",{newScreenShareTrack:f[0]}),(b=(h=s.pin).dispatch)==null||b.call(h,{msg:"set_pin",trackReference:f[0]}),l.current=f[0]):l.current&&!f.some(S=>{var P,A;return S.publication.trackSid===((A=(P=l.current)==null?void 0:P.publication)==null?void 0:A.trackSid)})&&(E.log.debug("Auto clearing screen share focus."),(y=(C=s.pin).dispatch)==null||y.call(C,{msg:"clear_pin"}),l.current=null),d&&!E.isTrackReference(d)){const S=i.find(P=>P.participant.identity===d.participant.identity&&P.source===d.source);S!==d&&E.isTrackReference(S)&&((T=(M=s.pin).dispatch)==null||T.call(M,{msg:"set_pin",trackReference:S}))}},[f.map(h=>`${h.publication.trackSid}_${h.publication.isSubscribed}`).join(),(v=d==null?void 0:d.publication)==null?void 0:v.trackSid,i]),se(),e.createElement("div",{className:"lk-video-conference",...c},E.isWeb()&&e.createElement(le,{value:s,onWidgetChange:m},e.createElement("div",{className:"lk-video-conference-inner"},d?e.createElement("div",{className:"lk-focus-layout-wrapper"},e.createElement(Be,null,e.createElement(Ue,{tracks:k},e.createElement(j,null)),d&&e.createElement(je,{trackRef:d}))):e.createElement("div",{className:"lk-grid-layout-wrapper"},e.createElement(He,{tracks:i},e.createElement(j,null))),e.createElement(ue,{controls:{chat:!0,settings:!!r}})),e.createElement(oe,{style:{display:o.showChat?"grid":"none"},messageFormatter:t,messageEncoder:a,messageDecoder:n}),r&&e.createElement("div",{className:"lk-settings-menu-modal",style:{display:o.showSettings?"block":"none"}},e.createElement(r,null))),e.createElement(qe,null),e.createElement(We,null))}function Ut({...t}){const[n,a]=e.useState({showChat:!1,unreadMessages:0}),r=p.useTracks([w.Track.Source.Microphone]);return se(),e.createElement(le,{onWidgetChange:a},e.createElement("div",{className:"lk-audio-conference",...t},e.createElement("div",{className:"lk-audio-conference-stage"},e.createElement(U,{tracks:r},e.createElement(Ge,null))),e.createElement(ue,{controls:{microphone:!0,screenShare:!1,camera:!1,chat:!0}}),n.showChat&&e.createElement(oe,null)))}function qt({controls:t,saveUserChoices:n=!0,onDeviceError:a,...r}){const c={leave:!0,microphone:!0,...t},o=p.useLocalParticipantPermissions(),{microphoneTrack:u,localParticipant:l}=E.useLocalParticipant(),i=e.useMemo(()=>({participant:l,source:w.Track.Source.Microphone,publication:u}),[l,u]);o?c.microphone??(c.microphone=o.canPublish):c.microphone=!1;const m=V({className:"lk-agent-control-bar"},r),{saveAudioInputEnabled:s,saveAudioInputDeviceId:f}=p.usePersistentUserChoices({preventSave:!n}),d=e.useCallback((k,g)=>{g&&s(k)},[s]);return e.createElement("div",{...m},c.microphone&&e.createElement("div",{clas