@applica-software-guru/persona-sdk 0.1.68 → 0.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +29 -3
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +4347 -655
- package/dist/bundle.es.js.map +1 -1
- package/dist/bundle.iife.js +29 -3
- package/dist/bundle.iife.js.map +1 -1
- package/dist/bundle.umd.js +29 -3
- package/dist/bundle.umd.js.map +1 -1
- package/dist/protocol/rest.d.ts.map +1 -1
- package/dist/protocol/transaction.d.ts +3 -1
- package/dist/protocol/transaction.d.ts.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/package.json +1 -1
- package/playground/src/chat.tsx +20 -4
- package/playground/src/tools.ts +22 -0
- package/src/protocol/rest.ts +11 -8
- package/src/protocol/transaction.ts +21 -11
- package/src/runtime.tsx +27 -23
package/dist/bundle.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(N,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("react"),require("@assistant-ui/react")):typeof define=="function"&&define.amd?define(["exports","react","@assistant-ui/react"],H):(N=typeof globalThis<"u"?globalThis:N||self,H(N.personaSDK={},N.React,N.AssistantUI))})(this,function(N,H,nt){"use strict";var Hd=Object.defineProperty;var Kd=(N,H,nt)=>H in N?Hd(N,H,{enumerable:!0,configurable:!0,writable:!0,value:nt}):N[H]=nt;var E=(N,H,nt)=>Kd(N,typeof H!="symbol"?H+"":H,nt);var Qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Oo(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var Hi={exports:{}},Vt={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,33 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var F;function K(){if(F)return E;F=1;var o=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(s,n,a){var i=null;if(a!==void 0&&(i=""+a),n.key!==void 0&&(i=""+n.key),"key"in n){a={};for(var l in n)l!=="key"&&(a[l]=n[l])}else a=n;return n=a.ref,{$$typeof:o,type:s,key:i,ref:n!==void 0?n:null,props:a}}return E.Fragment=t,E.jsx=e,E.jsxs=e,E}_.exports=K();var I=_.exports;function B(o){return o.filter(t=>{var e;return t.finishReason==="stop"?t.text!==null&&((e=t.text)==null?void 0:e.trim())!=="":!0})}function z(o){const t=[];let e=null;for(const n of o)n.type!=="transaction"&&(n.type==="reasoning"?(e!=null&&(t.push(e),e=null),t.push(n)):n.functionCalls?(e&&t.push(e),t.push(n),e=null):n.functionResponse?t[t.length-1]={...t[t.length-1],functionResponse:n.functionResponse}:e&&n.protocol===e.protocol&&(e.role===n.role||n.finishReason==="stop")?(e.text+=n.text,e.files=[...e.files??[],...n.files??[]]):(e&&t.push(e),e={...n}));return e&&t.push(e),B(t)}function V(o){var e,s;const t=((e=o.files)==null?void 0:e.map(n=>({type:"file",data:n.url,mimeType:n.contentType})))??[];return o.role==="function"?{id:o.id,role:"assistant",status:(o==null?void 0:o.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((s=o.functionCalls)==null?void 0:s.map(n=>{var a;return{type:"tool-call",toolName:n.name,toolCallId:n.id,args:n.args,result:(a=o.functionResponse)==null?void 0:a.result}}))??[]}:{id:o.id,role:o.role,content:o.type==="reasoning"?[{type:"reasoning",text:o.text},...t]:[{type:"text",text:o.text},...t]}}class A{constructor(){r(this,"statusChangeCallbacks",[]);r(this,"messageCallbacks",[])}addStatusChangeListener(t){this.statusChangeCallbacks.push(t)}addPacketListener(t){this.messageCallbacks.push(t)}async syncSession(t){this.session=t}async notifyPacket(t){this.messageCallbacks.forEach(e=>e(t))}async notifyPackets(t){t.forEach(e=>{this.messageCallbacks.forEach(s=>s(e))})}async setSession(t){this.session=t}async setStatus(t){const e=this.status!==t;this.status=t,e&&this.statusChangeCallbacks.forEach(s=>s(t))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(t){}}class j extends A{constructor(e){super();r(this,"status");r(this,"autostart");r(this,"session");r(this,"config");r(this,"notify",!0);r(this,"context",{});r(this,"tools",[]);this.config=e,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 100}async connect(e){return this.setStatus("connected"),e}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(e){this.session=e}async sendPacket(e){var d,f,w,R;const{apiUrl:s,apiKey:n,agentId:a}=this.config,i=this.session??"new";if(e.type==="command"&&((d=e==null?void 0:e.payload)==null?void 0:d.command)=="set_initial_context"){this.context=(f=e==null?void 0:e.payload)==null?void 0:f.arguments;return}else if(e.type==="command"&&((w=e==null?void 0:e.payload)==null?void 0:w.command)=="set_local_tools"){this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const l=e.payload;try{const T=await(await fetch(`${s}/sessions/${i}/messages`,{body:JSON.stringify({agentId:a,userMessage:l,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":n}})).json();this.notifyPackets(T.response.messages.map(U=>({type:"message",payload:U})))}catch(M){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(R=this.config.logger)==null||R.error("Error sending packet:",M)}}}class O extends A{constructor(e){super();r(this,"status");r(this,"autostart");r(this,"session");r(this,"config");r(this,"webSocket");this.config=e,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(e){var s;(s=this.config.logger)==null||s.debug("Syncing session with WebSocket protocol:",e),this.session=e,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(e))}connect(e){var l;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const s=e||this.session||"new";(l=this.config.logger)==null||l.debug("Connecting to WebSocket with sessionId:",s);const n=encodeURIComponent(this.config.apiKey),a=this.config.agentId,i=`${this.config.webSocketUrl}?sessionCode=${s}&agentId=${a}&apiKey=${n}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(i),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",d=>{const f=JSON.parse(d.data);this.notifyPacket(f)}),this.webSocket.addEventListener("close",d=>{var f;this.setStatus("disconnected"),this.webSocket=null,d.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(f=this.config.logger)==null||f.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var d;this.setStatus("disconnected"),this.webSocket=null,(d=this.config.logger)==null||d.error("WebSocket connection error")}),Promise.resolve(s)}disconnect(){var e;return(e=this.config.logger)==null||e.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(e){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(e)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class Y{constructor(t){r(this,"config");r(this,"pc",null);r(this,"ws",null);r(this,"localStream",null);r(this,"remoteStream",new MediaStream);r(this,"audioCtx",null);r(this,"localAnalyser",null);r(this,"remoteAnalyser",null);r(this,"analyzerFrame",null);r(this,"dataChannel",null);r(this,"isConnected",!1);r(this,"visualizerCallbacks",[]);r(this,"messageCallbacks",[]);r(this,"errorCallbacks",[]);r(this,"queuedMessages",[]);this.config=t}async connect(t){var s;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(n){(s=this.config.logger)==null||s.error("Error accessing microphone:",n);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(n=>{this.pc.addTrack(n,this.localStream)}),this.pc.ontrack=n=>{n.streams[0].getTracks().forEach(i=>{this.remoteStream.addTrack(i)}),this.audioCtx||this._startAnalyzers();const a=new Audio;a.srcObject=this.remoteStream,a.play().catch(i=>{var l;(l=this.config.logger)==null||l.error("Error playing remote audio:",i)})},this.pc.onicecandidate=n=>{var a;n.candidate&&((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:n.candidate}}))},this.pc.ondatachannel=n=>{const a=n.channel;a.onmessage=i=>{this.messageCallbacks.forEach(l=>{l(i)})},a.onopen=()=>{var i;for(;this.queuedMessages.length>0;){const l=this.queuedMessages.shift();l&&(a.send(JSON.stringify(l)),(i=this.config.logger)==null||i.info("Sent queued message:",l))}}};const e=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${e}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var l,d;const n=await this.pc.createOffer();await this.pc.setLocalDescription(n);const a={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:t};(l=this.config.logger)==null||l.debug("Opening connection to WebRTC server: ",a);const i={type:"OFFER",src:((d=crypto.randomUUID)==null?void 0:d.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:n.sdp,type:n.type},connectionId:(Date.now()%1e6).toString(),metadata:a}};this.ws.send(JSON.stringify(i))},this.ws.onmessage=async n=>{var i;const a=JSON.parse(n.data);if(a.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(a.payload.sdp));else if(a.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(a.payload.candidate))}catch(l){(i=this.config.logger)==null||i.error("Error adding ICE candidate:",l)}},this.ws.onclose=n=>{n.code!==1e3&&this.errorCallbacks.forEach(a=>{a("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var t;this.isConnected&&(this.isConnected=!1,((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(e=>e.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(t){this.visualizerCallbacks.push(t)}addMessageCallback(t){this.messageCallbacks.push(t)}addErrorCallback(t){this.errorCallbacks.push(t)}createDataChannel(t="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(t),this.dataChannel.onopen=()=>{var e,s;for((e=this.config.logger)==null||e.info("Data channel opened");this.queuedMessages.length>0;){const n=this.queuedMessages.shift();n&&(this.dataChannel.send(JSON.stringify(n)),(s=this.config.logger)==null||s.info("Sent queued message:",n))}},this.dataChannel.onmessage=e=>{this.messageCallbacks.forEach(s=>{s(e)})})}sendPacket(t){var e;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(t);return}this.dataChannel.send(JSON.stringify(t)),(e=this.config.logger)==null||e.info("Sent message:",t)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const t=this.audioCtx.createMediaStreamSource(this.localStream),e=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,t.connect(this.localAnalyser),e.connect(this.remoteAnalyser);const s=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const n=new Uint8Array(this.localAnalyser.frequencyBinCount),a=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(n),this.remoteAnalyser.getByteFrequencyData(a);const i=n.reduce((d,f)=>d+f,0)/n.length,l=a.reduce((d,f)=>d+f,0)/a.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(d=>{d({localAmplitude:i,remoteAmplitude:l})}),this.analyzerFrame=requestAnimationFrame(s)};this.analyzerFrame=requestAnimationFrame(s)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class W extends A{constructor(e){super();r(this,"status");r(this,"session");r(this,"autostart");r(this,"config");r(this,"webRTCClient");this.config=e,this.status="disconnected",this.session=null,this.autostart=(e==null?void 0:e.autostart)??!1,this.webRTCClient=new Y(e),this.webRTCClient.addMessageCallback(s=>{const n=JSON.parse(s.data);this.notifyPacket(n)}),this.webRTCClient.addErrorCallback(s=>{var n;(n=this.config.logger)==null||n.error("WebRTC error:",s),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:s}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(e){super.syncSession(e),this.status==="connected"&&(await this.disconnect(),await this.connect(e))}async connect(e){var s;return this.status==="connected"?Promise.resolve(this.session):(this.session=e||this.session||"new",this.setStatus("connecting"),(s=this.config.logger)==null||s.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 e,s,n;if(this.status==="disconnected")return(e=this.config.logger)==null||e.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(n=(s=this.config)==null?void 0:s.logger)==null||n.debug("Disconnected from WebRTC")}sendPacket(e){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(e),Promise.resolve())}}class G{constructor(t){r(this,"config");this.config=t}async complete(t,e){var s;await this.persist(t,{...e,success:!0}),(s=this.config.logger)==null||s.debug("Transaction completed:",t)}async fail(t,e){var s;await this.persist(t,{...e,success:!1}),(s=this.config.logger)==null||s.debug("Transaction failed:",{...t,...e})}async persist(t,e){await fetch(`${this.config.apiUrl}/transactions/${t.id}`,{body:JSON.stringify(e),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class H{constructor(t,e){r(this,"transaction");r(this,"manager");this.transaction=t,this.manager=e}getFunctionCall(){return this.transaction.functionCall}async invoke(t){var i;const e=this.transaction.functionCall;if(!e){await this.fail("No function call found");return}const s=e.name,n=e.args,a=t[s];if(!a){await this.fail(`Tool ${s} not found`);return}try{const d=(((i=a.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:i[1].split(",").map(w=>w.trim()).filter(Boolean))||[]).map(w=>n[w]),f=await a.apply(null,d);await this.complete(f)}catch(l){await this.fail(`Error executing tool ${s}: ${l}`)}}async complete(t){await this.manager.complete(this.transaction,{success:!0,output:t,error:null})}async fail(t){await this.manager.fail(this.transaction,{success:!1,output:null,error:t})}}class D extends A{constructor(e){super();r(this,"status");r(this,"autostart");r(this,"session");r(this,"config");r(this,"notify",!0);r(this,"_tools");if(this.config=e,this.status="disconnected",this.autostart=!0,Array.isArray(e.tools)){this._tools={};for(const s of e.tools)s.schema&&s.implementation&&(this._tools[s.schema.name]=s.implementation)}else this._tools=e.tools}getName(){return"transaction"}getPriority(){return 0}async connect(e){return this.setStatus("connected"),e}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(e){this.session=e}async sendPacket(e){}onTransaction(e){console.log("transaction received:",e);const s=new G(this.config),n=new H(e,s);this.config.onTransaction?this.config.onTransaction(n):n.invoke(this._tools)}getTools(){return this._tools}}const v=h.createContext(void 0);function Q(o){return new Promise((t,e)=>{const s=new FileReader;s.readAsDataURL(o),s.onload=()=>{const a=s.result.split(";base64,")[1];t(a)},s.onerror=n=>{e(n)}})}function X({dev:o=!1,baseUrl:t,protocols:e,logger:s,children:n,session:a="new",...i}){const[l,d]=h.useState(!1),[f,w]=h.useState([]),[R,M]=h.useState(a),[T,U]=h.useState(new Map),q=h.useRef(!1),k=h.useMemo(()=>{if(Array.isArray(e))return e;if(typeof e=="object"&&e!==null){const u=o?"localhost:8000":t||"persona.applica.guru/api",y=o?"http":"https",p=o?"ws":"wss";let b=Object.keys(e).map(g=>{switch(g){case"rest":const C=e[g];return C===!0?new j({apiUrl:`${y}://${u}`,apiKey:i.apiKey,agentId:i.agentId,logger:s}):typeof C=="object"&&C!==null?new j(C):null;case"webrtc":const m=e[g];return m===!0?new W({webrtcUrl:`${p}://${u}/webrtc`,apiKey:i.apiKey,agentId:i.agentId,logger:s}):typeof m=="object"&&m!==null?new W(m):null;case"websocket":const x=e[g];return x===!0?new O({webSocketUrl:`${p}://${u}/websocket`,apiKey:i.apiKey,agentId:i.agentId,logger:s}):typeof x=="object"&&x!==null?new O(x):null;default:throw new Error(`Unknown protocol: ${g}`)}}).filter(g=>g!==null);return i.tools&&b.push(new D({apiUrl:`${y}://${u}`,apiKey:i.apiKey,agentId:i.agentId,tools:i.tools,logger:s})),b}throw new Error("Invalid protocols configuration")},[]);h.useEffect(()=>{q.current||(q.current=!0,s==null||s.debug("Initializing protocols: ",k.map(u=>u.getName())),k.forEach(u=>{u.setSession(R),u.clearListeners(),u.addStatusChangeListener(y=>{s==null||s.debug(`${u.getName()} has notified new status: ${y}`),T.set(u.getName(),y),y==="connected"&&(i.context&&u.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:i.context}}),i.tools&&Array.isArray(i.tools)&&u.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:i.tools.map(p=>p.schema)}}})),U(new Map(T))}),u.addPacketListener(y=>{if(y.type==="message"){const p=y.payload;w(b=>z([...b,{...p,protocol:u.getName()}]))}else if(y.type==="reasoning"){const p=y.payload;let b=p.thought;p.imageUrl&&(b+=`
|
|
9
|
+
*/var Ki;function Wo(){if(Ki)return Vt;Ki=1;var y=Symbol.for("react.transitional.element"),p=Symbol.for("react.fragment");function i(w,m,C){var A=null;if(C!==void 0&&(A=""+C),m.key!==void 0&&(A=""+m.key),"key"in m){C={};for(var G in m)G!=="key"&&(C[G]=m[G])}else C=m;return m=C.ref,{$$typeof:y,type:w,key:A,ref:m!==void 0?m:null,props:C}}return Vt.Fragment=p,Vt.jsx=i,Vt.jsxs=i,Vt}Hi.exports=Wo();var yr=Hi.exports;function Mo(y){return y.filter(p=>{var i;return p.finishReason==="stop"?p.text!==null&&((i=p.text)==null?void 0:i.trim())!=="":!0})}function Ji(y){const p=[];let i=null;for(const m of y)m.type!=="transaction"&&(m.type==="reasoning"?(i!=null&&(p.push(i),i=null),p.push(m)):m.functionCalls?(i&&p.push(i),p.push(m),i=null):m.functionResponse?p[p.length-1]={...p[p.length-1],functionResponse:m.functionResponse}:i&&m.protocol===i.protocol&&(i.role===m.role||m.finishReason==="stop")?(i.text+=m.text,i.files=[...i.files??[],...m.files??[]]):(i&&p.push(i),i={...m}));return i&&p.push(i),Mo(p)}function Fo(y){var i,w;const p=((i=y.files)==null?void 0:i.map(m=>({type:"file",data:m.url,mimeType:m.contentType})))??[];return y.role==="function"?{id:y.id,role:"assistant",status:(y==null?void 0:y.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((w=y.functionCalls)==null?void 0:w.map(m=>{var C;return{type:"tool-call",toolName:m.name,toolCallId:m.id,args:m.args,result:(C=y.functionResponse)==null?void 0:C.result}}))??[]}:{id:y.id,role:y.role,content:y.type==="reasoning"?[{type:"reasoning",text:y.text},...p]:[{type:"text",text:y.text},...p]}}class jt{constructor(){E(this,"statusChangeCallbacks",[]);E(this,"messageCallbacks",[])}addStatusChangeListener(p){this.statusChangeCallbacks.push(p)}addPacketListener(p){this.messageCallbacks.push(p)}async syncSession(p){this.session=p}async notifyPacket(p){this.messageCallbacks.forEach(i=>i(p))}async notifyPackets(p){p.forEach(i=>{this.messageCallbacks.forEach(w=>w(i))})}async setSession(p){this.session=p}async setStatus(p){const i=this.status!==p;this.status=p,i&&this.statusChangeCallbacks.forEach(w=>w(p))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(p){}}class xr extends jt{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"notify",!0);E(this,"context",{});E(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,fn,vn,hn,Bn;const{apiUrl:w,apiKey:m,agentId:C}=this.config,A=this.session??"new";if(i.type==="command"&&((B=i==null?void 0:i.payload)==null?void 0:B.command)=="set_initial_context"){this.context=(fn=i==null?void 0:i.payload)==null?void 0:fn.arguments;return}else if(i.type==="command"&&((vn=i==null?void 0:i.payload)==null?void 0:vn.command)=="set_local_tools"){const ln=(hn=i==null?void 0:i.payload)==null?void 0:hn.arguments.tools;(ln==null?void 0:ln.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const G=i.payload;try{const Zn=await(await fetch(`${w}/sessions/${A}/messages`,{body:JSON.stringify({agentId:C,userMessage:G,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":m}})).json();this.notifyPackets(Zn.response.messages.map(tt=>({type:"message",payload:tt})))}catch(ln){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(Bn=this.config.logger)==null||Bn.error("Error sending packet:",ln)}}}class Sr extends jt{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(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 w;(w=this.config.logger)==null||w.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var G;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const w=i||this.session||"new";(G=this.config.logger)==null||G.debug("Connecting to WebSocket with sessionId:",w);const m=encodeURIComponent(this.config.apiKey),C=this.config.agentId,A=`${this.config.webSocketUrl}?sessionCode=${w}&agentId=${C}&apiKey=${m}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(A),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",B=>{const fn=JSON.parse(B.data);this.notifyPacket(fn)}),this.webSocket.addEventListener("close",B=>{var fn;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."}}),(fn=this.config.logger)==null||fn.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(w)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),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 Uo{constructor(p){E(this,"config");E(this,"pc",null);E(this,"ws",null);E(this,"localStream",null);E(this,"remoteStream",new MediaStream);E(this,"audioCtx",null);E(this,"localAnalyser",null);E(this,"remoteAnalyser",null);E(this,"analyzerFrame",null);E(this,"dataChannel",null);E(this,"isConnected",!1);E(this,"visualizerCallbacks",[]);E(this,"messageCallbacks",[]);E(this,"errorCallbacks",[]);E(this,"queuedMessages",[]);this.config=p}async connect(p){var w;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(m){(w=this.config.logger)==null||w.error("Error accessing microphone:",m);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(m=>{this.pc.addTrack(m,this.localStream)}),this.pc.ontrack=m=>{m.streams[0].getTracks().forEach(A=>{this.remoteStream.addTrack(A)}),this.audioCtx||this._startAnalyzers();const C=new Audio;C.srcObject=this.remoteStream,C.play().catch(A=>{var G;(G=this.config.logger)==null||G.error("Error playing remote audio:",A)})},this.pc.onicecandidate=m=>{var C;m.candidate&&((C=this.ws)==null?void 0:C.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:m.candidate}}))},this.pc.ondatachannel=m=>{const C=m.channel;C.onmessage=A=>{this.messageCallbacks.forEach(G=>{G(A)})},C.onopen=()=>{var A;for(;this.queuedMessages.length>0;){const G=this.queuedMessages.shift();G&&(C.send(JSON.stringify(G)),(A=this.config.logger)==null||A.info("Sent queued message:",G))}}};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 G,B;const m=await this.pc.createOffer();await this.pc.setLocalDescription(m);const C={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:p};(G=this.config.logger)==null||G.debug("Opening connection to WebRTC server: ",C);const A={type:"OFFER",src:((B=crypto.randomUUID)==null?void 0:B.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:m.sdp,type:m.type},connectionId:(Date.now()%1e6).toString(),metadata:C}};this.ws.send(JSON.stringify(A))},this.ws.onmessage=async m=>{var A;const C=JSON.parse(m.data);if(C.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(C.payload.sdp));else if(C.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(C.payload.candidate))}catch(G){(A=this.config.logger)==null||A.error("Error adding ICE candidate:",G)}},this.ws.onclose=m=>{m.code!==1e3&&this.errorCallbacks.forEach(C=>{C("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var p;this.isConnected&&(this.isConnected=!1,((p=this.ws)==null?void 0:p.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(p){this.visualizerCallbacks.push(p)}addMessageCallback(p){this.messageCallbacks.push(p)}addErrorCallback(p){this.errorCallbacks.push(p)}createDataChannel(p="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(p),this.dataChannel.onopen=()=>{var i,w;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const m=this.queuedMessages.shift();m&&(this.dataChannel.send(JSON.stringify(m)),(w=this.config.logger)==null||w.info("Sent queued message:",m))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(w=>{w(i)})})}sendPacket(p){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(p);return}this.dataChannel.send(JSON.stringify(p)),(i=this.config.logger)==null||i.info("Sent message:",p)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const p=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,p.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const w=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const m=new Uint8Array(this.localAnalyser.frequencyBinCount),C=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(m),this.remoteAnalyser.getByteFrequencyData(C);const A=m.reduce((B,fn)=>B+fn,0)/m.length,G=C.reduce((B,fn)=>B+fn,0)/C.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(B=>{B({localAmplitude:A,remoteAmplitude:G})}),this.analyzerFrame=requestAnimationFrame(w)};this.analyzerFrame=requestAnimationFrame(w)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class Ar extends jt{constructor(i){super();E(this,"status");E(this,"session");E(this,"autostart");E(this,"config");E(this,"webRTCClient");this.config=i,this.status="disconnected",this.session=null,this.autostart=(i==null?void 0:i.autostart)??!1,this.webRTCClient=new Uo(i),this.webRTCClient.addMessageCallback(w=>{const m=JSON.parse(w.data);this.notifyPacket(m)}),this.webRTCClient.addErrorCallback(w=>{var m;(m=this.config.logger)==null||m.error("WebRTC error:",w),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:w}})})}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 w;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(w=this.config.logger)==null||w.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,w,m;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(m=(w=this.config)==null?void 0:w.logger)==null||m.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var Ae={exports:{}};/**
|
|
10
|
+
* @license
|
|
11
|
+
* Lodash <https://lodash.com/>
|
|
12
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
13
|
+
* Released under MIT license <https://lodash.com/license>
|
|
14
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
15
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
16
|
+
*/Ae.exports,function(y,p){(function(){var i,w="4.17.21",m=200,C="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",A="Expected a function",G="Invalid `variable` option passed into `_.template`",B="__lodash_hash_undefined__",fn=500,vn="__lodash_placeholder__",hn=1,Bn=2,ln=4,Zn=1,tt=2,rn=1,ht=2,be=4,Gn=8,Ct=16,$n=32,un=64,$=128,nn=256,V=512,sn=30,kn="...",Z=800,gt=16,ji=1,jo=2,na=3,Re=1/0,Mt=9007199254740991,ta=17976931348623157e292,Te=NaN,Xn=4294967295,ea=Xn-1,ra=Xn>>>1,ia=[["ary",$],["bind",rn],["bindKey",ht],["curry",Gn],["curryRight",Ct],["flip",V],["partial",$n],["partialRight",un],["rearg",nn]],Ft="[object Arguments]",Pe="[object Array]",ua="[object AsyncFunction]",te="[object Boolean]",ee="[object Date]",sa="[object DOMException]",Ee="[object Error]",Ie="[object Function]",nu="[object GeneratorFunction]",qn="[object Map]",re="[object Number]",oa="[object Null]",et="[object Object]",tu="[object Promise]",aa="[object Proxy]",ie="[object RegExp]",zn="[object Set]",ue="[object String]",Le="[object Symbol]",fa="[object Undefined]",se="[object WeakMap]",la="[object WeakSet]",oe="[object ArrayBuffer]",Ut="[object DataView]",Cr="[object Float32Array]",br="[object Float64Array]",Rr="[object Int8Array]",Tr="[object Int16Array]",Pr="[object Int32Array]",Er="[object Uint8Array]",Ir="[object Uint8ClampedArray]",Lr="[object Uint16Array]",Or="[object Uint32Array]",ca=/\b__p \+= '';/g,ha=/\b(__p \+=) '' \+/g,ga=/(__e\(.*?\)|\b__t\)) \+\n'';/g,eu=/&(?:amp|lt|gt|quot|#39);/g,ru=/[&<>"']/g,pa=RegExp(eu.source),da=RegExp(ru.source),_a=/<%-([\s\S]+?)%>/g,va=/<%([\s\S]+?)%>/g,iu=/<%=([\s\S]+?)%>/g,wa=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ma=/^\w*$/,ya=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Wr=/[\\^$.*+?()[\]{}|]/g,xa=RegExp(Wr.source),Mr=/^\s+/,Sa=/\s/,Aa=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ca=/\{\n\/\* \[wrapped with (.+)\] \*/,ba=/,? & /,Ra=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ta=/[()=,{}\[\]\/\s]/,Pa=/\\(\\)?/g,Ea=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,uu=/\w*$/,Ia=/^[-+]0x[0-9a-f]+$/i,La=/^0b[01]+$/i,Oa=/^\[object .+?Constructor\]$/,Wa=/^0o[0-7]+$/i,Ma=/^(?:0|[1-9]\d*)$/,Fa=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Oe=/($^)/,Ua=/['\n\r\u2028\u2029\\]/g,We="\\ud800-\\udfff",Da="\\u0300-\\u036f",Na="\\ufe20-\\ufe2f",Ba="\\u20d0-\\u20ff",su=Da+Na+Ba,ou="\\u2700-\\u27bf",au="a-z\\xdf-\\xf6\\xf8-\\xff",Ga="\\xac\\xb1\\xd7\\xf7",$a="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ka="\\u2000-\\u206f",qa=" \\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",fu="A-Z\\xc0-\\xd6\\xd8-\\xde",lu="\\ufe0e\\ufe0f",cu=Ga+$a+ka+qa,Fr="['’]",za="["+We+"]",hu="["+cu+"]",Me="["+su+"]",gu="\\d+",Ha="["+ou+"]",pu="["+au+"]",du="[^"+We+cu+gu+ou+au+fu+"]",Ur="\\ud83c[\\udffb-\\udfff]",Ka="(?:"+Me+"|"+Ur+")",_u="[^"+We+"]",Dr="(?:\\ud83c[\\udde6-\\uddff]){2}",Nr="[\\ud800-\\udbff][\\udc00-\\udfff]",Dt="["+fu+"]",vu="\\u200d",wu="(?:"+pu+"|"+du+")",Ja="(?:"+Dt+"|"+du+")",mu="(?:"+Fr+"(?:d|ll|m|re|s|t|ve))?",yu="(?:"+Fr+"(?:D|LL|M|RE|S|T|VE))?",xu=Ka+"?",Su="["+lu+"]?",Ya="(?:"+vu+"(?:"+[_u,Dr,Nr].join("|")+")"+Su+xu+")*",Za="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Xa="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Au=Su+xu+Ya,Qa="(?:"+[Ha,Dr,Nr].join("|")+")"+Au,Va="(?:"+[_u+Me+"?",Me,Dr,Nr,za].join("|")+")",ja=RegExp(Fr,"g"),nf=RegExp(Me,"g"),Br=RegExp(Ur+"(?="+Ur+")|"+Va+Au,"g"),tf=RegExp([Dt+"?"+pu+"+"+mu+"(?="+[hu,Dt,"$"].join("|")+")",Ja+"+"+yu+"(?="+[hu,Dt+wu,"$"].join("|")+")",Dt+"?"+wu+"+"+mu,Dt+"+"+yu,Xa,Za,gu,Qa].join("|"),"g"),ef=RegExp("["+vu+We+su+lu+"]"),rf=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,uf=["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"],sf=-1,Y={};Y[Cr]=Y[br]=Y[Rr]=Y[Tr]=Y[Pr]=Y[Er]=Y[Ir]=Y[Lr]=Y[Or]=!0,Y[Ft]=Y[Pe]=Y[oe]=Y[te]=Y[Ut]=Y[ee]=Y[Ee]=Y[Ie]=Y[qn]=Y[re]=Y[et]=Y[ie]=Y[zn]=Y[ue]=Y[se]=!1;var J={};J[Ft]=J[Pe]=J[oe]=J[Ut]=J[te]=J[ee]=J[Cr]=J[br]=J[Rr]=J[Tr]=J[Pr]=J[qn]=J[re]=J[et]=J[ie]=J[zn]=J[ue]=J[Le]=J[Er]=J[Ir]=J[Lr]=J[Or]=!0,J[Ee]=J[Ie]=J[se]=!1;var of={À:"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"},af={"&":"&","<":"<",">":">",'"':""","'":"'"},ff={"&":"&","<":"<",">":">",""":'"',"'":"'"},lf={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},cf=parseFloat,hf=parseInt,Cu=typeof Qt=="object"&&Qt&&Qt.Object===Object&&Qt,gf=typeof self=="object"&&self&&self.Object===Object&&self,gn=Cu||gf||Function("return this")(),Gr=p&&!p.nodeType&&p,bt=Gr&&!0&&y&&!y.nodeType&&y,bu=bt&&bt.exports===Gr,$r=bu&&Cu.process,Ln=function(){try{var l=bt&&bt.require&&bt.require("util").types;return l||$r&&$r.binding&&$r.binding("util")}catch{}}(),Ru=Ln&&Ln.isArrayBuffer,Tu=Ln&&Ln.isDate,Pu=Ln&&Ln.isMap,Eu=Ln&&Ln.isRegExp,Iu=Ln&&Ln.isSet,Lu=Ln&&Ln.isTypedArray;function bn(l,g,h){switch(h.length){case 0:return l.call(g);case 1:return l.call(g,h[0]);case 2:return l.call(g,h[0],h[1]);case 3:return l.call(g,h[0],h[1],h[2])}return l.apply(g,h)}function pf(l,g,h,S){for(var I=-1,k=l==null?0:l.length;++I<k;){var on=l[I];g(S,on,h(on),l)}return S}function On(l,g){for(var h=-1,S=l==null?0:l.length;++h<S&&g(l[h],h,l)!==!1;);return l}function df(l,g){for(var h=l==null?0:l.length;h--&&g(l[h],h,l)!==!1;);return l}function Ou(l,g){for(var h=-1,S=l==null?0:l.length;++h<S;)if(!g(l[h],h,l))return!1;return!0}function pt(l,g){for(var h=-1,S=l==null?0:l.length,I=0,k=[];++h<S;){var on=l[h];g(on,h,l)&&(k[I++]=on)}return k}function Fe(l,g){var h=l==null?0:l.length;return!!h&&Nt(l,g,0)>-1}function kr(l,g,h){for(var S=-1,I=l==null?0:l.length;++S<I;)if(h(g,l[S]))return!0;return!1}function X(l,g){for(var h=-1,S=l==null?0:l.length,I=Array(S);++h<S;)I[h]=g(l[h],h,l);return I}function dt(l,g){for(var h=-1,S=g.length,I=l.length;++h<S;)l[I+h]=g[h];return l}function qr(l,g,h,S){var I=-1,k=l==null?0:l.length;for(S&&k&&(h=l[++I]);++I<k;)h=g(h,l[I],I,l);return h}function _f(l,g,h,S){var I=l==null?0:l.length;for(S&&I&&(h=l[--I]);I--;)h=g(h,l[I],I,l);return h}function zr(l,g){for(var h=-1,S=l==null?0:l.length;++h<S;)if(g(l[h],h,l))return!0;return!1}var vf=Hr("length");function wf(l){return l.split("")}function mf(l){return l.match(Ra)||[]}function Wu(l,g,h){var S;return h(l,function(I,k,on){if(g(I,k,on))return S=k,!1}),S}function Ue(l,g,h,S){for(var I=l.length,k=h+(S?1:-1);S?k--:++k<I;)if(g(l[k],k,l))return k;return-1}function Nt(l,g,h){return g===g?Lf(l,g,h):Ue(l,Mu,h)}function yf(l,g,h,S){for(var I=h-1,k=l.length;++I<k;)if(S(l[I],g))return I;return-1}function Mu(l){return l!==l}function Fu(l,g){var h=l==null?0:l.length;return h?Jr(l,g)/h:Te}function Hr(l){return function(g){return g==null?i:g[l]}}function Kr(l){return function(g){return l==null?i:l[g]}}function Uu(l,g,h,S,I){return I(l,function(k,on,K){h=S?(S=!1,k):g(h,k,on,K)}),h}function xf(l,g){var h=l.length;for(l.sort(g);h--;)l[h]=l[h].value;return l}function Jr(l,g){for(var h,S=-1,I=l.length;++S<I;){var k=g(l[S]);k!==i&&(h=h===i?k:h+k)}return h}function Yr(l,g){for(var h=-1,S=Array(l);++h<l;)S[h]=g(h);return S}function Sf(l,g){return X(g,function(h){return[h,l[h]]})}function Du(l){return l&&l.slice(0,$u(l)+1).replace(Mr,"")}function Rn(l){return function(g){return l(g)}}function Zr(l,g){return X(g,function(h){return l[h]})}function ae(l,g){return l.has(g)}function Nu(l,g){for(var h=-1,S=l.length;++h<S&&Nt(g,l[h],0)>-1;);return h}function Bu(l,g){for(var h=l.length;h--&&Nt(g,l[h],0)>-1;);return h}function Af(l,g){for(var h=l.length,S=0;h--;)l[h]===g&&++S;return S}var Cf=Kr(of),bf=Kr(af);function Rf(l){return"\\"+lf[l]}function Tf(l,g){return l==null?i:l[g]}function Bt(l){return ef.test(l)}function Pf(l){return rf.test(l)}function Ef(l){for(var g,h=[];!(g=l.next()).done;)h.push(g.value);return h}function Xr(l){var g=-1,h=Array(l.size);return l.forEach(function(S,I){h[++g]=[I,S]}),h}function Gu(l,g){return function(h){return l(g(h))}}function _t(l,g){for(var h=-1,S=l.length,I=0,k=[];++h<S;){var on=l[h];(on===g||on===vn)&&(l[h]=vn,k[I++]=h)}return k}function De(l){var g=-1,h=Array(l.size);return l.forEach(function(S){h[++g]=S}),h}function If(l){var g=-1,h=Array(l.size);return l.forEach(function(S){h[++g]=[S,S]}),h}function Lf(l,g,h){for(var S=h-1,I=l.length;++S<I;)if(l[S]===g)return S;return-1}function Of(l,g,h){for(var S=h+1;S--;)if(l[S]===g)return S;return S}function Gt(l){return Bt(l)?Mf(l):vf(l)}function Hn(l){return Bt(l)?Ff(l):wf(l)}function $u(l){for(var g=l.length;g--&&Sa.test(l.charAt(g)););return g}var Wf=Kr(ff);function Mf(l){for(var g=Br.lastIndex=0;Br.test(l);)++g;return g}function Ff(l){return l.match(Br)||[]}function Uf(l){return l.match(tf)||[]}var Df=function l(g){g=g==null?gn:$t.defaults(gn.Object(),g,$t.pick(gn,uf));var h=g.Array,S=g.Date,I=g.Error,k=g.Function,on=g.Math,K=g.Object,Qr=g.RegExp,Nf=g.String,Wn=g.TypeError,Ne=h.prototype,Bf=k.prototype,kt=K.prototype,Be=g["__core-js_shared__"],Ge=Bf.toString,z=kt.hasOwnProperty,Gf=0,ku=function(){var n=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),$e=kt.toString,$f=Ge.call(K),kf=gn._,qf=Qr("^"+Ge.call(z).replace(Wr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ke=bu?g.Buffer:i,vt=g.Symbol,qe=g.Uint8Array,qu=ke?ke.allocUnsafe:i,ze=Gu(K.getPrototypeOf,K),zu=K.create,Hu=kt.propertyIsEnumerable,He=Ne.splice,Ku=vt?vt.isConcatSpreadable:i,fe=vt?vt.iterator:i,Rt=vt?vt.toStringTag:i,Ke=function(){try{var n=Lt(K,"defineProperty");return n({},"",{}),n}catch{}}(),zf=g.clearTimeout!==gn.clearTimeout&&g.clearTimeout,Hf=S&&S.now!==gn.Date.now&&S.now,Kf=g.setTimeout!==gn.setTimeout&&g.setTimeout,Je=on.ceil,Ye=on.floor,Vr=K.getOwnPropertySymbols,Jf=ke?ke.isBuffer:i,Ju=g.isFinite,Yf=Ne.join,Zf=Gu(K.keys,K),an=on.max,dn=on.min,Xf=S.now,Qf=g.parseInt,Yu=on.random,Vf=Ne.reverse,jr=Lt(g,"DataView"),le=Lt(g,"Map"),ni=Lt(g,"Promise"),qt=Lt(g,"Set"),ce=Lt(g,"WeakMap"),he=Lt(K,"create"),Ze=ce&&new ce,zt={},jf=Ot(jr),nl=Ot(le),tl=Ot(ni),el=Ot(qt),rl=Ot(ce),Xe=vt?vt.prototype:i,ge=Xe?Xe.valueOf:i,Zu=Xe?Xe.toString:i;function s(n){if(j(n)&&!L(n)&&!(n instanceof U)){if(n instanceof Mn)return n;if(z.call(n,"__wrapped__"))return Xs(n)}return new Mn(n)}var Ht=function(){function n(){}return function(t){if(!Q(t))return{};if(zu)return zu(t);n.prototype=t;var e=new n;return n.prototype=i,e}}();function Qe(){}function Mn(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}s.templateSettings={escape:_a,evaluate:va,interpolate:iu,variable:"",imports:{_:s}},s.prototype=Qe.prototype,s.prototype.constructor=s,Mn.prototype=Ht(Qe.prototype),Mn.prototype.constructor=Mn;function U(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Xn,this.__views__=[]}function il(){var n=new U(this.__wrapped__);return n.__actions__=xn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=xn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=xn(this.__views__),n}function ul(){if(this.__filtered__){var n=new U(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function sl(){var n=this.__wrapped__.value(),t=this.__dir__,e=L(n),r=t<0,u=e?n.length:0,o=wc(0,u,this.__views__),a=o.start,f=o.end,c=f-a,d=r?f:a-1,_=this.__iteratees__,v=_.length,x=0,b=dn(c,this.__takeCount__);if(!e||!r&&u==c&&b==c)return ms(n,this.__actions__);var T=[];n:for(;c--&&x<b;){d+=t;for(var W=-1,P=n[d];++W<v;){var F=_[W],D=F.iteratee,En=F.type,yn=D(P);if(En==jo)P=yn;else if(!yn){if(En==ji)continue n;break n}}T[x++]=P}return T}U.prototype=Ht(Qe.prototype),U.prototype.constructor=U;function Tt(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function ol(){this.__data__=he?he(null):{},this.size=0}function al(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}function fl(n){var t=this.__data__;if(he){var e=t[n];return e===B?i:e}return z.call(t,n)?t[n]:i}function ll(n){var t=this.__data__;return he?t[n]!==i:z.call(t,n)}function cl(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=he&&t===i?B:t,this}Tt.prototype.clear=ol,Tt.prototype.delete=al,Tt.prototype.get=fl,Tt.prototype.has=ll,Tt.prototype.set=cl;function rt(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function hl(){this.__data__=[],this.size=0}function gl(n){var t=this.__data__,e=Ve(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():He.call(t,e,1),--this.size,!0}function pl(n){var t=this.__data__,e=Ve(t,n);return e<0?i:t[e][1]}function dl(n){return Ve(this.__data__,n)>-1}function _l(n,t){var e=this.__data__,r=Ve(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}rt.prototype.clear=hl,rt.prototype.delete=gl,rt.prototype.get=pl,rt.prototype.has=dl,rt.prototype.set=_l;function it(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function vl(){this.size=0,this.__data__={hash:new Tt,map:new(le||rt),string:new Tt}}function wl(n){var t=lr(this,n).delete(n);return this.size-=t?1:0,t}function ml(n){return lr(this,n).get(n)}function yl(n){return lr(this,n).has(n)}function xl(n,t){var e=lr(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}it.prototype.clear=vl,it.prototype.delete=wl,it.prototype.get=ml,it.prototype.has=yl,it.prototype.set=xl;function Pt(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new it;++t<e;)this.add(n[t])}function Sl(n){return this.__data__.set(n,B),this}function Al(n){return this.__data__.has(n)}Pt.prototype.add=Pt.prototype.push=Sl,Pt.prototype.has=Al;function Kn(n){var t=this.__data__=new rt(n);this.size=t.size}function Cl(){this.__data__=new rt,this.size=0}function bl(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}function Rl(n){return this.__data__.get(n)}function Tl(n){return this.__data__.has(n)}function Pl(n,t){var e=this.__data__;if(e instanceof rt){var r=e.__data__;if(!le||r.length<m-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new it(r)}return e.set(n,t),this.size=e.size,this}Kn.prototype.clear=Cl,Kn.prototype.delete=bl,Kn.prototype.get=Rl,Kn.prototype.has=Tl,Kn.prototype.set=Pl;function Xu(n,t){var e=L(n),r=!e&&Wt(n),u=!e&&!r&&St(n),o=!e&&!r&&!u&&Zt(n),a=e||r||u||o,f=a?Yr(n.length,Nf):[],c=f.length;for(var d in n)(t||z.call(n,d))&&!(a&&(d=="length"||u&&(d=="offset"||d=="parent")||o&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||at(d,c)))&&f.push(d);return f}function Qu(n){var t=n.length;return t?n[ci(0,t-1)]:i}function El(n,t){return cr(xn(n),Et(t,0,n.length))}function Il(n){return cr(xn(n))}function ti(n,t,e){(e!==i&&!Jn(n[t],e)||e===i&&!(t in n))&&ut(n,t,e)}function pe(n,t,e){var r=n[t];(!(z.call(n,t)&&Jn(r,e))||e===i&&!(t in n))&&ut(n,t,e)}function Ve(n,t){for(var e=n.length;e--;)if(Jn(n[e][0],t))return e;return-1}function Ll(n,t,e,r){return wt(n,function(u,o,a){t(r,u,e(u),a)}),r}function Vu(n,t){return n&&Vn(t,cn(t),n)}function Ol(n,t){return n&&Vn(t,An(t),n)}function ut(n,t,e){t=="__proto__"&&Ke?Ke(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function ei(n,t){for(var e=-1,r=t.length,u=h(r),o=n==null;++e<r;)u[e]=o?i:Ui(n,t[e]);return u}function Et(n,t,e){return n===n&&(e!==i&&(n=n<=e?n:e),t!==i&&(n=n>=t?n:t)),n}function Fn(n,t,e,r,u,o){var a,f=t&hn,c=t&Bn,d=t&ln;if(e&&(a=u?e(n,r,u,o):e(n)),a!==i)return a;if(!Q(n))return n;var _=L(n);if(_){if(a=yc(n),!f)return xn(n,a)}else{var v=_n(n),x=v==Ie||v==nu;if(St(n))return Ss(n,f);if(v==et||v==Ft||x&&!u){if(a=c||x?{}:$s(n),!f)return c?fc(n,Ol(a,n)):ac(n,Vu(a,n))}else{if(!J[v])return u?n:{};a=xc(n,v,f)}}o||(o=new Kn);var b=o.get(n);if(b)return b;o.set(n,a),vo(n)?n.forEach(function(P){a.add(Fn(P,t,e,P,n,o))}):po(n)&&n.forEach(function(P,F){a.set(F,Fn(P,t,e,F,n,o))});var T=d?c?Si:xi:c?An:cn,W=_?i:T(n);return On(W||n,function(P,F){W&&(F=P,P=n[F]),pe(a,F,Fn(P,t,e,F,n,o))}),a}function Wl(n){var t=cn(n);return function(e){return ju(e,n,t)}}function ju(n,t,e){var r=e.length;if(n==null)return!r;for(n=K(n);r--;){var u=e[r],o=t[u],a=n[u];if(a===i&&!(u in n)||!o(a))return!1}return!0}function ns(n,t,e){if(typeof n!="function")throw new Wn(A);return xe(function(){n.apply(i,e)},t)}function de(n,t,e,r){var u=-1,o=Fe,a=!0,f=n.length,c=[],d=t.length;if(!f)return c;e&&(t=X(t,Rn(e))),r?(o=kr,a=!1):t.length>=m&&(o=ae,a=!1,t=new Pt(t));n:for(;++u<f;){var _=n[u],v=e==null?_:e(_);if(_=r||_!==0?_:0,a&&v===v){for(var x=d;x--;)if(t[x]===v)continue n;c.push(_)}else o(t,v,r)||c.push(_)}return c}var wt=Ts(Qn),ts=Ts(ii,!0);function Ml(n,t){var e=!0;return wt(n,function(r,u,o){return e=!!t(r,u,o),e}),e}function je(n,t,e){for(var r=-1,u=n.length;++r<u;){var o=n[r],a=t(o);if(a!=null&&(f===i?a===a&&!Pn(a):e(a,f)))var f=a,c=o}return c}function Fl(n,t,e,r){var u=n.length;for(e=O(e),e<0&&(e=-e>u?0:u+e),r=r===i||r>u?u:O(r),r<0&&(r+=u),r=e>r?0:mo(r);e<r;)n[e++]=t;return n}function es(n,t){var e=[];return wt(n,function(r,u,o){t(r,u,o)&&e.push(r)}),e}function pn(n,t,e,r,u){var o=-1,a=n.length;for(e||(e=Ac),u||(u=[]);++o<a;){var f=n[o];t>0&&e(f)?t>1?pn(f,t-1,e,r,u):dt(u,f):r||(u[u.length]=f)}return u}var ri=Ps(),rs=Ps(!0);function Qn(n,t){return n&&ri(n,t,cn)}function ii(n,t){return n&&rs(n,t,cn)}function nr(n,t){return pt(t,function(e){return ft(n[e])})}function It(n,t){t=yt(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[jn(t[e++])];return e&&e==r?n:i}function is(n,t,e){var r=t(n);return L(n)?r:dt(r,e(n))}function wn(n){return n==null?n===i?fa:oa:Rt&&Rt in K(n)?vc(n):Ic(n)}function ui(n,t){return n>t}function Ul(n,t){return n!=null&&z.call(n,t)}function Dl(n,t){return n!=null&&t in K(n)}function Nl(n,t,e){return n>=dn(t,e)&&n<an(t,e)}function si(n,t,e){for(var r=e?kr:Fe,u=n[0].length,o=n.length,a=o,f=h(o),c=1/0,d=[];a--;){var _=n[a];a&&t&&(_=X(_,Rn(t))),c=dn(_.length,c),f[a]=!e&&(t||u>=120&&_.length>=120)?new Pt(a&&_):i}_=n[0];var v=-1,x=f[0];n:for(;++v<u&&d.length<c;){var b=_[v],T=t?t(b):b;if(b=e||b!==0?b:0,!(x?ae(x,T):r(d,T,e))){for(a=o;--a;){var W=f[a];if(!(W?ae(W,T):r(n[a],T,e)))continue n}x&&x.push(T),d.push(b)}}return d}function Bl(n,t,e,r){return Qn(n,function(u,o,a){t(r,e(u),o,a)}),r}function _e(n,t,e){t=yt(t,n),n=Hs(n,t);var r=n==null?n:n[jn(Dn(t))];return r==null?i:bn(r,n,e)}function us(n){return j(n)&&wn(n)==Ft}function Gl(n){return j(n)&&wn(n)==oe}function $l(n){return j(n)&&wn(n)==ee}function ve(n,t,e,r,u){return n===t?!0:n==null||t==null||!j(n)&&!j(t)?n!==n&&t!==t:kl(n,t,e,r,ve,u)}function kl(n,t,e,r,u,o){var a=L(n),f=L(t),c=a?Pe:_n(n),d=f?Pe:_n(t);c=c==Ft?et:c,d=d==Ft?et:d;var _=c==et,v=d==et,x=c==d;if(x&&St(n)){if(!St(t))return!1;a=!0,_=!1}if(x&&!_)return o||(o=new Kn),a||Zt(n)?Ns(n,t,e,r,u,o):dc(n,t,c,e,r,u,o);if(!(e&Zn)){var b=_&&z.call(n,"__wrapped__"),T=v&&z.call(t,"__wrapped__");if(b||T){var W=b?n.value():n,P=T?t.value():t;return o||(o=new Kn),u(W,P,e,r,o)}}return x?(o||(o=new Kn),_c(n,t,e,r,u,o)):!1}function ql(n){return j(n)&&_n(n)==qn}function oi(n,t,e,r){var u=e.length,o=u,a=!r;if(n==null)return!o;for(n=K(n);u--;){var f=e[u];if(a&&f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++u<o;){f=e[u];var c=f[0],d=n[c],_=f[1];if(a&&f[2]){if(d===i&&!(c in n))return!1}else{var v=new Kn;if(r)var x=r(d,_,c,n,t,v);if(!(x===i?ve(_,d,Zn|tt,r,v):x))return!1}}return!0}function ss(n){if(!Q(n)||bc(n))return!1;var t=ft(n)?qf:Oa;return t.test(Ot(n))}function zl(n){return j(n)&&wn(n)==ie}function Hl(n){return j(n)&&_n(n)==zn}function Kl(n){return j(n)&&vr(n.length)&&!!Y[wn(n)]}function os(n){return typeof n=="function"?n:n==null?Cn:typeof n=="object"?L(n)?ls(n[0],n[1]):fs(n):Io(n)}function ai(n){if(!ye(n))return Zf(n);var t=[];for(var e in K(n))z.call(n,e)&&e!="constructor"&&t.push(e);return t}function Jl(n){if(!Q(n))return Ec(n);var t=ye(n),e=[];for(var r in n)r=="constructor"&&(t||!z.call(n,r))||e.push(r);return e}function fi(n,t){return n<t}function as(n,t){var e=-1,r=Sn(n)?h(n.length):[];return wt(n,function(u,o,a){r[++e]=t(u,o,a)}),r}function fs(n){var t=Ci(n);return t.length==1&&t[0][2]?qs(t[0][0],t[0][1]):function(e){return e===n||oi(e,n,t)}}function ls(n,t){return Ri(n)&&ks(t)?qs(jn(n),t):function(e){var r=Ui(e,n);return r===i&&r===t?Di(e,n):ve(t,r,Zn|tt)}}function tr(n,t,e,r,u){n!==t&&ri(t,function(o,a){if(u||(u=new Kn),Q(o))Yl(n,t,a,e,tr,r,u);else{var f=r?r(Pi(n,a),o,a+"",n,t,u):i;f===i&&(f=o),ti(n,a,f)}},An)}function Yl(n,t,e,r,u,o,a){var f=Pi(n,e),c=Pi(t,e),d=a.get(c);if(d){ti(n,e,d);return}var _=o?o(f,c,e+"",n,t,a):i,v=_===i;if(v){var x=L(c),b=!x&&St(c),T=!x&&!b&&Zt(c);_=c,x||b||T?L(f)?_=f:tn(f)?_=xn(f):b?(v=!1,_=Ss(c,!0)):T?(v=!1,_=As(c,!0)):_=[]:Se(c)||Wt(c)?(_=f,Wt(f)?_=yo(f):(!Q(f)||ft(f))&&(_=$s(c))):v=!1}v&&(a.set(c,_),u(_,c,r,o,a),a.delete(c)),ti(n,e,_)}function cs(n,t){var e=n.length;if(e)return t+=t<0?e:0,at(t,e)?n[t]:i}function hs(n,t,e){t.length?t=X(t,function(o){return L(o)?function(a){return It(a,o.length===1?o[0]:o)}:o}):t=[Cn];var r=-1;t=X(t,Rn(R()));var u=as(n,function(o,a,f){var c=X(t,function(d){return d(o)});return{criteria:c,index:++r,value:o}});return xf(u,function(o,a){return oc(o,a,e)})}function Zl(n,t){return gs(n,t,function(e,r){return Di(n,r)})}function gs(n,t,e){for(var r=-1,u=t.length,o={};++r<u;){var a=t[r],f=It(n,a);e(f,a)&&we(o,yt(a,n),f)}return o}function Xl(n){return function(t){return It(t,n)}}function li(n,t,e,r){var u=r?yf:Nt,o=-1,a=t.length,f=n;for(n===t&&(t=xn(t)),e&&(f=X(n,Rn(e)));++o<a;)for(var c=0,d=t[o],_=e?e(d):d;(c=u(f,_,c,r))>-1;)f!==n&&He.call(f,c,1),He.call(n,c,1);return n}function ps(n,t){for(var e=n?t.length:0,r=e-1;e--;){var u=t[e];if(e==r||u!==o){var o=u;at(u)?He.call(n,u,1):pi(n,u)}}return n}function ci(n,t){return n+Ye(Yu()*(t-n+1))}function Ql(n,t,e,r){for(var u=-1,o=an(Je((t-n)/(e||1)),0),a=h(o);o--;)a[r?o:++u]=n,n+=e;return a}function hi(n,t){var e="";if(!n||t<1||t>Mt)return e;do t%2&&(e+=n),t=Ye(t/2),t&&(n+=n);while(t);return e}function M(n,t){return Ei(zs(n,t,Cn),n+"")}function Vl(n){return Qu(Xt(n))}function jl(n,t){var e=Xt(n);return cr(e,Et(t,0,e.length))}function we(n,t,e,r){if(!Q(n))return n;t=yt(t,n);for(var u=-1,o=t.length,a=o-1,f=n;f!=null&&++u<o;){var c=jn(t[u]),d=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(u!=a){var _=f[c];d=r?r(_,c,f):i,d===i&&(d=Q(_)?_:at(t[u+1])?[]:{})}pe(f,c,d),f=f[c]}return n}var ds=Ze?function(n,t){return Ze.set(n,t),n}:Cn,nc=Ke?function(n,t){return Ke(n,"toString",{configurable:!0,enumerable:!1,value:Bi(t),writable:!0})}:Cn;function tc(n){return cr(Xt(n))}function Un(n,t,e){var r=-1,u=n.length;t<0&&(t=-t>u?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=h(u);++r<u;)o[r]=n[r+t];return o}function ec(n,t){var e;return wt(n,function(r,u,o){return e=t(r,u,o),!e}),!!e}function er(n,t,e){var r=0,u=n==null?r:n.length;if(typeof t=="number"&&t===t&&u<=ra){for(;r<u;){var o=r+u>>>1,a=n[o];a!==null&&!Pn(a)&&(e?a<=t:a<t)?r=o+1:u=o}return u}return gi(n,t,Cn,e)}function gi(n,t,e,r){var u=0,o=n==null?0:n.length;if(o===0)return 0;t=e(t);for(var a=t!==t,f=t===null,c=Pn(t),d=t===i;u<o;){var _=Ye((u+o)/2),v=e(n[_]),x=v!==i,b=v===null,T=v===v,W=Pn(v);if(a)var P=r||T;else d?P=T&&(r||x):f?P=T&&x&&(r||!b):c?P=T&&x&&!b&&(r||!W):b||W?P=!1:P=r?v<=t:v<t;P?u=_+1:o=_}return dn(o,ea)}function _s(n,t){for(var e=-1,r=n.length,u=0,o=[];++e<r;){var a=n[e],f=t?t(a):a;if(!e||!Jn(f,c)){var c=f;o[u++]=a===0?0:a}}return o}function vs(n){return typeof n=="number"?n:Pn(n)?Te:+n}function Tn(n){if(typeof n=="string")return n;if(L(n))return X(n,Tn)+"";if(Pn(n))return Zu?Zu.call(n):"";var t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function mt(n,t,e){var r=-1,u=Fe,o=n.length,a=!0,f=[],c=f;if(e)a=!1,u=kr;else if(o>=m){var d=t?null:gc(n);if(d)return De(d);a=!1,u=ae,c=new Pt}else c=t?[]:f;n:for(;++r<o;){var _=n[r],v=t?t(_):_;if(_=e||_!==0?_:0,a&&v===v){for(var x=c.length;x--;)if(c[x]===v)continue n;t&&c.push(v),f.push(_)}else u(c,v,e)||(c!==f&&c.push(v),f.push(_))}return f}function pi(n,t){return t=yt(t,n),n=Hs(n,t),n==null||delete n[jn(Dn(t))]}function ws(n,t,e,r){return we(n,t,e(It(n,t)),r)}function rr(n,t,e,r){for(var u=n.length,o=r?u:-1;(r?o--:++o<u)&&t(n[o],o,n););return e?Un(n,r?0:o,r?o+1:u):Un(n,r?o+1:0,r?u:o)}function ms(n,t){var e=n;return e instanceof U&&(e=e.value()),qr(t,function(r,u){return u.func.apply(u.thisArg,dt([r],u.args))},e)}function di(n,t,e){var r=n.length;if(r<2)return r?mt(n[0]):[];for(var u=-1,o=h(r);++u<r;)for(var a=n[u],f=-1;++f<r;)f!=u&&(o[u]=de(o[u]||a,n[f],t,e));return mt(pn(o,1),t,e)}function ys(n,t,e){for(var r=-1,u=n.length,o=t.length,a={};++r<u;){var f=r<o?t[r]:i;e(a,n[r],f)}return a}function _i(n){return tn(n)?n:[]}function vi(n){return typeof n=="function"?n:Cn}function yt(n,t){return L(n)?n:Ri(n,t)?[n]:Zs(q(n))}var rc=M;function xt(n,t,e){var r=n.length;return e=e===i?r:e,!t&&e>=r?n:Un(n,t,e)}var xs=zf||function(n){return gn.clearTimeout(n)};function Ss(n,t){if(t)return n.slice();var e=n.length,r=qu?qu(e):new n.constructor(e);return n.copy(r),r}function wi(n){var t=new n.constructor(n.byteLength);return new qe(t).set(new qe(n)),t}function ic(n,t){var e=t?wi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}function uc(n){var t=new n.constructor(n.source,uu.exec(n));return t.lastIndex=n.lastIndex,t}function sc(n){return ge?K(ge.call(n)):{}}function As(n,t){var e=t?wi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}function Cs(n,t){if(n!==t){var e=n!==i,r=n===null,u=n===n,o=Pn(n),a=t!==i,f=t===null,c=t===t,d=Pn(t);if(!f&&!d&&!o&&n>t||o&&a&&c&&!f&&!d||r&&a&&c||!e&&c||!u)return 1;if(!r&&!o&&!d&&n<t||d&&e&&u&&!r&&!o||f&&e&&u||!a&&u||!c)return-1}return 0}function oc(n,t,e){for(var r=-1,u=n.criteria,o=t.criteria,a=u.length,f=e.length;++r<a;){var c=Cs(u[r],o[r]);if(c){if(r>=f)return c;var d=e[r];return c*(d=="desc"?-1:1)}}return n.index-t.index}function bs(n,t,e,r){for(var u=-1,o=n.length,a=e.length,f=-1,c=t.length,d=an(o-a,0),_=h(c+d),v=!r;++f<c;)_[f]=t[f];for(;++u<a;)(v||u<o)&&(_[e[u]]=n[u]);for(;d--;)_[f++]=n[u++];return _}function Rs(n,t,e,r){for(var u=-1,o=n.length,a=-1,f=e.length,c=-1,d=t.length,_=an(o-f,0),v=h(_+d),x=!r;++u<_;)v[u]=n[u];for(var b=u;++c<d;)v[b+c]=t[c];for(;++a<f;)(x||u<o)&&(v[b+e[a]]=n[u++]);return v}function xn(n,t){var e=-1,r=n.length;for(t||(t=h(r));++e<r;)t[e]=n[e];return t}function Vn(n,t,e,r){var u=!e;e||(e={});for(var o=-1,a=t.length;++o<a;){var f=t[o],c=r?r(e[f],n[f],f,e,n):i;c===i&&(c=n[f]),u?ut(e,f,c):pe(e,f,c)}return e}function ac(n,t){return Vn(n,bi(n),t)}function fc(n,t){return Vn(n,Bs(n),t)}function ir(n,t){return function(e,r){var u=L(e)?pf:Ll,o=t?t():{};return u(e,n,R(r,2),o)}}function Kt(n){return M(function(t,e){var r=-1,u=e.length,o=u>1?e[u-1]:i,a=u>2?e[2]:i;for(o=n.length>3&&typeof o=="function"?(u--,o):i,a&&mn(e[0],e[1],a)&&(o=u<3?i:o,u=1),t=K(t);++r<u;){var f=e[r];f&&n(t,f,r,o)}return t})}function Ts(n,t){return function(e,r){if(e==null)return e;if(!Sn(e))return n(e,r);for(var u=e.length,o=t?u:-1,a=K(e);(t?o--:++o<u)&&r(a[o],o,a)!==!1;);return e}}function Ps(n){return function(t,e,r){for(var u=-1,o=K(t),a=r(t),f=a.length;f--;){var c=a[n?f:++u];if(e(o[c],c,o)===!1)break}return t}}function lc(n,t,e){var r=t&rn,u=me(n);function o(){var a=this&&this!==gn&&this instanceof o?u:n;return a.apply(r?e:this,arguments)}return o}function Es(n){return function(t){t=q(t);var e=Bt(t)?Hn(t):i,r=e?e[0]:t.charAt(0),u=e?xt(e,1).join(""):t.slice(1);return r[n]()+u}}function Jt(n){return function(t){return qr(Po(To(t).replace(ja,"")),n,"")}}function me(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var e=Ht(n.prototype),r=n.apply(e,t);return Q(r)?r:e}}function cc(n,t,e){var r=me(n);function u(){for(var o=arguments.length,a=h(o),f=o,c=Yt(u);f--;)a[f]=arguments[f];var d=o<3&&a[0]!==c&&a[o-1]!==c?[]:_t(a,c);if(o-=d.length,o<e)return Ms(n,t,ur,u.placeholder,i,a,d,i,i,e-o);var _=this&&this!==gn&&this instanceof u?r:n;return bn(_,this,a)}return u}function Is(n){return function(t,e,r){var u=K(t);if(!Sn(t)){var o=R(e,3);t=cn(t),e=function(f){return o(u[f],f,u)}}var a=n(t,e,r);return a>-1?u[o?t[a]:a]:i}}function Ls(n){return ot(function(t){var e=t.length,r=e,u=Mn.prototype.thru;for(n&&t.reverse();r--;){var o=t[r];if(typeof o!="function")throw new Wn(A);if(u&&!a&&fr(o)=="wrapper")var a=new Mn([],!0)}for(r=a?r:e;++r<e;){o=t[r];var f=fr(o),c=f=="wrapper"?Ai(o):i;c&&Ti(c[0])&&c[1]==($|Gn|$n|nn)&&!c[4].length&&c[9]==1?a=a[fr(c[0])].apply(a,c[3]):a=o.length==1&&Ti(o)?a[f]():a.thru(o)}return function(){var d=arguments,_=d[0];if(a&&d.length==1&&L(_))return a.plant(_).value();for(var v=0,x=e?t[v].apply(this,d):_;++v<e;)x=t[v].call(this,x);return x}})}function ur(n,t,e,r,u,o,a,f,c,d){var _=t&$,v=t&rn,x=t&ht,b=t&(Gn|Ct),T=t&V,W=x?i:me(n);function P(){for(var F=arguments.length,D=h(F),En=F;En--;)D[En]=arguments[En];if(b)var yn=Yt(P),In=Af(D,yn);if(r&&(D=bs(D,r,u,b)),o&&(D=Rs(D,o,a,b)),F-=In,b&&F<d){var en=_t(D,yn);return Ms(n,t,ur,P.placeholder,e,D,en,f,c,d-F)}var Yn=v?e:this,ct=x?Yn[n]:n;return F=D.length,f?D=Lc(D,f):T&&F>1&&D.reverse(),_&&c<F&&(D.length=c),this&&this!==gn&&this instanceof P&&(ct=W||me(ct)),ct.apply(Yn,D)}return P}function Os(n,t){return function(e,r){return Bl(e,n,t(r),{})}}function sr(n,t){return function(e,r){var u;if(e===i&&r===i)return t;if(e!==i&&(u=e),r!==i){if(u===i)return r;typeof e=="string"||typeof r=="string"?(e=Tn(e),r=Tn(r)):(e=vs(e),r=vs(r)),u=n(e,r)}return u}}function mi(n){return ot(function(t){return t=X(t,Rn(R())),M(function(e){var r=this;return n(t,function(u){return bn(u,r,e)})})})}function or(n,t){t=t===i?" ":Tn(t);var e=t.length;if(e<2)return e?hi(t,n):t;var r=hi(t,Je(n/Gt(t)));return Bt(t)?xt(Hn(r),0,n).join(""):r.slice(0,n)}function hc(n,t,e,r){var u=t&rn,o=me(n);function a(){for(var f=-1,c=arguments.length,d=-1,_=r.length,v=h(_+c),x=this&&this!==gn&&this instanceof a?o:n;++d<_;)v[d]=r[d];for(;c--;)v[d++]=arguments[++f];return bn(x,u?e:this,v)}return a}function Ws(n){return function(t,e,r){return r&&typeof r!="number"&&mn(t,e,r)&&(e=r=i),t=lt(t),e===i?(e=t,t=0):e=lt(e),r=r===i?t<e?1:-1:lt(r),Ql(t,e,r,n)}}function ar(n){return function(t,e){return typeof t=="string"&&typeof e=="string"||(t=Nn(t),e=Nn(e)),n(t,e)}}function Ms(n,t,e,r,u,o,a,f,c,d){var _=t&Gn,v=_?a:i,x=_?i:a,b=_?o:i,T=_?i:o;t|=_?$n:un,t&=~(_?un:$n),t&be||(t&=-4);var W=[n,t,u,b,v,T,x,f,c,d],P=e.apply(i,W);return Ti(n)&&Ks(P,W),P.placeholder=r,Js(P,n,t)}function yi(n){var t=on[n];return function(e,r){if(e=Nn(e),r=r==null?0:dn(O(r),292),r&&Ju(e)){var u=(q(e)+"e").split("e"),o=t(u[0]+"e"+(+u[1]+r));return u=(q(o)+"e").split("e"),+(u[0]+"e"+(+u[1]-r))}return t(e)}}var gc=qt&&1/De(new qt([,-0]))[1]==Re?function(n){return new qt(n)}:ki;function Fs(n){return function(t){var e=_n(t);return e==qn?Xr(t):e==zn?If(t):Sf(t,n(t))}}function st(n,t,e,r,u,o,a,f){var c=t&ht;if(!c&&typeof n!="function")throw new Wn(A);var d=r?r.length:0;if(d||(t&=-97,r=u=i),a=a===i?a:an(O(a),0),f=f===i?f:O(f),d-=u?u.length:0,t&un){var _=r,v=u;r=u=i}var x=c?i:Ai(n),b=[n,t,e,r,u,_,v,o,a,f];if(x&&Pc(b,x),n=b[0],t=b[1],e=b[2],r=b[3],u=b[4],f=b[9]=b[9]===i?c?0:n.length:an(b[9]-d,0),!f&&t&(Gn|Ct)&&(t&=-25),!t||t==rn)var T=lc(n,t,e);else t==Gn||t==Ct?T=cc(n,t,f):(t==$n||t==(rn|$n))&&!u.length?T=hc(n,t,e,r):T=ur.apply(i,b);var W=x?ds:Ks;return Js(W(T,b),n,t)}function Us(n,t,e,r){return n===i||Jn(n,kt[e])&&!z.call(r,e)?t:n}function Ds(n,t,e,r,u,o){return Q(n)&&Q(t)&&(o.set(t,n),tr(n,t,i,Ds,o),o.delete(t)),n}function pc(n){return Se(n)?i:n}function Ns(n,t,e,r,u,o){var a=e&Zn,f=n.length,c=t.length;if(f!=c&&!(a&&c>f))return!1;var d=o.get(n),_=o.get(t);if(d&&_)return d==t&&_==n;var v=-1,x=!0,b=e&tt?new Pt:i;for(o.set(n,t),o.set(t,n);++v<f;){var T=n[v],W=t[v];if(r)var P=a?r(W,T,v,t,n,o):r(T,W,v,n,t,o);if(P!==i){if(P)continue;x=!1;break}if(b){if(!zr(t,function(F,D){if(!ae(b,D)&&(T===F||u(T,F,e,r,o)))return b.push(D)})){x=!1;break}}else if(!(T===W||u(T,W,e,r,o))){x=!1;break}}return o.delete(n),o.delete(t),x}function dc(n,t,e,r,u,o,a){switch(e){case Ut:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case oe:return!(n.byteLength!=t.byteLength||!o(new qe(n),new qe(t)));case te:case ee:case re:return Jn(+n,+t);case Ee:return n.name==t.name&&n.message==t.message;case ie:case ue:return n==t+"";case qn:var f=Xr;case zn:var c=r&Zn;if(f||(f=De),n.size!=t.size&&!c)return!1;var d=a.get(n);if(d)return d==t;r|=tt,a.set(n,t);var _=Ns(f(n),f(t),r,u,o,a);return a.delete(n),_;case Le:if(ge)return ge.call(n)==ge.call(t)}return!1}function _c(n,t,e,r,u,o){var a=e&Zn,f=xi(n),c=f.length,d=xi(t),_=d.length;if(c!=_&&!a)return!1;for(var v=c;v--;){var x=f[v];if(!(a?x in t:z.call(t,x)))return!1}var b=o.get(n),T=o.get(t);if(b&&T)return b==t&&T==n;var W=!0;o.set(n,t),o.set(t,n);for(var P=a;++v<c;){x=f[v];var F=n[x],D=t[x];if(r)var En=a?r(D,F,x,t,n,o):r(F,D,x,n,t,o);if(!(En===i?F===D||u(F,D,e,r,o):En)){W=!1;break}P||(P=x=="constructor")}if(W&&!P){var yn=n.constructor,In=t.constructor;yn!=In&&"constructor"in n&&"constructor"in t&&!(typeof yn=="function"&&yn instanceof yn&&typeof In=="function"&&In instanceof In)&&(W=!1)}return o.delete(n),o.delete(t),W}function ot(n){return Ei(zs(n,i,js),n+"")}function xi(n){return is(n,cn,bi)}function Si(n){return is(n,An,Bs)}var Ai=Ze?function(n){return Ze.get(n)}:ki;function fr(n){for(var t=n.name+"",e=zt[t],r=z.call(zt,t)?e.length:0;r--;){var u=e[r],o=u.func;if(o==null||o==n)return u.name}return t}function Yt(n){var t=z.call(s,"placeholder")?s:n;return t.placeholder}function R(){var n=s.iteratee||Gi;return n=n===Gi?os:n,arguments.length?n(arguments[0],arguments[1]):n}function lr(n,t){var e=n.__data__;return Cc(t)?e[typeof t=="string"?"string":"hash"]:e.map}function Ci(n){for(var t=cn(n),e=t.length;e--;){var r=t[e],u=n[r];t[e]=[r,u,ks(u)]}return t}function Lt(n,t){var e=Tf(n,t);return ss(e)?e:i}function vc(n){var t=z.call(n,Rt),e=n[Rt];try{n[Rt]=i;var r=!0}catch{}var u=$e.call(n);return r&&(t?n[Rt]=e:delete n[Rt]),u}var bi=Vr?function(n){return n==null?[]:(n=K(n),pt(Vr(n),function(t){return Hu.call(n,t)}))}:qi,Bs=Vr?function(n){for(var t=[];n;)dt(t,bi(n)),n=ze(n);return t}:qi,_n=wn;(jr&&_n(new jr(new ArrayBuffer(1)))!=Ut||le&&_n(new le)!=qn||ni&&_n(ni.resolve())!=tu||qt&&_n(new qt)!=zn||ce&&_n(new ce)!=se)&&(_n=function(n){var t=wn(n),e=t==et?n.constructor:i,r=e?Ot(e):"";if(r)switch(r){case jf:return Ut;case nl:return qn;case tl:return tu;case el:return zn;case rl:return se}return t});function wc(n,t,e){for(var r=-1,u=e.length;++r<u;){var o=e[r],a=o.size;switch(o.type){case"drop":n+=a;break;case"dropRight":t-=a;break;case"take":t=dn(t,n+a);break;case"takeRight":n=an(n,t-a);break}}return{start:n,end:t}}function mc(n){var t=n.match(Ca);return t?t[1].split(ba):[]}function Gs(n,t,e){t=yt(t,n);for(var r=-1,u=t.length,o=!1;++r<u;){var a=jn(t[r]);if(!(o=n!=null&&e(n,a)))break;n=n[a]}return o||++r!=u?o:(u=n==null?0:n.length,!!u&&vr(u)&&at(a,u)&&(L(n)||Wt(n)))}function yc(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&z.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function $s(n){return typeof n.constructor=="function"&&!ye(n)?Ht(ze(n)):{}}function xc(n,t,e){var r=n.constructor;switch(t){case oe:return wi(n);case te:case ee:return new r(+n);case Ut:return ic(n,e);case Cr:case br:case Rr:case Tr:case Pr:case Er:case Ir:case Lr:case Or:return As(n,e);case qn:return new r;case re:case ue:return new r(n);case ie:return uc(n);case zn:return new r;case Le:return sc(n)}}function Sc(n,t){var e=t.length;if(!e)return n;var r=e-1;return t[r]=(e>1?"& ":"")+t[r],t=t.join(e>2?", ":" "),n.replace(Aa,`{
|
|
17
|
+
/* [wrapped with `+t+`] */
|
|
18
|
+
`)}function Ac(n){return L(n)||Wt(n)||!!(Ku&&n&&n[Ku])}function at(n,t){var e=typeof n;return t=t??Mt,!!t&&(e=="number"||e!="symbol"&&Ma.test(n))&&n>-1&&n%1==0&&n<t}function mn(n,t,e){if(!Q(e))return!1;var r=typeof t;return(r=="number"?Sn(e)&&at(t,e.length):r=="string"&&t in e)?Jn(e[t],n):!1}function Ri(n,t){if(L(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Pn(n)?!0:ma.test(n)||!wa.test(n)||t!=null&&n in K(t)}function Cc(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function Ti(n){var t=fr(n),e=s[t];if(typeof e!="function"||!(t in U.prototype))return!1;if(n===e)return!0;var r=Ai(e);return!!r&&n===r[0]}function bc(n){return!!ku&&ku in n}var Rc=Be?ft:zi;function ye(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||kt;return n===e}function ks(n){return n===n&&!Q(n)}function qs(n,t){return function(e){return e==null?!1:e[n]===t&&(t!==i||n in K(e))}}function Tc(n){var t=dr(n,function(r){return e.size===fn&&e.clear(),r}),e=t.cache;return t}function Pc(n,t){var e=n[1],r=t[1],u=e|r,o=u<(rn|ht|$),a=r==$&&e==Gn||r==$&&e==nn&&n[7].length<=t[8]||r==($|nn)&&t[7].length<=t[8]&&e==Gn;if(!(o||a))return n;r&rn&&(n[2]=t[2],u|=e&rn?0:be);var f=t[3];if(f){var c=n[3];n[3]=c?bs(c,f,t[4]):f,n[4]=c?_t(n[3],vn):t[4]}return f=t[5],f&&(c=n[5],n[5]=c?Rs(c,f,t[6]):f,n[6]=c?_t(n[5],vn):t[6]),f=t[7],f&&(n[7]=f),r&$&&(n[8]=n[8]==null?t[8]:dn(n[8],t[8])),n[9]==null&&(n[9]=t[9]),n[0]=t[0],n[1]=u,n}function Ec(n){var t=[];if(n!=null)for(var e in K(n))t.push(e);return t}function Ic(n){return $e.call(n)}function zs(n,t,e){return t=an(t===i?n.length-1:t,0),function(){for(var r=arguments,u=-1,o=an(r.length-t,0),a=h(o);++u<o;)a[u]=r[t+u];u=-1;for(var f=h(t+1);++u<t;)f[u]=r[u];return f[t]=e(a),bn(n,this,f)}}function Hs(n,t){return t.length<2?n:It(n,Un(t,0,-1))}function Lc(n,t){for(var e=n.length,r=dn(t.length,e),u=xn(n);r--;){var o=t[r];n[r]=at(o,e)?u[o]:i}return n}function Pi(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Ks=Ys(ds),xe=Kf||function(n,t){return gn.setTimeout(n,t)},Ei=Ys(nc);function Js(n,t,e){var r=t+"";return Ei(n,Sc(r,Oc(mc(r),e)))}function Ys(n){var t=0,e=0;return function(){var r=Xf(),u=gt-(r-e);if(e=r,u>0){if(++t>=Z)return arguments[0]}else t=0;return n.apply(i,arguments)}}function cr(n,t){var e=-1,r=n.length,u=r-1;for(t=t===i?r:t;++e<t;){var o=ci(e,u),a=n[o];n[o]=n[e],n[e]=a}return n.length=t,n}var Zs=Tc(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(ya,function(e,r,u,o){t.push(u?o.replace(Pa,"$1"):r||e)}),t});function jn(n){if(typeof n=="string"||Pn(n))return n;var t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function Ot(n){if(n!=null){try{return Ge.call(n)}catch{}try{return n+""}catch{}}return""}function Oc(n,t){return On(ia,function(e){var r="_."+e[0];t&e[1]&&!Fe(n,r)&&n.push(r)}),n.sort()}function Xs(n){if(n instanceof U)return n.clone();var t=new Mn(n.__wrapped__,n.__chain__);return t.__actions__=xn(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function Wc(n,t,e){(e?mn(n,t,e):t===i)?t=1:t=an(O(t),0);var r=n==null?0:n.length;if(!r||t<1)return[];for(var u=0,o=0,a=h(Je(r/t));u<r;)a[o++]=Un(n,u,u+=t);return a}function Mc(n){for(var t=-1,e=n==null?0:n.length,r=0,u=[];++t<e;){var o=n[t];o&&(u[r++]=o)}return u}function Fc(){var n=arguments.length;if(!n)return[];for(var t=h(n-1),e=arguments[0],r=n;r--;)t[r-1]=arguments[r];return dt(L(e)?xn(e):[e],pn(t,1))}var Uc=M(function(n,t){return tn(n)?de(n,pn(t,1,tn,!0)):[]}),Dc=M(function(n,t){var e=Dn(t);return tn(e)&&(e=i),tn(n)?de(n,pn(t,1,tn,!0),R(e,2)):[]}),Nc=M(function(n,t){var e=Dn(t);return tn(e)&&(e=i),tn(n)?de(n,pn(t,1,tn,!0),i,e):[]});function Bc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:O(t),Un(n,t<0?0:t,r)):[]}function Gc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:O(t),t=r-t,Un(n,0,t<0?0:t)):[]}function $c(n,t){return n&&n.length?rr(n,R(t,3),!0,!0):[]}function kc(n,t){return n&&n.length?rr(n,R(t,3),!0):[]}function qc(n,t,e,r){var u=n==null?0:n.length;return u?(e&&typeof e!="number"&&mn(n,t,e)&&(e=0,r=u),Fl(n,t,e,r)):[]}function Qs(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:O(e);return u<0&&(u=an(r+u,0)),Ue(n,R(t,3),u)}function Vs(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r-1;return e!==i&&(u=O(e),u=e<0?an(r+u,0):dn(u,r-1)),Ue(n,R(t,3),u,!0)}function js(n){var t=n==null?0:n.length;return t?pn(n,1):[]}function zc(n){var t=n==null?0:n.length;return t?pn(n,Re):[]}function Hc(n,t){var e=n==null?0:n.length;return e?(t=t===i?1:O(t),pn(n,t)):[]}function Kc(n){for(var t=-1,e=n==null?0:n.length,r={};++t<e;){var u=n[t];r[u[0]]=u[1]}return r}function no(n){return n&&n.length?n[0]:i}function Jc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:O(e);return u<0&&(u=an(r+u,0)),Nt(n,t,u)}function Yc(n){var t=n==null?0:n.length;return t?Un(n,0,-1):[]}var Zc=M(function(n){var t=X(n,_i);return t.length&&t[0]===n[0]?si(t):[]}),Xc=M(function(n){var t=Dn(n),e=X(n,_i);return t===Dn(e)?t=i:e.pop(),e.length&&e[0]===n[0]?si(e,R(t,2)):[]}),Qc=M(function(n){var t=Dn(n),e=X(n,_i);return t=typeof t=="function"?t:i,t&&e.pop(),e.length&&e[0]===n[0]?si(e,i,t):[]});function Vc(n,t){return n==null?"":Yf.call(n,t)}function Dn(n){var t=n==null?0:n.length;return t?n[t-1]:i}function jc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r;return e!==i&&(u=O(e),u=u<0?an(r+u,0):dn(u,r-1)),t===t?Of(n,t,u):Ue(n,Mu,u,!0)}function nh(n,t){return n&&n.length?cs(n,O(t)):i}var th=M(to);function to(n,t){return n&&n.length&&t&&t.length?li(n,t):n}function eh(n,t,e){return n&&n.length&&t&&t.length?li(n,t,R(e,2)):n}function rh(n,t,e){return n&&n.length&&t&&t.length?li(n,t,i,e):n}var ih=ot(function(n,t){var e=n==null?0:n.length,r=ei(n,t);return ps(n,X(t,function(u){return at(u,e)?+u:u}).sort(Cs)),r});function uh(n,t){var e=[];if(!(n&&n.length))return e;var r=-1,u=[],o=n.length;for(t=R(t,3);++r<o;){var a=n[r];t(a,r,n)&&(e.push(a),u.push(r))}return ps(n,u),e}function Ii(n){return n==null?n:Vf.call(n)}function sh(n,t,e){var r=n==null?0:n.length;return r?(e&&typeof e!="number"&&mn(n,t,e)?(t=0,e=r):(t=t==null?0:O(t),e=e===i?r:O(e)),Un(n,t,e)):[]}function oh(n,t){return er(n,t)}function ah(n,t,e){return gi(n,t,R(e,2))}function fh(n,t){var e=n==null?0:n.length;if(e){var r=er(n,t);if(r<e&&Jn(n[r],t))return r}return-1}function lh(n,t){return er(n,t,!0)}function ch(n,t,e){return gi(n,t,R(e,2),!0)}function hh(n,t){var e=n==null?0:n.length;if(e){var r=er(n,t,!0)-1;if(Jn(n[r],t))return r}return-1}function gh(n){return n&&n.length?_s(n):[]}function ph(n,t){return n&&n.length?_s(n,R(t,2)):[]}function dh(n){var t=n==null?0:n.length;return t?Un(n,1,t):[]}function _h(n,t,e){return n&&n.length?(t=e||t===i?1:O(t),Un(n,0,t<0?0:t)):[]}function vh(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:O(t),t=r-t,Un(n,t<0?0:t,r)):[]}function wh(n,t){return n&&n.length?rr(n,R(t,3),!1,!0):[]}function mh(n,t){return n&&n.length?rr(n,R(t,3)):[]}var yh=M(function(n){return mt(pn(n,1,tn,!0))}),xh=M(function(n){var t=Dn(n);return tn(t)&&(t=i),mt(pn(n,1,tn,!0),R(t,2))}),Sh=M(function(n){var t=Dn(n);return t=typeof t=="function"?t:i,mt(pn(n,1,tn,!0),i,t)});function Ah(n){return n&&n.length?mt(n):[]}function Ch(n,t){return n&&n.length?mt(n,R(t,2)):[]}function bh(n,t){return t=typeof t=="function"?t:i,n&&n.length?mt(n,i,t):[]}function Li(n){if(!(n&&n.length))return[];var t=0;return n=pt(n,function(e){if(tn(e))return t=an(e.length,t),!0}),Yr(t,function(e){return X(n,Hr(e))})}function eo(n,t){if(!(n&&n.length))return[];var e=Li(n);return t==null?e:X(e,function(r){return bn(t,i,r)})}var Rh=M(function(n,t){return tn(n)?de(n,t):[]}),Th=M(function(n){return di(pt(n,tn))}),Ph=M(function(n){var t=Dn(n);return tn(t)&&(t=i),di(pt(n,tn),R(t,2))}),Eh=M(function(n){var t=Dn(n);return t=typeof t=="function"?t:i,di(pt(n,tn),i,t)}),Ih=M(Li);function Lh(n,t){return ys(n||[],t||[],pe)}function Oh(n,t){return ys(n||[],t||[],we)}var Wh=M(function(n){var t=n.length,e=t>1?n[t-1]:i;return e=typeof e=="function"?(n.pop(),e):i,eo(n,e)});function ro(n){var t=s(n);return t.__chain__=!0,t}function Mh(n,t){return t(n),n}function hr(n,t){return t(n)}var Fh=ot(function(n){var t=n.length,e=t?n[0]:0,r=this.__wrapped__,u=function(o){return ei(o,n)};return t>1||this.__actions__.length||!(r instanceof U)||!at(e)?this.thru(u):(r=r.slice(e,+e+(t?1:0)),r.__actions__.push({func:hr,args:[u],thisArg:i}),new Mn(r,this.__chain__).thru(function(o){return t&&!o.length&&o.push(i),o}))});function Uh(){return ro(this)}function Dh(){return new Mn(this.value(),this.__chain__)}function Nh(){this.__values__===i&&(this.__values__=wo(this.value()));var n=this.__index__>=this.__values__.length,t=n?i:this.__values__[this.__index__++];return{done:n,value:t}}function Bh(){return this}function Gh(n){for(var t,e=this;e instanceof Qe;){var r=Xs(e);r.__index__=0,r.__values__=i,t?u.__wrapped__=r:t=r;var u=r;e=e.__wrapped__}return u.__wrapped__=n,t}function $h(){var n=this.__wrapped__;if(n instanceof U){var t=n;return this.__actions__.length&&(t=new U(this)),t=t.reverse(),t.__actions__.push({func:hr,args:[Ii],thisArg:i}),new Mn(t,this.__chain__)}return this.thru(Ii)}function kh(){return ms(this.__wrapped__,this.__actions__)}var qh=ir(function(n,t,e){z.call(n,e)?++n[e]:ut(n,e,1)});function zh(n,t,e){var r=L(n)?Ou:Ml;return e&&mn(n,t,e)&&(t=i),r(n,R(t,3))}function Hh(n,t){var e=L(n)?pt:es;return e(n,R(t,3))}var Kh=Is(Qs),Jh=Is(Vs);function Yh(n,t){return pn(gr(n,t),1)}function Zh(n,t){return pn(gr(n,t),Re)}function Xh(n,t,e){return e=e===i?1:O(e),pn(gr(n,t),e)}function io(n,t){var e=L(n)?On:wt;return e(n,R(t,3))}function uo(n,t){var e=L(n)?df:ts;return e(n,R(t,3))}var Qh=ir(function(n,t,e){z.call(n,e)?n[e].push(t):ut(n,e,[t])});function Vh(n,t,e,r){n=Sn(n)?n:Xt(n),e=e&&!r?O(e):0;var u=n.length;return e<0&&(e=an(u+e,0)),wr(n)?e<=u&&n.indexOf(t,e)>-1:!!u&&Nt(n,t,e)>-1}var jh=M(function(n,t,e){var r=-1,u=typeof t=="function",o=Sn(n)?h(n.length):[];return wt(n,function(a){o[++r]=u?bn(t,a,e):_e(a,t,e)}),o}),ng=ir(function(n,t,e){ut(n,e,t)});function gr(n,t){var e=L(n)?X:as;return e(n,R(t,3))}function tg(n,t,e,r){return n==null?[]:(L(t)||(t=t==null?[]:[t]),e=r?i:e,L(e)||(e=e==null?[]:[e]),hs(n,t,e))}var eg=ir(function(n,t,e){n[e?0:1].push(t)},function(){return[[],[]]});function rg(n,t,e){var r=L(n)?qr:Uu,u=arguments.length<3;return r(n,R(t,4),e,u,wt)}function ig(n,t,e){var r=L(n)?_f:Uu,u=arguments.length<3;return r(n,R(t,4),e,u,ts)}function ug(n,t){var e=L(n)?pt:es;return e(n,_r(R(t,3)))}function sg(n){var t=L(n)?Qu:Vl;return t(n)}function og(n,t,e){(e?mn(n,t,e):t===i)?t=1:t=O(t);var r=L(n)?El:jl;return r(n,t)}function ag(n){var t=L(n)?Il:tc;return t(n)}function fg(n){if(n==null)return 0;if(Sn(n))return wr(n)?Gt(n):n.length;var t=_n(n);return t==qn||t==zn?n.size:ai(n).length}function lg(n,t,e){var r=L(n)?zr:ec;return e&&mn(n,t,e)&&(t=i),r(n,R(t,3))}var cg=M(function(n,t){if(n==null)return[];var e=t.length;return e>1&&mn(n,t[0],t[1])?t=[]:e>2&&mn(t[0],t[1],t[2])&&(t=[t[0]]),hs(n,pn(t,1),[])}),pr=Hf||function(){return gn.Date.now()};function hg(n,t){if(typeof t!="function")throw new Wn(A);return n=O(n),function(){if(--n<1)return t.apply(this,arguments)}}function so(n,t,e){return t=e?i:t,t=n&&t==null?n.length:t,st(n,$,i,i,i,i,t)}function oo(n,t){var e;if(typeof t!="function")throw new Wn(A);return n=O(n),function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=i),e}}var Oi=M(function(n,t,e){var r=rn;if(e.length){var u=_t(e,Yt(Oi));r|=$n}return st(n,r,t,e,u)}),ao=M(function(n,t,e){var r=rn|ht;if(e.length){var u=_t(e,Yt(ao));r|=$n}return st(t,r,n,e,u)});function fo(n,t,e){t=e?i:t;var r=st(n,Gn,i,i,i,i,i,t);return r.placeholder=fo.placeholder,r}function lo(n,t,e){t=e?i:t;var r=st(n,Ct,i,i,i,i,i,t);return r.placeholder=lo.placeholder,r}function co(n,t,e){var r,u,o,a,f,c,d=0,_=!1,v=!1,x=!0;if(typeof n!="function")throw new Wn(A);t=Nn(t)||0,Q(e)&&(_=!!e.leading,v="maxWait"in e,o=v?an(Nn(e.maxWait)||0,t):o,x="trailing"in e?!!e.trailing:x);function b(en){var Yn=r,ct=u;return r=u=i,d=en,a=n.apply(ct,Yn),a}function T(en){return d=en,f=xe(F,t),_?b(en):a}function W(en){var Yn=en-c,ct=en-d,Lo=t-Yn;return v?dn(Lo,o-ct):Lo}function P(en){var Yn=en-c,ct=en-d;return c===i||Yn>=t||Yn<0||v&&ct>=o}function F(){var en=pr();if(P(en))return D(en);f=xe(F,W(en))}function D(en){return f=i,x&&r?b(en):(r=u=i,a)}function En(){f!==i&&xs(f),d=0,r=c=u=f=i}function yn(){return f===i?a:D(pr())}function In(){var en=pr(),Yn=P(en);if(r=arguments,u=this,c=en,Yn){if(f===i)return T(c);if(v)return xs(f),f=xe(F,t),b(c)}return f===i&&(f=xe(F,t)),a}return In.cancel=En,In.flush=yn,In}var gg=M(function(n,t){return ns(n,1,t)}),pg=M(function(n,t,e){return ns(n,Nn(t)||0,e)});function dg(n){return st(n,V)}function dr(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new Wn(A);var e=function(){var r=arguments,u=t?t.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var a=n.apply(this,r);return e.cache=o.set(u,a)||o,a};return e.cache=new(dr.Cache||it),e}dr.Cache=it;function _r(n){if(typeof n!="function")throw new Wn(A);return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function _g(n){return oo(2,n)}var vg=rc(function(n,t){t=t.length==1&&L(t[0])?X(t[0],Rn(R())):X(pn(t,1),Rn(R()));var e=t.length;return M(function(r){for(var u=-1,o=dn(r.length,e);++u<o;)r[u]=t[u].call(this,r[u]);return bn(n,this,r)})}),Wi=M(function(n,t){var e=_t(t,Yt(Wi));return st(n,$n,i,t,e)}),ho=M(function(n,t){var e=_t(t,Yt(ho));return st(n,un,i,t,e)}),wg=ot(function(n,t){return st(n,nn,i,i,i,t)});function mg(n,t){if(typeof n!="function")throw new Wn(A);return t=t===i?t:O(t),M(n,t)}function yg(n,t){if(typeof n!="function")throw new Wn(A);return t=t==null?0:an(O(t),0),M(function(e){var r=e[t],u=xt(e,0,t);return r&&dt(u,r),bn(n,this,u)})}function xg(n,t,e){var r=!0,u=!0;if(typeof n!="function")throw new Wn(A);return Q(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),co(n,t,{leading:r,maxWait:t,trailing:u})}function Sg(n){return so(n,1)}function Ag(n,t){return Wi(vi(t),n)}function Cg(){if(!arguments.length)return[];var n=arguments[0];return L(n)?n:[n]}function bg(n){return Fn(n,ln)}function Rg(n,t){return t=typeof t=="function"?t:i,Fn(n,ln,t)}function Tg(n){return Fn(n,hn|ln)}function Pg(n,t){return t=typeof t=="function"?t:i,Fn(n,hn|ln,t)}function Eg(n,t){return t==null||ju(n,t,cn(t))}function Jn(n,t){return n===t||n!==n&&t!==t}var Ig=ar(ui),Lg=ar(function(n,t){return n>=t}),Wt=us(function(){return arguments}())?us:function(n){return j(n)&&z.call(n,"callee")&&!Hu.call(n,"callee")},L=h.isArray,Og=Ru?Rn(Ru):Gl;function Sn(n){return n!=null&&vr(n.length)&&!ft(n)}function tn(n){return j(n)&&Sn(n)}function Wg(n){return n===!0||n===!1||j(n)&&wn(n)==te}var St=Jf||zi,Mg=Tu?Rn(Tu):$l;function Fg(n){return j(n)&&n.nodeType===1&&!Se(n)}function Ug(n){if(n==null)return!0;if(Sn(n)&&(L(n)||typeof n=="string"||typeof n.splice=="function"||St(n)||Zt(n)||Wt(n)))return!n.length;var t=_n(n);if(t==qn||t==zn)return!n.size;if(ye(n))return!ai(n).length;for(var e in n)if(z.call(n,e))return!1;return!0}function Dg(n,t){return ve(n,t)}function Ng(n,t,e){e=typeof e=="function"?e:i;var r=e?e(n,t):i;return r===i?ve(n,t,i,e):!!r}function Mi(n){if(!j(n))return!1;var t=wn(n);return t==Ee||t==sa||typeof n.message=="string"&&typeof n.name=="string"&&!Se(n)}function Bg(n){return typeof n=="number"&&Ju(n)}function ft(n){if(!Q(n))return!1;var t=wn(n);return t==Ie||t==nu||t==ua||t==aa}function go(n){return typeof n=="number"&&n==O(n)}function vr(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Mt}function Q(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function j(n){return n!=null&&typeof n=="object"}var po=Pu?Rn(Pu):ql;function Gg(n,t){return n===t||oi(n,t,Ci(t))}function $g(n,t,e){return e=typeof e=="function"?e:i,oi(n,t,Ci(t),e)}function kg(n){return _o(n)&&n!=+n}function qg(n){if(Rc(n))throw new I(C);return ss(n)}function zg(n){return n===null}function Hg(n){return n==null}function _o(n){return typeof n=="number"||j(n)&&wn(n)==re}function Se(n){if(!j(n)||wn(n)!=et)return!1;var t=ze(n);if(t===null)return!0;var e=z.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Ge.call(e)==$f}var Fi=Eu?Rn(Eu):zl;function Kg(n){return go(n)&&n>=-9007199254740991&&n<=Mt}var vo=Iu?Rn(Iu):Hl;function wr(n){return typeof n=="string"||!L(n)&&j(n)&&wn(n)==ue}function Pn(n){return typeof n=="symbol"||j(n)&&wn(n)==Le}var Zt=Lu?Rn(Lu):Kl;function Jg(n){return n===i}function Yg(n){return j(n)&&_n(n)==se}function Zg(n){return j(n)&&wn(n)==la}var Xg=ar(fi),Qg=ar(function(n,t){return n<=t});function wo(n){if(!n)return[];if(Sn(n))return wr(n)?Hn(n):xn(n);if(fe&&n[fe])return Ef(n[fe]());var t=_n(n),e=t==qn?Xr:t==zn?De:Xt;return e(n)}function lt(n){if(!n)return n===0?n:0;if(n=Nn(n),n===Re||n===-1/0){var t=n<0?-1:1;return t*ta}return n===n?n:0}function O(n){var t=lt(n),e=t%1;return t===t?e?t-e:t:0}function mo(n){return n?Et(O(n),0,Xn):0}function Nn(n){if(typeof n=="number")return n;if(Pn(n))return Te;if(Q(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=Q(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=Du(n);var e=La.test(n);return e||Wa.test(n)?hf(n.slice(2),e?2:8):Ia.test(n)?Te:+n}function yo(n){return Vn(n,An(n))}function Vg(n){return n?Et(O(n),-9007199254740991,Mt):n===0?n:0}function q(n){return n==null?"":Tn(n)}var jg=Kt(function(n,t){if(ye(t)||Sn(t)){Vn(t,cn(t),n);return}for(var e in t)z.call(t,e)&&pe(n,e,t[e])}),xo=Kt(function(n,t){Vn(t,An(t),n)}),mr=Kt(function(n,t,e,r){Vn(t,An(t),n,r)}),np=Kt(function(n,t,e,r){Vn(t,cn(t),n,r)}),tp=ot(ei);function ep(n,t){var e=Ht(n);return t==null?e:Vu(e,t)}var rp=M(function(n,t){n=K(n);var e=-1,r=t.length,u=r>2?t[2]:i;for(u&&mn(t[0],t[1],u)&&(r=1);++e<r;)for(var o=t[e],a=An(o),f=-1,c=a.length;++f<c;){var d=a[f],_=n[d];(_===i||Jn(_,kt[d])&&!z.call(n,d))&&(n[d]=o[d])}return n}),ip=M(function(n){return n.push(i,Ds),bn(So,i,n)});function up(n,t){return Wu(n,R(t,3),Qn)}function sp(n,t){return Wu(n,R(t,3),ii)}function op(n,t){return n==null?n:ri(n,R(t,3),An)}function ap(n,t){return n==null?n:rs(n,R(t,3),An)}function fp(n,t){return n&&Qn(n,R(t,3))}function lp(n,t){return n&&ii(n,R(t,3))}function cp(n){return n==null?[]:nr(n,cn(n))}function hp(n){return n==null?[]:nr(n,An(n))}function Ui(n,t,e){var r=n==null?i:It(n,t);return r===i?e:r}function gp(n,t){return n!=null&&Gs(n,t,Ul)}function Di(n,t){return n!=null&&Gs(n,t,Dl)}var pp=Os(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=$e.call(t)),n[t]=e},Bi(Cn)),dp=Os(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=$e.call(t)),z.call(n,t)?n[t].push(e):n[t]=[e]},R),_p=M(_e);function cn(n){return Sn(n)?Xu(n):ai(n)}function An(n){return Sn(n)?Xu(n,!0):Jl(n)}function vp(n,t){var e={};return t=R(t,3),Qn(n,function(r,u,o){ut(e,t(r,u,o),r)}),e}function wp(n,t){var e={};return t=R(t,3),Qn(n,function(r,u,o){ut(e,u,t(r,u,o))}),e}var mp=Kt(function(n,t,e){tr(n,t,e)}),So=Kt(function(n,t,e,r){tr(n,t,e,r)}),yp=ot(function(n,t){var e={};if(n==null)return e;var r=!1;t=X(t,function(o){return o=yt(o,n),r||(r=o.length>1),o}),Vn(n,Si(n),e),r&&(e=Fn(e,hn|Bn|ln,pc));for(var u=t.length;u--;)pi(e,t[u]);return e});function xp(n,t){return Ao(n,_r(R(t)))}var Sp=ot(function(n,t){return n==null?{}:Zl(n,t)});function Ao(n,t){if(n==null)return{};var e=X(Si(n),function(r){return[r]});return t=R(t),gs(n,e,function(r,u){return t(r,u[0])})}function Ap(n,t,e){t=yt(t,n);var r=-1,u=t.length;for(u||(u=1,n=i);++r<u;){var o=n==null?i:n[jn(t[r])];o===i&&(r=u,o=e),n=ft(o)?o.call(n):o}return n}function Cp(n,t,e){return n==null?n:we(n,t,e)}function bp(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:we(n,t,e,r)}var Co=Fs(cn),bo=Fs(An);function Rp(n,t,e){var r=L(n),u=r||St(n)||Zt(n);if(t=R(t,4),e==null){var o=n&&n.constructor;u?e=r?new o:[]:Q(n)?e=ft(o)?Ht(ze(n)):{}:e={}}return(u?On:Qn)(n,function(a,f,c){return t(e,a,f,c)}),e}function Tp(n,t){return n==null?!0:pi(n,t)}function Pp(n,t,e){return n==null?n:ws(n,t,vi(e))}function Ep(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:ws(n,t,vi(e),r)}function Xt(n){return n==null?[]:Zr(n,cn(n))}function Ip(n){return n==null?[]:Zr(n,An(n))}function Lp(n,t,e){return e===i&&(e=t,t=i),e!==i&&(e=Nn(e),e=e===e?e:0),t!==i&&(t=Nn(t),t=t===t?t:0),Et(Nn(n),t,e)}function Op(n,t,e){return t=lt(t),e===i?(e=t,t=0):e=lt(e),n=Nn(n),Nl(n,t,e)}function Wp(n,t,e){if(e&&typeof e!="boolean"&&mn(n,t,e)&&(t=e=i),e===i&&(typeof t=="boolean"?(e=t,t=i):typeof n=="boolean"&&(e=n,n=i)),n===i&&t===i?(n=0,t=1):(n=lt(n),t===i?(t=n,n=0):t=lt(t)),n>t){var r=n;n=t,t=r}if(e||n%1||t%1){var u=Yu();return dn(n+u*(t-n+cf("1e-"+((u+"").length-1))),t)}return ci(n,t)}var Mp=Jt(function(n,t,e){return t=t.toLowerCase(),n+(e?Ro(t):t)});function Ro(n){return Ni(q(n).toLowerCase())}function To(n){return n=q(n),n&&n.replace(Fa,Cf).replace(nf,"")}function Fp(n,t,e){n=q(n),t=Tn(t);var r=n.length;e=e===i?r:Et(O(e),0,r);var u=e;return e-=t.length,e>=0&&n.slice(e,u)==t}function Up(n){return n=q(n),n&&da.test(n)?n.replace(ru,bf):n}function Dp(n){return n=q(n),n&&xa.test(n)?n.replace(Wr,"\\$&"):n}var Np=Jt(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()}),Bp=Jt(function(n,t,e){return n+(e?" ":"")+t.toLowerCase()}),Gp=Es("toLowerCase");function $p(n,t,e){n=q(n),t=O(t);var r=t?Gt(n):0;if(!t||r>=t)return n;var u=(t-r)/2;return or(Ye(u),e)+n+or(Je(u),e)}function kp(n,t,e){n=q(n),t=O(t);var r=t?Gt(n):0;return t&&r<t?n+or(t-r,e):n}function qp(n,t,e){n=q(n),t=O(t);var r=t?Gt(n):0;return t&&r<t?or(t-r,e)+n:n}function zp(n,t,e){return e||t==null?t=0:t&&(t=+t),Qf(q(n).replace(Mr,""),t||0)}function Hp(n,t,e){return(e?mn(n,t,e):t===i)?t=1:t=O(t),hi(q(n),t)}function Kp(){var n=arguments,t=q(n[0]);return n.length<3?t:t.replace(n[1],n[2])}var Jp=Jt(function(n,t,e){return n+(e?"_":"")+t.toLowerCase()});function Yp(n,t,e){return e&&typeof e!="number"&&mn(n,t,e)&&(t=e=i),e=e===i?Xn:e>>>0,e?(n=q(n),n&&(typeof t=="string"||t!=null&&!Fi(t))&&(t=Tn(t),!t&&Bt(n))?xt(Hn(n),0,e):n.split(t,e)):[]}var Zp=Jt(function(n,t,e){return n+(e?" ":"")+Ni(t)});function Xp(n,t,e){return n=q(n),e=e==null?0:Et(O(e),0,n.length),t=Tn(t),n.slice(e,e+t.length)==t}function Qp(n,t,e){var r=s.templateSettings;e&&mn(n,t,e)&&(t=i),n=q(n),t=mr({},t,r,Us);var u=mr({},t.imports,r.imports,Us),o=cn(u),a=Zr(u,o),f,c,d=0,_=t.interpolate||Oe,v="__p += '",x=Qr((t.escape||Oe).source+"|"+_.source+"|"+(_===iu?Ea:Oe).source+"|"+(t.evaluate||Oe).source+"|$","g"),b="//# sourceURL="+(z.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++sf+"]")+`
|
|
19
|
+
`;n.replace(x,function(P,F,D,En,yn,In){return D||(D=En),v+=n.slice(d,In).replace(Ua,Rf),F&&(f=!0,v+=`' +
|
|
20
|
+
__e(`+F+`) +
|
|
21
|
+
'`),yn&&(c=!0,v+=`';
|
|
22
|
+
`+yn+`;
|
|
23
|
+
__p += '`),D&&(v+=`' +
|
|
24
|
+
((__t = (`+D+`)) == null ? '' : __t) +
|
|
25
|
+
'`),d=In+P.length,P}),v+=`';
|
|
26
|
+
`;var T=z.call(t,"variable")&&t.variable;if(!T)v=`with (obj) {
|
|
27
|
+
`+v+`
|
|
28
|
+
}
|
|
29
|
+
`;else if(Ta.test(T))throw new I(G);v=(c?v.replace(ca,""):v).replace(ha,"$1").replace(ga,"$1;"),v="function("+(T||"obj")+`) {
|
|
30
|
+
`+(T?"":`obj || (obj = {});
|
|
31
|
+
`)+"var __t, __p = ''"+(f?", __e = _.escape":"")+(c?`, __j = Array.prototype.join;
|
|
32
|
+
function print() { __p += __j.call(arguments, '') }
|
|
33
|
+
`:`;
|
|
34
|
+
`)+v+`return __p
|
|
35
|
+
}`;var W=Eo(function(){return k(o,b+"return "+v).apply(i,a)});if(W.source=v,Mi(W))throw W;return W}function Vp(n){return q(n).toLowerCase()}function jp(n){return q(n).toUpperCase()}function nd(n,t,e){if(n=q(n),n&&(e||t===i))return Du(n);if(!n||!(t=Tn(t)))return n;var r=Hn(n),u=Hn(t),o=Nu(r,u),a=Bu(r,u)+1;return xt(r,o,a).join("")}function td(n,t,e){if(n=q(n),n&&(e||t===i))return n.slice(0,$u(n)+1);if(!n||!(t=Tn(t)))return n;var r=Hn(n),u=Bu(r,Hn(t))+1;return xt(r,0,u).join("")}function ed(n,t,e){if(n=q(n),n&&(e||t===i))return n.replace(Mr,"");if(!n||!(t=Tn(t)))return n;var r=Hn(n),u=Nu(r,Hn(t));return xt(r,u).join("")}function rd(n,t){var e=sn,r=kn;if(Q(t)){var u="separator"in t?t.separator:u;e="length"in t?O(t.length):e,r="omission"in t?Tn(t.omission):r}n=q(n);var o=n.length;if(Bt(n)){var a=Hn(n);o=a.length}if(e>=o)return n;var f=e-Gt(r);if(f<1)return r;var c=a?xt(a,0,f).join(""):n.slice(0,f);if(u===i)return c+r;if(a&&(f+=c.length-f),Fi(u)){if(n.slice(f).search(u)){var d,_=c;for(u.global||(u=Qr(u.source,q(uu.exec(u))+"g")),u.lastIndex=0;d=u.exec(_);)var v=d.index;c=c.slice(0,v===i?f:v)}}else if(n.indexOf(Tn(u),f)!=f){var x=c.lastIndexOf(u);x>-1&&(c=c.slice(0,x))}return c+r}function id(n){return n=q(n),n&&pa.test(n)?n.replace(eu,Wf):n}var ud=Jt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Ni=Es("toUpperCase");function Po(n,t,e){return n=q(n),t=e?i:t,t===i?Pf(n)?Uf(n):mf(n):n.match(t)||[]}var Eo=M(function(n,t){try{return bn(n,i,t)}catch(e){return Mi(e)?e:new I(e)}}),sd=ot(function(n,t){return On(t,function(e){e=jn(e),ut(n,e,Oi(n[e],n))}),n});function od(n){var t=n==null?0:n.length,e=R();return n=t?X(n,function(r){if(typeof r[1]!="function")throw new Wn(A);return[e(r[0]),r[1]]}):[],M(function(r){for(var u=-1;++u<t;){var o=n[u];if(bn(o[0],this,r))return bn(o[1],this,r)}})}function ad(n){return Wl(Fn(n,hn))}function Bi(n){return function(){return n}}function fd(n,t){return n==null||n!==n?t:n}var ld=Ls(),cd=Ls(!0);function Cn(n){return n}function Gi(n){return os(typeof n=="function"?n:Fn(n,hn))}function hd(n){return fs(Fn(n,hn))}function gd(n,t){return ls(n,Fn(t,hn))}var pd=M(function(n,t){return function(e){return _e(e,n,t)}}),dd=M(function(n,t){return function(e){return _e(n,e,t)}});function $i(n,t,e){var r=cn(t),u=nr(t,r);e==null&&!(Q(t)&&(u.length||!r.length))&&(e=t,t=n,n=this,u=nr(t,cn(t)));var o=!(Q(e)&&"chain"in e)||!!e.chain,a=ft(n);return On(u,function(f){var c=t[f];n[f]=c,a&&(n.prototype[f]=function(){var d=this.__chain__;if(o||d){var _=n(this.__wrapped__),v=_.__actions__=xn(this.__actions__);return v.push({func:c,args:arguments,thisArg:n}),_.__chain__=d,_}return c.apply(n,dt([this.value()],arguments))})}),n}function _d(){return gn._===this&&(gn._=kf),this}function ki(){}function vd(n){return n=O(n),M(function(t){return cs(t,n)})}var wd=mi(X),md=mi(Ou),yd=mi(zr);function Io(n){return Ri(n)?Hr(jn(n)):Xl(n)}function xd(n){return function(t){return n==null?i:It(n,t)}}var Sd=Ws(),Ad=Ws(!0);function qi(){return[]}function zi(){return!1}function Cd(){return{}}function bd(){return""}function Rd(){return!0}function Td(n,t){if(n=O(n),n<1||n>Mt)return[];var e=Xn,r=dn(n,Xn);t=R(t),n-=Xn;for(var u=Yr(r,t);++e<n;)t(e);return u}function Pd(n){return L(n)?X(n,jn):Pn(n)?[n]:xn(Zs(q(n)))}function Ed(n){var t=++Gf;return q(n)+t}var Id=sr(function(n,t){return n+t},0),Ld=yi("ceil"),Od=sr(function(n,t){return n/t},1),Wd=yi("floor");function Md(n){return n&&n.length?je(n,Cn,ui):i}function Fd(n,t){return n&&n.length?je(n,R(t,2),ui):i}function Ud(n){return Fu(n,Cn)}function Dd(n,t){return Fu(n,R(t,2))}function Nd(n){return n&&n.length?je(n,Cn,fi):i}function Bd(n,t){return n&&n.length?je(n,R(t,2),fi):i}var Gd=sr(function(n,t){return n*t},1),$d=yi("round"),kd=sr(function(n,t){return n-t},0);function qd(n){return n&&n.length?Jr(n,Cn):0}function zd(n,t){return n&&n.length?Jr(n,R(t,2)):0}return s.after=hg,s.ary=so,s.assign=jg,s.assignIn=xo,s.assignInWith=mr,s.assignWith=np,s.at=tp,s.before=oo,s.bind=Oi,s.bindAll=sd,s.bindKey=ao,s.castArray=Cg,s.chain=ro,s.chunk=Wc,s.compact=Mc,s.concat=Fc,s.cond=od,s.conforms=ad,s.constant=Bi,s.countBy=qh,s.create=ep,s.curry=fo,s.curryRight=lo,s.debounce=co,s.defaults=rp,s.defaultsDeep=ip,s.defer=gg,s.delay=pg,s.difference=Uc,s.differenceBy=Dc,s.differenceWith=Nc,s.drop=Bc,s.dropRight=Gc,s.dropRightWhile=$c,s.dropWhile=kc,s.fill=qc,s.filter=Hh,s.flatMap=Yh,s.flatMapDeep=Zh,s.flatMapDepth=Xh,s.flatten=js,s.flattenDeep=zc,s.flattenDepth=Hc,s.flip=dg,s.flow=ld,s.flowRight=cd,s.fromPairs=Kc,s.functions=cp,s.functionsIn=hp,s.groupBy=Qh,s.initial=Yc,s.intersection=Zc,s.intersectionBy=Xc,s.intersectionWith=Qc,s.invert=pp,s.invertBy=dp,s.invokeMap=jh,s.iteratee=Gi,s.keyBy=ng,s.keys=cn,s.keysIn=An,s.map=gr,s.mapKeys=vp,s.mapValues=wp,s.matches=hd,s.matchesProperty=gd,s.memoize=dr,s.merge=mp,s.mergeWith=So,s.method=pd,s.methodOf=dd,s.mixin=$i,s.negate=_r,s.nthArg=vd,s.omit=yp,s.omitBy=xp,s.once=_g,s.orderBy=tg,s.over=wd,s.overArgs=vg,s.overEvery=md,s.overSome=yd,s.partial=Wi,s.partialRight=ho,s.partition=eg,s.pick=Sp,s.pickBy=Ao,s.property=Io,s.propertyOf=xd,s.pull=th,s.pullAll=to,s.pullAllBy=eh,s.pullAllWith=rh,s.pullAt=ih,s.range=Sd,s.rangeRight=Ad,s.rearg=wg,s.reject=ug,s.remove=uh,s.rest=mg,s.reverse=Ii,s.sampleSize=og,s.set=Cp,s.setWith=bp,s.shuffle=ag,s.slice=sh,s.sortBy=cg,s.sortedUniq=gh,s.sortedUniqBy=ph,s.split=Yp,s.spread=yg,s.tail=dh,s.take=_h,s.takeRight=vh,s.takeRightWhile=wh,s.takeWhile=mh,s.tap=Mh,s.throttle=xg,s.thru=hr,s.toArray=wo,s.toPairs=Co,s.toPairsIn=bo,s.toPath=Pd,s.toPlainObject=yo,s.transform=Rp,s.unary=Sg,s.union=yh,s.unionBy=xh,s.unionWith=Sh,s.uniq=Ah,s.uniqBy=Ch,s.uniqWith=bh,s.unset=Tp,s.unzip=Li,s.unzipWith=eo,s.update=Pp,s.updateWith=Ep,s.values=Xt,s.valuesIn=Ip,s.without=Rh,s.words=Po,s.wrap=Ag,s.xor=Th,s.xorBy=Ph,s.xorWith=Eh,s.zip=Ih,s.zipObject=Lh,s.zipObjectDeep=Oh,s.zipWith=Wh,s.entries=Co,s.entriesIn=bo,s.extend=xo,s.extendWith=mr,$i(s,s),s.add=Id,s.attempt=Eo,s.camelCase=Mp,s.capitalize=Ro,s.ceil=Ld,s.clamp=Lp,s.clone=bg,s.cloneDeep=Tg,s.cloneDeepWith=Pg,s.cloneWith=Rg,s.conformsTo=Eg,s.deburr=To,s.defaultTo=fd,s.divide=Od,s.endsWith=Fp,s.eq=Jn,s.escape=Up,s.escapeRegExp=Dp,s.every=zh,s.find=Kh,s.findIndex=Qs,s.findKey=up,s.findLast=Jh,s.findLastIndex=Vs,s.findLastKey=sp,s.floor=Wd,s.forEach=io,s.forEachRight=uo,s.forIn=op,s.forInRight=ap,s.forOwn=fp,s.forOwnRight=lp,s.get=Ui,s.gt=Ig,s.gte=Lg,s.has=gp,s.hasIn=Di,s.head=no,s.identity=Cn,s.includes=Vh,s.indexOf=Jc,s.inRange=Op,s.invoke=_p,s.isArguments=Wt,s.isArray=L,s.isArrayBuffer=Og,s.isArrayLike=Sn,s.isArrayLikeObject=tn,s.isBoolean=Wg,s.isBuffer=St,s.isDate=Mg,s.isElement=Fg,s.isEmpty=Ug,s.isEqual=Dg,s.isEqualWith=Ng,s.isError=Mi,s.isFinite=Bg,s.isFunction=ft,s.isInteger=go,s.isLength=vr,s.isMap=po,s.isMatch=Gg,s.isMatchWith=$g,s.isNaN=kg,s.isNative=qg,s.isNil=Hg,s.isNull=zg,s.isNumber=_o,s.isObject=Q,s.isObjectLike=j,s.isPlainObject=Se,s.isRegExp=Fi,s.isSafeInteger=Kg,s.isSet=vo,s.isString=wr,s.isSymbol=Pn,s.isTypedArray=Zt,s.isUndefined=Jg,s.isWeakMap=Yg,s.isWeakSet=Zg,s.join=Vc,s.kebabCase=Np,s.last=Dn,s.lastIndexOf=jc,s.lowerCase=Bp,s.lowerFirst=Gp,s.lt=Xg,s.lte=Qg,s.max=Md,s.maxBy=Fd,s.mean=Ud,s.meanBy=Dd,s.min=Nd,s.minBy=Bd,s.stubArray=qi,s.stubFalse=zi,s.stubObject=Cd,s.stubString=bd,s.stubTrue=Rd,s.multiply=Gd,s.nth=nh,s.noConflict=_d,s.noop=ki,s.now=pr,s.pad=$p,s.padEnd=kp,s.padStart=qp,s.parseInt=zp,s.random=Wp,s.reduce=rg,s.reduceRight=ig,s.repeat=Hp,s.replace=Kp,s.result=Ap,s.round=$d,s.runInContext=l,s.sample=sg,s.size=fg,s.snakeCase=Jp,s.some=lg,s.sortedIndex=oh,s.sortedIndexBy=ah,s.sortedIndexOf=fh,s.sortedLastIndex=lh,s.sortedLastIndexBy=ch,s.sortedLastIndexOf=hh,s.startCase=Zp,s.startsWith=Xp,s.subtract=kd,s.sum=qd,s.sumBy=zd,s.template=Qp,s.times=Td,s.toFinite=lt,s.toInteger=O,s.toLength=mo,s.toLower=Vp,s.toNumber=Nn,s.toSafeInteger=Vg,s.toString=q,s.toUpper=jp,s.trim=nd,s.trimEnd=td,s.trimStart=ed,s.truncate=rd,s.unescape=id,s.uniqueId=Ed,s.upperCase=ud,s.upperFirst=Ni,s.each=io,s.eachRight=uo,s.first=no,$i(s,function(){var n={};return Qn(s,function(t,e){z.call(s.prototype,e)||(n[e]=t)}),n}(),{chain:!1}),s.VERSION=w,On(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){s[n].placeholder=s}),On(["drop","take"],function(n,t){U.prototype[n]=function(e){e=e===i?1:an(O(e),0);var r=this.__filtered__&&!t?new U(this):this.clone();return r.__filtered__?r.__takeCount__=dn(e,r.__takeCount__):r.__views__.push({size:dn(e,Xn),type:n+(r.__dir__<0?"Right":"")}),r},U.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()}}),On(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==ji||e==na;U.prototype[n]=function(u){var o=this.clone();return o.__iteratees__.push({iteratee:R(u,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),On(["head","last"],function(n,t){var e="take"+(t?"Right":"");U.prototype[n]=function(){return this[e](1).value()[0]}}),On(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");U.prototype[n]=function(){return this.__filtered__?new U(this):this[e](1)}}),U.prototype.compact=function(){return this.filter(Cn)},U.prototype.find=function(n){return this.filter(n).head()},U.prototype.findLast=function(n){return this.reverse().find(n)},U.prototype.invokeMap=M(function(n,t){return typeof n=="function"?new U(this):this.map(function(e){return _e(e,n,t)})}),U.prototype.reject=function(n){return this.filter(_r(R(n)))},U.prototype.slice=function(n,t){n=O(n);var e=this;return e.__filtered__&&(n>0||t<0)?new U(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=O(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},U.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},U.prototype.toArray=function(){return this.take(Xn)},Qn(U.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),u=s[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);u&&(s.prototype[t]=function(){var a=this.__wrapped__,f=r?[1]:arguments,c=a instanceof U,d=f[0],_=c||L(a),v=function(F){var D=u.apply(s,dt([F],f));return r&&x?D[0]:D};_&&e&&typeof d=="function"&&d.length!=1&&(c=_=!1);var x=this.__chain__,b=!!this.__actions__.length,T=o&&!x,W=c&&!b;if(!o&&_){a=W?a:new U(this);var P=n.apply(a,f);return P.__actions__.push({func:hr,args:[v],thisArg:i}),new Mn(P,x)}return T&&W?n.apply(this,f):(P=this.thru(v),T?r?P.value()[0]:P.value():P)})}),On(["pop","push","shift","sort","splice","unshift"],function(n){var t=Ne[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);s.prototype[n]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(L(o)?o:[],u)}return this[e](function(a){return t.apply(L(a)?a:[],u)})}}),Qn(U.prototype,function(n,t){var e=s[t];if(e){var r=e.name+"";z.call(zt,r)||(zt[r]=[]),zt[r].push({name:t,func:e})}}),zt[ur(i,ht).name]=[{name:"wrapper",func:i}],U.prototype.clone=il,U.prototype.reverse=ul,U.prototype.value=sl,s.prototype.at=Fh,s.prototype.chain=Uh,s.prototype.commit=Dh,s.prototype.next=Nh,s.prototype.plant=Gh,s.prototype.reverse=$h,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=kh,s.prototype.first=s.prototype.head,fe&&(s.prototype[fe]=Bh),s},$t=Df();bt?((bt.exports=$t)._=$t,Gr._=$t):gn._=$t}).call(Qt)}(Ae,Ae.exports);var Do=Ae.exports;const No=Oo(Do);class Bo{constructor(p){E(this,"config");this.config=p}async complete(p,i){var w;await this.persist(p,{...i,success:!0}),(w=this.config.logger)==null||w.debug("Transaction completed:",p)}async fail(p,i){var w;await this.persist(p,{...i,success:!1}),(w=this.config.logger)==null||w.debug("Transaction failed:",{...p,...i})}async persist(p,i){await fetch(`${this.config.apiUrl}/transactions/${p.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Go{constructor(p,i){E(this,"transaction");E(this,"manager");this.transaction=p,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(p,i){var G;const w=this.transaction.functionCall;if(!w){await this.fail("No function call found");return}const m=w.name,C=w.args,A=p[m];if(!A){await this.fail(`Tool ${m} not found`);return}try{const B=No.get(i,"schema.config.parameters.properties",{}),vn=(B&&Object.keys(B).length>0?Object.keys(B):((G=A.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:G[1].split(",").map(Bn=>Bn.trim()).filter(Boolean))||[]).map(Bn=>C[Bn]),hn=await A.apply(null,vn);await this.complete(hn)}catch(B){await this.fail(`Error executing tool ${m}: ${B}`)}}async complete(p){await this.manager.complete(this.transaction,{success:!0,output:p,error:null})}async fail(p){await this.manager.fail(this.transaction,{success:!1,output:null,error:p})}}class Yi extends jt{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"notify",!0);E(this,"_tools");E(this,"_toolSchema",{});if(this.config=i,this.status="disconnected",this.autostart=!0,Array.isArray(i.tools)){this._tools={};for(const w of i.tools)w.schema&&w.implementation&&(this._tools[w.schema.name]=w.implementation,this._toolSchema[w.schema.name]=w)}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 w=new Bo(this.config),m=new Go(i,w);if(this.config.onTransaction)this.config.onTransaction(m);else{const C=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;m.invoke(this._tools,C)}}getTools(){return this._tools}}const ne=H.createContext(void 0);function $o(y){return new Promise((p,i)=>{const w=new FileReader;w.readAsDataURL(y),w.onload=()=>{const C=w.result.split(";base64,")[1];p(C)},w.onerror=m=>{i(m)}})}function Zi(y){const p={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 y){const w=p[i.getName()];if(w)return w(i)}return null}function ko({dev:y=!1,baseUrl:p,protocols:i,logger:w,children:m,session:C="new",...A}){const[G,B]=H.useState(!1),[fn,vn]=H.useState([]),[hn,Bn]=H.useState(C),[ln,Zn]=H.useState(new Map),tt=H.useRef(!1),rn=H.useMemo(()=>{if(Array.isArray(i))return i;if(typeof i=="object"&&i!==null){const un=y?"localhost:8000":p||"persona.applica.guru/api",$=y?"http":"https",nn=y?"ws":"wss";let V=Object.keys(i).map(sn=>{switch(sn){case"rest":const kn=i[sn];return kn===!0?new xr({apiUrl:`${$}://${un}`,apiKey:A.apiKey,agentId:A.agentId,logger:w}):typeof kn=="object"&&kn!==null?new xr(kn):null;case"webrtc":const Z=i[sn];return Z===!0?new Ar({webrtcUrl:`${nn}://${un}/webrtc`,apiKey:A.apiKey,agentId:A.agentId,logger:w}):typeof Z=="object"&&Z!==null?new Ar(Z):null;case"websocket":const gt=i[sn];return gt===!0?new Sr({webSocketUrl:`${nn}://${un}/websocket`,apiKey:A.apiKey,agentId:A.agentId,logger:w}):typeof gt=="object"&>!==null?new Sr(gt):null;default:throw new Error(`Unknown protocol: ${sn}`)}}).filter(sn=>sn!==null);return A.tools&&V.push(new Yi({apiUrl:`${$}://${un}`,apiKey:A.apiKey,agentId:A.agentId,tools:A.tools,logger:w})),V}throw new Error("Invalid protocols configuration")},[]);H.useEffect(()=>{if(tt.current)return;tt.current=!0,w==null||w.debug("Initializing protocols: ",rn.map($=>$.getName()));const un=Zi(rn);rn.forEach($=>{$.setSession(hn),$.clearListeners(),$.addStatusChangeListener(nn=>{w==null||w.debug(`${$.getName()} has notified new status: ${nn}`),ln.set($.getName(),nn),nn==="connected"&&(A.context&&$.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:A.context}}),A.tools&&Array.isArray(A.tools)&&$.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:A.tools.map(V=>V.schema)}}})),Zn(new Map(ln))}),$.addPacketListener(nn=>{if(nn.type==="message"){const V=nn.payload;vn(sn=>Ji([...sn,{...V,protocol:$.getName()}]))}else if(nn.type==="reasoning"){const V=nn.payload;let sn=V.thought;V.imageUrl&&(sn+=`
|
|
10
36
|
|
|
11
|
-
`);const kn={type:"reasoning",text:sn,role:"assistant",finishReason:"stop"};vn(Z=>Ji([...Z,{...kn,protocol:$.getName()}]))}else nn.type==="transaction"&&rn.filter(V=>V!==$).forEach(V=>V.onTransaction(nn.payload))}),$.autostart&&$.status==="disconnected"&&(w==null||w.debug(`Connecting to protocol: ${$.getName()}`),$.connect(hn))})},[hn,rn,w,ln]);const ht=async un=>{var kn;if(((kn=un.content[0])==null?void 0:kn.type)!=="text")throw new Error("Only text messages are supported");if(!rn.some(Z=>Z.getName()!=="transaction"&&Z.status==="connected")){vn(Z=>[...Z,{role:"assistant",type:"text",text:"No protocol is connected."}]);return}const nn=un.content[0].text;vn(Z=>[...Z,{role:"user",type:"text",text:nn}]),B(!0);const V=rn.sort((Z,gt)=>gt.getPriority()-Z.getPriority()).find(Z=>Z.status==="connected"),sn=[];if(un.attachments)for(const Z of un.attachments)Z.contentType.startsWith("image/")&&Z.file&&sn.push({role:"user",image:{contentType:Z.contentType,content:await $o(Z.file)},text:"",type:"text"});un.content&&sn.push({role:"user",text:un.content[0].text,type:"text"}),w==null||w.debug("Sending message:",sn),await(V==null?void 0:V.sendPacket({type:"request",payload:sn})),B(!1)},be=H.useCallback(()=>(B(!1),vn([]),Bn("new"),Promise.resolve()),[]),Gn=H.useCallback(()=>Promise.resolve(),[]),Ct=H.useCallback(()=>fn,[fn]),$n=nt.useExternalStoreRuntime({isRunning:G,messages:fn,convertMessage:Fo,onNew:ht,onCancel:be,onReload:Gn,adapters:{attachments:new nt.CompositeAttachmentAdapter([new nt.SimpleImageAttachmentAdapter])}});return yr.jsx(ne.Provider,{value:{protocols:rn,protocolsStatus:ln,getMessages:Ct},children:yr.jsx(nt.AssistantRuntimeProvider,{runtime:$n,children:m})})}function qo({children:y,...p}){return yr.jsx(ko,{...p,children:y})}function zo(){const y=H.useContext(ne);if(!y)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return y}function Xi(y){const p=H.useContext(ne);if(!p)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=p.protocols.find(m=>m.getName()===y);if(!i)return null;const w=p.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:w||i.status}}function Ho(){const y=H.useContext(ne);if(!y)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return Zi(y.protocols)}function Ko(){return Xi("webrtc")}function Jo(){const y=H.useContext(ne);if(!y)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return y.getMessages()}class Yo{constructor(){E(this,"prefix","[Persona]")}log(p,...i){console.log(`${this.prefix} - ${p}`,...i)}info(p,...i){console.info(`${this.prefix} - ${p}`,...i)}warn(p,...i){console.warn(`${this.prefix} - ${p}`,...i)}error(p,...i){console.error(`${this.prefix} - ${p}`,...i)}debug(p,...i){console.debug(`${this.prefix} - ${p}`,...i)}}function At(y,p,i){return{type:y,description:p,...i}}function Qi(y){const p=Object.entries(y.parameters).filter(([i,w])=>w.required).map(([i])=>i);return{type:"local",name:y.name,description:y.description,config:{timeout:y.timeout||60,parameters:{type:"object",title:y.title||`${y.name} parameters`,required:p,properties:y.parameters},output:{type:"object",title:`${y.name} output`,properties:y.output}}}}function Ce(y){return{schema:Qi(y),implementation:y.implementation}}function Vi(y,p,i,w,m,C){const A={name:y,description:p,title:C==null?void 0:C.title,timeout:C==null?void 0:C.timeout,parameters:w,output:m,implementation:i};return Ce(A)}const Zo=Vi("sum","Sum two numbers",function(p,i){return{result:p+i}},{a:At("number","First number to sum",{required:!0}),b:At("number","Second number to sum",{required:!0})},{result:At("number","Sum of two numbers")}),Xo=Ce({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:At("number","First number to sum"),b:At("number","Seconth number to sum")},output:{result:At("number","Sum of two numbers")},implementation:function(p,i){return{result:p+i}}});function Qo(y){const p=[],i={};return y.forEach(w=>{const{schema:m,implementation:C}=Ce(w);p.push(m),i[w.name]=C}),{schemas:p,implementations:i}}function Vo(y,p){const{required:i,properties:w}=p.config.parameters;for(const m of i)if(!(m in y))throw new Error(`Missing required parameter: ${m}`);for(const[m,C]of Object.entries(y)){const A=w[m];if(A){if(A.type==="number"&&typeof C!="number")throw new Error(`Parameter ${m} should be a number`);if(A.type==="string"&&typeof C!="string")throw new Error(`Parameter ${m} should be a string`);if(A.type==="boolean"&&typeof C!="boolean")throw new Error(`Parameter ${m} should be a boolean`)}}return!0}N.PersonaConsoleLogger=Yo,N.PersonaProtocolBase=jt,N.PersonaRESTProtocol=xr,N.PersonaRuntimeProvider=qo,N.PersonaTransactionProtocol=Yi,N.PersonaWebRTCProtocol=Ar,N.PersonaWebSocketProtocol=Sr,N.createParameter=At,N.createTool=Ce,N.createToolFromFunction=Vi,N.createToolRegistry=Qo,N.generateToolSchema=Qi,N.navigateToToolExample=Xo,N.sumTool=Zo,N.usePersonaRuntime=zo,N.usePersonaRuntimeEndpoint=Ho,N.usePersonaRuntimeMessages=Jo,N.usePersonaRuntimeProtocol=Xi,N.usePersonaRuntimeWebRTCProtocol=Ko,N.validateToolParameters=Vo,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
|
12
38
|
//# sourceMappingURL=bundle.umd.js.map
|