@applica-software-guru/persona-sdk 0.1.91 → 0.1.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,28 @@
1
- "use strict";var xg=Object.defineProperty;var Sg=(h,f,i)=>f in h?xg(h,f,{enumerable:!0,configurable:!0,writable:!0,value:i}):h[f]=i;var W=(h,f,i)=>Sg(h,typeof f!="symbol"?f+"":f,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Zi=require("react/jsx-runtime"),j=require("react"),xr=require("@assistant-ui/react");let Ag=0;function bg(){return`msg_${Date.now()}_${Ag++}`}function Cg(h){return h.thought&&(h={...h,type:"reasoning"}),h.id?h.createdAt?h:{...h,createdAt:new Date}:{...h,id:bg(),createdAt:h.createdAt||new Date}}function Ig(h){return h.filter(f=>f.finishReason==="stop"?f.text!==null&&f.text.trim()!=="":!0)}function ee(h){const f=[];let i=null;for(let _ of h)if(_=Cg(_),_.type!=="transaction")if(_.file){i&&(f.push(i),i=null),f.push(_);continue}else _.functionCalls?(i&&f.push(i),f.push(_),i=null):_.functionResponse?f[f.length-1]={...f[f.length-1],functionResponse:_.functionResponse}:i&&_.type===i.type&&_.protocol===i.protocol&&i.role===_.role&&(_.id===i.id||!i.finishReason)?(i.text+=_.text,i.file=i.file||_.file,i.finishReason=_.finishReason||i.finishReason,i.id=i.id||_.id,i.sources=i.sources?[...i.sources||[],..._.sources||[]]:_.sources):(i&&f.push(i),i={..._,text:_.file?"":_.text,finishReason:_.file?void 0:_.finishReason});return i&&f.push(i),Ig(f)}function Rg(h){var _,v,x;const f=h.file?[{type:"file",data:h.file.url,mimeType:h.file.contentType}]:[];let i;if((h.role==="assistant"||h.role==="function")&&(h.status?i=h.status:h.finishReason==="stop"?i={type:"complete",reason:"stop"}:h.finishReason==="function_call"?i={type:"complete",reason:"stop"}:h.finishReason||(i=void 0)),h.role==="function"){const T={id:h.id,role:"assistant",createdAt:h.createdAt,content:((_=h.functionCalls)==null?void 0:_.map(b=>{var B;return{type:"tool-call",toolName:b.name,toolCallId:b.id||`tool_${Date.now()}`,args:b.args,result:(B=h.functionResponse)==null?void 0:B.result}}))??[],metadata:{...h.metadata,custom:{protocol:h.protocol,sessionId:h.sessionId,sources:h.sources,...(v=h.metadata)==null?void 0:v.custom}}};return i?{...T,status:i}:T}const p={id:h.id,role:h.role,createdAt:h.createdAt,content:h.type==="reasoning"?[{type:"reasoning",text:h.text},...f]:[{type:"text",text:h.text},...f],metadata:{...h.metadata,custom:{protocol:h.protocol,sessionId:h.sessionId,sources:h.sources,type:h.type,...(x=h.metadata)==null?void 0:x.custom}}};return h.role==="assistant"&&i?{...p,status:i}:p}class Ce{constructor(){W(this,"statusChangeCallbacks",[]);W(this,"messageCallbacks",[])}addStatusChangeListener(f){this.statusChangeCallbacks.push(f)}addPacketListener(f){this.messageCallbacks.push(f)}async syncSession(f){this.session=f}async notifyPacket(f){this.messageCallbacks.forEach(i=>i(f))}async notifyPackets(f){f.forEach(i=>{this.messageCallbacks.forEach(p=>p(i))})}async setSession(f){this.session=f}async setStatus(f){const i=this.status!==f;this.status=f,i&&this.statusChangeCallbacks.forEach(p=>p(f))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}setAgentContext(f){return this.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:f}})}onTransaction(f){}}class Yi extends Ce{constructor(i){super();W(this,"status");W(this,"autostart");W(this,"session");W(this,"config");W(this,"notify",!0);W(this,"context",{});W(this,"tools",[]);this.config=i,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 100}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){var b,B,C,k,P;const{apiUrl:p,apiKey:_,agentId:v}=this.config,x=this.session??"new";if(i.type==="command"&&((b=i==null?void 0:i.payload)==null?void 0:b.command)=="set_initial_context"){this.context=(B=i==null?void 0:i.payload)==null?void 0:B.arguments;return}else if(i.type==="command"&&((C=i==null?void 0:i.payload)==null?void 0:C.command)=="set_local_tools"){const G=(k=i==null?void 0:i.payload)==null?void 0:k.arguments.tools;(G==null?void 0:G.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const T=i.payload;try{const J=await(await fetch(`${p}/sessions/${x}/messages`,{body:JSON.stringify({agentId:v,userMessage:T,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":_}})).json();this.notifyPackets(J.response.messages.map($=>({type:"message",payload:$})))}catch(G){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(P=this.config.logger)==null||P.error("Error sending packet:",G)}}}class Xi extends Ce{constructor(i){super();W(this,"status");W(this,"autostart");W(this,"session");W(this,"config");W(this,"webSocket");this.config=i,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(i){var p;(p=this.config.logger)==null||p.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var b;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const p=i||this.session||"new";(b=this.config.logger)==null||b.debug("Connecting to WebSocket with sessionId:",p);const _=encodeURIComponent(this.config.apiKey),v=this.config.agentId,x=this.config.userId||"anonymous",T=`${this.config.webSocketUrl}?sessionCode=${p}&agentId=${v}&apiKey=${_}&userId=${encodeURIComponent(x)}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(T),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",B=>{const C=JSON.parse(B.data);this.notifyPacket(C)}),this.webSocket.addEventListener("close",B=>{var C;this.setStatus("disconnected"),this.webSocket=null,B.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(C=this.config.logger)==null||C.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var B;this.setStatus("disconnected"),this.webSocket=null,(B=this.config.logger)==null||B.error("WebSocket connection error")}),Promise.resolve(p)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(1e3,"Normal closure"),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(i){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(i)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class Pg{constructor(f){W(this,"config");W(this,"pc",null);W(this,"ws",null);W(this,"localStream",null);W(this,"remoteStream",new MediaStream);W(this,"audioCtx",null);W(this,"localAnalyser",null);W(this,"remoteAnalyser",null);W(this,"analyzerFrame",null);W(this,"dataChannel",null);W(this,"isConnected",!1);W(this,"visualizerCallbacks",[]);W(this,"messageCallbacks",[]);W(this,"errorCallbacks",[]);W(this,"queuedMessages",[]);this.config=f}async connect(f){var p;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(_){(p=this.config.logger)==null||p.error("Error accessing microphone:",_);return}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers||[{urls:"stun:34.38.108.251:3478"},{urls:"turn:34.38.108.251:3478",username:"webrtc",credential:"webrtc"}]}),this.localStream.getTracks().forEach(_=>{this.pc.addTrack(_,this.localStream)}),this.pc.ontrack=_=>{_.streams[0].getTracks().forEach(x=>{this.remoteStream.addTrack(x)}),this.audioCtx||this._startAnalyzers();const v=new Audio;v.srcObject=this.remoteStream,v.play().catch(x=>{var T;(T=this.config.logger)==null||T.error("Error playing remote audio:",x)})},this.pc.onicecandidate=_=>{var v;_.candidate&&((v=this.ws)==null?void 0:v.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:_.candidate}}))},this.pc.ondatachannel=_=>{const v=_.channel;v.onmessage=x=>{this.messageCallbacks.forEach(T=>{T(x)})},v.onopen=()=>{var x;for(;this.queuedMessages.length>0;){const T=this.queuedMessages.shift();T&&(v.send(JSON.stringify(T)),(x=this.config.logger)==null||x.info("Sent queued message:",T))}}};const i=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${i}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var T,b;const _=await this.pc.createOffer();await this.pc.setLocalDescription(_);const v={apiKey:this.config.apiKey,agentId:this.config.agentId,userId:this.config.userId||"anonymous",sessionCode:f};(T=this.config.logger)==null||T.debug("Opening connection to WebRTC server: ",v);const x={type:"OFFER",src:((b=crypto.randomUUID)==null?void 0:b.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:_.sdp,type:_.type},connectionId:(Date.now()%1e6).toString(),metadata:v}};this.ws.send(JSON.stringify(x))},this.ws.onmessage=async _=>{var x;const v=JSON.parse(_.data);if(v.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(v.payload.sdp));else if(v.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(v.payload.candidate))}catch(T){(x=this.config.logger)==null||x.error("Error adding ICE candidate:",T)}},this.ws.onclose=_=>{_.code!==1e3&&this.errorCallbacks.forEach(v=>{v("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var f;this.isConnected&&(this.isConnected=!1,((f=this.ws)==null?void 0:f.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(i=>i.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(f){this.visualizerCallbacks.push(f)}addMessageCallback(f){this.messageCallbacks.push(f)}addErrorCallback(f){this.errorCallbacks.push(f)}createDataChannel(f="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(f),this.dataChannel.onopen=()=>{var i,p;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const _=this.queuedMessages.shift();_&&(this.dataChannel.send(JSON.stringify(_)),(p=this.config.logger)==null||p.info("Sent queued message:",_))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(p=>{p(i)})})}sendPacket(f){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(f);return}this.dataChannel.send(JSON.stringify(f)),(i=this.config.logger)==null||i.info("Sent message:",f)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const f=this.audioCtx.createMediaStreamSource(this.localStream),i=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,f.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const p=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const _=new Uint8Array(this.localAnalyser.frequencyBinCount),v=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(_),this.remoteAnalyser.getByteFrequencyData(v);const x=_.reduce((b,B)=>b+B,0)/_.length,T=v.reduce((b,B)=>b+B,0)/v.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(b=>{b({localAmplitude:x,remoteAmplitude:T})}),this.analyzerFrame=requestAnimationFrame(p)};this.analyzerFrame=requestAnimationFrame(p)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class Qi extends Ce{constructor(i){super();W(this,"status");W(this,"session");W(this,"autostart");W(this,"config");W(this,"webRTCClient");this.config=i,this.status="disconnected",this.session=null,this.autostart=(i==null?void 0:i.autostart)??!1,this.webRTCClient=new Pg(i),this.webRTCClient.addMessageCallback(p=>{const _=JSON.parse(p.data);this.notifyPacket(_)}),this.webRTCClient.addErrorCallback(p=>{var _;(_=this.config.logger)==null||_.error("WebRTC error:",p),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:p}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(i){super.syncSession(i),this.status==="connected"&&(await this.disconnect(),await this.connect(i))}async connect(i){var p;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(p=this.config.logger)==null||p.debug("Connecting to WebRTC with sessionId:",this.session),await this.webRTCClient.connect(this.session),this.setStatus("connected"),await this.webRTCClient.createDataChannel(),this.session)}async disconnect(){var i,p,_;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(_=(p=this.config)==null?void 0:p.logger)==null||_.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var be=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Eg(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var Sr={exports:{}};/**
1
+ "use strict";var xg=Object.defineProperty;var Sg=(h,f,i)=>f in h?xg(h,f,{enumerable:!0,configurable:!0,writable:!0,value:i}):h[f]=i;var W=(h,f,i)=>Sg(h,typeof f!="symbol"?f+"":f,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Zi=require("react/jsx-runtime"),V=require("react"),xr=require("@assistant-ui/react");let Ag=0;function bg(){return`msg_${Date.now()}_${Ag++}`}function Cg(h){return h.thought&&(h={...h,type:"reasoning"}),h.id?h.createdAt?h:{...h,createdAt:new Date}:{...h,id:bg(),createdAt:h.createdAt||new Date}}function Ig(h){return h.filter(f=>f.finishReason==="stop"?f.text!==null&&f.text.trim()!=="":!0)}function Un(h){const f=[];let i=null;for(let _ of h)if(_=Cg(_),_.type!=="transaction")if(_.file){i&&(f.push(i),i=null),f.push(_);continue}else _.functionCalls?(i&&f.push(i),f.push(_),i=null):_.functionResponse?f[f.length-1]={...f[f.length-1],functionResponse:_.functionResponse}:i&&_.type===i.type&&_.protocol===i.protocol&&i.role===_.role&&(_.id===i.id||!i.finishReason)?(i.text+=_.text,i.file=i.file||_.file,i.finishReason=_.finishReason||i.finishReason,i.id=i.id||_.id,i.sources=i.sources?[...i.sources||[],..._.sources||[]]:_.sources):(i&&f.push(i),i={..._,text:_.file?"":_.text,finishReason:_.file?void 0:_.finishReason});return i&&f.push(i),Ig(f)}function Rg(h){var _,v,x;const f=h.file?[{type:"file",data:h.file.url,mimeType:h.file.contentType}]:[];let i;if((h.role==="assistant"||h.role==="function")&&(h.status?i=h.status:h.finishReason==="stop"?i={type:"complete",reason:"stop"}:h.finishReason==="function_call"?i={type:"complete",reason:"stop"}:h.finishReason||(i=void 0)),h.role==="function"){const E={id:h.id,role:"assistant",createdAt:h.createdAt,content:((_=h.functionCalls)==null?void 0:_.map(b=>{var B;return{type:"tool-call",toolName:b.name,toolCallId:b.id||`tool_${Date.now()}`,args:b.args,result:(B=h.functionResponse)==null?void 0:B.result}}))??[],metadata:{...h.metadata,custom:{protocol:h.protocol,sessionId:h.sessionId,sources:h.sources,...(v=h.metadata)==null?void 0:v.custom}}};return i?{...E,status:i}:E}const p={id:h.id,role:h.role,createdAt:h.createdAt,content:h.type==="reasoning"?[{type:"reasoning",text:h.text},...f]:[{type:"text",text:h.text},...f],metadata:{...h.metadata,custom:{protocol:h.protocol,sessionId:h.sessionId,sources:h.sources,type:h.type,...(x=h.metadata)==null?void 0:x.custom}}};return h.role==="assistant"&&i?{...p,status:i}:p}class Ce{constructor(){W(this,"statusChangeCallbacks",[]);W(this,"messageCallbacks",[])}addStatusChangeListener(f){this.statusChangeCallbacks.push(f)}addPacketListener(f){this.messageCallbacks.push(f)}async syncSession(f){this.session=f}async notifyPacket(f){this.messageCallbacks.forEach(i=>i(f))}async notifyPackets(f){f.forEach(i=>{this.messageCallbacks.forEach(p=>p(i))})}async setSession(f){this.session=f}async setStatus(f){const i=this.status!==f;this.status=f,i&&this.statusChangeCallbacks.forEach(p=>p(f))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}setAgentContext(f){return this.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:f}})}onTransaction(f){}}class Yi extends Ce{constructor(i){super();W(this,"status");W(this,"autostart");W(this,"session");W(this,"config");W(this,"notify",!0);W(this,"context",{});W(this,"tools",[]);this.config=i,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 100}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){var b,B,C,k,P;const{apiUrl:p,apiKey:_,agentId:v}=this.config,x=this.session??"new";if(i.type==="command"&&((b=i==null?void 0:i.payload)==null?void 0:b.command)=="set_initial_context"){this.context=(B=i==null?void 0:i.payload)==null?void 0:B.arguments;return}else if(i.type==="command"&&((C=i==null?void 0:i.payload)==null?void 0:C.command)=="set_local_tools"){const J=(k=i==null?void 0:i.payload)==null?void 0:k.arguments.tools;(J==null?void 0:J.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const E=i.payload;try{const Z=await(await fetch(`${p}/sessions/${x}/messages`,{body:JSON.stringify({agentId:v,userMessage:E,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":_}})).json();this.notifyPackets(Z.response.messages.map($=>({type:"message",payload:$})))}catch(J){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(P=this.config.logger)==null||P.error("Error sending packet:",J)}}}class Xi extends Ce{constructor(i){super();W(this,"status");W(this,"autostart");W(this,"session");W(this,"config");W(this,"webSocket");this.config=i,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(i){var p;(p=this.config.logger)==null||p.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var b;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const p=i||this.session||"new";(b=this.config.logger)==null||b.debug("Connecting to WebSocket with sessionId:",p);const _=encodeURIComponent(this.config.apiKey),v=this.config.agentId,x=this.config.userId||"anonymous",E=`${this.config.webSocketUrl}?sessionCode=${p}&agentId=${v}&apiKey=${_}&userId=${encodeURIComponent(x)}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(E),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",B=>{const C=JSON.parse(B.data);this.notifyPacket(C)}),this.webSocket.addEventListener("close",B=>{var C;this.setStatus("disconnected"),this.webSocket=null,B.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(C=this.config.logger)==null||C.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var B;this.setStatus("disconnected"),this.webSocket=null,(B=this.config.logger)==null||B.error("WebSocket connection error")}),Promise.resolve(p)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(1e3,"Normal closure"),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(i){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(i)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class Pg{constructor(f){W(this,"config");W(this,"pc",null);W(this,"ws",null);W(this,"localStream",null);W(this,"remoteStream",new MediaStream);W(this,"audioCtx",null);W(this,"localAnalyser",null);W(this,"remoteAnalyser",null);W(this,"analyzerFrame",null);W(this,"dataChannel",null);W(this,"isConnected",!1);W(this,"visualizerCallbacks",[]);W(this,"messageCallbacks",[]);W(this,"errorCallbacks",[]);W(this,"queuedMessages",[]);this.config=f}async connect(f){var p;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(_){(p=this.config.logger)==null||p.error("Error accessing microphone:",_);return}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers||[{urls:"stun:34.38.108.251:3478"},{urls:"turn:34.38.108.251:3478",username:"webrtc",credential:"webrtc"}]}),this.localStream.getTracks().forEach(_=>{this.pc.addTrack(_,this.localStream)}),this.pc.ontrack=_=>{_.streams[0].getTracks().forEach(x=>{this.remoteStream.addTrack(x)}),this.audioCtx||this._startAnalyzers();const v=new Audio;v.srcObject=this.remoteStream,v.play().catch(x=>{var E;(E=this.config.logger)==null||E.error("Error playing remote audio:",x)})},this.pc.onicecandidate=_=>{var v;_.candidate&&((v=this.ws)==null?void 0:v.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:_.candidate}}))},this.pc.ondatachannel=_=>{const v=_.channel;v.onmessage=x=>{this.messageCallbacks.forEach(E=>{E(x)})},v.onopen=()=>{var x;for(;this.queuedMessages.length>0;){const E=this.queuedMessages.shift();E&&(v.send(JSON.stringify(E)),(x=this.config.logger)==null||x.info("Sent queued message:",E))}}};const i=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${i}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var E,b;const _=await this.pc.createOffer();await this.pc.setLocalDescription(_);const v={apiKey:this.config.apiKey,agentId:this.config.agentId,userId:this.config.userId||"anonymous",sessionCode:f};(E=this.config.logger)==null||E.debug("Opening connection to WebRTC server: ",v);const x={type:"OFFER",src:((b=crypto.randomUUID)==null?void 0:b.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:_.sdp,type:_.type},connectionId:(Date.now()%1e6).toString(),metadata:v}};this.ws.send(JSON.stringify(x))},this.ws.onmessage=async _=>{var x;const v=JSON.parse(_.data);if(v.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(v.payload.sdp));else if(v.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(v.payload.candidate))}catch(E){(x=this.config.logger)==null||x.error("Error adding ICE candidate:",E)}},this.ws.onclose=_=>{_.code!==1e3&&this.errorCallbacks.forEach(v=>{v("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var f;this.isConnected&&(this.isConnected=!1,((f=this.ws)==null?void 0:f.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(i=>i.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(f){this.visualizerCallbacks.push(f)}addMessageCallback(f){this.messageCallbacks.push(f)}addErrorCallback(f){this.errorCallbacks.push(f)}createDataChannel(f="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(f),this.dataChannel.onopen=()=>{var i,p;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const _=this.queuedMessages.shift();_&&(this.dataChannel.send(JSON.stringify(_)),(p=this.config.logger)==null||p.info("Sent queued message:",_))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(p=>{p(i)})})}sendPacket(f){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(f);return}this.dataChannel.send(JSON.stringify(f)),(i=this.config.logger)==null||i.info("Sent message:",f)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const f=this.audioCtx.createMediaStreamSource(this.localStream),i=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,f.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const p=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const _=new Uint8Array(this.localAnalyser.frequencyBinCount),v=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(_),this.remoteAnalyser.getByteFrequencyData(v);const x=_.reduce((b,B)=>b+B,0)/_.length,E=v.reduce((b,B)=>b+B,0)/v.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(b=>{b({localAmplitude:x,remoteAmplitude:E})}),this.analyzerFrame=requestAnimationFrame(p)};this.analyzerFrame=requestAnimationFrame(p)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class Qi extends Ce{constructor(i){super();W(this,"status");W(this,"session");W(this,"autostart");W(this,"config");W(this,"webRTCClient");this.config=i,this.status="disconnected",this.session=null,this.autostart=(i==null?void 0:i.autostart)??!1,this.webRTCClient=new Pg(i),this.webRTCClient.addMessageCallback(p=>{const _=JSON.parse(p.data);this.notifyPacket(_)}),this.webRTCClient.addErrorCallback(p=>{var _;(_=this.config.logger)==null||_.error("WebRTC error:",p),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:p}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(i){super.syncSession(i),this.status==="connected"&&(await this.disconnect(),await this.connect(i))}async connect(i){var p;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(p=this.config.logger)==null||p.debug("Connecting to WebRTC with sessionId:",this.session),await this.webRTCClient.connect(this.session),this.setStatus("connected"),await this.webRTCClient.createDataChannel(),this.session)}async disconnect(){var i,p,_;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(_=(p=this.config)==null?void 0:p.logger)==null||_.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var be=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Eg(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var Sr={exports:{}};/**
2
2
  * @license
3
3
  * Lodash <https://lodash.com/>
4
4
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
5
5
  * Released under MIT license <https://lodash.com/license>
6
6
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7
7
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8
- */Sr.exports;(function(h,f){(function(){var i,p="4.17.21",_=200,v="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",x="Expected a function",T="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",B=500,C="__lodash_placeholder__",k=1,P=2,G=4,J=1,$=2,_t=1,It=2,Vt=4,st=8,In=16,Ht=32,gn=64,xt=128,Dt=256,Bn=512,Re=30,Rt="...",Pe=800,Mn=16,re=1,ft=2,br=3,rn=1/0,jt=9007199254740991,Cr=17976931348623157e292,$n=NaN,Ft=4294967295,Ee=Ft-1,Ir=Ft>>>1,X=[["ary",xt],["bind",_t],["bindKey",It],["curry",st],["curryRight",In],["flip",Bn],["partial",Ht],["partialRight",gn],["rearg",Dt]],ct="[object Arguments]",zt="[object Array]",Rn="[object AsyncFunction]",_n="[object Boolean]",vt="[object Date]",No="[object DOMException]",Te="[object Error]",Le="[object Function]",Vi="[object GeneratorFunction]",Gt="[object Map]",ie="[object Number]",Uo="[object Null]",un="[object Object]",ji="[object Promise]",Bo="[object Proxy]",ue="[object RegExp]",Jt="[object Set]",se="[object String]",Oe="[object Symbol]",Mo="[object Undefined]",oe="[object WeakMap]",$o="[object WeakSet]",ae="[object ArrayBuffer]",Kn="[object DataView]",Rr="[object Float32Array]",Pr="[object Float64Array]",Er="[object Int8Array]",Tr="[object Int16Array]",Lr="[object Int32Array]",Or="[object Uint8Array]",Wr="[object Uint8ClampedArray]",Dr="[object Uint16Array]",Fr="[object Uint32Array]",Ko=/\b__p \+= '';/g,qo=/\b(__p \+=) '' \+/g,ko=/(__e\(.*?\)|\b__t\)) \+\n'';/g,tu=/&(?:amp|lt|gt|quot|#39);/g,nu=/[&<>"']/g,Ho=RegExp(tu.source),zo=RegExp(nu.source),Go=/<%-([\s\S]+?)%>/g,Jo=/<%([\s\S]+?)%>/g,eu=/<%=([\s\S]+?)%>/g,Zo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yo=/^\w*$/,Xo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Nr=/[\\^$.*+?()[\]{}|]/g,Qo=RegExp(Nr.source),Ur=/^\s+/,Vo=/\s/,jo=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ta=/\{\n\/\* \[wrapped with (.+)\] \*/,na=/,? & /,ea=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ra=/[()=,{}\[\]\/\s]/,ia=/\\(\\)?/g,ua=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ru=/\w*$/,sa=/^[-+]0x[0-9a-f]+$/i,oa=/^0b[01]+$/i,aa=/^\[object .+?Constructor\]$/,fa=/^0o[0-7]+$/i,ca=/^(?:0|[1-9]\d*)$/,la=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,We=/($^)/,ha=/['\n\r\u2028\u2029\\]/g,De="\\ud800-\\udfff",da="\\u0300-\\u036f",pa="\\ufe20-\\ufe2f",ga="\\u20d0-\\u20ff",iu=da+pa+ga,uu="\\u2700-\\u27bf",su="a-z\\xdf-\\xf6\\xf8-\\xff",_a="\\xac\\xb1\\xd7\\xf7",va="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",wa="\\u2000-\\u206f",ya=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ou="A-Z\\xc0-\\xd6\\xd8-\\xde",au="\\ufe0e\\ufe0f",fu=_a+va+wa+ya,Br="['’]",ma="["+De+"]",cu="["+fu+"]",Fe="["+iu+"]",lu="\\d+",xa="["+uu+"]",hu="["+su+"]",du="[^"+De+fu+lu+uu+su+ou+"]",Mr="\\ud83c[\\udffb-\\udfff]",Sa="(?:"+Fe+"|"+Mr+")",pu="[^"+De+"]",$r="(?:\\ud83c[\\udde6-\\uddff]){2}",Kr="[\\ud800-\\udbff][\\udc00-\\udfff]",qn="["+ou+"]",gu="\\u200d",_u="(?:"+hu+"|"+du+")",Aa="(?:"+qn+"|"+du+")",vu="(?:"+Br+"(?:d|ll|m|re|s|t|ve))?",wu="(?:"+Br+"(?:D|LL|M|RE|S|T|VE))?",yu=Sa+"?",mu="["+au+"]?",ba="(?:"+gu+"(?:"+[pu,$r,Kr].join("|")+")"+mu+yu+")*",Ca="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ia="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",xu=mu+yu+ba,Ra="(?:"+[xa,$r,Kr].join("|")+")"+xu,Pa="(?:"+[pu+Fe+"?",Fe,$r,Kr,ma].join("|")+")",Ea=RegExp(Br,"g"),Ta=RegExp(Fe,"g"),qr=RegExp(Mr+"(?="+Mr+")|"+Pa+xu,"g"),La=RegExp([qn+"?"+hu+"+"+vu+"(?="+[cu,qn,"$"].join("|")+")",Aa+"+"+wu+"(?="+[cu,qn+_u,"$"].join("|")+")",qn+"?"+_u+"+"+vu,qn+"+"+wu,Ia,Ca,lu,Ra].join("|"),"g"),Oa=RegExp("["+gu+De+iu+au+"]"),Wa=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Da=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Fa=-1,tt={};tt[Rr]=tt[Pr]=tt[Er]=tt[Tr]=tt[Lr]=tt[Or]=tt[Wr]=tt[Dr]=tt[Fr]=!0,tt[ct]=tt[zt]=tt[ae]=tt[_n]=tt[Kn]=tt[vt]=tt[Te]=tt[Le]=tt[Gt]=tt[ie]=tt[un]=tt[ue]=tt[Jt]=tt[se]=tt[oe]=!1;var V={};V[ct]=V[zt]=V[ae]=V[Kn]=V[_n]=V[vt]=V[Rr]=V[Pr]=V[Er]=V[Tr]=V[Lr]=V[Gt]=V[ie]=V[un]=V[ue]=V[Jt]=V[se]=V[Oe]=V[Or]=V[Wr]=V[Dr]=V[Fr]=!0,V[Te]=V[Le]=V[oe]=!1;var Na={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Ua={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ba={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Ma={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$a=parseFloat,Ka=parseInt,Su=typeof be=="object"&&be&&be.Object===Object&&be,qa=typeof self=="object"&&self&&self.Object===Object&&self,ht=Su||qa||Function("return this")(),kr=f&&!f.nodeType&&f,Pn=kr&&!0&&h&&!h.nodeType&&h,Au=Pn&&Pn.exports===kr,Hr=Au&&Su.process,Nt=function(){try{var l=Pn&&Pn.require&&Pn.require("util").types;return l||Hr&&Hr.binding&&Hr.binding("util")}catch{}}(),bu=Nt&&Nt.isArrayBuffer,Cu=Nt&&Nt.isDate,Iu=Nt&&Nt.isMap,Ru=Nt&&Nt.isRegExp,Pu=Nt&&Nt.isSet,Eu=Nt&&Nt.isTypedArray;function Pt(l,w,g){switch(g.length){case 0:return l.call(w);case 1:return l.call(w,g[0]);case 2:return l.call(w,g[0],g[1]);case 3:return l.call(w,g[0],g[1],g[2])}return l.apply(w,g)}function ka(l,w,g,I){for(var D=-1,z=l==null?0:l.length;++D<z;){var ot=l[D];w(I,ot,g(ot),l)}return I}function Ut(l,w){for(var g=-1,I=l==null?0:l.length;++g<I&&w(l[g],g,l)!==!1;);return l}function Ha(l,w){for(var g=l==null?0:l.length;g--&&w(l[g],g,l)!==!1;);return l}function Tu(l,w){for(var g=-1,I=l==null?0:l.length;++g<I;)if(!w(l[g],g,l))return!1;return!0}function vn(l,w){for(var g=-1,I=l==null?0:l.length,D=0,z=[];++g<I;){var ot=l[g];w(ot,g,l)&&(z[D++]=ot)}return z}function Ne(l,w){var g=l==null?0:l.length;return!!g&&kn(l,w,0)>-1}function zr(l,w,g){for(var I=-1,D=l==null?0:l.length;++I<D;)if(g(w,l[I]))return!0;return!1}function nt(l,w){for(var g=-1,I=l==null?0:l.length,D=Array(I);++g<I;)D[g]=w(l[g],g,l);return D}function wn(l,w){for(var g=-1,I=w.length,D=l.length;++g<I;)l[D+g]=w[g];return l}function Gr(l,w,g,I){var D=-1,z=l==null?0:l.length;for(I&&z&&(g=l[++D]);++D<z;)g=w(g,l[D],D,l);return g}function za(l,w,g,I){var D=l==null?0:l.length;for(I&&D&&(g=l[--D]);D--;)g=w(g,l[D],D,l);return g}function Jr(l,w){for(var g=-1,I=l==null?0:l.length;++g<I;)if(w(l[g],g,l))return!0;return!1}var Ga=Zr("length");function Ja(l){return l.split("")}function Za(l){return l.match(ea)||[]}function Lu(l,w,g){var I;return g(l,function(D,z,ot){if(w(D,z,ot))return I=z,!1}),I}function Ue(l,w,g,I){for(var D=l.length,z=g+(I?1:-1);I?z--:++z<D;)if(w(l[z],z,l))return z;return-1}function kn(l,w,g){return w===w?of(l,w,g):Ue(l,Ou,g)}function Ya(l,w,g,I){for(var D=g-1,z=l.length;++D<z;)if(I(l[D],w))return D;return-1}function Ou(l){return l!==l}function Wu(l,w){var g=l==null?0:l.length;return g?Xr(l,w)/g:$n}function Zr(l){return function(w){return w==null?i:w[l]}}function Yr(l){return function(w){return l==null?i:l[w]}}function Du(l,w,g,I,D){return D(l,function(z,ot,Q){g=I?(I=!1,z):w(g,z,ot,Q)}),g}function Xa(l,w){var g=l.length;for(l.sort(w);g--;)l[g]=l[g].value;return l}function Xr(l,w){for(var g,I=-1,D=l.length;++I<D;){var z=w(l[I]);z!==i&&(g=g===i?z:g+z)}return g}function Qr(l,w){for(var g=-1,I=Array(l);++g<l;)I[g]=w(g);return I}function Qa(l,w){return nt(w,function(g){return[g,l[g]]})}function Fu(l){return l&&l.slice(0,Mu(l)+1).replace(Ur,"")}function Et(l){return function(w){return l(w)}}function Vr(l,w){return nt(w,function(g){return l[g]})}function fe(l,w){return l.has(w)}function Nu(l,w){for(var g=-1,I=l.length;++g<I&&kn(w,l[g],0)>-1;);return g}function Uu(l,w){for(var g=l.length;g--&&kn(w,l[g],0)>-1;);return g}function Va(l,w){for(var g=l.length,I=0;g--;)l[g]===w&&++I;return I}var ja=Yr(Na),tf=Yr(Ua);function nf(l){return"\\"+Ma[l]}function ef(l,w){return l==null?i:l[w]}function Hn(l){return Oa.test(l)}function rf(l){return Wa.test(l)}function uf(l){for(var w,g=[];!(w=l.next()).done;)g.push(w.value);return g}function jr(l){var w=-1,g=Array(l.size);return l.forEach(function(I,D){g[++w]=[D,I]}),g}function Bu(l,w){return function(g){return l(w(g))}}function yn(l,w){for(var g=-1,I=l.length,D=0,z=[];++g<I;){var ot=l[g];(ot===w||ot===C)&&(l[g]=C,z[D++]=g)}return z}function Be(l){var w=-1,g=Array(l.size);return l.forEach(function(I){g[++w]=I}),g}function sf(l){var w=-1,g=Array(l.size);return l.forEach(function(I){g[++w]=[I,I]}),g}function of(l,w,g){for(var I=g-1,D=l.length;++I<D;)if(l[I]===w)return I;return-1}function af(l,w,g){for(var I=g+1;I--;)if(l[I]===w)return I;return I}function zn(l){return Hn(l)?cf(l):Ga(l)}function Zt(l){return Hn(l)?lf(l):Ja(l)}function Mu(l){for(var w=l.length;w--&&Vo.test(l.charAt(w)););return w}var ff=Yr(Ba);function cf(l){for(var w=qr.lastIndex=0;qr.test(l);)++w;return w}function lf(l){return l.match(qr)||[]}function hf(l){return l.match(La)||[]}var df=function l(w){w=w==null?ht:Gn.defaults(ht.Object(),w,Gn.pick(ht,Da));var g=w.Array,I=w.Date,D=w.Error,z=w.Function,ot=w.Math,Q=w.Object,ti=w.RegExp,pf=w.String,Bt=w.TypeError,Me=g.prototype,gf=z.prototype,Jn=Q.prototype,$e=w["__core-js_shared__"],Ke=gf.toString,Y=Jn.hasOwnProperty,_f=0,$u=function(){var t=/[^.]+$/.exec($e&&$e.keys&&$e.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),qe=Jn.toString,vf=Ke.call(Q),wf=ht._,yf=ti("^"+Ke.call(Y).replace(Nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ke=Au?w.Buffer:i,mn=w.Symbol,He=w.Uint8Array,Ku=ke?ke.allocUnsafe:i,ze=Bu(Q.getPrototypeOf,Q),qu=Q.create,ku=Jn.propertyIsEnumerable,Ge=Me.splice,Hu=mn?mn.isConcatSpreadable:i,ce=mn?mn.iterator:i,En=mn?mn.toStringTag:i,Je=function(){try{var t=Dn(Q,"defineProperty");return t({},"",{}),t}catch{}}(),mf=w.clearTimeout!==ht.clearTimeout&&w.clearTimeout,xf=I&&I.now!==ht.Date.now&&I.now,Sf=w.setTimeout!==ht.setTimeout&&w.setTimeout,Ze=ot.ceil,Ye=ot.floor,ni=Q.getOwnPropertySymbols,Af=ke?ke.isBuffer:i,zu=w.isFinite,bf=Me.join,Cf=Bu(Q.keys,Q),at=ot.max,pt=ot.min,If=I.now,Rf=w.parseInt,Gu=ot.random,Pf=Me.reverse,ei=Dn(w,"DataView"),le=Dn(w,"Map"),ri=Dn(w,"Promise"),Zn=Dn(w,"Set"),he=Dn(w,"WeakMap"),de=Dn(Q,"create"),Xe=he&&new he,Yn={},Ef=Fn(ei),Tf=Fn(le),Lf=Fn(ri),Of=Fn(Zn),Wf=Fn(he),Qe=mn?mn.prototype:i,pe=Qe?Qe.valueOf:i,Ju=Qe?Qe.toString:i;function s(t){if(rt(t)&&!F(t)&&!(t instanceof q)){if(t instanceof Mt)return t;if(Y.call(t,"__wrapped__"))return Zs(t)}return new Mt(t)}var Xn=function(){function t(){}return function(n){if(!et(n))return{};if(qu)return qu(n);t.prototype=n;var e=new t;return t.prototype=i,e}}();function Ve(){}function Mt(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=i}s.templateSettings={escape:Go,evaluate:Jo,interpolate:eu,variable:"",imports:{_:s}},s.prototype=Ve.prototype,s.prototype.constructor=s,Mt.prototype=Xn(Ve.prototype),Mt.prototype.constructor=Mt;function q(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ft,this.__views__=[]}function Df(){var t=new q(this.__wrapped__);return t.__actions__=St(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=St(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=St(this.__views__),t}function Ff(){if(this.__filtered__){var t=new q(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Nf(){var t=this.__wrapped__.value(),n=this.__dir__,e=F(t),r=n<0,u=e?t.length:0,o=Zc(0,u,this.__views__),a=o.start,c=o.end,d=c-a,y=r?c:a-1,m=this.__iteratees__,S=m.length,A=0,R=pt(d,this.__takeCount__);if(!e||!r&&u==d&&R==d)return vs(t,this.__actions__);var L=[];t:for(;d--&&A<R;){y+=n;for(var U=-1,O=t[y];++U<S;){var K=m[U],H=K.iteratee,Ot=K.type,mt=H(O);if(Ot==ft)O=mt;else if(!mt){if(Ot==re)continue t;break t}}L[A++]=O}return L}q.prototype=Xn(Ve.prototype),q.prototype.constructor=q;function Tn(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Uf(){this.__data__=de?de(null):{},this.size=0}function Bf(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function Mf(t){var n=this.__data__;if(de){var e=n[t];return e===b?i:e}return Y.call(n,t)?n[t]:i}function $f(t){var n=this.__data__;return de?n[t]!==i:Y.call(n,t)}function Kf(t,n){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=de&&n===i?b:n,this}Tn.prototype.clear=Uf,Tn.prototype.delete=Bf,Tn.prototype.get=Mf,Tn.prototype.has=$f,Tn.prototype.set=Kf;function sn(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function qf(){this.__data__=[],this.size=0}function kf(t){var n=this.__data__,e=je(n,t);if(e<0)return!1;var r=n.length-1;return e==r?n.pop():Ge.call(n,e,1),--this.size,!0}function Hf(t){var n=this.__data__,e=je(n,t);return e<0?i:n[e][1]}function zf(t){return je(this.__data__,t)>-1}function Gf(t,n){var e=this.__data__,r=je(e,t);return r<0?(++this.size,e.push([t,n])):e[r][1]=n,this}sn.prototype.clear=qf,sn.prototype.delete=kf,sn.prototype.get=Hf,sn.prototype.has=zf,sn.prototype.set=Gf;function on(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Jf(){this.size=0,this.__data__={hash:new Tn,map:new(le||sn),string:new Tn}}function Zf(t){var n=lr(this,t).delete(t);return this.size-=n?1:0,n}function Yf(t){return lr(this,t).get(t)}function Xf(t){return lr(this,t).has(t)}function Qf(t,n){var e=lr(this,t),r=e.size;return e.set(t,n),this.size+=e.size==r?0:1,this}on.prototype.clear=Jf,on.prototype.delete=Zf,on.prototype.get=Yf,on.prototype.has=Xf,on.prototype.set=Qf;function Ln(t){var n=-1,e=t==null?0:t.length;for(this.__data__=new on;++n<e;)this.add(t[n])}function Vf(t){return this.__data__.set(t,b),this}function jf(t){return this.__data__.has(t)}Ln.prototype.add=Ln.prototype.push=Vf,Ln.prototype.has=jf;function Yt(t){var n=this.__data__=new sn(t);this.size=n.size}function tc(){this.__data__=new sn,this.size=0}function nc(t){var n=this.__data__,e=n.delete(t);return this.size=n.size,e}function ec(t){return this.__data__.get(t)}function rc(t){return this.__data__.has(t)}function ic(t,n){var e=this.__data__;if(e instanceof sn){var r=e.__data__;if(!le||r.length<_-1)return r.push([t,n]),this.size=++e.size,this;e=this.__data__=new on(r)}return e.set(t,n),this.size=e.size,this}Yt.prototype.clear=tc,Yt.prototype.delete=nc,Yt.prototype.get=ec,Yt.prototype.has=rc,Yt.prototype.set=ic;function Zu(t,n){var e=F(t),r=!e&&Nn(t),u=!e&&!r&&Cn(t),o=!e&&!r&&!u&&te(t),a=e||r||u||o,c=a?Qr(t.length,pf):[],d=c.length;for(var y in t)(n||Y.call(t,y))&&!(a&&(y=="length"||u&&(y=="offset"||y=="parent")||o&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||ln(y,d)))&&c.push(y);return c}function Yu(t){var n=t.length;return n?t[pi(0,n-1)]:i}function uc(t,n){return hr(St(t),On(n,0,t.length))}function sc(t){return hr(St(t))}function ii(t,n,e){(e!==i&&!Xt(t[n],e)||e===i&&!(n in t))&&an(t,n,e)}function ge(t,n,e){var r=t[n];(!(Y.call(t,n)&&Xt(r,e))||e===i&&!(n in t))&&an(t,n,e)}function je(t,n){for(var e=t.length;e--;)if(Xt(t[e][0],n))return e;return-1}function oc(t,n,e,r){return xn(t,function(u,o,a){n(r,u,e(u),a)}),r}function Xu(t,n){return t&&nn(n,lt(n),t)}function ac(t,n){return t&&nn(n,bt(n),t)}function an(t,n,e){n=="__proto__"&&Je?Je(t,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[n]=e}function ui(t,n){for(var e=-1,r=n.length,u=g(r),o=t==null;++e<r;)u[e]=o?i:Mi(t,n[e]);return u}function On(t,n,e){return t===t&&(e!==i&&(t=t<=e?t:e),n!==i&&(t=t>=n?t:n)),t}function $t(t,n,e,r,u,o){var a,c=n&k,d=n&P,y=n&G;if(e&&(a=u?e(t,r,u,o):e(t)),a!==i)return a;if(!et(t))return t;var m=F(t);if(m){if(a=Xc(t),!c)return St(t,a)}else{var S=gt(t),A=S==Le||S==Vi;if(Cn(t))return ms(t,c);if(S==un||S==ct||A&&!u){if(a=d||A?{}:Ms(t),!c)return d?Mc(t,ac(a,t)):Bc(t,Xu(a,t))}else{if(!V[S])return u?t:{};a=Qc(t,S,c)}}o||(o=new Yt);var R=o.get(t);if(R)return R;o.set(t,a),go(t)?t.forEach(function(O){a.add($t(O,n,e,O,t,o))}):ho(t)&&t.forEach(function(O,K){a.set(K,$t(O,n,e,K,t,o))});var L=y?d?Ci:bi:d?bt:lt,U=m?i:L(t);return Ut(U||t,function(O,K){U&&(K=O,O=t[K]),ge(a,K,$t(O,n,e,K,t,o))}),a}function fc(t){var n=lt(t);return function(e){return Qu(e,t,n)}}function Qu(t,n,e){var r=e.length;if(t==null)return!r;for(t=Q(t);r--;){var u=e[r],o=n[u],a=t[u];if(a===i&&!(u in t)||!o(a))return!1}return!0}function Vu(t,n,e){if(typeof t!="function")throw new Bt(x);return Se(function(){t.apply(i,e)},n)}function _e(t,n,e,r){var u=-1,o=Ne,a=!0,c=t.length,d=[],y=n.length;if(!c)return d;e&&(n=nt(n,Et(e))),r?(o=zr,a=!1):n.length>=_&&(o=fe,a=!1,n=new Ln(n));t:for(;++u<c;){var m=t[u],S=e==null?m:e(m);if(m=r||m!==0?m:0,a&&S===S){for(var A=y;A--;)if(n[A]===S)continue t;d.push(m)}else o(n,S,r)||d.push(m)}return d}var xn=Cs(tn),ju=Cs(oi,!0);function cc(t,n){var e=!0;return xn(t,function(r,u,o){return e=!!n(r,u,o),e}),e}function tr(t,n,e){for(var r=-1,u=t.length;++r<u;){var o=t[r],a=n(o);if(a!=null&&(c===i?a===a&&!Lt(a):e(a,c)))var c=a,d=o}return d}function lc(t,n,e,r){var u=t.length;for(e=N(e),e<0&&(e=-e>u?0:u+e),r=r===i||r>u?u:N(r),r<0&&(r+=u),r=e>r?0:vo(r);e<r;)t[e++]=n;return t}function ts(t,n){var e=[];return xn(t,function(r,u,o){n(r,u,o)&&e.push(r)}),e}function dt(t,n,e,r,u){var o=-1,a=t.length;for(e||(e=jc),u||(u=[]);++o<a;){var c=t[o];n>0&&e(c)?n>1?dt(c,n-1,e,r,u):wn(u,c):r||(u[u.length]=c)}return u}var si=Is(),ns=Is(!0);function tn(t,n){return t&&si(t,n,lt)}function oi(t,n){return t&&ns(t,n,lt)}function nr(t,n){return vn(n,function(e){return hn(t[e])})}function Wn(t,n){n=An(n,t);for(var e=0,r=n.length;t!=null&&e<r;)t=t[en(n[e++])];return e&&e==r?t:i}function es(t,n,e){var r=n(t);return F(t)?r:wn(r,e(t))}function wt(t){return t==null?t===i?Mo:Uo:En&&En in Q(t)?Jc(t):sl(t)}function ai(t,n){return t>n}function hc(t,n){return t!=null&&Y.call(t,n)}function dc(t,n){return t!=null&&n in Q(t)}function pc(t,n,e){return t>=pt(n,e)&&t<at(n,e)}function fi(t,n,e){for(var r=e?zr:Ne,u=t[0].length,o=t.length,a=o,c=g(o),d=1/0,y=[];a--;){var m=t[a];a&&n&&(m=nt(m,Et(n))),d=pt(m.length,d),c[a]=!e&&(n||u>=120&&m.length>=120)?new Ln(a&&m):i}m=t[0];var S=-1,A=c[0];t:for(;++S<u&&y.length<d;){var R=m[S],L=n?n(R):R;if(R=e||R!==0?R:0,!(A?fe(A,L):r(y,L,e))){for(a=o;--a;){var U=c[a];if(!(U?fe(U,L):r(t[a],L,e)))continue t}A&&A.push(L),y.push(R)}}return y}function gc(t,n,e,r){return tn(t,function(u,o,a){n(r,e(u),o,a)}),r}function ve(t,n,e){n=An(n,t),t=ks(t,n);var r=t==null?t:t[en(qt(n))];return r==null?i:Pt(r,t,e)}function rs(t){return rt(t)&&wt(t)==ct}function _c(t){return rt(t)&&wt(t)==ae}function vc(t){return rt(t)&&wt(t)==vt}function we(t,n,e,r,u){return t===n?!0:t==null||n==null||!rt(t)&&!rt(n)?t!==t&&n!==n:wc(t,n,e,r,we,u)}function wc(t,n,e,r,u,o){var a=F(t),c=F(n),d=a?zt:gt(t),y=c?zt:gt(n);d=d==ct?un:d,y=y==ct?un:y;var m=d==un,S=y==un,A=d==y;if(A&&Cn(t)){if(!Cn(n))return!1;a=!0,m=!1}if(A&&!m)return o||(o=new Yt),a||te(t)?Ns(t,n,e,r,u,o):zc(t,n,d,e,r,u,o);if(!(e&J)){var R=m&&Y.call(t,"__wrapped__"),L=S&&Y.call(n,"__wrapped__");if(R||L){var U=R?t.value():t,O=L?n.value():n;return o||(o=new Yt),u(U,O,e,r,o)}}return A?(o||(o=new Yt),Gc(t,n,e,r,u,o)):!1}function yc(t){return rt(t)&&gt(t)==Gt}function ci(t,n,e,r){var u=e.length,o=u,a=!r;if(t==null)return!o;for(t=Q(t);u--;){var c=e[u];if(a&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++u<o;){c=e[u];var d=c[0],y=t[d],m=c[1];if(a&&c[2]){if(y===i&&!(d in t))return!1}else{var S=new Yt;if(r)var A=r(y,m,d,t,n,S);if(!(A===i?we(m,y,J|$,r,S):A))return!1}}return!0}function is(t){if(!et(t)||nl(t))return!1;var n=hn(t)?yf:aa;return n.test(Fn(t))}function mc(t){return rt(t)&&wt(t)==ue}function xc(t){return rt(t)&&gt(t)==Jt}function Sc(t){return rt(t)&&wr(t.length)&&!!tt[wt(t)]}function us(t){return typeof t=="function"?t:t==null?Ct:typeof t=="object"?F(t)?as(t[0],t[1]):os(t):Po(t)}function li(t){if(!xe(t))return Cf(t);var n=[];for(var e in Q(t))Y.call(t,e)&&e!="constructor"&&n.push(e);return n}function Ac(t){if(!et(t))return ul(t);var n=xe(t),e=[];for(var r in t)r=="constructor"&&(n||!Y.call(t,r))||e.push(r);return e}function hi(t,n){return t<n}function ss(t,n){var e=-1,r=At(t)?g(t.length):[];return xn(t,function(u,o,a){r[++e]=n(u,o,a)}),r}function os(t){var n=Ri(t);return n.length==1&&n[0][2]?Ks(n[0][0],n[0][1]):function(e){return e===t||ci(e,t,n)}}function as(t,n){return Ei(t)&&$s(n)?Ks(en(t),n):function(e){var r=Mi(e,t);return r===i&&r===n?$i(e,t):we(n,r,J|$)}}function er(t,n,e,r,u){t!==n&&si(n,function(o,a){if(u||(u=new Yt),et(o))bc(t,n,a,e,er,r,u);else{var c=r?r(Li(t,a),o,a+"",t,n,u):i;c===i&&(c=o),ii(t,a,c)}},bt)}function bc(t,n,e,r,u,o,a){var c=Li(t,e),d=Li(n,e),y=a.get(d);if(y){ii(t,e,y);return}var m=o?o(c,d,e+"",t,n,a):i,S=m===i;if(S){var A=F(d),R=!A&&Cn(d),L=!A&&!R&&te(d);m=d,A||R||L?F(c)?m=c:it(c)?m=St(c):R?(S=!1,m=ms(d,!0)):L?(S=!1,m=xs(d,!0)):m=[]:Ae(d)||Nn(d)?(m=c,Nn(c)?m=wo(c):(!et(c)||hn(c))&&(m=Ms(d))):S=!1}S&&(a.set(d,m),u(m,d,r,o,a),a.delete(d)),ii(t,e,m)}function fs(t,n){var e=t.length;if(e)return n+=n<0?e:0,ln(n,e)?t[n]:i}function cs(t,n,e){n.length?n=nt(n,function(o){return F(o)?function(a){return Wn(a,o.length===1?o[0]:o)}:o}):n=[Ct];var r=-1;n=nt(n,Et(E()));var u=ss(t,function(o,a,c){var d=nt(n,function(y){return y(o)});return{criteria:d,index:++r,value:o}});return Xa(u,function(o,a){return Uc(o,a,e)})}function Cc(t,n){return ls(t,n,function(e,r){return $i(t,r)})}function ls(t,n,e){for(var r=-1,u=n.length,o={};++r<u;){var a=n[r],c=Wn(t,a);e(c,a)&&ye(o,An(a,t),c)}return o}function Ic(t){return function(n){return Wn(n,t)}}function di(t,n,e,r){var u=r?Ya:kn,o=-1,a=n.length,c=t;for(t===n&&(n=St(n)),e&&(c=nt(t,Et(e)));++o<a;)for(var d=0,y=n[o],m=e?e(y):y;(d=u(c,m,d,r))>-1;)c!==t&&Ge.call(c,d,1),Ge.call(t,d,1);return t}function hs(t,n){for(var e=t?n.length:0,r=e-1;e--;){var u=n[e];if(e==r||u!==o){var o=u;ln(u)?Ge.call(t,u,1):vi(t,u)}}return t}function pi(t,n){return t+Ye(Gu()*(n-t+1))}function Rc(t,n,e,r){for(var u=-1,o=at(Ze((n-t)/(e||1)),0),a=g(o);o--;)a[r?o:++u]=t,t+=e;return a}function gi(t,n){var e="";if(!t||n<1||n>jt)return e;do n%2&&(e+=t),n=Ye(n/2),n&&(t+=t);while(n);return e}function M(t,n){return Oi(qs(t,n,Ct),t+"")}function Pc(t){return Yu(ne(t))}function Ec(t,n){var e=ne(t);return hr(e,On(n,0,e.length))}function ye(t,n,e,r){if(!et(t))return t;n=An(n,t);for(var u=-1,o=n.length,a=o-1,c=t;c!=null&&++u<o;){var d=en(n[u]),y=e;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(u!=a){var m=c[d];y=r?r(m,d,c):i,y===i&&(y=et(m)?m:ln(n[u+1])?[]:{})}ge(c,d,y),c=c[d]}return t}var ds=Xe?function(t,n){return Xe.set(t,n),t}:Ct,Tc=Je?function(t,n){return Je(t,"toString",{configurable:!0,enumerable:!1,value:qi(n),writable:!0})}:Ct;function Lc(t){return hr(ne(t))}function Kt(t,n,e){var r=-1,u=t.length;n<0&&(n=-n>u?0:u+n),e=e>u?u:e,e<0&&(e+=u),u=n>e?0:e-n>>>0,n>>>=0;for(var o=g(u);++r<u;)o[r]=t[r+n];return o}function Oc(t,n){var e;return xn(t,function(r,u,o){return e=n(r,u,o),!e}),!!e}function rr(t,n,e){var r=0,u=t==null?r:t.length;if(typeof n=="number"&&n===n&&u<=Ir){for(;r<u;){var o=r+u>>>1,a=t[o];a!==null&&!Lt(a)&&(e?a<=n:a<n)?r=o+1:u=o}return u}return _i(t,n,Ct,e)}function _i(t,n,e,r){var u=0,o=t==null?0:t.length;if(o===0)return 0;n=e(n);for(var a=n!==n,c=n===null,d=Lt(n),y=n===i;u<o;){var m=Ye((u+o)/2),S=e(t[m]),A=S!==i,R=S===null,L=S===S,U=Lt(S);if(a)var O=r||L;else y?O=L&&(r||A):c?O=L&&A&&(r||!R):d?O=L&&A&&!R&&(r||!U):R||U?O=!1:O=r?S<=n:S<n;O?u=m+1:o=m}return pt(o,Ee)}function ps(t,n){for(var e=-1,r=t.length,u=0,o=[];++e<r;){var a=t[e],c=n?n(a):a;if(!e||!Xt(c,d)){var d=c;o[u++]=a===0?0:a}}return o}function gs(t){return typeof t=="number"?t:Lt(t)?$n:+t}function Tt(t){if(typeof t=="string")return t;if(F(t))return nt(t,Tt)+"";if(Lt(t))return Ju?Ju.call(t):"";var n=t+"";return n=="0"&&1/t==-rn?"-0":n}function Sn(t,n,e){var r=-1,u=Ne,o=t.length,a=!0,c=[],d=c;if(e)a=!1,u=zr;else if(o>=_){var y=n?null:kc(t);if(y)return Be(y);a=!1,u=fe,d=new Ln}else d=n?[]:c;t:for(;++r<o;){var m=t[r],S=n?n(m):m;if(m=e||m!==0?m:0,a&&S===S){for(var A=d.length;A--;)if(d[A]===S)continue t;n&&d.push(S),c.push(m)}else u(d,S,e)||(d!==c&&d.push(S),c.push(m))}return c}function vi(t,n){return n=An(n,t),t=ks(t,n),t==null||delete t[en(qt(n))]}function _s(t,n,e,r){return ye(t,n,e(Wn(t,n)),r)}function ir(t,n,e,r){for(var u=t.length,o=r?u:-1;(r?o--:++o<u)&&n(t[o],o,t););return e?Kt(t,r?0:o,r?o+1:u):Kt(t,r?o+1:0,r?u:o)}function vs(t,n){var e=t;return e instanceof q&&(e=e.value()),Gr(n,function(r,u){return u.func.apply(u.thisArg,wn([r],u.args))},e)}function wi(t,n,e){var r=t.length;if(r<2)return r?Sn(t[0]):[];for(var u=-1,o=g(r);++u<r;)for(var a=t[u],c=-1;++c<r;)c!=u&&(o[u]=_e(o[u]||a,t[c],n,e));return Sn(dt(o,1),n,e)}function ws(t,n,e){for(var r=-1,u=t.length,o=n.length,a={};++r<u;){var c=r<o?n[r]:i;e(a,t[r],c)}return a}function yi(t){return it(t)?t:[]}function mi(t){return typeof t=="function"?t:Ct}function An(t,n){return F(t)?t:Ei(t,n)?[t]:Js(Z(t))}var Wc=M;function bn(t,n,e){var r=t.length;return e=e===i?r:e,!n&&e>=r?t:Kt(t,n,e)}var ys=mf||function(t){return ht.clearTimeout(t)};function ms(t,n){if(n)return t.slice();var e=t.length,r=Ku?Ku(e):new t.constructor(e);return t.copy(r),r}function xi(t){var n=new t.constructor(t.byteLength);return new He(n).set(new He(t)),n}function Dc(t,n){var e=n?xi(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}function Fc(t){var n=new t.constructor(t.source,ru.exec(t));return n.lastIndex=t.lastIndex,n}function Nc(t){return pe?Q(pe.call(t)):{}}function xs(t,n){var e=n?xi(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}function Ss(t,n){if(t!==n){var e=t!==i,r=t===null,u=t===t,o=Lt(t),a=n!==i,c=n===null,d=n===n,y=Lt(n);if(!c&&!y&&!o&&t>n||o&&a&&d&&!c&&!y||r&&a&&d||!e&&d||!u)return 1;if(!r&&!o&&!y&&t<n||y&&e&&u&&!r&&!o||c&&e&&u||!a&&u||!d)return-1}return 0}function Uc(t,n,e){for(var r=-1,u=t.criteria,o=n.criteria,a=u.length,c=e.length;++r<a;){var d=Ss(u[r],o[r]);if(d){if(r>=c)return d;var y=e[r];return d*(y=="desc"?-1:1)}}return t.index-n.index}function As(t,n,e,r){for(var u=-1,o=t.length,a=e.length,c=-1,d=n.length,y=at(o-a,0),m=g(d+y),S=!r;++c<d;)m[c]=n[c];for(;++u<a;)(S||u<o)&&(m[e[u]]=t[u]);for(;y--;)m[c++]=t[u++];return m}function bs(t,n,e,r){for(var u=-1,o=t.length,a=-1,c=e.length,d=-1,y=n.length,m=at(o-c,0),S=g(m+y),A=!r;++u<m;)S[u]=t[u];for(var R=u;++d<y;)S[R+d]=n[d];for(;++a<c;)(A||u<o)&&(S[R+e[a]]=t[u++]);return S}function St(t,n){var e=-1,r=t.length;for(n||(n=g(r));++e<r;)n[e]=t[e];return n}function nn(t,n,e,r){var u=!e;e||(e={});for(var o=-1,a=n.length;++o<a;){var c=n[o],d=r?r(e[c],t[c],c,e,t):i;d===i&&(d=t[c]),u?an(e,c,d):ge(e,c,d)}return e}function Bc(t,n){return nn(t,Pi(t),n)}function Mc(t,n){return nn(t,Us(t),n)}function ur(t,n){return function(e,r){var u=F(e)?ka:oc,o=n?n():{};return u(e,t,E(r,2),o)}}function Qn(t){return M(function(n,e){var r=-1,u=e.length,o=u>1?e[u-1]:i,a=u>2?e[2]:i;for(o=t.length>3&&typeof o=="function"?(u--,o):i,a&&yt(e[0],e[1],a)&&(o=u<3?i:o,u=1),n=Q(n);++r<u;){var c=e[r];c&&t(n,c,r,o)}return n})}function Cs(t,n){return function(e,r){if(e==null)return e;if(!At(e))return t(e,r);for(var u=e.length,o=n?u:-1,a=Q(e);(n?o--:++o<u)&&r(a[o],o,a)!==!1;);return e}}function Is(t){return function(n,e,r){for(var u=-1,o=Q(n),a=r(n),c=a.length;c--;){var d=a[t?c:++u];if(e(o[d],d,o)===!1)break}return n}}function $c(t,n,e){var r=n&_t,u=me(t);function o(){var a=this&&this!==ht&&this instanceof o?u:t;return a.apply(r?e:this,arguments)}return o}function Rs(t){return function(n){n=Z(n);var e=Hn(n)?Zt(n):i,r=e?e[0]:n.charAt(0),u=e?bn(e,1).join(""):n.slice(1);return r[t]()+u}}function Vn(t){return function(n){return Gr(Io(Co(n).replace(Ea,"")),t,"")}}function me(t){return function(){var n=arguments;switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3]);case 5:return new t(n[0],n[1],n[2],n[3],n[4]);case 6:return new t(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var e=Xn(t.prototype),r=t.apply(e,n);return et(r)?r:e}}function Kc(t,n,e){var r=me(t);function u(){for(var o=arguments.length,a=g(o),c=o,d=jn(u);c--;)a[c]=arguments[c];var y=o<3&&a[0]!==d&&a[o-1]!==d?[]:yn(a,d);if(o-=y.length,o<e)return Os(t,n,sr,u.placeholder,i,a,y,i,i,e-o);var m=this&&this!==ht&&this instanceof u?r:t;return Pt(m,this,a)}return u}function Ps(t){return function(n,e,r){var u=Q(n);if(!At(n)){var o=E(e,3);n=lt(n),e=function(c){return o(u[c],c,u)}}var a=t(n,e,r);return a>-1?u[o?n[a]:a]:i}}function Es(t){return cn(function(n){var e=n.length,r=e,u=Mt.prototype.thru;for(t&&n.reverse();r--;){var o=n[r];if(typeof o!="function")throw new Bt(x);if(u&&!a&&cr(o)=="wrapper")var a=new Mt([],!0)}for(r=a?r:e;++r<e;){o=n[r];var c=cr(o),d=c=="wrapper"?Ii(o):i;d&&Ti(d[0])&&d[1]==(xt|st|Ht|Dt)&&!d[4].length&&d[9]==1?a=a[cr(d[0])].apply(a,d[3]):a=o.length==1&&Ti(o)?a[c]():a.thru(o)}return function(){var y=arguments,m=y[0];if(a&&y.length==1&&F(m))return a.plant(m).value();for(var S=0,A=e?n[S].apply(this,y):m;++S<e;)A=n[S].call(this,A);return A}})}function sr(t,n,e,r,u,o,a,c,d,y){var m=n&xt,S=n&_t,A=n&It,R=n&(st|In),L=n&Bn,U=A?i:me(t);function O(){for(var K=arguments.length,H=g(K),Ot=K;Ot--;)H[Ot]=arguments[Ot];if(R)var mt=jn(O),Wt=Va(H,mt);if(r&&(H=As(H,r,u,R)),o&&(H=bs(H,o,a,R)),K-=Wt,R&&K<y){var ut=yn(H,mt);return Os(t,n,sr,O.placeholder,e,H,ut,c,d,y-K)}var Qt=S?e:this,pn=A?Qt[t]:t;return K=H.length,c?H=ol(H,c):L&&K>1&&H.reverse(),m&&d<K&&(H.length=d),this&&this!==ht&&this instanceof O&&(pn=U||me(pn)),pn.apply(Qt,H)}return O}function Ts(t,n){return function(e,r){return gc(e,t,n(r),{})}}function or(t,n){return function(e,r){var u;if(e===i&&r===i)return n;if(e!==i&&(u=e),r!==i){if(u===i)return r;typeof e=="string"||typeof r=="string"?(e=Tt(e),r=Tt(r)):(e=gs(e),r=gs(r)),u=t(e,r)}return u}}function Si(t){return cn(function(n){return n=nt(n,Et(E())),M(function(e){var r=this;return t(n,function(u){return Pt(u,r,e)})})})}function ar(t,n){n=n===i?" ":Tt(n);var e=n.length;if(e<2)return e?gi(n,t):n;var r=gi(n,Ze(t/zn(n)));return Hn(n)?bn(Zt(r),0,t).join(""):r.slice(0,t)}function qc(t,n,e,r){var u=n&_t,o=me(t);function a(){for(var c=-1,d=arguments.length,y=-1,m=r.length,S=g(m+d),A=this&&this!==ht&&this instanceof a?o:t;++y<m;)S[y]=r[y];for(;d--;)S[y++]=arguments[++c];return Pt(A,u?e:this,S)}return a}function Ls(t){return function(n,e,r){return r&&typeof r!="number"&&yt(n,e,r)&&(e=r=i),n=dn(n),e===i?(e=n,n=0):e=dn(e),r=r===i?n<e?1:-1:dn(r),Rc(n,e,r,t)}}function fr(t){return function(n,e){return typeof n=="string"&&typeof e=="string"||(n=kt(n),e=kt(e)),t(n,e)}}function Os(t,n,e,r,u,o,a,c,d,y){var m=n&st,S=m?a:i,A=m?i:a,R=m?o:i,L=m?i:o;n|=m?Ht:gn,n&=~(m?gn:Ht),n&Vt||(n&=-4);var U=[t,n,u,R,S,L,A,c,d,y],O=e.apply(i,U);return Ti(t)&&Hs(O,U),O.placeholder=r,zs(O,t,n)}function Ai(t){var n=ot[t];return function(e,r){if(e=kt(e),r=r==null?0:pt(N(r),292),r&&zu(e)){var u=(Z(e)+"e").split("e"),o=n(u[0]+"e"+(+u[1]+r));return u=(Z(o)+"e").split("e"),+(u[0]+"e"+(+u[1]-r))}return n(e)}}var kc=Zn&&1/Be(new Zn([,-0]))[1]==rn?function(t){return new Zn(t)}:zi;function Ws(t){return function(n){var e=gt(n);return e==Gt?jr(n):e==Jt?sf(n):Qa(n,t(n))}}function fn(t,n,e,r,u,o,a,c){var d=n&It;if(!d&&typeof t!="function")throw new Bt(x);var y=r?r.length:0;if(y||(n&=-97,r=u=i),a=a===i?a:at(N(a),0),c=c===i?c:N(c),y-=u?u.length:0,n&gn){var m=r,S=u;r=u=i}var A=d?i:Ii(t),R=[t,n,e,r,u,m,S,o,a,c];if(A&&il(R,A),t=R[0],n=R[1],e=R[2],r=R[3],u=R[4],c=R[9]=R[9]===i?d?0:t.length:at(R[9]-y,0),!c&&n&(st|In)&&(n&=-25),!n||n==_t)var L=$c(t,n,e);else n==st||n==In?L=Kc(t,n,c):(n==Ht||n==(_t|Ht))&&!u.length?L=qc(t,n,e,r):L=sr.apply(i,R);var U=A?ds:Hs;return zs(U(L,R),t,n)}function Ds(t,n,e,r){return t===i||Xt(t,Jn[e])&&!Y.call(r,e)?n:t}function Fs(t,n,e,r,u,o){return et(t)&&et(n)&&(o.set(n,t),er(t,n,i,Fs,o),o.delete(n)),t}function Hc(t){return Ae(t)?i:t}function Ns(t,n,e,r,u,o){var a=e&J,c=t.length,d=n.length;if(c!=d&&!(a&&d>c))return!1;var y=o.get(t),m=o.get(n);if(y&&m)return y==n&&m==t;var S=-1,A=!0,R=e&$?new Ln:i;for(o.set(t,n),o.set(n,t);++S<c;){var L=t[S],U=n[S];if(r)var O=a?r(U,L,S,n,t,o):r(L,U,S,t,n,o);if(O!==i){if(O)continue;A=!1;break}if(R){if(!Jr(n,function(K,H){if(!fe(R,H)&&(L===K||u(L,K,e,r,o)))return R.push(H)})){A=!1;break}}else if(!(L===U||u(L,U,e,r,o))){A=!1;break}}return o.delete(t),o.delete(n),A}function zc(t,n,e,r,u,o,a){switch(e){case Kn:if(t.byteLength!=n.byteLength||t.byteOffset!=n.byteOffset)return!1;t=t.buffer,n=n.buffer;case ae:return!(t.byteLength!=n.byteLength||!o(new He(t),new He(n)));case _n:case vt:case ie:return Xt(+t,+n);case Te:return t.name==n.name&&t.message==n.message;case ue:case se:return t==n+"";case Gt:var c=jr;case Jt:var d=r&J;if(c||(c=Be),t.size!=n.size&&!d)return!1;var y=a.get(t);if(y)return y==n;r|=$,a.set(t,n);var m=Ns(c(t),c(n),r,u,o,a);return a.delete(t),m;case Oe:if(pe)return pe.call(t)==pe.call(n)}return!1}function Gc(t,n,e,r,u,o){var a=e&J,c=bi(t),d=c.length,y=bi(n),m=y.length;if(d!=m&&!a)return!1;for(var S=d;S--;){var A=c[S];if(!(a?A in n:Y.call(n,A)))return!1}var R=o.get(t),L=o.get(n);if(R&&L)return R==n&&L==t;var U=!0;o.set(t,n),o.set(n,t);for(var O=a;++S<d;){A=c[S];var K=t[A],H=n[A];if(r)var Ot=a?r(H,K,A,n,t,o):r(K,H,A,t,n,o);if(!(Ot===i?K===H||u(K,H,e,r,o):Ot)){U=!1;break}O||(O=A=="constructor")}if(U&&!O){var mt=t.constructor,Wt=n.constructor;mt!=Wt&&"constructor"in t&&"constructor"in n&&!(typeof mt=="function"&&mt instanceof mt&&typeof Wt=="function"&&Wt instanceof Wt)&&(U=!1)}return o.delete(t),o.delete(n),U}function cn(t){return Oi(qs(t,i,Qs),t+"")}function bi(t){return es(t,lt,Pi)}function Ci(t){return es(t,bt,Us)}var Ii=Xe?function(t){return Xe.get(t)}:zi;function cr(t){for(var n=t.name+"",e=Yn[n],r=Y.call(Yn,n)?e.length:0;r--;){var u=e[r],o=u.func;if(o==null||o==t)return u.name}return n}function jn(t){var n=Y.call(s,"placeholder")?s:t;return n.placeholder}function E(){var t=s.iteratee||ki;return t=t===ki?us:t,arguments.length?t(arguments[0],arguments[1]):t}function lr(t,n){var e=t.__data__;return tl(n)?e[typeof n=="string"?"string":"hash"]:e.map}function Ri(t){for(var n=lt(t),e=n.length;e--;){var r=n[e],u=t[r];n[e]=[r,u,$s(u)]}return n}function Dn(t,n){var e=ef(t,n);return is(e)?e:i}function Jc(t){var n=Y.call(t,En),e=t[En];try{t[En]=i;var r=!0}catch{}var u=qe.call(t);return r&&(n?t[En]=e:delete t[En]),u}var Pi=ni?function(t){return t==null?[]:(t=Q(t),vn(ni(t),function(n){return ku.call(t,n)}))}:Gi,Us=ni?function(t){for(var n=[];t;)wn(n,Pi(t)),t=ze(t);return n}:Gi,gt=wt;(ei&&gt(new ei(new ArrayBuffer(1)))!=Kn||le&&gt(new le)!=Gt||ri&&gt(ri.resolve())!=ji||Zn&&gt(new Zn)!=Jt||he&&gt(new he)!=oe)&&(gt=function(t){var n=wt(t),e=n==un?t.constructor:i,r=e?Fn(e):"";if(r)switch(r){case Ef:return Kn;case Tf:return Gt;case Lf:return ji;case Of:return Jt;case Wf:return oe}return n});function Zc(t,n,e){for(var r=-1,u=e.length;++r<u;){var o=e[r],a=o.size;switch(o.type){case"drop":t+=a;break;case"dropRight":n-=a;break;case"take":n=pt(n,t+a);break;case"takeRight":t=at(t,n-a);break}}return{start:t,end:n}}function Yc(t){var n=t.match(ta);return n?n[1].split(na):[]}function Bs(t,n,e){n=An(n,t);for(var r=-1,u=n.length,o=!1;++r<u;){var a=en(n[r]);if(!(o=t!=null&&e(t,a)))break;t=t[a]}return o||++r!=u?o:(u=t==null?0:t.length,!!u&&wr(u)&&ln(a,u)&&(F(t)||Nn(t)))}function Xc(t){var n=t.length,e=new t.constructor(n);return n&&typeof t[0]=="string"&&Y.call(t,"index")&&(e.index=t.index,e.input=t.input),e}function Ms(t){return typeof t.constructor=="function"&&!xe(t)?Xn(ze(t)):{}}function Qc(t,n,e){var r=t.constructor;switch(n){case ae:return xi(t);case _n:case vt:return new r(+t);case Kn:return Dc(t,e);case Rr:case Pr:case Er:case Tr:case Lr:case Or:case Wr:case Dr:case Fr:return xs(t,e);case Gt:return new r;case ie:case se:return new r(t);case ue:return Fc(t);case Jt:return new r;case Oe:return Nc(t)}}function Vc(t,n){var e=n.length;if(!e)return t;var r=e-1;return n[r]=(e>1?"& ":"")+n[r],n=n.join(e>2?", ":" "),t.replace(jo,`{
8
+ */Sr.exports;(function(h,f){(function(){var i,p="4.17.21",_=200,v="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",x="Expected a function",E="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",B=500,C="__lodash_placeholder__",k=1,P=2,J=4,Z=1,$=2,_t=1,It=2,Vt=4,ot=8,In=16,Ht=32,gn=64,xt=128,Rt=256,Mn=512,Re=30,Pt="...",Pe=800,$n=16,re=1,ct=2,br=3,rn=1/0,jt=9007199254740991,Cr=17976931348623157e292,Kn=NaN,Ft=4294967295,Ee=Ft-1,Ir=Ft>>>1,z=[["ary",xt],["bind",_t],["bindKey",It],["curry",ot],["curryRight",In],["flip",Mn],["partial",Ht],["partialRight",gn],["rearg",Rt]],it="[object Arguments]",zt="[object Array]",Rn="[object AsyncFunction]",_n="[object Boolean]",vt="[object Date]",No="[object DOMException]",Te="[object Error]",Le="[object Function]",Vi="[object GeneratorFunction]",Gt="[object Map]",ie="[object Number]",Uo="[object Null]",un="[object Object]",ji="[object Promise]",Bo="[object Proxy]",ue="[object RegExp]",Jt="[object Set]",se="[object String]",Oe="[object Symbol]",Mo="[object Undefined]",oe="[object WeakMap]",$o="[object WeakSet]",ae="[object ArrayBuffer]",qn="[object DataView]",Rr="[object Float32Array]",Pr="[object Float64Array]",Er="[object Int8Array]",Tr="[object Int16Array]",Lr="[object Int32Array]",Or="[object Uint8Array]",Wr="[object Uint8ClampedArray]",Dr="[object Uint16Array]",Fr="[object Uint32Array]",Ko=/\b__p \+= '';/g,qo=/\b(__p \+=) '' \+/g,ko=/(__e\(.*?\)|\b__t\)) \+\n'';/g,tu=/&(?:amp|lt|gt|quot|#39);/g,nu=/[&<>"']/g,Ho=RegExp(tu.source),zo=RegExp(nu.source),Go=/<%-([\s\S]+?)%>/g,Jo=/<%([\s\S]+?)%>/g,eu=/<%=([\s\S]+?)%>/g,Zo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yo=/^\w*$/,Xo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Nr=/[\\^$.*+?()[\]{}|]/g,Qo=RegExp(Nr.source),Ur=/^\s+/,Vo=/\s/,jo=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ta=/\{\n\/\* \[wrapped with (.+)\] \*/,na=/,? & /,ea=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ra=/[()=,{}\[\]\/\s]/,ia=/\\(\\)?/g,ua=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ru=/\w*$/,sa=/^[-+]0x[0-9a-f]+$/i,oa=/^0b[01]+$/i,aa=/^\[object .+?Constructor\]$/,fa=/^0o[0-7]+$/i,ca=/^(?:0|[1-9]\d*)$/,la=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,We=/($^)/,ha=/['\n\r\u2028\u2029\\]/g,De="\\ud800-\\udfff",da="\\u0300-\\u036f",pa="\\ufe20-\\ufe2f",ga="\\u20d0-\\u20ff",iu=da+pa+ga,uu="\\u2700-\\u27bf",su="a-z\\xdf-\\xf6\\xf8-\\xff",_a="\\xac\\xb1\\xd7\\xf7",va="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",wa="\\u2000-\\u206f",ya=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ou="A-Z\\xc0-\\xd6\\xd8-\\xde",au="\\ufe0e\\ufe0f",fu=_a+va+wa+ya,Br="['’]",ma="["+De+"]",cu="["+fu+"]",Fe="["+iu+"]",lu="\\d+",xa="["+uu+"]",hu="["+su+"]",du="[^"+De+fu+lu+uu+su+ou+"]",Mr="\\ud83c[\\udffb-\\udfff]",Sa="(?:"+Fe+"|"+Mr+")",pu="[^"+De+"]",$r="(?:\\ud83c[\\udde6-\\uddff]){2}",Kr="[\\ud800-\\udbff][\\udc00-\\udfff]",kn="["+ou+"]",gu="\\u200d",_u="(?:"+hu+"|"+du+")",Aa="(?:"+kn+"|"+du+")",vu="(?:"+Br+"(?:d|ll|m|re|s|t|ve))?",wu="(?:"+Br+"(?:D|LL|M|RE|S|T|VE))?",yu=Sa+"?",mu="["+au+"]?",ba="(?:"+gu+"(?:"+[pu,$r,Kr].join("|")+")"+mu+yu+")*",Ca="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ia="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",xu=mu+yu+ba,Ra="(?:"+[xa,$r,Kr].join("|")+")"+xu,Pa="(?:"+[pu+Fe+"?",Fe,$r,Kr,ma].join("|")+")",Ea=RegExp(Br,"g"),Ta=RegExp(Fe,"g"),qr=RegExp(Mr+"(?="+Mr+")|"+Pa+xu,"g"),La=RegExp([kn+"?"+hu+"+"+vu+"(?="+[cu,kn,"$"].join("|")+")",Aa+"+"+wu+"(?="+[cu,kn+_u,"$"].join("|")+")",kn+"?"+_u+"+"+vu,kn+"+"+wu,Ia,Ca,lu,Ra].join("|"),"g"),Oa=RegExp("["+gu+De+iu+au+"]"),Wa=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Da=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Fa=-1,tt={};tt[Rr]=tt[Pr]=tt[Er]=tt[Tr]=tt[Lr]=tt[Or]=tt[Wr]=tt[Dr]=tt[Fr]=!0,tt[it]=tt[zt]=tt[ae]=tt[_n]=tt[qn]=tt[vt]=tt[Te]=tt[Le]=tt[Gt]=tt[ie]=tt[un]=tt[ue]=tt[Jt]=tt[se]=tt[oe]=!1;var j={};j[it]=j[zt]=j[ae]=j[qn]=j[_n]=j[vt]=j[Rr]=j[Pr]=j[Er]=j[Tr]=j[Lr]=j[Gt]=j[ie]=j[un]=j[ue]=j[Jt]=j[se]=j[Oe]=j[Or]=j[Wr]=j[Dr]=j[Fr]=!0,j[Te]=j[Le]=j[oe]=!1;var Na={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Ua={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ba={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Ma={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$a=parseFloat,Ka=parseInt,Su=typeof be=="object"&&be&&be.Object===Object&&be,qa=typeof self=="object"&&self&&self.Object===Object&&self,ht=Su||qa||Function("return this")(),kr=f&&!f.nodeType&&f,Pn=kr&&!0&&h&&!h.nodeType&&h,Au=Pn&&Pn.exports===kr,Hr=Au&&Su.process,Nt=function(){try{var l=Pn&&Pn.require&&Pn.require("util").types;return l||Hr&&Hr.binding&&Hr.binding("util")}catch{}}(),bu=Nt&&Nt.isArrayBuffer,Cu=Nt&&Nt.isDate,Iu=Nt&&Nt.isMap,Ru=Nt&&Nt.isRegExp,Pu=Nt&&Nt.isSet,Eu=Nt&&Nt.isTypedArray;function Et(l,w,g){switch(g.length){case 0:return l.call(w);case 1:return l.call(w,g[0]);case 2:return l.call(w,g[0],g[1]);case 3:return l.call(w,g[0],g[1],g[2])}return l.apply(w,g)}function ka(l,w,g,I){for(var D=-1,G=l==null?0:l.length;++D<G;){var at=l[D];w(I,at,g(at),l)}return I}function Ut(l,w){for(var g=-1,I=l==null?0:l.length;++g<I&&w(l[g],g,l)!==!1;);return l}function Ha(l,w){for(var g=l==null?0:l.length;g--&&w(l[g],g,l)!==!1;);return l}function Tu(l,w){for(var g=-1,I=l==null?0:l.length;++g<I;)if(!w(l[g],g,l))return!1;return!0}function vn(l,w){for(var g=-1,I=l==null?0:l.length,D=0,G=[];++g<I;){var at=l[g];w(at,g,l)&&(G[D++]=at)}return G}function Ne(l,w){var g=l==null?0:l.length;return!!g&&Hn(l,w,0)>-1}function zr(l,w,g){for(var I=-1,D=l==null?0:l.length;++I<D;)if(g(w,l[I]))return!0;return!1}function nt(l,w){for(var g=-1,I=l==null?0:l.length,D=Array(I);++g<I;)D[g]=w(l[g],g,l);return D}function wn(l,w){for(var g=-1,I=w.length,D=l.length;++g<I;)l[D+g]=w[g];return l}function Gr(l,w,g,I){var D=-1,G=l==null?0:l.length;for(I&&G&&(g=l[++D]);++D<G;)g=w(g,l[D],D,l);return g}function za(l,w,g,I){var D=l==null?0:l.length;for(I&&D&&(g=l[--D]);D--;)g=w(g,l[D],D,l);return g}function Jr(l,w){for(var g=-1,I=l==null?0:l.length;++g<I;)if(w(l[g],g,l))return!0;return!1}var Ga=Zr("length");function Ja(l){return l.split("")}function Za(l){return l.match(ea)||[]}function Lu(l,w,g){var I;return g(l,function(D,G,at){if(w(D,G,at))return I=G,!1}),I}function Ue(l,w,g,I){for(var D=l.length,G=g+(I?1:-1);I?G--:++G<D;)if(w(l[G],G,l))return G;return-1}function Hn(l,w,g){return w===w?of(l,w,g):Ue(l,Ou,g)}function Ya(l,w,g,I){for(var D=g-1,G=l.length;++D<G;)if(I(l[D],w))return D;return-1}function Ou(l){return l!==l}function Wu(l,w){var g=l==null?0:l.length;return g?Xr(l,w)/g:Kn}function Zr(l){return function(w){return w==null?i:w[l]}}function Yr(l){return function(w){return l==null?i:l[w]}}function Du(l,w,g,I,D){return D(l,function(G,at,Q){g=I?(I=!1,G):w(g,G,at,Q)}),g}function Xa(l,w){var g=l.length;for(l.sort(w);g--;)l[g]=l[g].value;return l}function Xr(l,w){for(var g,I=-1,D=l.length;++I<D;){var G=w(l[I]);G!==i&&(g=g===i?G:g+G)}return g}function Qr(l,w){for(var g=-1,I=Array(l);++g<l;)I[g]=w(g);return I}function Qa(l,w){return nt(w,function(g){return[g,l[g]]})}function Fu(l){return l&&l.slice(0,Mu(l)+1).replace(Ur,"")}function Tt(l){return function(w){return l(w)}}function Vr(l,w){return nt(w,function(g){return l[g]})}function fe(l,w){return l.has(w)}function Nu(l,w){for(var g=-1,I=l.length;++g<I&&Hn(w,l[g],0)>-1;);return g}function Uu(l,w){for(var g=l.length;g--&&Hn(w,l[g],0)>-1;);return g}function Va(l,w){for(var g=l.length,I=0;g--;)l[g]===w&&++I;return I}var ja=Yr(Na),tf=Yr(Ua);function nf(l){return"\\"+Ma[l]}function ef(l,w){return l==null?i:l[w]}function zn(l){return Oa.test(l)}function rf(l){return Wa.test(l)}function uf(l){for(var w,g=[];!(w=l.next()).done;)g.push(w.value);return g}function jr(l){var w=-1,g=Array(l.size);return l.forEach(function(I,D){g[++w]=[D,I]}),g}function Bu(l,w){return function(g){return l(w(g))}}function yn(l,w){for(var g=-1,I=l.length,D=0,G=[];++g<I;){var at=l[g];(at===w||at===C)&&(l[g]=C,G[D++]=g)}return G}function Be(l){var w=-1,g=Array(l.size);return l.forEach(function(I){g[++w]=I}),g}function sf(l){var w=-1,g=Array(l.size);return l.forEach(function(I){g[++w]=[I,I]}),g}function of(l,w,g){for(var I=g-1,D=l.length;++I<D;)if(l[I]===w)return I;return-1}function af(l,w,g){for(var I=g+1;I--;)if(l[I]===w)return I;return I}function Gn(l){return zn(l)?cf(l):Ga(l)}function Zt(l){return zn(l)?lf(l):Ja(l)}function Mu(l){for(var w=l.length;w--&&Vo.test(l.charAt(w)););return w}var ff=Yr(Ba);function cf(l){for(var w=qr.lastIndex=0;qr.test(l);)++w;return w}function lf(l){return l.match(qr)||[]}function hf(l){return l.match(La)||[]}var df=function l(w){w=w==null?ht:Jn.defaults(ht.Object(),w,Jn.pick(ht,Da));var g=w.Array,I=w.Date,D=w.Error,G=w.Function,at=w.Math,Q=w.Object,ti=w.RegExp,pf=w.String,Bt=w.TypeError,Me=g.prototype,gf=G.prototype,Zn=Q.prototype,$e=w["__core-js_shared__"],Ke=gf.toString,X=Zn.hasOwnProperty,_f=0,$u=function(){var t=/[^.]+$/.exec($e&&$e.keys&&$e.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),qe=Zn.toString,vf=Ke.call(Q),wf=ht._,yf=ti("^"+Ke.call(X).replace(Nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ke=Au?w.Buffer:i,mn=w.Symbol,He=w.Uint8Array,Ku=ke?ke.allocUnsafe:i,ze=Bu(Q.getPrototypeOf,Q),qu=Q.create,ku=Zn.propertyIsEnumerable,Ge=Me.splice,Hu=mn?mn.isConcatSpreadable:i,ce=mn?mn.iterator:i,En=mn?mn.toStringTag:i,Je=function(){try{var t=Dn(Q,"defineProperty");return t({},"",{}),t}catch{}}(),mf=w.clearTimeout!==ht.clearTimeout&&w.clearTimeout,xf=I&&I.now!==ht.Date.now&&I.now,Sf=w.setTimeout!==ht.setTimeout&&w.setTimeout,Ze=at.ceil,Ye=at.floor,ni=Q.getOwnPropertySymbols,Af=ke?ke.isBuffer:i,zu=w.isFinite,bf=Me.join,Cf=Bu(Q.keys,Q),ft=at.max,pt=at.min,If=I.now,Rf=w.parseInt,Gu=at.random,Pf=Me.reverse,ei=Dn(w,"DataView"),le=Dn(w,"Map"),ri=Dn(w,"Promise"),Yn=Dn(w,"Set"),he=Dn(w,"WeakMap"),de=Dn(Q,"create"),Xe=he&&new he,Xn={},Ef=Fn(ei),Tf=Fn(le),Lf=Fn(ri),Of=Fn(Yn),Wf=Fn(he),Qe=mn?mn.prototype:i,pe=Qe?Qe.valueOf:i,Ju=Qe?Qe.toString:i;function s(t){if(rt(t)&&!F(t)&&!(t instanceof q)){if(t instanceof Mt)return t;if(X.call(t,"__wrapped__"))return Zs(t)}return new Mt(t)}var Qn=function(){function t(){}return function(n){if(!et(n))return{};if(qu)return qu(n);t.prototype=n;var e=new t;return t.prototype=i,e}}();function Ve(){}function Mt(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=i}s.templateSettings={escape:Go,evaluate:Jo,interpolate:eu,variable:"",imports:{_:s}},s.prototype=Ve.prototype,s.prototype.constructor=s,Mt.prototype=Qn(Ve.prototype),Mt.prototype.constructor=Mt;function q(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ft,this.__views__=[]}function Df(){var t=new q(this.__wrapped__);return t.__actions__=St(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=St(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=St(this.__views__),t}function Ff(){if(this.__filtered__){var t=new q(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Nf(){var t=this.__wrapped__.value(),n=this.__dir__,e=F(t),r=n<0,u=e?t.length:0,o=Zc(0,u,this.__views__),a=o.start,c=o.end,d=c-a,y=r?c:a-1,m=this.__iteratees__,S=m.length,A=0,R=pt(d,this.__takeCount__);if(!e||!r&&u==d&&R==d)return vs(t,this.__actions__);var L=[];t:for(;d--&&A<R;){y+=n;for(var U=-1,O=t[y];++U<S;){var K=m[U],H=K.iteratee,Wt=K.type,mt=H(O);if(Wt==ct)O=mt;else if(!mt){if(Wt==re)continue t;break t}}L[A++]=O}return L}q.prototype=Qn(Ve.prototype),q.prototype.constructor=q;function Tn(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Uf(){this.__data__=de?de(null):{},this.size=0}function Bf(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function Mf(t){var n=this.__data__;if(de){var e=n[t];return e===b?i:e}return X.call(n,t)?n[t]:i}function $f(t){var n=this.__data__;return de?n[t]!==i:X.call(n,t)}function Kf(t,n){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=de&&n===i?b:n,this}Tn.prototype.clear=Uf,Tn.prototype.delete=Bf,Tn.prototype.get=Mf,Tn.prototype.has=$f,Tn.prototype.set=Kf;function sn(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function qf(){this.__data__=[],this.size=0}function kf(t){var n=this.__data__,e=je(n,t);if(e<0)return!1;var r=n.length-1;return e==r?n.pop():Ge.call(n,e,1),--this.size,!0}function Hf(t){var n=this.__data__,e=je(n,t);return e<0?i:n[e][1]}function zf(t){return je(this.__data__,t)>-1}function Gf(t,n){var e=this.__data__,r=je(e,t);return r<0?(++this.size,e.push([t,n])):e[r][1]=n,this}sn.prototype.clear=qf,sn.prototype.delete=kf,sn.prototype.get=Hf,sn.prototype.has=zf,sn.prototype.set=Gf;function on(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Jf(){this.size=0,this.__data__={hash:new Tn,map:new(le||sn),string:new Tn}}function Zf(t){var n=lr(this,t).delete(t);return this.size-=n?1:0,n}function Yf(t){return lr(this,t).get(t)}function Xf(t){return lr(this,t).has(t)}function Qf(t,n){var e=lr(this,t),r=e.size;return e.set(t,n),this.size+=e.size==r?0:1,this}on.prototype.clear=Jf,on.prototype.delete=Zf,on.prototype.get=Yf,on.prototype.has=Xf,on.prototype.set=Qf;function Ln(t){var n=-1,e=t==null?0:t.length;for(this.__data__=new on;++n<e;)this.add(t[n])}function Vf(t){return this.__data__.set(t,b),this}function jf(t){return this.__data__.has(t)}Ln.prototype.add=Ln.prototype.push=Vf,Ln.prototype.has=jf;function Yt(t){var n=this.__data__=new sn(t);this.size=n.size}function tc(){this.__data__=new sn,this.size=0}function nc(t){var n=this.__data__,e=n.delete(t);return this.size=n.size,e}function ec(t){return this.__data__.get(t)}function rc(t){return this.__data__.has(t)}function ic(t,n){var e=this.__data__;if(e instanceof sn){var r=e.__data__;if(!le||r.length<_-1)return r.push([t,n]),this.size=++e.size,this;e=this.__data__=new on(r)}return e.set(t,n),this.size=e.size,this}Yt.prototype.clear=tc,Yt.prototype.delete=nc,Yt.prototype.get=ec,Yt.prototype.has=rc,Yt.prototype.set=ic;function Zu(t,n){var e=F(t),r=!e&&Nn(t),u=!e&&!r&&Cn(t),o=!e&&!r&&!u&&ne(t),a=e||r||u||o,c=a?Qr(t.length,pf):[],d=c.length;for(var y in t)(n||X.call(t,y))&&!(a&&(y=="length"||u&&(y=="offset"||y=="parent")||o&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||ln(y,d)))&&c.push(y);return c}function Yu(t){var n=t.length;return n?t[pi(0,n-1)]:i}function uc(t,n){return hr(St(t),On(n,0,t.length))}function sc(t){return hr(St(t))}function ii(t,n,e){(e!==i&&!Xt(t[n],e)||e===i&&!(n in t))&&an(t,n,e)}function ge(t,n,e){var r=t[n];(!(X.call(t,n)&&Xt(r,e))||e===i&&!(n in t))&&an(t,n,e)}function je(t,n){for(var e=t.length;e--;)if(Xt(t[e][0],n))return e;return-1}function oc(t,n,e,r){return xn(t,function(u,o,a){n(r,u,e(u),a)}),r}function Xu(t,n){return t&&nn(n,lt(n),t)}function ac(t,n){return t&&nn(n,bt(n),t)}function an(t,n,e){n=="__proto__"&&Je?Je(t,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[n]=e}function ui(t,n){for(var e=-1,r=n.length,u=g(r),o=t==null;++e<r;)u[e]=o?i:Mi(t,n[e]);return u}function On(t,n,e){return t===t&&(e!==i&&(t=t<=e?t:e),n!==i&&(t=t>=n?t:n)),t}function $t(t,n,e,r,u,o){var a,c=n&k,d=n&P,y=n&J;if(e&&(a=u?e(t,r,u,o):e(t)),a!==i)return a;if(!et(t))return t;var m=F(t);if(m){if(a=Xc(t),!c)return St(t,a)}else{var S=gt(t),A=S==Le||S==Vi;if(Cn(t))return ms(t,c);if(S==un||S==it||A&&!u){if(a=d||A?{}:Ms(t),!c)return d?Mc(t,ac(a,t)):Bc(t,Xu(a,t))}else{if(!j[S])return u?t:{};a=Qc(t,S,c)}}o||(o=new Yt);var R=o.get(t);if(R)return R;o.set(t,a),go(t)?t.forEach(function(O){a.add($t(O,n,e,O,t,o))}):ho(t)&&t.forEach(function(O,K){a.set(K,$t(O,n,e,K,t,o))});var L=y?d?Ci:bi:d?bt:lt,U=m?i:L(t);return Ut(U||t,function(O,K){U&&(K=O,O=t[K]),ge(a,K,$t(O,n,e,K,t,o))}),a}function fc(t){var n=lt(t);return function(e){return Qu(e,t,n)}}function Qu(t,n,e){var r=e.length;if(t==null)return!r;for(t=Q(t);r--;){var u=e[r],o=n[u],a=t[u];if(a===i&&!(u in t)||!o(a))return!1}return!0}function Vu(t,n,e){if(typeof t!="function")throw new Bt(x);return Se(function(){t.apply(i,e)},n)}function _e(t,n,e,r){var u=-1,o=Ne,a=!0,c=t.length,d=[],y=n.length;if(!c)return d;e&&(n=nt(n,Tt(e))),r?(o=zr,a=!1):n.length>=_&&(o=fe,a=!1,n=new Ln(n));t:for(;++u<c;){var m=t[u],S=e==null?m:e(m);if(m=r||m!==0?m:0,a&&S===S){for(var A=y;A--;)if(n[A]===S)continue t;d.push(m)}else o(n,S,r)||d.push(m)}return d}var xn=Cs(tn),ju=Cs(oi,!0);function cc(t,n){var e=!0;return xn(t,function(r,u,o){return e=!!n(r,u,o),e}),e}function tr(t,n,e){for(var r=-1,u=t.length;++r<u;){var o=t[r],a=n(o);if(a!=null&&(c===i?a===a&&!Ot(a):e(a,c)))var c=a,d=o}return d}function lc(t,n,e,r){var u=t.length;for(e=N(e),e<0&&(e=-e>u?0:u+e),r=r===i||r>u?u:N(r),r<0&&(r+=u),r=e>r?0:vo(r);e<r;)t[e++]=n;return t}function ts(t,n){var e=[];return xn(t,function(r,u,o){n(r,u,o)&&e.push(r)}),e}function dt(t,n,e,r,u){var o=-1,a=t.length;for(e||(e=jc),u||(u=[]);++o<a;){var c=t[o];n>0&&e(c)?n>1?dt(c,n-1,e,r,u):wn(u,c):r||(u[u.length]=c)}return u}var si=Is(),ns=Is(!0);function tn(t,n){return t&&si(t,n,lt)}function oi(t,n){return t&&ns(t,n,lt)}function nr(t,n){return vn(n,function(e){return hn(t[e])})}function Wn(t,n){n=An(n,t);for(var e=0,r=n.length;t!=null&&e<r;)t=t[en(n[e++])];return e&&e==r?t:i}function es(t,n,e){var r=n(t);return F(t)?r:wn(r,e(t))}function wt(t){return t==null?t===i?Mo:Uo:En&&En in Q(t)?Jc(t):sl(t)}function ai(t,n){return t>n}function hc(t,n){return t!=null&&X.call(t,n)}function dc(t,n){return t!=null&&n in Q(t)}function pc(t,n,e){return t>=pt(n,e)&&t<ft(n,e)}function fi(t,n,e){for(var r=e?zr:Ne,u=t[0].length,o=t.length,a=o,c=g(o),d=1/0,y=[];a--;){var m=t[a];a&&n&&(m=nt(m,Tt(n))),d=pt(m.length,d),c[a]=!e&&(n||u>=120&&m.length>=120)?new Ln(a&&m):i}m=t[0];var S=-1,A=c[0];t:for(;++S<u&&y.length<d;){var R=m[S],L=n?n(R):R;if(R=e||R!==0?R:0,!(A?fe(A,L):r(y,L,e))){for(a=o;--a;){var U=c[a];if(!(U?fe(U,L):r(t[a],L,e)))continue t}A&&A.push(L),y.push(R)}}return y}function gc(t,n,e,r){return tn(t,function(u,o,a){n(r,e(u),o,a)}),r}function ve(t,n,e){n=An(n,t),t=ks(t,n);var r=t==null?t:t[en(qt(n))];return r==null?i:Et(r,t,e)}function rs(t){return rt(t)&&wt(t)==it}function _c(t){return rt(t)&&wt(t)==ae}function vc(t){return rt(t)&&wt(t)==vt}function we(t,n,e,r,u){return t===n?!0:t==null||n==null||!rt(t)&&!rt(n)?t!==t&&n!==n:wc(t,n,e,r,we,u)}function wc(t,n,e,r,u,o){var a=F(t),c=F(n),d=a?zt:gt(t),y=c?zt:gt(n);d=d==it?un:d,y=y==it?un:y;var m=d==un,S=y==un,A=d==y;if(A&&Cn(t)){if(!Cn(n))return!1;a=!0,m=!1}if(A&&!m)return o||(o=new Yt),a||ne(t)?Ns(t,n,e,r,u,o):zc(t,n,d,e,r,u,o);if(!(e&Z)){var R=m&&X.call(t,"__wrapped__"),L=S&&X.call(n,"__wrapped__");if(R||L){var U=R?t.value():t,O=L?n.value():n;return o||(o=new Yt),u(U,O,e,r,o)}}return A?(o||(o=new Yt),Gc(t,n,e,r,u,o)):!1}function yc(t){return rt(t)&&gt(t)==Gt}function ci(t,n,e,r){var u=e.length,o=u,a=!r;if(t==null)return!o;for(t=Q(t);u--;){var c=e[u];if(a&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++u<o;){c=e[u];var d=c[0],y=t[d],m=c[1];if(a&&c[2]){if(y===i&&!(d in t))return!1}else{var S=new Yt;if(r)var A=r(y,m,d,t,n,S);if(!(A===i?we(m,y,Z|$,r,S):A))return!1}}return!0}function is(t){if(!et(t)||nl(t))return!1;var n=hn(t)?yf:aa;return n.test(Fn(t))}function mc(t){return rt(t)&&wt(t)==ue}function xc(t){return rt(t)&&gt(t)==Jt}function Sc(t){return rt(t)&&wr(t.length)&&!!tt[wt(t)]}function us(t){return typeof t=="function"?t:t==null?Ct:typeof t=="object"?F(t)?as(t[0],t[1]):os(t):Po(t)}function li(t){if(!xe(t))return Cf(t);var n=[];for(var e in Q(t))X.call(t,e)&&e!="constructor"&&n.push(e);return n}function Ac(t){if(!et(t))return ul(t);var n=xe(t),e=[];for(var r in t)r=="constructor"&&(n||!X.call(t,r))||e.push(r);return e}function hi(t,n){return t<n}function ss(t,n){var e=-1,r=At(t)?g(t.length):[];return xn(t,function(u,o,a){r[++e]=n(u,o,a)}),r}function os(t){var n=Ri(t);return n.length==1&&n[0][2]?Ks(n[0][0],n[0][1]):function(e){return e===t||ci(e,t,n)}}function as(t,n){return Ei(t)&&$s(n)?Ks(en(t),n):function(e){var r=Mi(e,t);return r===i&&r===n?$i(e,t):we(n,r,Z|$)}}function er(t,n,e,r,u){t!==n&&si(n,function(o,a){if(u||(u=new Yt),et(o))bc(t,n,a,e,er,r,u);else{var c=r?r(Li(t,a),o,a+"",t,n,u):i;c===i&&(c=o),ii(t,a,c)}},bt)}function bc(t,n,e,r,u,o,a){var c=Li(t,e),d=Li(n,e),y=a.get(d);if(y){ii(t,e,y);return}var m=o?o(c,d,e+"",t,n,a):i,S=m===i;if(S){var A=F(d),R=!A&&Cn(d),L=!A&&!R&&ne(d);m=d,A||R||L?F(c)?m=c:ut(c)?m=St(c):R?(S=!1,m=ms(d,!0)):L?(S=!1,m=xs(d,!0)):m=[]:Ae(d)||Nn(d)?(m=c,Nn(c)?m=wo(c):(!et(c)||hn(c))&&(m=Ms(d))):S=!1}S&&(a.set(d,m),u(m,d,r,o,a),a.delete(d)),ii(t,e,m)}function fs(t,n){var e=t.length;if(e)return n+=n<0?e:0,ln(n,e)?t[n]:i}function cs(t,n,e){n.length?n=nt(n,function(o){return F(o)?function(a){return Wn(a,o.length===1?o[0]:o)}:o}):n=[Ct];var r=-1;n=nt(n,Tt(T()));var u=ss(t,function(o,a,c){var d=nt(n,function(y){return y(o)});return{criteria:d,index:++r,value:o}});return Xa(u,function(o,a){return Uc(o,a,e)})}function Cc(t,n){return ls(t,n,function(e,r){return $i(t,r)})}function ls(t,n,e){for(var r=-1,u=n.length,o={};++r<u;){var a=n[r],c=Wn(t,a);e(c,a)&&ye(o,An(a,t),c)}return o}function Ic(t){return function(n){return Wn(n,t)}}function di(t,n,e,r){var u=r?Ya:Hn,o=-1,a=n.length,c=t;for(t===n&&(n=St(n)),e&&(c=nt(t,Tt(e)));++o<a;)for(var d=0,y=n[o],m=e?e(y):y;(d=u(c,m,d,r))>-1;)c!==t&&Ge.call(c,d,1),Ge.call(t,d,1);return t}function hs(t,n){for(var e=t?n.length:0,r=e-1;e--;){var u=n[e];if(e==r||u!==o){var o=u;ln(u)?Ge.call(t,u,1):vi(t,u)}}return t}function pi(t,n){return t+Ye(Gu()*(n-t+1))}function Rc(t,n,e,r){for(var u=-1,o=ft(Ze((n-t)/(e||1)),0),a=g(o);o--;)a[r?o:++u]=t,t+=e;return a}function gi(t,n){var e="";if(!t||n<1||n>jt)return e;do n%2&&(e+=t),n=Ye(n/2),n&&(t+=t);while(n);return e}function M(t,n){return Oi(qs(t,n,Ct),t+"")}function Pc(t){return Yu(ee(t))}function Ec(t,n){var e=ee(t);return hr(e,On(n,0,e.length))}function ye(t,n,e,r){if(!et(t))return t;n=An(n,t);for(var u=-1,o=n.length,a=o-1,c=t;c!=null&&++u<o;){var d=en(n[u]),y=e;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(u!=a){var m=c[d];y=r?r(m,d,c):i,y===i&&(y=et(m)?m:ln(n[u+1])?[]:{})}ge(c,d,y),c=c[d]}return t}var ds=Xe?function(t,n){return Xe.set(t,n),t}:Ct,Tc=Je?function(t,n){return Je(t,"toString",{configurable:!0,enumerable:!1,value:qi(n),writable:!0})}:Ct;function Lc(t){return hr(ee(t))}function Kt(t,n,e){var r=-1,u=t.length;n<0&&(n=-n>u?0:u+n),e=e>u?u:e,e<0&&(e+=u),u=n>e?0:e-n>>>0,n>>>=0;for(var o=g(u);++r<u;)o[r]=t[r+n];return o}function Oc(t,n){var e;return xn(t,function(r,u,o){return e=n(r,u,o),!e}),!!e}function rr(t,n,e){var r=0,u=t==null?r:t.length;if(typeof n=="number"&&n===n&&u<=Ir){for(;r<u;){var o=r+u>>>1,a=t[o];a!==null&&!Ot(a)&&(e?a<=n:a<n)?r=o+1:u=o}return u}return _i(t,n,Ct,e)}function _i(t,n,e,r){var u=0,o=t==null?0:t.length;if(o===0)return 0;n=e(n);for(var a=n!==n,c=n===null,d=Ot(n),y=n===i;u<o;){var m=Ye((u+o)/2),S=e(t[m]),A=S!==i,R=S===null,L=S===S,U=Ot(S);if(a)var O=r||L;else y?O=L&&(r||A):c?O=L&&A&&(r||!R):d?O=L&&A&&!R&&(r||!U):R||U?O=!1:O=r?S<=n:S<n;O?u=m+1:o=m}return pt(o,Ee)}function ps(t,n){for(var e=-1,r=t.length,u=0,o=[];++e<r;){var a=t[e],c=n?n(a):a;if(!e||!Xt(c,d)){var d=c;o[u++]=a===0?0:a}}return o}function gs(t){return typeof t=="number"?t:Ot(t)?Kn:+t}function Lt(t){if(typeof t=="string")return t;if(F(t))return nt(t,Lt)+"";if(Ot(t))return Ju?Ju.call(t):"";var n=t+"";return n=="0"&&1/t==-rn?"-0":n}function Sn(t,n,e){var r=-1,u=Ne,o=t.length,a=!0,c=[],d=c;if(e)a=!1,u=zr;else if(o>=_){var y=n?null:kc(t);if(y)return Be(y);a=!1,u=fe,d=new Ln}else d=n?[]:c;t:for(;++r<o;){var m=t[r],S=n?n(m):m;if(m=e||m!==0?m:0,a&&S===S){for(var A=d.length;A--;)if(d[A]===S)continue t;n&&d.push(S),c.push(m)}else u(d,S,e)||(d!==c&&d.push(S),c.push(m))}return c}function vi(t,n){return n=An(n,t),t=ks(t,n),t==null||delete t[en(qt(n))]}function _s(t,n,e,r){return ye(t,n,e(Wn(t,n)),r)}function ir(t,n,e,r){for(var u=t.length,o=r?u:-1;(r?o--:++o<u)&&n(t[o],o,t););return e?Kt(t,r?0:o,r?o+1:u):Kt(t,r?o+1:0,r?u:o)}function vs(t,n){var e=t;return e instanceof q&&(e=e.value()),Gr(n,function(r,u){return u.func.apply(u.thisArg,wn([r],u.args))},e)}function wi(t,n,e){var r=t.length;if(r<2)return r?Sn(t[0]):[];for(var u=-1,o=g(r);++u<r;)for(var a=t[u],c=-1;++c<r;)c!=u&&(o[u]=_e(o[u]||a,t[c],n,e));return Sn(dt(o,1),n,e)}function ws(t,n,e){for(var r=-1,u=t.length,o=n.length,a={};++r<u;){var c=r<o?n[r]:i;e(a,t[r],c)}return a}function yi(t){return ut(t)?t:[]}function mi(t){return typeof t=="function"?t:Ct}function An(t,n){return F(t)?t:Ei(t,n)?[t]:Js(Y(t))}var Wc=M;function bn(t,n,e){var r=t.length;return e=e===i?r:e,!n&&e>=r?t:Kt(t,n,e)}var ys=mf||function(t){return ht.clearTimeout(t)};function ms(t,n){if(n)return t.slice();var e=t.length,r=Ku?Ku(e):new t.constructor(e);return t.copy(r),r}function xi(t){var n=new t.constructor(t.byteLength);return new He(n).set(new He(t)),n}function Dc(t,n){var e=n?xi(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}function Fc(t){var n=new t.constructor(t.source,ru.exec(t));return n.lastIndex=t.lastIndex,n}function Nc(t){return pe?Q(pe.call(t)):{}}function xs(t,n){var e=n?xi(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}function Ss(t,n){if(t!==n){var e=t!==i,r=t===null,u=t===t,o=Ot(t),a=n!==i,c=n===null,d=n===n,y=Ot(n);if(!c&&!y&&!o&&t>n||o&&a&&d&&!c&&!y||r&&a&&d||!e&&d||!u)return 1;if(!r&&!o&&!y&&t<n||y&&e&&u&&!r&&!o||c&&e&&u||!a&&u||!d)return-1}return 0}function Uc(t,n,e){for(var r=-1,u=t.criteria,o=n.criteria,a=u.length,c=e.length;++r<a;){var d=Ss(u[r],o[r]);if(d){if(r>=c)return d;var y=e[r];return d*(y=="desc"?-1:1)}}return t.index-n.index}function As(t,n,e,r){for(var u=-1,o=t.length,a=e.length,c=-1,d=n.length,y=ft(o-a,0),m=g(d+y),S=!r;++c<d;)m[c]=n[c];for(;++u<a;)(S||u<o)&&(m[e[u]]=t[u]);for(;y--;)m[c++]=t[u++];return m}function bs(t,n,e,r){for(var u=-1,o=t.length,a=-1,c=e.length,d=-1,y=n.length,m=ft(o-c,0),S=g(m+y),A=!r;++u<m;)S[u]=t[u];for(var R=u;++d<y;)S[R+d]=n[d];for(;++a<c;)(A||u<o)&&(S[R+e[a]]=t[u++]);return S}function St(t,n){var e=-1,r=t.length;for(n||(n=g(r));++e<r;)n[e]=t[e];return n}function nn(t,n,e,r){var u=!e;e||(e={});for(var o=-1,a=n.length;++o<a;){var c=n[o],d=r?r(e[c],t[c],c,e,t):i;d===i&&(d=t[c]),u?an(e,c,d):ge(e,c,d)}return e}function Bc(t,n){return nn(t,Pi(t),n)}function Mc(t,n){return nn(t,Us(t),n)}function ur(t,n){return function(e,r){var u=F(e)?ka:oc,o=n?n():{};return u(e,t,T(r,2),o)}}function Vn(t){return M(function(n,e){var r=-1,u=e.length,o=u>1?e[u-1]:i,a=u>2?e[2]:i;for(o=t.length>3&&typeof o=="function"?(u--,o):i,a&&yt(e[0],e[1],a)&&(o=u<3?i:o,u=1),n=Q(n);++r<u;){var c=e[r];c&&t(n,c,r,o)}return n})}function Cs(t,n){return function(e,r){if(e==null)return e;if(!At(e))return t(e,r);for(var u=e.length,o=n?u:-1,a=Q(e);(n?o--:++o<u)&&r(a[o],o,a)!==!1;);return e}}function Is(t){return function(n,e,r){for(var u=-1,o=Q(n),a=r(n),c=a.length;c--;){var d=a[t?c:++u];if(e(o[d],d,o)===!1)break}return n}}function $c(t,n,e){var r=n&_t,u=me(t);function o(){var a=this&&this!==ht&&this instanceof o?u:t;return a.apply(r?e:this,arguments)}return o}function Rs(t){return function(n){n=Y(n);var e=zn(n)?Zt(n):i,r=e?e[0]:n.charAt(0),u=e?bn(e,1).join(""):n.slice(1);return r[t]()+u}}function jn(t){return function(n){return Gr(Io(Co(n).replace(Ea,"")),t,"")}}function me(t){return function(){var n=arguments;switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3]);case 5:return new t(n[0],n[1],n[2],n[3],n[4]);case 6:return new t(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var e=Qn(t.prototype),r=t.apply(e,n);return et(r)?r:e}}function Kc(t,n,e){var r=me(t);function u(){for(var o=arguments.length,a=g(o),c=o,d=te(u);c--;)a[c]=arguments[c];var y=o<3&&a[0]!==d&&a[o-1]!==d?[]:yn(a,d);if(o-=y.length,o<e)return Os(t,n,sr,u.placeholder,i,a,y,i,i,e-o);var m=this&&this!==ht&&this instanceof u?r:t;return Et(m,this,a)}return u}function Ps(t){return function(n,e,r){var u=Q(n);if(!At(n)){var o=T(e,3);n=lt(n),e=function(c){return o(u[c],c,u)}}var a=t(n,e,r);return a>-1?u[o?n[a]:a]:i}}function Es(t){return cn(function(n){var e=n.length,r=e,u=Mt.prototype.thru;for(t&&n.reverse();r--;){var o=n[r];if(typeof o!="function")throw new Bt(x);if(u&&!a&&cr(o)=="wrapper")var a=new Mt([],!0)}for(r=a?r:e;++r<e;){o=n[r];var c=cr(o),d=c=="wrapper"?Ii(o):i;d&&Ti(d[0])&&d[1]==(xt|ot|Ht|Rt)&&!d[4].length&&d[9]==1?a=a[cr(d[0])].apply(a,d[3]):a=o.length==1&&Ti(o)?a[c]():a.thru(o)}return function(){var y=arguments,m=y[0];if(a&&y.length==1&&F(m))return a.plant(m).value();for(var S=0,A=e?n[S].apply(this,y):m;++S<e;)A=n[S].call(this,A);return A}})}function sr(t,n,e,r,u,o,a,c,d,y){var m=n&xt,S=n&_t,A=n&It,R=n&(ot|In),L=n&Mn,U=A?i:me(t);function O(){for(var K=arguments.length,H=g(K),Wt=K;Wt--;)H[Wt]=arguments[Wt];if(R)var mt=te(O),Dt=Va(H,mt);if(r&&(H=As(H,r,u,R)),o&&(H=bs(H,o,a,R)),K-=Dt,R&&K<y){var st=yn(H,mt);return Os(t,n,sr,O.placeholder,e,H,st,c,d,y-K)}var Qt=S?e:this,pn=A?Qt[t]:t;return K=H.length,c?H=ol(H,c):L&&K>1&&H.reverse(),m&&d<K&&(H.length=d),this&&this!==ht&&this instanceof O&&(pn=U||me(pn)),pn.apply(Qt,H)}return O}function Ts(t,n){return function(e,r){return gc(e,t,n(r),{})}}function or(t,n){return function(e,r){var u;if(e===i&&r===i)return n;if(e!==i&&(u=e),r!==i){if(u===i)return r;typeof e=="string"||typeof r=="string"?(e=Lt(e),r=Lt(r)):(e=gs(e),r=gs(r)),u=t(e,r)}return u}}function Si(t){return cn(function(n){return n=nt(n,Tt(T())),M(function(e){var r=this;return t(n,function(u){return Et(u,r,e)})})})}function ar(t,n){n=n===i?" ":Lt(n);var e=n.length;if(e<2)return e?gi(n,t):n;var r=gi(n,Ze(t/Gn(n)));return zn(n)?bn(Zt(r),0,t).join(""):r.slice(0,t)}function qc(t,n,e,r){var u=n&_t,o=me(t);function a(){for(var c=-1,d=arguments.length,y=-1,m=r.length,S=g(m+d),A=this&&this!==ht&&this instanceof a?o:t;++y<m;)S[y]=r[y];for(;d--;)S[y++]=arguments[++c];return Et(A,u?e:this,S)}return a}function Ls(t){return function(n,e,r){return r&&typeof r!="number"&&yt(n,e,r)&&(e=r=i),n=dn(n),e===i?(e=n,n=0):e=dn(e),r=r===i?n<e?1:-1:dn(r),Rc(n,e,r,t)}}function fr(t){return function(n,e){return typeof n=="string"&&typeof e=="string"||(n=kt(n),e=kt(e)),t(n,e)}}function Os(t,n,e,r,u,o,a,c,d,y){var m=n&ot,S=m?a:i,A=m?i:a,R=m?o:i,L=m?i:o;n|=m?Ht:gn,n&=~(m?gn:Ht),n&Vt||(n&=-4);var U=[t,n,u,R,S,L,A,c,d,y],O=e.apply(i,U);return Ti(t)&&Hs(O,U),O.placeholder=r,zs(O,t,n)}function Ai(t){var n=at[t];return function(e,r){if(e=kt(e),r=r==null?0:pt(N(r),292),r&&zu(e)){var u=(Y(e)+"e").split("e"),o=n(u[0]+"e"+(+u[1]+r));return u=(Y(o)+"e").split("e"),+(u[0]+"e"+(+u[1]-r))}return n(e)}}var kc=Yn&&1/Be(new Yn([,-0]))[1]==rn?function(t){return new Yn(t)}:zi;function Ws(t){return function(n){var e=gt(n);return e==Gt?jr(n):e==Jt?sf(n):Qa(n,t(n))}}function fn(t,n,e,r,u,o,a,c){var d=n&It;if(!d&&typeof t!="function")throw new Bt(x);var y=r?r.length:0;if(y||(n&=-97,r=u=i),a=a===i?a:ft(N(a),0),c=c===i?c:N(c),y-=u?u.length:0,n&gn){var m=r,S=u;r=u=i}var A=d?i:Ii(t),R=[t,n,e,r,u,m,S,o,a,c];if(A&&il(R,A),t=R[0],n=R[1],e=R[2],r=R[3],u=R[4],c=R[9]=R[9]===i?d?0:t.length:ft(R[9]-y,0),!c&&n&(ot|In)&&(n&=-25),!n||n==_t)var L=$c(t,n,e);else n==ot||n==In?L=Kc(t,n,c):(n==Ht||n==(_t|Ht))&&!u.length?L=qc(t,n,e,r):L=sr.apply(i,R);var U=A?ds:Hs;return zs(U(L,R),t,n)}function Ds(t,n,e,r){return t===i||Xt(t,Zn[e])&&!X.call(r,e)?n:t}function Fs(t,n,e,r,u,o){return et(t)&&et(n)&&(o.set(n,t),er(t,n,i,Fs,o),o.delete(n)),t}function Hc(t){return Ae(t)?i:t}function Ns(t,n,e,r,u,o){var a=e&Z,c=t.length,d=n.length;if(c!=d&&!(a&&d>c))return!1;var y=o.get(t),m=o.get(n);if(y&&m)return y==n&&m==t;var S=-1,A=!0,R=e&$?new Ln:i;for(o.set(t,n),o.set(n,t);++S<c;){var L=t[S],U=n[S];if(r)var O=a?r(U,L,S,n,t,o):r(L,U,S,t,n,o);if(O!==i){if(O)continue;A=!1;break}if(R){if(!Jr(n,function(K,H){if(!fe(R,H)&&(L===K||u(L,K,e,r,o)))return R.push(H)})){A=!1;break}}else if(!(L===U||u(L,U,e,r,o))){A=!1;break}}return o.delete(t),o.delete(n),A}function zc(t,n,e,r,u,o,a){switch(e){case qn:if(t.byteLength!=n.byteLength||t.byteOffset!=n.byteOffset)return!1;t=t.buffer,n=n.buffer;case ae:return!(t.byteLength!=n.byteLength||!o(new He(t),new He(n)));case _n:case vt:case ie:return Xt(+t,+n);case Te:return t.name==n.name&&t.message==n.message;case ue:case se:return t==n+"";case Gt:var c=jr;case Jt:var d=r&Z;if(c||(c=Be),t.size!=n.size&&!d)return!1;var y=a.get(t);if(y)return y==n;r|=$,a.set(t,n);var m=Ns(c(t),c(n),r,u,o,a);return a.delete(t),m;case Oe:if(pe)return pe.call(t)==pe.call(n)}return!1}function Gc(t,n,e,r,u,o){var a=e&Z,c=bi(t),d=c.length,y=bi(n),m=y.length;if(d!=m&&!a)return!1;for(var S=d;S--;){var A=c[S];if(!(a?A in n:X.call(n,A)))return!1}var R=o.get(t),L=o.get(n);if(R&&L)return R==n&&L==t;var U=!0;o.set(t,n),o.set(n,t);for(var O=a;++S<d;){A=c[S];var K=t[A],H=n[A];if(r)var Wt=a?r(H,K,A,n,t,o):r(K,H,A,t,n,o);if(!(Wt===i?K===H||u(K,H,e,r,o):Wt)){U=!1;break}O||(O=A=="constructor")}if(U&&!O){var mt=t.constructor,Dt=n.constructor;mt!=Dt&&"constructor"in t&&"constructor"in n&&!(typeof mt=="function"&&mt instanceof mt&&typeof Dt=="function"&&Dt instanceof Dt)&&(U=!1)}return o.delete(t),o.delete(n),U}function cn(t){return Oi(qs(t,i,Qs),t+"")}function bi(t){return es(t,lt,Pi)}function Ci(t){return es(t,bt,Us)}var Ii=Xe?function(t){return Xe.get(t)}:zi;function cr(t){for(var n=t.name+"",e=Xn[n],r=X.call(Xn,n)?e.length:0;r--;){var u=e[r],o=u.func;if(o==null||o==t)return u.name}return n}function te(t){var n=X.call(s,"placeholder")?s:t;return n.placeholder}function T(){var t=s.iteratee||ki;return t=t===ki?us:t,arguments.length?t(arguments[0],arguments[1]):t}function lr(t,n){var e=t.__data__;return tl(n)?e[typeof n=="string"?"string":"hash"]:e.map}function Ri(t){for(var n=lt(t),e=n.length;e--;){var r=n[e],u=t[r];n[e]=[r,u,$s(u)]}return n}function Dn(t,n){var e=ef(t,n);return is(e)?e:i}function Jc(t){var n=X.call(t,En),e=t[En];try{t[En]=i;var r=!0}catch{}var u=qe.call(t);return r&&(n?t[En]=e:delete t[En]),u}var Pi=ni?function(t){return t==null?[]:(t=Q(t),vn(ni(t),function(n){return ku.call(t,n)}))}:Gi,Us=ni?function(t){for(var n=[];t;)wn(n,Pi(t)),t=ze(t);return n}:Gi,gt=wt;(ei&&gt(new ei(new ArrayBuffer(1)))!=qn||le&&gt(new le)!=Gt||ri&&gt(ri.resolve())!=ji||Yn&&gt(new Yn)!=Jt||he&&gt(new he)!=oe)&&(gt=function(t){var n=wt(t),e=n==un?t.constructor:i,r=e?Fn(e):"";if(r)switch(r){case Ef:return qn;case Tf:return Gt;case Lf:return ji;case Of:return Jt;case Wf:return oe}return n});function Zc(t,n,e){for(var r=-1,u=e.length;++r<u;){var o=e[r],a=o.size;switch(o.type){case"drop":t+=a;break;case"dropRight":n-=a;break;case"take":n=pt(n,t+a);break;case"takeRight":t=ft(t,n-a);break}}return{start:t,end:n}}function Yc(t){var n=t.match(ta);return n?n[1].split(na):[]}function Bs(t,n,e){n=An(n,t);for(var r=-1,u=n.length,o=!1;++r<u;){var a=en(n[r]);if(!(o=t!=null&&e(t,a)))break;t=t[a]}return o||++r!=u?o:(u=t==null?0:t.length,!!u&&wr(u)&&ln(a,u)&&(F(t)||Nn(t)))}function Xc(t){var n=t.length,e=new t.constructor(n);return n&&typeof t[0]=="string"&&X.call(t,"index")&&(e.index=t.index,e.input=t.input),e}function Ms(t){return typeof t.constructor=="function"&&!xe(t)?Qn(ze(t)):{}}function Qc(t,n,e){var r=t.constructor;switch(n){case ae:return xi(t);case _n:case vt:return new r(+t);case qn:return Dc(t,e);case Rr:case Pr:case Er:case Tr:case Lr:case Or:case Wr:case Dr:case Fr:return xs(t,e);case Gt:return new r;case ie:case se:return new r(t);case ue:return Fc(t);case Jt:return new r;case Oe:return Nc(t)}}function Vc(t,n){var e=n.length;if(!e)return t;var r=e-1;return n[r]=(e>1?"& ":"")+n[r],n=n.join(e>2?", ":" "),t.replace(jo,`{
9
9
  /* [wrapped with `+n+`] */
10
- `)}function jc(t){return F(t)||Nn(t)||!!(Hu&&t&&t[Hu])}function ln(t,n){var e=typeof t;return n=n??jt,!!n&&(e=="number"||e!="symbol"&&ca.test(t))&&t>-1&&t%1==0&&t<n}function yt(t,n,e){if(!et(e))return!1;var r=typeof n;return(r=="number"?At(e)&&ln(n,e.length):r=="string"&&n in e)?Xt(e[n],t):!1}function Ei(t,n){if(F(t))return!1;var e=typeof t;return e=="number"||e=="symbol"||e=="boolean"||t==null||Lt(t)?!0:Yo.test(t)||!Zo.test(t)||n!=null&&t in Q(n)}function tl(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}function Ti(t){var n=cr(t),e=s[n];if(typeof e!="function"||!(n in q.prototype))return!1;if(t===e)return!0;var r=Ii(e);return!!r&&t===r[0]}function nl(t){return!!$u&&$u in t}var el=$e?hn:Ji;function xe(t){var n=t&&t.constructor,e=typeof n=="function"&&n.prototype||Jn;return t===e}function $s(t){return t===t&&!et(t)}function Ks(t,n){return function(e){return e==null?!1:e[t]===n&&(n!==i||t in Q(e))}}function rl(t){var n=_r(t,function(r){return e.size===B&&e.clear(),r}),e=n.cache;return n}function il(t,n){var e=t[1],r=n[1],u=e|r,o=u<(_t|It|xt),a=r==xt&&e==st||r==xt&&e==Dt&&t[7].length<=n[8]||r==(xt|Dt)&&n[7].length<=n[8]&&e==st;if(!(o||a))return t;r&_t&&(t[2]=n[2],u|=e&_t?0:Vt);var c=n[3];if(c){var d=t[3];t[3]=d?As(d,c,n[4]):c,t[4]=d?yn(t[3],C):n[4]}return c=n[5],c&&(d=t[5],t[5]=d?bs(d,c,n[6]):c,t[6]=d?yn(t[5],C):n[6]),c=n[7],c&&(t[7]=c),r&xt&&(t[8]=t[8]==null?n[8]:pt(t[8],n[8])),t[9]==null&&(t[9]=n[9]),t[0]=n[0],t[1]=u,t}function ul(t){var n=[];if(t!=null)for(var e in Q(t))n.push(e);return n}function sl(t){return qe.call(t)}function qs(t,n,e){return n=at(n===i?t.length-1:n,0),function(){for(var r=arguments,u=-1,o=at(r.length-n,0),a=g(o);++u<o;)a[u]=r[n+u];u=-1;for(var c=g(n+1);++u<n;)c[u]=r[u];return c[n]=e(a),Pt(t,this,c)}}function ks(t,n){return n.length<2?t:Wn(t,Kt(n,0,-1))}function ol(t,n){for(var e=t.length,r=pt(n.length,e),u=St(t);r--;){var o=n[r];t[r]=ln(o,e)?u[o]:i}return t}function Li(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}var Hs=Gs(ds),Se=Sf||function(t,n){return ht.setTimeout(t,n)},Oi=Gs(Tc);function zs(t,n,e){var r=n+"";return Oi(t,Vc(r,al(Yc(r),e)))}function Gs(t){var n=0,e=0;return function(){var r=If(),u=Mn-(r-e);if(e=r,u>0){if(++n>=Pe)return arguments[0]}else n=0;return t.apply(i,arguments)}}function hr(t,n){var e=-1,r=t.length,u=r-1;for(n=n===i?r:n;++e<n;){var o=pi(e,u),a=t[o];t[o]=t[e],t[e]=a}return t.length=n,t}var Js=rl(function(t){var n=[];return t.charCodeAt(0)===46&&n.push(""),t.replace(Xo,function(e,r,u,o){n.push(u?o.replace(ia,"$1"):r||e)}),n});function en(t){if(typeof t=="string"||Lt(t))return t;var n=t+"";return n=="0"&&1/t==-rn?"-0":n}function Fn(t){if(t!=null){try{return Ke.call(t)}catch{}try{return t+""}catch{}}return""}function al(t,n){return Ut(X,function(e){var r="_."+e[0];n&e[1]&&!Ne(t,r)&&t.push(r)}),t.sort()}function Zs(t){if(t instanceof q)return t.clone();var n=new Mt(t.__wrapped__,t.__chain__);return n.__actions__=St(t.__actions__),n.__index__=t.__index__,n.__values__=t.__values__,n}function fl(t,n,e){(e?yt(t,n,e):n===i)?n=1:n=at(N(n),0);var r=t==null?0:t.length;if(!r||n<1)return[];for(var u=0,o=0,a=g(Ze(r/n));u<r;)a[o++]=Kt(t,u,u+=n);return a}function cl(t){for(var n=-1,e=t==null?0:t.length,r=0,u=[];++n<e;){var o=t[n];o&&(u[r++]=o)}return u}function ll(){var t=arguments.length;if(!t)return[];for(var n=g(t-1),e=arguments[0],r=t;r--;)n[r-1]=arguments[r];return wn(F(e)?St(e):[e],dt(n,1))}var hl=M(function(t,n){return it(t)?_e(t,dt(n,1,it,!0)):[]}),dl=M(function(t,n){var e=qt(n);return it(e)&&(e=i),it(t)?_e(t,dt(n,1,it,!0),E(e,2)):[]}),pl=M(function(t,n){var e=qt(n);return it(e)&&(e=i),it(t)?_e(t,dt(n,1,it,!0),i,e):[]});function gl(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:N(n),Kt(t,n<0?0:n,r)):[]}function _l(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:N(n),n=r-n,Kt(t,0,n<0?0:n)):[]}function vl(t,n){return t&&t.length?ir(t,E(n,3),!0,!0):[]}function wl(t,n){return t&&t.length?ir(t,E(n,3),!0):[]}function yl(t,n,e,r){var u=t==null?0:t.length;return u?(e&&typeof e!="number"&&yt(t,n,e)&&(e=0,r=u),lc(t,n,e,r)):[]}function Ys(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var u=e==null?0:N(e);return u<0&&(u=at(r+u,0)),Ue(t,E(n,3),u)}function Xs(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var u=r-1;return e!==i&&(u=N(e),u=e<0?at(r+u,0):pt(u,r-1)),Ue(t,E(n,3),u,!0)}function Qs(t){var n=t==null?0:t.length;return n?dt(t,1):[]}function ml(t){var n=t==null?0:t.length;return n?dt(t,rn):[]}function xl(t,n){var e=t==null?0:t.length;return e?(n=n===i?1:N(n),dt(t,n)):[]}function Sl(t){for(var n=-1,e=t==null?0:t.length,r={};++n<e;){var u=t[n];r[u[0]]=u[1]}return r}function Vs(t){return t&&t.length?t[0]:i}function Al(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var u=e==null?0:N(e);return u<0&&(u=at(r+u,0)),kn(t,n,u)}function bl(t){var n=t==null?0:t.length;return n?Kt(t,0,-1):[]}var Cl=M(function(t){var n=nt(t,yi);return n.length&&n[0]===t[0]?fi(n):[]}),Il=M(function(t){var n=qt(t),e=nt(t,yi);return n===qt(e)?n=i:e.pop(),e.length&&e[0]===t[0]?fi(e,E(n,2)):[]}),Rl=M(function(t){var n=qt(t),e=nt(t,yi);return n=typeof n=="function"?n:i,n&&e.pop(),e.length&&e[0]===t[0]?fi(e,i,n):[]});function Pl(t,n){return t==null?"":bf.call(t,n)}function qt(t){var n=t==null?0:t.length;return n?t[n-1]:i}function El(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var u=r;return e!==i&&(u=N(e),u=u<0?at(r+u,0):pt(u,r-1)),n===n?af(t,n,u):Ue(t,Ou,u,!0)}function Tl(t,n){return t&&t.length?fs(t,N(n)):i}var Ll=M(js);function js(t,n){return t&&t.length&&n&&n.length?di(t,n):t}function Ol(t,n,e){return t&&t.length&&n&&n.length?di(t,n,E(e,2)):t}function Wl(t,n,e){return t&&t.length&&n&&n.length?di(t,n,i,e):t}var Dl=cn(function(t,n){var e=t==null?0:t.length,r=ui(t,n);return hs(t,nt(n,function(u){return ln(u,e)?+u:u}).sort(Ss)),r});function Fl(t,n){var e=[];if(!(t&&t.length))return e;var r=-1,u=[],o=t.length;for(n=E(n,3);++r<o;){var a=t[r];n(a,r,t)&&(e.push(a),u.push(r))}return hs(t,u),e}function Wi(t){return t==null?t:Pf.call(t)}function Nl(t,n,e){var r=t==null?0:t.length;return r?(e&&typeof e!="number"&&yt(t,n,e)?(n=0,e=r):(n=n==null?0:N(n),e=e===i?r:N(e)),Kt(t,n,e)):[]}function Ul(t,n){return rr(t,n)}function Bl(t,n,e){return _i(t,n,E(e,2))}function Ml(t,n){var e=t==null?0:t.length;if(e){var r=rr(t,n);if(r<e&&Xt(t[r],n))return r}return-1}function $l(t,n){return rr(t,n,!0)}function Kl(t,n,e){return _i(t,n,E(e,2),!0)}function ql(t,n){var e=t==null?0:t.length;if(e){var r=rr(t,n,!0)-1;if(Xt(t[r],n))return r}return-1}function kl(t){return t&&t.length?ps(t):[]}function Hl(t,n){return t&&t.length?ps(t,E(n,2)):[]}function zl(t){var n=t==null?0:t.length;return n?Kt(t,1,n):[]}function Gl(t,n,e){return t&&t.length?(n=e||n===i?1:N(n),Kt(t,0,n<0?0:n)):[]}function Jl(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:N(n),n=r-n,Kt(t,n<0?0:n,r)):[]}function Zl(t,n){return t&&t.length?ir(t,E(n,3),!1,!0):[]}function Yl(t,n){return t&&t.length?ir(t,E(n,3)):[]}var Xl=M(function(t){return Sn(dt(t,1,it,!0))}),Ql=M(function(t){var n=qt(t);return it(n)&&(n=i),Sn(dt(t,1,it,!0),E(n,2))}),Vl=M(function(t){var n=qt(t);return n=typeof n=="function"?n:i,Sn(dt(t,1,it,!0),i,n)});function jl(t){return t&&t.length?Sn(t):[]}function th(t,n){return t&&t.length?Sn(t,E(n,2)):[]}function nh(t,n){return n=typeof n=="function"?n:i,t&&t.length?Sn(t,i,n):[]}function Di(t){if(!(t&&t.length))return[];var n=0;return t=vn(t,function(e){if(it(e))return n=at(e.length,n),!0}),Qr(n,function(e){return nt(t,Zr(e))})}function to(t,n){if(!(t&&t.length))return[];var e=Di(t);return n==null?e:nt(e,function(r){return Pt(n,i,r)})}var eh=M(function(t,n){return it(t)?_e(t,n):[]}),rh=M(function(t){return wi(vn(t,it))}),ih=M(function(t){var n=qt(t);return it(n)&&(n=i),wi(vn(t,it),E(n,2))}),uh=M(function(t){var n=qt(t);return n=typeof n=="function"?n:i,wi(vn(t,it),i,n)}),sh=M(Di);function oh(t,n){return ws(t||[],n||[],ge)}function ah(t,n){return ws(t||[],n||[],ye)}var fh=M(function(t){var n=t.length,e=n>1?t[n-1]:i;return e=typeof e=="function"?(t.pop(),e):i,to(t,e)});function no(t){var n=s(t);return n.__chain__=!0,n}function ch(t,n){return n(t),t}function dr(t,n){return n(t)}var lh=cn(function(t){var n=t.length,e=n?t[0]:0,r=this.__wrapped__,u=function(o){return ui(o,t)};return n>1||this.__actions__.length||!(r instanceof q)||!ln(e)?this.thru(u):(r=r.slice(e,+e+(n?1:0)),r.__actions__.push({func:dr,args:[u],thisArg:i}),new Mt(r,this.__chain__).thru(function(o){return n&&!o.length&&o.push(i),o}))});function hh(){return no(this)}function dh(){return new Mt(this.value(),this.__chain__)}function ph(){this.__values__===i&&(this.__values__=_o(this.value()));var t=this.__index__>=this.__values__.length,n=t?i:this.__values__[this.__index__++];return{done:t,value:n}}function gh(){return this}function _h(t){for(var n,e=this;e instanceof Ve;){var r=Zs(e);r.__index__=0,r.__values__=i,n?u.__wrapped__=r:n=r;var u=r;e=e.__wrapped__}return u.__wrapped__=t,n}function vh(){var t=this.__wrapped__;if(t instanceof q){var n=t;return this.__actions__.length&&(n=new q(this)),n=n.reverse(),n.__actions__.push({func:dr,args:[Wi],thisArg:i}),new Mt(n,this.__chain__)}return this.thru(Wi)}function wh(){return vs(this.__wrapped__,this.__actions__)}var yh=ur(function(t,n,e){Y.call(t,e)?++t[e]:an(t,e,1)});function mh(t,n,e){var r=F(t)?Tu:cc;return e&&yt(t,n,e)&&(n=i),r(t,E(n,3))}function xh(t,n){var e=F(t)?vn:ts;return e(t,E(n,3))}var Sh=Ps(Ys),Ah=Ps(Xs);function bh(t,n){return dt(pr(t,n),1)}function Ch(t,n){return dt(pr(t,n),rn)}function Ih(t,n,e){return e=e===i?1:N(e),dt(pr(t,n),e)}function eo(t,n){var e=F(t)?Ut:xn;return e(t,E(n,3))}function ro(t,n){var e=F(t)?Ha:ju;return e(t,E(n,3))}var Rh=ur(function(t,n,e){Y.call(t,e)?t[e].push(n):an(t,e,[n])});function Ph(t,n,e,r){t=At(t)?t:ne(t),e=e&&!r?N(e):0;var u=t.length;return e<0&&(e=at(u+e,0)),yr(t)?e<=u&&t.indexOf(n,e)>-1:!!u&&kn(t,n,e)>-1}var Eh=M(function(t,n,e){var r=-1,u=typeof n=="function",o=At(t)?g(t.length):[];return xn(t,function(a){o[++r]=u?Pt(n,a,e):ve(a,n,e)}),o}),Th=ur(function(t,n,e){an(t,e,n)});function pr(t,n){var e=F(t)?nt:ss;return e(t,E(n,3))}function Lh(t,n,e,r){return t==null?[]:(F(n)||(n=n==null?[]:[n]),e=r?i:e,F(e)||(e=e==null?[]:[e]),cs(t,n,e))}var Oh=ur(function(t,n,e){t[e?0:1].push(n)},function(){return[[],[]]});function Wh(t,n,e){var r=F(t)?Gr:Du,u=arguments.length<3;return r(t,E(n,4),e,u,xn)}function Dh(t,n,e){var r=F(t)?za:Du,u=arguments.length<3;return r(t,E(n,4),e,u,ju)}function Fh(t,n){var e=F(t)?vn:ts;return e(t,vr(E(n,3)))}function Nh(t){var n=F(t)?Yu:Pc;return n(t)}function Uh(t,n,e){(e?yt(t,n,e):n===i)?n=1:n=N(n);var r=F(t)?uc:Ec;return r(t,n)}function Bh(t){var n=F(t)?sc:Lc;return n(t)}function Mh(t){if(t==null)return 0;if(At(t))return yr(t)?zn(t):t.length;var n=gt(t);return n==Gt||n==Jt?t.size:li(t).length}function $h(t,n,e){var r=F(t)?Jr:Oc;return e&&yt(t,n,e)&&(n=i),r(t,E(n,3))}var Kh=M(function(t,n){if(t==null)return[];var e=n.length;return e>1&&yt(t,n[0],n[1])?n=[]:e>2&&yt(n[0],n[1],n[2])&&(n=[n[0]]),cs(t,dt(n,1),[])}),gr=xf||function(){return ht.Date.now()};function qh(t,n){if(typeof n!="function")throw new Bt(x);return t=N(t),function(){if(--t<1)return n.apply(this,arguments)}}function io(t,n,e){return n=e?i:n,n=t&&n==null?t.length:n,fn(t,xt,i,i,i,i,n)}function uo(t,n){var e;if(typeof n!="function")throw new Bt(x);return t=N(t),function(){return--t>0&&(e=n.apply(this,arguments)),t<=1&&(n=i),e}}var Fi=M(function(t,n,e){var r=_t;if(e.length){var u=yn(e,jn(Fi));r|=Ht}return fn(t,r,n,e,u)}),so=M(function(t,n,e){var r=_t|It;if(e.length){var u=yn(e,jn(so));r|=Ht}return fn(n,r,t,e,u)});function oo(t,n,e){n=e?i:n;var r=fn(t,st,i,i,i,i,i,n);return r.placeholder=oo.placeholder,r}function ao(t,n,e){n=e?i:n;var r=fn(t,In,i,i,i,i,i,n);return r.placeholder=ao.placeholder,r}function fo(t,n,e){var r,u,o,a,c,d,y=0,m=!1,S=!1,A=!0;if(typeof t!="function")throw new Bt(x);n=kt(n)||0,et(e)&&(m=!!e.leading,S="maxWait"in e,o=S?at(kt(e.maxWait)||0,n):o,A="trailing"in e?!!e.trailing:A);function R(ut){var Qt=r,pn=u;return r=u=i,y=ut,a=t.apply(pn,Qt),a}function L(ut){return y=ut,c=Se(K,n),m?R(ut):a}function U(ut){var Qt=ut-d,pn=ut-y,Eo=n-Qt;return S?pt(Eo,o-pn):Eo}function O(ut){var Qt=ut-d,pn=ut-y;return d===i||Qt>=n||Qt<0||S&&pn>=o}function K(){var ut=gr();if(O(ut))return H(ut);c=Se(K,U(ut))}function H(ut){return c=i,A&&r?R(ut):(r=u=i,a)}function Ot(){c!==i&&ys(c),y=0,r=d=u=c=i}function mt(){return c===i?a:H(gr())}function Wt(){var ut=gr(),Qt=O(ut);if(r=arguments,u=this,d=ut,Qt){if(c===i)return L(d);if(S)return ys(c),c=Se(K,n),R(d)}return c===i&&(c=Se(K,n)),a}return Wt.cancel=Ot,Wt.flush=mt,Wt}var kh=M(function(t,n){return Vu(t,1,n)}),Hh=M(function(t,n,e){return Vu(t,kt(n)||0,e)});function zh(t){return fn(t,Bn)}function _r(t,n){if(typeof t!="function"||n!=null&&typeof n!="function")throw new Bt(x);var e=function(){var r=arguments,u=n?n.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var a=t.apply(this,r);return e.cache=o.set(u,a)||o,a};return e.cache=new(_r.Cache||on),e}_r.Cache=on;function vr(t){if(typeof t!="function")throw new Bt(x);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}function Gh(t){return uo(2,t)}var Jh=Wc(function(t,n){n=n.length==1&&F(n[0])?nt(n[0],Et(E())):nt(dt(n,1),Et(E()));var e=n.length;return M(function(r){for(var u=-1,o=pt(r.length,e);++u<o;)r[u]=n[u].call(this,r[u]);return Pt(t,this,r)})}),Ni=M(function(t,n){var e=yn(n,jn(Ni));return fn(t,Ht,i,n,e)}),co=M(function(t,n){var e=yn(n,jn(co));return fn(t,gn,i,n,e)}),Zh=cn(function(t,n){return fn(t,Dt,i,i,i,n)});function Yh(t,n){if(typeof t!="function")throw new Bt(x);return n=n===i?n:N(n),M(t,n)}function Xh(t,n){if(typeof t!="function")throw new Bt(x);return n=n==null?0:at(N(n),0),M(function(e){var r=e[n],u=bn(e,0,n);return r&&wn(u,r),Pt(t,this,u)})}function Qh(t,n,e){var r=!0,u=!0;if(typeof t!="function")throw new Bt(x);return et(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),fo(t,n,{leading:r,maxWait:n,trailing:u})}function Vh(t){return io(t,1)}function jh(t,n){return Ni(mi(n),t)}function td(){if(!arguments.length)return[];var t=arguments[0];return F(t)?t:[t]}function nd(t){return $t(t,G)}function ed(t,n){return n=typeof n=="function"?n:i,$t(t,G,n)}function rd(t){return $t(t,k|G)}function id(t,n){return n=typeof n=="function"?n:i,$t(t,k|G,n)}function ud(t,n){return n==null||Qu(t,n,lt(n))}function Xt(t,n){return t===n||t!==t&&n!==n}var sd=fr(ai),od=fr(function(t,n){return t>=n}),Nn=rs(function(){return arguments}())?rs:function(t){return rt(t)&&Y.call(t,"callee")&&!ku.call(t,"callee")},F=g.isArray,ad=bu?Et(bu):_c;function At(t){return t!=null&&wr(t.length)&&!hn(t)}function it(t){return rt(t)&&At(t)}function fd(t){return t===!0||t===!1||rt(t)&&wt(t)==_n}var Cn=Af||Ji,cd=Cu?Et(Cu):vc;function ld(t){return rt(t)&&t.nodeType===1&&!Ae(t)}function hd(t){if(t==null)return!0;if(At(t)&&(F(t)||typeof t=="string"||typeof t.splice=="function"||Cn(t)||te(t)||Nn(t)))return!t.length;var n=gt(t);if(n==Gt||n==Jt)return!t.size;if(xe(t))return!li(t).length;for(var e in t)if(Y.call(t,e))return!1;return!0}function dd(t,n){return we(t,n)}function pd(t,n,e){e=typeof e=="function"?e:i;var r=e?e(t,n):i;return r===i?we(t,n,i,e):!!r}function Ui(t){if(!rt(t))return!1;var n=wt(t);return n==Te||n==No||typeof t.message=="string"&&typeof t.name=="string"&&!Ae(t)}function gd(t){return typeof t=="number"&&zu(t)}function hn(t){if(!et(t))return!1;var n=wt(t);return n==Le||n==Vi||n==Rn||n==Bo}function lo(t){return typeof t=="number"&&t==N(t)}function wr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=jt}function et(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}function rt(t){return t!=null&&typeof t=="object"}var ho=Iu?Et(Iu):yc;function _d(t,n){return t===n||ci(t,n,Ri(n))}function vd(t,n,e){return e=typeof e=="function"?e:i,ci(t,n,Ri(n),e)}function wd(t){return po(t)&&t!=+t}function yd(t){if(el(t))throw new D(v);return is(t)}function md(t){return t===null}function xd(t){return t==null}function po(t){return typeof t=="number"||rt(t)&&wt(t)==ie}function Ae(t){if(!rt(t)||wt(t)!=un)return!1;var n=ze(t);if(n===null)return!0;var e=Y.call(n,"constructor")&&n.constructor;return typeof e=="function"&&e instanceof e&&Ke.call(e)==vf}var Bi=Ru?Et(Ru):mc;function Sd(t){return lo(t)&&t>=-jt&&t<=jt}var go=Pu?Et(Pu):xc;function yr(t){return typeof t=="string"||!F(t)&&rt(t)&&wt(t)==se}function Lt(t){return typeof t=="symbol"||rt(t)&&wt(t)==Oe}var te=Eu?Et(Eu):Sc;function Ad(t){return t===i}function bd(t){return rt(t)&&gt(t)==oe}function Cd(t){return rt(t)&&wt(t)==$o}var Id=fr(hi),Rd=fr(function(t,n){return t<=n});function _o(t){if(!t)return[];if(At(t))return yr(t)?Zt(t):St(t);if(ce&&t[ce])return uf(t[ce]());var n=gt(t),e=n==Gt?jr:n==Jt?Be:ne;return e(t)}function dn(t){if(!t)return t===0?t:0;if(t=kt(t),t===rn||t===-rn){var n=t<0?-1:1;return n*Cr}return t===t?t:0}function N(t){var n=dn(t),e=n%1;return n===n?e?n-e:n:0}function vo(t){return t?On(N(t),0,Ft):0}function kt(t){if(typeof t=="number")return t;if(Lt(t))return $n;if(et(t)){var n=typeof t.valueOf=="function"?t.valueOf():t;t=et(n)?n+"":n}if(typeof t!="string")return t===0?t:+t;t=Fu(t);var e=oa.test(t);return e||fa.test(t)?Ka(t.slice(2),e?2:8):sa.test(t)?$n:+t}function wo(t){return nn(t,bt(t))}function Pd(t){return t?On(N(t),-jt,jt):t===0?t:0}function Z(t){return t==null?"":Tt(t)}var Ed=Qn(function(t,n){if(xe(n)||At(n)){nn(n,lt(n),t);return}for(var e in n)Y.call(n,e)&&ge(t,e,n[e])}),yo=Qn(function(t,n){nn(n,bt(n),t)}),mr=Qn(function(t,n,e,r){nn(n,bt(n),t,r)}),Td=Qn(function(t,n,e,r){nn(n,lt(n),t,r)}),Ld=cn(ui);function Od(t,n){var e=Xn(t);return n==null?e:Xu(e,n)}var Wd=M(function(t,n){t=Q(t);var e=-1,r=n.length,u=r>2?n[2]:i;for(u&&yt(n[0],n[1],u)&&(r=1);++e<r;)for(var o=n[e],a=bt(o),c=-1,d=a.length;++c<d;){var y=a[c],m=t[y];(m===i||Xt(m,Jn[y])&&!Y.call(t,y))&&(t[y]=o[y])}return t}),Dd=M(function(t){return t.push(i,Fs),Pt(mo,i,t)});function Fd(t,n){return Lu(t,E(n,3),tn)}function Nd(t,n){return Lu(t,E(n,3),oi)}function Ud(t,n){return t==null?t:si(t,E(n,3),bt)}function Bd(t,n){return t==null?t:ns(t,E(n,3),bt)}function Md(t,n){return t&&tn(t,E(n,3))}function $d(t,n){return t&&oi(t,E(n,3))}function Kd(t){return t==null?[]:nr(t,lt(t))}function qd(t){return t==null?[]:nr(t,bt(t))}function Mi(t,n,e){var r=t==null?i:Wn(t,n);return r===i?e:r}function kd(t,n){return t!=null&&Bs(t,n,hc)}function $i(t,n){return t!=null&&Bs(t,n,dc)}var Hd=Ts(function(t,n,e){n!=null&&typeof n.toString!="function"&&(n=qe.call(n)),t[n]=e},qi(Ct)),zd=Ts(function(t,n,e){n!=null&&typeof n.toString!="function"&&(n=qe.call(n)),Y.call(t,n)?t[n].push(e):t[n]=[e]},E),Gd=M(ve);function lt(t){return At(t)?Zu(t):li(t)}function bt(t){return At(t)?Zu(t,!0):Ac(t)}function Jd(t,n){var e={};return n=E(n,3),tn(t,function(r,u,o){an(e,n(r,u,o),r)}),e}function Zd(t,n){var e={};return n=E(n,3),tn(t,function(r,u,o){an(e,u,n(r,u,o))}),e}var Yd=Qn(function(t,n,e){er(t,n,e)}),mo=Qn(function(t,n,e,r){er(t,n,e,r)}),Xd=cn(function(t,n){var e={};if(t==null)return e;var r=!1;n=nt(n,function(o){return o=An(o,t),r||(r=o.length>1),o}),nn(t,Ci(t),e),r&&(e=$t(e,k|P|G,Hc));for(var u=n.length;u--;)vi(e,n[u]);return e});function Qd(t,n){return xo(t,vr(E(n)))}var Vd=cn(function(t,n){return t==null?{}:Cc(t,n)});function xo(t,n){if(t==null)return{};var e=nt(Ci(t),function(r){return[r]});return n=E(n),ls(t,e,function(r,u){return n(r,u[0])})}function jd(t,n,e){n=An(n,t);var r=-1,u=n.length;for(u||(u=1,t=i);++r<u;){var o=t==null?i:t[en(n[r])];o===i&&(r=u,o=e),t=hn(o)?o.call(t):o}return t}function tp(t,n,e){return t==null?t:ye(t,n,e)}function np(t,n,e,r){return r=typeof r=="function"?r:i,t==null?t:ye(t,n,e,r)}var So=Ws(lt),Ao=Ws(bt);function ep(t,n,e){var r=F(t),u=r||Cn(t)||te(t);if(n=E(n,4),e==null){var o=t&&t.constructor;u?e=r?new o:[]:et(t)?e=hn(o)?Xn(ze(t)):{}:e={}}return(u?Ut:tn)(t,function(a,c,d){return n(e,a,c,d)}),e}function rp(t,n){return t==null?!0:vi(t,n)}function ip(t,n,e){return t==null?t:_s(t,n,mi(e))}function up(t,n,e,r){return r=typeof r=="function"?r:i,t==null?t:_s(t,n,mi(e),r)}function ne(t){return t==null?[]:Vr(t,lt(t))}function sp(t){return t==null?[]:Vr(t,bt(t))}function op(t,n,e){return e===i&&(e=n,n=i),e!==i&&(e=kt(e),e=e===e?e:0),n!==i&&(n=kt(n),n=n===n?n:0),On(kt(t),n,e)}function ap(t,n,e){return n=dn(n),e===i?(e=n,n=0):e=dn(e),t=kt(t),pc(t,n,e)}function fp(t,n,e){if(e&&typeof e!="boolean"&&yt(t,n,e)&&(n=e=i),e===i&&(typeof n=="boolean"?(e=n,n=i):typeof t=="boolean"&&(e=t,t=i)),t===i&&n===i?(t=0,n=1):(t=dn(t),n===i?(n=t,t=0):n=dn(n)),t>n){var r=t;t=n,n=r}if(e||t%1||n%1){var u=Gu();return pt(t+u*(n-t+$a("1e-"+((u+"").length-1))),n)}return pi(t,n)}var cp=Vn(function(t,n,e){return n=n.toLowerCase(),t+(e?bo(n):n)});function bo(t){return Ki(Z(t).toLowerCase())}function Co(t){return t=Z(t),t&&t.replace(la,ja).replace(Ta,"")}function lp(t,n,e){t=Z(t),n=Tt(n);var r=t.length;e=e===i?r:On(N(e),0,r);var u=e;return e-=n.length,e>=0&&t.slice(e,u)==n}function hp(t){return t=Z(t),t&&zo.test(t)?t.replace(nu,tf):t}function dp(t){return t=Z(t),t&&Qo.test(t)?t.replace(Nr,"\\$&"):t}var pp=Vn(function(t,n,e){return t+(e?"-":"")+n.toLowerCase()}),gp=Vn(function(t,n,e){return t+(e?" ":"")+n.toLowerCase()}),_p=Rs("toLowerCase");function vp(t,n,e){t=Z(t),n=N(n);var r=n?zn(t):0;if(!n||r>=n)return t;var u=(n-r)/2;return ar(Ye(u),e)+t+ar(Ze(u),e)}function wp(t,n,e){t=Z(t),n=N(n);var r=n?zn(t):0;return n&&r<n?t+ar(n-r,e):t}function yp(t,n,e){t=Z(t),n=N(n);var r=n?zn(t):0;return n&&r<n?ar(n-r,e)+t:t}function mp(t,n,e){return e||n==null?n=0:n&&(n=+n),Rf(Z(t).replace(Ur,""),n||0)}function xp(t,n,e){return(e?yt(t,n,e):n===i)?n=1:n=N(n),gi(Z(t),n)}function Sp(){var t=arguments,n=Z(t[0]);return t.length<3?n:n.replace(t[1],t[2])}var Ap=Vn(function(t,n,e){return t+(e?"_":"")+n.toLowerCase()});function bp(t,n,e){return e&&typeof e!="number"&&yt(t,n,e)&&(n=e=i),e=e===i?Ft:e>>>0,e?(t=Z(t),t&&(typeof n=="string"||n!=null&&!Bi(n))&&(n=Tt(n),!n&&Hn(t))?bn(Zt(t),0,e):t.split(n,e)):[]}var Cp=Vn(function(t,n,e){return t+(e?" ":"")+Ki(n)});function Ip(t,n,e){return t=Z(t),e=e==null?0:On(N(e),0,t.length),n=Tt(n),t.slice(e,e+n.length)==n}function Rp(t,n,e){var r=s.templateSettings;e&&yt(t,n,e)&&(n=i),t=Z(t),n=mr({},n,r,Ds);var u=mr({},n.imports,r.imports,Ds),o=lt(u),a=Vr(u,o),c,d,y=0,m=n.interpolate||We,S="__p += '",A=ti((n.escape||We).source+"|"+m.source+"|"+(m===eu?ua:We).source+"|"+(n.evaluate||We).source+"|$","g"),R="//# sourceURL="+(Y.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Fa+"]")+`
11
- `;t.replace(A,function(O,K,H,Ot,mt,Wt){return H||(H=Ot),S+=t.slice(y,Wt).replace(ha,nf),K&&(c=!0,S+=`' +
10
+ `)}function jc(t){return F(t)||Nn(t)||!!(Hu&&t&&t[Hu])}function ln(t,n){var e=typeof t;return n=n??jt,!!n&&(e=="number"||e!="symbol"&&ca.test(t))&&t>-1&&t%1==0&&t<n}function yt(t,n,e){if(!et(e))return!1;var r=typeof n;return(r=="number"?At(e)&&ln(n,e.length):r=="string"&&n in e)?Xt(e[n],t):!1}function Ei(t,n){if(F(t))return!1;var e=typeof t;return e=="number"||e=="symbol"||e=="boolean"||t==null||Ot(t)?!0:Yo.test(t)||!Zo.test(t)||n!=null&&t in Q(n)}function tl(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}function Ti(t){var n=cr(t),e=s[n];if(typeof e!="function"||!(n in q.prototype))return!1;if(t===e)return!0;var r=Ii(e);return!!r&&t===r[0]}function nl(t){return!!$u&&$u in t}var el=$e?hn:Ji;function xe(t){var n=t&&t.constructor,e=typeof n=="function"&&n.prototype||Zn;return t===e}function $s(t){return t===t&&!et(t)}function Ks(t,n){return function(e){return e==null?!1:e[t]===n&&(n!==i||t in Q(e))}}function rl(t){var n=_r(t,function(r){return e.size===B&&e.clear(),r}),e=n.cache;return n}function il(t,n){var e=t[1],r=n[1],u=e|r,o=u<(_t|It|xt),a=r==xt&&e==ot||r==xt&&e==Rt&&t[7].length<=n[8]||r==(xt|Rt)&&n[7].length<=n[8]&&e==ot;if(!(o||a))return t;r&_t&&(t[2]=n[2],u|=e&_t?0:Vt);var c=n[3];if(c){var d=t[3];t[3]=d?As(d,c,n[4]):c,t[4]=d?yn(t[3],C):n[4]}return c=n[5],c&&(d=t[5],t[5]=d?bs(d,c,n[6]):c,t[6]=d?yn(t[5],C):n[6]),c=n[7],c&&(t[7]=c),r&xt&&(t[8]=t[8]==null?n[8]:pt(t[8],n[8])),t[9]==null&&(t[9]=n[9]),t[0]=n[0],t[1]=u,t}function ul(t){var n=[];if(t!=null)for(var e in Q(t))n.push(e);return n}function sl(t){return qe.call(t)}function qs(t,n,e){return n=ft(n===i?t.length-1:n,0),function(){for(var r=arguments,u=-1,o=ft(r.length-n,0),a=g(o);++u<o;)a[u]=r[n+u];u=-1;for(var c=g(n+1);++u<n;)c[u]=r[u];return c[n]=e(a),Et(t,this,c)}}function ks(t,n){return n.length<2?t:Wn(t,Kt(n,0,-1))}function ol(t,n){for(var e=t.length,r=pt(n.length,e),u=St(t);r--;){var o=n[r];t[r]=ln(o,e)?u[o]:i}return t}function Li(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}var Hs=Gs(ds),Se=Sf||function(t,n){return ht.setTimeout(t,n)},Oi=Gs(Tc);function zs(t,n,e){var r=n+"";return Oi(t,Vc(r,al(Yc(r),e)))}function Gs(t){var n=0,e=0;return function(){var r=If(),u=$n-(r-e);if(e=r,u>0){if(++n>=Pe)return arguments[0]}else n=0;return t.apply(i,arguments)}}function hr(t,n){var e=-1,r=t.length,u=r-1;for(n=n===i?r:n;++e<n;){var o=pi(e,u),a=t[o];t[o]=t[e],t[e]=a}return t.length=n,t}var Js=rl(function(t){var n=[];return t.charCodeAt(0)===46&&n.push(""),t.replace(Xo,function(e,r,u,o){n.push(u?o.replace(ia,"$1"):r||e)}),n});function en(t){if(typeof t=="string"||Ot(t))return t;var n=t+"";return n=="0"&&1/t==-rn?"-0":n}function Fn(t){if(t!=null){try{return Ke.call(t)}catch{}try{return t+""}catch{}}return""}function al(t,n){return Ut(z,function(e){var r="_."+e[0];n&e[1]&&!Ne(t,r)&&t.push(r)}),t.sort()}function Zs(t){if(t instanceof q)return t.clone();var n=new Mt(t.__wrapped__,t.__chain__);return n.__actions__=St(t.__actions__),n.__index__=t.__index__,n.__values__=t.__values__,n}function fl(t,n,e){(e?yt(t,n,e):n===i)?n=1:n=ft(N(n),0);var r=t==null?0:t.length;if(!r||n<1)return[];for(var u=0,o=0,a=g(Ze(r/n));u<r;)a[o++]=Kt(t,u,u+=n);return a}function cl(t){for(var n=-1,e=t==null?0:t.length,r=0,u=[];++n<e;){var o=t[n];o&&(u[r++]=o)}return u}function ll(){var t=arguments.length;if(!t)return[];for(var n=g(t-1),e=arguments[0],r=t;r--;)n[r-1]=arguments[r];return wn(F(e)?St(e):[e],dt(n,1))}var hl=M(function(t,n){return ut(t)?_e(t,dt(n,1,ut,!0)):[]}),dl=M(function(t,n){var e=qt(n);return ut(e)&&(e=i),ut(t)?_e(t,dt(n,1,ut,!0),T(e,2)):[]}),pl=M(function(t,n){var e=qt(n);return ut(e)&&(e=i),ut(t)?_e(t,dt(n,1,ut,!0),i,e):[]});function gl(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:N(n),Kt(t,n<0?0:n,r)):[]}function _l(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:N(n),n=r-n,Kt(t,0,n<0?0:n)):[]}function vl(t,n){return t&&t.length?ir(t,T(n,3),!0,!0):[]}function wl(t,n){return t&&t.length?ir(t,T(n,3),!0):[]}function yl(t,n,e,r){var u=t==null?0:t.length;return u?(e&&typeof e!="number"&&yt(t,n,e)&&(e=0,r=u),lc(t,n,e,r)):[]}function Ys(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var u=e==null?0:N(e);return u<0&&(u=ft(r+u,0)),Ue(t,T(n,3),u)}function Xs(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var u=r-1;return e!==i&&(u=N(e),u=e<0?ft(r+u,0):pt(u,r-1)),Ue(t,T(n,3),u,!0)}function Qs(t){var n=t==null?0:t.length;return n?dt(t,1):[]}function ml(t){var n=t==null?0:t.length;return n?dt(t,rn):[]}function xl(t,n){var e=t==null?0:t.length;return e?(n=n===i?1:N(n),dt(t,n)):[]}function Sl(t){for(var n=-1,e=t==null?0:t.length,r={};++n<e;){var u=t[n];r[u[0]]=u[1]}return r}function Vs(t){return t&&t.length?t[0]:i}function Al(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var u=e==null?0:N(e);return u<0&&(u=ft(r+u,0)),Hn(t,n,u)}function bl(t){var n=t==null?0:t.length;return n?Kt(t,0,-1):[]}var Cl=M(function(t){var n=nt(t,yi);return n.length&&n[0]===t[0]?fi(n):[]}),Il=M(function(t){var n=qt(t),e=nt(t,yi);return n===qt(e)?n=i:e.pop(),e.length&&e[0]===t[0]?fi(e,T(n,2)):[]}),Rl=M(function(t){var n=qt(t),e=nt(t,yi);return n=typeof n=="function"?n:i,n&&e.pop(),e.length&&e[0]===t[0]?fi(e,i,n):[]});function Pl(t,n){return t==null?"":bf.call(t,n)}function qt(t){var n=t==null?0:t.length;return n?t[n-1]:i}function El(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var u=r;return e!==i&&(u=N(e),u=u<0?ft(r+u,0):pt(u,r-1)),n===n?af(t,n,u):Ue(t,Ou,u,!0)}function Tl(t,n){return t&&t.length?fs(t,N(n)):i}var Ll=M(js);function js(t,n){return t&&t.length&&n&&n.length?di(t,n):t}function Ol(t,n,e){return t&&t.length&&n&&n.length?di(t,n,T(e,2)):t}function Wl(t,n,e){return t&&t.length&&n&&n.length?di(t,n,i,e):t}var Dl=cn(function(t,n){var e=t==null?0:t.length,r=ui(t,n);return hs(t,nt(n,function(u){return ln(u,e)?+u:u}).sort(Ss)),r});function Fl(t,n){var e=[];if(!(t&&t.length))return e;var r=-1,u=[],o=t.length;for(n=T(n,3);++r<o;){var a=t[r];n(a,r,t)&&(e.push(a),u.push(r))}return hs(t,u),e}function Wi(t){return t==null?t:Pf.call(t)}function Nl(t,n,e){var r=t==null?0:t.length;return r?(e&&typeof e!="number"&&yt(t,n,e)?(n=0,e=r):(n=n==null?0:N(n),e=e===i?r:N(e)),Kt(t,n,e)):[]}function Ul(t,n){return rr(t,n)}function Bl(t,n,e){return _i(t,n,T(e,2))}function Ml(t,n){var e=t==null?0:t.length;if(e){var r=rr(t,n);if(r<e&&Xt(t[r],n))return r}return-1}function $l(t,n){return rr(t,n,!0)}function Kl(t,n,e){return _i(t,n,T(e,2),!0)}function ql(t,n){var e=t==null?0:t.length;if(e){var r=rr(t,n,!0)-1;if(Xt(t[r],n))return r}return-1}function kl(t){return t&&t.length?ps(t):[]}function Hl(t,n){return t&&t.length?ps(t,T(n,2)):[]}function zl(t){var n=t==null?0:t.length;return n?Kt(t,1,n):[]}function Gl(t,n,e){return t&&t.length?(n=e||n===i?1:N(n),Kt(t,0,n<0?0:n)):[]}function Jl(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:N(n),n=r-n,Kt(t,n<0?0:n,r)):[]}function Zl(t,n){return t&&t.length?ir(t,T(n,3),!1,!0):[]}function Yl(t,n){return t&&t.length?ir(t,T(n,3)):[]}var Xl=M(function(t){return Sn(dt(t,1,ut,!0))}),Ql=M(function(t){var n=qt(t);return ut(n)&&(n=i),Sn(dt(t,1,ut,!0),T(n,2))}),Vl=M(function(t){var n=qt(t);return n=typeof n=="function"?n:i,Sn(dt(t,1,ut,!0),i,n)});function jl(t){return t&&t.length?Sn(t):[]}function th(t,n){return t&&t.length?Sn(t,T(n,2)):[]}function nh(t,n){return n=typeof n=="function"?n:i,t&&t.length?Sn(t,i,n):[]}function Di(t){if(!(t&&t.length))return[];var n=0;return t=vn(t,function(e){if(ut(e))return n=ft(e.length,n),!0}),Qr(n,function(e){return nt(t,Zr(e))})}function to(t,n){if(!(t&&t.length))return[];var e=Di(t);return n==null?e:nt(e,function(r){return Et(n,i,r)})}var eh=M(function(t,n){return ut(t)?_e(t,n):[]}),rh=M(function(t){return wi(vn(t,ut))}),ih=M(function(t){var n=qt(t);return ut(n)&&(n=i),wi(vn(t,ut),T(n,2))}),uh=M(function(t){var n=qt(t);return n=typeof n=="function"?n:i,wi(vn(t,ut),i,n)}),sh=M(Di);function oh(t,n){return ws(t||[],n||[],ge)}function ah(t,n){return ws(t||[],n||[],ye)}var fh=M(function(t){var n=t.length,e=n>1?t[n-1]:i;return e=typeof e=="function"?(t.pop(),e):i,to(t,e)});function no(t){var n=s(t);return n.__chain__=!0,n}function ch(t,n){return n(t),t}function dr(t,n){return n(t)}var lh=cn(function(t){var n=t.length,e=n?t[0]:0,r=this.__wrapped__,u=function(o){return ui(o,t)};return n>1||this.__actions__.length||!(r instanceof q)||!ln(e)?this.thru(u):(r=r.slice(e,+e+(n?1:0)),r.__actions__.push({func:dr,args:[u],thisArg:i}),new Mt(r,this.__chain__).thru(function(o){return n&&!o.length&&o.push(i),o}))});function hh(){return no(this)}function dh(){return new Mt(this.value(),this.__chain__)}function ph(){this.__values__===i&&(this.__values__=_o(this.value()));var t=this.__index__>=this.__values__.length,n=t?i:this.__values__[this.__index__++];return{done:t,value:n}}function gh(){return this}function _h(t){for(var n,e=this;e instanceof Ve;){var r=Zs(e);r.__index__=0,r.__values__=i,n?u.__wrapped__=r:n=r;var u=r;e=e.__wrapped__}return u.__wrapped__=t,n}function vh(){var t=this.__wrapped__;if(t instanceof q){var n=t;return this.__actions__.length&&(n=new q(this)),n=n.reverse(),n.__actions__.push({func:dr,args:[Wi],thisArg:i}),new Mt(n,this.__chain__)}return this.thru(Wi)}function wh(){return vs(this.__wrapped__,this.__actions__)}var yh=ur(function(t,n,e){X.call(t,e)?++t[e]:an(t,e,1)});function mh(t,n,e){var r=F(t)?Tu:cc;return e&&yt(t,n,e)&&(n=i),r(t,T(n,3))}function xh(t,n){var e=F(t)?vn:ts;return e(t,T(n,3))}var Sh=Ps(Ys),Ah=Ps(Xs);function bh(t,n){return dt(pr(t,n),1)}function Ch(t,n){return dt(pr(t,n),rn)}function Ih(t,n,e){return e=e===i?1:N(e),dt(pr(t,n),e)}function eo(t,n){var e=F(t)?Ut:xn;return e(t,T(n,3))}function ro(t,n){var e=F(t)?Ha:ju;return e(t,T(n,3))}var Rh=ur(function(t,n,e){X.call(t,e)?t[e].push(n):an(t,e,[n])});function Ph(t,n,e,r){t=At(t)?t:ee(t),e=e&&!r?N(e):0;var u=t.length;return e<0&&(e=ft(u+e,0)),yr(t)?e<=u&&t.indexOf(n,e)>-1:!!u&&Hn(t,n,e)>-1}var Eh=M(function(t,n,e){var r=-1,u=typeof n=="function",o=At(t)?g(t.length):[];return xn(t,function(a){o[++r]=u?Et(n,a,e):ve(a,n,e)}),o}),Th=ur(function(t,n,e){an(t,e,n)});function pr(t,n){var e=F(t)?nt:ss;return e(t,T(n,3))}function Lh(t,n,e,r){return t==null?[]:(F(n)||(n=n==null?[]:[n]),e=r?i:e,F(e)||(e=e==null?[]:[e]),cs(t,n,e))}var Oh=ur(function(t,n,e){t[e?0:1].push(n)},function(){return[[],[]]});function Wh(t,n,e){var r=F(t)?Gr:Du,u=arguments.length<3;return r(t,T(n,4),e,u,xn)}function Dh(t,n,e){var r=F(t)?za:Du,u=arguments.length<3;return r(t,T(n,4),e,u,ju)}function Fh(t,n){var e=F(t)?vn:ts;return e(t,vr(T(n,3)))}function Nh(t){var n=F(t)?Yu:Pc;return n(t)}function Uh(t,n,e){(e?yt(t,n,e):n===i)?n=1:n=N(n);var r=F(t)?uc:Ec;return r(t,n)}function Bh(t){var n=F(t)?sc:Lc;return n(t)}function Mh(t){if(t==null)return 0;if(At(t))return yr(t)?Gn(t):t.length;var n=gt(t);return n==Gt||n==Jt?t.size:li(t).length}function $h(t,n,e){var r=F(t)?Jr:Oc;return e&&yt(t,n,e)&&(n=i),r(t,T(n,3))}var Kh=M(function(t,n){if(t==null)return[];var e=n.length;return e>1&&yt(t,n[0],n[1])?n=[]:e>2&&yt(n[0],n[1],n[2])&&(n=[n[0]]),cs(t,dt(n,1),[])}),gr=xf||function(){return ht.Date.now()};function qh(t,n){if(typeof n!="function")throw new Bt(x);return t=N(t),function(){if(--t<1)return n.apply(this,arguments)}}function io(t,n,e){return n=e?i:n,n=t&&n==null?t.length:n,fn(t,xt,i,i,i,i,n)}function uo(t,n){var e;if(typeof n!="function")throw new Bt(x);return t=N(t),function(){return--t>0&&(e=n.apply(this,arguments)),t<=1&&(n=i),e}}var Fi=M(function(t,n,e){var r=_t;if(e.length){var u=yn(e,te(Fi));r|=Ht}return fn(t,r,n,e,u)}),so=M(function(t,n,e){var r=_t|It;if(e.length){var u=yn(e,te(so));r|=Ht}return fn(n,r,t,e,u)});function oo(t,n,e){n=e?i:n;var r=fn(t,ot,i,i,i,i,i,n);return r.placeholder=oo.placeholder,r}function ao(t,n,e){n=e?i:n;var r=fn(t,In,i,i,i,i,i,n);return r.placeholder=ao.placeholder,r}function fo(t,n,e){var r,u,o,a,c,d,y=0,m=!1,S=!1,A=!0;if(typeof t!="function")throw new Bt(x);n=kt(n)||0,et(e)&&(m=!!e.leading,S="maxWait"in e,o=S?ft(kt(e.maxWait)||0,n):o,A="trailing"in e?!!e.trailing:A);function R(st){var Qt=r,pn=u;return r=u=i,y=st,a=t.apply(pn,Qt),a}function L(st){return y=st,c=Se(K,n),m?R(st):a}function U(st){var Qt=st-d,pn=st-y,Eo=n-Qt;return S?pt(Eo,o-pn):Eo}function O(st){var Qt=st-d,pn=st-y;return d===i||Qt>=n||Qt<0||S&&pn>=o}function K(){var st=gr();if(O(st))return H(st);c=Se(K,U(st))}function H(st){return c=i,A&&r?R(st):(r=u=i,a)}function Wt(){c!==i&&ys(c),y=0,r=d=u=c=i}function mt(){return c===i?a:H(gr())}function Dt(){var st=gr(),Qt=O(st);if(r=arguments,u=this,d=st,Qt){if(c===i)return L(d);if(S)return ys(c),c=Se(K,n),R(d)}return c===i&&(c=Se(K,n)),a}return Dt.cancel=Wt,Dt.flush=mt,Dt}var kh=M(function(t,n){return Vu(t,1,n)}),Hh=M(function(t,n,e){return Vu(t,kt(n)||0,e)});function zh(t){return fn(t,Mn)}function _r(t,n){if(typeof t!="function"||n!=null&&typeof n!="function")throw new Bt(x);var e=function(){var r=arguments,u=n?n.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var a=t.apply(this,r);return e.cache=o.set(u,a)||o,a};return e.cache=new(_r.Cache||on),e}_r.Cache=on;function vr(t){if(typeof t!="function")throw new Bt(x);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}function Gh(t){return uo(2,t)}var Jh=Wc(function(t,n){n=n.length==1&&F(n[0])?nt(n[0],Tt(T())):nt(dt(n,1),Tt(T()));var e=n.length;return M(function(r){for(var u=-1,o=pt(r.length,e);++u<o;)r[u]=n[u].call(this,r[u]);return Et(t,this,r)})}),Ni=M(function(t,n){var e=yn(n,te(Ni));return fn(t,Ht,i,n,e)}),co=M(function(t,n){var e=yn(n,te(co));return fn(t,gn,i,n,e)}),Zh=cn(function(t,n){return fn(t,Rt,i,i,i,n)});function Yh(t,n){if(typeof t!="function")throw new Bt(x);return n=n===i?n:N(n),M(t,n)}function Xh(t,n){if(typeof t!="function")throw new Bt(x);return n=n==null?0:ft(N(n),0),M(function(e){var r=e[n],u=bn(e,0,n);return r&&wn(u,r),Et(t,this,u)})}function Qh(t,n,e){var r=!0,u=!0;if(typeof t!="function")throw new Bt(x);return et(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),fo(t,n,{leading:r,maxWait:n,trailing:u})}function Vh(t){return io(t,1)}function jh(t,n){return Ni(mi(n),t)}function td(){if(!arguments.length)return[];var t=arguments[0];return F(t)?t:[t]}function nd(t){return $t(t,J)}function ed(t,n){return n=typeof n=="function"?n:i,$t(t,J,n)}function rd(t){return $t(t,k|J)}function id(t,n){return n=typeof n=="function"?n:i,$t(t,k|J,n)}function ud(t,n){return n==null||Qu(t,n,lt(n))}function Xt(t,n){return t===n||t!==t&&n!==n}var sd=fr(ai),od=fr(function(t,n){return t>=n}),Nn=rs(function(){return arguments}())?rs:function(t){return rt(t)&&X.call(t,"callee")&&!ku.call(t,"callee")},F=g.isArray,ad=bu?Tt(bu):_c;function At(t){return t!=null&&wr(t.length)&&!hn(t)}function ut(t){return rt(t)&&At(t)}function fd(t){return t===!0||t===!1||rt(t)&&wt(t)==_n}var Cn=Af||Ji,cd=Cu?Tt(Cu):vc;function ld(t){return rt(t)&&t.nodeType===1&&!Ae(t)}function hd(t){if(t==null)return!0;if(At(t)&&(F(t)||typeof t=="string"||typeof t.splice=="function"||Cn(t)||ne(t)||Nn(t)))return!t.length;var n=gt(t);if(n==Gt||n==Jt)return!t.size;if(xe(t))return!li(t).length;for(var e in t)if(X.call(t,e))return!1;return!0}function dd(t,n){return we(t,n)}function pd(t,n,e){e=typeof e=="function"?e:i;var r=e?e(t,n):i;return r===i?we(t,n,i,e):!!r}function Ui(t){if(!rt(t))return!1;var n=wt(t);return n==Te||n==No||typeof t.message=="string"&&typeof t.name=="string"&&!Ae(t)}function gd(t){return typeof t=="number"&&zu(t)}function hn(t){if(!et(t))return!1;var n=wt(t);return n==Le||n==Vi||n==Rn||n==Bo}function lo(t){return typeof t=="number"&&t==N(t)}function wr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=jt}function et(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}function rt(t){return t!=null&&typeof t=="object"}var ho=Iu?Tt(Iu):yc;function _d(t,n){return t===n||ci(t,n,Ri(n))}function vd(t,n,e){return e=typeof e=="function"?e:i,ci(t,n,Ri(n),e)}function wd(t){return po(t)&&t!=+t}function yd(t){if(el(t))throw new D(v);return is(t)}function md(t){return t===null}function xd(t){return t==null}function po(t){return typeof t=="number"||rt(t)&&wt(t)==ie}function Ae(t){if(!rt(t)||wt(t)!=un)return!1;var n=ze(t);if(n===null)return!0;var e=X.call(n,"constructor")&&n.constructor;return typeof e=="function"&&e instanceof e&&Ke.call(e)==vf}var Bi=Ru?Tt(Ru):mc;function Sd(t){return lo(t)&&t>=-jt&&t<=jt}var go=Pu?Tt(Pu):xc;function yr(t){return typeof t=="string"||!F(t)&&rt(t)&&wt(t)==se}function Ot(t){return typeof t=="symbol"||rt(t)&&wt(t)==Oe}var ne=Eu?Tt(Eu):Sc;function Ad(t){return t===i}function bd(t){return rt(t)&&gt(t)==oe}function Cd(t){return rt(t)&&wt(t)==$o}var Id=fr(hi),Rd=fr(function(t,n){return t<=n});function _o(t){if(!t)return[];if(At(t))return yr(t)?Zt(t):St(t);if(ce&&t[ce])return uf(t[ce]());var n=gt(t),e=n==Gt?jr:n==Jt?Be:ee;return e(t)}function dn(t){if(!t)return t===0?t:0;if(t=kt(t),t===rn||t===-rn){var n=t<0?-1:1;return n*Cr}return t===t?t:0}function N(t){var n=dn(t),e=n%1;return n===n?e?n-e:n:0}function vo(t){return t?On(N(t),0,Ft):0}function kt(t){if(typeof t=="number")return t;if(Ot(t))return Kn;if(et(t)){var n=typeof t.valueOf=="function"?t.valueOf():t;t=et(n)?n+"":n}if(typeof t!="string")return t===0?t:+t;t=Fu(t);var e=oa.test(t);return e||fa.test(t)?Ka(t.slice(2),e?2:8):sa.test(t)?Kn:+t}function wo(t){return nn(t,bt(t))}function Pd(t){return t?On(N(t),-jt,jt):t===0?t:0}function Y(t){return t==null?"":Lt(t)}var Ed=Vn(function(t,n){if(xe(n)||At(n)){nn(n,lt(n),t);return}for(var e in n)X.call(n,e)&&ge(t,e,n[e])}),yo=Vn(function(t,n){nn(n,bt(n),t)}),mr=Vn(function(t,n,e,r){nn(n,bt(n),t,r)}),Td=Vn(function(t,n,e,r){nn(n,lt(n),t,r)}),Ld=cn(ui);function Od(t,n){var e=Qn(t);return n==null?e:Xu(e,n)}var Wd=M(function(t,n){t=Q(t);var e=-1,r=n.length,u=r>2?n[2]:i;for(u&&yt(n[0],n[1],u)&&(r=1);++e<r;)for(var o=n[e],a=bt(o),c=-1,d=a.length;++c<d;){var y=a[c],m=t[y];(m===i||Xt(m,Zn[y])&&!X.call(t,y))&&(t[y]=o[y])}return t}),Dd=M(function(t){return t.push(i,Fs),Et(mo,i,t)});function Fd(t,n){return Lu(t,T(n,3),tn)}function Nd(t,n){return Lu(t,T(n,3),oi)}function Ud(t,n){return t==null?t:si(t,T(n,3),bt)}function Bd(t,n){return t==null?t:ns(t,T(n,3),bt)}function Md(t,n){return t&&tn(t,T(n,3))}function $d(t,n){return t&&oi(t,T(n,3))}function Kd(t){return t==null?[]:nr(t,lt(t))}function qd(t){return t==null?[]:nr(t,bt(t))}function Mi(t,n,e){var r=t==null?i:Wn(t,n);return r===i?e:r}function kd(t,n){return t!=null&&Bs(t,n,hc)}function $i(t,n){return t!=null&&Bs(t,n,dc)}var Hd=Ts(function(t,n,e){n!=null&&typeof n.toString!="function"&&(n=qe.call(n)),t[n]=e},qi(Ct)),zd=Ts(function(t,n,e){n!=null&&typeof n.toString!="function"&&(n=qe.call(n)),X.call(t,n)?t[n].push(e):t[n]=[e]},T),Gd=M(ve);function lt(t){return At(t)?Zu(t):li(t)}function bt(t){return At(t)?Zu(t,!0):Ac(t)}function Jd(t,n){var e={};return n=T(n,3),tn(t,function(r,u,o){an(e,n(r,u,o),r)}),e}function Zd(t,n){var e={};return n=T(n,3),tn(t,function(r,u,o){an(e,u,n(r,u,o))}),e}var Yd=Vn(function(t,n,e){er(t,n,e)}),mo=Vn(function(t,n,e,r){er(t,n,e,r)}),Xd=cn(function(t,n){var e={};if(t==null)return e;var r=!1;n=nt(n,function(o){return o=An(o,t),r||(r=o.length>1),o}),nn(t,Ci(t),e),r&&(e=$t(e,k|P|J,Hc));for(var u=n.length;u--;)vi(e,n[u]);return e});function Qd(t,n){return xo(t,vr(T(n)))}var Vd=cn(function(t,n){return t==null?{}:Cc(t,n)});function xo(t,n){if(t==null)return{};var e=nt(Ci(t),function(r){return[r]});return n=T(n),ls(t,e,function(r,u){return n(r,u[0])})}function jd(t,n,e){n=An(n,t);var r=-1,u=n.length;for(u||(u=1,t=i);++r<u;){var o=t==null?i:t[en(n[r])];o===i&&(r=u,o=e),t=hn(o)?o.call(t):o}return t}function tp(t,n,e){return t==null?t:ye(t,n,e)}function np(t,n,e,r){return r=typeof r=="function"?r:i,t==null?t:ye(t,n,e,r)}var So=Ws(lt),Ao=Ws(bt);function ep(t,n,e){var r=F(t),u=r||Cn(t)||ne(t);if(n=T(n,4),e==null){var o=t&&t.constructor;u?e=r?new o:[]:et(t)?e=hn(o)?Qn(ze(t)):{}:e={}}return(u?Ut:tn)(t,function(a,c,d){return n(e,a,c,d)}),e}function rp(t,n){return t==null?!0:vi(t,n)}function ip(t,n,e){return t==null?t:_s(t,n,mi(e))}function up(t,n,e,r){return r=typeof r=="function"?r:i,t==null?t:_s(t,n,mi(e),r)}function ee(t){return t==null?[]:Vr(t,lt(t))}function sp(t){return t==null?[]:Vr(t,bt(t))}function op(t,n,e){return e===i&&(e=n,n=i),e!==i&&(e=kt(e),e=e===e?e:0),n!==i&&(n=kt(n),n=n===n?n:0),On(kt(t),n,e)}function ap(t,n,e){return n=dn(n),e===i?(e=n,n=0):e=dn(e),t=kt(t),pc(t,n,e)}function fp(t,n,e){if(e&&typeof e!="boolean"&&yt(t,n,e)&&(n=e=i),e===i&&(typeof n=="boolean"?(e=n,n=i):typeof t=="boolean"&&(e=t,t=i)),t===i&&n===i?(t=0,n=1):(t=dn(t),n===i?(n=t,t=0):n=dn(n)),t>n){var r=t;t=n,n=r}if(e||t%1||n%1){var u=Gu();return pt(t+u*(n-t+$a("1e-"+((u+"").length-1))),n)}return pi(t,n)}var cp=jn(function(t,n,e){return n=n.toLowerCase(),t+(e?bo(n):n)});function bo(t){return Ki(Y(t).toLowerCase())}function Co(t){return t=Y(t),t&&t.replace(la,ja).replace(Ta,"")}function lp(t,n,e){t=Y(t),n=Lt(n);var r=t.length;e=e===i?r:On(N(e),0,r);var u=e;return e-=n.length,e>=0&&t.slice(e,u)==n}function hp(t){return t=Y(t),t&&zo.test(t)?t.replace(nu,tf):t}function dp(t){return t=Y(t),t&&Qo.test(t)?t.replace(Nr,"\\$&"):t}var pp=jn(function(t,n,e){return t+(e?"-":"")+n.toLowerCase()}),gp=jn(function(t,n,e){return t+(e?" ":"")+n.toLowerCase()}),_p=Rs("toLowerCase");function vp(t,n,e){t=Y(t),n=N(n);var r=n?Gn(t):0;if(!n||r>=n)return t;var u=(n-r)/2;return ar(Ye(u),e)+t+ar(Ze(u),e)}function wp(t,n,e){t=Y(t),n=N(n);var r=n?Gn(t):0;return n&&r<n?t+ar(n-r,e):t}function yp(t,n,e){t=Y(t),n=N(n);var r=n?Gn(t):0;return n&&r<n?ar(n-r,e)+t:t}function mp(t,n,e){return e||n==null?n=0:n&&(n=+n),Rf(Y(t).replace(Ur,""),n||0)}function xp(t,n,e){return(e?yt(t,n,e):n===i)?n=1:n=N(n),gi(Y(t),n)}function Sp(){var t=arguments,n=Y(t[0]);return t.length<3?n:n.replace(t[1],t[2])}var Ap=jn(function(t,n,e){return t+(e?"_":"")+n.toLowerCase()});function bp(t,n,e){return e&&typeof e!="number"&&yt(t,n,e)&&(n=e=i),e=e===i?Ft:e>>>0,e?(t=Y(t),t&&(typeof n=="string"||n!=null&&!Bi(n))&&(n=Lt(n),!n&&zn(t))?bn(Zt(t),0,e):t.split(n,e)):[]}var Cp=jn(function(t,n,e){return t+(e?" ":"")+Ki(n)});function Ip(t,n,e){return t=Y(t),e=e==null?0:On(N(e),0,t.length),n=Lt(n),t.slice(e,e+n.length)==n}function Rp(t,n,e){var r=s.templateSettings;e&&yt(t,n,e)&&(n=i),t=Y(t),n=mr({},n,r,Ds);var u=mr({},n.imports,r.imports,Ds),o=lt(u),a=Vr(u,o),c,d,y=0,m=n.interpolate||We,S="__p += '",A=ti((n.escape||We).source+"|"+m.source+"|"+(m===eu?ua:We).source+"|"+(n.evaluate||We).source+"|$","g"),R="//# sourceURL="+(X.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Fa+"]")+`
11
+ `;t.replace(A,function(O,K,H,Wt,mt,Dt){return H||(H=Wt),S+=t.slice(y,Dt).replace(ha,nf),K&&(c=!0,S+=`' +
12
12
  __e(`+K+`) +
13
13
  '`),mt&&(d=!0,S+=`';
14
14
  `+mt+`;
15
15
  __p += '`),H&&(S+=`' +
16
16
  ((__t = (`+H+`)) == null ? '' : __t) +
17
- '`),y=Wt+O.length,O}),S+=`';
18
- `;var L=Y.call(n,"variable")&&n.variable;if(!L)S=`with (obj) {
17
+ '`),y=Dt+O.length,O}),S+=`';
18
+ `;var L=X.call(n,"variable")&&n.variable;if(!L)S=`with (obj) {
19
19
  `+S+`
20
20
  }
21
- `;else if(ra.test(L))throw new D(T);S=(d?S.replace(Ko,""):S).replace(qo,"$1").replace(ko,"$1;"),S="function("+(L||"obj")+`) {
21
+ `;else if(ra.test(L))throw new D(E);S=(d?S.replace(Ko,""):S).replace(qo,"$1").replace(ko,"$1;"),S="function("+(L||"obj")+`) {
22
22
  `+(L?"":`obj || (obj = {});
23
23
  `)+"var __t, __p = ''"+(c?", __e = _.escape":"")+(d?`, __j = Array.prototype.join;
24
24
  function print() { __p += __j.call(arguments, '') }
25
25
  `:`;
26
26
  `)+S+`return __p
27
- }`;var U=Ro(function(){return z(o,R+"return "+S).apply(i,a)});if(U.source=S,Ui(U))throw U;return U}function Pp(t){return Z(t).toLowerCase()}function Ep(t){return Z(t).toUpperCase()}function Tp(t,n,e){if(t=Z(t),t&&(e||n===i))return Fu(t);if(!t||!(n=Tt(n)))return t;var r=Zt(t),u=Zt(n),o=Nu(r,u),a=Uu(r,u)+1;return bn(r,o,a).join("")}function Lp(t,n,e){if(t=Z(t),t&&(e||n===i))return t.slice(0,Mu(t)+1);if(!t||!(n=Tt(n)))return t;var r=Zt(t),u=Uu(r,Zt(n))+1;return bn(r,0,u).join("")}function Op(t,n,e){if(t=Z(t),t&&(e||n===i))return t.replace(Ur,"");if(!t||!(n=Tt(n)))return t;var r=Zt(t),u=Nu(r,Zt(n));return bn(r,u).join("")}function Wp(t,n){var e=Re,r=Rt;if(et(n)){var u="separator"in n?n.separator:u;e="length"in n?N(n.length):e,r="omission"in n?Tt(n.omission):r}t=Z(t);var o=t.length;if(Hn(t)){var a=Zt(t);o=a.length}if(e>=o)return t;var c=e-zn(r);if(c<1)return r;var d=a?bn(a,0,c).join(""):t.slice(0,c);if(u===i)return d+r;if(a&&(c+=d.length-c),Bi(u)){if(t.slice(c).search(u)){var y,m=d;for(u.global||(u=ti(u.source,Z(ru.exec(u))+"g")),u.lastIndex=0;y=u.exec(m);)var S=y.index;d=d.slice(0,S===i?c:S)}}else if(t.indexOf(Tt(u),c)!=c){var A=d.lastIndexOf(u);A>-1&&(d=d.slice(0,A))}return d+r}function Dp(t){return t=Z(t),t&&Ho.test(t)?t.replace(tu,ff):t}var Fp=Vn(function(t,n,e){return t+(e?" ":"")+n.toUpperCase()}),Ki=Rs("toUpperCase");function Io(t,n,e){return t=Z(t),n=e?i:n,n===i?rf(t)?hf(t):Za(t):t.match(n)||[]}var Ro=M(function(t,n){try{return Pt(t,i,n)}catch(e){return Ui(e)?e:new D(e)}}),Np=cn(function(t,n){return Ut(n,function(e){e=en(e),an(t,e,Fi(t[e],t))}),t});function Up(t){var n=t==null?0:t.length,e=E();return t=n?nt(t,function(r){if(typeof r[1]!="function")throw new Bt(x);return[e(r[0]),r[1]]}):[],M(function(r){for(var u=-1;++u<n;){var o=t[u];if(Pt(o[0],this,r))return Pt(o[1],this,r)}})}function Bp(t){return fc($t(t,k))}function qi(t){return function(){return t}}function Mp(t,n){return t==null||t!==t?n:t}var $p=Es(),Kp=Es(!0);function Ct(t){return t}function ki(t){return us(typeof t=="function"?t:$t(t,k))}function qp(t){return os($t(t,k))}function kp(t,n){return as(t,$t(n,k))}var Hp=M(function(t,n){return function(e){return ve(e,t,n)}}),zp=M(function(t,n){return function(e){return ve(t,e,n)}});function Hi(t,n,e){var r=lt(n),u=nr(n,r);e==null&&!(et(n)&&(u.length||!r.length))&&(e=n,n=t,t=this,u=nr(n,lt(n)));var o=!(et(e)&&"chain"in e)||!!e.chain,a=hn(t);return Ut(u,function(c){var d=n[c];t[c]=d,a&&(t.prototype[c]=function(){var y=this.__chain__;if(o||y){var m=t(this.__wrapped__),S=m.__actions__=St(this.__actions__);return S.push({func:d,args:arguments,thisArg:t}),m.__chain__=y,m}return d.apply(t,wn([this.value()],arguments))})}),t}function Gp(){return ht._===this&&(ht._=wf),this}function zi(){}function Jp(t){return t=N(t),M(function(n){return fs(n,t)})}var Zp=Si(nt),Yp=Si(Tu),Xp=Si(Jr);function Po(t){return Ei(t)?Zr(en(t)):Ic(t)}function Qp(t){return function(n){return t==null?i:Wn(t,n)}}var Vp=Ls(),jp=Ls(!0);function Gi(){return[]}function Ji(){return!1}function tg(){return{}}function ng(){return""}function eg(){return!0}function rg(t,n){if(t=N(t),t<1||t>jt)return[];var e=Ft,r=pt(t,Ft);n=E(n),t-=Ft;for(var u=Qr(r,n);++e<t;)n(e);return u}function ig(t){return F(t)?nt(t,en):Lt(t)?[t]:St(Js(Z(t)))}function ug(t){var n=++_f;return Z(t)+n}var sg=or(function(t,n){return t+n},0),og=Ai("ceil"),ag=or(function(t,n){return t/n},1),fg=Ai("floor");function cg(t){return t&&t.length?tr(t,Ct,ai):i}function lg(t,n){return t&&t.length?tr(t,E(n,2),ai):i}function hg(t){return Wu(t,Ct)}function dg(t,n){return Wu(t,E(n,2))}function pg(t){return t&&t.length?tr(t,Ct,hi):i}function gg(t,n){return t&&t.length?tr(t,E(n,2),hi):i}var _g=or(function(t,n){return t*n},1),vg=Ai("round"),wg=or(function(t,n){return t-n},0);function yg(t){return t&&t.length?Xr(t,Ct):0}function mg(t,n){return t&&t.length?Xr(t,E(n,2)):0}return s.after=qh,s.ary=io,s.assign=Ed,s.assignIn=yo,s.assignInWith=mr,s.assignWith=Td,s.at=Ld,s.before=uo,s.bind=Fi,s.bindAll=Np,s.bindKey=so,s.castArray=td,s.chain=no,s.chunk=fl,s.compact=cl,s.concat=ll,s.cond=Up,s.conforms=Bp,s.constant=qi,s.countBy=yh,s.create=Od,s.curry=oo,s.curryRight=ao,s.debounce=fo,s.defaults=Wd,s.defaultsDeep=Dd,s.defer=kh,s.delay=Hh,s.difference=hl,s.differenceBy=dl,s.differenceWith=pl,s.drop=gl,s.dropRight=_l,s.dropRightWhile=vl,s.dropWhile=wl,s.fill=yl,s.filter=xh,s.flatMap=bh,s.flatMapDeep=Ch,s.flatMapDepth=Ih,s.flatten=Qs,s.flattenDeep=ml,s.flattenDepth=xl,s.flip=zh,s.flow=$p,s.flowRight=Kp,s.fromPairs=Sl,s.functions=Kd,s.functionsIn=qd,s.groupBy=Rh,s.initial=bl,s.intersection=Cl,s.intersectionBy=Il,s.intersectionWith=Rl,s.invert=Hd,s.invertBy=zd,s.invokeMap=Eh,s.iteratee=ki,s.keyBy=Th,s.keys=lt,s.keysIn=bt,s.map=pr,s.mapKeys=Jd,s.mapValues=Zd,s.matches=qp,s.matchesProperty=kp,s.memoize=_r,s.merge=Yd,s.mergeWith=mo,s.method=Hp,s.methodOf=zp,s.mixin=Hi,s.negate=vr,s.nthArg=Jp,s.omit=Xd,s.omitBy=Qd,s.once=Gh,s.orderBy=Lh,s.over=Zp,s.overArgs=Jh,s.overEvery=Yp,s.overSome=Xp,s.partial=Ni,s.partialRight=co,s.partition=Oh,s.pick=Vd,s.pickBy=xo,s.property=Po,s.propertyOf=Qp,s.pull=Ll,s.pullAll=js,s.pullAllBy=Ol,s.pullAllWith=Wl,s.pullAt=Dl,s.range=Vp,s.rangeRight=jp,s.rearg=Zh,s.reject=Fh,s.remove=Fl,s.rest=Yh,s.reverse=Wi,s.sampleSize=Uh,s.set=tp,s.setWith=np,s.shuffle=Bh,s.slice=Nl,s.sortBy=Kh,s.sortedUniq=kl,s.sortedUniqBy=Hl,s.split=bp,s.spread=Xh,s.tail=zl,s.take=Gl,s.takeRight=Jl,s.takeRightWhile=Zl,s.takeWhile=Yl,s.tap=ch,s.throttle=Qh,s.thru=dr,s.toArray=_o,s.toPairs=So,s.toPairsIn=Ao,s.toPath=ig,s.toPlainObject=wo,s.transform=ep,s.unary=Vh,s.union=Xl,s.unionBy=Ql,s.unionWith=Vl,s.uniq=jl,s.uniqBy=th,s.uniqWith=nh,s.unset=rp,s.unzip=Di,s.unzipWith=to,s.update=ip,s.updateWith=up,s.values=ne,s.valuesIn=sp,s.without=eh,s.words=Io,s.wrap=jh,s.xor=rh,s.xorBy=ih,s.xorWith=uh,s.zip=sh,s.zipObject=oh,s.zipObjectDeep=ah,s.zipWith=fh,s.entries=So,s.entriesIn=Ao,s.extend=yo,s.extendWith=mr,Hi(s,s),s.add=sg,s.attempt=Ro,s.camelCase=cp,s.capitalize=bo,s.ceil=og,s.clamp=op,s.clone=nd,s.cloneDeep=rd,s.cloneDeepWith=id,s.cloneWith=ed,s.conformsTo=ud,s.deburr=Co,s.defaultTo=Mp,s.divide=ag,s.endsWith=lp,s.eq=Xt,s.escape=hp,s.escapeRegExp=dp,s.every=mh,s.find=Sh,s.findIndex=Ys,s.findKey=Fd,s.findLast=Ah,s.findLastIndex=Xs,s.findLastKey=Nd,s.floor=fg,s.forEach=eo,s.forEachRight=ro,s.forIn=Ud,s.forInRight=Bd,s.forOwn=Md,s.forOwnRight=$d,s.get=Mi,s.gt=sd,s.gte=od,s.has=kd,s.hasIn=$i,s.head=Vs,s.identity=Ct,s.includes=Ph,s.indexOf=Al,s.inRange=ap,s.invoke=Gd,s.isArguments=Nn,s.isArray=F,s.isArrayBuffer=ad,s.isArrayLike=At,s.isArrayLikeObject=it,s.isBoolean=fd,s.isBuffer=Cn,s.isDate=cd,s.isElement=ld,s.isEmpty=hd,s.isEqual=dd,s.isEqualWith=pd,s.isError=Ui,s.isFinite=gd,s.isFunction=hn,s.isInteger=lo,s.isLength=wr,s.isMap=ho,s.isMatch=_d,s.isMatchWith=vd,s.isNaN=wd,s.isNative=yd,s.isNil=xd,s.isNull=md,s.isNumber=po,s.isObject=et,s.isObjectLike=rt,s.isPlainObject=Ae,s.isRegExp=Bi,s.isSafeInteger=Sd,s.isSet=go,s.isString=yr,s.isSymbol=Lt,s.isTypedArray=te,s.isUndefined=Ad,s.isWeakMap=bd,s.isWeakSet=Cd,s.join=Pl,s.kebabCase=pp,s.last=qt,s.lastIndexOf=El,s.lowerCase=gp,s.lowerFirst=_p,s.lt=Id,s.lte=Rd,s.max=cg,s.maxBy=lg,s.mean=hg,s.meanBy=dg,s.min=pg,s.minBy=gg,s.stubArray=Gi,s.stubFalse=Ji,s.stubObject=tg,s.stubString=ng,s.stubTrue=eg,s.multiply=_g,s.nth=Tl,s.noConflict=Gp,s.noop=zi,s.now=gr,s.pad=vp,s.padEnd=wp,s.padStart=yp,s.parseInt=mp,s.random=fp,s.reduce=Wh,s.reduceRight=Dh,s.repeat=xp,s.replace=Sp,s.result=jd,s.round=vg,s.runInContext=l,s.sample=Nh,s.size=Mh,s.snakeCase=Ap,s.some=$h,s.sortedIndex=Ul,s.sortedIndexBy=Bl,s.sortedIndexOf=Ml,s.sortedLastIndex=$l,s.sortedLastIndexBy=Kl,s.sortedLastIndexOf=ql,s.startCase=Cp,s.startsWith=Ip,s.subtract=wg,s.sum=yg,s.sumBy=mg,s.template=Rp,s.times=rg,s.toFinite=dn,s.toInteger=N,s.toLength=vo,s.toLower=Pp,s.toNumber=kt,s.toSafeInteger=Pd,s.toString=Z,s.toUpper=Ep,s.trim=Tp,s.trimEnd=Lp,s.trimStart=Op,s.truncate=Wp,s.unescape=Dp,s.uniqueId=ug,s.upperCase=Fp,s.upperFirst=Ki,s.each=eo,s.eachRight=ro,s.first=Vs,Hi(s,function(){var t={};return tn(s,function(n,e){Y.call(s.prototype,e)||(t[e]=n)}),t}(),{chain:!1}),s.VERSION=p,Ut(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){s[t].placeholder=s}),Ut(["drop","take"],function(t,n){q.prototype[t]=function(e){e=e===i?1:at(N(e),0);var r=this.__filtered__&&!n?new q(this):this.clone();return r.__filtered__?r.__takeCount__=pt(e,r.__takeCount__):r.__views__.push({size:pt(e,Ft),type:t+(r.__dir__<0?"Right":"")}),r},q.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ut(["filter","map","takeWhile"],function(t,n){var e=n+1,r=e==re||e==br;q.prototype[t]=function(u){var o=this.clone();return o.__iteratees__.push({iteratee:E(u,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),Ut(["head","last"],function(t,n){var e="take"+(n?"Right":"");q.prototype[t]=function(){return this[e](1).value()[0]}}),Ut(["initial","tail"],function(t,n){var e="drop"+(n?"":"Right");q.prototype[t]=function(){return this.__filtered__?new q(this):this[e](1)}}),q.prototype.compact=function(){return this.filter(Ct)},q.prototype.find=function(t){return this.filter(t).head()},q.prototype.findLast=function(t){return this.reverse().find(t)},q.prototype.invokeMap=M(function(t,n){return typeof t=="function"?new q(this):this.map(function(e){return ve(e,t,n)})}),q.prototype.reject=function(t){return this.filter(vr(E(t)))},q.prototype.slice=function(t,n){t=N(t);var e=this;return e.__filtered__&&(t>0||n<0)?new q(e):(t<0?e=e.takeRight(-t):t&&(e=e.drop(t)),n!==i&&(n=N(n),e=n<0?e.dropRight(-n):e.take(n-t)),e)},q.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},q.prototype.toArray=function(){return this.take(Ft)},tn(q.prototype,function(t,n){var e=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),u=s[r?"take"+(n=="last"?"Right":""):n],o=r||/^find/.test(n);u&&(s.prototype[n]=function(){var a=this.__wrapped__,c=r?[1]:arguments,d=a instanceof q,y=c[0],m=d||F(a),S=function(K){var H=u.apply(s,wn([K],c));return r&&A?H[0]:H};m&&e&&typeof y=="function"&&y.length!=1&&(d=m=!1);var A=this.__chain__,R=!!this.__actions__.length,L=o&&!A,U=d&&!R;if(!o&&m){a=U?a:new q(this);var O=t.apply(a,c);return O.__actions__.push({func:dr,args:[S],thisArg:i}),new Mt(O,A)}return L&&U?t.apply(this,c):(O=this.thru(S),L?r?O.value()[0]:O.value():O)})}),Ut(["pop","push","shift","sort","splice","unshift"],function(t){var n=Me[t],e=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);s.prototype[t]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return n.apply(F(o)?o:[],u)}return this[e](function(a){return n.apply(F(a)?a:[],u)})}}),tn(q.prototype,function(t,n){var e=s[n];if(e){var r=e.name+"";Y.call(Yn,r)||(Yn[r]=[]),Yn[r].push({name:n,func:e})}}),Yn[sr(i,It).name]=[{name:"wrapper",func:i}],q.prototype.clone=Df,q.prototype.reverse=Ff,q.prototype.value=Nf,s.prototype.at=lh,s.prototype.chain=hh,s.prototype.commit=dh,s.prototype.next=ph,s.prototype.plant=_h,s.prototype.reverse=vh,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=wh,s.prototype.first=s.prototype.head,ce&&(s.prototype[ce]=gh),s},Gn=df();Pn?((Pn.exports=Gn)._=Gn,kr._=Gn):ht._=Gn}).call(be)})(Sr,Sr.exports);var Tg=Sr.exports;const Lg=Eg(Tg);class Og{constructor(f){W(this,"config");this.config=f}async complete(f,i){var p;await this.persist(f,{...i,success:!0}),(p=this.config.logger)==null||p.debug("Transaction completed:",f)}async fail(f,i){var p;await this.persist(f,{...i,success:!1}),(p=this.config.logger)==null||p.debug("Transaction failed:",{...f,...i})}async persist(f,i){await fetch(`${this.config.apiUrl}/transactions/${f.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Wg{constructor(f,i){W(this,"transaction");W(this,"manager");this.transaction=f,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(f,i){var T;const p=this.transaction.functionCall;if(!p){await this.fail("No function call found");return}const _=p.name,v=p.args,x=f[_];if(!x){await this.fail(`Tool ${_} not found`);return}try{const b=Lg.get(i,"schema.config.parameters.properties",{}),C=(b&&Object.keys(b).length>0?Object.keys(b):((T=x.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:T[1].split(",").map(P=>P.trim()).filter(Boolean))||[]).map(P=>v[P]),k=await x.apply(null,C);await this.complete(k)}catch(b){await this.fail(`Error executing tool ${_}: ${b}`)}}async complete(f){await this.manager.complete(this.transaction,{success:!0,output:f,error:null})}async fail(f){await this.manager.fail(this.transaction,{success:!1,output:null,error:f})}}class Lo extends Ce{constructor(i){super();W(this,"status");W(this,"autostart");W(this,"session");W(this,"config");W(this,"notify",!0);W(this,"_tools");W(this,"_toolSchema",{});if(this.config=i,this.status="disconnected",this.autostart=!0,Array.isArray(i.tools)){this._tools={};for(const p of i.tools)p.schema&&p.implementation&&(this._tools[p.schema.name]=p.implementation,this._toolSchema[p.schema.name]=p)}else this._tools=i.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(i){return this._toolSchema[i]}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){}onTransaction(i){const p=new Og(this.config),_=new Wg(i,p);if(this.config.onTransaction)this.config.onTransaction(_);else{const v=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;_.invoke(this._tools,v)}}getTools(){return this._tools}}function Dg(h,f){if(Array.isArray(h))return h;if(typeof h=="object"&&h!==null){const i=f.dev?"localhost:8000":f.baseUrl||"persona.applica.guru/api",p=f.dev?"http":"https",_=f.dev?"ws":"wss";let v=Object.keys(h).map(x=>{switch(x){case"rest":return Fg(h[x],{baseEndpointProtocol:p,baseEndpoint:i,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger});case"webrtc":return Ng(h[x],{baseWebSocketProtocol:_,baseEndpoint:i,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger});case"websocket":return Ug(h[x],{baseWebSocketProtocol:_,baseEndpoint:i,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger});default:throw new Error(`Unknown protocol: ${x}`)}}).filter(x=>x!==null);return f.tools&&v.push(new Lo({apiUrl:`${p}://${i}`,apiKey:f.apiKey,agentId:f.agentId,tools:f.tools,logger:f.logger})),v}throw new Error("Invalid protocols configuration")}function Fg(h,f){return h===!0?new Yi({apiUrl:`${f.baseEndpointProtocol}://${f.baseEndpoint}`,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger}):typeof h=="object"&&h!==null?new Yi(h):null}function Ng(h,f){return h===!0?new Qi({webrtcUrl:`${f.baseWebSocketProtocol}://${f.baseEndpoint}/webrtc`,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger}):typeof h=="object"&&h!==null?new Qi(h):null}function Ug(h,f){return h===!0?new Xi({webSocketUrl:`${f.baseWebSocketProtocol}://${f.baseEndpoint}/websocket`,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger}):typeof h=="object"&&h!==null?new Xi(h):null}function Bg(h,f,i,p,_){return v=>{v.type==="message"?Mg(v.payload,h,f,i,_):v.type==="reasoning"?$g(v.payload,h,f,_):v.type==="transaction"&&Kg(v.payload,h,p)}}function Mg(h,f,i,p,_){h.createdAt||(h.createdAt=new Date),(h==null?void 0:h.finishReason)==="stop"&&!(h!=null&&h.functionResponse)&&!(h!=null&&h.thought)&&p(!1),h.thought&&(h.type="reasoning"),h.protocol=f.getName(),i(v=>{const x=ee([...v,h]);return _?_(x):x})}function $g(h,f,i,p){const _={type:"reasoning",text:h.thought,role:"assistant",finishReason:"stop",protocol:f.getName(),createdAt:new Date};i(v=>{const x=ee([...v,_]);return p?p(x):x})}function Kg(h,f,i){i.filter(p=>p!==f).forEach(p=>p.onTransaction(h))}function qg(h){return new Promise((f,i)=>{const p=new FileReader;p.readAsDataURL(h),p.onload=()=>{const v=p.result.split(";base64,")[1];f(v)},p.onerror=_=>{i(_)}})}function kg(h){const f={rest:i=>i.config.apiUrl,webrtc:i=>i.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:i=>i.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const i of h){const p=f[i.getName()];if(p)return p(i)}return null}function Hg(h,f,i,p,_){return async v=>{var k;if(((k=v.content[0])==null?void 0:k.type)!=="text")throw new Error("Only text messages are supported");if(!h.some(P=>P.getName()!=="transaction"&&P.status==="connected")){f(P=>{const G={role:"assistant",type:"text",text:"No protocol is connected.",createdAt:new Date,finishReason:"stop"},J=[...P,G];return p?p(J):J});return}const b={role:"user",type:"text",text:v.content[0].text,createdAt:new Date};f(P=>{const G=ee([...P,b]);return p?p(G):G}),i(!0);const B=h.sort((P,G)=>G.getPriority()-P.getPriority()).find(P=>P.status==="connected"),C=[];if(v.attachments)for(const P of v.attachments)P.contentType.startsWith("image/")&&P.file&&C.push({role:"user",image:{contentType:P.contentType,content:await qg(P.file)},text:"",type:"text",createdAt:new Date});v.content&&C.push({role:"user",text:v.content[0].text,type:"text",createdAt:new Date}),_==null||_.debug("Sending message:",C),await(B==null?void 0:B.sendPacket({type:"request",payload:C}))}}function zg(h,f,i,p,_,v){return async x=>{var J;if(((J=x.content[0])==null?void 0:J.type)!=="text")throw new Error("Only text messages are supported");const T=h.sort(($,_t)=>_t.getPriority()-$.getPriority()).find($=>$.status==="connected");if(!T){v==null||v.debug("No protocol available for edit");return}const b=x.parentId;if(!b){v==null||v.debug("No parent ID provided for edit");return}const B=f.findIndex($=>$.id===b);if(B===-1){v==null||v.debug("Parent message not found:",b);return}const C=f.slice(0,B+1),k={role:"user",text:x.content[0].text,type:"text",createdAt:new Date},P=ee([...C,k]);i(_?_(P):P),p(!0);const G=[{role:"user",text:x.content[0].text,type:"text",createdAt:new Date}];v==null||v.debug("Sending edited message:",G),await T.sendPacket({type:"request",payload:G})}}function Gg(h,f,i,p,_,v){return async(x,T)=>{const b=h.sort((J,$)=>$.getPriority()-J.getPriority()).find(J=>J.status==="connected");if(!b){v==null||v.debug("No protocol available for reload");return}const B=T.parentId??x;if(!B){v==null||v.debug("No parent ID provided for reload");return}const C=f.findIndex(J=>J.id===B);if(C===-1){v==null||v.debug("Parent message not found:",B);return}const k=f[C];i(J=>{const $=J.slice(0,C+1);return _?_($):$});let P;if(k.role==="assistant"||k.role==="function"){for(let J=C-1;J>=0;J--)if(f[J].role==="user"){P=f[J];break}}else k.role==="user"&&(P=k);if(!P){v==null||v.debug("No user message found to regenerate from");return}p(!0);const G=[];P.image&&G.push({role:"user",image:P.image,text:"",type:"text",createdAt:new Date}),G.push({role:"user",text:P.text,type:"text",createdAt:new Date}),v==null||v.debug("Regenerating message with config:",{actualParentId:B,sourceId:T.sourceId,custom:T.runConfig.custom}),await b.sendPacket({type:"request",payload:G})}}function Jg(h,f,i,p){return()=>(i(!1),f(_=>{const v=_[_.length-1];if((v==null?void 0:v.role)==="assistant"&&!v.finishReason){const x=[..._];return x[x.length-1]={...v,finishReason:"stop",status:{type:"incomplete"}},p?p(x):x}return _}),h.forEach(_=>{_.status==="connected"&&_.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:{cancel:!0}}}).catch(()=>{})}),Promise.resolve())}const Ie=j.createContext(void 0);function Zg(){const h=j.useContext(Ie);if(!h)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return h}function Oo(h){const f=j.useContext(Ie);if(!f)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=f.protocols.find(_=>_.getName()===h);if(!i)return null;const p=f.protocolsStatus.get(i.getName());return{...i,connect:i.connect.bind(i),disconnect:i.disconnect.bind(i),sendPacket:i.sendPacket.bind(i),setSession:i.setSession.bind(i),addStatusChangeListener:i.addStatusChangeListener.bind(i),addPacketListener:i.addPacketListener.bind(i),getName:i.getName.bind(i),getPriority:i.getPriority.bind(i),status:p||i.status}}function Yg(){const h=j.useContext(Ie);if(!h)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return kg(h.protocols)}function Xg(){return Oo("webrtc")}function Qg(){const h=j.useContext(Ie);if(!h)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return h.getMessages()}const To="DEFAULT_THREAD_ID";function Vg(){const h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let f="";for(let i=0;i<8;i++)f+=h.charAt(Math.floor(Math.random()*h.length));return f}function jg(h,f,i,p,_,v,x,T,b,B){return{threadId:h,threads:f.filter(C=>C.status==="regular").map(C=>({id:C.threadId,threadId:C.threadId,title:C.title||`Session ${C.threadId}`,status:C.status})),archivedThreads:f.filter(C=>C.status==="archived").map(C=>({id:C.threadId,threadId:C.threadId,title:C.title||`Archived Chat ${C.threadId}`,status:C.status})),onSwitchToNewThread:()=>{const C=Vg(),k={threadId:C,status:"regular",title:`Session ${C}`};p(P=>[k,...P]),i(C),v==null||v(C)},onSwitchToThread:C=>{i(C),x==null||x(C)},onArchive:C=>{p(k=>k.map(P=>P.threadId===C?{...P,status:"archived"}:P)),T==null||T(C),C!==To&&_.archive(C)},onUnarchive:C=>{p(k=>k.map(P=>P.threadId===C?{...P,status:"regular"}:P)),b==null||b(C)},onDelete:async C=>{if(p(k=>k.filter(P=>P.threadId!==C)),h===C){const k=f.filter(P=>P.threadId!==C&&P.status==="regular");k.length>0&&i(k[0].threadId)}B==null||B(C),C!==To&&await _.delete(C)}}}class Wo{constructor(f){W(this,"endpoint");W(this,"apiKey");W(this,"pageSize");W(this,"logger");this.endpoint=f.endpoint.replace(/\/$/,""),this.apiKey=f.apiKey,this.pageSize=f.pageSize??200,this.logger=f.logger}buildHeaders(){const f={"Content-Type":"application/json"};return this.apiKey&&(f["x-persona-apikey"]=this.apiKey),f}async sync(f){var p,_;if(!f)return[];const i=`${this.endpoint}/sessions/${encodeURIComponent(String(f))}/messages?page=1&size=${this.pageSize}`;try{const v=await fetch(i,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return(p=this.logger)==null||p.warn("PersonaSessionStorage: failed to fetch messages",v.status,await v.text()),[];const x=await v.json();return Array.isArray(x.items)?x.items.map(b=>({id:b.id??b.messageId??void 0,protocol:b.protocol,thought:b.thought,text:b.text??"",image:b.image,type:b.type??"text",role:b.role??"assistant",file:b.file,sources:b.sources,sessionId:b.sessionId??f,finishReason:b.finishReason,functionCalls:b.functionCalls,functionResponse:b.functionResponse,status:b.status,createdAt:b.createdAt?new Date(b.createdAt):void 0,metadata:b.metadata})):[]}catch(v){return(_=this.logger)==null||_.warn("PersonaSessionStorage: error fetching messages",v),[]}}async archive(f){return this._visiblility(f,"archived")}async unarchive(f){return this._visiblility(f,"active")}async delete(f){return this._visiblility(f,"deleted")}async _visiblility(f,i){var _;if(!f)return;const p=`${this.endpoint}/sessions/${encodeURIComponent(String(f))}/visibility`;try{const v=JSON.stringify({visibility:i}),x=await fetch(p,{method:"PUT",headers:this.buildHeaders(),body:v});if(!x.ok){const T=await x.text();throw(_=this.logger)==null||_.warn("PersonaSessionStorage: failed to set session visibility",x.status,T),new Error(`Failed to set session visibility: ${x.status}`)}return}catch(v){throw v}}async clearAll(){return Promise.reject(new Error("PersonaAPIMessageStorage: clearAll not supported"))}async list(f,i){const p=new URLSearchParams({page:"1",size:"100",visibility:"active"});i&&p.set("userId",i),f&&p.set("agentId",f);const _=`${this.endpoint}/sessions?${p.toString()}`;try{const v=await fetch(_,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return[];const x=await v.json();return Array.isArray(x.items)?x.items.map(b=>({threadId:b.code||b.id,title:b.title||`Session ${b.code||b.id}`,status:b.status==="archived"?"archived":"regular"})):[]}catch{return[]}}}function t_({dev:h=!1,baseUrl:f,protocols:i,logger:p,children:_,session:v="new",transformMessages:x,threads:T=!1,sessionStorage:b,onThreadCreate:B,onThreadSwitch:C,onThreadRename:k,onThreadArchive:P,onThreadUnarchive:G,onThreadDelete:J,...$}){const[_t,It]=j.useState(!1),[Vt,st]=j.useState([]),[In,Ht]=j.useState(new Map),gn=j.useRef(!1),xt=j.useRef(!1),Dt=j.useMemo(()=>b||new Wo({apiKey:$.apiKey,endpoint:f||"https://persona.applica.guru/api"}),[b,f,$.apiKey]),[Bn,Re]=j.useState([]),[Rt,Pe]=j.useState(""),Mn=j.useRef(typeof v=="string"?v:"new"),re=j.useRef(!1);j.useEffect(()=>{!T||re.current||(re.current=!0,Dt.list($.agentId,$.userId).then(X=>{(X==null?void 0:X.length)>0&&(Re(X),Pe(X[0].threadId))}).catch(X=>p==null?void 0:p.error("Failed to load threads:",X)))},[T,Dt,$.agentId,$.userId,p]);const ft=j.useMemo(()=>Dg(i,{dev:h||!1,baseUrl:f,apiKey:$.apiKey,agentId:$.agentId,userId:$.userId,tools:$.tools,logger:p}),[i,h,f,$.apiKey,$.agentId,$.userId,$.tools,p]);j.useEffect(()=>{gn.current||(gn.current=!0,p==null||p.debug("Setting up protocols:",ft.map(X=>X.getName())),ft.forEach(X=>{X.setSession(Mn.current),X.clearListeners(),X.addStatusChangeListener(ct=>{p==null||p.debug(`${X.getName()} status: ${ct}`),Ht(zt=>{const Rn=new Map(zt);return Rn.set(X.getName(),ct),Rn}),ct==="connected"&&!xt.current&&($.context&&X.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:$.context}}).catch(()=>{}),$.tools&&Array.isArray($.tools)&&X.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:$.tools.map(zt=>zt.schema)}}}).catch(()=>{}))}),X.addPacketListener(Bg(X,st,It,ft,x)),X.autostart&&X.status==="disconnected"&&(p==null||p.debug(`Auto-connecting protocol: ${X.getName()}`),X.connect(Mn.current).catch(()=>{}),It(!1))}))},[]),j.useEffect(()=>{if(!T||!Rt){st([]);return}if(xt.current||Rt===Mn.current)return;xt.current=!0,p==null||p.info("Switching to thread:",Rt),(async()=>{try{const ct=ft.filter(vt=>vt.status==="connected");ct.length>0&&await Promise.allSettled(ct.map(vt=>vt.disconnect())),Mn.current=Rt,await Promise.allSettled(ft.map(vt=>vt.setSession(Rt)));const zt=await Dt.sync(Rt),Rn=ee(zt);st(x?x(Rn):Rn),p==null||p.debug(`Loaded ${zt.length} messages for thread ${Rt}`);const _n=ft.filter(vt=>vt.autostart);_n.length>0&&await Promise.allSettled(_n.map(vt=>vt.connect(Rt)))}catch(ct){p==null||p.error("Failed to switch thread:",ct),st([])}finally{xt.current=!1}})()},[Rt,T,ft,Dt,x,p]);const br=j.useCallback(Hg(ft,st,It,x,p),[ft,x,p]),rn=j.useCallback(zg(ft,Vt,st,It,x,p),[ft,Vt,x,p]),jt=j.useCallback(Gg(ft,Vt,st,It,x,p),[ft,Vt,x,p]),Cr=j.useCallback(Jg(ft,st,It,x),[ft,x]),$n=j.useCallback(X=>{const ct=ee([...X]);st(x?x(ct):ct)},[x]),Ft=j.useCallback(()=>Vt,[Vt]),Ee=j.useMemo(()=>{if(T)return jg(Rt,Bn,Pe,Re,Dt,B,C,P,G,J)},[T,Rt,Bn,Dt,B,C,P,G,J,p]),Ir=xr.useExternalStoreRuntime({isRunning:_t,messages:Vt,convertMessage:Rg,setMessages:$n,onNew:br,onEdit:rn,onCancel:Cr,onReload:jt,adapters:{attachments:new xr.CompositeAttachmentAdapter([new xr.SimpleImageAttachmentAdapter]),...Ee?{threadList:Ee}:{}}});return Zi.jsx(Ie.Provider,{value:{protocols:ft,protocolsStatus:In,getMessages:Ft},children:Zi.jsx(xr.AssistantRuntimeProvider,{runtime:Ir,children:_})})}function n_({children:h,...f}){return Zi.jsx(t_,{...f,children:h})}class e_{constructor(){W(this,"prefix","[Persona]")}log(f,...i){console.log(`${this.prefix} - ${f}`,...i)}info(f,...i){console.info(`${this.prefix} - ${f}`,...i)}warn(f,...i){console.warn(`${this.prefix} - ${f}`,...i)}error(f,...i){console.error(`${this.prefix} - ${f}`,...i)}debug(f,...i){console.debug(`${this.prefix} - ${f}`,...i)}}function Un(h,f,i){return{type:h,description:f,...i}}function Do(h){const f=Object.entries(h.parameters).filter(([i,p])=>p.required).map(([i])=>i);return{type:"local",name:h.name,description:h.description,config:{timeout:h.timeout||60,parameters:{type:"object",title:h.title||`${h.name} parameters`,required:f,properties:h.parameters},output:{type:"object",title:`${h.name} output`,properties:h.output}}}}function Ar(h){return{schema:Do(h),implementation:h.implementation}}function Fo(h,f,i,p,_,v){const x={name:h,description:f,title:v==null?void 0:v.title,timeout:v==null?void 0:v.timeout,parameters:p,output:_,implementation:i};return Ar(x)}const r_=Fo("sum","Sum two numbers",function(f,i){return{result:f+i}},{a:Un("number","First number to sum",{required:!0}),b:Un("number","Second number to sum",{required:!0})},{result:Un("number","Sum of two numbers")}),i_=Ar({name:"navigate_to",description:"Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",title:"Sum two numbers",timeout:60,parameters:{a:Un("number","First number to sum"),b:Un("number","Seconth number to sum")},output:{result:Un("number","Sum of two numbers")},implementation:function(f,i){return{result:f+i}}});function u_(h){const f=[],i={};return h.forEach(p=>{const{schema:_,implementation:v}=Ar(p);f.push(_),i[p.name]=v}),{schemas:f,implementations:i}}function s_(h,f){const{required:i,properties:p}=f.config.parameters;for(const _ of i)if(!(_ in h))throw new Error(`Missing required parameter: ${_}`);for(const[_,v]of Object.entries(h)){const x=p[_];if(x){if(x.type==="number"&&typeof v!="number")throw new Error(`Parameter ${_} should be a number`);if(x.type==="string"&&typeof v!="string")throw new Error(`Parameter ${_} should be a string`);if(x.type==="boolean"&&typeof v!="boolean")throw new Error(`Parameter ${_} should be a boolean`)}}return!0}exports.PersonaConsoleLogger=e_;exports.PersonaProtocolBase=Ce;exports.PersonaRESTProtocol=Yi;exports.PersonaRuntimeProvider=n_;exports.PersonaSessionStorage=Wo;exports.PersonaTransactionProtocol=Lo;exports.PersonaWebRTCProtocol=Qi;exports.PersonaWebSocketProtocol=Xi;exports.createParameter=Un;exports.createTool=Ar;exports.createToolFromFunction=Fo;exports.createToolRegistry=u_;exports.generateToolSchema=Do;exports.navigateToToolExample=i_;exports.sumTool=r_;exports.usePersonaRuntime=Zg;exports.usePersonaRuntimeEndpoint=Yg;exports.usePersonaRuntimeMessages=Qg;exports.usePersonaRuntimeProtocol=Oo;exports.usePersonaRuntimeWebRTCProtocol=Xg;exports.validateToolParameters=s_;
27
+ }`;var U=Ro(function(){return G(o,R+"return "+S).apply(i,a)});if(U.source=S,Ui(U))throw U;return U}function Pp(t){return Y(t).toLowerCase()}function Ep(t){return Y(t).toUpperCase()}function Tp(t,n,e){if(t=Y(t),t&&(e||n===i))return Fu(t);if(!t||!(n=Lt(n)))return t;var r=Zt(t),u=Zt(n),o=Nu(r,u),a=Uu(r,u)+1;return bn(r,o,a).join("")}function Lp(t,n,e){if(t=Y(t),t&&(e||n===i))return t.slice(0,Mu(t)+1);if(!t||!(n=Lt(n)))return t;var r=Zt(t),u=Uu(r,Zt(n))+1;return bn(r,0,u).join("")}function Op(t,n,e){if(t=Y(t),t&&(e||n===i))return t.replace(Ur,"");if(!t||!(n=Lt(n)))return t;var r=Zt(t),u=Nu(r,Zt(n));return bn(r,u).join("")}function Wp(t,n){var e=Re,r=Pt;if(et(n)){var u="separator"in n?n.separator:u;e="length"in n?N(n.length):e,r="omission"in n?Lt(n.omission):r}t=Y(t);var o=t.length;if(zn(t)){var a=Zt(t);o=a.length}if(e>=o)return t;var c=e-Gn(r);if(c<1)return r;var d=a?bn(a,0,c).join(""):t.slice(0,c);if(u===i)return d+r;if(a&&(c+=d.length-c),Bi(u)){if(t.slice(c).search(u)){var y,m=d;for(u.global||(u=ti(u.source,Y(ru.exec(u))+"g")),u.lastIndex=0;y=u.exec(m);)var S=y.index;d=d.slice(0,S===i?c:S)}}else if(t.indexOf(Lt(u),c)!=c){var A=d.lastIndexOf(u);A>-1&&(d=d.slice(0,A))}return d+r}function Dp(t){return t=Y(t),t&&Ho.test(t)?t.replace(tu,ff):t}var Fp=jn(function(t,n,e){return t+(e?" ":"")+n.toUpperCase()}),Ki=Rs("toUpperCase");function Io(t,n,e){return t=Y(t),n=e?i:n,n===i?rf(t)?hf(t):Za(t):t.match(n)||[]}var Ro=M(function(t,n){try{return Et(t,i,n)}catch(e){return Ui(e)?e:new D(e)}}),Np=cn(function(t,n){return Ut(n,function(e){e=en(e),an(t,e,Fi(t[e],t))}),t});function Up(t){var n=t==null?0:t.length,e=T();return t=n?nt(t,function(r){if(typeof r[1]!="function")throw new Bt(x);return[e(r[0]),r[1]]}):[],M(function(r){for(var u=-1;++u<n;){var o=t[u];if(Et(o[0],this,r))return Et(o[1],this,r)}})}function Bp(t){return fc($t(t,k))}function qi(t){return function(){return t}}function Mp(t,n){return t==null||t!==t?n:t}var $p=Es(),Kp=Es(!0);function Ct(t){return t}function ki(t){return us(typeof t=="function"?t:$t(t,k))}function qp(t){return os($t(t,k))}function kp(t,n){return as(t,$t(n,k))}var Hp=M(function(t,n){return function(e){return ve(e,t,n)}}),zp=M(function(t,n){return function(e){return ve(t,e,n)}});function Hi(t,n,e){var r=lt(n),u=nr(n,r);e==null&&!(et(n)&&(u.length||!r.length))&&(e=n,n=t,t=this,u=nr(n,lt(n)));var o=!(et(e)&&"chain"in e)||!!e.chain,a=hn(t);return Ut(u,function(c){var d=n[c];t[c]=d,a&&(t.prototype[c]=function(){var y=this.__chain__;if(o||y){var m=t(this.__wrapped__),S=m.__actions__=St(this.__actions__);return S.push({func:d,args:arguments,thisArg:t}),m.__chain__=y,m}return d.apply(t,wn([this.value()],arguments))})}),t}function Gp(){return ht._===this&&(ht._=wf),this}function zi(){}function Jp(t){return t=N(t),M(function(n){return fs(n,t)})}var Zp=Si(nt),Yp=Si(Tu),Xp=Si(Jr);function Po(t){return Ei(t)?Zr(en(t)):Ic(t)}function Qp(t){return function(n){return t==null?i:Wn(t,n)}}var Vp=Ls(),jp=Ls(!0);function Gi(){return[]}function Ji(){return!1}function tg(){return{}}function ng(){return""}function eg(){return!0}function rg(t,n){if(t=N(t),t<1||t>jt)return[];var e=Ft,r=pt(t,Ft);n=T(n),t-=Ft;for(var u=Qr(r,n);++e<t;)n(e);return u}function ig(t){return F(t)?nt(t,en):Ot(t)?[t]:St(Js(Y(t)))}function ug(t){var n=++_f;return Y(t)+n}var sg=or(function(t,n){return t+n},0),og=Ai("ceil"),ag=or(function(t,n){return t/n},1),fg=Ai("floor");function cg(t){return t&&t.length?tr(t,Ct,ai):i}function lg(t,n){return t&&t.length?tr(t,T(n,2),ai):i}function hg(t){return Wu(t,Ct)}function dg(t,n){return Wu(t,T(n,2))}function pg(t){return t&&t.length?tr(t,Ct,hi):i}function gg(t,n){return t&&t.length?tr(t,T(n,2),hi):i}var _g=or(function(t,n){return t*n},1),vg=Ai("round"),wg=or(function(t,n){return t-n},0);function yg(t){return t&&t.length?Xr(t,Ct):0}function mg(t,n){return t&&t.length?Xr(t,T(n,2)):0}return s.after=qh,s.ary=io,s.assign=Ed,s.assignIn=yo,s.assignInWith=mr,s.assignWith=Td,s.at=Ld,s.before=uo,s.bind=Fi,s.bindAll=Np,s.bindKey=so,s.castArray=td,s.chain=no,s.chunk=fl,s.compact=cl,s.concat=ll,s.cond=Up,s.conforms=Bp,s.constant=qi,s.countBy=yh,s.create=Od,s.curry=oo,s.curryRight=ao,s.debounce=fo,s.defaults=Wd,s.defaultsDeep=Dd,s.defer=kh,s.delay=Hh,s.difference=hl,s.differenceBy=dl,s.differenceWith=pl,s.drop=gl,s.dropRight=_l,s.dropRightWhile=vl,s.dropWhile=wl,s.fill=yl,s.filter=xh,s.flatMap=bh,s.flatMapDeep=Ch,s.flatMapDepth=Ih,s.flatten=Qs,s.flattenDeep=ml,s.flattenDepth=xl,s.flip=zh,s.flow=$p,s.flowRight=Kp,s.fromPairs=Sl,s.functions=Kd,s.functionsIn=qd,s.groupBy=Rh,s.initial=bl,s.intersection=Cl,s.intersectionBy=Il,s.intersectionWith=Rl,s.invert=Hd,s.invertBy=zd,s.invokeMap=Eh,s.iteratee=ki,s.keyBy=Th,s.keys=lt,s.keysIn=bt,s.map=pr,s.mapKeys=Jd,s.mapValues=Zd,s.matches=qp,s.matchesProperty=kp,s.memoize=_r,s.merge=Yd,s.mergeWith=mo,s.method=Hp,s.methodOf=zp,s.mixin=Hi,s.negate=vr,s.nthArg=Jp,s.omit=Xd,s.omitBy=Qd,s.once=Gh,s.orderBy=Lh,s.over=Zp,s.overArgs=Jh,s.overEvery=Yp,s.overSome=Xp,s.partial=Ni,s.partialRight=co,s.partition=Oh,s.pick=Vd,s.pickBy=xo,s.property=Po,s.propertyOf=Qp,s.pull=Ll,s.pullAll=js,s.pullAllBy=Ol,s.pullAllWith=Wl,s.pullAt=Dl,s.range=Vp,s.rangeRight=jp,s.rearg=Zh,s.reject=Fh,s.remove=Fl,s.rest=Yh,s.reverse=Wi,s.sampleSize=Uh,s.set=tp,s.setWith=np,s.shuffle=Bh,s.slice=Nl,s.sortBy=Kh,s.sortedUniq=kl,s.sortedUniqBy=Hl,s.split=bp,s.spread=Xh,s.tail=zl,s.take=Gl,s.takeRight=Jl,s.takeRightWhile=Zl,s.takeWhile=Yl,s.tap=ch,s.throttle=Qh,s.thru=dr,s.toArray=_o,s.toPairs=So,s.toPairsIn=Ao,s.toPath=ig,s.toPlainObject=wo,s.transform=ep,s.unary=Vh,s.union=Xl,s.unionBy=Ql,s.unionWith=Vl,s.uniq=jl,s.uniqBy=th,s.uniqWith=nh,s.unset=rp,s.unzip=Di,s.unzipWith=to,s.update=ip,s.updateWith=up,s.values=ee,s.valuesIn=sp,s.without=eh,s.words=Io,s.wrap=jh,s.xor=rh,s.xorBy=ih,s.xorWith=uh,s.zip=sh,s.zipObject=oh,s.zipObjectDeep=ah,s.zipWith=fh,s.entries=So,s.entriesIn=Ao,s.extend=yo,s.extendWith=mr,Hi(s,s),s.add=sg,s.attempt=Ro,s.camelCase=cp,s.capitalize=bo,s.ceil=og,s.clamp=op,s.clone=nd,s.cloneDeep=rd,s.cloneDeepWith=id,s.cloneWith=ed,s.conformsTo=ud,s.deburr=Co,s.defaultTo=Mp,s.divide=ag,s.endsWith=lp,s.eq=Xt,s.escape=hp,s.escapeRegExp=dp,s.every=mh,s.find=Sh,s.findIndex=Ys,s.findKey=Fd,s.findLast=Ah,s.findLastIndex=Xs,s.findLastKey=Nd,s.floor=fg,s.forEach=eo,s.forEachRight=ro,s.forIn=Ud,s.forInRight=Bd,s.forOwn=Md,s.forOwnRight=$d,s.get=Mi,s.gt=sd,s.gte=od,s.has=kd,s.hasIn=$i,s.head=Vs,s.identity=Ct,s.includes=Ph,s.indexOf=Al,s.inRange=ap,s.invoke=Gd,s.isArguments=Nn,s.isArray=F,s.isArrayBuffer=ad,s.isArrayLike=At,s.isArrayLikeObject=ut,s.isBoolean=fd,s.isBuffer=Cn,s.isDate=cd,s.isElement=ld,s.isEmpty=hd,s.isEqual=dd,s.isEqualWith=pd,s.isError=Ui,s.isFinite=gd,s.isFunction=hn,s.isInteger=lo,s.isLength=wr,s.isMap=ho,s.isMatch=_d,s.isMatchWith=vd,s.isNaN=wd,s.isNative=yd,s.isNil=xd,s.isNull=md,s.isNumber=po,s.isObject=et,s.isObjectLike=rt,s.isPlainObject=Ae,s.isRegExp=Bi,s.isSafeInteger=Sd,s.isSet=go,s.isString=yr,s.isSymbol=Ot,s.isTypedArray=ne,s.isUndefined=Ad,s.isWeakMap=bd,s.isWeakSet=Cd,s.join=Pl,s.kebabCase=pp,s.last=qt,s.lastIndexOf=El,s.lowerCase=gp,s.lowerFirst=_p,s.lt=Id,s.lte=Rd,s.max=cg,s.maxBy=lg,s.mean=hg,s.meanBy=dg,s.min=pg,s.minBy=gg,s.stubArray=Gi,s.stubFalse=Ji,s.stubObject=tg,s.stubString=ng,s.stubTrue=eg,s.multiply=_g,s.nth=Tl,s.noConflict=Gp,s.noop=zi,s.now=gr,s.pad=vp,s.padEnd=wp,s.padStart=yp,s.parseInt=mp,s.random=fp,s.reduce=Wh,s.reduceRight=Dh,s.repeat=xp,s.replace=Sp,s.result=jd,s.round=vg,s.runInContext=l,s.sample=Nh,s.size=Mh,s.snakeCase=Ap,s.some=$h,s.sortedIndex=Ul,s.sortedIndexBy=Bl,s.sortedIndexOf=Ml,s.sortedLastIndex=$l,s.sortedLastIndexBy=Kl,s.sortedLastIndexOf=ql,s.startCase=Cp,s.startsWith=Ip,s.subtract=wg,s.sum=yg,s.sumBy=mg,s.template=Rp,s.times=rg,s.toFinite=dn,s.toInteger=N,s.toLength=vo,s.toLower=Pp,s.toNumber=kt,s.toSafeInteger=Pd,s.toString=Y,s.toUpper=Ep,s.trim=Tp,s.trimEnd=Lp,s.trimStart=Op,s.truncate=Wp,s.unescape=Dp,s.uniqueId=ug,s.upperCase=Fp,s.upperFirst=Ki,s.each=eo,s.eachRight=ro,s.first=Vs,Hi(s,function(){var t={};return tn(s,function(n,e){X.call(s.prototype,e)||(t[e]=n)}),t}(),{chain:!1}),s.VERSION=p,Ut(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){s[t].placeholder=s}),Ut(["drop","take"],function(t,n){q.prototype[t]=function(e){e=e===i?1:ft(N(e),0);var r=this.__filtered__&&!n?new q(this):this.clone();return r.__filtered__?r.__takeCount__=pt(e,r.__takeCount__):r.__views__.push({size:pt(e,Ft),type:t+(r.__dir__<0?"Right":"")}),r},q.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ut(["filter","map","takeWhile"],function(t,n){var e=n+1,r=e==re||e==br;q.prototype[t]=function(u){var o=this.clone();return o.__iteratees__.push({iteratee:T(u,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),Ut(["head","last"],function(t,n){var e="take"+(n?"Right":"");q.prototype[t]=function(){return this[e](1).value()[0]}}),Ut(["initial","tail"],function(t,n){var e="drop"+(n?"":"Right");q.prototype[t]=function(){return this.__filtered__?new q(this):this[e](1)}}),q.prototype.compact=function(){return this.filter(Ct)},q.prototype.find=function(t){return this.filter(t).head()},q.prototype.findLast=function(t){return this.reverse().find(t)},q.prototype.invokeMap=M(function(t,n){return typeof t=="function"?new q(this):this.map(function(e){return ve(e,t,n)})}),q.prototype.reject=function(t){return this.filter(vr(T(t)))},q.prototype.slice=function(t,n){t=N(t);var e=this;return e.__filtered__&&(t>0||n<0)?new q(e):(t<0?e=e.takeRight(-t):t&&(e=e.drop(t)),n!==i&&(n=N(n),e=n<0?e.dropRight(-n):e.take(n-t)),e)},q.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},q.prototype.toArray=function(){return this.take(Ft)},tn(q.prototype,function(t,n){var e=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),u=s[r?"take"+(n=="last"?"Right":""):n],o=r||/^find/.test(n);u&&(s.prototype[n]=function(){var a=this.__wrapped__,c=r?[1]:arguments,d=a instanceof q,y=c[0],m=d||F(a),S=function(K){var H=u.apply(s,wn([K],c));return r&&A?H[0]:H};m&&e&&typeof y=="function"&&y.length!=1&&(d=m=!1);var A=this.__chain__,R=!!this.__actions__.length,L=o&&!A,U=d&&!R;if(!o&&m){a=U?a:new q(this);var O=t.apply(a,c);return O.__actions__.push({func:dr,args:[S],thisArg:i}),new Mt(O,A)}return L&&U?t.apply(this,c):(O=this.thru(S),L?r?O.value()[0]:O.value():O)})}),Ut(["pop","push","shift","sort","splice","unshift"],function(t){var n=Me[t],e=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);s.prototype[t]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return n.apply(F(o)?o:[],u)}return this[e](function(a){return n.apply(F(a)?a:[],u)})}}),tn(q.prototype,function(t,n){var e=s[n];if(e){var r=e.name+"";X.call(Xn,r)||(Xn[r]=[]),Xn[r].push({name:n,func:e})}}),Xn[sr(i,It).name]=[{name:"wrapper",func:i}],q.prototype.clone=Df,q.prototype.reverse=Ff,q.prototype.value=Nf,s.prototype.at=lh,s.prototype.chain=hh,s.prototype.commit=dh,s.prototype.next=ph,s.prototype.plant=_h,s.prototype.reverse=vh,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=wh,s.prototype.first=s.prototype.head,ce&&(s.prototype[ce]=gh),s},Jn=df();Pn?((Pn.exports=Jn)._=Jn,kr._=Jn):ht._=Jn}).call(be)})(Sr,Sr.exports);var Tg=Sr.exports;const Lg=Eg(Tg);class Og{constructor(f){W(this,"config");this.config=f}async complete(f,i){var p;await this.persist(f,{...i,success:!0}),(p=this.config.logger)==null||p.debug("Transaction completed:",f)}async fail(f,i){var p;await this.persist(f,{...i,success:!1}),(p=this.config.logger)==null||p.debug("Transaction failed:",{...f,...i})}async persist(f,i){await fetch(`${this.config.apiUrl}/transactions/${f.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Wg{constructor(f,i){W(this,"transaction");W(this,"manager");this.transaction=f,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(f,i){var E;const p=this.transaction.functionCall;if(!p){await this.fail("No function call found");return}const _=p.name,v=p.args,x=f[_];if(!x){await this.fail(`Tool ${_} not found`);return}try{const b=Lg.get(i,"schema.config.parameters.properties",{}),C=(b&&Object.keys(b).length>0?Object.keys(b):((E=x.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:E[1].split(",").map(P=>P.trim()).filter(Boolean))||[]).map(P=>v[P]),k=await x.apply(null,C);await this.complete(k)}catch(b){await this.fail(`Error executing tool ${_}: ${b}`)}}async complete(f){await this.manager.complete(this.transaction,{success:!0,output:f,error:null})}async fail(f){await this.manager.fail(this.transaction,{success:!1,output:null,error:f})}}class Lo extends Ce{constructor(i){super();W(this,"status");W(this,"autostart");W(this,"session");W(this,"config");W(this,"notify",!0);W(this,"_tools");W(this,"_toolSchema",{});if(this.config=i,this.status="disconnected",this.autostart=!0,Array.isArray(i.tools)){this._tools={};for(const p of i.tools)p.schema&&p.implementation&&(this._tools[p.schema.name]=p.implementation,this._toolSchema[p.schema.name]=p)}else this._tools=i.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(i){return this._toolSchema[i]}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){}onTransaction(i){const p=new Og(this.config),_=new Wg(i,p);if(this.config.onTransaction)this.config.onTransaction(_);else{const v=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;_.invoke(this._tools,v)}}getTools(){return this._tools}}function Dg(h,f){if(Array.isArray(h))return h;if(typeof h=="object"&&h!==null){const i=f.dev?"localhost:8000":f.baseUrl||"persona.applica.guru/api",p=f.dev?"http":"https",_=f.dev?"ws":"wss";let v=Object.keys(h).map(x=>{switch(x){case"rest":return Fg(h[x],{baseEndpointProtocol:p,baseEndpoint:i,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger});case"webrtc":return Ng(h[x],{baseWebSocketProtocol:_,baseEndpoint:i,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger});case"websocket":return Ug(h[x],{baseWebSocketProtocol:_,baseEndpoint:i,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger});default:throw new Error(`Unknown protocol: ${x}`)}}).filter(x=>x!==null);return f.tools&&v.push(new Lo({apiUrl:`${p}://${i}`,apiKey:f.apiKey,agentId:f.agentId,tools:f.tools,logger:f.logger})),v}throw new Error("Invalid protocols configuration")}function Fg(h,f){return h===!0?new Yi({apiUrl:`${f.baseEndpointProtocol}://${f.baseEndpoint}`,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger}):typeof h=="object"&&h!==null?new Yi(h):null}function Ng(h,f){return h===!0?new Qi({webrtcUrl:`${f.baseWebSocketProtocol}://${f.baseEndpoint}/webrtc`,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger}):typeof h=="object"&&h!==null?new Qi(h):null}function Ug(h,f){return h===!0?new Xi({webSocketUrl:`${f.baseWebSocketProtocol}://${f.baseEndpoint}/websocket`,apiKey:f.apiKey,agentId:f.agentId,userId:f.userId,logger:f.logger}):typeof h=="object"&&h!==null?new Xi(h):null}function Bg(h,f,i,p,_){return v=>{v.type==="message"?Mg(v.payload,h,f,i,_):v.type==="reasoning"?$g(v.payload,h,f,_):v.type==="transaction"&&Kg(v.payload,h,p)}}function Mg(h,f,i,p,_){h.createdAt||(h.createdAt=new Date),(h==null?void 0:h.finishReason)==="stop"&&!(h!=null&&h.functionResponse)&&!(h!=null&&h.thought)&&p(!1),h.thought&&(h.type="reasoning"),h.protocol=f.getName(),i(v=>{const x=Un([...v,h]);return _?_(x):x})}function $g(h,f,i,p){const _={type:"reasoning",text:h.thought,role:"assistant",finishReason:"stop",protocol:f.getName(),createdAt:new Date};i(v=>{const x=Un([...v,_]);return p?p(x):x})}function Kg(h,f,i){i.filter(p=>p!==f).forEach(p=>p.onTransaction(h))}function qg(h){return new Promise((f,i)=>{const p=new FileReader;p.readAsDataURL(h),p.onload=()=>{const v=p.result.split(";base64,")[1];f(v)},p.onerror=_=>{i(_)}})}function kg(h){const f={rest:i=>i.config.apiUrl,webrtc:i=>i.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:i=>i.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const i of h){const p=f[i.getName()];if(p)return p(i)}return null}function Hg(h,f,i,p,_){return async v=>{var k;if(((k=v.content[0])==null?void 0:k.type)!=="text")throw new Error("Only text messages are supported");if(!h.some(P=>P.getName()!=="transaction"&&P.status==="connected")){f(P=>{const J={role:"assistant",type:"text",text:"No protocol is connected.",createdAt:new Date,finishReason:"stop"},Z=[...P,J];return p?p(Z):Z});return}const b={role:"user",type:"text",text:v.content[0].text,createdAt:new Date};f(P=>{const J=Un([...P,b]);return p?p(J):J}),i(!0);const B=h.sort((P,J)=>J.getPriority()-P.getPriority()).find(P=>P.status==="connected"),C=[];if(v.attachments)for(const P of v.attachments)P.contentType.startsWith("image/")&&P.file&&C.push({role:"user",image:{contentType:P.contentType,content:await qg(P.file)},text:"",type:"text",createdAt:new Date});v.content&&C.push({role:"user",text:v.content[0].text,type:"text",createdAt:new Date}),_==null||_.debug("Sending message:",C),await(B==null?void 0:B.sendPacket({type:"request",payload:C}))}}function zg(h,f,i,p,_,v){return async x=>{var Z;if(((Z=x.content[0])==null?void 0:Z.type)!=="text")throw new Error("Only text messages are supported");const E=h.sort(($,_t)=>_t.getPriority()-$.getPriority()).find($=>$.status==="connected");if(!E){v==null||v.debug("No protocol available for edit");return}const b=x.parentId;if(!b){v==null||v.debug("No parent ID provided for edit");return}const B=f.findIndex($=>$.id===b);if(B===-1){v==null||v.debug("Parent message not found:",b);return}const C=f.slice(0,B+1),k={role:"user",text:x.content[0].text,type:"text",createdAt:new Date},P=Un([...C,k]);i(_?_(P):P),p(!0);const J=[{role:"user",text:x.content[0].text,type:"text",createdAt:new Date}];v==null||v.debug("Sending edited message:",J),await E.sendPacket({type:"request",payload:J})}}function Gg(h,f,i,p,_,v){return async(x,E)=>{const b=h.sort((Z,$)=>$.getPriority()-Z.getPriority()).find(Z=>Z.status==="connected");if(!b){v==null||v.debug("No protocol available for reload");return}const B=E.parentId??x;if(!B){v==null||v.debug("No parent ID provided for reload");return}const C=f.findIndex(Z=>Z.id===B);if(C===-1){v==null||v.debug("Parent message not found:",B);return}const k=f[C];i(Z=>{const $=Z.slice(0,C+1);return _?_($):$});let P;if(k.role==="assistant"||k.role==="function"){for(let Z=C-1;Z>=0;Z--)if(f[Z].role==="user"){P=f[Z];break}}else k.role==="user"&&(P=k);if(!P){v==null||v.debug("No user message found to regenerate from");return}p(!0);const J=[];P.image&&J.push({role:"user",image:P.image,text:"",type:"text",createdAt:new Date}),J.push({role:"user",text:P.text,type:"text",createdAt:new Date}),v==null||v.debug("Regenerating message with config:",{actualParentId:B,sourceId:E.sourceId,custom:E.runConfig.custom}),await b.sendPacket({type:"request",payload:J})}}function Jg(h,f,i,p){return()=>(i(!1),f(_=>{const v=_[_.length-1];if((v==null?void 0:v.role)==="assistant"&&!v.finishReason){const x=[..._];return x[x.length-1]={...v,finishReason:"stop",status:{type:"incomplete"}},p?p(x):x}return _}),h.forEach(_=>{_.status==="connected"&&_.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:{cancel:!0}}}).catch(()=>{})}),Promise.resolve())}const Ie=V.createContext(void 0);function Zg(){const h=V.useContext(Ie);if(!h)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return h}function Oo(h){const f=V.useContext(Ie);if(!f)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=f.protocols.find(_=>_.getName()===h);if(!i)return null;const p=f.protocolsStatus.get(i.getName());return{...i,connect:i.connect.bind(i),disconnect:i.disconnect.bind(i),sendPacket:i.sendPacket.bind(i),setSession:i.setSession.bind(i),addStatusChangeListener:i.addStatusChangeListener.bind(i),addPacketListener:i.addPacketListener.bind(i),getName:i.getName.bind(i),getPriority:i.getPriority.bind(i),status:p||i.status}}function Yg(){const h=V.useContext(Ie);if(!h)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return kg(h.protocols)}function Xg(){return Oo("webrtc")}function Qg(){const h=V.useContext(Ie);if(!h)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return h.getMessages()}const To="DEFAULT_THREAD_ID";function Vg(){const h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let f="";for(let i=0;i<8;i++)f+=h.charAt(Math.floor(Math.random()*h.length));return f}function jg(h,f,i,p,_,v,x,E,b,B){return{threadId:h,threads:f.filter(C=>C.status==="regular").map(C=>({id:C.threadId,threadId:C.threadId,title:C.title||`Session ${C.threadId}`,status:C.status})),archivedThreads:f.filter(C=>C.status==="archived").map(C=>({id:C.threadId,threadId:C.threadId,title:C.title||`Archived Chat ${C.threadId}`,status:C.status})),onSwitchToNewThread:()=>{const C=Vg(),k={threadId:C,status:"regular",title:`Session ${C}`};p(P=>[k,...P]),i(C),v==null||v(C)},onSwitchToThread:C=>{i(C),x==null||x(C)},onArchive:C=>{p(k=>k.map(P=>P.threadId===C?{...P,status:"archived"}:P)),E==null||E(C),C!==To&&_.archive(C)},onUnarchive:C=>{p(k=>k.map(P=>P.threadId===C?{...P,status:"regular"}:P)),b==null||b(C)},onDelete:async C=>{if(p(k=>k.filter(P=>P.threadId!==C)),h===C){const k=f.filter(P=>P.threadId!==C&&P.status==="regular");k.length>0&&i(k[0].threadId)}B==null||B(C),C!==To&&await _.delete(C)}}}class Wo{constructor(f){W(this,"endpoint");W(this,"apiKey");W(this,"pageSize");W(this,"logger");this.endpoint=f.endpoint.replace(/\/$/,""),this.apiKey=f.apiKey,this.pageSize=f.pageSize??200,this.logger=f.logger}buildHeaders(){const f={"Content-Type":"application/json"};return this.apiKey&&(f["x-persona-apikey"]=this.apiKey),f}async sync(f){var p,_;if(!f)return[];const i=`${this.endpoint}/sessions/${encodeURIComponent(String(f))}/messages?page=1&size=${this.pageSize}`;try{const v=await fetch(i,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return(p=this.logger)==null||p.warn("PersonaSessionStorage: failed to fetch messages",v.status,await v.text()),[];const x=await v.json();return Array.isArray(x.items)?x.items.map(b=>({id:b.id??b.messageId??void 0,protocol:b.protocol,thought:b.thought,text:b.text??"",image:b.image,type:b.type??"text",role:b.role??"assistant",file:b.file,sources:b.sources,sessionId:b.sessionId??f,finishReason:b.finishReason,functionCalls:b.functionCalls,functionResponse:b.functionResponse,status:b.status,createdAt:b.createdAt?new Date(b.createdAt):void 0,metadata:b.metadata})):[]}catch(v){return(_=this.logger)==null||_.warn("PersonaSessionStorage: error fetching messages",v),[]}}async archive(f){return this._visiblility(f,"archived")}async unarchive(f){return this._visiblility(f,"active")}async delete(f){return this._visiblility(f,"deleted")}async _visiblility(f,i){var _;if(!f)return;const p=`${this.endpoint}/sessions/${encodeURIComponent(String(f))}/visibility`;try{const v=JSON.stringify({visibility:i}),x=await fetch(p,{method:"PUT",headers:this.buildHeaders(),body:v});if(!x.ok){const E=await x.text();throw(_=this.logger)==null||_.warn("PersonaSessionStorage: failed to set session visibility",x.status,E),new Error(`Failed to set session visibility: ${x.status}`)}return}catch(v){throw v}}async clearAll(){return Promise.reject(new Error("PersonaAPIMessageStorage: clearAll not supported"))}async list(f,i){const p=new URLSearchParams({page:"1",size:"100",visibility:"active"});i&&p.set("userId",i),f&&p.set("agentId",f);const _=`${this.endpoint}/sessions?${p.toString()}`;try{const v=await fetch(_,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return[];const x=await v.json();return Array.isArray(x.items)?x.items.map(b=>({threadId:b.code||b.id,title:b.title||`Session ${b.code||b.id}`,status:b.status==="archived"?"archived":"regular"})):[]}catch{return[]}}}function t_({dev:h=!1,baseUrl:f,protocols:i,logger:p,children:_,session:v="new",transformMessages:x,threads:E=!1,sessionStorage:b,onThreadCreate:B,onThreadSwitch:C,onThreadRename:k,onThreadArchive:P,onThreadUnarchive:J,onThreadDelete:Z,...$}){const[_t,It]=V.useState(!1),[Vt,ot]=V.useState([]),[In,Ht]=V.useState(new Map),gn=V.useRef(!1),xt=V.useRef(!1),Rt=V.useMemo(()=>b||new Wo({apiKey:$.apiKey,endpoint:f||"https://persona.applica.guru/api"}),[b,f,$.apiKey]),[Mn,Re]=V.useState([]),[Pt,Pe]=V.useState(""),$n=V.useRef(typeof v=="string"?v:"new"),re=V.useRef(!1);V.useEffect(()=>{!E||re.current||(re.current=!0,Rt.list($.agentId,$.userId).then(z=>{(z==null?void 0:z.length)>0&&(Re(z),Pe(z[0].threadId))}).catch(z=>p==null?void 0:p.error("Failed to load threads:",z)))},[E,Rt,$.agentId,$.userId,p]);const ct=V.useMemo(()=>Dg(i,{dev:h||!1,baseUrl:f,apiKey:$.apiKey,agentId:$.agentId,userId:$.userId,tools:$.tools,logger:p}),[i,h,f,$.apiKey,$.agentId,$.userId,$.tools,p]);V.useEffect(()=>{gn.current||(gn.current=!0,p==null||p.debug("Setting up protocols:",ct.map(z=>z.getName())),ct.forEach(z=>{z.setSession($n.current),z.clearListeners(),z.addStatusChangeListener(it=>{p==null||p.debug(`${z.getName()} status: ${it}`),Ht(zt=>{const Rn=new Map(zt);return Rn.set(z.getName(),it),Rn}),it==="connected"&&!xt.current&&($.context&&z.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:$.context}}).catch(()=>{}),$.tools&&Array.isArray($.tools)&&z.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:$.tools.map(zt=>zt.schema)}}}).catch(()=>{}))}),z.addPacketListener(Bg(z,ot,It,ct,x)),z.autostart&&z.status==="disconnected"&&(p==null||p.debug(`Auto-connecting protocol: ${z.getName()}`),z.connect($n.current).catch(()=>{}),It(!1))}))},[]),V.useEffect(()=>{E||!v||v==="new"||Rt.sync(v).then(z=>{if(z.length>0){const it=Un(z);ot(x?x(it):it),p==null||p.debug(`Loaded ${z.length} messages for session ${v}`)}}).catch(z=>{p==null||p.error("Failed to load session messages:",z)})},[]),V.useEffect(()=>{if(!E||!Pt){ot([]);return}if(xt.current||Pt===$n.current)return;xt.current=!0,p==null||p.info("Switching to thread:",Pt),(async()=>{try{const it=ct.filter(vt=>vt.status==="connected");it.length>0&&await Promise.allSettled(it.map(vt=>vt.disconnect())),$n.current=Pt,await Promise.allSettled(ct.map(vt=>vt.setSession(Pt)));const zt=await Rt.sync(Pt),Rn=Un(zt);ot(x?x(Rn):Rn),p==null||p.debug(`Loaded ${zt.length} messages for thread ${Pt}`);const _n=ct.filter(vt=>vt.autostart);_n.length>0&&await Promise.allSettled(_n.map(vt=>vt.connect(Pt)))}catch(it){p==null||p.error("Failed to switch thread:",it),ot([])}finally{xt.current=!1}})()},[Pt,E,ct,Rt,x,p]);const br=V.useCallback(Hg(ct,ot,It,x,p),[ct,x,p]),rn=V.useCallback(zg(ct,Vt,ot,It,x,p),[ct,Vt,x,p]),jt=V.useCallback(Gg(ct,Vt,ot,It,x,p),[ct,Vt,x,p]),Cr=V.useCallback(Jg(ct,ot,It,x),[ct,x]),Kn=V.useCallback(z=>{const it=Un([...z]);ot(x?x(it):it)},[x]),Ft=V.useCallback(()=>Vt,[Vt]),Ee=V.useMemo(()=>{if(E)return jg(Pt,Mn,Pe,Re,Rt,B,C,P,J,Z)},[E,Pt,Mn,Rt,B,C,P,J,Z,p]),Ir=xr.useExternalStoreRuntime({isRunning:_t,messages:Vt,convertMessage:Rg,setMessages:Kn,onNew:br,onEdit:rn,onCancel:Cr,onReload:jt,adapters:{attachments:new xr.CompositeAttachmentAdapter([new xr.SimpleImageAttachmentAdapter]),...Ee?{threadList:Ee}:{}}});return Zi.jsx(Ie.Provider,{value:{protocols:ct,protocolsStatus:In,getMessages:Ft},children:Zi.jsx(xr.AssistantRuntimeProvider,{runtime:Ir,children:_})})}function n_({children:h,...f}){return Zi.jsx(t_,{...f,children:h})}class e_{constructor(){W(this,"prefix","[Persona]")}log(f,...i){console.log(`${this.prefix} - ${f}`,...i)}info(f,...i){console.info(`${this.prefix} - ${f}`,...i)}warn(f,...i){console.warn(`${this.prefix} - ${f}`,...i)}error(f,...i){console.error(`${this.prefix} - ${f}`,...i)}debug(f,...i){console.debug(`${this.prefix} - ${f}`,...i)}}function Bn(h,f,i){return{type:h,description:f,...i}}function Do(h){const f=Object.entries(h.parameters).filter(([i,p])=>p.required).map(([i])=>i);return{type:"local",name:h.name,description:h.description,config:{timeout:h.timeout||60,parameters:{type:"object",title:h.title||`${h.name} parameters`,required:f,properties:h.parameters},output:{type:"object",title:`${h.name} output`,properties:h.output}}}}function Ar(h){return{schema:Do(h),implementation:h.implementation}}function Fo(h,f,i,p,_,v){const x={name:h,description:f,title:v==null?void 0:v.title,timeout:v==null?void 0:v.timeout,parameters:p,output:_,implementation:i};return Ar(x)}const r_=Fo("sum","Sum two numbers",function(f,i){return{result:f+i}},{a:Bn("number","First number to sum",{required:!0}),b:Bn("number","Second number to sum",{required:!0})},{result:Bn("number","Sum of two numbers")}),i_=Ar({name:"navigate_to",description:"Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",title:"Sum two numbers",timeout:60,parameters:{a:Bn("number","First number to sum"),b:Bn("number","Seconth number to sum")},output:{result:Bn("number","Sum of two numbers")},implementation:function(f,i){return{result:f+i}}});function u_(h){const f=[],i={};return h.forEach(p=>{const{schema:_,implementation:v}=Ar(p);f.push(_),i[p.name]=v}),{schemas:f,implementations:i}}function s_(h,f){const{required:i,properties:p}=f.config.parameters;for(const _ of i)if(!(_ in h))throw new Error(`Missing required parameter: ${_}`);for(const[_,v]of Object.entries(h)){const x=p[_];if(x){if(x.type==="number"&&typeof v!="number")throw new Error(`Parameter ${_} should be a number`);if(x.type==="string"&&typeof v!="string")throw new Error(`Parameter ${_} should be a string`);if(x.type==="boolean"&&typeof v!="boolean")throw new Error(`Parameter ${_} should be a boolean`)}}return!0}exports.PersonaConsoleLogger=e_;exports.PersonaProtocolBase=Ce;exports.PersonaRESTProtocol=Yi;exports.PersonaRuntimeProvider=n_;exports.PersonaSessionStorage=Wo;exports.PersonaTransactionProtocol=Lo;exports.PersonaWebRTCProtocol=Qi;exports.PersonaWebSocketProtocol=Xi;exports.createParameter=Bn;exports.createTool=Ar;exports.createToolFromFunction=Fo;exports.createToolRegistry=u_;exports.generateToolSchema=Do;exports.navigateToToolExample=i_;exports.sumTool=r_;exports.usePersonaRuntime=Zg;exports.usePersonaRuntimeEndpoint=Yg;exports.usePersonaRuntimeMessages=Qg;exports.usePersonaRuntimeProtocol=Oo;exports.usePersonaRuntimeWebRTCProtocol=Xg;exports.validateToolParameters=s_;
28
28
  //# sourceMappingURL=bundle.cjs.js.map