@applica-software-guru/persona-chat-sdk 0.1.113 → 0.1.115
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/.eslintrc.cjs +7 -0
- package/dist/bundle.cjs.js +14 -14
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +2867 -2633
- package/dist/bundle.es.js.map +1 -1
- package/dist/bundle.iife.js +17 -17
- package/dist/bundle.iife.js.map +1 -1
- package/dist/bundle.umd.js +14 -14
- package/dist/bundle.umd.js.map +1 -1
- package/dist/protocol/rest.d.ts +1 -0
- package/dist/protocol/rest.d.ts.map +1 -1
- package/dist/runtime/context.d.ts +11 -1
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/handlers.d.ts +7 -6
- package/dist/runtime/handlers.d.ts.map +1 -1
- package/dist/runtime/listeners.d.ts +6 -3
- package/dist/runtime/listeners.d.ts.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/types.d.ts +68 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/playground/src/hooks/theme.ts +0 -1
- package/playground/src/tools.ts +4 -3
- package/src/protocol/rest.ts +134 -21
- package/src/runtime/context.ts +25 -1
- package/src/runtime/handlers.ts +70 -32
- package/src/runtime/listeners.ts +190 -18
- package/src/runtime.tsx +56 -26
- package/src/types.ts +88 -3
package/dist/bundle.cjs.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";var Ag=Object.defineProperty;var bg=(l,a,i)=>a in l?Ag(l,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):l[a]=i;var E=(l,a,i)=>bg(l,typeof a!="symbol"?a+"":a,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Xi=require("react/jsx-runtime"),Q=require("react"),Ce=require("@assistant-ui/react");function Cg(l){return new Promise((a,i)=>{const p=new FileReader;p.onload=()=>a(p.result),p.onerror=g=>i(g),p.readAsDataURL(l)})}class Pg{constructor(){E(this,"accept","*")}async add(a){return{id:a.file.name,type:"file",name:a.file.name,contentType:a.file.type||"application/octet-stream",file:a.file,status:{type:"requires-action",reason:"composer-send"}}}async send(a){const p=(await Cg(a.file)).split(";base64,")[1];return{...a,status:{type:"complete"},content:[{type:"file",data:p,mimeType:a.contentType||"application/octet-stream"}]}}async remove(a){}}function Qi(l){if(l==null||typeof l=="string")return l;if(Array.isArray(l))return l.map(Qi);if(typeof l=="object"){const a=l;return typeof a.contentType=="string"&&typeof a.content=="string"?{type:"image",contentType:a.contentType,note:"image content delivered separately"}:typeof a.name=="string"&&typeof a.contentType=="string"?{type:"file",name:a.name,url:a.url??null,contentType:a.contentType}:Object.fromEntries(Object.entries(a).map(([i,p])=>[i,Qi(p)]))}return l}let Ig=0;function Rg(){return`msg_${Date.now()}_${Ig++}`}function Eg(l){return l.thought&&(l={...l,type:"reasoning"}),l.id?l.createdAt?l:{...l,createdAt:new Date}:{...l,id:Rg(),createdAt:l.createdAt||new Date}}function Tg(l){return l.filter(a=>!(a.role==="assistant"&&!a.functionCalls&&!a.file&&!a.image&&(!a.text||a.text.trim()==="")))}function Bn(l){const a=[];let i=null;for(let g of l)if(g=Eg(g),g.type!=="transaction")if(g.file){i&&(a.push(i),i=null),a.push(g);continue}else g.functionCalls?(i&&(i.role==="assistant"&&(!i.text||i.text.trim()==="")&&!i.file&&!i.image||a.push(i)),a.push(g),i=null):g.functionResponse?a[a.length-1]={...a[a.length-1],functionResponse:g.functionResponse}:i&&g.type===i.type&&g.protocol===i.protocol&&i.role===g.role&&(g.id===i.id||!i.finishReason)?(i.text+=g.text,i.file=i.file||g.file,i.finishReason=g.finishReason||i.finishReason,i.id=i.id||g.id,i.sources=i.sources?[...i.sources||[],...g.sources||[]]:g.sources):(i&&a.push(i),i={...g,text:g.file?"":g.text,finishReason:g.file?void 0:g.finishReason});return i&&a.push(i),Tg(a)}function Og(l){var g,v,x;const a=l.file?[{type:"file",data:l.file.url,mimeType:l.file.contentType}]:[];let i;if((l.role==="assistant"||l.role==="function")&&(l.status?i=l.status:l.finishReason==="stop"?i={type:"complete",reason:"stop"}:l.finishReason==="function_call"?i={type:"complete",reason:"stop"}:l.finishReason||(i=void 0)),l.role==="function"){const T={id:l.id,role:"assistant",createdAt:l.createdAt,content:((g=l.functionCalls)==null?void 0:g.map(C=>{var K;return{type:"tool-call",toolName:C.name,toolCallId:C.id||`tool_${Date.now()}`,args:C.args,result:Qi((K=l.functionResponse)==null?void 0:K.result)}}))??[],metadata:{...l.metadata,custom:{protocol:l.protocol,sessionId:l.sessionId,sources:l.sources,...(v=l.metadata)==null?void 0:v.custom}}};return i?{...T,status:i}:T}const p={id:l.id,role:l.role,createdAt:l.createdAt,content:l.type==="reasoning"?[{type:"reasoning",text:l.text},...a]:[{type:"text",text:l.text},...a],metadata:{...l.metadata,custom:{protocol:l.protocol,sessionId:l.sessionId,sources:l.sources,type:l.type,...(x=l.metadata)==null?void 0:x.custom}}};return l.role==="assistant"&&i?{...p,status:i}:p}class Ie{constructor(){E(this,"statusChangeCallbacks",[]);E(this,"messageCallbacks",[])}addStatusChangeListener(a){this.statusChangeCallbacks.push(a)}addPacketListener(a){this.messageCallbacks.push(a)}async syncSession(a){this.session=a}async notifyPacket(a){this.messageCallbacks.forEach(i=>i(a))}async notifyPackets(a){a.forEach(i=>{this.messageCallbacks.forEach(p=>p(i))})}async setSession(a){this.session=a}async setStatus(a){const i=this.status!==a;this.status=a,i&&this.statusChangeCallbacks.forEach(p=>p(a))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}setAgentContext(a){return this.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:a}})}onTransaction(a){}}class Vi extends Ie{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 C,K,Z,A,D;const{apiUrl:p,apiKey:g,agentId:v}=this.config,x=this.session??"new";if(i.type==="command"&&((C=i==null?void 0:i.payload)==null?void 0:C.command)=="set_initial_context"){this.context=(K=i==null?void 0:i.payload)==null?void 0:K.arguments;return}else if(i.type==="command"&&((Z=i==null?void 0:i.payload)==null?void 0:Z.command)=="set_local_tools"){const P=(A=i==null?void 0:i.payload)==null?void 0:A.arguments.tools;(P==null?void 0:P.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const T=i.payload;try{const N=await(await fetch(`${p}/sessions/${x}/messages`,{body:JSON.stringify({agentId:v,userMessage:T,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":g}})).json();this.notifyPackets(N.response.messages.map(j=>({type:"message",payload:j})))}catch(P){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(D=this.config.logger)==null||D.error("Error sending packet:",P)}}}class ji extends Ie{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 p;(p=this.config.logger)==null||p.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var C;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const p=i||this.session||"new";(C=this.config.logger)==null||C.debug("Connecting to WebSocket with sessionId:",p);const g=encodeURIComponent(this.config.apiKey),v=this.config.agentId,x=this.config.userId||"anonymous",T=`${this.config.webSocketUrl}?sessionCode=${p}&agentId=${v}&apiKey=${g}&userId=${encodeURIComponent(x)}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(T),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",K=>{const Z=JSON.parse(K.data);this.notifyPacket(Z)}),this.webSocket.addEventListener("close",K=>{var Z;this.setStatus("disconnected"),this.webSocket=null,K.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(Z=this.config.logger)==null||Z.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var K;this.setStatus("disconnected"),this.webSocket=null,(K=this.config.logger)==null||K.error("WebSocket connection error")}),Promise.resolve(p)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(1e3,"Normal closure"),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(i){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(i)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class Lg{constructor(a){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=a}async connect(a){var p;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(g){(p=this.config.logger)==null||p.error("Error accessing microphone:",g);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(g=>{this.pc.addTrack(g,this.localStream)}),this.pc.ontrack=g=>{g.streams[0].getTracks().forEach(x=>{this.remoteStream.addTrack(x)}),this.audioCtx||this._startAnalyzers();const v=new Audio;v.srcObject=this.remoteStream,v.play().catch(x=>{var T;(T=this.config.logger)==null||T.error("Error playing remote audio:",x)})},this.pc.onicecandidate=g=>{var v;g.candidate&&((v=this.ws)==null?void 0:v.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:g.candidate}}))},this.pc.ondatachannel=g=>{const v=g.channel;v.onmessage=x=>{this.messageCallbacks.forEach(T=>{T(x)})},v.onopen=()=>{var x;for(;this.queuedMessages.length>0;){const T=this.queuedMessages.shift();T&&(v.send(JSON.stringify(T)),(x=this.config.logger)==null||x.info("Sent queued message:",T))}}};const i=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${i}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var T,C;const g=await this.pc.createOffer();await this.pc.setLocalDescription(g);const v={apiKey:this.config.apiKey,agentId:this.config.agentId,userId:this.config.userId||"anonymous",sessionCode:a};(T=this.config.logger)==null||T.debug("Opening connection to WebRTC server: ",v);const x={type:"OFFER",src:((C=crypto.randomUUID)==null?void 0:C.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:g.sdp,type:g.type},connectionId:(Date.now()%1e6).toString(),metadata:v}};this.ws.send(JSON.stringify(x))},this.ws.onmessage=async g=>{var x;const v=JSON.parse(g.data);if(v.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(v.payload.sdp));else if(v.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(v.payload.candidate))}catch(T){(x=this.config.logger)==null||x.error("Error adding ICE candidate:",T)}},this.ws.onclose=g=>{g.code!==1e3&&this.errorCallbacks.forEach(v=>{v("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var a;this.isConnected&&(this.isConnected=!1,((a=this.ws)==null?void 0:a.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(a){this.visualizerCallbacks.push(a)}addMessageCallback(a){this.messageCallbacks.push(a)}addErrorCallback(a){this.errorCallbacks.push(a)}createDataChannel(a="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(a),this.dataChannel.onopen=()=>{var i,p;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const g=this.queuedMessages.shift();g&&(this.dataChannel.send(JSON.stringify(g)),(p=this.config.logger)==null||p.info("Sent queued message:",g))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(p=>{p(i)})})}sendPacket(a){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(a);return}this.dataChannel.send(JSON.stringify(a)),(i=this.config.logger)==null||i.info("Sent message:",a)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const a=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,a.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const p=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const g=new Uint8Array(this.localAnalyser.frequencyBinCount),v=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(g),this.remoteAnalyser.getByteFrequencyData(v);const x=g.reduce((C,K)=>C+K,0)/g.length,T=v.reduce((C,K)=>C+K,0)/v.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(C=>{C({localAmplitude:x,remoteAmplitude:T})}),this.analyzerFrame=requestAnimationFrame(p)};this.analyzerFrame=requestAnimationFrame(p)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class ts extends Ie{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 Lg(i),this.webRTCClient.addMessageCallback(p=>{const g=JSON.parse(p.data);this.notifyPacket(g)}),this.webRTCClient.addErrorCallback(p=>{var g;(g=this.config.logger)==null||g.error("WebRTC error:",p),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:p}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(i){super.syncSession(i),this.status==="connected"&&(await this.disconnect(),await this.connect(i))}async connect(i){var p;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(p=this.config.logger)==null||p.debug("Connecting to WebRTC with sessionId:",this.session),await this.webRTCClient.connect(this.session),this.setStatus("connected"),await this.webRTCClient.createDataChannel(),this.session)}async disconnect(){var i,p,g;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(g=(p=this.config)==null?void 0:p.logger)==null||g.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var Pe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wg(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Ar={exports:{}};/**
|
|
1
|
+
"use strict";var bg=Object.defineProperty;var Ag=(f,o,i)=>o in f?bg(f,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):f[o]=i;var O=(f,o,i)=>Ag(f,typeof o!="symbol"?o+"":o,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vi=require("react/jsx-runtime"),z=require("react"),Rn=require("@assistant-ui/react");function Pg(f){return new Promise((o,i)=>{const h=new FileReader;h.onload=()=>o(h.result),h.onerror=g=>i(g),h.readAsDataURL(f)})}class Cg{constructor(){O(this,"accept","*")}async add(o){return{id:o.file.name,type:"file",name:o.file.name,contentType:o.file.type||"application/octet-stream",file:o.file,status:{type:"requires-action",reason:"composer-send"}}}async send(o){const h=(await Pg(o.file)).split(";base64,")[1];return{...o,status:{type:"complete"},content:[{type:"file",data:h,mimeType:o.contentType||"application/octet-stream"}]}}async remove(o){}}function ji(f){if(f==null||typeof f=="string")return f;if(Array.isArray(f))return f.map(ji);if(typeof f=="object"){const o=f;return typeof o.contentType=="string"&&typeof o.content=="string"?{type:"image",contentType:o.contentType,note:"image content delivered separately"}:typeof o.name=="string"&&typeof o.contentType=="string"?{type:"file",name:o.name,url:o.url??null,contentType:o.contentType}:Object.fromEntries(Object.entries(o).map(([i,h])=>[i,ji(h)]))}return f}let Rg=0;function Ig(){return`msg_${Date.now()}_${Rg++}`}function Eg(f){return f.thought&&(f={...f,type:"reasoning"}),f.id?f.createdAt?f:{...f,createdAt:new Date}:{...f,id:Ig(),createdAt:f.createdAt||new Date}}function Tg(f){return f.filter(o=>!(o.role==="assistant"&&!o.functionCalls&&!o.file&&!o.image&&(!o.text||o.text.trim()==="")))}function Be(f){const o=[];let i=null;for(let g of f)if(g=Eg(g),g.type!=="transaction")if(g.file){i&&(o.push(i),i=null),o.push(g);continue}else g.functionCalls?(i&&(i.role==="assistant"&&(!i.text||i.text.trim()==="")&&!i.file&&!i.image||o.push(i)),o.push(g),i=null):g.functionResponse?o[o.length-1]={...o[o.length-1],functionResponse:g.functionResponse}:i&&g.type===i.type&&g.protocol===i.protocol&&i.role===g.role&&(g.id===i.id||!i.finishReason)?(i.text+=g.text,i.file=i.file||g.file,i.finishReason=g.finishReason||i.finishReason,i.id=i.id||g.id,i.sources=i.sources?[...i.sources||[],...g.sources||[]]:g.sources):(i&&o.push(i),i={...g,text:g.file?"":g.text,finishReason:g.file?void 0:g.finishReason});return i&&o.push(i),Tg(o)}function Og(f){var g,y,x;const o=f.file?[{type:"file",data:f.file.url,mimeType:f.file.contentType}]:[];let i;if((f.role==="assistant"||f.role==="function")&&(f.status?i=f.status:f.finishReason==="stop"?i={type:"complete",reason:"stop"}:f.finishReason==="function_call"?i={type:"complete",reason:"stop"}:f.finishReason||(i=void 0)),f.role==="function"){const I={id:f.id,role:"assistant",createdAt:f.createdAt,content:((g=f.functionCalls)==null?void 0:g.map(b=>{var B;return{type:"tool-call",toolName:b.name,toolCallId:b.id||`tool_${Date.now()}`,args:b.args,result:ji((B=f.functionResponse)==null?void 0:B.result)}}))??[],metadata:{...f.metadata,custom:{protocol:f.protocol,sessionId:f.sessionId,sources:f.sources,...(y=f.metadata)==null?void 0:y.custom}}};return i?{...I,status:i}:I}const h={id:f.id,role:f.role,createdAt:f.createdAt,content:f.type==="reasoning"?[{type:"reasoning",text:f.text},...o]:[{type:"text",text:f.text},...o],metadata:{...f.metadata,custom:{protocol:f.protocol,sessionId:f.sessionId,sources:f.sources,type:f.type,...(x=f.metadata)==null?void 0:x.custom}}};return f.role==="assistant"&&i?{...h,status:i}:h}class En{constructor(){O(this,"statusChangeCallbacks",[]);O(this,"messageCallbacks",[])}addStatusChangeListener(o){this.statusChangeCallbacks.push(o)}addPacketListener(o){this.messageCallbacks.push(o)}async syncSession(o){this.session=o}async notifyPacket(o){this.messageCallbacks.forEach(i=>i(o))}async notifyPackets(o){o.forEach(i=>{this.messageCallbacks.forEach(h=>h(i))})}async setSession(o){this.session=o}async setStatus(o){const i=this.status!==o;this.status=o,i&&this.statusChangeCallbacks.forEach(h=>h(o))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}setAgentContext(o){return this.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:o}})}onTransaction(o){}}class ts extends En{constructor(i){super();O(this,"status");O(this,"autostart");O(this,"session");O(this,"config");O(this,"notify",!0);O(this,"context",{});O(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}buildHeaders(){return{"Content-Type":"application/json","x-persona-apikey":this.config.apiKey}}async sendPacket(i){var I,b,B,Y,P,U;const{apiUrl:h,agentId:g}=this.config,y=this.session??"new";if(i.type==="command"){const A=i.payload;if(A.command==="set_initial_context"){this.context=A.arguments;return}if(A.command==="set_local_tools"){const T=(I=A.arguments)==null?void 0:I.tools;T!=null&&T.length&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}if(A.command==="cancel"){try{await fetch(`${h}/sessions/${encodeURIComponent(String(y))}/cancel`,{method:"POST",headers:this.buildHeaders()}),this.notifyPacket({type:"agent_end",payload:{sessionId:String(y),stopReason:"cancelled",totalTurns:0}})}catch(T){(b=this.config.logger)==null||b.error("Error cancelling via REST:",T)}return}if(A.command==="steer"){const T=((B=A.arguments)==null?void 0:B.text)||"";if(!T)return;try{const ct=await(await fetch(`${h}/sessions/${encodeURIComponent(String(y))}/steer`,{method:"POST",headers:this.buildHeaders(),body:JSON.stringify({text:T})})).json();this.notifyPacket({type:"steer_accepted",payload:ct})}catch(J){(Y=this.config.logger)==null||Y.error("Error steering via REST:",J)}return}if(A.command==="get_agent_state"){try{const J=await(await fetch(`${h}/sessions/${encodeURIComponent(String(y))}/agent-state`,{method:"GET",headers:this.buildHeaders()})).json();this.notifyPacket({type:"command",payload:{command:"get_agent_state",arguments:J}})}catch(T){(P=this.config.logger)==null||P.error("Error getting agent state via REST:",T)}return}return}if(i.type!=="request")return;const x=i.payload;this.notifyPacket({type:"agent_start",payload:{sessionId:String(y),agentId:g,timestamp:new Date().toISOString()}});try{const T=await(await fetch(`${h}/sessions/${encodeURIComponent(String(y))}/messages`,{body:JSON.stringify({agentId:g,userMessage:x,initialContext:this.context,tools:this.tools}),method:"POST",headers:this.buildHeaders()})).json();this.notifyPackets(T.response.messages.map(J=>({type:"message",payload:J}))),this.notifyPacket({type:"agent_end",payload:{sessionId:String(y),stopReason:"completed",totalTurns:1}}),T.sessionId&&T.sessionId!==y&&(this.session=T.sessionId,this.notifyPacket({type:"command",payload:{command:"set_initial_context",arguments:{sessionId:T.sessionId}}}))}catch(A){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),this.notifyPacket({type:"agent_end",payload:{sessionId:String(y),stopReason:"error",totalTurns:0,errorMessage:String(A)}}),(U=this.config.logger)==null||U.error("Error sending REST packet:",A)}}}class es extends En{constructor(i){super();O(this,"status");O(this,"autostart");O(this,"session");O(this,"config");O(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 h;(h=this.config.logger)==null||h.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var b;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const h=i||this.session||"new";(b=this.config.logger)==null||b.debug("Connecting to WebSocket with sessionId:",h);const g=encodeURIComponent(this.config.apiKey),y=this.config.agentId,x=this.config.userId||"anonymous",I=`${this.config.webSocketUrl}?sessionCode=${h}&agentId=${y}&apiKey=${g}&userId=${encodeURIComponent(x)}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(I),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",B=>{const Y=JSON.parse(B.data);this.notifyPacket(Y)}),this.webSocket.addEventListener("close",B=>{var Y;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."}}),(Y=this.config.logger)==null||Y.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(h)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(1e3,"Normal closure"),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(i){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(i)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class Lg{constructor(o){O(this,"config");O(this,"pc",null);O(this,"ws",null);O(this,"localStream",null);O(this,"remoteStream",new MediaStream);O(this,"audioCtx",null);O(this,"localAnalyser",null);O(this,"remoteAnalyser",null);O(this,"analyzerFrame",null);O(this,"dataChannel",null);O(this,"isConnected",!1);O(this,"visualizerCallbacks",[]);O(this,"messageCallbacks",[]);O(this,"errorCallbacks",[]);O(this,"queuedMessages",[]);this.config=o}async connect(o){var h;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(g){(h=this.config.logger)==null||h.error("Error accessing microphone:",g);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(g=>{this.pc.addTrack(g,this.localStream)}),this.pc.ontrack=g=>{g.streams[0].getTracks().forEach(x=>{this.remoteStream.addTrack(x)}),this.audioCtx||this._startAnalyzers();const y=new Audio;y.srcObject=this.remoteStream,y.play().catch(x=>{var I;(I=this.config.logger)==null||I.error("Error playing remote audio:",x)})},this.pc.onicecandidate=g=>{var y;g.candidate&&((y=this.ws)==null?void 0:y.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:g.candidate}}))},this.pc.ondatachannel=g=>{const y=g.channel;y.onmessage=x=>{this.messageCallbacks.forEach(I=>{I(x)})},y.onopen=()=>{var x;for(;this.queuedMessages.length>0;){const I=this.queuedMessages.shift();I&&(y.send(JSON.stringify(I)),(x=this.config.logger)==null||x.info("Sent queued message:",I))}}};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 I,b;const g=await this.pc.createOffer();await this.pc.setLocalDescription(g);const y={apiKey:this.config.apiKey,agentId:this.config.agentId,userId:this.config.userId||"anonymous",sessionCode:o};(I=this.config.logger)==null||I.debug("Opening connection to WebRTC server: ",y);const x={type:"OFFER",src:((b=crypto.randomUUID)==null?void 0:b.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:g.sdp,type:g.type},connectionId:(Date.now()%1e6).toString(),metadata:y}};this.ws.send(JSON.stringify(x))},this.ws.onmessage=async g=>{var x;const y=JSON.parse(g.data);if(y.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(y.payload.sdp));else if(y.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(y.payload.candidate))}catch(I){(x=this.config.logger)==null||x.error("Error adding ICE candidate:",I)}},this.ws.onclose=g=>{g.code!==1e3&&this.errorCallbacks.forEach(y=>{y("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var o;this.isConnected&&(this.isConnected=!1,((o=this.ws)==null?void 0:o.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(o){this.visualizerCallbacks.push(o)}addMessageCallback(o){this.messageCallbacks.push(o)}addErrorCallback(o){this.errorCallbacks.push(o)}createDataChannel(o="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(o),this.dataChannel.onopen=()=>{var i,h;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const g=this.queuedMessages.shift();g&&(this.dataChannel.send(JSON.stringify(g)),(h=this.config.logger)==null||h.info("Sent queued message:",g))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(h=>{h(i)})})}sendPacket(o){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(o);return}this.dataChannel.send(JSON.stringify(o)),(i=this.config.logger)==null||i.info("Sent message:",o)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const o=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,o.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const h=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const g=new Uint8Array(this.localAnalyser.frequencyBinCount),y=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(g),this.remoteAnalyser.getByteFrequencyData(y);const x=g.reduce((b,B)=>b+B,0)/g.length,I=y.reduce((b,B)=>b+B,0)/y.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(b=>{b({localAmplitude:x,remoteAmplitude:I})}),this.analyzerFrame=requestAnimationFrame(h)};this.analyzerFrame=requestAnimationFrame(h)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class ns extends En{constructor(i){super();O(this,"status");O(this,"session");O(this,"autostart");O(this,"config");O(this,"webRTCClient");this.config=i,this.status="disconnected",this.session=null,this.autostart=(i==null?void 0:i.autostart)??!1,this.webRTCClient=new Lg(i),this.webRTCClient.addMessageCallback(h=>{const g=JSON.parse(h.data);this.notifyPacket(g)}),this.webRTCClient.addErrorCallback(h=>{var g;(g=this.config.logger)==null||g.error("WebRTC error:",h),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:h}})})}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 h;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(h=this.config.logger)==null||h.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,h,g;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(g=(h=this.config)==null?void 0:h.logger)==null||g.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Dg(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var br={exports:{}};/**
|
|
2
2
|
* @license
|
|
3
3
|
* Lodash <https://lodash.com/>
|
|
4
4
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
5
5
|
* Released under MIT license <https://lodash.com/license>
|
|
6
6
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
7
7
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
8
|
-
*/Ar.exports;(function(l,a){(function(){var i,p="4.17.21",g=200,v="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",x="Expected a function",T="Invalid `variable` option passed into `_.template`",C="__lodash_hash_undefined__",K=500,Z="__lodash_placeholder__",A=1,D=2,P=4,N=1,j=2,k=1,vn=2,sn=4,ht=8,gt=16,Gt=32,Rn=64,Ut=128,jt=256,Rt=512,Re=30,ie="...",Et=800,Ee=16,En=1,Te=2,ct=3,un=1/0,tn=9007199254740991,Cr=17976931348623157e292,Kn=NaN,Nt=4294967295,Pr=Nt-1,Oe=Nt>>>1,Ir=[["ary",Ut],["bind",k],["bindKey",vn],["curry",ht],["curryRight",gt],["flip",Rt],["partial",Gt],["partialRight",Rn],["rearg",jt]],wn="[object Arguments]",$="[object Array]",ot="[object AsyncFunction]",St="[object Boolean]",wt="[object Date]",Le="[object DOMException]",At="[object Error]",We="[object Function]",ns="[object GeneratorFunction]",Jt="[object Map]",se="[object Number]",Bo="[object Null]",on="[object Object]",es="[object Promise]",Mo="[object Proxy]",ue="[object RegExp]",Zt="[object Set]",oe="[object String]",De="[object Symbol]",Ko="[object Undefined]",ae="[object WeakMap]",qo="[object WeakSet]",fe="[object ArrayBuffer]",qn="[object DataView]",Rr="[object Float32Array]",Er="[object Float64Array]",Tr="[object Int8Array]",Or="[object Int16Array]",Lr="[object Int32Array]",Wr="[object Uint8Array]",Dr="[object Uint8ClampedArray]",Fr="[object Uint16Array]",Ur="[object Uint32Array]",ko=/\b__p \+= '';/g,Ho=/\b(__p \+=) '' \+/g,zo=/(__e\(.*?\)|\b__t\)) \+\n'';/g,rs=/&(?:amp|lt|gt|quot|#39);/g,is=/[&<>"']/g,Go=RegExp(rs.source),Jo=RegExp(is.source),Zo=/<%-([\s\S]+?)%>/g,Yo=/<%([\s\S]+?)%>/g,ss=/<%=([\s\S]+?)%>/g,Xo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qo=/^\w*$/,Vo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Nr=/[\\^$.*+?()[\]{}|]/g,jo=RegExp(Nr.source),$r=/^\s+/,ta=/\s/,na=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ea=/\{\n\/\* \[wrapped with (.+)\] \*/,ra=/,? & /,ia=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,sa=/[()=,{}\[\]\/\s]/,ua=/\\(\\)?/g,oa=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,us=/\w*$/,aa=/^[-+]0x[0-9a-f]+$/i,fa=/^0b[01]+$/i,ca=/^\[object .+?Constructor\]$/,la=/^0o[0-7]+$/i,ha=/^(?:0|[1-9]\d*)$/,da=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Fe=/($^)/,pa=/['\n\r\u2028\u2029\\]/g,Ue="\\ud800-\\udfff",ga="\\u0300-\\u036f",_a="\\ufe20-\\ufe2f",va="\\u20d0-\\u20ff",os=ga+_a+va,as="\\u2700-\\u27bf",fs="a-z\\xdf-\\xf6\\xf8-\\xff",wa="\\xac\\xb1\\xd7\\xf7",ya="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ma="\\u2000-\\u206f",xa=" \\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",cs="A-Z\\xc0-\\xd6\\xd8-\\xde",ls="\\ufe0e\\ufe0f",hs=wa+ya+ma+xa,Br="['’]",Sa="["+Ue+"]",ds="["+hs+"]",Ne="["+os+"]",ps="\\d+",Aa="["+as+"]",gs="["+fs+"]",_s="[^"+Ue+hs+ps+as+fs+cs+"]",Mr="\\ud83c[\\udffb-\\udfff]",ba="(?:"+Ne+"|"+Mr+")",vs="[^"+Ue+"]",Kr="(?:\\ud83c[\\udde6-\\uddff]){2}",qr="[\\ud800-\\udbff][\\udc00-\\udfff]",kn="["+cs+"]",ws="\\u200d",ys="(?:"+gs+"|"+_s+")",Ca="(?:"+kn+"|"+_s+")",ms="(?:"+Br+"(?:d|ll|m|re|s|t|ve))?",xs="(?:"+Br+"(?:D|LL|M|RE|S|T|VE))?",Ss=ba+"?",As="["+ls+"]?",Pa="(?:"+ws+"(?:"+[vs,Kr,qr].join("|")+")"+As+Ss+")*",Ia="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ra="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",bs=As+Ss+Pa,Ea="(?:"+[Aa,Kr,qr].join("|")+")"+bs,Ta="(?:"+[vs+Ne+"?",Ne,Kr,qr,Sa].join("|")+")",Oa=RegExp(Br,"g"),La=RegExp(Ne,"g"),kr=RegExp(Mr+"(?="+Mr+")|"+Ta+bs,"g"),Wa=RegExp([kn+"?"+gs+"+"+ms+"(?="+[ds,kn,"$"].join("|")+")",Ca+"+"+xs+"(?="+[ds,kn+ys,"$"].join("|")+")",kn+"?"+ys+"+"+ms,kn+"+"+xs,Ra,Ia,ps,Ea].join("|"),"g"),Da=RegExp("["+ws+Ue+os+ls+"]"),Fa=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ua=["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"],Na=-1,nt={};nt[Rr]=nt[Er]=nt[Tr]=nt[Or]=nt[Lr]=nt[Wr]=nt[Dr]=nt[Fr]=nt[Ur]=!0,nt[wn]=nt[$]=nt[fe]=nt[St]=nt[qn]=nt[wt]=nt[At]=nt[We]=nt[Jt]=nt[se]=nt[on]=nt[ue]=nt[Zt]=nt[oe]=nt[ae]=!1;var tt={};tt[wn]=tt[$]=tt[fe]=tt[qn]=tt[St]=tt[wt]=tt[Rr]=tt[Er]=tt[Tr]=tt[Or]=tt[Lr]=tt[Jt]=tt[se]=tt[on]=tt[ue]=tt[Zt]=tt[oe]=tt[De]=tt[Wr]=tt[Dr]=tt[Fr]=tt[Ur]=!0,tt[At]=tt[We]=tt[ae]=!1;var $a={À:"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"},Ba={"&":"&","<":"<",">":">",'"':""","'":"'"},Ma={"&":"&","<":"<",">":">",""":'"',"'":"'"},Ka={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},qa=parseFloat,ka=parseInt,Cs=typeof Pe=="object"&&Pe&&Pe.Object===Object&&Pe,Ha=typeof self=="object"&&self&&self.Object===Object&&self,dt=Cs||Ha||Function("return this")(),Hr=a&&!a.nodeType&&a,Tn=Hr&&!0&&l&&!l.nodeType&&l,Ps=Tn&&Tn.exports===Hr,zr=Ps&&Cs.process,$t=function(){try{var h=Tn&&Tn.require&&Tn.require("util").types;return h||zr&&zr.binding&&zr.binding("util")}catch{}}(),Is=$t&&$t.isArrayBuffer,Rs=$t&&$t.isDate,Es=$t&&$t.isMap,Ts=$t&&$t.isRegExp,Os=$t&&$t.isSet,Ls=$t&&$t.isTypedArray;function Tt(h,w,_){switch(_.length){case 0:return h.call(w);case 1:return h.call(w,_[0]);case 2:return h.call(w,_[0],_[1]);case 3:return h.call(w,_[0],_[1],_[2])}return h.apply(w,_)}function za(h,w,_,I){for(var F=-1,J=h==null?0:h.length;++F<J;){var at=h[F];w(I,at,_(at),h)}return I}function Bt(h,w){for(var _=-1,I=h==null?0:h.length;++_<I&&w(h[_],_,h)!==!1;);return h}function Ga(h,w){for(var _=h==null?0:h.length;_--&&w(h[_],_,h)!==!1;);return h}function Ws(h,w){for(var _=-1,I=h==null?0:h.length;++_<I;)if(!w(h[_],_,h))return!1;return!0}function yn(h,w){for(var _=-1,I=h==null?0:h.length,F=0,J=[];++_<I;){var at=h[_];w(at,_,h)&&(J[F++]=at)}return J}function $e(h,w){var _=h==null?0:h.length;return!!_&&Hn(h,w,0)>-1}function Gr(h,w,_){for(var I=-1,F=h==null?0:h.length;++I<F;)if(_(w,h[I]))return!0;return!1}function et(h,w){for(var _=-1,I=h==null?0:h.length,F=Array(I);++_<I;)F[_]=w(h[_],_,h);return F}function mn(h,w){for(var _=-1,I=w.length,F=h.length;++_<I;)h[F+_]=w[_];return h}function Jr(h,w,_,I){var F=-1,J=h==null?0:h.length;for(I&&J&&(_=h[++F]);++F<J;)_=w(_,h[F],F,h);return _}function Ja(h,w,_,I){var F=h==null?0:h.length;for(I&&F&&(_=h[--F]);F--;)_=w(_,h[F],F,h);return _}function Zr(h,w){for(var _=-1,I=h==null?0:h.length;++_<I;)if(w(h[_],_,h))return!0;return!1}var Za=Yr("length");function Ya(h){return h.split("")}function Xa(h){return h.match(ia)||[]}function Ds(h,w,_){var I;return _(h,function(F,J,at){if(w(F,J,at))return I=J,!1}),I}function Be(h,w,_,I){for(var F=h.length,J=_+(I?1:-1);I?J--:++J<F;)if(w(h[J],J,h))return J;return-1}function Hn(h,w,_){return w===w?ff(h,w,_):Be(h,Fs,_)}function Qa(h,w,_,I){for(var F=_-1,J=h.length;++F<J;)if(I(h[F],w))return F;return-1}function Fs(h){return h!==h}function Us(h,w){var _=h==null?0:h.length;return _?Qr(h,w)/_:Kn}function Yr(h){return function(w){return w==null?i:w[h]}}function Xr(h){return function(w){return h==null?i:h[w]}}function Ns(h,w,_,I,F){return F(h,function(J,at,V){_=I?(I=!1,J):w(_,J,at,V)}),_}function Va(h,w){var _=h.length;for(h.sort(w);_--;)h[_]=h[_].value;return h}function Qr(h,w){for(var _,I=-1,F=h.length;++I<F;){var J=w(h[I]);J!==i&&(_=_===i?J:_+J)}return _}function Vr(h,w){for(var _=-1,I=Array(h);++_<h;)I[_]=w(_);return I}function ja(h,w){return et(w,function(_){return[_,h[_]]})}function $s(h){return h&&h.slice(0,qs(h)+1).replace($r,"")}function Ot(h){return function(w){return h(w)}}function jr(h,w){return et(w,function(_){return h[_]})}function ce(h,w){return h.has(w)}function Bs(h,w){for(var _=-1,I=h.length;++_<I&&Hn(w,h[_],0)>-1;);return _}function Ms(h,w){for(var _=h.length;_--&&Hn(w,h[_],0)>-1;);return _}function tf(h,w){for(var _=h.length,I=0;_--;)h[_]===w&&++I;return I}var nf=Xr($a),ef=Xr(Ba);function rf(h){return"\\"+Ka[h]}function sf(h,w){return h==null?i:h[w]}function zn(h){return Da.test(h)}function uf(h){return Fa.test(h)}function of(h){for(var w,_=[];!(w=h.next()).done;)_.push(w.value);return _}function ti(h){var w=-1,_=Array(h.size);return h.forEach(function(I,F){_[++w]=[F,I]}),_}function Ks(h,w){return function(_){return h(w(_))}}function xn(h,w){for(var _=-1,I=h.length,F=0,J=[];++_<I;){var at=h[_];(at===w||at===Z)&&(h[_]=Z,J[F++]=_)}return J}function Me(h){var w=-1,_=Array(h.size);return h.forEach(function(I){_[++w]=I}),_}function af(h){var w=-1,_=Array(h.size);return h.forEach(function(I){_[++w]=[I,I]}),_}function ff(h,w,_){for(var I=_-1,F=h.length;++I<F;)if(h[I]===w)return I;return-1}function cf(h,w,_){for(var I=_+1;I--;)if(h[I]===w)return I;return I}function Gn(h){return zn(h)?hf(h):Za(h)}function Yt(h){return zn(h)?df(h):Ya(h)}function qs(h){for(var w=h.length;w--&&ta.test(h.charAt(w)););return w}var lf=Xr(Ma);function hf(h){for(var w=kr.lastIndex=0;kr.test(h);)++w;return w}function df(h){return h.match(kr)||[]}function pf(h){return h.match(Wa)||[]}var gf=function h(w){w=w==null?dt:Jn.defaults(dt.Object(),w,Jn.pick(dt,Ua));var _=w.Array,I=w.Date,F=w.Error,J=w.Function,at=w.Math,V=w.Object,ni=w.RegExp,_f=w.String,Mt=w.TypeError,Ke=_.prototype,vf=J.prototype,Zn=V.prototype,qe=w["__core-js_shared__"],ke=vf.toString,X=Zn.hasOwnProperty,wf=0,ks=function(){var t=/[^.]+$/.exec(qe&&qe.keys&&qe.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),He=Zn.toString,yf=ke.call(V),mf=dt._,xf=ni("^"+ke.call(X).replace(Nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=Ps?w.Buffer:i,Sn=w.Symbol,Ge=w.Uint8Array,Hs=ze?ze.allocUnsafe:i,Je=Ks(V.getPrototypeOf,V),zs=V.create,Gs=Zn.propertyIsEnumerable,Ze=Ke.splice,Js=Sn?Sn.isConcatSpreadable:i,le=Sn?Sn.iterator:i,On=Sn?Sn.toStringTag:i,Ye=function(){try{var t=Un(V,"defineProperty");return t({},"",{}),t}catch{}}(),Sf=w.clearTimeout!==dt.clearTimeout&&w.clearTimeout,Af=I&&I.now!==dt.Date.now&&I.now,bf=w.setTimeout!==dt.setTimeout&&w.setTimeout,Xe=at.ceil,Qe=at.floor,ei=V.getOwnPropertySymbols,Cf=ze?ze.isBuffer:i,Zs=w.isFinite,Pf=Ke.join,If=Ks(V.keys,V),ft=at.max,_t=at.min,Rf=I.now,Ef=w.parseInt,Ys=at.random,Tf=Ke.reverse,ri=Un(w,"DataView"),he=Un(w,"Map"),ii=Un(w,"Promise"),Yn=Un(w,"Set"),de=Un(w,"WeakMap"),pe=Un(V,"create"),Ve=de&&new de,Xn={},Of=Nn(ri),Lf=Nn(he),Wf=Nn(ii),Df=Nn(Yn),Ff=Nn(de),je=Sn?Sn.prototype:i,ge=je?je.valueOf:i,Xs=je?je.toString:i;function u(t){if(it(t)&&!U(t)&&!(t instanceof z)){if(t instanceof Kt)return t;if(X.call(t,"__wrapped__"))return Qu(t)}return new Kt(t)}var Qn=function(){function t(){}return function(n){if(!rt(n))return{};if(zs)return zs(n);t.prototype=n;var e=new t;return t.prototype=i,e}}();function tr(){}function Kt(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=i}u.templateSettings={escape:Zo,evaluate:Yo,interpolate:ss,variable:"",imports:{_:u}},u.prototype=tr.prototype,u.prototype.constructor=u,Kt.prototype=Qn(tr.prototype),Kt.prototype.constructor=Kt;function z(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Nt,this.__views__=[]}function Uf(){var t=new z(this.__wrapped__);return t.__actions__=bt(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=bt(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=bt(this.__views__),t}function Nf(){if(this.__filtered__){var t=new z(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function $f(){var t=this.__wrapped__.value(),n=this.__dir__,e=U(t),r=n<0,s=e?t.length:0,o=Xc(0,s,this.__views__),f=o.start,c=o.end,d=c-f,y=r?c:f-1,m=this.__iteratees__,S=m.length,b=0,R=_t(d,this.__takeCount__);if(!e||!r&&s==d&&R==d)return mu(t,this.__actions__);var L=[];t:for(;d--&&b<R;){y+=n;for(var M=-1,W=t[y];++M<S;){var H=m[M],G=H.iteratee,Dt=H.type,xt=G(W);if(Dt==Te)W=xt;else if(!xt){if(Dt==En)continue t;break t}}L[b++]=W}return L}z.prototype=Qn(tr.prototype),z.prototype.constructor=z;function Ln(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Bf(){this.__data__=pe?pe(null):{},this.size=0}function Mf(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function Kf(t){var n=this.__data__;if(pe){var e=n[t];return e===C?i:e}return X.call(n,t)?n[t]:i}function qf(t){var n=this.__data__;return pe?n[t]!==i:X.call(n,t)}function kf(t,n){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=pe&&n===i?C:n,this}Ln.prototype.clear=Bf,Ln.prototype.delete=Mf,Ln.prototype.get=Kf,Ln.prototype.has=qf,Ln.prototype.set=kf;function an(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Hf(){this.__data__=[],this.size=0}function zf(t){var n=this.__data__,e=nr(n,t);if(e<0)return!1;var r=n.length-1;return e==r?n.pop():Ze.call(n,e,1),--this.size,!0}function Gf(t){var n=this.__data__,e=nr(n,t);return e<0?i:n[e][1]}function Jf(t){return nr(this.__data__,t)>-1}function Zf(t,n){var e=this.__data__,r=nr(e,t);return r<0?(++this.size,e.push([t,n])):e[r][1]=n,this}an.prototype.clear=Hf,an.prototype.delete=zf,an.prototype.get=Gf,an.prototype.has=Jf,an.prototype.set=Zf;function fn(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Yf(){this.size=0,this.__data__={hash:new Ln,map:new(he||an),string:new Ln}}function Xf(t){var n=dr(this,t).delete(t);return this.size-=n?1:0,n}function Qf(t){return dr(this,t).get(t)}function Vf(t){return dr(this,t).has(t)}function jf(t,n){var e=dr(this,t),r=e.size;return e.set(t,n),this.size+=e.size==r?0:1,this}fn.prototype.clear=Yf,fn.prototype.delete=Xf,fn.prototype.get=Qf,fn.prototype.has=Vf,fn.prototype.set=jf;function Wn(t){var n=-1,e=t==null?0:t.length;for(this.__data__=new fn;++n<e;)this.add(t[n])}function tc(t){return this.__data__.set(t,C),this}function nc(t){return this.__data__.has(t)}Wn.prototype.add=Wn.prototype.push=tc,Wn.prototype.has=nc;function Xt(t){var n=this.__data__=new an(t);this.size=n.size}function ec(){this.__data__=new an,this.size=0}function rc(t){var n=this.__data__,e=n.delete(t);return this.size=n.size,e}function ic(t){return this.__data__.get(t)}function sc(t){return this.__data__.has(t)}function uc(t,n){var e=this.__data__;if(e instanceof an){var r=e.__data__;if(!he||r.length<g-1)return r.push([t,n]),this.size=++e.size,this;e=this.__data__=new fn(r)}return e.set(t,n),this.size=e.size,this}Xt.prototype.clear=ec,Xt.prototype.delete=rc,Xt.prototype.get=ic,Xt.prototype.has=sc,Xt.prototype.set=uc;function Qs(t,n){var e=U(t),r=!e&&$n(t),s=!e&&!r&&In(t),o=!e&&!r&&!s&&ne(t),f=e||r||s||o,c=f?Vr(t.length,_f):[],d=c.length;for(var y in t)(n||X.call(t,y))&&!(f&&(y=="length"||s&&(y=="offset"||y=="parent")||o&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||dn(y,d)))&&c.push(y);return c}function Vs(t){var n=t.length;return n?t[gi(0,n-1)]:i}function oc(t,n){return pr(bt(t),Dn(n,0,t.length))}function ac(t){return pr(bt(t))}function si(t,n,e){(e!==i&&!Qt(t[n],e)||e===i&&!(n in t))&&cn(t,n,e)}function _e(t,n,e){var r=t[n];(!(X.call(t,n)&&Qt(r,e))||e===i&&!(n in t))&&cn(t,n,e)}function nr(t,n){for(var e=t.length;e--;)if(Qt(t[e][0],n))return e;return-1}function fc(t,n,e,r){return An(t,function(s,o,f){n(r,s,e(s),f)}),r}function js(t,n){return t&&en(n,lt(n),t)}function cc(t,n){return t&&en(n,Pt(n),t)}function cn(t,n,e){n=="__proto__"&&Ye?Ye(t,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[n]=e}function ui(t,n){for(var e=-1,r=n.length,s=_(r),o=t==null;++e<r;)s[e]=o?i:Mi(t,n[e]);return s}function Dn(t,n,e){return t===t&&(e!==i&&(t=t<=e?t:e),n!==i&&(t=t>=n?t:n)),t}function qt(t,n,e,r,s,o){var f,c=n&A,d=n&D,y=n&P;if(e&&(f=s?e(t,r,s,o):e(t)),f!==i)return f;if(!rt(t))return t;var m=U(t);if(m){if(f=Vc(t),!c)return bt(t,f)}else{var S=vt(t),b=S==We||S==ns;if(In(t))return Au(t,c);if(S==on||S==wn||b&&!s){if(f=d||b?{}:qu(t),!c)return d?Kc(t,cc(f,t)):Mc(t,js(f,t))}else{if(!tt[S])return s?t:{};f=jc(t,S,c)}}o||(o=new Xt);var R=o.get(t);if(R)return R;o.set(t,f),wo(t)?t.forEach(function(W){f.add(qt(W,n,e,W,t,o))}):_o(t)&&t.forEach(function(W,H){f.set(H,qt(W,n,e,H,t,o))});var L=y?d?Pi:Ci:d?Pt:lt,M=m?i:L(t);return Bt(M||t,function(W,H){M&&(H=W,W=t[H]),_e(f,H,qt(W,n,e,H,t,o))}),f}function lc(t){var n=lt(t);return function(e){return tu(e,t,n)}}function tu(t,n,e){var r=e.length;if(t==null)return!r;for(t=V(t);r--;){var s=e[r],o=n[s],f=t[s];if(f===i&&!(s in t)||!o(f))return!1}return!0}function nu(t,n,e){if(typeof t!="function")throw new Mt(x);return Ae(function(){t.apply(i,e)},n)}function ve(t,n,e,r){var s=-1,o=$e,f=!0,c=t.length,d=[],y=n.length;if(!c)return d;e&&(n=et(n,Ot(e))),r?(o=Gr,f=!1):n.length>=g&&(o=ce,f=!1,n=new Wn(n));t:for(;++s<c;){var m=t[s],S=e==null?m:e(m);if(m=r||m!==0?m:0,f&&S===S){for(var b=y;b--;)if(n[b]===S)continue t;d.push(m)}else o(n,S,r)||d.push(m)}return d}var An=Ru(nn),eu=Ru(ai,!0);function hc(t,n){var e=!0;return An(t,function(r,s,o){return e=!!n(r,s,o),e}),e}function er(t,n,e){for(var r=-1,s=t.length;++r<s;){var o=t[r],f=n(o);if(f!=null&&(c===i?f===f&&!Wt(f):e(f,c)))var c=f,d=o}return d}function dc(t,n,e,r){var s=t.length;for(e=B(e),e<0&&(e=-e>s?0:s+e),r=r===i||r>s?s:B(r),r<0&&(r+=s),r=e>r?0:mo(r);e<r;)t[e++]=n;return t}function ru(t,n){var e=[];return An(t,function(r,s,o){n(r,s,o)&&e.push(r)}),e}function pt(t,n,e,r,s){var o=-1,f=t.length;for(e||(e=nl),s||(s=[]);++o<f;){var c=t[o];n>0&&e(c)?n>1?pt(c,n-1,e,r,s):mn(s,c):r||(s[s.length]=c)}return s}var oi=Eu(),iu=Eu(!0);function nn(t,n){return t&&oi(t,n,lt)}function ai(t,n){return t&&iu(t,n,lt)}function rr(t,n){return yn(n,function(e){return pn(t[e])})}function Fn(t,n){n=Cn(n,t);for(var e=0,r=n.length;t!=null&&e<r;)t=t[rn(n[e++])];return e&&e==r?t:i}function su(t,n,e){var r=n(t);return U(t)?r:mn(r,e(t))}function yt(t){return t==null?t===i?Ko:Bo:On&&On in V(t)?Yc(t):al(t)}function fi(t,n){return t>n}function pc(t,n){return t!=null&&X.call(t,n)}function gc(t,n){return t!=null&&n in V(t)}function _c(t,n,e){return t>=_t(n,e)&&t<ft(n,e)}function ci(t,n,e){for(var r=e?Gr:$e,s=t[0].length,o=t.length,f=o,c=_(o),d=1/0,y=[];f--;){var m=t[f];f&&n&&(m=et(m,Ot(n))),d=_t(m.length,d),c[f]=!e&&(n||s>=120&&m.length>=120)?new Wn(f&&m):i}m=t[0];var S=-1,b=c[0];t:for(;++S<s&&y.length<d;){var R=m[S],L=n?n(R):R;if(R=e||R!==0?R:0,!(b?ce(b,L):r(y,L,e))){for(f=o;--f;){var M=c[f];if(!(M?ce(M,L):r(t[f],L,e)))continue t}b&&b.push(L),y.push(R)}}return y}function vc(t,n,e,r){return nn(t,function(s,o,f){n(r,e(s),o,f)}),r}function we(t,n,e){n=Cn(n,t),t=Gu(t,n);var r=t==null?t:t[rn(Ht(n))];return r==null?i:Tt(r,t,e)}function uu(t){return it(t)&&yt(t)==wn}function wc(t){return it(t)&&yt(t)==fe}function yc(t){return it(t)&&yt(t)==wt}function ye(t,n,e,r,s){return t===n?!0:t==null||n==null||!it(t)&&!it(n)?t!==t&&n!==n:mc(t,n,e,r,ye,s)}function mc(t,n,e,r,s,o){var f=U(t),c=U(n),d=f?$:vt(t),y=c?$:vt(n);d=d==wn?on:d,y=y==wn?on:y;var m=d==on,S=y==on,b=d==y;if(b&&In(t)){if(!In(n))return!1;f=!0,m=!1}if(b&&!m)return o||(o=new Xt),f||ne(t)?Bu(t,n,e,r,s,o):Jc(t,n,d,e,r,s,o);if(!(e&N)){var R=m&&X.call(t,"__wrapped__"),L=S&&X.call(n,"__wrapped__");if(R||L){var M=R?t.value():t,W=L?n.value():n;return o||(o=new Xt),s(M,W,e,r,o)}}return b?(o||(o=new Xt),Zc(t,n,e,r,s,o)):!1}function xc(t){return it(t)&&vt(t)==Jt}function li(t,n,e,r){var s=e.length,o=s,f=!r;if(t==null)return!o;for(t=V(t);s--;){var c=e[s];if(f&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++s<o;){c=e[s];var d=c[0],y=t[d],m=c[1];if(f&&c[2]){if(y===i&&!(d in t))return!1}else{var S=new Xt;if(r)var b=r(y,m,d,t,n,S);if(!(b===i?ye(m,y,N|j,r,S):b))return!1}}return!0}function ou(t){if(!rt(t)||rl(t))return!1;var n=pn(t)?xf:ca;return n.test(Nn(t))}function Sc(t){return it(t)&&yt(t)==ue}function Ac(t){return it(t)&&vt(t)==Zt}function bc(t){return it(t)&&mr(t.length)&&!!nt[yt(t)]}function au(t){return typeof t=="function"?t:t==null?It:typeof t=="object"?U(t)?lu(t[0],t[1]):cu(t):Oo(t)}function hi(t){if(!Se(t))return If(t);var n=[];for(var e in V(t))X.call(t,e)&&e!="constructor"&&n.push(e);return n}function Cc(t){if(!rt(t))return ol(t);var n=Se(t),e=[];for(var r in t)r=="constructor"&&(n||!X.call(t,r))||e.push(r);return e}function di(t,n){return t<n}function fu(t,n){var e=-1,r=Ct(t)?_(t.length):[];return An(t,function(s,o,f){r[++e]=n(s,o,f)}),r}function cu(t){var n=Ri(t);return n.length==1&&n[0][2]?Hu(n[0][0],n[0][1]):function(e){return e===t||li(e,t,n)}}function lu(t,n){return Ti(t)&&ku(n)?Hu(rn(t),n):function(e){var r=Mi(e,t);return r===i&&r===n?Ki(e,t):ye(n,r,N|j)}}function ir(t,n,e,r,s){t!==n&&oi(n,function(o,f){if(s||(s=new Xt),rt(o))Pc(t,n,f,e,ir,r,s);else{var c=r?r(Li(t,f),o,f+"",t,n,s):i;c===i&&(c=o),si(t,f,c)}},Pt)}function Pc(t,n,e,r,s,o,f){var c=Li(t,e),d=Li(n,e),y=f.get(d);if(y){si(t,e,y);return}var m=o?o(c,d,e+"",t,n,f):i,S=m===i;if(S){var b=U(d),R=!b&&In(d),L=!b&&!R&&ne(d);m=d,b||R||L?U(c)?m=c:st(c)?m=bt(c):R?(S=!1,m=Au(d,!0)):L?(S=!1,m=bu(d,!0)):m=[]:be(d)||$n(d)?(m=c,$n(c)?m=xo(c):(!rt(c)||pn(c))&&(m=qu(d))):S=!1}S&&(f.set(d,m),s(m,d,r,o,f),f.delete(d)),si(t,e,m)}function hu(t,n){var e=t.length;if(e)return n+=n<0?e:0,dn(n,e)?t[n]:i}function du(t,n,e){n.length?n=et(n,function(o){return U(o)?function(f){return Fn(f,o.length===1?o[0]:o)}:o}):n=[It];var r=-1;n=et(n,Ot(O()));var s=fu(t,function(o,f,c){var d=et(n,function(y){return y(o)});return{criteria:d,index:++r,value:o}});return Va(s,function(o,f){return Bc(o,f,e)})}function Ic(t,n){return pu(t,n,function(e,r){return Ki(t,r)})}function pu(t,n,e){for(var r=-1,s=n.length,o={};++r<s;){var f=n[r],c=Fn(t,f);e(c,f)&&me(o,Cn(f,t),c)}return o}function Rc(t){return function(n){return Fn(n,t)}}function pi(t,n,e,r){var s=r?Qa:Hn,o=-1,f=n.length,c=t;for(t===n&&(n=bt(n)),e&&(c=et(t,Ot(e)));++o<f;)for(var d=0,y=n[o],m=e?e(y):y;(d=s(c,m,d,r))>-1;)c!==t&&Ze.call(c,d,1),Ze.call(t,d,1);return t}function gu(t,n){for(var e=t?n.length:0,r=e-1;e--;){var s=n[e];if(e==r||s!==o){var o=s;dn(s)?Ze.call(t,s,1):wi(t,s)}}return t}function gi(t,n){return t+Qe(Ys()*(n-t+1))}function Ec(t,n,e,r){for(var s=-1,o=ft(Xe((n-t)/(e||1)),0),f=_(o);o--;)f[r?o:++s]=t,t+=e;return f}function _i(t,n){var e="";if(!t||n<1||n>tn)return e;do n%2&&(e+=t),n=Qe(n/2),n&&(t+=t);while(n);return e}function q(t,n){return Wi(zu(t,n,It),t+"")}function Tc(t){return Vs(ee(t))}function Oc(t,n){var e=ee(t);return pr(e,Dn(n,0,e.length))}function me(t,n,e,r){if(!rt(t))return t;n=Cn(n,t);for(var s=-1,o=n.length,f=o-1,c=t;c!=null&&++s<o;){var d=rn(n[s]),y=e;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=f){var m=c[d];y=r?r(m,d,c):i,y===i&&(y=rt(m)?m:dn(n[s+1])?[]:{})}_e(c,d,y),c=c[d]}return t}var _u=Ve?function(t,n){return Ve.set(t,n),t}:It,Lc=Ye?function(t,n){return Ye(t,"toString",{configurable:!0,enumerable:!1,value:ki(n),writable:!0})}:It;function Wc(t){return pr(ee(t))}function kt(t,n,e){var r=-1,s=t.length;n<0&&(n=-n>s?0:s+n),e=e>s?s:e,e<0&&(e+=s),s=n>e?0:e-n>>>0,n>>>=0;for(var o=_(s);++r<s;)o[r]=t[r+n];return o}function Dc(t,n){var e;return An(t,function(r,s,o){return e=n(r,s,o),!e}),!!e}function sr(t,n,e){var r=0,s=t==null?r:t.length;if(typeof n=="number"&&n===n&&s<=Oe){for(;r<s;){var o=r+s>>>1,f=t[o];f!==null&&!Wt(f)&&(e?f<=n:f<n)?r=o+1:s=o}return s}return vi(t,n,It,e)}function vi(t,n,e,r){var s=0,o=t==null?0:t.length;if(o===0)return 0;n=e(n);for(var f=n!==n,c=n===null,d=Wt(n),y=n===i;s<o;){var m=Qe((s+o)/2),S=e(t[m]),b=S!==i,R=S===null,L=S===S,M=Wt(S);if(f)var W=r||L;else y?W=L&&(r||b):c?W=L&&b&&(r||!R):d?W=L&&b&&!R&&(r||!M):R||M?W=!1:W=r?S<=n:S<n;W?s=m+1:o=m}return _t(o,Pr)}function vu(t,n){for(var e=-1,r=t.length,s=0,o=[];++e<r;){var f=t[e],c=n?n(f):f;if(!e||!Qt(c,d)){var d=c;o[s++]=f===0?0:f}}return o}function wu(t){return typeof t=="number"?t:Wt(t)?Kn:+t}function Lt(t){if(typeof t=="string")return t;if(U(t))return et(t,Lt)+"";if(Wt(t))return Xs?Xs.call(t):"";var n=t+"";return n=="0"&&1/t==-un?"-0":n}function bn(t,n,e){var r=-1,s=$e,o=t.length,f=!0,c=[],d=c;if(e)f=!1,s=Gr;else if(o>=g){var y=n?null:zc(t);if(y)return Me(y);f=!1,s=ce,d=new Wn}else d=n?[]:c;t:for(;++r<o;){var m=t[r],S=n?n(m):m;if(m=e||m!==0?m:0,f&&S===S){for(var b=d.length;b--;)if(d[b]===S)continue t;n&&d.push(S),c.push(m)}else s(d,S,e)||(d!==c&&d.push(S),c.push(m))}return c}function wi(t,n){return n=Cn(n,t),t=Gu(t,n),t==null||delete t[rn(Ht(n))]}function yu(t,n,e,r){return me(t,n,e(Fn(t,n)),r)}function ur(t,n,e,r){for(var s=t.length,o=r?s:-1;(r?o--:++o<s)&&n(t[o],o,t););return e?kt(t,r?0:o,r?o+1:s):kt(t,r?o+1:0,r?s:o)}function mu(t,n){var e=t;return e instanceof z&&(e=e.value()),Jr(n,function(r,s){return s.func.apply(s.thisArg,mn([r],s.args))},e)}function yi(t,n,e){var r=t.length;if(r<2)return r?bn(t[0]):[];for(var s=-1,o=_(r);++s<r;)for(var f=t[s],c=-1;++c<r;)c!=s&&(o[s]=ve(o[s]||f,t[c],n,e));return bn(pt(o,1),n,e)}function xu(t,n,e){for(var r=-1,s=t.length,o=n.length,f={};++r<s;){var c=r<o?n[r]:i;e(f,t[r],c)}return f}function mi(t){return st(t)?t:[]}function xi(t){return typeof t=="function"?t:It}function Cn(t,n){return U(t)?t:Ti(t,n)?[t]:Xu(Y(t))}var Fc=q;function Pn(t,n,e){var r=t.length;return e=e===i?r:e,!n&&e>=r?t:kt(t,n,e)}var Su=Sf||function(t){return dt.clearTimeout(t)};function Au(t,n){if(n)return t.slice();var e=t.length,r=Hs?Hs(e):new t.constructor(e);return t.copy(r),r}function Si(t){var n=new t.constructor(t.byteLength);return new Ge(n).set(new Ge(t)),n}function Uc(t,n){var e=n?Si(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}function Nc(t){var n=new t.constructor(t.source,us.exec(t));return n.lastIndex=t.lastIndex,n}function $c(t){return ge?V(ge.call(t)):{}}function bu(t,n){var e=n?Si(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}function Cu(t,n){if(t!==n){var e=t!==i,r=t===null,s=t===t,o=Wt(t),f=n!==i,c=n===null,d=n===n,y=Wt(n);if(!c&&!y&&!o&&t>n||o&&f&&d&&!c&&!y||r&&f&&d||!e&&d||!s)return 1;if(!r&&!o&&!y&&t<n||y&&e&&s&&!r&&!o||c&&e&&s||!f&&s||!d)return-1}return 0}function Bc(t,n,e){for(var r=-1,s=t.criteria,o=n.criteria,f=s.length,c=e.length;++r<f;){var d=Cu(s[r],o[r]);if(d){if(r>=c)return d;var y=e[r];return d*(y=="desc"?-1:1)}}return t.index-n.index}function Pu(t,n,e,r){for(var s=-1,o=t.length,f=e.length,c=-1,d=n.length,y=ft(o-f,0),m=_(d+y),S=!r;++c<d;)m[c]=n[c];for(;++s<f;)(S||s<o)&&(m[e[s]]=t[s]);for(;y--;)m[c++]=t[s++];return m}function Iu(t,n,e,r){for(var s=-1,o=t.length,f=-1,c=e.length,d=-1,y=n.length,m=ft(o-c,0),S=_(m+y),b=!r;++s<m;)S[s]=t[s];for(var R=s;++d<y;)S[R+d]=n[d];for(;++f<c;)(b||s<o)&&(S[R+e[f]]=t[s++]);return S}function bt(t,n){var e=-1,r=t.length;for(n||(n=_(r));++e<r;)n[e]=t[e];return n}function en(t,n,e,r){var s=!e;e||(e={});for(var o=-1,f=n.length;++o<f;){var c=n[o],d=r?r(e[c],t[c],c,e,t):i;d===i&&(d=t[c]),s?cn(e,c,d):_e(e,c,d)}return e}function Mc(t,n){return en(t,Ei(t),n)}function Kc(t,n){return en(t,Mu(t),n)}function or(t,n){return function(e,r){var s=U(e)?za:fc,o=n?n():{};return s(e,t,O(r,2),o)}}function Vn(t){return q(function(n,e){var r=-1,s=e.length,o=s>1?e[s-1]:i,f=s>2?e[2]:i;for(o=t.length>3&&typeof o=="function"?(s--,o):i,f&&mt(e[0],e[1],f)&&(o=s<3?i:o,s=1),n=V(n);++r<s;){var c=e[r];c&&t(n,c,r,o)}return n})}function Ru(t,n){return function(e,r){if(e==null)return e;if(!Ct(e))return t(e,r);for(var s=e.length,o=n?s:-1,f=V(e);(n?o--:++o<s)&&r(f[o],o,f)!==!1;);return e}}function Eu(t){return function(n,e,r){for(var s=-1,o=V(n),f=r(n),c=f.length;c--;){var d=f[t?c:++s];if(e(o[d],d,o)===!1)break}return n}}function qc(t,n,e){var r=n&k,s=xe(t);function o(){var f=this&&this!==dt&&this instanceof o?s:t;return f.apply(r?e:this,arguments)}return o}function Tu(t){return function(n){n=Y(n);var e=zn(n)?Yt(n):i,r=e?e[0]:n.charAt(0),s=e?Pn(e,1).join(""):n.slice(1);return r[t]()+s}}function jn(t){return function(n){return Jr(Eo(Ro(n).replace(Oa,"")),t,"")}}function xe(t){return function(){var n=arguments;switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3]);case 5:return new t(n[0],n[1],n[2],n[3],n[4]);case 6:return new t(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var e=Qn(t.prototype),r=t.apply(e,n);return rt(r)?r:e}}function kc(t,n,e){var r=xe(t);function s(){for(var o=arguments.length,f=_(o),c=o,d=te(s);c--;)f[c]=arguments[c];var y=o<3&&f[0]!==d&&f[o-1]!==d?[]:xn(f,d);if(o-=y.length,o<e)return Fu(t,n,ar,s.placeholder,i,f,y,i,i,e-o);var m=this&&this!==dt&&this instanceof s?r:t;return Tt(m,this,f)}return s}function Ou(t){return function(n,e,r){var s=V(n);if(!Ct(n)){var o=O(e,3);n=lt(n),e=function(c){return o(s[c],c,s)}}var f=t(n,e,r);return f>-1?s[o?n[f]:f]:i}}function Lu(t){return hn(function(n){var e=n.length,r=e,s=Kt.prototype.thru;for(t&&n.reverse();r--;){var o=n[r];if(typeof o!="function")throw new Mt(x);if(s&&!f&&hr(o)=="wrapper")var f=new Kt([],!0)}for(r=f?r:e;++r<e;){o=n[r];var c=hr(o),d=c=="wrapper"?Ii(o):i;d&&Oi(d[0])&&d[1]==(Ut|ht|Gt|jt)&&!d[4].length&&d[9]==1?f=f[hr(d[0])].apply(f,d[3]):f=o.length==1&&Oi(o)?f[c]():f.thru(o)}return function(){var y=arguments,m=y[0];if(f&&y.length==1&&U(m))return f.plant(m).value();for(var S=0,b=e?n[S].apply(this,y):m;++S<e;)b=n[S].call(this,b);return b}})}function ar(t,n,e,r,s,o,f,c,d,y){var m=n&Ut,S=n&k,b=n&vn,R=n&(ht|gt),L=n&Rt,M=b?i:xe(t);function W(){for(var H=arguments.length,G=_(H),Dt=H;Dt--;)G[Dt]=arguments[Dt];if(R)var xt=te(W),Ft=tf(G,xt);if(r&&(G=Pu(G,r,s,R)),o&&(G=Iu(G,o,f,R)),H-=Ft,R&&H<y){var ut=xn(G,xt);return Fu(t,n,ar,W.placeholder,e,G,ut,c,d,y-H)}var Vt=S?e:this,_n=b?Vt[t]:t;return H=G.length,c?G=fl(G,c):L&&H>1&&G.reverse(),m&&d<H&&(G.length=d),this&&this!==dt&&this instanceof W&&(_n=M||xe(_n)),_n.apply(Vt,G)}return W}function Wu(t,n){return function(e,r){return vc(e,t,n(r),{})}}function fr(t,n){return function(e,r){var s;if(e===i&&r===i)return n;if(e!==i&&(s=e),r!==i){if(s===i)return r;typeof e=="string"||typeof r=="string"?(e=Lt(e),r=Lt(r)):(e=wu(e),r=wu(r)),s=t(e,r)}return s}}function Ai(t){return hn(function(n){return n=et(n,Ot(O())),q(function(e){var r=this;return t(n,function(s){return Tt(s,r,e)})})})}function cr(t,n){n=n===i?" ":Lt(n);var e=n.length;if(e<2)return e?_i(n,t):n;var r=_i(n,Xe(t/Gn(n)));return zn(n)?Pn(Yt(r),0,t).join(""):r.slice(0,t)}function Hc(t,n,e,r){var s=n&k,o=xe(t);function f(){for(var c=-1,d=arguments.length,y=-1,m=r.length,S=_(m+d),b=this&&this!==dt&&this instanceof f?o:t;++y<m;)S[y]=r[y];for(;d--;)S[y++]=arguments[++c];return Tt(b,s?e:this,S)}return f}function Du(t){return function(n,e,r){return r&&typeof r!="number"&&mt(n,e,r)&&(e=r=i),n=gn(n),e===i?(e=n,n=0):e=gn(e),r=r===i?n<e?1:-1:gn(r),Ec(n,e,r,t)}}function lr(t){return function(n,e){return typeof n=="string"&&typeof e=="string"||(n=zt(n),e=zt(e)),t(n,e)}}function Fu(t,n,e,r,s,o,f,c,d,y){var m=n&ht,S=m?f:i,b=m?i:f,R=m?o:i,L=m?i:o;n|=m?Gt:Rn,n&=~(m?Rn:Gt),n&sn||(n&=-4);var M=[t,n,s,R,S,L,b,c,d,y],W=e.apply(i,M);return Oi(t)&&Ju(W,M),W.placeholder=r,Zu(W,t,n)}function bi(t){var n=at[t];return function(e,r){if(e=zt(e),r=r==null?0:_t(B(r),292),r&&Zs(e)){var s=(Y(e)+"e").split("e"),o=n(s[0]+"e"+(+s[1]+r));return s=(Y(o)+"e").split("e"),+(s[0]+"e"+(+s[1]-r))}return n(e)}}var zc=Yn&&1/Me(new Yn([,-0]))[1]==un?function(t){return new Yn(t)}:Gi;function Uu(t){return function(n){var e=vt(n);return e==Jt?ti(n):e==Zt?af(n):ja(n,t(n))}}function ln(t,n,e,r,s,o,f,c){var d=n&vn;if(!d&&typeof t!="function")throw new Mt(x);var y=r?r.length:0;if(y||(n&=-97,r=s=i),f=f===i?f:ft(B(f),0),c=c===i?c:B(c),y-=s?s.length:0,n&Rn){var m=r,S=s;r=s=i}var b=d?i:Ii(t),R=[t,n,e,r,s,m,S,o,f,c];if(b&&ul(R,b),t=R[0],n=R[1],e=R[2],r=R[3],s=R[4],c=R[9]=R[9]===i?d?0:t.length:ft(R[9]-y,0),!c&&n&(ht|gt)&&(n&=-25),!n||n==k)var L=qc(t,n,e);else n==ht||n==gt?L=kc(t,n,c):(n==Gt||n==(k|Gt))&&!s.length?L=Hc(t,n,e,r):L=ar.apply(i,R);var M=b?_u:Ju;return Zu(M(L,R),t,n)}function Nu(t,n,e,r){return t===i||Qt(t,Zn[e])&&!X.call(r,e)?n:t}function $u(t,n,e,r,s,o){return rt(t)&&rt(n)&&(o.set(n,t),ir(t,n,i,$u,o),o.delete(n)),t}function Gc(t){return be(t)?i:t}function Bu(t,n,e,r,s,o){var f=e&N,c=t.length,d=n.length;if(c!=d&&!(f&&d>c))return!1;var y=o.get(t),m=o.get(n);if(y&&m)return y==n&&m==t;var S=-1,b=!0,R=e&j?new Wn:i;for(o.set(t,n),o.set(n,t);++S<c;){var L=t[S],M=n[S];if(r)var W=f?r(M,L,S,n,t,o):r(L,M,S,t,n,o);if(W!==i){if(W)continue;b=!1;break}if(R){if(!Zr(n,function(H,G){if(!ce(R,G)&&(L===H||s(L,H,e,r,o)))return R.push(G)})){b=!1;break}}else if(!(L===M||s(L,M,e,r,o))){b=!1;break}}return o.delete(t),o.delete(n),b}function Jc(t,n,e,r,s,o,f){switch(e){case qn:if(t.byteLength!=n.byteLength||t.byteOffset!=n.byteOffset)return!1;t=t.buffer,n=n.buffer;case fe:return!(t.byteLength!=n.byteLength||!o(new Ge(t),new Ge(n)));case St:case wt:case se:return Qt(+t,+n);case At:return t.name==n.name&&t.message==n.message;case ue:case oe:return t==n+"";case Jt:var c=ti;case Zt:var d=r&N;if(c||(c=Me),t.size!=n.size&&!d)return!1;var y=f.get(t);if(y)return y==n;r|=j,f.set(t,n);var m=Bu(c(t),c(n),r,s,o,f);return f.delete(t),m;case De:if(ge)return ge.call(t)==ge.call(n)}return!1}function Zc(t,n,e,r,s,o){var f=e&N,c=Ci(t),d=c.length,y=Ci(n),m=y.length;if(d!=m&&!f)return!1;for(var S=d;S--;){var b=c[S];if(!(f?b in n:X.call(n,b)))return!1}var R=o.get(t),L=o.get(n);if(R&&L)return R==n&&L==t;var M=!0;o.set(t,n),o.set(n,t);for(var W=f;++S<d;){b=c[S];var H=t[b],G=n[b];if(r)var Dt=f?r(G,H,b,n,t,o):r(H,G,b,t,n,o);if(!(Dt===i?H===G||s(H,G,e,r,o):Dt)){M=!1;break}W||(W=b=="constructor")}if(M&&!W){var xt=t.constructor,Ft=n.constructor;xt!=Ft&&"constructor"in t&&"constructor"in n&&!(typeof xt=="function"&&xt instanceof xt&&typeof Ft=="function"&&Ft instanceof Ft)&&(M=!1)}return o.delete(t),o.delete(n),M}function hn(t){return Wi(zu(t,i,to),t+"")}function Ci(t){return su(t,lt,Ei)}function Pi(t){return su(t,Pt,Mu)}var Ii=Ve?function(t){return Ve.get(t)}:Gi;function hr(t){for(var n=t.name+"",e=Xn[n],r=X.call(Xn,n)?e.length:0;r--;){var s=e[r],o=s.func;if(o==null||o==t)return s.name}return n}function te(t){var n=X.call(u,"placeholder")?u:t;return n.placeholder}function O(){var t=u.iteratee||Hi;return t=t===Hi?au:t,arguments.length?t(arguments[0],arguments[1]):t}function dr(t,n){var e=t.__data__;return el(n)?e[typeof n=="string"?"string":"hash"]:e.map}function Ri(t){for(var n=lt(t),e=n.length;e--;){var r=n[e],s=t[r];n[e]=[r,s,ku(s)]}return n}function Un(t,n){var e=sf(t,n);return ou(e)?e:i}function Yc(t){var n=X.call(t,On),e=t[On];try{t[On]=i;var r=!0}catch{}var s=He.call(t);return r&&(n?t[On]=e:delete t[On]),s}var Ei=ei?function(t){return t==null?[]:(t=V(t),yn(ei(t),function(n){return Gs.call(t,n)}))}:Ji,Mu=ei?function(t){for(var n=[];t;)mn(n,Ei(t)),t=Je(t);return n}:Ji,vt=yt;(ri&&vt(new ri(new ArrayBuffer(1)))!=qn||he&&vt(new he)!=Jt||ii&&vt(ii.resolve())!=es||Yn&&vt(new Yn)!=Zt||de&&vt(new de)!=ae)&&(vt=function(t){var n=yt(t),e=n==on?t.constructor:i,r=e?Nn(e):"";if(r)switch(r){case Of:return qn;case Lf:return Jt;case Wf:return es;case Df:return Zt;case Ff:return ae}return n});function Xc(t,n,e){for(var r=-1,s=e.length;++r<s;){var o=e[r],f=o.size;switch(o.type){case"drop":t+=f;break;case"dropRight":n-=f;break;case"take":n=_t(n,t+f);break;case"takeRight":t=ft(t,n-f);break}}return{start:t,end:n}}function Qc(t){var n=t.match(ea);return n?n[1].split(ra):[]}function Ku(t,n,e){n=Cn(n,t);for(var r=-1,s=n.length,o=!1;++r<s;){var f=rn(n[r]);if(!(o=t!=null&&e(t,f)))break;t=t[f]}return o||++r!=s?o:(s=t==null?0:t.length,!!s&&mr(s)&&dn(f,s)&&(U(t)||$n(t)))}function Vc(t){var n=t.length,e=new t.constructor(n);return n&&typeof t[0]=="string"&&X.call(t,"index")&&(e.index=t.index,e.input=t.input),e}function qu(t){return typeof t.constructor=="function"&&!Se(t)?Qn(Je(t)):{}}function jc(t,n,e){var r=t.constructor;switch(n){case fe:return Si(t);case St:case wt:return new r(+t);case qn:return Uc(t,e);case Rr:case Er:case Tr:case Or:case Lr:case Wr:case Dr:case Fr:case Ur:return bu(t,e);case Jt:return new r;case se:case oe:return new r(t);case ue:return Nc(t);case Zt:return new r;case De:return $c(t)}}function tl(t,n){var e=n.length;if(!e)return t;var r=e-1;return n[r]=(e>1?"& ":"")+n[r],n=n.join(e>2?", ":" "),t.replace(na,`{
|
|
9
|
-
/* [wrapped with `+
|
|
10
|
-
`)}function nl(t){return U(t)||$n(t)||!!(Js&&t&&t[Js])}function dn(t,n){var e=typeof t;return n=n??tn,!!n&&(e=="number"||e!="symbol"&&ha.test(t))&&t>-1&&t%1==0&&t<n}function mt(t,n,e){if(!rt(e))return!1;var r=typeof n;return(r=="number"?Ct(e)&&dn(n,e.length):r=="string"&&n in e)?Qt(e[n],t):!1}function Ti(t,n){if(U(t))return!1;var e=typeof t;return e=="number"||e=="symbol"||e=="boolean"||t==null||Wt(t)?!0:Qo.test(t)||!Xo.test(t)||n!=null&&t in V(n)}function el(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}function Oi(t){var n=hr(t),e=u[n];if(typeof e!="function"||!(n in z.prototype))return!1;if(t===e)return!0;var r=Ii(e);return!!r&&t===r[0]}function rl(t){return!!ks&&ks in t}var il=qe?pn:Zi;function Se(t){var n=t&&t.constructor,e=typeof n=="function"&&n.prototype||Zn;return t===e}function ku(t){return t===t&&!rt(t)}function Hu(t,n){return function(e){return e==null?!1:e[t]===n&&(n!==i||t in V(e))}}function sl(t){var n=wr(t,function(r){return e.size===K&&e.clear(),r}),e=n.cache;return n}function ul(t,n){var e=t[1],r=n[1],s=e|r,o=s<(k|vn|Ut),f=r==Ut&&e==ht||r==Ut&&e==jt&&t[7].length<=n[8]||r==(Ut|jt)&&n[7].length<=n[8]&&e==ht;if(!(o||f))return t;r&k&&(t[2]=n[2],s|=e&k?0:sn);var c=n[3];if(c){var d=t[3];t[3]=d?Pu(d,c,n[4]):c,t[4]=d?xn(t[3],Z):n[4]}return c=n[5],c&&(d=t[5],t[5]=d?Iu(d,c,n[6]):c,t[6]=d?xn(t[5],Z):n[6]),c=n[7],c&&(t[7]=c),r&Ut&&(t[8]=t[8]==null?n[8]:_t(t[8],n[8])),t[9]==null&&(t[9]=n[9]),t[0]=n[0],t[1]=s,t}function ol(t){var n=[];if(t!=null)for(var e in V(t))n.push(e);return n}function al(t){return He.call(t)}function zu(t,n,e){return n=ft(n===i?t.length-1:n,0),function(){for(var r=arguments,s=-1,o=ft(r.length-n,0),f=_(o);++s<o;)f[s]=r[n+s];s=-1;for(var c=_(n+1);++s<n;)c[s]=r[s];return c[n]=e(f),Tt(t,this,c)}}function Gu(t,n){return n.length<2?t:Fn(t,kt(n,0,-1))}function fl(t,n){for(var e=t.length,r=_t(n.length,e),s=bt(t);r--;){var o=n[r];t[r]=dn(o,e)?s[o]:i}return t}function Li(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}var Ju=Yu(_u),Ae=bf||function(t,n){return dt.setTimeout(t,n)},Wi=Yu(Lc);function Zu(t,n,e){var r=n+"";return Wi(t,tl(r,cl(Qc(r),e)))}function Yu(t){var n=0,e=0;return function(){var r=Rf(),s=Ee-(r-e);if(e=r,s>0){if(++n>=Et)return arguments[0]}else n=0;return t.apply(i,arguments)}}function pr(t,n){var e=-1,r=t.length,s=r-1;for(n=n===i?r:n;++e<n;){var o=gi(e,s),f=t[o];t[o]=t[e],t[e]=f}return t.length=n,t}var Xu=sl(function(t){var n=[];return t.charCodeAt(0)===46&&n.push(""),t.replace(Vo,function(e,r,s,o){n.push(s?o.replace(ua,"$1"):r||e)}),n});function rn(t){if(typeof t=="string"||Wt(t))return t;var n=t+"";return n=="0"&&1/t==-un?"-0":n}function Nn(t){if(t!=null){try{return ke.call(t)}catch{}try{return t+""}catch{}}return""}function cl(t,n){return Bt(Ir,function(e){var r="_."+e[0];n&e[1]&&!$e(t,r)&&t.push(r)}),t.sort()}function Qu(t){if(t instanceof z)return t.clone();var n=new Kt(t.__wrapped__,t.__chain__);return n.__actions__=bt(t.__actions__),n.__index__=t.__index__,n.__values__=t.__values__,n}function ll(t,n,e){(e?mt(t,n,e):n===i)?n=1:n=ft(B(n),0);var r=t==null?0:t.length;if(!r||n<1)return[];for(var s=0,o=0,f=_(Xe(r/n));s<r;)f[o++]=kt(t,s,s+=n);return f}function hl(t){for(var n=-1,e=t==null?0:t.length,r=0,s=[];++n<e;){var o=t[n];o&&(s[r++]=o)}return s}function dl(){var t=arguments.length;if(!t)return[];for(var n=_(t-1),e=arguments[0],r=t;r--;)n[r-1]=arguments[r];return mn(U(e)?bt(e):[e],pt(n,1))}var pl=q(function(t,n){return st(t)?ve(t,pt(n,1,st,!0)):[]}),gl=q(function(t,n){var e=Ht(n);return st(e)&&(e=i),st(t)?ve(t,pt(n,1,st,!0),O(e,2)):[]}),_l=q(function(t,n){var e=Ht(n);return st(e)&&(e=i),st(t)?ve(t,pt(n,1,st,!0),i,e):[]});function vl(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:B(n),kt(t,n<0?0:n,r)):[]}function wl(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:B(n),n=r-n,kt(t,0,n<0?0:n)):[]}function yl(t,n){return t&&t.length?ur(t,O(n,3),!0,!0):[]}function ml(t,n){return t&&t.length?ur(t,O(n,3),!0):[]}function xl(t,n,e,r){var s=t==null?0:t.length;return s?(e&&typeof e!="number"&&mt(t,n,e)&&(e=0,r=s),dc(t,n,e,r)):[]}function Vu(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var s=e==null?0:B(e);return s<0&&(s=ft(r+s,0)),Be(t,O(n,3),s)}function ju(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var s=r-1;return e!==i&&(s=B(e),s=e<0?ft(r+s,0):_t(s,r-1)),Be(t,O(n,3),s,!0)}function to(t){var n=t==null?0:t.length;return n?pt(t,1):[]}function Sl(t){var n=t==null?0:t.length;return n?pt(t,un):[]}function Al(t,n){var e=t==null?0:t.length;return e?(n=n===i?1:B(n),pt(t,n)):[]}function bl(t){for(var n=-1,e=t==null?0:t.length,r={};++n<e;){var s=t[n];r[s[0]]=s[1]}return r}function no(t){return t&&t.length?t[0]:i}function Cl(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var s=e==null?0:B(e);return s<0&&(s=ft(r+s,0)),Hn(t,n,s)}function Pl(t){var n=t==null?0:t.length;return n?kt(t,0,-1):[]}var Il=q(function(t){var n=et(t,mi);return n.length&&n[0]===t[0]?ci(n):[]}),Rl=q(function(t){var n=Ht(t),e=et(t,mi);return n===Ht(e)?n=i:e.pop(),e.length&&e[0]===t[0]?ci(e,O(n,2)):[]}),El=q(function(t){var n=Ht(t),e=et(t,mi);return n=typeof n=="function"?n:i,n&&e.pop(),e.length&&e[0]===t[0]?ci(e,i,n):[]});function Tl(t,n){return t==null?"":Pf.call(t,n)}function Ht(t){var n=t==null?0:t.length;return n?t[n-1]:i}function Ol(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var s=r;return e!==i&&(s=B(e),s=s<0?ft(r+s,0):_t(s,r-1)),n===n?cf(t,n,s):Be(t,Fs,s,!0)}function Ll(t,n){return t&&t.length?hu(t,B(n)):i}var Wl=q(eo);function eo(t,n){return t&&t.length&&n&&n.length?pi(t,n):t}function Dl(t,n,e){return t&&t.length&&n&&n.length?pi(t,n,O(e,2)):t}function Fl(t,n,e){return t&&t.length&&n&&n.length?pi(t,n,i,e):t}var Ul=hn(function(t,n){var e=t==null?0:t.length,r=ui(t,n);return gu(t,et(n,function(s){return dn(s,e)?+s:s}).sort(Cu)),r});function Nl(t,n){var e=[];if(!(t&&t.length))return e;var r=-1,s=[],o=t.length;for(n=O(n,3);++r<o;){var f=t[r];n(f,r,t)&&(e.push(f),s.push(r))}return gu(t,s),e}function Di(t){return t==null?t:Tf.call(t)}function $l(t,n,e){var r=t==null?0:t.length;return r?(e&&typeof e!="number"&&mt(t,n,e)?(n=0,e=r):(n=n==null?0:B(n),e=e===i?r:B(e)),kt(t,n,e)):[]}function Bl(t,n){return sr(t,n)}function Ml(t,n,e){return vi(t,n,O(e,2))}function Kl(t,n){var e=t==null?0:t.length;if(e){var r=sr(t,n);if(r<e&&Qt(t[r],n))return r}return-1}function ql(t,n){return sr(t,n,!0)}function kl(t,n,e){return vi(t,n,O(e,2),!0)}function Hl(t,n){var e=t==null?0:t.length;if(e){var r=sr(t,n,!0)-1;if(Qt(t[r],n))return r}return-1}function zl(t){return t&&t.length?vu(t):[]}function Gl(t,n){return t&&t.length?vu(t,O(n,2)):[]}function Jl(t){var n=t==null?0:t.length;return n?kt(t,1,n):[]}function Zl(t,n,e){return t&&t.length?(n=e||n===i?1:B(n),kt(t,0,n<0?0:n)):[]}function Yl(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:B(n),n=r-n,kt(t,n<0?0:n,r)):[]}function Xl(t,n){return t&&t.length?ur(t,O(n,3),!1,!0):[]}function Ql(t,n){return t&&t.length?ur(t,O(n,3)):[]}var Vl=q(function(t){return bn(pt(t,1,st,!0))}),jl=q(function(t){var n=Ht(t);return st(n)&&(n=i),bn(pt(t,1,st,!0),O(n,2))}),th=q(function(t){var n=Ht(t);return n=typeof n=="function"?n:i,bn(pt(t,1,st,!0),i,n)});function nh(t){return t&&t.length?bn(t):[]}function eh(t,n){return t&&t.length?bn(t,O(n,2)):[]}function rh(t,n){return n=typeof n=="function"?n:i,t&&t.length?bn(t,i,n):[]}function Fi(t){if(!(t&&t.length))return[];var n=0;return t=yn(t,function(e){if(st(e))return n=ft(e.length,n),!0}),Vr(n,function(e){return et(t,Yr(e))})}function ro(t,n){if(!(t&&t.length))return[];var e=Fi(t);return n==null?e:et(e,function(r){return Tt(n,i,r)})}var ih=q(function(t,n){return st(t)?ve(t,n):[]}),sh=q(function(t){return yi(yn(t,st))}),uh=q(function(t){var n=Ht(t);return st(n)&&(n=i),yi(yn(t,st),O(n,2))}),oh=q(function(t){var n=Ht(t);return n=typeof n=="function"?n:i,yi(yn(t,st),i,n)}),ah=q(Fi);function fh(t,n){return xu(t||[],n||[],_e)}function ch(t,n){return xu(t||[],n||[],me)}var lh=q(function(t){var n=t.length,e=n>1?t[n-1]:i;return e=typeof e=="function"?(t.pop(),e):i,ro(t,e)});function io(t){var n=u(t);return n.__chain__=!0,n}function hh(t,n){return n(t),t}function gr(t,n){return n(t)}var dh=hn(function(t){var n=t.length,e=n?t[0]:0,r=this.__wrapped__,s=function(o){return ui(o,t)};return n>1||this.__actions__.length||!(r instanceof z)||!dn(e)?this.thru(s):(r=r.slice(e,+e+(n?1:0)),r.__actions__.push({func:gr,args:[s],thisArg:i}),new Kt(r,this.__chain__).thru(function(o){return n&&!o.length&&o.push(i),o}))});function ph(){return io(this)}function gh(){return new Kt(this.value(),this.__chain__)}function _h(){this.__values__===i&&(this.__values__=yo(this.value()));var t=this.__index__>=this.__values__.length,n=t?i:this.__values__[this.__index__++];return{done:t,value:n}}function vh(){return this}function wh(t){for(var n,e=this;e instanceof tr;){var r=Qu(e);r.__index__=0,r.__values__=i,n?s.__wrapped__=r:n=r;var s=r;e=e.__wrapped__}return s.__wrapped__=t,n}function yh(){var t=this.__wrapped__;if(t instanceof z){var n=t;return this.__actions__.length&&(n=new z(this)),n=n.reverse(),n.__actions__.push({func:gr,args:[Di],thisArg:i}),new Kt(n,this.__chain__)}return this.thru(Di)}function mh(){return mu(this.__wrapped__,this.__actions__)}var xh=or(function(t,n,e){X.call(t,e)?++t[e]:cn(t,e,1)});function Sh(t,n,e){var r=U(t)?Ws:hc;return e&&mt(t,n,e)&&(n=i),r(t,O(n,3))}function Ah(t,n){var e=U(t)?yn:ru;return e(t,O(n,3))}var bh=Ou(Vu),Ch=Ou(ju);function Ph(t,n){return pt(_r(t,n),1)}function Ih(t,n){return pt(_r(t,n),un)}function Rh(t,n,e){return e=e===i?1:B(e),pt(_r(t,n),e)}function so(t,n){var e=U(t)?Bt:An;return e(t,O(n,3))}function uo(t,n){var e=U(t)?Ga:eu;return e(t,O(n,3))}var Eh=or(function(t,n,e){X.call(t,e)?t[e].push(n):cn(t,e,[n])});function Th(t,n,e,r){t=Ct(t)?t:ee(t),e=e&&!r?B(e):0;var s=t.length;return e<0&&(e=ft(s+e,0)),xr(t)?e<=s&&t.indexOf(n,e)>-1:!!s&&Hn(t,n,e)>-1}var Oh=q(function(t,n,e){var r=-1,s=typeof n=="function",o=Ct(t)?_(t.length):[];return An(t,function(f){o[++r]=s?Tt(n,f,e):we(f,n,e)}),o}),Lh=or(function(t,n,e){cn(t,e,n)});function _r(t,n){var e=U(t)?et:fu;return e(t,O(n,3))}function Wh(t,n,e,r){return t==null?[]:(U(n)||(n=n==null?[]:[n]),e=r?i:e,U(e)||(e=e==null?[]:[e]),du(t,n,e))}var Dh=or(function(t,n,e){t[e?0:1].push(n)},function(){return[[],[]]});function Fh(t,n,e){var r=U(t)?Jr:Ns,s=arguments.length<3;return r(t,O(n,4),e,s,An)}function Uh(t,n,e){var r=U(t)?Ja:Ns,s=arguments.length<3;return r(t,O(n,4),e,s,eu)}function Nh(t,n){var e=U(t)?yn:ru;return e(t,yr(O(n,3)))}function $h(t){var n=U(t)?Vs:Tc;return n(t)}function Bh(t,n,e){(e?mt(t,n,e):n===i)?n=1:n=B(n);var r=U(t)?oc:Oc;return r(t,n)}function Mh(t){var n=U(t)?ac:Wc;return n(t)}function Kh(t){if(t==null)return 0;if(Ct(t))return xr(t)?Gn(t):t.length;var n=vt(t);return n==Jt||n==Zt?t.size:hi(t).length}function qh(t,n,e){var r=U(t)?Zr:Dc;return e&&mt(t,n,e)&&(n=i),r(t,O(n,3))}var kh=q(function(t,n){if(t==null)return[];var e=n.length;return e>1&&mt(t,n[0],n[1])?n=[]:e>2&&mt(n[0],n[1],n[2])&&(n=[n[0]]),du(t,pt(n,1),[])}),vr=Af||function(){return dt.Date.now()};function Hh(t,n){if(typeof n!="function")throw new Mt(x);return t=B(t),function(){if(--t<1)return n.apply(this,arguments)}}function oo(t,n,e){return n=e?i:n,n=t&&n==null?t.length:n,ln(t,Ut,i,i,i,i,n)}function ao(t,n){var e;if(typeof n!="function")throw new Mt(x);return t=B(t),function(){return--t>0&&(e=n.apply(this,arguments)),t<=1&&(n=i),e}}var Ui=q(function(t,n,e){var r=k;if(e.length){var s=xn(e,te(Ui));r|=Gt}return ln(t,r,n,e,s)}),fo=q(function(t,n,e){var r=k|vn;if(e.length){var s=xn(e,te(fo));r|=Gt}return ln(n,r,t,e,s)});function co(t,n,e){n=e?i:n;var r=ln(t,ht,i,i,i,i,i,n);return r.placeholder=co.placeholder,r}function lo(t,n,e){n=e?i:n;var r=ln(t,gt,i,i,i,i,i,n);return r.placeholder=lo.placeholder,r}function ho(t,n,e){var r,s,o,f,c,d,y=0,m=!1,S=!1,b=!0;if(typeof t!="function")throw new Mt(x);n=zt(n)||0,rt(e)&&(m=!!e.leading,S="maxWait"in e,o=S?ft(zt(e.maxWait)||0,n):o,b="trailing"in e?!!e.trailing:b);function R(ut){var Vt=r,_n=s;return r=s=i,y=ut,f=t.apply(_n,Vt),f}function L(ut){return y=ut,c=Ae(H,n),m?R(ut):f}function M(ut){var Vt=ut-d,_n=ut-y,Lo=n-Vt;return S?_t(Lo,o-_n):Lo}function W(ut){var Vt=ut-d,_n=ut-y;return d===i||Vt>=n||Vt<0||S&&_n>=o}function H(){var ut=vr();if(W(ut))return G(ut);c=Ae(H,M(ut))}function G(ut){return c=i,b&&r?R(ut):(r=s=i,f)}function Dt(){c!==i&&Su(c),y=0,r=d=s=c=i}function xt(){return c===i?f:G(vr())}function Ft(){var ut=vr(),Vt=W(ut);if(r=arguments,s=this,d=ut,Vt){if(c===i)return L(d);if(S)return Su(c),c=Ae(H,n),R(d)}return c===i&&(c=Ae(H,n)),f}return Ft.cancel=Dt,Ft.flush=xt,Ft}var zh=q(function(t,n){return nu(t,1,n)}),Gh=q(function(t,n,e){return nu(t,zt(n)||0,e)});function Jh(t){return ln(t,Rt)}function wr(t,n){if(typeof t!="function"||n!=null&&typeof n!="function")throw new Mt(x);var e=function(){var r=arguments,s=n?n.apply(this,r):r[0],o=e.cache;if(o.has(s))return o.get(s);var f=t.apply(this,r);return e.cache=o.set(s,f)||o,f};return e.cache=new(wr.Cache||fn),e}wr.Cache=fn;function yr(t){if(typeof t!="function")throw new Mt(x);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}function Zh(t){return ao(2,t)}var Yh=Fc(function(t,n){n=n.length==1&&U(n[0])?et(n[0],Ot(O())):et(pt(n,1),Ot(O()));var e=n.length;return q(function(r){for(var s=-1,o=_t(r.length,e);++s<o;)r[s]=n[s].call(this,r[s]);return Tt(t,this,r)})}),Ni=q(function(t,n){var e=xn(n,te(Ni));return ln(t,Gt,i,n,e)}),po=q(function(t,n){var e=xn(n,te(po));return ln(t,Rn,i,n,e)}),Xh=hn(function(t,n){return ln(t,jt,i,i,i,n)});function Qh(t,n){if(typeof t!="function")throw new Mt(x);return n=n===i?n:B(n),q(t,n)}function Vh(t,n){if(typeof t!="function")throw new Mt(x);return n=n==null?0:ft(B(n),0),q(function(e){var r=e[n],s=Pn(e,0,n);return r&&mn(s,r),Tt(t,this,s)})}function jh(t,n,e){var r=!0,s=!0;if(typeof t!="function")throw new Mt(x);return rt(e)&&(r="leading"in e?!!e.leading:r,s="trailing"in e?!!e.trailing:s),ho(t,n,{leading:r,maxWait:n,trailing:s})}function td(t){return oo(t,1)}function nd(t,n){return Ni(xi(n),t)}function ed(){if(!arguments.length)return[];var t=arguments[0];return U(t)?t:[t]}function rd(t){return qt(t,P)}function id(t,n){return n=typeof n=="function"?n:i,qt(t,P,n)}function sd(t){return qt(t,A|P)}function ud(t,n){return n=typeof n=="function"?n:i,qt(t,A|P,n)}function od(t,n){return n==null||tu(t,n,lt(n))}function Qt(t,n){return t===n||t!==t&&n!==n}var ad=lr(fi),fd=lr(function(t,n){return t>=n}),$n=uu(function(){return arguments}())?uu:function(t){return it(t)&&X.call(t,"callee")&&!Gs.call(t,"callee")},U=_.isArray,cd=Is?Ot(Is):wc;function Ct(t){return t!=null&&mr(t.length)&&!pn(t)}function st(t){return it(t)&&Ct(t)}function ld(t){return t===!0||t===!1||it(t)&&yt(t)==St}var In=Cf||Zi,hd=Rs?Ot(Rs):yc;function dd(t){return it(t)&&t.nodeType===1&&!be(t)}function pd(t){if(t==null)return!0;if(Ct(t)&&(U(t)||typeof t=="string"||typeof t.splice=="function"||In(t)||ne(t)||$n(t)))return!t.length;var n=vt(t);if(n==Jt||n==Zt)return!t.size;if(Se(t))return!hi(t).length;for(var e in t)if(X.call(t,e))return!1;return!0}function gd(t,n){return ye(t,n)}function _d(t,n,e){e=typeof e=="function"?e:i;var r=e?e(t,n):i;return r===i?ye(t,n,i,e):!!r}function $i(t){if(!it(t))return!1;var n=yt(t);return n==At||n==Le||typeof t.message=="string"&&typeof t.name=="string"&&!be(t)}function vd(t){return typeof t=="number"&&Zs(t)}function pn(t){if(!rt(t))return!1;var n=yt(t);return n==We||n==ns||n==ot||n==Mo}function go(t){return typeof t=="number"&&t==B(t)}function mr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=tn}function rt(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}function it(t){return t!=null&&typeof t=="object"}var _o=Es?Ot(Es):xc;function wd(t,n){return t===n||li(t,n,Ri(n))}function yd(t,n,e){return e=typeof e=="function"?e:i,li(t,n,Ri(n),e)}function md(t){return vo(t)&&t!=+t}function xd(t){if(il(t))throw new F(v);return ou(t)}function Sd(t){return t===null}function Ad(t){return t==null}function vo(t){return typeof t=="number"||it(t)&&yt(t)==se}function be(t){if(!it(t)||yt(t)!=on)return!1;var n=Je(t);if(n===null)return!0;var e=X.call(n,"constructor")&&n.constructor;return typeof e=="function"&&e instanceof e&&ke.call(e)==yf}var Bi=Ts?Ot(Ts):Sc;function bd(t){return go(t)&&t>=-tn&&t<=tn}var wo=Os?Ot(Os):Ac;function xr(t){return typeof t=="string"||!U(t)&&it(t)&&yt(t)==oe}function Wt(t){return typeof t=="symbol"||it(t)&&yt(t)==De}var ne=Ls?Ot(Ls):bc;function Cd(t){return t===i}function Pd(t){return it(t)&&vt(t)==ae}function Id(t){return it(t)&&yt(t)==qo}var Rd=lr(di),Ed=lr(function(t,n){return t<=n});function yo(t){if(!t)return[];if(Ct(t))return xr(t)?Yt(t):bt(t);if(le&&t[le])return of(t[le]());var n=vt(t),e=n==Jt?ti:n==Zt?Me:ee;return e(t)}function gn(t){if(!t)return t===0?t:0;if(t=zt(t),t===un||t===-un){var n=t<0?-1:1;return n*Cr}return t===t?t:0}function B(t){var n=gn(t),e=n%1;return n===n?e?n-e:n:0}function mo(t){return t?Dn(B(t),0,Nt):0}function zt(t){if(typeof t=="number")return t;if(Wt(t))return Kn;if(rt(t)){var n=typeof t.valueOf=="function"?t.valueOf():t;t=rt(n)?n+"":n}if(typeof t!="string")return t===0?t:+t;t=$s(t);var e=fa.test(t);return e||la.test(t)?ka(t.slice(2),e?2:8):aa.test(t)?Kn:+t}function xo(t){return en(t,Pt(t))}function Td(t){return t?Dn(B(t),-tn,tn):t===0?t:0}function Y(t){return t==null?"":Lt(t)}var Od=Vn(function(t,n){if(Se(n)||Ct(n)){en(n,lt(n),t);return}for(var e in n)X.call(n,e)&&_e(t,e,n[e])}),So=Vn(function(t,n){en(n,Pt(n),t)}),Sr=Vn(function(t,n,e,r){en(n,Pt(n),t,r)}),Ld=Vn(function(t,n,e,r){en(n,lt(n),t,r)}),Wd=hn(ui);function Dd(t,n){var e=Qn(t);return n==null?e:js(e,n)}var Fd=q(function(t,n){t=V(t);var e=-1,r=n.length,s=r>2?n[2]:i;for(s&&mt(n[0],n[1],s)&&(r=1);++e<r;)for(var o=n[e],f=Pt(o),c=-1,d=f.length;++c<d;){var y=f[c],m=t[y];(m===i||Qt(m,Zn[y])&&!X.call(t,y))&&(t[y]=o[y])}return t}),Ud=q(function(t){return t.push(i,$u),Tt(Ao,i,t)});function Nd(t,n){return Ds(t,O(n,3),nn)}function $d(t,n){return Ds(t,O(n,3),ai)}function Bd(t,n){return t==null?t:oi(t,O(n,3),Pt)}function Md(t,n){return t==null?t:iu(t,O(n,3),Pt)}function Kd(t,n){return t&&nn(t,O(n,3))}function qd(t,n){return t&&ai(t,O(n,3))}function kd(t){return t==null?[]:rr(t,lt(t))}function Hd(t){return t==null?[]:rr(t,Pt(t))}function Mi(t,n,e){var r=t==null?i:Fn(t,n);return r===i?e:r}function zd(t,n){return t!=null&&Ku(t,n,pc)}function Ki(t,n){return t!=null&&Ku(t,n,gc)}var Gd=Wu(function(t,n,e){n!=null&&typeof n.toString!="function"&&(n=He.call(n)),t[n]=e},ki(It)),Jd=Wu(function(t,n,e){n!=null&&typeof n.toString!="function"&&(n=He.call(n)),X.call(t,n)?t[n].push(e):t[n]=[e]},O),Zd=q(we);function lt(t){return Ct(t)?Qs(t):hi(t)}function Pt(t){return Ct(t)?Qs(t,!0):Cc(t)}function Yd(t,n){var e={};return n=O(n,3),nn(t,function(r,s,o){cn(e,n(r,s,o),r)}),e}function Xd(t,n){var e={};return n=O(n,3),nn(t,function(r,s,o){cn(e,s,n(r,s,o))}),e}var Qd=Vn(function(t,n,e){ir(t,n,e)}),Ao=Vn(function(t,n,e,r){ir(t,n,e,r)}),Vd=hn(function(t,n){var e={};if(t==null)return e;var r=!1;n=et(n,function(o){return o=Cn(o,t),r||(r=o.length>1),o}),en(t,Pi(t),e),r&&(e=qt(e,A|D|P,Gc));for(var s=n.length;s--;)wi(e,n[s]);return e});function jd(t,n){return bo(t,yr(O(n)))}var tp=hn(function(t,n){return t==null?{}:Ic(t,n)});function bo(t,n){if(t==null)return{};var e=et(Pi(t),function(r){return[r]});return n=O(n),pu(t,e,function(r,s){return n(r,s[0])})}function np(t,n,e){n=Cn(n,t);var r=-1,s=n.length;for(s||(s=1,t=i);++r<s;){var o=t==null?i:t[rn(n[r])];o===i&&(r=s,o=e),t=pn(o)?o.call(t):o}return t}function ep(t,n,e){return t==null?t:me(t,n,e)}function rp(t,n,e,r){return r=typeof r=="function"?r:i,t==null?t:me(t,n,e,r)}var Co=Uu(lt),Po=Uu(Pt);function ip(t,n,e){var r=U(t),s=r||In(t)||ne(t);if(n=O(n,4),e==null){var o=t&&t.constructor;s?e=r?new o:[]:rt(t)?e=pn(o)?Qn(Je(t)):{}:e={}}return(s?Bt:nn)(t,function(f,c,d){return n(e,f,c,d)}),e}function sp(t,n){return t==null?!0:wi(t,n)}function up(t,n,e){return t==null?t:yu(t,n,xi(e))}function op(t,n,e,r){return r=typeof r=="function"?r:i,t==null?t:yu(t,n,xi(e),r)}function ee(t){return t==null?[]:jr(t,lt(t))}function ap(t){return t==null?[]:jr(t,Pt(t))}function fp(t,n,e){return e===i&&(e=n,n=i),e!==i&&(e=zt(e),e=e===e?e:0),n!==i&&(n=zt(n),n=n===n?n:0),Dn(zt(t),n,e)}function cp(t,n,e){return n=gn(n),e===i?(e=n,n=0):e=gn(e),t=zt(t),_c(t,n,e)}function lp(t,n,e){if(e&&typeof e!="boolean"&&mt(t,n,e)&&(n=e=i),e===i&&(typeof n=="boolean"?(e=n,n=i):typeof t=="boolean"&&(e=t,t=i)),t===i&&n===i?(t=0,n=1):(t=gn(t),n===i?(n=t,t=0):n=gn(n)),t>n){var r=t;t=n,n=r}if(e||t%1||n%1){var s=Ys();return _t(t+s*(n-t+qa("1e-"+((s+"").length-1))),n)}return gi(t,n)}var hp=jn(function(t,n,e){return n=n.toLowerCase(),t+(e?Io(n):n)});function Io(t){return qi(Y(t).toLowerCase())}function Ro(t){return t=Y(t),t&&t.replace(da,nf).replace(La,"")}function dp(t,n,e){t=Y(t),n=Lt(n);var r=t.length;e=e===i?r:Dn(B(e),0,r);var s=e;return e-=n.length,e>=0&&t.slice(e,s)==n}function pp(t){return t=Y(t),t&&Jo.test(t)?t.replace(is,ef):t}function gp(t){return t=Y(t),t&&jo.test(t)?t.replace(Nr,"\\$&"):t}var _p=jn(function(t,n,e){return t+(e?"-":"")+n.toLowerCase()}),vp=jn(function(t,n,e){return t+(e?" ":"")+n.toLowerCase()}),wp=Tu("toLowerCase");function yp(t,n,e){t=Y(t),n=B(n);var r=n?Gn(t):0;if(!n||r>=n)return t;var s=(n-r)/2;return cr(Qe(s),e)+t+cr(Xe(s),e)}function mp(t,n,e){t=Y(t),n=B(n);var r=n?Gn(t):0;return n&&r<n?t+cr(n-r,e):t}function xp(t,n,e){t=Y(t),n=B(n);var r=n?Gn(t):0;return n&&r<n?cr(n-r,e)+t:t}function Sp(t,n,e){return e||n==null?n=0:n&&(n=+n),Ef(Y(t).replace($r,""),n||0)}function Ap(t,n,e){return(e?mt(t,n,e):n===i)?n=1:n=B(n),_i(Y(t),n)}function bp(){var t=arguments,n=Y(t[0]);return t.length<3?n:n.replace(t[1],t[2])}var Cp=jn(function(t,n,e){return t+(e?"_":"")+n.toLowerCase()});function Pp(t,n,e){return e&&typeof e!="number"&&mt(t,n,e)&&(n=e=i),e=e===i?Nt:e>>>0,e?(t=Y(t),t&&(typeof n=="string"||n!=null&&!Bi(n))&&(n=Lt(n),!n&&zn(t))?Pn(Yt(t),0,e):t.split(n,e)):[]}var Ip=jn(function(t,n,e){return t+(e?" ":"")+qi(n)});function Rp(t,n,e){return t=Y(t),e=e==null?0:Dn(B(e),0,t.length),n=Lt(n),t.slice(e,e+n.length)==n}function Ep(t,n,e){var r=u.templateSettings;e&&mt(t,n,e)&&(n=i),t=Y(t),n=Sr({},n,r,Nu);var s=Sr({},n.imports,r.imports,Nu),o=lt(s),f=jr(s,o),c,d,y=0,m=n.interpolate||Fe,S="__p += '",b=ni((n.escape||Fe).source+"|"+m.source+"|"+(m===ss?oa:Fe).source+"|"+(n.evaluate||Fe).source+"|$","g"),R="//# sourceURL="+(X.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Na+"]")+`
|
|
11
|
-
`;t.replace(
|
|
12
|
-
__e(`+
|
|
13
|
-
'`),
|
|
14
|
-
`+
|
|
8
|
+
*/br.exports;(function(f,o){(function(){var i,h="4.17.21",g=200,y="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",x="Expected a function",I="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",B=500,Y="__lodash_placeholder__",P=1,U=2,A=4,T=1,J=2,ct=1,pe=2,Tn=4,Q=8,re=16,yt=32,It=64,lt=128,Re=256,an=512,On=30,Ke="...",zt=800,Ln=16,qe=1,Et=2,Dn=3,Nt=1/0,Jt=9007199254740991,ft=17976931348623157e292,He=NaN,Ft=4294967295,Pr=Ft-1,Cr=Ft>>>1,Rr=[["ary",lt],["bind",ct],["bindKey",pe],["curry",Q],["curryRight",re],["flip",an],["partial",yt],["partialRight",It],["rearg",Re]],ge="[object Arguments]",Ie="[object Array]",Ir="[object AsyncFunction]",Ee="[object Boolean]",Te="[object Date]",Er="[object DOMException]",N="[object Error]",tt="[object Function]",vt="[object GeneratorFunction]",ut="[object Map]",_e="[object Number]",Zt="[object Null]",ie="[object Object]",rs="[object Promise]",$a="[object Proxy]",on="[object RegExp]",Yt="[object Set]",cn="[object String]",Wn="[object Symbol]",Ba="[object Undefined]",fn="[object WeakMap]",ka="[object WeakSet]",ln="[object ArrayBuffer]",Ge="[object DataView]",Tr="[object Float32Array]",Or="[object Float64Array]",Lr="[object Int8Array]",Dr="[object Int16Array]",Wr="[object Int32Array]",Ur="[object Uint8Array]",Nr="[object Uint8ClampedArray]",Fr="[object Uint16Array]",Mr="[object Uint32Array]",Ka=/\b__p \+= '';/g,qa=/\b(__p \+=) '' \+/g,Ha=/(__e\(.*?\)|\b__t\)) \+\n'';/g,is=/&(?:amp|lt|gt|quot|#39);/g,ss=/[&<>"']/g,Ga=RegExp(is.source),za=RegExp(ss.source),Ja=/<%-([\s\S]+?)%>/g,Za=/<%([\s\S]+?)%>/g,us=/<%=([\s\S]+?)%>/g,Ya=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Xa=/^\w*$/,Qa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$r=/[\\^$.*+?()[\]{}|]/g,Va=RegExp($r.source),Br=/^\s+/,ja=/\s/,to=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,eo=/\{\n\/\* \[wrapped with (.+)\] \*/,no=/,? & /,ro=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,io=/[()=,{}\[\]\/\s]/,so=/\\(\\)?/g,uo=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,as=/\w*$/,ao=/^[-+]0x[0-9a-f]+$/i,oo=/^0b[01]+$/i,co=/^\[object .+?Constructor\]$/,fo=/^0o[0-7]+$/i,lo=/^(?:0|[1-9]\d*)$/,ho=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Un=/($^)/,po=/['\n\r\u2028\u2029\\]/g,Nn="\\ud800-\\udfff",go="\\u0300-\\u036f",_o="\\ufe20-\\ufe2f",yo="\\u20d0-\\u20ff",os=go+_o+yo,cs="\\u2700-\\u27bf",fs="a-z\\xdf-\\xf6\\xf8-\\xff",vo="\\xac\\xb1\\xd7\\xf7",wo="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",mo="\\u2000-\\u206f",xo=" \\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",ls="A-Z\\xc0-\\xd6\\xd8-\\xde",hs="\\ufe0e\\ufe0f",ds=vo+wo+mo+xo,kr="['’]",So="["+Nn+"]",ps="["+ds+"]",Fn="["+os+"]",gs="\\d+",bo="["+cs+"]",_s="["+fs+"]",ys="[^"+Nn+ds+gs+cs+fs+ls+"]",Kr="\\ud83c[\\udffb-\\udfff]",Ao="(?:"+Fn+"|"+Kr+")",vs="[^"+Nn+"]",qr="(?:\\ud83c[\\udde6-\\uddff]){2}",Hr="[\\ud800-\\udbff][\\udc00-\\udfff]",ze="["+ls+"]",ws="\\u200d",ms="(?:"+_s+"|"+ys+")",Po="(?:"+ze+"|"+ys+")",xs="(?:"+kr+"(?:d|ll|m|re|s|t|ve))?",Ss="(?:"+kr+"(?:D|LL|M|RE|S|T|VE))?",bs=Ao+"?",As="["+hs+"]?",Co="(?:"+ws+"(?:"+[vs,qr,Hr].join("|")+")"+As+bs+")*",Ro="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Io="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ps=As+bs+Co,Eo="(?:"+[bo,qr,Hr].join("|")+")"+Ps,To="(?:"+[vs+Fn+"?",Fn,qr,Hr,So].join("|")+")",Oo=RegExp(kr,"g"),Lo=RegExp(Fn,"g"),Gr=RegExp(Kr+"(?="+Kr+")|"+To+Ps,"g"),Do=RegExp([ze+"?"+_s+"+"+xs+"(?="+[ps,ze,"$"].join("|")+")",Po+"+"+Ss+"(?="+[ps,ze+ms,"$"].join("|")+")",ze+"?"+ms+"+"+xs,ze+"+"+Ss,Io,Ro,gs,Eo].join("|"),"g"),Wo=RegExp("["+ws+Nn+os+hs+"]"),Uo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,No=["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"],Fo=-1,nt={};nt[Tr]=nt[Or]=nt[Lr]=nt[Dr]=nt[Wr]=nt[Ur]=nt[Nr]=nt[Fr]=nt[Mr]=!0,nt[ge]=nt[Ie]=nt[ln]=nt[Ee]=nt[Ge]=nt[Te]=nt[N]=nt[tt]=nt[ut]=nt[_e]=nt[ie]=nt[on]=nt[Yt]=nt[cn]=nt[fn]=!1;var et={};et[ge]=et[Ie]=et[ln]=et[Ge]=et[Ee]=et[Te]=et[Tr]=et[Or]=et[Lr]=et[Dr]=et[Wr]=et[ut]=et[_e]=et[ie]=et[on]=et[Yt]=et[cn]=et[Wn]=et[Ur]=et[Nr]=et[Fr]=et[Mr]=!0,et[N]=et[tt]=et[fn]=!1;var Mo={À:"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"},$o={"&":"&","<":"<",">":">",'"':""","'":"'"},Bo={"&":"&","<":"<",">":">",""":'"',"'":"'"},ko={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ko=parseFloat,qo=parseInt,Cs=typeof In=="object"&&In&&In.Object===Object&&In,Ho=typeof self=="object"&&self&&self.Object===Object&&self,gt=Cs||Ho||Function("return this")(),zr=o&&!o.nodeType&&o,Oe=zr&&!0&&f&&!f.nodeType&&f,Rs=Oe&&Oe.exports===zr,Jr=Rs&&Cs.process,Mt=function(){try{var d=Oe&&Oe.require&&Oe.require("util").types;return d||Jr&&Jr.binding&&Jr.binding("util")}catch{}}(),Is=Mt&&Mt.isArrayBuffer,Es=Mt&&Mt.isDate,Ts=Mt&&Mt.isMap,Os=Mt&&Mt.isRegExp,Ls=Mt&&Mt.isSet,Ds=Mt&&Mt.isTypedArray;function Tt(d,v,_){switch(_.length){case 0:return d.call(v);case 1:return d.call(v,_[0]);case 2:return d.call(v,_[0],_[1]);case 3:return d.call(v,_[0],_[1],_[2])}return d.apply(v,_)}function Go(d,v,_,R){for(var F=-1,Z=d==null?0:d.length;++F<Z;){var ht=d[F];v(R,ht,_(ht),d)}return R}function $t(d,v){for(var _=-1,R=d==null?0:d.length;++_<R&&v(d[_],_,d)!==!1;);return d}function zo(d,v){for(var _=d==null?0:d.length;_--&&v(d[_],_,d)!==!1;);return d}function Ws(d,v){for(var _=-1,R=d==null?0:d.length;++_<R;)if(!v(d[_],_,d))return!1;return!0}function ye(d,v){for(var _=-1,R=d==null?0:d.length,F=0,Z=[];++_<R;){var ht=d[_];v(ht,_,d)&&(Z[F++]=ht)}return Z}function Mn(d,v){var _=d==null?0:d.length;return!!_&&Je(d,v,0)>-1}function Zr(d,v,_){for(var R=-1,F=d==null?0:d.length;++R<F;)if(_(v,d[R]))return!0;return!1}function rt(d,v){for(var _=-1,R=d==null?0:d.length,F=Array(R);++_<R;)F[_]=v(d[_],_,d);return F}function ve(d,v){for(var _=-1,R=v.length,F=d.length;++_<R;)d[F+_]=v[_];return d}function Yr(d,v,_,R){var F=-1,Z=d==null?0:d.length;for(R&&Z&&(_=d[++F]);++F<Z;)_=v(_,d[F],F,d);return _}function Jo(d,v,_,R){var F=d==null?0:d.length;for(R&&F&&(_=d[--F]);F--;)_=v(_,d[F],F,d);return _}function Xr(d,v){for(var _=-1,R=d==null?0:d.length;++_<R;)if(v(d[_],_,d))return!0;return!1}var Zo=Qr("length");function Yo(d){return d.split("")}function Xo(d){return d.match(ro)||[]}function Us(d,v,_){var R;return _(d,function(F,Z,ht){if(v(F,Z,ht))return R=Z,!1}),R}function $n(d,v,_,R){for(var F=d.length,Z=_+(R?1:-1);R?Z--:++Z<F;)if(v(d[Z],Z,d))return Z;return-1}function Je(d,v,_){return v===v?oc(d,v,_):$n(d,Ns,_)}function Qo(d,v,_,R){for(var F=_-1,Z=d.length;++F<Z;)if(R(d[F],v))return F;return-1}function Ns(d){return d!==d}function Fs(d,v){var _=d==null?0:d.length;return _?jr(d,v)/_:He}function Qr(d){return function(v){return v==null?i:v[d]}}function Vr(d){return function(v){return d==null?i:d[v]}}function Ms(d,v,_,R,F){return F(d,function(Z,ht,j){_=R?(R=!1,Z):v(_,Z,ht,j)}),_}function Vo(d,v){var _=d.length;for(d.sort(v);_--;)d[_]=d[_].value;return d}function jr(d,v){for(var _,R=-1,F=d.length;++R<F;){var Z=v(d[R]);Z!==i&&(_=_===i?Z:_+Z)}return _}function ti(d,v){for(var _=-1,R=Array(d);++_<d;)R[_]=v(_);return R}function jo(d,v){return rt(v,function(_){return[_,d[_]]})}function $s(d){return d&&d.slice(0,qs(d)+1).replace(Br,"")}function Ot(d){return function(v){return d(v)}}function ei(d,v){return rt(v,function(_){return d[_]})}function hn(d,v){return d.has(v)}function Bs(d,v){for(var _=-1,R=d.length;++_<R&&Je(v,d[_],0)>-1;);return _}function ks(d,v){for(var _=d.length;_--&&Je(v,d[_],0)>-1;);return _}function tc(d,v){for(var _=d.length,R=0;_--;)d[_]===v&&++R;return R}var ec=Vr(Mo),nc=Vr($o);function rc(d){return"\\"+ko[d]}function ic(d,v){return d==null?i:d[v]}function Ze(d){return Wo.test(d)}function sc(d){return Uo.test(d)}function uc(d){for(var v,_=[];!(v=d.next()).done;)_.push(v.value);return _}function ni(d){var v=-1,_=Array(d.size);return d.forEach(function(R,F){_[++v]=[F,R]}),_}function Ks(d,v){return function(_){return d(v(_))}}function we(d,v){for(var _=-1,R=d.length,F=0,Z=[];++_<R;){var ht=d[_];(ht===v||ht===Y)&&(d[_]=Y,Z[F++]=_)}return Z}function Bn(d){var v=-1,_=Array(d.size);return d.forEach(function(R){_[++v]=R}),_}function ac(d){var v=-1,_=Array(d.size);return d.forEach(function(R){_[++v]=[R,R]}),_}function oc(d,v,_){for(var R=_-1,F=d.length;++R<F;)if(d[R]===v)return R;return-1}function cc(d,v,_){for(var R=_+1;R--;)if(d[R]===v)return R;return R}function Ye(d){return Ze(d)?lc(d):Zo(d)}function Xt(d){return Ze(d)?hc(d):Yo(d)}function qs(d){for(var v=d.length;v--&&ja.test(d.charAt(v)););return v}var fc=Vr(Bo);function lc(d){for(var v=Gr.lastIndex=0;Gr.test(d);)++v;return v}function hc(d){return d.match(Gr)||[]}function dc(d){return d.match(Do)||[]}var pc=function d(v){v=v==null?gt:Xe.defaults(gt.Object(),v,Xe.pick(gt,No));var _=v.Array,R=v.Date,F=v.Error,Z=v.Function,ht=v.Math,j=v.Object,ri=v.RegExp,gc=v.String,Bt=v.TypeError,kn=_.prototype,_c=Z.prototype,Qe=j.prototype,Kn=v["__core-js_shared__"],qn=_c.toString,V=Qe.hasOwnProperty,yc=0,Hs=function(){var t=/[^.]+$/.exec(Kn&&Kn.keys&&Kn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Hn=Qe.toString,vc=qn.call(j),wc=gt._,mc=ri("^"+qn.call(V).replace($r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Gn=Rs?v.Buffer:i,me=v.Symbol,zn=v.Uint8Array,Gs=Gn?Gn.allocUnsafe:i,Jn=Ks(j.getPrototypeOf,j),zs=j.create,Js=Qe.propertyIsEnumerable,Zn=kn.splice,Zs=me?me.isConcatSpreadable:i,dn=me?me.iterator:i,Le=me?me.toStringTag:i,Yn=function(){try{var t=Fe(j,"defineProperty");return t({},"",{}),t}catch{}}(),xc=v.clearTimeout!==gt.clearTimeout&&v.clearTimeout,Sc=R&&R.now!==gt.Date.now&&R.now,bc=v.setTimeout!==gt.setTimeout&&v.setTimeout,Xn=ht.ceil,Qn=ht.floor,ii=j.getOwnPropertySymbols,Ac=Gn?Gn.isBuffer:i,Ys=v.isFinite,Pc=kn.join,Cc=Ks(j.keys,j),dt=ht.max,wt=ht.min,Rc=R.now,Ic=v.parseInt,Xs=ht.random,Ec=kn.reverse,si=Fe(v,"DataView"),pn=Fe(v,"Map"),ui=Fe(v,"Promise"),Ve=Fe(v,"Set"),gn=Fe(v,"WeakMap"),_n=Fe(j,"create"),Vn=gn&&new gn,je={},Tc=Me(si),Oc=Me(pn),Lc=Me(ui),Dc=Me(Ve),Wc=Me(gn),jn=me?me.prototype:i,yn=jn?jn.valueOf:i,Qs=jn?jn.toString:i;function u(t){if(st(t)&&!M(t)&&!(t instanceof H)){if(t instanceof kt)return t;if(V.call(t,"__wrapped__"))return Vu(t)}return new kt(t)}var tn=function(){function t(){}return function(e){if(!it(e))return{};if(zs)return zs(e);t.prototype=e;var n=new t;return t.prototype=i,n}}();function tr(){}function kt(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=i}u.templateSettings={escape:Ja,evaluate:Za,interpolate:us,variable:"",imports:{_:u}},u.prototype=tr.prototype,u.prototype.constructor=u,kt.prototype=tn(tr.prototype),kt.prototype.constructor=kt;function H(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ft,this.__views__=[]}function Uc(){var t=new H(this.__wrapped__);return t.__actions__=At(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=At(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=At(this.__views__),t}function Nc(){if(this.__filtered__){var t=new H(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Fc(){var t=this.__wrapped__.value(),e=this.__dir__,n=M(t),r=e<0,s=n?t.length:0,a=Xf(0,s,this.__views__),c=a.start,l=a.end,p=l-c,w=r?l:c-1,m=this.__iteratees__,S=m.length,C=0,E=wt(p,this.__takeCount__);if(!n||!r&&s==p&&E==p)return xu(t,this.__actions__);var D=[];t:for(;p--&&C<E;){w+=e;for(var k=-1,W=t[w];++k<S;){var q=m[k],G=q.iteratee,Wt=q.type,bt=G(W);if(Wt==Et)W=bt;else if(!bt){if(Wt==qe)continue t;break t}}D[C++]=W}return D}H.prototype=tn(tr.prototype),H.prototype.constructor=H;function De(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Mc(){this.__data__=_n?_n(null):{},this.size=0}function $c(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function Bc(t){var e=this.__data__;if(_n){var n=e[t];return n===b?i:n}return V.call(e,t)?e[t]:i}function kc(t){var e=this.__data__;return _n?e[t]!==i:V.call(e,t)}function Kc(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=_n&&e===i?b:e,this}De.prototype.clear=Mc,De.prototype.delete=$c,De.prototype.get=Bc,De.prototype.has=kc,De.prototype.set=Kc;function se(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function qc(){this.__data__=[],this.size=0}function Hc(t){var e=this.__data__,n=er(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Zn.call(e,n,1),--this.size,!0}function Gc(t){var e=this.__data__,n=er(e,t);return n<0?i:e[n][1]}function zc(t){return er(this.__data__,t)>-1}function Jc(t,e){var n=this.__data__,r=er(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}se.prototype.clear=qc,se.prototype.delete=Hc,se.prototype.get=Gc,se.prototype.has=zc,se.prototype.set=Jc;function ue(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Zc(){this.size=0,this.__data__={hash:new De,map:new(pn||se),string:new De}}function Yc(t){var e=dr(this,t).delete(t);return this.size-=e?1:0,e}function Xc(t){return dr(this,t).get(t)}function Qc(t){return dr(this,t).has(t)}function Vc(t,e){var n=dr(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}ue.prototype.clear=Zc,ue.prototype.delete=Yc,ue.prototype.get=Xc,ue.prototype.has=Qc,ue.prototype.set=Vc;function We(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new ue;++e<n;)this.add(t[e])}function jc(t){return this.__data__.set(t,b),this}function tf(t){return this.__data__.has(t)}We.prototype.add=We.prototype.push=jc,We.prototype.has=tf;function Qt(t){var e=this.__data__=new se(t);this.size=e.size}function ef(){this.__data__=new se,this.size=0}function nf(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function rf(t){return this.__data__.get(t)}function sf(t){return this.__data__.has(t)}function uf(t,e){var n=this.__data__;if(n instanceof se){var r=n.__data__;if(!pn||r.length<g-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new ue(r)}return n.set(t,e),this.size=n.size,this}Qt.prototype.clear=ef,Qt.prototype.delete=nf,Qt.prototype.get=rf,Qt.prototype.has=sf,Qt.prototype.set=uf;function Vs(t,e){var n=M(t),r=!n&&$e(t),s=!n&&!r&&Pe(t),a=!n&&!r&&!s&&sn(t),c=n||r||s||a,l=c?ti(t.length,gc):[],p=l.length;for(var w in t)(e||V.call(t,w))&&!(c&&(w=="length"||s&&(w=="offset"||w=="parent")||a&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||fe(w,p)))&&l.push(w);return l}function js(t){var e=t.length;return e?t[yi(0,e-1)]:i}function af(t,e){return pr(At(t),Ue(e,0,t.length))}function of(t){return pr(At(t))}function ai(t,e,n){(n!==i&&!Vt(t[e],n)||n===i&&!(e in t))&&ae(t,e,n)}function vn(t,e,n){var r=t[e];(!(V.call(t,e)&&Vt(r,n))||n===i&&!(e in t))&&ae(t,e,n)}function er(t,e){for(var n=t.length;n--;)if(Vt(t[n][0],e))return n;return-1}function cf(t,e,n,r){return xe(t,function(s,a,c){e(r,s,n(s),c)}),r}function tu(t,e){return t&&ee(e,pt(e),t)}function ff(t,e){return t&&ee(e,Ct(e),t)}function ae(t,e,n){e=="__proto__"&&Yn?Yn(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function oi(t,e){for(var n=-1,r=e.length,s=_(r),a=t==null;++n<r;)s[n]=a?i:Ki(t,e[n]);return s}function Ue(t,e,n){return t===t&&(n!==i&&(t=t<=n?t:n),e!==i&&(t=t>=e?t:e)),t}function Kt(t,e,n,r,s,a){var c,l=e&P,p=e&U,w=e&A;if(n&&(c=s?n(t,r,s,a):n(t)),c!==i)return c;if(!it(t))return t;var m=M(t);if(m){if(c=Vf(t),!l)return At(t,c)}else{var S=mt(t),C=S==tt||S==vt;if(Pe(t))return Au(t,l);if(S==ie||S==ge||C&&!s){if(c=p||C?{}:qu(t),!l)return p?kf(t,ff(c,t)):Bf(t,tu(c,t))}else{if(!et[S])return s?t:{};c=jf(t,S,l)}}a||(a=new Qt);var E=a.get(t);if(E)return E;a.set(t,c),va(t)?t.forEach(function(W){c.add(Kt(W,e,n,W,t,a))}):_a(t)&&t.forEach(function(W,q){c.set(q,Kt(W,e,n,q,t,a))});var D=w?p?Ii:Ri:p?Ct:pt,k=m?i:D(t);return $t(k||t,function(W,q){k&&(q=W,W=t[q]),vn(c,q,Kt(W,e,n,q,t,a))}),c}function lf(t){var e=pt(t);return function(n){return eu(n,t,e)}}function eu(t,e,n){var r=n.length;if(t==null)return!r;for(t=j(t);r--;){var s=n[r],a=e[s],c=t[s];if(c===i&&!(s in t)||!a(c))return!1}return!0}function nu(t,e,n){if(typeof t!="function")throw new Bt(x);return Pn(function(){t.apply(i,n)},e)}function wn(t,e,n,r){var s=-1,a=Mn,c=!0,l=t.length,p=[],w=e.length;if(!l)return p;n&&(e=rt(e,Ot(n))),r?(a=Zr,c=!1):e.length>=g&&(a=hn,c=!1,e=new We(e));t:for(;++s<l;){var m=t[s],S=n==null?m:n(m);if(m=r||m!==0?m:0,c&&S===S){for(var C=w;C--;)if(e[C]===S)continue t;p.push(m)}else a(e,S,r)||p.push(m)}return p}var xe=Eu(te),ru=Eu(fi,!0);function hf(t,e){var n=!0;return xe(t,function(r,s,a){return n=!!e(r,s,a),n}),n}function nr(t,e,n){for(var r=-1,s=t.length;++r<s;){var a=t[r],c=e(a);if(c!=null&&(l===i?c===c&&!Dt(c):n(c,l)))var l=c,p=a}return p}function df(t,e,n,r){var s=t.length;for(n=$(n),n<0&&(n=-n>s?0:s+n),r=r===i||r>s?s:$(r),r<0&&(r+=s),r=n>r?0:ma(r);n<r;)t[n++]=e;return t}function iu(t,e){var n=[];return xe(t,function(r,s,a){e(r,s,a)&&n.push(r)}),n}function _t(t,e,n,r,s){var a=-1,c=t.length;for(n||(n=el),s||(s=[]);++a<c;){var l=t[a];e>0&&n(l)?e>1?_t(l,e-1,n,r,s):ve(s,l):r||(s[s.length]=l)}return s}var ci=Tu(),su=Tu(!0);function te(t,e){return t&&ci(t,e,pt)}function fi(t,e){return t&&su(t,e,pt)}function rr(t,e){return ye(e,function(n){return le(t[n])})}function Ne(t,e){e=be(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[ne(e[n++])];return n&&n==r?t:i}function uu(t,e,n){var r=e(t);return M(t)?r:ve(r,n(t))}function xt(t){return t==null?t===i?Ba:Zt:Le&&Le in j(t)?Yf(t):ol(t)}function li(t,e){return t>e}function pf(t,e){return t!=null&&V.call(t,e)}function gf(t,e){return t!=null&&e in j(t)}function _f(t,e,n){return t>=wt(e,n)&&t<dt(e,n)}function hi(t,e,n){for(var r=n?Zr:Mn,s=t[0].length,a=t.length,c=a,l=_(a),p=1/0,w=[];c--;){var m=t[c];c&&e&&(m=rt(m,Ot(e))),p=wt(m.length,p),l[c]=!n&&(e||s>=120&&m.length>=120)?new We(c&&m):i}m=t[0];var S=-1,C=l[0];t:for(;++S<s&&w.length<p;){var E=m[S],D=e?e(E):E;if(E=n||E!==0?E:0,!(C?hn(C,D):r(w,D,n))){for(c=a;--c;){var k=l[c];if(!(k?hn(k,D):r(t[c],D,n)))continue t}C&&C.push(D),w.push(E)}}return w}function yf(t,e,n,r){return te(t,function(s,a,c){e(r,n(s),a,c)}),r}function mn(t,e,n){e=be(e,t),t=Ju(t,e);var r=t==null?t:t[ne(Ht(e))];return r==null?i:Tt(r,t,n)}function au(t){return st(t)&&xt(t)==ge}function vf(t){return st(t)&&xt(t)==ln}function wf(t){return st(t)&&xt(t)==Te}function xn(t,e,n,r,s){return t===e?!0:t==null||e==null||!st(t)&&!st(e)?t!==t&&e!==e:mf(t,e,n,r,xn,s)}function mf(t,e,n,r,s,a){var c=M(t),l=M(e),p=c?Ie:mt(t),w=l?Ie:mt(e);p=p==ge?ie:p,w=w==ge?ie:w;var m=p==ie,S=w==ie,C=p==w;if(C&&Pe(t)){if(!Pe(e))return!1;c=!0,m=!1}if(C&&!m)return a||(a=new Qt),c||sn(t)?Bu(t,e,n,r,s,a):Jf(t,e,p,n,r,s,a);if(!(n&T)){var E=m&&V.call(t,"__wrapped__"),D=S&&V.call(e,"__wrapped__");if(E||D){var k=E?t.value():t,W=D?e.value():e;return a||(a=new Qt),s(k,W,n,r,a)}}return C?(a||(a=new Qt),Zf(t,e,n,r,s,a)):!1}function xf(t){return st(t)&&mt(t)==ut}function di(t,e,n,r){var s=n.length,a=s,c=!r;if(t==null)return!a;for(t=j(t);s--;){var l=n[s];if(c&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<a;){l=n[s];var p=l[0],w=t[p],m=l[1];if(c&&l[2]){if(w===i&&!(p in t))return!1}else{var S=new Qt;if(r)var C=r(w,m,p,t,e,S);if(!(C===i?xn(m,w,T|J,r,S):C))return!1}}return!0}function ou(t){if(!it(t)||rl(t))return!1;var e=le(t)?mc:co;return e.test(Me(t))}function Sf(t){return st(t)&&xt(t)==on}function bf(t){return st(t)&&mt(t)==Yt}function Af(t){return st(t)&&mr(t.length)&&!!nt[xt(t)]}function cu(t){return typeof t=="function"?t:t==null?Rt:typeof t=="object"?M(t)?hu(t[0],t[1]):lu(t):Oa(t)}function pi(t){if(!An(t))return Cc(t);var e=[];for(var n in j(t))V.call(t,n)&&n!="constructor"&&e.push(n);return e}function Pf(t){if(!it(t))return al(t);var e=An(t),n=[];for(var r in t)r=="constructor"&&(e||!V.call(t,r))||n.push(r);return n}function gi(t,e){return t<e}function fu(t,e){var n=-1,r=Pt(t)?_(t.length):[];return xe(t,function(s,a,c){r[++n]=e(s,a,c)}),r}function lu(t){var e=Ti(t);return e.length==1&&e[0][2]?Gu(e[0][0],e[0][1]):function(n){return n===t||di(n,t,e)}}function hu(t,e){return Li(t)&&Hu(e)?Gu(ne(t),e):function(n){var r=Ki(n,t);return r===i&&r===e?qi(n,t):xn(e,r,T|J)}}function ir(t,e,n,r,s){t!==e&&ci(e,function(a,c){if(s||(s=new Qt),it(a))Cf(t,e,c,n,ir,r,s);else{var l=r?r(Wi(t,c),a,c+"",t,e,s):i;l===i&&(l=a),ai(t,c,l)}},Ct)}function Cf(t,e,n,r,s,a,c){var l=Wi(t,n),p=Wi(e,n),w=c.get(p);if(w){ai(t,n,w);return}var m=a?a(l,p,n+"",t,e,c):i,S=m===i;if(S){var C=M(p),E=!C&&Pe(p),D=!C&&!E&&sn(p);m=p,C||E||D?M(l)?m=l:at(l)?m=At(l):E?(S=!1,m=Au(p,!0)):D?(S=!1,m=Pu(p,!0)):m=[]:Cn(p)||$e(p)?(m=l,$e(l)?m=xa(l):(!it(l)||le(l))&&(m=qu(p))):S=!1}S&&(c.set(p,m),s(m,p,r,a,c),c.delete(p)),ai(t,n,m)}function du(t,e){var n=t.length;if(n)return e+=e<0?n:0,fe(e,n)?t[e]:i}function pu(t,e,n){e.length?e=rt(e,function(a){return M(a)?function(c){return Ne(c,a.length===1?a[0]:a)}:a}):e=[Rt];var r=-1;e=rt(e,Ot(L()));var s=fu(t,function(a,c,l){var p=rt(e,function(w){return w(a)});return{criteria:p,index:++r,value:a}});return Vo(s,function(a,c){return $f(a,c,n)})}function Rf(t,e){return gu(t,e,function(n,r){return qi(t,r)})}function gu(t,e,n){for(var r=-1,s=e.length,a={};++r<s;){var c=e[r],l=Ne(t,c);n(l,c)&&Sn(a,be(c,t),l)}return a}function If(t){return function(e){return Ne(e,t)}}function _i(t,e,n,r){var s=r?Qo:Je,a=-1,c=e.length,l=t;for(t===e&&(e=At(e)),n&&(l=rt(t,Ot(n)));++a<c;)for(var p=0,w=e[a],m=n?n(w):w;(p=s(l,m,p,r))>-1;)l!==t&&Zn.call(l,p,1),Zn.call(t,p,1);return t}function _u(t,e){for(var n=t?e.length:0,r=n-1;n--;){var s=e[n];if(n==r||s!==a){var a=s;fe(s)?Zn.call(t,s,1):mi(t,s)}}return t}function yi(t,e){return t+Qn(Xs()*(e-t+1))}function Ef(t,e,n,r){for(var s=-1,a=dt(Xn((e-t)/(n||1)),0),c=_(a);a--;)c[r?a:++s]=t,t+=n;return c}function vi(t,e){var n="";if(!t||e<1||e>Jt)return n;do e%2&&(n+=t),e=Qn(e/2),e&&(t+=t);while(e);return n}function K(t,e){return Ui(zu(t,e,Rt),t+"")}function Tf(t){return js(un(t))}function Of(t,e){var n=un(t);return pr(n,Ue(e,0,n.length))}function Sn(t,e,n,r){if(!it(t))return t;e=be(e,t);for(var s=-1,a=e.length,c=a-1,l=t;l!=null&&++s<a;){var p=ne(e[s]),w=n;if(p==="__proto__"||p==="constructor"||p==="prototype")return t;if(s!=c){var m=l[p];w=r?r(m,p,l):i,w===i&&(w=it(m)?m:fe(e[s+1])?[]:{})}vn(l,p,w),l=l[p]}return t}var yu=Vn?function(t,e){return Vn.set(t,e),t}:Rt,Lf=Yn?function(t,e){return Yn(t,"toString",{configurable:!0,enumerable:!1,value:Gi(e),writable:!0})}:Rt;function Df(t){return pr(un(t))}function qt(t,e,n){var r=-1,s=t.length;e<0&&(e=-e>s?0:s+e),n=n>s?s:n,n<0&&(n+=s),s=e>n?0:n-e>>>0,e>>>=0;for(var a=_(s);++r<s;)a[r]=t[r+e];return a}function Wf(t,e){var n;return xe(t,function(r,s,a){return n=e(r,s,a),!n}),!!n}function sr(t,e,n){var r=0,s=t==null?r:t.length;if(typeof e=="number"&&e===e&&s<=Cr){for(;r<s;){var a=r+s>>>1,c=t[a];c!==null&&!Dt(c)&&(n?c<=e:c<e)?r=a+1:s=a}return s}return wi(t,e,Rt,n)}function wi(t,e,n,r){var s=0,a=t==null?0:t.length;if(a===0)return 0;e=n(e);for(var c=e!==e,l=e===null,p=Dt(e),w=e===i;s<a;){var m=Qn((s+a)/2),S=n(t[m]),C=S!==i,E=S===null,D=S===S,k=Dt(S);if(c)var W=r||D;else w?W=D&&(r||C):l?W=D&&C&&(r||!E):p?W=D&&C&&!E&&(r||!k):E||k?W=!1:W=r?S<=e:S<e;W?s=m+1:a=m}return wt(a,Pr)}function vu(t,e){for(var n=-1,r=t.length,s=0,a=[];++n<r;){var c=t[n],l=e?e(c):c;if(!n||!Vt(l,p)){var p=l;a[s++]=c===0?0:c}}return a}function wu(t){return typeof t=="number"?t:Dt(t)?He:+t}function Lt(t){if(typeof t=="string")return t;if(M(t))return rt(t,Lt)+"";if(Dt(t))return Qs?Qs.call(t):"";var e=t+"";return e=="0"&&1/t==-Nt?"-0":e}function Se(t,e,n){var r=-1,s=Mn,a=t.length,c=!0,l=[],p=l;if(n)c=!1,s=Zr;else if(a>=g){var w=e?null:Gf(t);if(w)return Bn(w);c=!1,s=hn,p=new We}else p=e?[]:l;t:for(;++r<a;){var m=t[r],S=e?e(m):m;if(m=n||m!==0?m:0,c&&S===S){for(var C=p.length;C--;)if(p[C]===S)continue t;e&&p.push(S),l.push(m)}else s(p,S,n)||(p!==l&&p.push(S),l.push(m))}return l}function mi(t,e){return e=be(e,t),t=Ju(t,e),t==null||delete t[ne(Ht(e))]}function mu(t,e,n,r){return Sn(t,e,n(Ne(t,e)),r)}function ur(t,e,n,r){for(var s=t.length,a=r?s:-1;(r?a--:++a<s)&&e(t[a],a,t););return n?qt(t,r?0:a,r?a+1:s):qt(t,r?a+1:0,r?s:a)}function xu(t,e){var n=t;return n instanceof H&&(n=n.value()),Yr(e,function(r,s){return s.func.apply(s.thisArg,ve([r],s.args))},n)}function xi(t,e,n){var r=t.length;if(r<2)return r?Se(t[0]):[];for(var s=-1,a=_(r);++s<r;)for(var c=t[s],l=-1;++l<r;)l!=s&&(a[s]=wn(a[s]||c,t[l],e,n));return Se(_t(a,1),e,n)}function Su(t,e,n){for(var r=-1,s=t.length,a=e.length,c={};++r<s;){var l=r<a?e[r]:i;n(c,t[r],l)}return c}function Si(t){return at(t)?t:[]}function bi(t){return typeof t=="function"?t:Rt}function be(t,e){return M(t)?t:Li(t,e)?[t]:Qu(X(t))}var Uf=K;function Ae(t,e,n){var r=t.length;return n=n===i?r:n,!e&&n>=r?t:qt(t,e,n)}var bu=xc||function(t){return gt.clearTimeout(t)};function Au(t,e){if(e)return t.slice();var n=t.length,r=Gs?Gs(n):new t.constructor(n);return t.copy(r),r}function Ai(t){var e=new t.constructor(t.byteLength);return new zn(e).set(new zn(t)),e}function Nf(t,e){var n=e?Ai(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}function Ff(t){var e=new t.constructor(t.source,as.exec(t));return e.lastIndex=t.lastIndex,e}function Mf(t){return yn?j(yn.call(t)):{}}function Pu(t,e){var n=e?Ai(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Cu(t,e){if(t!==e){var n=t!==i,r=t===null,s=t===t,a=Dt(t),c=e!==i,l=e===null,p=e===e,w=Dt(e);if(!l&&!w&&!a&&t>e||a&&c&&p&&!l&&!w||r&&c&&p||!n&&p||!s)return 1;if(!r&&!a&&!w&&t<e||w&&n&&s&&!r&&!a||l&&n&&s||!c&&s||!p)return-1}return 0}function $f(t,e,n){for(var r=-1,s=t.criteria,a=e.criteria,c=s.length,l=n.length;++r<c;){var p=Cu(s[r],a[r]);if(p){if(r>=l)return p;var w=n[r];return p*(w=="desc"?-1:1)}}return t.index-e.index}function Ru(t,e,n,r){for(var s=-1,a=t.length,c=n.length,l=-1,p=e.length,w=dt(a-c,0),m=_(p+w),S=!r;++l<p;)m[l]=e[l];for(;++s<c;)(S||s<a)&&(m[n[s]]=t[s]);for(;w--;)m[l++]=t[s++];return m}function Iu(t,e,n,r){for(var s=-1,a=t.length,c=-1,l=n.length,p=-1,w=e.length,m=dt(a-l,0),S=_(m+w),C=!r;++s<m;)S[s]=t[s];for(var E=s;++p<w;)S[E+p]=e[p];for(;++c<l;)(C||s<a)&&(S[E+n[c]]=t[s++]);return S}function At(t,e){var n=-1,r=t.length;for(e||(e=_(r));++n<r;)e[n]=t[n];return e}function ee(t,e,n,r){var s=!n;n||(n={});for(var a=-1,c=e.length;++a<c;){var l=e[a],p=r?r(n[l],t[l],l,n,t):i;p===i&&(p=t[l]),s?ae(n,l,p):vn(n,l,p)}return n}function Bf(t,e){return ee(t,Oi(t),e)}function kf(t,e){return ee(t,ku(t),e)}function ar(t,e){return function(n,r){var s=M(n)?Go:cf,a=e?e():{};return s(n,t,L(r,2),a)}}function en(t){return K(function(e,n){var r=-1,s=n.length,a=s>1?n[s-1]:i,c=s>2?n[2]:i;for(a=t.length>3&&typeof a=="function"?(s--,a):i,c&&St(n[0],n[1],c)&&(a=s<3?i:a,s=1),e=j(e);++r<s;){var l=n[r];l&&t(e,l,r,a)}return e})}function Eu(t,e){return function(n,r){if(n==null)return n;if(!Pt(n))return t(n,r);for(var s=n.length,a=e?s:-1,c=j(n);(e?a--:++a<s)&&r(c[a],a,c)!==!1;);return n}}function Tu(t){return function(e,n,r){for(var s=-1,a=j(e),c=r(e),l=c.length;l--;){var p=c[t?l:++s];if(n(a[p],p,a)===!1)break}return e}}function Kf(t,e,n){var r=e&ct,s=bn(t);function a(){var c=this&&this!==gt&&this instanceof a?s:t;return c.apply(r?n:this,arguments)}return a}function Ou(t){return function(e){e=X(e);var n=Ze(e)?Xt(e):i,r=n?n[0]:e.charAt(0),s=n?Ae(n,1).join(""):e.slice(1);return r[t]()+s}}function nn(t){return function(e){return Yr(Ea(Ia(e).replace(Oo,"")),t,"")}}function bn(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=tn(t.prototype),r=t.apply(n,e);return it(r)?r:n}}function qf(t,e,n){var r=bn(t);function s(){for(var a=arguments.length,c=_(a),l=a,p=rn(s);l--;)c[l]=arguments[l];var w=a<3&&c[0]!==p&&c[a-1]!==p?[]:we(c,p);if(a-=w.length,a<n)return Nu(t,e,or,s.placeholder,i,c,w,i,i,n-a);var m=this&&this!==gt&&this instanceof s?r:t;return Tt(m,this,c)}return s}function Lu(t){return function(e,n,r){var s=j(e);if(!Pt(e)){var a=L(n,3);e=pt(e),n=function(l){return a(s[l],l,s)}}var c=t(e,n,r);return c>-1?s[a?e[c]:c]:i}}function Du(t){return ce(function(e){var n=e.length,r=n,s=kt.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if(typeof a!="function")throw new Bt(x);if(s&&!c&&hr(a)=="wrapper")var c=new kt([],!0)}for(r=c?r:n;++r<n;){a=e[r];var l=hr(a),p=l=="wrapper"?Ei(a):i;p&&Di(p[0])&&p[1]==(lt|Q|yt|Re)&&!p[4].length&&p[9]==1?c=c[hr(p[0])].apply(c,p[3]):c=a.length==1&&Di(a)?c[l]():c.thru(a)}return function(){var w=arguments,m=w[0];if(c&&w.length==1&&M(m))return c.plant(m).value();for(var S=0,C=n?e[S].apply(this,w):m;++S<n;)C=e[S].call(this,C);return C}})}function or(t,e,n,r,s,a,c,l,p,w){var m=e<,S=e&ct,C=e&pe,E=e&(Q|re),D=e&an,k=C?i:bn(t);function W(){for(var q=arguments.length,G=_(q),Wt=q;Wt--;)G[Wt]=arguments[Wt];if(E)var bt=rn(W),Ut=tc(G,bt);if(r&&(G=Ru(G,r,s,E)),a&&(G=Iu(G,a,c,E)),q-=Ut,E&&q<w){var ot=we(G,bt);return Nu(t,e,or,W.placeholder,n,G,ot,l,p,w-q)}var jt=S?n:this,de=C?jt[t]:t;return q=G.length,l?G=cl(G,l):D&&q>1&&G.reverse(),m&&p<q&&(G.length=p),this&&this!==gt&&this instanceof W&&(de=k||bn(de)),de.apply(jt,G)}return W}function Wu(t,e){return function(n,r){return yf(n,t,e(r),{})}}function cr(t,e){return function(n,r){var s;if(n===i&&r===i)return e;if(n!==i&&(s=n),r!==i){if(s===i)return r;typeof n=="string"||typeof r=="string"?(n=Lt(n),r=Lt(r)):(n=wu(n),r=wu(r)),s=t(n,r)}return s}}function Pi(t){return ce(function(e){return e=rt(e,Ot(L())),K(function(n){var r=this;return t(e,function(s){return Tt(s,r,n)})})})}function fr(t,e){e=e===i?" ":Lt(e);var n=e.length;if(n<2)return n?vi(e,t):e;var r=vi(e,Xn(t/Ye(e)));return Ze(e)?Ae(Xt(r),0,t).join(""):r.slice(0,t)}function Hf(t,e,n,r){var s=e&ct,a=bn(t);function c(){for(var l=-1,p=arguments.length,w=-1,m=r.length,S=_(m+p),C=this&&this!==gt&&this instanceof c?a:t;++w<m;)S[w]=r[w];for(;p--;)S[w++]=arguments[++l];return Tt(C,s?n:this,S)}return c}function Uu(t){return function(e,n,r){return r&&typeof r!="number"&&St(e,n,r)&&(n=r=i),e=he(e),n===i?(n=e,e=0):n=he(n),r=r===i?e<n?1:-1:he(r),Ef(e,n,r,t)}}function lr(t){return function(e,n){return typeof e=="string"&&typeof n=="string"||(e=Gt(e),n=Gt(n)),t(e,n)}}function Nu(t,e,n,r,s,a,c,l,p,w){var m=e&Q,S=m?c:i,C=m?i:c,E=m?a:i,D=m?i:a;e|=m?yt:It,e&=~(m?It:yt),e&Tn||(e&=-4);var k=[t,e,s,E,S,D,C,l,p,w],W=n.apply(i,k);return Di(t)&&Zu(W,k),W.placeholder=r,Yu(W,t,e)}function Ci(t){var e=ht[t];return function(n,r){if(n=Gt(n),r=r==null?0:wt($(r),292),r&&Ys(n)){var s=(X(n)+"e").split("e"),a=e(s[0]+"e"+(+s[1]+r));return s=(X(a)+"e").split("e"),+(s[0]+"e"+(+s[1]-r))}return e(n)}}var Gf=Ve&&1/Bn(new Ve([,-0]))[1]==Nt?function(t){return new Ve(t)}:Zi;function Fu(t){return function(e){var n=mt(e);return n==ut?ni(e):n==Yt?ac(e):jo(e,t(e))}}function oe(t,e,n,r,s,a,c,l){var p=e&pe;if(!p&&typeof t!="function")throw new Bt(x);var w=r?r.length:0;if(w||(e&=-97,r=s=i),c=c===i?c:dt($(c),0),l=l===i?l:$(l),w-=s?s.length:0,e&It){var m=r,S=s;r=s=i}var C=p?i:Ei(t),E=[t,e,n,r,s,m,S,a,c,l];if(C&&ul(E,C),t=E[0],e=E[1],n=E[2],r=E[3],s=E[4],l=E[9]=E[9]===i?p?0:t.length:dt(E[9]-w,0),!l&&e&(Q|re)&&(e&=-25),!e||e==ct)var D=Kf(t,e,n);else e==Q||e==re?D=qf(t,e,l):(e==yt||e==(ct|yt))&&!s.length?D=Hf(t,e,n,r):D=or.apply(i,E);var k=C?yu:Zu;return Yu(k(D,E),t,e)}function Mu(t,e,n,r){return t===i||Vt(t,Qe[n])&&!V.call(r,n)?e:t}function $u(t,e,n,r,s,a){return it(t)&&it(e)&&(a.set(e,t),ir(t,e,i,$u,a),a.delete(e)),t}function zf(t){return Cn(t)?i:t}function Bu(t,e,n,r,s,a){var c=n&T,l=t.length,p=e.length;if(l!=p&&!(c&&p>l))return!1;var w=a.get(t),m=a.get(e);if(w&&m)return w==e&&m==t;var S=-1,C=!0,E=n&J?new We:i;for(a.set(t,e),a.set(e,t);++S<l;){var D=t[S],k=e[S];if(r)var W=c?r(k,D,S,e,t,a):r(D,k,S,t,e,a);if(W!==i){if(W)continue;C=!1;break}if(E){if(!Xr(e,function(q,G){if(!hn(E,G)&&(D===q||s(D,q,n,r,a)))return E.push(G)})){C=!1;break}}else if(!(D===k||s(D,k,n,r,a))){C=!1;break}}return a.delete(t),a.delete(e),C}function Jf(t,e,n,r,s,a,c){switch(n){case Ge:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case ln:return!(t.byteLength!=e.byteLength||!a(new zn(t),new zn(e)));case Ee:case Te:case _e:return Vt(+t,+e);case N:return t.name==e.name&&t.message==e.message;case on:case cn:return t==e+"";case ut:var l=ni;case Yt:var p=r&T;if(l||(l=Bn),t.size!=e.size&&!p)return!1;var w=c.get(t);if(w)return w==e;r|=J,c.set(t,e);var m=Bu(l(t),l(e),r,s,a,c);return c.delete(t),m;case Wn:if(yn)return yn.call(t)==yn.call(e)}return!1}function Zf(t,e,n,r,s,a){var c=n&T,l=Ri(t),p=l.length,w=Ri(e),m=w.length;if(p!=m&&!c)return!1;for(var S=p;S--;){var C=l[S];if(!(c?C in e:V.call(e,C)))return!1}var E=a.get(t),D=a.get(e);if(E&&D)return E==e&&D==t;var k=!0;a.set(t,e),a.set(e,t);for(var W=c;++S<p;){C=l[S];var q=t[C],G=e[C];if(r)var Wt=c?r(G,q,C,e,t,a):r(q,G,C,t,e,a);if(!(Wt===i?q===G||s(q,G,n,r,a):Wt)){k=!1;break}W||(W=C=="constructor")}if(k&&!W){var bt=t.constructor,Ut=e.constructor;bt!=Ut&&"constructor"in t&&"constructor"in e&&!(typeof bt=="function"&&bt instanceof bt&&typeof Ut=="function"&&Ut instanceof Ut)&&(k=!1)}return a.delete(t),a.delete(e),k}function ce(t){return Ui(zu(t,i,ea),t+"")}function Ri(t){return uu(t,pt,Oi)}function Ii(t){return uu(t,Ct,ku)}var Ei=Vn?function(t){return Vn.get(t)}:Zi;function hr(t){for(var e=t.name+"",n=je[e],r=V.call(je,e)?n.length:0;r--;){var s=n[r],a=s.func;if(a==null||a==t)return s.name}return e}function rn(t){var e=V.call(u,"placeholder")?u:t;return e.placeholder}function L(){var t=u.iteratee||zi;return t=t===zi?cu:t,arguments.length?t(arguments[0],arguments[1]):t}function dr(t,e){var n=t.__data__;return nl(e)?n[typeof e=="string"?"string":"hash"]:n.map}function Ti(t){for(var e=pt(t),n=e.length;n--;){var r=e[n],s=t[r];e[n]=[r,s,Hu(s)]}return e}function Fe(t,e){var n=ic(t,e);return ou(n)?n:i}function Yf(t){var e=V.call(t,Le),n=t[Le];try{t[Le]=i;var r=!0}catch{}var s=Hn.call(t);return r&&(e?t[Le]=n:delete t[Le]),s}var Oi=ii?function(t){return t==null?[]:(t=j(t),ye(ii(t),function(e){return Js.call(t,e)}))}:Yi,ku=ii?function(t){for(var e=[];t;)ve(e,Oi(t)),t=Jn(t);return e}:Yi,mt=xt;(si&&mt(new si(new ArrayBuffer(1)))!=Ge||pn&&mt(new pn)!=ut||ui&&mt(ui.resolve())!=rs||Ve&&mt(new Ve)!=Yt||gn&&mt(new gn)!=fn)&&(mt=function(t){var e=xt(t),n=e==ie?t.constructor:i,r=n?Me(n):"";if(r)switch(r){case Tc:return Ge;case Oc:return ut;case Lc:return rs;case Dc:return Yt;case Wc:return fn}return e});function Xf(t,e,n){for(var r=-1,s=n.length;++r<s;){var a=n[r],c=a.size;switch(a.type){case"drop":t+=c;break;case"dropRight":e-=c;break;case"take":e=wt(e,t+c);break;case"takeRight":t=dt(t,e-c);break}}return{start:t,end:e}}function Qf(t){var e=t.match(eo);return e?e[1].split(no):[]}function Ku(t,e,n){e=be(e,t);for(var r=-1,s=e.length,a=!1;++r<s;){var c=ne(e[r]);if(!(a=t!=null&&n(t,c)))break;t=t[c]}return a||++r!=s?a:(s=t==null?0:t.length,!!s&&mr(s)&&fe(c,s)&&(M(t)||$e(t)))}function Vf(t){var e=t.length,n=new t.constructor(e);return e&&typeof t[0]=="string"&&V.call(t,"index")&&(n.index=t.index,n.input=t.input),n}function qu(t){return typeof t.constructor=="function"&&!An(t)?tn(Jn(t)):{}}function jf(t,e,n){var r=t.constructor;switch(e){case ln:return Ai(t);case Ee:case Te:return new r(+t);case Ge:return Nf(t,n);case Tr:case Or:case Lr:case Dr:case Wr:case Ur:case Nr:case Fr:case Mr:return Pu(t,n);case ut:return new r;case _e:case cn:return new r(t);case on:return Ff(t);case Yt:return new r;case Wn:return Mf(t)}}function tl(t,e){var n=e.length;if(!n)return t;var r=n-1;return e[r]=(n>1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(to,`{
|
|
9
|
+
/* [wrapped with `+e+`] */
|
|
10
|
+
`)}function el(t){return M(t)||$e(t)||!!(Zs&&t&&t[Zs])}function fe(t,e){var n=typeof t;return e=e??Jt,!!e&&(n=="number"||n!="symbol"&&lo.test(t))&&t>-1&&t%1==0&&t<e}function St(t,e,n){if(!it(n))return!1;var r=typeof e;return(r=="number"?Pt(n)&&fe(e,n.length):r=="string"&&e in n)?Vt(n[e],t):!1}function Li(t,e){if(M(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||Dt(t)?!0:Xa.test(t)||!Ya.test(t)||e!=null&&t in j(e)}function nl(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Di(t){var e=hr(t),n=u[e];if(typeof n!="function"||!(e in H.prototype))return!1;if(t===n)return!0;var r=Ei(n);return!!r&&t===r[0]}function rl(t){return!!Hs&&Hs in t}var il=Kn?le:Xi;function An(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||Qe;return t===n}function Hu(t){return t===t&&!it(t)}function Gu(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==i||t in j(n))}}function sl(t){var e=vr(t,function(r){return n.size===B&&n.clear(),r}),n=e.cache;return e}function ul(t,e){var n=t[1],r=e[1],s=n|r,a=s<(ct|pe|lt),c=r==lt&&n==Q||r==lt&&n==Re&&t[7].length<=e[8]||r==(lt|Re)&&e[7].length<=e[8]&&n==Q;if(!(a||c))return t;r&ct&&(t[2]=e[2],s|=n&ct?0:Tn);var l=e[3];if(l){var p=t[3];t[3]=p?Ru(p,l,e[4]):l,t[4]=p?we(t[3],Y):e[4]}return l=e[5],l&&(p=t[5],t[5]=p?Iu(p,l,e[6]):l,t[6]=p?we(t[5],Y):e[6]),l=e[7],l&&(t[7]=l),r<&&(t[8]=t[8]==null?e[8]:wt(t[8],e[8])),t[9]==null&&(t[9]=e[9]),t[0]=e[0],t[1]=s,t}function al(t){var e=[];if(t!=null)for(var n in j(t))e.push(n);return e}function ol(t){return Hn.call(t)}function zu(t,e,n){return e=dt(e===i?t.length-1:e,0),function(){for(var r=arguments,s=-1,a=dt(r.length-e,0),c=_(a);++s<a;)c[s]=r[e+s];s=-1;for(var l=_(e+1);++s<e;)l[s]=r[s];return l[e]=n(c),Tt(t,this,l)}}function Ju(t,e){return e.length<2?t:Ne(t,qt(e,0,-1))}function cl(t,e){for(var n=t.length,r=wt(e.length,n),s=At(t);r--;){var a=e[r];t[r]=fe(a,n)?s[a]:i}return t}function Wi(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var Zu=Xu(yu),Pn=bc||function(t,e){return gt.setTimeout(t,e)},Ui=Xu(Lf);function Yu(t,e,n){var r=e+"";return Ui(t,tl(r,fl(Qf(r),n)))}function Xu(t){var e=0,n=0;return function(){var r=Rc(),s=Ln-(r-n);if(n=r,s>0){if(++e>=zt)return arguments[0]}else e=0;return t.apply(i,arguments)}}function pr(t,e){var n=-1,r=t.length,s=r-1;for(e=e===i?r:e;++n<e;){var a=yi(n,s),c=t[a];t[a]=t[n],t[n]=c}return t.length=e,t}var Qu=sl(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Qa,function(n,r,s,a){e.push(s?a.replace(so,"$1"):r||n)}),e});function ne(t){if(typeof t=="string"||Dt(t))return t;var e=t+"";return e=="0"&&1/t==-Nt?"-0":e}function Me(t){if(t!=null){try{return qn.call(t)}catch{}try{return t+""}catch{}}return""}function fl(t,e){return $t(Rr,function(n){var r="_."+n[0];e&n[1]&&!Mn(t,r)&&t.push(r)}),t.sort()}function Vu(t){if(t instanceof H)return t.clone();var e=new kt(t.__wrapped__,t.__chain__);return e.__actions__=At(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}function ll(t,e,n){(n?St(t,e,n):e===i)?e=1:e=dt($(e),0);var r=t==null?0:t.length;if(!r||e<1)return[];for(var s=0,a=0,c=_(Xn(r/e));s<r;)c[a++]=qt(t,s,s+=e);return c}function hl(t){for(var e=-1,n=t==null?0:t.length,r=0,s=[];++e<n;){var a=t[e];a&&(s[r++]=a)}return s}function dl(){var t=arguments.length;if(!t)return[];for(var e=_(t-1),n=arguments[0],r=t;r--;)e[r-1]=arguments[r];return ve(M(n)?At(n):[n],_t(e,1))}var pl=K(function(t,e){return at(t)?wn(t,_t(e,1,at,!0)):[]}),gl=K(function(t,e){var n=Ht(e);return at(n)&&(n=i),at(t)?wn(t,_t(e,1,at,!0),L(n,2)):[]}),_l=K(function(t,e){var n=Ht(e);return at(n)&&(n=i),at(t)?wn(t,_t(e,1,at,!0),i,n):[]});function yl(t,e,n){var r=t==null?0:t.length;return r?(e=n||e===i?1:$(e),qt(t,e<0?0:e,r)):[]}function vl(t,e,n){var r=t==null?0:t.length;return r?(e=n||e===i?1:$(e),e=r-e,qt(t,0,e<0?0:e)):[]}function wl(t,e){return t&&t.length?ur(t,L(e,3),!0,!0):[]}function ml(t,e){return t&&t.length?ur(t,L(e,3),!0):[]}function xl(t,e,n,r){var s=t==null?0:t.length;return s?(n&&typeof n!="number"&&St(t,e,n)&&(n=0,r=s),df(t,e,n,r)):[]}function ju(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=n==null?0:$(n);return s<0&&(s=dt(r+s,0)),$n(t,L(e,3),s)}function ta(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=r-1;return n!==i&&(s=$(n),s=n<0?dt(r+s,0):wt(s,r-1)),$n(t,L(e,3),s,!0)}function ea(t){var e=t==null?0:t.length;return e?_t(t,1):[]}function Sl(t){var e=t==null?0:t.length;return e?_t(t,Nt):[]}function bl(t,e){var n=t==null?0:t.length;return n?(e=e===i?1:$(e),_t(t,e)):[]}function Al(t){for(var e=-1,n=t==null?0:t.length,r={};++e<n;){var s=t[e];r[s[0]]=s[1]}return r}function na(t){return t&&t.length?t[0]:i}function Pl(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=n==null?0:$(n);return s<0&&(s=dt(r+s,0)),Je(t,e,s)}function Cl(t){var e=t==null?0:t.length;return e?qt(t,0,-1):[]}var Rl=K(function(t){var e=rt(t,Si);return e.length&&e[0]===t[0]?hi(e):[]}),Il=K(function(t){var e=Ht(t),n=rt(t,Si);return e===Ht(n)?e=i:n.pop(),n.length&&n[0]===t[0]?hi(n,L(e,2)):[]}),El=K(function(t){var e=Ht(t),n=rt(t,Si);return e=typeof e=="function"?e:i,e&&n.pop(),n.length&&n[0]===t[0]?hi(n,i,e):[]});function Tl(t,e){return t==null?"":Pc.call(t,e)}function Ht(t){var e=t==null?0:t.length;return e?t[e-1]:i}function Ol(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=r;return n!==i&&(s=$(n),s=s<0?dt(r+s,0):wt(s,r-1)),e===e?cc(t,e,s):$n(t,Ns,s,!0)}function Ll(t,e){return t&&t.length?du(t,$(e)):i}var Dl=K(ra);function ra(t,e){return t&&t.length&&e&&e.length?_i(t,e):t}function Wl(t,e,n){return t&&t.length&&e&&e.length?_i(t,e,L(n,2)):t}function Ul(t,e,n){return t&&t.length&&e&&e.length?_i(t,e,i,n):t}var Nl=ce(function(t,e){var n=t==null?0:t.length,r=oi(t,e);return _u(t,rt(e,function(s){return fe(s,n)?+s:s}).sort(Cu)),r});function Fl(t,e){var n=[];if(!(t&&t.length))return n;var r=-1,s=[],a=t.length;for(e=L(e,3);++r<a;){var c=t[r];e(c,r,t)&&(n.push(c),s.push(r))}return _u(t,s),n}function Ni(t){return t==null?t:Ec.call(t)}function Ml(t,e,n){var r=t==null?0:t.length;return r?(n&&typeof n!="number"&&St(t,e,n)?(e=0,n=r):(e=e==null?0:$(e),n=n===i?r:$(n)),qt(t,e,n)):[]}function $l(t,e){return sr(t,e)}function Bl(t,e,n){return wi(t,e,L(n,2))}function kl(t,e){var n=t==null?0:t.length;if(n){var r=sr(t,e);if(r<n&&Vt(t[r],e))return r}return-1}function Kl(t,e){return sr(t,e,!0)}function ql(t,e,n){return wi(t,e,L(n,2),!0)}function Hl(t,e){var n=t==null?0:t.length;if(n){var r=sr(t,e,!0)-1;if(Vt(t[r],e))return r}return-1}function Gl(t){return t&&t.length?vu(t):[]}function zl(t,e){return t&&t.length?vu(t,L(e,2)):[]}function Jl(t){var e=t==null?0:t.length;return e?qt(t,1,e):[]}function Zl(t,e,n){return t&&t.length?(e=n||e===i?1:$(e),qt(t,0,e<0?0:e)):[]}function Yl(t,e,n){var r=t==null?0:t.length;return r?(e=n||e===i?1:$(e),e=r-e,qt(t,e<0?0:e,r)):[]}function Xl(t,e){return t&&t.length?ur(t,L(e,3),!1,!0):[]}function Ql(t,e){return t&&t.length?ur(t,L(e,3)):[]}var Vl=K(function(t){return Se(_t(t,1,at,!0))}),jl=K(function(t){var e=Ht(t);return at(e)&&(e=i),Se(_t(t,1,at,!0),L(e,2))}),th=K(function(t){var e=Ht(t);return e=typeof e=="function"?e:i,Se(_t(t,1,at,!0),i,e)});function eh(t){return t&&t.length?Se(t):[]}function nh(t,e){return t&&t.length?Se(t,L(e,2)):[]}function rh(t,e){return e=typeof e=="function"?e:i,t&&t.length?Se(t,i,e):[]}function Fi(t){if(!(t&&t.length))return[];var e=0;return t=ye(t,function(n){if(at(n))return e=dt(n.length,e),!0}),ti(e,function(n){return rt(t,Qr(n))})}function ia(t,e){if(!(t&&t.length))return[];var n=Fi(t);return e==null?n:rt(n,function(r){return Tt(e,i,r)})}var ih=K(function(t,e){return at(t)?wn(t,e):[]}),sh=K(function(t){return xi(ye(t,at))}),uh=K(function(t){var e=Ht(t);return at(e)&&(e=i),xi(ye(t,at),L(e,2))}),ah=K(function(t){var e=Ht(t);return e=typeof e=="function"?e:i,xi(ye(t,at),i,e)}),oh=K(Fi);function ch(t,e){return Su(t||[],e||[],vn)}function fh(t,e){return Su(t||[],e||[],Sn)}var lh=K(function(t){var e=t.length,n=e>1?t[e-1]:i;return n=typeof n=="function"?(t.pop(),n):i,ia(t,n)});function sa(t){var e=u(t);return e.__chain__=!0,e}function hh(t,e){return e(t),t}function gr(t,e){return e(t)}var dh=ce(function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,s=function(a){return oi(a,t)};return e>1||this.__actions__.length||!(r instanceof H)||!fe(n)?this.thru(s):(r=r.slice(n,+n+(e?1:0)),r.__actions__.push({func:gr,args:[s],thisArg:i}),new kt(r,this.__chain__).thru(function(a){return e&&!a.length&&a.push(i),a}))});function ph(){return sa(this)}function gh(){return new kt(this.value(),this.__chain__)}function _h(){this.__values__===i&&(this.__values__=wa(this.value()));var t=this.__index__>=this.__values__.length,e=t?i:this.__values__[this.__index__++];return{done:t,value:e}}function yh(){return this}function vh(t){for(var e,n=this;n instanceof tr;){var r=Vu(n);r.__index__=0,r.__values__=i,e?s.__wrapped__=r:e=r;var s=r;n=n.__wrapped__}return s.__wrapped__=t,e}function wh(){var t=this.__wrapped__;if(t instanceof H){var e=t;return this.__actions__.length&&(e=new H(this)),e=e.reverse(),e.__actions__.push({func:gr,args:[Ni],thisArg:i}),new kt(e,this.__chain__)}return this.thru(Ni)}function mh(){return xu(this.__wrapped__,this.__actions__)}var xh=ar(function(t,e,n){V.call(t,n)?++t[n]:ae(t,n,1)});function Sh(t,e,n){var r=M(t)?Ws:hf;return n&&St(t,e,n)&&(e=i),r(t,L(e,3))}function bh(t,e){var n=M(t)?ye:iu;return n(t,L(e,3))}var Ah=Lu(ju),Ph=Lu(ta);function Ch(t,e){return _t(_r(t,e),1)}function Rh(t,e){return _t(_r(t,e),Nt)}function Ih(t,e,n){return n=n===i?1:$(n),_t(_r(t,e),n)}function ua(t,e){var n=M(t)?$t:xe;return n(t,L(e,3))}function aa(t,e){var n=M(t)?zo:ru;return n(t,L(e,3))}var Eh=ar(function(t,e,n){V.call(t,n)?t[n].push(e):ae(t,n,[e])});function Th(t,e,n,r){t=Pt(t)?t:un(t),n=n&&!r?$(n):0;var s=t.length;return n<0&&(n=dt(s+n,0)),xr(t)?n<=s&&t.indexOf(e,n)>-1:!!s&&Je(t,e,n)>-1}var Oh=K(function(t,e,n){var r=-1,s=typeof e=="function",a=Pt(t)?_(t.length):[];return xe(t,function(c){a[++r]=s?Tt(e,c,n):mn(c,e,n)}),a}),Lh=ar(function(t,e,n){ae(t,n,e)});function _r(t,e){var n=M(t)?rt:fu;return n(t,L(e,3))}function Dh(t,e,n,r){return t==null?[]:(M(e)||(e=e==null?[]:[e]),n=r?i:n,M(n)||(n=n==null?[]:[n]),pu(t,e,n))}var Wh=ar(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});function Uh(t,e,n){var r=M(t)?Yr:Ms,s=arguments.length<3;return r(t,L(e,4),n,s,xe)}function Nh(t,e,n){var r=M(t)?Jo:Ms,s=arguments.length<3;return r(t,L(e,4),n,s,ru)}function Fh(t,e){var n=M(t)?ye:iu;return n(t,wr(L(e,3)))}function Mh(t){var e=M(t)?js:Tf;return e(t)}function $h(t,e,n){(n?St(t,e,n):e===i)?e=1:e=$(e);var r=M(t)?af:Of;return r(t,e)}function Bh(t){var e=M(t)?of:Df;return e(t)}function kh(t){if(t==null)return 0;if(Pt(t))return xr(t)?Ye(t):t.length;var e=mt(t);return e==ut||e==Yt?t.size:pi(t).length}function Kh(t,e,n){var r=M(t)?Xr:Wf;return n&&St(t,e,n)&&(e=i),r(t,L(e,3))}var qh=K(function(t,e){if(t==null)return[];var n=e.length;return n>1&&St(t,e[0],e[1])?e=[]:n>2&&St(e[0],e[1],e[2])&&(e=[e[0]]),pu(t,_t(e,1),[])}),yr=Sc||function(){return gt.Date.now()};function Hh(t,e){if(typeof e!="function")throw new Bt(x);return t=$(t),function(){if(--t<1)return e.apply(this,arguments)}}function oa(t,e,n){return e=n?i:e,e=t&&e==null?t.length:e,oe(t,lt,i,i,i,i,e)}function ca(t,e){var n;if(typeof e!="function")throw new Bt(x);return t=$(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=i),n}}var Mi=K(function(t,e,n){var r=ct;if(n.length){var s=we(n,rn(Mi));r|=yt}return oe(t,r,e,n,s)}),fa=K(function(t,e,n){var r=ct|pe;if(n.length){var s=we(n,rn(fa));r|=yt}return oe(e,r,t,n,s)});function la(t,e,n){e=n?i:e;var r=oe(t,Q,i,i,i,i,i,e);return r.placeholder=la.placeholder,r}function ha(t,e,n){e=n?i:e;var r=oe(t,re,i,i,i,i,i,e);return r.placeholder=ha.placeholder,r}function da(t,e,n){var r,s,a,c,l,p,w=0,m=!1,S=!1,C=!0;if(typeof t!="function")throw new Bt(x);e=Gt(e)||0,it(n)&&(m=!!n.leading,S="maxWait"in n,a=S?dt(Gt(n.maxWait)||0,e):a,C="trailing"in n?!!n.trailing:C);function E(ot){var jt=r,de=s;return r=s=i,w=ot,c=t.apply(de,jt),c}function D(ot){return w=ot,l=Pn(q,e),m?E(ot):c}function k(ot){var jt=ot-p,de=ot-w,La=e-jt;return S?wt(La,a-de):La}function W(ot){var jt=ot-p,de=ot-w;return p===i||jt>=e||jt<0||S&&de>=a}function q(){var ot=yr();if(W(ot))return G(ot);l=Pn(q,k(ot))}function G(ot){return l=i,C&&r?E(ot):(r=s=i,c)}function Wt(){l!==i&&bu(l),w=0,r=p=s=l=i}function bt(){return l===i?c:G(yr())}function Ut(){var ot=yr(),jt=W(ot);if(r=arguments,s=this,p=ot,jt){if(l===i)return D(p);if(S)return bu(l),l=Pn(q,e),E(p)}return l===i&&(l=Pn(q,e)),c}return Ut.cancel=Wt,Ut.flush=bt,Ut}var Gh=K(function(t,e){return nu(t,1,e)}),zh=K(function(t,e,n){return nu(t,Gt(e)||0,n)});function Jh(t){return oe(t,an)}function vr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new Bt(x);var n=function(){var r=arguments,s=e?e.apply(this,r):r[0],a=n.cache;if(a.has(s))return a.get(s);var c=t.apply(this,r);return n.cache=a.set(s,c)||a,c};return n.cache=new(vr.Cache||ue),n}vr.Cache=ue;function wr(t){if(typeof t!="function")throw new Bt(x);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Zh(t){return ca(2,t)}var Yh=Uf(function(t,e){e=e.length==1&&M(e[0])?rt(e[0],Ot(L())):rt(_t(e,1),Ot(L()));var n=e.length;return K(function(r){for(var s=-1,a=wt(r.length,n);++s<a;)r[s]=e[s].call(this,r[s]);return Tt(t,this,r)})}),$i=K(function(t,e){var n=we(e,rn($i));return oe(t,yt,i,e,n)}),pa=K(function(t,e){var n=we(e,rn(pa));return oe(t,It,i,e,n)}),Xh=ce(function(t,e){return oe(t,Re,i,i,i,e)});function Qh(t,e){if(typeof t!="function")throw new Bt(x);return e=e===i?e:$(e),K(t,e)}function Vh(t,e){if(typeof t!="function")throw new Bt(x);return e=e==null?0:dt($(e),0),K(function(n){var r=n[e],s=Ae(n,0,e);return r&&ve(s,r),Tt(t,this,s)})}function jh(t,e,n){var r=!0,s=!0;if(typeof t!="function")throw new Bt(x);return it(n)&&(r="leading"in n?!!n.leading:r,s="trailing"in n?!!n.trailing:s),da(t,e,{leading:r,maxWait:e,trailing:s})}function td(t){return oa(t,1)}function ed(t,e){return $i(bi(e),t)}function nd(){if(!arguments.length)return[];var t=arguments[0];return M(t)?t:[t]}function rd(t){return Kt(t,A)}function id(t,e){return e=typeof e=="function"?e:i,Kt(t,A,e)}function sd(t){return Kt(t,P|A)}function ud(t,e){return e=typeof e=="function"?e:i,Kt(t,P|A,e)}function ad(t,e){return e==null||eu(t,e,pt(e))}function Vt(t,e){return t===e||t!==t&&e!==e}var od=lr(li),cd=lr(function(t,e){return t>=e}),$e=au(function(){return arguments}())?au:function(t){return st(t)&&V.call(t,"callee")&&!Js.call(t,"callee")},M=_.isArray,fd=Is?Ot(Is):vf;function Pt(t){return t!=null&&mr(t.length)&&!le(t)}function at(t){return st(t)&&Pt(t)}function ld(t){return t===!0||t===!1||st(t)&&xt(t)==Ee}var Pe=Ac||Xi,hd=Es?Ot(Es):wf;function dd(t){return st(t)&&t.nodeType===1&&!Cn(t)}function pd(t){if(t==null)return!0;if(Pt(t)&&(M(t)||typeof t=="string"||typeof t.splice=="function"||Pe(t)||sn(t)||$e(t)))return!t.length;var e=mt(t);if(e==ut||e==Yt)return!t.size;if(An(t))return!pi(t).length;for(var n in t)if(V.call(t,n))return!1;return!0}function gd(t,e){return xn(t,e)}function _d(t,e,n){n=typeof n=="function"?n:i;var r=n?n(t,e):i;return r===i?xn(t,e,i,n):!!r}function Bi(t){if(!st(t))return!1;var e=xt(t);return e==N||e==Er||typeof t.message=="string"&&typeof t.name=="string"&&!Cn(t)}function yd(t){return typeof t=="number"&&Ys(t)}function le(t){if(!it(t))return!1;var e=xt(t);return e==tt||e==vt||e==Ir||e==$a}function ga(t){return typeof t=="number"&&t==$(t)}function mr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Jt}function it(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function st(t){return t!=null&&typeof t=="object"}var _a=Ts?Ot(Ts):xf;function vd(t,e){return t===e||di(t,e,Ti(e))}function wd(t,e,n){return n=typeof n=="function"?n:i,di(t,e,Ti(e),n)}function md(t){return ya(t)&&t!=+t}function xd(t){if(il(t))throw new F(y);return ou(t)}function Sd(t){return t===null}function bd(t){return t==null}function ya(t){return typeof t=="number"||st(t)&&xt(t)==_e}function Cn(t){if(!st(t)||xt(t)!=ie)return!1;var e=Jn(t);if(e===null)return!0;var n=V.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&qn.call(n)==vc}var ki=Os?Ot(Os):Sf;function Ad(t){return ga(t)&&t>=-Jt&&t<=Jt}var va=Ls?Ot(Ls):bf;function xr(t){return typeof t=="string"||!M(t)&&st(t)&&xt(t)==cn}function Dt(t){return typeof t=="symbol"||st(t)&&xt(t)==Wn}var sn=Ds?Ot(Ds):Af;function Pd(t){return t===i}function Cd(t){return st(t)&&mt(t)==fn}function Rd(t){return st(t)&&xt(t)==ka}var Id=lr(gi),Ed=lr(function(t,e){return t<=e});function wa(t){if(!t)return[];if(Pt(t))return xr(t)?Xt(t):At(t);if(dn&&t[dn])return uc(t[dn]());var e=mt(t),n=e==ut?ni:e==Yt?Bn:un;return n(t)}function he(t){if(!t)return t===0?t:0;if(t=Gt(t),t===Nt||t===-Nt){var e=t<0?-1:1;return e*ft}return t===t?t:0}function $(t){var e=he(t),n=e%1;return e===e?n?e-n:e:0}function ma(t){return t?Ue($(t),0,Ft):0}function Gt(t){if(typeof t=="number")return t;if(Dt(t))return He;if(it(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=it(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=$s(t);var n=oo.test(t);return n||fo.test(t)?qo(t.slice(2),n?2:8):ao.test(t)?He:+t}function xa(t){return ee(t,Ct(t))}function Td(t){return t?Ue($(t),-Jt,Jt):t===0?t:0}function X(t){return t==null?"":Lt(t)}var Od=en(function(t,e){if(An(e)||Pt(e)){ee(e,pt(e),t);return}for(var n in e)V.call(e,n)&&vn(t,n,e[n])}),Sa=en(function(t,e){ee(e,Ct(e),t)}),Sr=en(function(t,e,n,r){ee(e,Ct(e),t,r)}),Ld=en(function(t,e,n,r){ee(e,pt(e),t,r)}),Dd=ce(oi);function Wd(t,e){var n=tn(t);return e==null?n:tu(n,e)}var Ud=K(function(t,e){t=j(t);var n=-1,r=e.length,s=r>2?e[2]:i;for(s&&St(e[0],e[1],s)&&(r=1);++n<r;)for(var a=e[n],c=Ct(a),l=-1,p=c.length;++l<p;){var w=c[l],m=t[w];(m===i||Vt(m,Qe[w])&&!V.call(t,w))&&(t[w]=a[w])}return t}),Nd=K(function(t){return t.push(i,$u),Tt(ba,i,t)});function Fd(t,e){return Us(t,L(e,3),te)}function Md(t,e){return Us(t,L(e,3),fi)}function $d(t,e){return t==null?t:ci(t,L(e,3),Ct)}function Bd(t,e){return t==null?t:su(t,L(e,3),Ct)}function kd(t,e){return t&&te(t,L(e,3))}function Kd(t,e){return t&&fi(t,L(e,3))}function qd(t){return t==null?[]:rr(t,pt(t))}function Hd(t){return t==null?[]:rr(t,Ct(t))}function Ki(t,e,n){var r=t==null?i:Ne(t,e);return r===i?n:r}function Gd(t,e){return t!=null&&Ku(t,e,pf)}function qi(t,e){return t!=null&&Ku(t,e,gf)}var zd=Wu(function(t,e,n){e!=null&&typeof e.toString!="function"&&(e=Hn.call(e)),t[e]=n},Gi(Rt)),Jd=Wu(function(t,e,n){e!=null&&typeof e.toString!="function"&&(e=Hn.call(e)),V.call(t,e)?t[e].push(n):t[e]=[n]},L),Zd=K(mn);function pt(t){return Pt(t)?Vs(t):pi(t)}function Ct(t){return Pt(t)?Vs(t,!0):Pf(t)}function Yd(t,e){var n={};return e=L(e,3),te(t,function(r,s,a){ae(n,e(r,s,a),r)}),n}function Xd(t,e){var n={};return e=L(e,3),te(t,function(r,s,a){ae(n,s,e(r,s,a))}),n}var Qd=en(function(t,e,n){ir(t,e,n)}),ba=en(function(t,e,n,r){ir(t,e,n,r)}),Vd=ce(function(t,e){var n={};if(t==null)return n;var r=!1;e=rt(e,function(a){return a=be(a,t),r||(r=a.length>1),a}),ee(t,Ii(t),n),r&&(n=Kt(n,P|U|A,zf));for(var s=e.length;s--;)mi(n,e[s]);return n});function jd(t,e){return Aa(t,wr(L(e)))}var tp=ce(function(t,e){return t==null?{}:Rf(t,e)});function Aa(t,e){if(t==null)return{};var n=rt(Ii(t),function(r){return[r]});return e=L(e),gu(t,n,function(r,s){return e(r,s[0])})}function ep(t,e,n){e=be(e,t);var r=-1,s=e.length;for(s||(s=1,t=i);++r<s;){var a=t==null?i:t[ne(e[r])];a===i&&(r=s,a=n),t=le(a)?a.call(t):a}return t}function np(t,e,n){return t==null?t:Sn(t,e,n)}function rp(t,e,n,r){return r=typeof r=="function"?r:i,t==null?t:Sn(t,e,n,r)}var Pa=Fu(pt),Ca=Fu(Ct);function ip(t,e,n){var r=M(t),s=r||Pe(t)||sn(t);if(e=L(e,4),n==null){var a=t&&t.constructor;s?n=r?new a:[]:it(t)?n=le(a)?tn(Jn(t)):{}:n={}}return(s?$t:te)(t,function(c,l,p){return e(n,c,l,p)}),n}function sp(t,e){return t==null?!0:mi(t,e)}function up(t,e,n){return t==null?t:mu(t,e,bi(n))}function ap(t,e,n,r){return r=typeof r=="function"?r:i,t==null?t:mu(t,e,bi(n),r)}function un(t){return t==null?[]:ei(t,pt(t))}function op(t){return t==null?[]:ei(t,Ct(t))}function cp(t,e,n){return n===i&&(n=e,e=i),n!==i&&(n=Gt(n),n=n===n?n:0),e!==i&&(e=Gt(e),e=e===e?e:0),Ue(Gt(t),e,n)}function fp(t,e,n){return e=he(e),n===i?(n=e,e=0):n=he(n),t=Gt(t),_f(t,e,n)}function lp(t,e,n){if(n&&typeof n!="boolean"&&St(t,e,n)&&(e=n=i),n===i&&(typeof e=="boolean"?(n=e,e=i):typeof t=="boolean"&&(n=t,t=i)),t===i&&e===i?(t=0,e=1):(t=he(t),e===i?(e=t,t=0):e=he(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var s=Xs();return wt(t+s*(e-t+Ko("1e-"+((s+"").length-1))),e)}return yi(t,e)}var hp=nn(function(t,e,n){return e=e.toLowerCase(),t+(n?Ra(e):e)});function Ra(t){return Hi(X(t).toLowerCase())}function Ia(t){return t=X(t),t&&t.replace(ho,ec).replace(Lo,"")}function dp(t,e,n){t=X(t),e=Lt(e);var r=t.length;n=n===i?r:Ue($(n),0,r);var s=n;return n-=e.length,n>=0&&t.slice(n,s)==e}function pp(t){return t=X(t),t&&za.test(t)?t.replace(ss,nc):t}function gp(t){return t=X(t),t&&Va.test(t)?t.replace($r,"\\$&"):t}var _p=nn(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),yp=nn(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),vp=Ou("toLowerCase");function wp(t,e,n){t=X(t),e=$(e);var r=e?Ye(t):0;if(!e||r>=e)return t;var s=(e-r)/2;return fr(Qn(s),n)+t+fr(Xn(s),n)}function mp(t,e,n){t=X(t),e=$(e);var r=e?Ye(t):0;return e&&r<e?t+fr(e-r,n):t}function xp(t,e,n){t=X(t),e=$(e);var r=e?Ye(t):0;return e&&r<e?fr(e-r,n)+t:t}function Sp(t,e,n){return n||e==null?e=0:e&&(e=+e),Ic(X(t).replace(Br,""),e||0)}function bp(t,e,n){return(n?St(t,e,n):e===i)?e=1:e=$(e),vi(X(t),e)}function Ap(){var t=arguments,e=X(t[0]);return t.length<3?e:e.replace(t[1],t[2])}var Pp=nn(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()});function Cp(t,e,n){return n&&typeof n!="number"&&St(t,e,n)&&(e=n=i),n=n===i?Ft:n>>>0,n?(t=X(t),t&&(typeof e=="string"||e!=null&&!ki(e))&&(e=Lt(e),!e&&Ze(t))?Ae(Xt(t),0,n):t.split(e,n)):[]}var Rp=nn(function(t,e,n){return t+(n?" ":"")+Hi(e)});function Ip(t,e,n){return t=X(t),n=n==null?0:Ue($(n),0,t.length),e=Lt(e),t.slice(n,n+e.length)==e}function Ep(t,e,n){var r=u.templateSettings;n&&St(t,e,n)&&(e=i),t=X(t),e=Sr({},e,r,Mu);var s=Sr({},e.imports,r.imports,Mu),a=pt(s),c=ei(s,a),l,p,w=0,m=e.interpolate||Un,S="__p += '",C=ri((e.escape||Un).source+"|"+m.source+"|"+(m===us?uo:Un).source+"|"+(e.evaluate||Un).source+"|$","g"),E="//# sourceURL="+(V.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Fo+"]")+`
|
|
11
|
+
`;t.replace(C,function(W,q,G,Wt,bt,Ut){return G||(G=Wt),S+=t.slice(w,Ut).replace(po,rc),q&&(l=!0,S+=`' +
|
|
12
|
+
__e(`+q+`) +
|
|
13
|
+
'`),bt&&(p=!0,S+=`';
|
|
14
|
+
`+bt+`;
|
|
15
15
|
__p += '`),G&&(S+=`' +
|
|
16
16
|
((__t = (`+G+`)) == null ? '' : __t) +
|
|
17
|
-
'`),
|
|
18
|
-
`;var
|
|
17
|
+
'`),w=Ut+W.length,W}),S+=`';
|
|
18
|
+
`;var D=V.call(e,"variable")&&e.variable;if(!D)S=`with (obj) {
|
|
19
19
|
`+S+`
|
|
20
20
|
}
|
|
21
|
-
`;else if(
|
|
22
|
-
`+(
|
|
23
|
-
`)+"var __t, __p = ''"+(
|
|
21
|
+
`;else if(io.test(D))throw new F(I);S=(p?S.replace(Ka,""):S).replace(qa,"$1").replace(Ha,"$1;"),S="function("+(D||"obj")+`) {
|
|
22
|
+
`+(D?"":`obj || (obj = {});
|
|
23
|
+
`)+"var __t, __p = ''"+(l?", __e = _.escape":"")+(p?`, __j = Array.prototype.join;
|
|
24
24
|
function print() { __p += __j.call(arguments, '') }
|
|
25
25
|
`:`;
|
|
26
26
|
`)+S+`return __p
|
|
27
|
-
}`;var M=To(function(){return J(o,R+"return "+S).apply(i,f)});if(M.source=S,$i(M))throw M;return M}function Tp(t){return Y(t).toLowerCase()}function Op(t){return Y(t).toUpperCase()}function Lp(t,n,e){if(t=Y(t),t&&(e||n===i))return $s(t);if(!t||!(n=Lt(n)))return t;var r=Yt(t),s=Yt(n),o=Bs(r,s),f=Ms(r,s)+1;return Pn(r,o,f).join("")}function Wp(t,n,e){if(t=Y(t),t&&(e||n===i))return t.slice(0,qs(t)+1);if(!t||!(n=Lt(n)))return t;var r=Yt(t),s=Ms(r,Yt(n))+1;return Pn(r,0,s).join("")}function Dp(t,n,e){if(t=Y(t),t&&(e||n===i))return t.replace($r,"");if(!t||!(n=Lt(n)))return t;var r=Yt(t),s=Bs(r,Yt(n));return Pn(r,s).join("")}function Fp(t,n){var e=Re,r=ie;if(rt(n)){var s="separator"in n?n.separator:s;e="length"in n?B(n.length):e,r="omission"in n?Lt(n.omission):r}t=Y(t);var o=t.length;if(zn(t)){var f=Yt(t);o=f.length}if(e>=o)return t;var c=e-Gn(r);if(c<1)return r;var d=f?Pn(f,0,c).join(""):t.slice(0,c);if(s===i)return d+r;if(f&&(c+=d.length-c),Bi(s)){if(t.slice(c).search(s)){var y,m=d;for(s.global||(s=ni(s.source,Y(us.exec(s))+"g")),s.lastIndex=0;y=s.exec(m);)var S=y.index;d=d.slice(0,S===i?c:S)}}else if(t.indexOf(Lt(s),c)!=c){var b=d.lastIndexOf(s);b>-1&&(d=d.slice(0,b))}return d+r}function Up(t){return t=Y(t),t&&Go.test(t)?t.replace(rs,lf):t}var Np=jn(function(t,n,e){return t+(e?" ":"")+n.toUpperCase()}),qi=Tu("toUpperCase");function Eo(t,n,e){return t=Y(t),n=e?i:n,n===i?uf(t)?pf(t):Xa(t):t.match(n)||[]}var To=q(function(t,n){try{return Tt(t,i,n)}catch(e){return $i(e)?e:new F(e)}}),$p=hn(function(t,n){return Bt(n,function(e){e=rn(e),cn(t,e,Ui(t[e],t))}),t});function Bp(t){var n=t==null?0:t.length,e=O();return t=n?et(t,function(r){if(typeof r[1]!="function")throw new Mt(x);return[e(r[0]),r[1]]}):[],q(function(r){for(var s=-1;++s<n;){var o=t[s];if(Tt(o[0],this,r))return Tt(o[1],this,r)}})}function Mp(t){return lc(qt(t,A))}function ki(t){return function(){return t}}function Kp(t,n){return t==null||t!==t?n:t}var qp=Lu(),kp=Lu(!0);function It(t){return t}function Hi(t){return au(typeof t=="function"?t:qt(t,A))}function Hp(t){return cu(qt(t,A))}function zp(t,n){return lu(t,qt(n,A))}var Gp=q(function(t,n){return function(e){return we(e,t,n)}}),Jp=q(function(t,n){return function(e){return we(t,e,n)}});function zi(t,n,e){var r=lt(n),s=rr(n,r);e==null&&!(rt(n)&&(s.length||!r.length))&&(e=n,n=t,t=this,s=rr(n,lt(n)));var o=!(rt(e)&&"chain"in e)||!!e.chain,f=pn(t);return Bt(s,function(c){var d=n[c];t[c]=d,f&&(t.prototype[c]=function(){var y=this.__chain__;if(o||y){var m=t(this.__wrapped__),S=m.__actions__=bt(this.__actions__);return S.push({func:d,args:arguments,thisArg:t}),m.__chain__=y,m}return d.apply(t,mn([this.value()],arguments))})}),t}function Zp(){return dt._===this&&(dt._=mf),this}function Gi(){}function Yp(t){return t=B(t),q(function(n){return hu(n,t)})}var Xp=Ai(et),Qp=Ai(Ws),Vp=Ai(Zr);function Oo(t){return Ti(t)?Yr(rn(t)):Rc(t)}function jp(t){return function(n){return t==null?i:Fn(t,n)}}var tg=Du(),ng=Du(!0);function Ji(){return[]}function Zi(){return!1}function eg(){return{}}function rg(){return""}function ig(){return!0}function sg(t,n){if(t=B(t),t<1||t>tn)return[];var e=Nt,r=_t(t,Nt);n=O(n),t-=Nt;for(var s=Vr(r,n);++e<t;)n(e);return s}function ug(t){return U(t)?et(t,rn):Wt(t)?[t]:bt(Xu(Y(t)))}function og(t){var n=++wf;return Y(t)+n}var ag=fr(function(t,n){return t+n},0),fg=bi("ceil"),cg=fr(function(t,n){return t/n},1),lg=bi("floor");function hg(t){return t&&t.length?er(t,It,fi):i}function dg(t,n){return t&&t.length?er(t,O(n,2),fi):i}function pg(t){return Us(t,It)}function gg(t,n){return Us(t,O(n,2))}function _g(t){return t&&t.length?er(t,It,di):i}function vg(t,n){return t&&t.length?er(t,O(n,2),di):i}var wg=fr(function(t,n){return t*n},1),yg=bi("round"),mg=fr(function(t,n){return t-n},0);function xg(t){return t&&t.length?Qr(t,It):0}function Sg(t,n){return t&&t.length?Qr(t,O(n,2)):0}return u.after=Hh,u.ary=oo,u.assign=Od,u.assignIn=So,u.assignInWith=Sr,u.assignWith=Ld,u.at=Wd,u.before=ao,u.bind=Ui,u.bindAll=$p,u.bindKey=fo,u.castArray=ed,u.chain=io,u.chunk=ll,u.compact=hl,u.concat=dl,u.cond=Bp,u.conforms=Mp,u.constant=ki,u.countBy=xh,u.create=Dd,u.curry=co,u.curryRight=lo,u.debounce=ho,u.defaults=Fd,u.defaultsDeep=Ud,u.defer=zh,u.delay=Gh,u.difference=pl,u.differenceBy=gl,u.differenceWith=_l,u.drop=vl,u.dropRight=wl,u.dropRightWhile=yl,u.dropWhile=ml,u.fill=xl,u.filter=Ah,u.flatMap=Ph,u.flatMapDeep=Ih,u.flatMapDepth=Rh,u.flatten=to,u.flattenDeep=Sl,u.flattenDepth=Al,u.flip=Jh,u.flow=qp,u.flowRight=kp,u.fromPairs=bl,u.functions=kd,u.functionsIn=Hd,u.groupBy=Eh,u.initial=Pl,u.intersection=Il,u.intersectionBy=Rl,u.intersectionWith=El,u.invert=Gd,u.invertBy=Jd,u.invokeMap=Oh,u.iteratee=Hi,u.keyBy=Lh,u.keys=lt,u.keysIn=Pt,u.map=_r,u.mapKeys=Yd,u.mapValues=Xd,u.matches=Hp,u.matchesProperty=zp,u.memoize=wr,u.merge=Qd,u.mergeWith=Ao,u.method=Gp,u.methodOf=Jp,u.mixin=zi,u.negate=yr,u.nthArg=Yp,u.omit=Vd,u.omitBy=jd,u.once=Zh,u.orderBy=Wh,u.over=Xp,u.overArgs=Yh,u.overEvery=Qp,u.overSome=Vp,u.partial=Ni,u.partialRight=po,u.partition=Dh,u.pick=tp,u.pickBy=bo,u.property=Oo,u.propertyOf=jp,u.pull=Wl,u.pullAll=eo,u.pullAllBy=Dl,u.pullAllWith=Fl,u.pullAt=Ul,u.range=tg,u.rangeRight=ng,u.rearg=Xh,u.reject=Nh,u.remove=Nl,u.rest=Qh,u.reverse=Di,u.sampleSize=Bh,u.set=ep,u.setWith=rp,u.shuffle=Mh,u.slice=$l,u.sortBy=kh,u.sortedUniq=zl,u.sortedUniqBy=Gl,u.split=Pp,u.spread=Vh,u.tail=Jl,u.take=Zl,u.takeRight=Yl,u.takeRightWhile=Xl,u.takeWhile=Ql,u.tap=hh,u.throttle=jh,u.thru=gr,u.toArray=yo,u.toPairs=Co,u.toPairsIn=Po,u.toPath=ug,u.toPlainObject=xo,u.transform=ip,u.unary=td,u.union=Vl,u.unionBy=jl,u.unionWith=th,u.uniq=nh,u.uniqBy=eh,u.uniqWith=rh,u.unset=sp,u.unzip=Fi,u.unzipWith=ro,u.update=up,u.updateWith=op,u.values=ee,u.valuesIn=ap,u.without=ih,u.words=Eo,u.wrap=nd,u.xor=sh,u.xorBy=uh,u.xorWith=oh,u.zip=ah,u.zipObject=fh,u.zipObjectDeep=ch,u.zipWith=lh,u.entries=Co,u.entriesIn=Po,u.extend=So,u.extendWith=Sr,zi(u,u),u.add=ag,u.attempt=To,u.camelCase=hp,u.capitalize=Io,u.ceil=fg,u.clamp=fp,u.clone=rd,u.cloneDeep=sd,u.cloneDeepWith=ud,u.cloneWith=id,u.conformsTo=od,u.deburr=Ro,u.defaultTo=Kp,u.divide=cg,u.endsWith=dp,u.eq=Qt,u.escape=pp,u.escapeRegExp=gp,u.every=Sh,u.find=bh,u.findIndex=Vu,u.findKey=Nd,u.findLast=Ch,u.findLastIndex=ju,u.findLastKey=$d,u.floor=lg,u.forEach=so,u.forEachRight=uo,u.forIn=Bd,u.forInRight=Md,u.forOwn=Kd,u.forOwnRight=qd,u.get=Mi,u.gt=ad,u.gte=fd,u.has=zd,u.hasIn=Ki,u.head=no,u.identity=It,u.includes=Th,u.indexOf=Cl,u.inRange=cp,u.invoke=Zd,u.isArguments=$n,u.isArray=U,u.isArrayBuffer=cd,u.isArrayLike=Ct,u.isArrayLikeObject=st,u.isBoolean=ld,u.isBuffer=In,u.isDate=hd,u.isElement=dd,u.isEmpty=pd,u.isEqual=gd,u.isEqualWith=_d,u.isError=$i,u.isFinite=vd,u.isFunction=pn,u.isInteger=go,u.isLength=mr,u.isMap=_o,u.isMatch=wd,u.isMatchWith=yd,u.isNaN=md,u.isNative=xd,u.isNil=Ad,u.isNull=Sd,u.isNumber=vo,u.isObject=rt,u.isObjectLike=it,u.isPlainObject=be,u.isRegExp=Bi,u.isSafeInteger=bd,u.isSet=wo,u.isString=xr,u.isSymbol=Wt,u.isTypedArray=ne,u.isUndefined=Cd,u.isWeakMap=Pd,u.isWeakSet=Id,u.join=Tl,u.kebabCase=_p,u.last=Ht,u.lastIndexOf=Ol,u.lowerCase=vp,u.lowerFirst=wp,u.lt=Rd,u.lte=Ed,u.max=hg,u.maxBy=dg,u.mean=pg,u.meanBy=gg,u.min=_g,u.minBy=vg,u.stubArray=Ji,u.stubFalse=Zi,u.stubObject=eg,u.stubString=rg,u.stubTrue=ig,u.multiply=wg,u.nth=Ll,u.noConflict=Zp,u.noop=Gi,u.now=vr,u.pad=yp,u.padEnd=mp,u.padStart=xp,u.parseInt=Sp,u.random=lp,u.reduce=Fh,u.reduceRight=Uh,u.repeat=Ap,u.replace=bp,u.result=np,u.round=yg,u.runInContext=h,u.sample=$h,u.size=Kh,u.snakeCase=Cp,u.some=qh,u.sortedIndex=Bl,u.sortedIndexBy=Ml,u.sortedIndexOf=Kl,u.sortedLastIndex=ql,u.sortedLastIndexBy=kl,u.sortedLastIndexOf=Hl,u.startCase=Ip,u.startsWith=Rp,u.subtract=mg,u.sum=xg,u.sumBy=Sg,u.template=Ep,u.times=sg,u.toFinite=gn,u.toInteger=B,u.toLength=mo,u.toLower=Tp,u.toNumber=zt,u.toSafeInteger=Td,u.toString=Y,u.toUpper=Op,u.trim=Lp,u.trimEnd=Wp,u.trimStart=Dp,u.truncate=Fp,u.unescape=Up,u.uniqueId=og,u.upperCase=Np,u.upperFirst=qi,u.each=so,u.eachRight=uo,u.first=no,zi(u,function(){var t={};return nn(u,function(n,e){X.call(u.prototype,e)||(t[e]=n)}),t}(),{chain:!1}),u.VERSION=p,Bt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){u[t].placeholder=u}),Bt(["drop","take"],function(t,n){z.prototype[t]=function(e){e=e===i?1:ft(B(e),0);var r=this.__filtered__&&!n?new z(this):this.clone();return r.__filtered__?r.__takeCount__=_t(e,r.__takeCount__):r.__views__.push({size:_t(e,Nt),type:t+(r.__dir__<0?"Right":"")}),r},z.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Bt(["filter","map","takeWhile"],function(t,n){var e=n+1,r=e==En||e==ct;z.prototype[t]=function(s){var o=this.clone();return o.__iteratees__.push({iteratee:O(s,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),Bt(["head","last"],function(t,n){var e="take"+(n?"Right":"");z.prototype[t]=function(){return this[e](1).value()[0]}}),Bt(["initial","tail"],function(t,n){var e="drop"+(n?"":"Right");z.prototype[t]=function(){return this.__filtered__?new z(this):this[e](1)}}),z.prototype.compact=function(){return this.filter(It)},z.prototype.find=function(t){return this.filter(t).head()},z.prototype.findLast=function(t){return this.reverse().find(t)},z.prototype.invokeMap=q(function(t,n){return typeof t=="function"?new z(this):this.map(function(e){return we(e,t,n)})}),z.prototype.reject=function(t){return this.filter(yr(O(t)))},z.prototype.slice=function(t,n){t=B(t);var e=this;return e.__filtered__&&(t>0||n<0)?new z(e):(t<0?e=e.takeRight(-t):t&&(e=e.drop(t)),n!==i&&(n=B(n),e=n<0?e.dropRight(-n):e.take(n-t)),e)},z.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},z.prototype.toArray=function(){return this.take(Nt)},nn(z.prototype,function(t,n){var e=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),s=u[r?"take"+(n=="last"?"Right":""):n],o=r||/^find/.test(n);s&&(u.prototype[n]=function(){var f=this.__wrapped__,c=r?[1]:arguments,d=f instanceof z,y=c[0],m=d||U(f),S=function(H){var G=s.apply(u,mn([H],c));return r&&b?G[0]:G};m&&e&&typeof y=="function"&&y.length!=1&&(d=m=!1);var b=this.__chain__,R=!!this.__actions__.length,L=o&&!b,M=d&&!R;if(!o&&m){f=M?f:new z(this);var W=t.apply(f,c);return W.__actions__.push({func:gr,args:[S],thisArg:i}),new Kt(W,b)}return L&&M?t.apply(this,c):(W=this.thru(S),L?r?W.value()[0]:W.value():W)})}),Bt(["pop","push","shift","sort","splice","unshift"],function(t){var n=Ke[t],e=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);u.prototype[t]=function(){var s=arguments;if(r&&!this.__chain__){var o=this.value();return n.apply(U(o)?o:[],s)}return this[e](function(f){return n.apply(U(f)?f:[],s)})}}),nn(z.prototype,function(t,n){var e=u[n];if(e){var r=e.name+"";X.call(Xn,r)||(Xn[r]=[]),Xn[r].push({name:n,func:e})}}),Xn[ar(i,vn).name]=[{name:"wrapper",func:i}],z.prototype.clone=Uf,z.prototype.reverse=Nf,z.prototype.value=$f,u.prototype.at=dh,u.prototype.chain=ph,u.prototype.commit=gh,u.prototype.next=_h,u.prototype.plant=wh,u.prototype.reverse=yh,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=mh,u.prototype.first=u.prototype.head,le&&(u.prototype[le]=vh),u},Jn=gf();Tn?((Tn.exports=Jn)._=Jn,Hr._=Jn):dt._=Jn}).call(Pe)})(Ar,Ar.exports);var Dg=Ar.exports;const Fg=Wg(Dg);class Ug{constructor(a){E(this,"config");this.config=a}async complete(a,i){var p;await this.persist(a,{...i,success:!0}),(p=this.config.logger)==null||p.debug("Transaction completed:",a)}async fail(a,i){var p;await this.persist(a,{...i,success:!1}),(p=this.config.logger)==null||p.debug("Transaction failed:",{...a,...i})}async persist(a,i){await fetch(`${this.config.apiUrl}/transactions/${a.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Ng{constructor(a,i){E(this,"transaction");E(this,"manager");this.transaction=a,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(a,i){var T;const p=this.transaction.functionCall;if(!p){await this.fail("No function call found");return}const g=p.name,v=p.args,x=a[g];if(!x){await this.fail(`Tool ${g} not found`);return}try{const C=Fg.get(i,"schema.config.parameters.properties",{}),Z=(C&&Object.keys(C).length>0?Object.keys(C):((T=x.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:T[1].split(",").map(D=>D.trim()).filter(Boolean))||[]).map(D=>v[D]),A=await x(...Z);await this.complete(A)}catch(C){await this.fail(`Error executing tool ${g}: ${C}`)}}async complete(a){await this.manager.complete(this.transaction,{success:!0,output:a,error:null})}async fail(a){await this.manager.fail(this.transaction,{success:!1,output:null,error:a})}}class Do extends Ie{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 p of i.tools)p.schema&&p.implementation&&(this._tools[p.schema.name]=p.implementation,this._toolSchema[p.schema.name]=p)}else this._tools=i.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(i){return this._toolSchema[i]}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){}onTransaction(i){const p=new Ug(this.config),g=new Ng(i,p);if(this.config.onTransaction)this.config.onTransaction(g);else{const v=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;g.invoke(this._tools,v)}}getTools(){return this._tools}}function $g(l,a){if(Array.isArray(l))return l;if(typeof l=="object"&&l!==null){const i=a.dev?"localhost:8000":a.baseUrl||"persona.applica.guru/api",p=a.dev?"http":"https",g=a.dev?"ws":"wss",v=Object.keys(l).map(x=>{switch(x){case"rest":return Bg(l[x],{baseEndpointProtocol:p,baseEndpoint:i,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger});case"webrtc":return Mg(l[x],{baseWebSocketProtocol:g,baseEndpoint:i,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger});case"websocket":return Kg(l[x],{baseWebSocketProtocol:g,baseEndpoint:i,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger});default:throw new Error(`Unknown protocol: ${x}`)}}).filter(x=>x!==null);return a.tools&&v.push(new Do({apiUrl:`${p}://${i}`,apiKey:a.apiKey,agentId:a.agentId,tools:a.tools,logger:a.logger})),v}throw new Error("Invalid protocols configuration")}function Bg(l,a){return l===!0?new Vi({apiUrl:`${a.baseEndpointProtocol}://${a.baseEndpoint}`,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger}):typeof l=="object"&&l!==null?new Vi(l):null}function Mg(l,a){return l===!0?new ts({webrtcUrl:`${a.baseWebSocketProtocol}://${a.baseEndpoint}/webrtc`,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger}):typeof l=="object"&&l!==null?new ts(l):null}function Kg(l,a){return l===!0?new ji({webSocketUrl:`${a.baseWebSocketProtocol}://${a.baseEndpoint}/websocket`,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger}):typeof l=="object"&&l!==null?new ji(l):null}function qg(l,a,i,p,g){return v=>{v.type==="message"?kg(v.payload,l,a,i,g):v.type==="reasoning"?Hg(v.payload,l,a,g):v.type==="transaction"&&zg(v.payload,l,p)}}function kg(l,a,i,p,g){l.createdAt||(l.createdAt=new Date),(l==null?void 0:l.finishReason)==="stop"&&!(l!=null&&l.functionResponse)&&!(l!=null&&l.thought)&&p(!1),l.thought&&(l.type="reasoning"),l.protocol=a.getName(),i(v=>{const x=Bn([...v,l]);return g?g(x):x})}function Hg(l,a,i,p){const g={type:"reasoning",text:l.thought,role:"assistant",finishReason:"stop",protocol:a.getName(),createdAt:new Date};i(v=>{const x=Bn([...v,g]);return p?p(x):x})}function zg(l,a,i){i.filter(p=>p!==a).forEach(p=>p.onTransaction(l))}function Wo(l){return new Promise((a,i)=>{const p=new FileReader;p.readAsDataURL(l),p.onload=()=>{const v=p.result.split(";base64,")[1];a(v)},p.onerror=g=>{i(g)}})}function Gg(l){const a={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 l){const p=a[i.getName()];if(p)return p(i)}return null}function Jg(l,a,i,p,g){return async v=>{const x=v.content.find(P=>P.type==="text"),T=v.attachments&&v.attachments.length>0;if(!x&&!T)throw new Error("Message must contain text or attachments");if(!l.some(P=>P.getName()!=="transaction"&&P.status==="connected")){a(P=>{const N={role:"assistant",type:"text",text:"No protocol is connected.",createdAt:new Date,finishReason:"stop"},j=[...P,N];return p?p(j):j});return}const K=(x==null?void 0:x.type)==="text"?x.text??"":"",Z={role:"user",type:"text",text:K,createdAt:new Date};a(P=>{const N=Bn([...P,Z]);return p?p(N):N}),i(!0);const A=l.sort((P,N)=>N.getPriority()-P.getPriority()).find(P=>P.status==="connected"),D=[];if(v.attachments)for(const P of v.attachments)if(P.contentType.startsWith("image/")&&P.file)D.push({role:"user",image:{contentType:P.contentType,content:await Wo(P.file)},text:"",type:"text",createdAt:new Date});else if(P.content){const N=P.content.find(k=>k.type==="text");N&&"text"in N&&D.push({role:"user",file:{name:P.name,contentType:P.contentType},text:N.text,type:"text",createdAt:new Date});const j=P.content.find(k=>k.type==="file");j&&"data"in j&&D.push({role:"user",file:{name:P.name,base64:j.data,contentType:P.contentType},text:"",type:"text",createdAt:new Date})}else P.file&&D.push({role:"user",file:{name:P.name,base64:await Wo(P.file),contentType:P.contentType||"application/octet-stream"},text:"",type:"text",createdAt:new Date});K&&D.push({role:"user",text:K,type:"text",createdAt:new Date}),g==null||g.debug("Sending message:",D),await(A==null?void 0:A.sendPacket({type:"request",payload:D}))}}function Zg(l,a,i,p,g,v){return async x=>{var N;if(((N=x.content[0])==null?void 0:N.type)!=="text")throw new Error("Only text messages are supported");const T=l.sort((j,k)=>k.getPriority()-j.getPriority()).find(j=>j.status==="connected");if(!T){v==null||v.debug("No protocol available for edit");return}const C=x.parentId;if(!C){v==null||v.debug("No parent ID provided for edit");return}const K=a.findIndex(j=>j.id===C);if(K===-1){v==null||v.debug("Parent message not found:",C);return}const Z=a.slice(0,K+1),A={role:"user",text:x.content[0].text,type:"text",createdAt:new Date},D=Bn([...Z,A]);i(g?g(D):D),p(!0);const P=[{role:"user",text:x.content[0].text,type:"text",createdAt:new Date}];v==null||v.debug("Sending edited message:",P),await T.sendPacket({type:"request",payload:P})}}function Yg(l,a,i,p,g,v){return async(x,T)=>{const C=l.sort((N,j)=>j.getPriority()-N.getPriority()).find(N=>N.status==="connected");if(!C){v==null||v.debug("No protocol available for reload");return}const K=T.parentId??x;if(!K){v==null||v.debug("No parent ID provided for reload");return}const Z=a.findIndex(N=>N.id===K);if(Z===-1){v==null||v.debug("Parent message not found:",K);return}const A=a[Z];i(N=>{const j=N.slice(0,Z+1);return g?g(j):j});let D;if(A.role==="assistant"||A.role==="function"){for(let N=Z-1;N>=0;N--)if(a[N].role==="user"){D=a[N];break}}else A.role==="user"&&(D=A);if(!D){v==null||v.debug("No user message found to regenerate from");return}p(!0);const P=[];D.image&&P.push({role:"user",image:D.image,text:"",type:"text",createdAt:new Date}),P.push({role:"user",text:D.text,type:"text",createdAt:new Date}),v==null||v.debug("Regenerating message with config:",{actualParentId:K,sourceId:T.sourceId,custom:T.runConfig.custom}),await C.sendPacket({type:"request",payload:P})}}function Xg(l,a,i,p){return()=>(i(!1),a(g=>{const v=g[g.length-1];if((v==null?void 0:v.role)==="assistant"&&!v.finishReason){const x=[...g];return x[x.length-1]={...v,finishReason:"stop",status:{type:"incomplete"}},p?p(x):x}return g}),l.forEach(g=>{g.status==="connected"&&g.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:{cancel:!0}}}).catch(()=>{})}),Promise.resolve())}const re=Q.createContext(void 0);function Qg(){const l=Q.useContext(re);if(!l)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return l}function Fo(l){const a=Q.useContext(re);if(!a)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=a.protocols.find(g=>g.getName()===l);if(!i)return null;const p=a.protocolsStatus.get(i.getName());return{...i,connect:i.connect.bind(i),disconnect:i.disconnect.bind(i),sendPacket:i.sendPacket.bind(i),setSession:i.setSession.bind(i),addStatusChangeListener:i.addStatusChangeListener.bind(i),addPacketListener:i.addPacketListener.bind(i),getName:i.getName.bind(i),getPriority:i.getPriority.bind(i),status:p||i.status}}function Vg(){const l=Q.useContext(re);if(!l)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return Gg(l.protocols)}function jg(){return Fo("webrtc")}function t_(){const l=Q.useContext(re);if(!l)throw new Error("usePersonaRenameThread must be used within a PersonaRuntimeProvider");return l.renameThread}function n_(){const l=Q.useContext(re);if(!l)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return l.getMessages()}const Yi="DEFAULT_THREAD_ID";function e_(){const l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let a="";for(let i=0;i<8;i++)a+=l.charAt(Math.floor(Math.random()*l.length));return a}function r_(l,a,i,p,g,v,x,T,C,K,Z){return{threadId:l,threads:a.filter(A=>A.status==="regular").map(A=>({id:A.threadId,threadId:A.threadId,title:A.title||`Session ${A.threadId}`,status:A.status})),archivedThreads:a.filter(A=>A.status==="archived").map(A=>({id:A.threadId,threadId:A.threadId,title:A.title||`Archived Chat ${A.threadId}`,status:A.status})),onSwitchToNewThread:()=>{const A=e_(),D={threadId:A,status:"regular",title:`Session ${A}`};p(P=>[D,...P]),i(A),v==null||v(A)},onSwitchToThread:A=>{i(A),x==null||x(A)},onArchive:A=>{p(D=>D.map(P=>P.threadId===A?{...P,status:"archived"}:P)),T==null||T(A),A!==Yi&&g.archive(A)},onUnarchive:A=>{p(D=>D.map(P=>P.threadId===A?{...P,status:"regular"}:P)),C==null||C(A)},onRename:(A,D)=>{p(P=>P.map(N=>N.threadId===A?{...N,title:D}:N)),Z==null||Z(A,D),A!==Yi&&g.rename(A,D)},onDelete:async A=>{if(p(D=>D.filter(P=>P.threadId!==A)),l===A){const D=a.filter(P=>P.threadId!==A&&P.status==="regular");D.length>0&&i(D[0].threadId)}K==null||K(A),A!==Yi&&await g.delete(A)}}}class Uo{constructor(a){E(this,"endpoint");E(this,"apiKey");E(this,"pageSize");E(this,"logger");this.endpoint=a.endpoint.replace(/\/$/,""),this.apiKey=a.apiKey,this.pageSize=a.pageSize??200,this.logger=a.logger}buildHeaders(){const a={"Content-Type":"application/json"};return this.apiKey&&(a["x-persona-apikey"]=this.apiKey),a}async sync(a){var p,g;if(!a)return[];const i=`${this.endpoint}/sessions/${encodeURIComponent(String(a))}/messages?page=1&size=${this.pageSize}`;try{const v=await fetch(i,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return(p=this.logger)==null||p.warn("PersonaSessionStorage: failed to fetch messages",v.status,await v.text()),[];const x=await v.json();return Array.isArray(x.items)?x.items.map(C=>({id:C.id??C.messageId??void 0,protocol:C.protocol,thought:C.thought,text:C.text??"",image:C.image,type:C.type??"text",role:C.role??"assistant",file:C.file,sources:C.sources,sessionId:C.sessionId??a,finishReason:C.finishReason,functionCalls:C.functionCalls,functionResponse:C.functionResponse,status:C.status,createdAt:C.createdAt?new Date(C.createdAt):void 0,metadata:C.metadata})):[]}catch(v){return(g=this.logger)==null||g.warn("PersonaSessionStorage: error fetching messages",v),[]}}async archive(a){return this._visiblility(a,"archived")}async unarchive(a){return this._visiblility(a,"active")}async delete(a){return this._visiblility(a,"deleted")}async _visiblility(a,i){var x;if(!a)return;const p=`${this.endpoint}/sessions/${encodeURIComponent(String(a))}/visibility`,g=JSON.stringify({visibility:i}),v=await fetch(p,{method:"PUT",headers:this.buildHeaders(),body:g});if(!v.ok){const T=await v.text();throw(x=this.logger)==null||x.warn("PersonaSessionStorage: failed to set session visibility",v.status,T),new Error(`Failed to set session visibility: ${v.status}`)}}async rename(a,i){var v;if(!a)return;const p=`${this.endpoint}/sessions/${encodeURIComponent(String(a))}/name`,g=await fetch(p,{method:"PUT",headers:this.buildHeaders(),body:JSON.stringify({name:i})});if(!g.ok){const x=await g.text();throw(v=this.logger)==null||v.warn("PersonaSessionStorage: failed to rename session",g.status,x),new Error(`Failed to rename session: ${g.status}`)}}async clearAll(){return Promise.reject(new Error("PersonaAPIMessageStorage: clearAll not supported"))}async list(a,i){const p=new URLSearchParams({page:"1",size:"100",visibility:"active"});i&&p.set("userId",i),a&&p.set("agentId",a);const g=`${this.endpoint}/sessions?${p.toString()}`;try{const v=await fetch(g,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return[];const x=await v.json();return Array.isArray(x.items)?x.items.map(C=>({threadId:C.code||C.id,title:C.name||`Session ${C.code||C.id}`,status:C.status==="archived"?"archived":"regular"})):[]}catch{return[]}}}function i_({dev:l=!1,baseUrl:a,protocols:i,logger:p,children:g,session:v="new",transformMessages:x,threads:T=!1,sessionStorage:C,onThreadCreate:K,onThreadSwitch:Z,onThreadRename:A,onThreadArchive:D,onThreadUnarchive:P,onThreadDelete:N,enableAttachments:j=!1,...k}){const[vn,sn]=Q.useState(!1),[ht,gt]=Q.useState([]),[Gt,Rn]=Q.useState(new Map),Ut=Q.useRef(!1),jt=Q.useRef(!1),Rt=Q.useMemo(()=>C||new Uo({apiKey:k.apiKey,endpoint:a||"https://persona.applica.guru/api"}),[C,a,k.apiKey]),[Re,ie]=Q.useState([]),[Et,Ee]=Q.useState(""),En=Q.useRef(typeof v=="string"?v:"new"),Te=Q.useRef(!1);Q.useEffect(()=>{!T||Te.current||(Te.current=!0,Rt.list(k.agentId,k.userId).then($=>{($==null?void 0:$.length)>0&&(ie($),Ee($[0].threadId))}).catch($=>p==null?void 0:p.error("Failed to load threads:",$)))},[T,Rt,k.agentId,k.userId,p]);const ct=Q.useMemo(()=>$g(i,{dev:l||!1,baseUrl:a,apiKey:k.apiKey,agentId:k.agentId,userId:k.userId,tools:k.tools,logger:p}),[i,l,a,k.apiKey,k.agentId,k.userId,k.tools,p]);Q.useEffect(()=>{Ut.current||(Ut.current=!0,p==null||p.debug("Setting up protocols:",ct.map($=>$.getName())),ct.forEach($=>{$.setSession(En.current),$.clearListeners(),$.addStatusChangeListener(ot=>{p==null||p.debug(`${$.getName()} status: ${ot}`),Rn(St=>{const wt=new Map(St);return wt.set($.getName(),ot),wt}),ot==="connected"&&!jt.current&&(k.context&&$.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:k.context}}).catch(()=>{}),k.tools&&Array.isArray(k.tools)&&$.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:k.tools.map(St=>St.schema)}}}).catch(()=>{}))}),$.addPacketListener(qg($,gt,sn,ct,x)),$.autostart&&$.status==="disconnected"&&(p==null||p.debug(`Auto-connecting protocol: ${$.getName()}`),$.connect(En.current).catch(()=>{}),sn(!1))}))},[]),Q.useEffect(()=>{T||!v||v==="new"||Rt.sync(v).then($=>{if($.length>0){const ot=Bn($);gt(x?x(ot):ot),p==null||p.debug(`Loaded ${$.length} messages for session ${v}`)}}).catch($=>{p==null||p.error("Failed to load session messages:",$)})},[]),Q.useEffect(()=>{if(!T||!Et){gt([]);return}if(jt.current||Et===En.current)return;jt.current=!0,p==null||p.info("Switching to thread:",Et),(async()=>{try{const ot=ct.filter(At=>At.status==="connected");ot.length>0&&await Promise.allSettled(ot.map(At=>At.disconnect())),En.current=Et,await Promise.allSettled(ct.map(At=>At.setSession(Et)));const St=await Rt.sync(Et),wt=Bn(St);gt(x?x(wt):wt),p==null||p.debug(`Loaded ${St.length} messages for thread ${Et}`);const Le=ct.filter(At=>At.autostart);Le.length>0&&await Promise.allSettled(Le.map(At=>At.connect(Et)))}catch(ot){p==null||p.error("Failed to switch thread:",ot),gt([])}finally{jt.current=!1}})()},[Et,T,ct,Rt,x,p]);const un=Q.useCallback(Jg(ct,gt,sn,x,p),[ct,x,p]),tn=Q.useCallback(Zg(ct,ht,gt,sn,x,p),[ct,ht,x,p]),Cr=Q.useCallback(Yg(ct,ht,gt,sn,x,p),[ct,ht,x,p]),Kn=Q.useCallback(Xg(ct,gt,sn,x),[ct,x]),Nt=Q.useCallback($=>{const ot=Bn([...$]);gt(x?x(ot):ot)},[x]),Pr=Q.useCallback(()=>ht,[ht]),Oe=Q.useMemo(()=>{if(T)return r_(Et,Re,Ee,ie,Rt,K,Z,D,P,N,A)},[T,Et,Re,Rt,K,Z,D,P,N,A,p]),Ir=Ce.useExternalStoreRuntime({isRunning:vn,messages:ht,convertMessage:Og,setMessages:Nt,onNew:un,onEdit:tn,onCancel:Kn,onReload:Cr,adapters:{...j?{attachments:new Ce.CompositeAttachmentAdapter([new Ce.SimpleImageAttachmentAdapter,new Ce.SimpleTextAttachmentAdapter,new Pg])}:{},...Oe?{threadList:Oe}:{}}}),wn=Q.useCallback(($,ot)=>{ie(St=>St.map(wt=>wt.threadId===$?{...wt,title:ot}:wt)),A==null||A($,ot),Rt.rename($,ot)},[Rt,A]);return Xi.jsx(re.Provider,{value:{protocols:ct,protocolsStatus:Gt,getMessages:Pr,renameThread:wn},children:Xi.jsx(Ce.AssistantRuntimeProvider,{runtime:Ir,children:g})})}function s_({children:l,...a}){return Xi.jsx(i_,{...a,children:l})}class u_{constructor(){E(this,"prefix","[Persona]")}log(a,...i){console.log(`${this.prefix} - ${a}`,...i)}info(a,...i){console.info(`${this.prefix} - ${a}`,...i)}warn(a,...i){console.warn(`${this.prefix} - ${a}`,...i)}error(a,...i){console.error(`${this.prefix} - ${a}`,...i)}debug(a,...i){console.debug(`${this.prefix} - ${a}`,...i)}}function Mn(l,a,i){return{type:l,description:a,...i}}function No(l){const a=Object.entries(l.parameters).filter(([i,p])=>p.required).map(([i])=>i);return{type:"local",name:l.name,description:l.description,config:{timeout:l.timeout||60,parameters:{type:"object",title:l.title||`${l.name} parameters`,required:a,properties:l.parameters},output:{type:"object",title:`${l.name} output`,properties:l.output}}}}function br(l){return{schema:No(l),implementation:l.implementation}}function $o(l,a,i,p,g,v){const x={name:l,description:a,title:v==null?void 0:v.title,timeout:v==null?void 0:v.timeout,parameters:p,output:g,implementation:i};return br(x)}const o_=$o("sum","Sum two numbers",function(a,i){return{result:a+i}},{a:Mn("number","First number to sum",{required:!0}),b:Mn("number","Second number to sum",{required:!0})},{result:Mn("number","Sum of two numbers")}),a_=br({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:Mn("number","First number to sum"),b:Mn("number","Seconth number to sum")},output:{result:Mn("number","Sum of two numbers")},implementation:function(a,i){return{result:a+i}}});function f_(l){const a=[],i={};return l.forEach(p=>{const{schema:g,implementation:v}=br(p);a.push(g),i[p.name]=v}),{schemas:a,implementations:i}}function c_(l,a){const{required:i,properties:p}=a.config.parameters;for(const g of i)if(!(g in l))throw new Error(`Missing required parameter: ${g}`);for(const[g,v]of Object.entries(l)){const x=p[g];if(x){if(x.type==="number"&&typeof v!="number")throw new Error(`Parameter ${g} should be a number`);if(x.type==="string"&&typeof v!="string")throw new Error(`Parameter ${g} should be a string`);if(x.type==="boolean"&&typeof v!="boolean")throw new Error(`Parameter ${g} should be a boolean`)}}return!0}class l_{constructor(a){E(this,"baseUrl");E(this,"apiKey");this.baseUrl=a.baseUrl.replace(/\/$/,""),this.apiKey=a.apiKey}async request(a,i){const p=await fetch(`${this.baseUrl}${a}`,{...i,headers:{"Content-Type":"application/json","x-persona-apikey":this.apiKey,...(i==null?void 0:i.headers)??{}}});if(!p.ok)throw new Error(await p.text());return await p.json()}async getSubscription(a){return this.request(`/projects/${a}/subscription`)}async changeSubscriptionPlan(a,i){return this.request(`/projects/${a}/subscription/actions/change-plan`,{method:"POST",body:JSON.stringify({toPlanType:i})})}async addSubscriptionCredits(a,i){return this.request(`/projects/${a}/subscription/actions/add-credits`,{method:"POST",body:JSON.stringify({credits:i})})}}exports.PersonaConsoleLogger=u_;exports.PersonaProtocolBase=Ie;exports.PersonaRESTProtocol=Vi;exports.PersonaRuntimeProvider=s_;exports.PersonaSessionStorage=Uo;exports.PersonaTransactionProtocol=Do;exports.PersonaWebRTCProtocol=ts;exports.PersonaWebSocketProtocol=ji;exports.ProjectsApi=l_;exports.createParameter=Mn;exports.createTool=br;exports.createToolFromFunction=$o;exports.createToolRegistry=f_;exports.generateToolSchema=No;exports.navigateToToolExample=a_;exports.sumTool=o_;exports.usePersonaRenameThread=t_;exports.usePersonaRuntime=Qg;exports.usePersonaRuntimeEndpoint=Vg;exports.usePersonaRuntimeMessages=n_;exports.usePersonaRuntimeProtocol=Fo;exports.usePersonaRuntimeWebRTCProtocol=jg;exports.validateToolParameters=c_;
|
|
27
|
+
}`;var k=Ta(function(){return Z(a,E+"return "+S).apply(i,c)});if(k.source=S,Bi(k))throw k;return k}function Tp(t){return X(t).toLowerCase()}function Op(t){return X(t).toUpperCase()}function Lp(t,e,n){if(t=X(t),t&&(n||e===i))return $s(t);if(!t||!(e=Lt(e)))return t;var r=Xt(t),s=Xt(e),a=Bs(r,s),c=ks(r,s)+1;return Ae(r,a,c).join("")}function Dp(t,e,n){if(t=X(t),t&&(n||e===i))return t.slice(0,qs(t)+1);if(!t||!(e=Lt(e)))return t;var r=Xt(t),s=ks(r,Xt(e))+1;return Ae(r,0,s).join("")}function Wp(t,e,n){if(t=X(t),t&&(n||e===i))return t.replace(Br,"");if(!t||!(e=Lt(e)))return t;var r=Xt(t),s=Bs(r,Xt(e));return Ae(r,s).join("")}function Up(t,e){var n=On,r=Ke;if(it(e)){var s="separator"in e?e.separator:s;n="length"in e?$(e.length):n,r="omission"in e?Lt(e.omission):r}t=X(t);var a=t.length;if(Ze(t)){var c=Xt(t);a=c.length}if(n>=a)return t;var l=n-Ye(r);if(l<1)return r;var p=c?Ae(c,0,l).join(""):t.slice(0,l);if(s===i)return p+r;if(c&&(l+=p.length-l),ki(s)){if(t.slice(l).search(s)){var w,m=p;for(s.global||(s=ri(s.source,X(as.exec(s))+"g")),s.lastIndex=0;w=s.exec(m);)var S=w.index;p=p.slice(0,S===i?l:S)}}else if(t.indexOf(Lt(s),l)!=l){var C=p.lastIndexOf(s);C>-1&&(p=p.slice(0,C))}return p+r}function Np(t){return t=X(t),t&&Ga.test(t)?t.replace(is,fc):t}var Fp=nn(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),Hi=Ou("toUpperCase");function Ea(t,e,n){return t=X(t),e=n?i:e,e===i?sc(t)?dc(t):Xo(t):t.match(e)||[]}var Ta=K(function(t,e){try{return Tt(t,i,e)}catch(n){return Bi(n)?n:new F(n)}}),Mp=ce(function(t,e){return $t(e,function(n){n=ne(n),ae(t,n,Mi(t[n],t))}),t});function $p(t){var e=t==null?0:t.length,n=L();return t=e?rt(t,function(r){if(typeof r[1]!="function")throw new Bt(x);return[n(r[0]),r[1]]}):[],K(function(r){for(var s=-1;++s<e;){var a=t[s];if(Tt(a[0],this,r))return Tt(a[1],this,r)}})}function Bp(t){return lf(Kt(t,P))}function Gi(t){return function(){return t}}function kp(t,e){return t==null||t!==t?e:t}var Kp=Du(),qp=Du(!0);function Rt(t){return t}function zi(t){return cu(typeof t=="function"?t:Kt(t,P))}function Hp(t){return lu(Kt(t,P))}function Gp(t,e){return hu(t,Kt(e,P))}var zp=K(function(t,e){return function(n){return mn(n,t,e)}}),Jp=K(function(t,e){return function(n){return mn(t,n,e)}});function Ji(t,e,n){var r=pt(e),s=rr(e,r);n==null&&!(it(e)&&(s.length||!r.length))&&(n=e,e=t,t=this,s=rr(e,pt(e)));var a=!(it(n)&&"chain"in n)||!!n.chain,c=le(t);return $t(s,function(l){var p=e[l];t[l]=p,c&&(t.prototype[l]=function(){var w=this.__chain__;if(a||w){var m=t(this.__wrapped__),S=m.__actions__=At(this.__actions__);return S.push({func:p,args:arguments,thisArg:t}),m.__chain__=w,m}return p.apply(t,ve([this.value()],arguments))})}),t}function Zp(){return gt._===this&&(gt._=wc),this}function Zi(){}function Yp(t){return t=$(t),K(function(e){return du(e,t)})}var Xp=Pi(rt),Qp=Pi(Ws),Vp=Pi(Xr);function Oa(t){return Li(t)?Qr(ne(t)):If(t)}function jp(t){return function(e){return t==null?i:Ne(t,e)}}var tg=Uu(),eg=Uu(!0);function Yi(){return[]}function Xi(){return!1}function ng(){return{}}function rg(){return""}function ig(){return!0}function sg(t,e){if(t=$(t),t<1||t>Jt)return[];var n=Ft,r=wt(t,Ft);e=L(e),t-=Ft;for(var s=ti(r,e);++n<t;)e(n);return s}function ug(t){return M(t)?rt(t,ne):Dt(t)?[t]:At(Qu(X(t)))}function ag(t){var e=++yc;return X(t)+e}var og=cr(function(t,e){return t+e},0),cg=Ci("ceil"),fg=cr(function(t,e){return t/e},1),lg=Ci("floor");function hg(t){return t&&t.length?nr(t,Rt,li):i}function dg(t,e){return t&&t.length?nr(t,L(e,2),li):i}function pg(t){return Fs(t,Rt)}function gg(t,e){return Fs(t,L(e,2))}function _g(t){return t&&t.length?nr(t,Rt,gi):i}function yg(t,e){return t&&t.length?nr(t,L(e,2),gi):i}var vg=cr(function(t,e){return t*e},1),wg=Ci("round"),mg=cr(function(t,e){return t-e},0);function xg(t){return t&&t.length?jr(t,Rt):0}function Sg(t,e){return t&&t.length?jr(t,L(e,2)):0}return u.after=Hh,u.ary=oa,u.assign=Od,u.assignIn=Sa,u.assignInWith=Sr,u.assignWith=Ld,u.at=Dd,u.before=ca,u.bind=Mi,u.bindAll=Mp,u.bindKey=fa,u.castArray=nd,u.chain=sa,u.chunk=ll,u.compact=hl,u.concat=dl,u.cond=$p,u.conforms=Bp,u.constant=Gi,u.countBy=xh,u.create=Wd,u.curry=la,u.curryRight=ha,u.debounce=da,u.defaults=Ud,u.defaultsDeep=Nd,u.defer=Gh,u.delay=zh,u.difference=pl,u.differenceBy=gl,u.differenceWith=_l,u.drop=yl,u.dropRight=vl,u.dropRightWhile=wl,u.dropWhile=ml,u.fill=xl,u.filter=bh,u.flatMap=Ch,u.flatMapDeep=Rh,u.flatMapDepth=Ih,u.flatten=ea,u.flattenDeep=Sl,u.flattenDepth=bl,u.flip=Jh,u.flow=Kp,u.flowRight=qp,u.fromPairs=Al,u.functions=qd,u.functionsIn=Hd,u.groupBy=Eh,u.initial=Cl,u.intersection=Rl,u.intersectionBy=Il,u.intersectionWith=El,u.invert=zd,u.invertBy=Jd,u.invokeMap=Oh,u.iteratee=zi,u.keyBy=Lh,u.keys=pt,u.keysIn=Ct,u.map=_r,u.mapKeys=Yd,u.mapValues=Xd,u.matches=Hp,u.matchesProperty=Gp,u.memoize=vr,u.merge=Qd,u.mergeWith=ba,u.method=zp,u.methodOf=Jp,u.mixin=Ji,u.negate=wr,u.nthArg=Yp,u.omit=Vd,u.omitBy=jd,u.once=Zh,u.orderBy=Dh,u.over=Xp,u.overArgs=Yh,u.overEvery=Qp,u.overSome=Vp,u.partial=$i,u.partialRight=pa,u.partition=Wh,u.pick=tp,u.pickBy=Aa,u.property=Oa,u.propertyOf=jp,u.pull=Dl,u.pullAll=ra,u.pullAllBy=Wl,u.pullAllWith=Ul,u.pullAt=Nl,u.range=tg,u.rangeRight=eg,u.rearg=Xh,u.reject=Fh,u.remove=Fl,u.rest=Qh,u.reverse=Ni,u.sampleSize=$h,u.set=np,u.setWith=rp,u.shuffle=Bh,u.slice=Ml,u.sortBy=qh,u.sortedUniq=Gl,u.sortedUniqBy=zl,u.split=Cp,u.spread=Vh,u.tail=Jl,u.take=Zl,u.takeRight=Yl,u.takeRightWhile=Xl,u.takeWhile=Ql,u.tap=hh,u.throttle=jh,u.thru=gr,u.toArray=wa,u.toPairs=Pa,u.toPairsIn=Ca,u.toPath=ug,u.toPlainObject=xa,u.transform=ip,u.unary=td,u.union=Vl,u.unionBy=jl,u.unionWith=th,u.uniq=eh,u.uniqBy=nh,u.uniqWith=rh,u.unset=sp,u.unzip=Fi,u.unzipWith=ia,u.update=up,u.updateWith=ap,u.values=un,u.valuesIn=op,u.without=ih,u.words=Ea,u.wrap=ed,u.xor=sh,u.xorBy=uh,u.xorWith=ah,u.zip=oh,u.zipObject=ch,u.zipObjectDeep=fh,u.zipWith=lh,u.entries=Pa,u.entriesIn=Ca,u.extend=Sa,u.extendWith=Sr,Ji(u,u),u.add=og,u.attempt=Ta,u.camelCase=hp,u.capitalize=Ra,u.ceil=cg,u.clamp=cp,u.clone=rd,u.cloneDeep=sd,u.cloneDeepWith=ud,u.cloneWith=id,u.conformsTo=ad,u.deburr=Ia,u.defaultTo=kp,u.divide=fg,u.endsWith=dp,u.eq=Vt,u.escape=pp,u.escapeRegExp=gp,u.every=Sh,u.find=Ah,u.findIndex=ju,u.findKey=Fd,u.findLast=Ph,u.findLastIndex=ta,u.findLastKey=Md,u.floor=lg,u.forEach=ua,u.forEachRight=aa,u.forIn=$d,u.forInRight=Bd,u.forOwn=kd,u.forOwnRight=Kd,u.get=Ki,u.gt=od,u.gte=cd,u.has=Gd,u.hasIn=qi,u.head=na,u.identity=Rt,u.includes=Th,u.indexOf=Pl,u.inRange=fp,u.invoke=Zd,u.isArguments=$e,u.isArray=M,u.isArrayBuffer=fd,u.isArrayLike=Pt,u.isArrayLikeObject=at,u.isBoolean=ld,u.isBuffer=Pe,u.isDate=hd,u.isElement=dd,u.isEmpty=pd,u.isEqual=gd,u.isEqualWith=_d,u.isError=Bi,u.isFinite=yd,u.isFunction=le,u.isInteger=ga,u.isLength=mr,u.isMap=_a,u.isMatch=vd,u.isMatchWith=wd,u.isNaN=md,u.isNative=xd,u.isNil=bd,u.isNull=Sd,u.isNumber=ya,u.isObject=it,u.isObjectLike=st,u.isPlainObject=Cn,u.isRegExp=ki,u.isSafeInteger=Ad,u.isSet=va,u.isString=xr,u.isSymbol=Dt,u.isTypedArray=sn,u.isUndefined=Pd,u.isWeakMap=Cd,u.isWeakSet=Rd,u.join=Tl,u.kebabCase=_p,u.last=Ht,u.lastIndexOf=Ol,u.lowerCase=yp,u.lowerFirst=vp,u.lt=Id,u.lte=Ed,u.max=hg,u.maxBy=dg,u.mean=pg,u.meanBy=gg,u.min=_g,u.minBy=yg,u.stubArray=Yi,u.stubFalse=Xi,u.stubObject=ng,u.stubString=rg,u.stubTrue=ig,u.multiply=vg,u.nth=Ll,u.noConflict=Zp,u.noop=Zi,u.now=yr,u.pad=wp,u.padEnd=mp,u.padStart=xp,u.parseInt=Sp,u.random=lp,u.reduce=Uh,u.reduceRight=Nh,u.repeat=bp,u.replace=Ap,u.result=ep,u.round=wg,u.runInContext=d,u.sample=Mh,u.size=kh,u.snakeCase=Pp,u.some=Kh,u.sortedIndex=$l,u.sortedIndexBy=Bl,u.sortedIndexOf=kl,u.sortedLastIndex=Kl,u.sortedLastIndexBy=ql,u.sortedLastIndexOf=Hl,u.startCase=Rp,u.startsWith=Ip,u.subtract=mg,u.sum=xg,u.sumBy=Sg,u.template=Ep,u.times=sg,u.toFinite=he,u.toInteger=$,u.toLength=ma,u.toLower=Tp,u.toNumber=Gt,u.toSafeInteger=Td,u.toString=X,u.toUpper=Op,u.trim=Lp,u.trimEnd=Dp,u.trimStart=Wp,u.truncate=Up,u.unescape=Np,u.uniqueId=ag,u.upperCase=Fp,u.upperFirst=Hi,u.each=ua,u.eachRight=aa,u.first=na,Ji(u,function(){var t={};return te(u,function(e,n){V.call(u.prototype,n)||(t[n]=e)}),t}(),{chain:!1}),u.VERSION=h,$t(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){u[t].placeholder=u}),$t(["drop","take"],function(t,e){H.prototype[t]=function(n){n=n===i?1:dt($(n),0);var r=this.__filtered__&&!e?new H(this):this.clone();return r.__filtered__?r.__takeCount__=wt(n,r.__takeCount__):r.__views__.push({size:wt(n,Ft),type:t+(r.__dir__<0?"Right":"")}),r},H.prototype[t+"Right"]=function(n){return this.reverse()[t](n).reverse()}}),$t(["filter","map","takeWhile"],function(t,e){var n=e+1,r=n==qe||n==Dn;H.prototype[t]=function(s){var a=this.clone();return a.__iteratees__.push({iteratee:L(s,3),type:n}),a.__filtered__=a.__filtered__||r,a}}),$t(["head","last"],function(t,e){var n="take"+(e?"Right":"");H.prototype[t]=function(){return this[n](1).value()[0]}}),$t(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");H.prototype[t]=function(){return this.__filtered__?new H(this):this[n](1)}}),H.prototype.compact=function(){return this.filter(Rt)},H.prototype.find=function(t){return this.filter(t).head()},H.prototype.findLast=function(t){return this.reverse().find(t)},H.prototype.invokeMap=K(function(t,e){return typeof t=="function"?new H(this):this.map(function(n){return mn(n,t,e)})}),H.prototype.reject=function(t){return this.filter(wr(L(t)))},H.prototype.slice=function(t,e){t=$(t);var n=this;return n.__filtered__&&(t>0||e<0)?new H(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==i&&(e=$(e),n=e<0?n.dropRight(-e):n.take(e-t)),n)},H.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},H.prototype.toArray=function(){return this.take(Ft)},te(H.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),s=u[r?"take"+(e=="last"?"Right":""):e],a=r||/^find/.test(e);s&&(u.prototype[e]=function(){var c=this.__wrapped__,l=r?[1]:arguments,p=c instanceof H,w=l[0],m=p||M(c),S=function(q){var G=s.apply(u,ve([q],l));return r&&C?G[0]:G};m&&n&&typeof w=="function"&&w.length!=1&&(p=m=!1);var C=this.__chain__,E=!!this.__actions__.length,D=a&&!C,k=p&&!E;if(!a&&m){c=k?c:new H(this);var W=t.apply(c,l);return W.__actions__.push({func:gr,args:[S],thisArg:i}),new kt(W,C)}return D&&k?t.apply(this,l):(W=this.thru(S),D?r?W.value()[0]:W.value():W)})}),$t(["pop","push","shift","sort","splice","unshift"],function(t){var e=kn[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);u.prototype[t]=function(){var s=arguments;if(r&&!this.__chain__){var a=this.value();return e.apply(M(a)?a:[],s)}return this[n](function(c){return e.apply(M(c)?c:[],s)})}}),te(H.prototype,function(t,e){var n=u[e];if(n){var r=n.name+"";V.call(je,r)||(je[r]=[]),je[r].push({name:e,func:n})}}),je[or(i,pe).name]=[{name:"wrapper",func:i}],H.prototype.clone=Uc,H.prototype.reverse=Nc,H.prototype.value=Fc,u.prototype.at=dh,u.prototype.chain=ph,u.prototype.commit=gh,u.prototype.next=_h,u.prototype.plant=vh,u.prototype.reverse=wh,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=mh,u.prototype.first=u.prototype.head,dn&&(u.prototype[dn]=yh),u},Xe=pc();Oe?((Oe.exports=Xe)._=Xe,zr._=Xe):gt._=Xe}).call(In)})(br,br.exports);var Wg=br.exports;const Ug=Dg(Wg);class Ng{constructor(o){O(this,"config");this.config=o}async complete(o,i){var h;await this.persist(o,{...i,success:!0}),(h=this.config.logger)==null||h.debug("Transaction completed:",o)}async fail(o,i){var h;await this.persist(o,{...i,success:!1}),(h=this.config.logger)==null||h.debug("Transaction failed:",{...o,...i})}async persist(o,i){await fetch(`${this.config.apiUrl}/transactions/${o.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Fg{constructor(o,i){O(this,"transaction");O(this,"manager");this.transaction=o,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(o,i){var I;const h=this.transaction.functionCall;if(!h){await this.fail("No function call found");return}const g=h.name,y=h.args,x=o[g];if(!x){await this.fail(`Tool ${g} not found`);return}try{const b=Ug.get(i,"schema.config.parameters.properties",{}),Y=(b&&Object.keys(b).length>0?Object.keys(b):((I=x.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:I[1].split(",").map(U=>U.trim()).filter(Boolean))||[]).map(U=>y[U]),P=await x(...Y);await this.complete(P)}catch(b){await this.fail(`Error executing tool ${g}: ${b}`)}}async complete(o){await this.manager.complete(this.transaction,{success:!0,output:o,error:null})}async fail(o){await this.manager.fail(this.transaction,{success:!1,output:null,error:o})}}class Wa extends En{constructor(i){super();O(this,"status");O(this,"autostart");O(this,"session");O(this,"config");O(this,"notify",!0);O(this,"_tools");O(this,"_toolSchema",{});if(this.config=i,this.status="disconnected",this.autostart=!0,Array.isArray(i.tools)){this._tools={};for(const h of i.tools)h.schema&&h.implementation&&(this._tools[h.schema.name]=h.implementation,this._toolSchema[h.schema.name]=h)}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 h=new Ng(this.config),g=new Fg(i,h);if(this.config.onTransaction)this.config.onTransaction(g);else{const y=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;g.invoke(this._tools,y)}}getTools(){return this._tools}}function Mg(f,o){if(Array.isArray(f))return f;if(typeof f=="object"&&f!==null){const i=o.dev?"localhost:8000":o.baseUrl||"persona.applica.guru/api",h=o.dev?"http":"https",g=o.dev?"ws":"wss",y=Object.keys(f).map(x=>{switch(x){case"rest":return $g(f[x],{baseEndpointProtocol:h,baseEndpoint:i,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger});case"webrtc":return Bg(f[x],{baseWebSocketProtocol:g,baseEndpoint:i,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger});case"websocket":return kg(f[x],{baseWebSocketProtocol:g,baseEndpoint:i,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger});default:throw new Error(`Unknown protocol: ${x}`)}}).filter(x=>x!==null);return o.tools&&y.push(new Wa({apiUrl:`${h}://${i}`,apiKey:o.apiKey,agentId:o.agentId,tools:o.tools,logger:o.logger})),y}throw new Error("Invalid protocols configuration")}function $g(f,o){return f===!0?new ts({apiUrl:`${o.baseEndpointProtocol}://${o.baseEndpoint}`,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger}):typeof f=="object"&&f!==null?new ts(f):null}function Bg(f,o){return f===!0?new ns({webrtcUrl:`${o.baseWebSocketProtocol}://${o.baseEndpoint}/webrtc`,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger}):typeof f=="object"&&f!==null?new ns(f):null}function kg(f,o){return f===!0?new es({webSocketUrl:`${o.baseWebSocketProtocol}://${o.baseEndpoint}/websocket`,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger}):typeof f=="object"&&f!==null?new es(f):null}function Kg(f,o,i,h,g,y,x){return I=>{switch(I.type){case"agent_start":i("running");break;case"agent_end":{const b=I.payload;i("idle"),b.stopReason==="cancelled"?o(B=>[...B,{role:"assistant",type:"text",text:"⏹ Task cancelled",createdAt:new Date,finishReason:"stop",status:{type:"incomplete"}}]):b.stopReason==="error"&&o(B=>[...B,{role:"assistant",type:"text",text:`❌ Error: ${b.errorMessage||"Unknown error"}`,createdAt:new Date,finishReason:"stop",status:{type:"incomplete"}}]);break}case"turn_start":break;case"turn_end":break;case"tool_execution_start":zg(I.payload,f);break;case"tool_execution_update":Jg(I.payload);break;case"tool_execution_end":Zg(I.payload,f);break;case"steer_accepted":y==null||y(I.payload);break;case"steer_processed":x==null||x(I.payload);break;case"message":qg(I.payload,f,o,g);break;case"reasoning":Hg(I.payload,f,o,g);break;case"transaction":Gg(I.payload,f,h);break}}}function qg(f,o,i,h){f.createdAt||(f.createdAt=new Date),f.thought&&(f.type="reasoning"),f.protocol=o.getName(),i(g=>{const y=Be([...g,f]);return h?h(y):y})}function Hg(f,o,i,h){const g={type:"reasoning",text:f.thought,role:"assistant",finishReason:"stop",protocol:o.getName(),createdAt:new Date};i(y=>{const x=Be([...y,g]);return h?h(x):x})}function Gg(f,o,i){i.filter(h=>h!==o).forEach(h=>h.onTransaction(f))}function zg(f,o,i){typeof window<"u"&&window.__PERSONA_DEBUG__&&console.debug(`[${o.getName()}] Tool start: ${f.toolName}`,f.args)}function Jg(f,o){typeof window<"u"&&window.__PERSONA_DEBUG__&&console.debug(`Tool update: ${f.toolCallId}`,f.partialResult)}function Zg(f,o,i){typeof window<"u"&&window.__PERSONA_DEBUG__&&console.debug(`[${o.getName()}] Tool end: ${f.toolCallId}`,f.durationMs?`(${f.durationMs}ms)`:"",f.error?`ERROR: ${f.error}`:"")}function Da(f){return new Promise((o,i)=>{const h=new FileReader;h.readAsDataURL(f),h.onload=()=>{const y=h.result.split(";base64,")[1];o(y)},h.onerror=g=>{i(g)}})}function Yg(f){const o={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 f){const h=o[i.getName()];if(h)return h(i)}return null}function Xg(f,o,i,h,g){return async y=>{const x=y.content.find(A=>A.type==="text"),I=y.attachments&&y.attachments.length>0;if(!x&&!I)throw new Error("Message must contain text or attachments");const b=(x==null?void 0:x.type)==="text"?x.text??"":"";if(b.startsWith("/steer ")&&!I){const A=b.slice(7).trim();if(A)return Qg(f,A,g)}if(!f.some(A=>A.getName()!=="transaction"&&A.status==="connected")){o(A=>{const T={role:"assistant",type:"text",text:"No protocol is connected.",createdAt:new Date,finishReason:"stop"},J=[...A,T];return h?h(J):J});return}const Y={role:"user",type:"text",text:b,createdAt:new Date};o(A=>{const T=Be([...A,Y]);return h?h(T):T}),i("running");const P=f.sort((A,T)=>T.getPriority()-A.getPriority()).find(A=>A.status==="connected"),U=[];if(y.attachments)for(const A of y.attachments)if(A.contentType.startsWith("image/")&&A.file)U.push({role:"user",image:{contentType:A.contentType,content:await Da(A.file)},text:"",type:"text",createdAt:new Date});else if(A.content){const T=A.content.find(ct=>ct.type==="text");T&&"text"in T&&U.push({role:"user",file:{name:A.name,contentType:A.contentType},text:T.text,type:"text",createdAt:new Date});const J=A.content.find(ct=>ct.type==="file");J&&"data"in J&&U.push({role:"user",file:{name:A.name,base64:J.data,contentType:A.contentType},text:"",type:"text",createdAt:new Date})}else A.file&&U.push({role:"user",file:{name:A.name,base64:await Da(A.file),contentType:A.contentType||"application/octet-stream"},text:"",type:"text",createdAt:new Date});b&&U.push({role:"user",text:b,type:"text",createdAt:new Date}),g==null||g.debug("Sending message:",U),await(P==null?void 0:P.sendPacket({type:"request",payload:U}))}}async function Qg(f,o,i){const h=f.filter(g=>g.getName()!=="transaction"&&g.status==="connected");if(h.length===0){i==null||i.warn("No connected protocol available for steer");return}i==null||i.debug("Sending steer command:",o),await Promise.allSettled(h.map(g=>g.sendPacket({type:"command",payload:{command:"steer",arguments:{text:o}}})))}function Vg(f,o,i,h,g,y){return async x=>{var T;if(((T=x.content[0])==null?void 0:T.type)!=="text")throw new Error("Only text messages are supported");const I=f.sort((J,ct)=>ct.getPriority()-J.getPriority()).find(J=>J.status==="connected");if(!I){y==null||y.debug("No protocol available for edit");return}const b=x.parentId;if(!b){y==null||y.debug("No parent ID provided for edit");return}const B=o.findIndex(J=>J.id===b);if(B===-1){y==null||y.debug("Parent message not found:",b);return}const Y=o.slice(0,B+1),P={role:"user",text:x.content[0].text,type:"text",createdAt:new Date},U=Be([...Y,P]);i(g?g(U):U),h("running");const A=[{role:"user",text:x.content[0].text,type:"text",createdAt:new Date}];y==null||y.debug("Sending edited message:",A),await I.sendPacket({type:"request",payload:A})}}function jg(f,o,i,h,g,y){return async(x,I)=>{const b=f.sort((T,J)=>J.getPriority()-T.getPriority()).find(T=>T.status==="connected");if(!b){y==null||y.debug("No protocol available for reload");return}const B=I.parentId??x;if(!B){y==null||y.debug("No parent ID provided for reload");return}const Y=o.findIndex(T=>T.id===B);if(Y===-1){y==null||y.debug("Parent message not found:",B);return}const P=o[Y];i(T=>{const J=T.slice(0,Y+1);return g?g(J):J});let U;if(P.role==="assistant"||P.role==="function"){for(let T=Y-1;T>=0;T--)if(o[T].role==="user"){U=o[T];break}}else P.role==="user"&&(U=P);if(!U){y==null||y.debug("No user message found to regenerate from");return}h("running");const A=[];U.image&&A.push({role:"user",image:U.image,text:"",type:"text",createdAt:new Date}),A.push({role:"user",text:U.text,type:"text",createdAt:new Date}),y==null||y.debug("Regenerating message with config:",{actualParentId:B,sourceId:I.sourceId,custom:I.runConfig.custom}),await b.sendPacket({type:"request",payload:A})}}function t_(f,o,i){return()=>(o("cancelling"),i==null||i.debug("Sending cancel command to all connected protocols"),f.forEach(h=>{h.status==="connected"&&h.sendPacket({type:"command",payload:{command:"cancel",arguments:{}}}).catch(g=>{i==null||i.error("Failed to send cancel command:",g)})}),Promise.resolve())}const Ce=z.createContext(void 0);function e_(){const f=z.useContext(Ce);if(!f)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return f}function Ua(f){const o=z.useContext(Ce);if(!o)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=o.protocols.find(g=>g.getName()===f);if(!i)return null;const h=o.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:h||i.status}}function n_(){const f=z.useContext(Ce);if(!f)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return Yg(f.protocols)}function r_(){return Ua("webrtc")}function i_(){const f=z.useContext(Ce);if(!f)throw new Error("usePersonaRenameThread must be used within a PersonaRuntimeProvider");return f.renameThread}function s_(){const f=z.useContext(Ce);if(!f)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return f.getMessages()}function u_(){const f=z.useContext(Ce);if(!f)throw new Error("useAgentState must be used within a PersonaRuntimeProvider");return f.agentState}function a_(){const f=z.useContext(Ce);if(!f)throw new Error("useSteerAgent must be used within a PersonaRuntimeProvider");return f.steerAgent}const Qi="DEFAULT_THREAD_ID";function o_(){const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let o="";for(let i=0;i<8;i++)o+=f.charAt(Math.floor(Math.random()*f.length));return o}function c_(f,o,i,h,g,y,x,I,b,B,Y){return{threadId:f,threads:o.filter(P=>P.status==="regular").map(P=>({id:P.threadId,threadId:P.threadId,title:P.title||`Session ${P.threadId}`,status:P.status})),archivedThreads:o.filter(P=>P.status==="archived").map(P=>({id:P.threadId,threadId:P.threadId,title:P.title||`Archived Chat ${P.threadId}`,status:P.status})),onSwitchToNewThread:()=>{const P=o_(),U={threadId:P,status:"regular",title:`Session ${P}`};h(A=>[U,...A]),i(P),y==null||y(P)},onSwitchToThread:P=>{i(P),x==null||x(P)},onArchive:P=>{h(U=>U.map(A=>A.threadId===P?{...A,status:"archived"}:A)),I==null||I(P),P!==Qi&&g.archive(P)},onUnarchive:P=>{h(U=>U.map(A=>A.threadId===P?{...A,status:"regular"}:A)),b==null||b(P)},onRename:(P,U)=>{h(A=>A.map(T=>T.threadId===P?{...T,title:U}:T)),Y==null||Y(P,U),P!==Qi&&g.rename(P,U)},onDelete:async P=>{if(h(U=>U.filter(A=>A.threadId!==P)),f===P){const U=o.filter(A=>A.threadId!==P&&A.status==="regular");U.length>0&&i(U[0].threadId)}B==null||B(P),P!==Qi&&await g.delete(P)}}}class Na{constructor(o){O(this,"endpoint");O(this,"apiKey");O(this,"pageSize");O(this,"logger");this.endpoint=o.endpoint.replace(/\/$/,""),this.apiKey=o.apiKey,this.pageSize=o.pageSize??200,this.logger=o.logger}buildHeaders(){const o={"Content-Type":"application/json"};return this.apiKey&&(o["x-persona-apikey"]=this.apiKey),o}async sync(o){var h,g;if(!o)return[];const i=`${this.endpoint}/sessions/${encodeURIComponent(String(o))}/messages?page=1&size=${this.pageSize}`;try{const y=await fetch(i,{method:"GET",headers:this.buildHeaders()});if(!y.ok)return(h=this.logger)==null||h.warn("PersonaSessionStorage: failed to fetch messages",y.status,await y.text()),[];const x=await y.json();return Array.isArray(x.items)?x.items.map(b=>({id:b.id??b.messageId??void 0,protocol:b.protocol,thought:b.thought,text:b.text??"",image:b.image,type:b.type??"text",role:b.role??"assistant",file:b.file,sources:b.sources,sessionId:b.sessionId??o,finishReason:b.finishReason,functionCalls:b.functionCalls,functionResponse:b.functionResponse,status:b.status,createdAt:b.createdAt?new Date(b.createdAt):void 0,metadata:b.metadata})):[]}catch(y){return(g=this.logger)==null||g.warn("PersonaSessionStorage: error fetching messages",y),[]}}async archive(o){return this._visiblility(o,"archived")}async unarchive(o){return this._visiblility(o,"active")}async delete(o){return this._visiblility(o,"deleted")}async _visiblility(o,i){var x;if(!o)return;const h=`${this.endpoint}/sessions/${encodeURIComponent(String(o))}/visibility`,g=JSON.stringify({visibility:i}),y=await fetch(h,{method:"PUT",headers:this.buildHeaders(),body:g});if(!y.ok){const I=await y.text();throw(x=this.logger)==null||x.warn("PersonaSessionStorage: failed to set session visibility",y.status,I),new Error(`Failed to set session visibility: ${y.status}`)}}async rename(o,i){var y;if(!o)return;const h=`${this.endpoint}/sessions/${encodeURIComponent(String(o))}/name`,g=await fetch(h,{method:"PUT",headers:this.buildHeaders(),body:JSON.stringify({name:i})});if(!g.ok){const x=await g.text();throw(y=this.logger)==null||y.warn("PersonaSessionStorage: failed to rename session",g.status,x),new Error(`Failed to rename session: ${g.status}`)}}async clearAll(){return Promise.reject(new Error("PersonaAPIMessageStorage: clearAll not supported"))}async list(o,i){const h=new URLSearchParams({page:"1",size:"100",visibility:"active"});i&&h.set("userId",i),o&&h.set("agentId",o);const g=`${this.endpoint}/sessions?${h.toString()}`;try{const y=await fetch(g,{method:"GET",headers:this.buildHeaders()});if(!y.ok)return[];const x=await y.json();return Array.isArray(x.items)?x.items.map(b=>({threadId:b.code||b.id,title:b.name||`Session ${b.code||b.id}`,status:b.status==="archived"?"archived":"regular"})):[]}catch{return[]}}}function f_({dev:f=!1,baseUrl:o,protocols:i,logger:h,children:g,session:y="new",transformMessages:x,threads:I=!1,sessionStorage:b,onThreadCreate:B,onThreadSwitch:Y,onThreadRename:P,onThreadArchive:U,onThreadUnarchive:A,onThreadDelete:T,enableAttachments:J=!1,enableSteer:ct=!1,onSteerAccepted:pe,onSteerProcessed:Tn,...Q}){const[re,yt]=z.useState("idle"),[It,lt]=z.useState([]),[Re,an]=z.useState(new Map),On=z.useRef(!1),Ke=z.useRef(!1),zt=z.useMemo(()=>b||new Na({apiKey:Q.apiKey,endpoint:o||"https://persona.applica.guru/api"}),[b,o,Q.apiKey]),[Ln,qe]=z.useState([]),[Et,Dn]=z.useState(""),Nt=z.useRef(typeof y=="string"?y:"new"),Jt=z.useRef(!1);z.useEffect(()=>{!I||Jt.current||(Jt.current=!0,zt.list(Q.agentId,Q.userId).then(N=>{(N==null?void 0:N.length)>0&&(qe(N),Dn(N[0].threadId))}).catch(N=>h==null?void 0:h.error("Failed to load threads:",N)))},[I,zt,Q.agentId,Q.userId,h]);const ft=z.useMemo(()=>Mg(i,{dev:f||!1,baseUrl:o,apiKey:Q.apiKey,agentId:Q.agentId,userId:Q.userId,tools:Q.tools,logger:h}),[i,f,o,Q.apiKey,Q.agentId,Q.userId,Q.tools,h]);z.useEffect(()=>{On.current||(On.current=!0,h==null||h.debug("Setting up protocols:",ft.map(N=>N.getName())),ft.forEach(N=>{N.setSession(Nt.current),N.clearListeners(),N.addStatusChangeListener(tt=>{h==null||h.debug(`${N.getName()} status: ${tt}`),an(vt=>{const ut=new Map(vt);return ut.set(N.getName(),tt),ut}),tt==="connected"&&!Ke.current&&(Q.context&&N.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:Q.context}}).catch(()=>{}),Q.tools&&Array.isArray(Q.tools)&&N.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:Q.tools.map(vt=>vt.schema)}}}).catch(()=>{}))}),N.addPacketListener(Kg(N,lt,yt,ft,x,pe,Tn)),N.autostart&&N.status==="disconnected"&&(h==null||h.debug(`Auto-connecting protocol: ${N.getName()}`),N.connect(Nt.current).catch(()=>{}),yt("idle"))}))},[]),z.useEffect(()=>{I||!y||y==="new"||zt.sync(y).then(N=>{if(N.length>0){const tt=Be(N);lt(x?x(tt):tt),h==null||h.debug(`Loaded ${N.length} messages for session ${y}`)}}).catch(N=>{h==null||h.error("Failed to load session messages:",N)})},[]),z.useEffect(()=>{if(!I||!Et){lt([]);return}if(Ke.current||Et===Nt.current)return;Ke.current=!0,h==null||h.info("Switching to thread:",Et),(async()=>{try{const tt=ft.filter(Zt=>Zt.status==="connected");tt.length>0&&await Promise.allSettled(tt.map(Zt=>Zt.disconnect())),Nt.current=Et,await Promise.allSettled(ft.map(Zt=>Zt.setSession(Et)));const vt=await zt.sync(Et),ut=Be(vt);lt(x?x(ut):ut),h==null||h.debug(`Loaded ${vt.length} messages for thread ${Et}`);const _e=ft.filter(Zt=>Zt.autostart);_e.length>0&&await Promise.allSettled(_e.map(Zt=>Zt.connect(Et)))}catch(tt){h==null||h.error("Failed to switch thread:",tt),lt([])}finally{Ke.current=!1}})()},[Et,I,ft,zt,x,h]);const He=z.useCallback(Xg(ft,lt,yt,x,h),[ft,x,h]),Ft=z.useCallback(Vg(ft,It,lt,yt,x,h),[ft,It,x,h]),Pr=z.useCallback(jg(ft,It,lt,yt,x,h),[ft,It,x,h]),Cr=z.useCallback(t_(ft,yt,h),[ft,h]),Rr=z.useCallback(N=>{const tt=Be([...N]);lt(x?x(tt):tt)},[x]),ge=z.useCallback(()=>It,[It]),Ie=z.useMemo(()=>{if(I)return c_(Et,Ln,Dn,qe,zt,B,Y,U,A,T,P)},[I,Et,Ln,zt,B,Y,U,A,T,P,h]),Ir=re==="running"||re==="cancelling",Ee=Rn.useExternalStoreRuntime({isRunning:Ir,messages:It,convertMessage:Og,setMessages:Rr,onNew:He,onEdit:Ft,onCancel:Cr,onReload:Pr,adapters:{...J?{attachments:new Rn.CompositeAttachmentAdapter([new Rn.SimpleImageAttachmentAdapter,new Rn.SimpleTextAttachmentAdapter,new Cg])}:{},...Ie?{threadList:Ie}:{}}}),Te=z.useCallback((N,tt)=>{qe(vt=>vt.map(ut=>ut.threadId===N?{...ut,title:tt}:ut)),P==null||P(N,tt),zt.rename(N,tt)},[zt,P]),Er=z.useCallback(async N=>{const tt=ft.filter(vt=>vt.getName()!=="transaction"&&vt.status==="connected");if(tt.length===0){h==null||h.warn("No connected protocol available for steer");return}h==null||h.debug("Sending steer command:",N),await Promise.allSettled(tt.map(vt=>vt.sendPacket({type:"command",payload:{command:"steer",arguments:{text:N}}})))},[ft,h]);return Vi.jsx(Ce.Provider,{value:{protocols:ft,protocolsStatus:Re,agentState:re,getMessages:ge,renameThread:Te,steerAgent:Er},children:Vi.jsx(Rn.AssistantRuntimeProvider,{runtime:Ee,children:g})})}function l_({children:f,...o}){return Vi.jsx(f_,{...o,children:f})}class h_{constructor(){O(this,"prefix","[Persona]")}log(o,...i){console.log(`${this.prefix} - ${o}`,...i)}info(o,...i){console.info(`${this.prefix} - ${o}`,...i)}warn(o,...i){console.warn(`${this.prefix} - ${o}`,...i)}error(o,...i){console.error(`${this.prefix} - ${o}`,...i)}debug(o,...i){console.debug(`${this.prefix} - ${o}`,...i)}}function ke(f,o,i){return{type:f,description:o,...i}}function Fa(f){const o=Object.entries(f.parameters).filter(([i,h])=>h.required).map(([i])=>i);return{type:"local",name:f.name,description:f.description,config:{timeout:f.timeout||60,parameters:{type:"object",title:f.title||`${f.name} parameters`,required:o,properties:f.parameters},output:{type:"object",title:`${f.name} output`,properties:f.output}}}}function Ar(f){return{schema:Fa(f),implementation:f.implementation}}function Ma(f,o,i,h,g,y){const x={name:f,description:o,title:y==null?void 0:y.title,timeout:y==null?void 0:y.timeout,parameters:h,output:g,implementation:i};return Ar(x)}const d_=Ma("sum","Sum two numbers",function(o,i){return{result:o+i}},{a:ke("number","First number to sum",{required:!0}),b:ke("number","Second number to sum",{required:!0})},{result:ke("number","Sum of two numbers")}),p_=Ar({name:"navigate_to",description:"Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",title:"Sum two numbers",timeout:60,parameters:{a:ke("number","First number to sum"),b:ke("number","Seconth number to sum")},output:{result:ke("number","Sum of two numbers")},implementation:function(o,i){return{result:o+i}}});function g_(f){const o=[],i={};return f.forEach(h=>{const{schema:g,implementation:y}=Ar(h);o.push(g),i[h.name]=y}),{schemas:o,implementations:i}}function __(f,o){const{required:i,properties:h}=o.config.parameters;for(const g of i)if(!(g in f))throw new Error(`Missing required parameter: ${g}`);for(const[g,y]of Object.entries(f)){const x=h[g];if(x){if(x.type==="number"&&typeof y!="number")throw new Error(`Parameter ${g} should be a number`);if(x.type==="string"&&typeof y!="string")throw new Error(`Parameter ${g} should be a string`);if(x.type==="boolean"&&typeof y!="boolean")throw new Error(`Parameter ${g} should be a boolean`)}}return!0}class y_{constructor(o){O(this,"baseUrl");O(this,"apiKey");this.baseUrl=o.baseUrl.replace(/\/$/,""),this.apiKey=o.apiKey}async request(o,i){const h=await fetch(`${this.baseUrl}${o}`,{...i,headers:{"Content-Type":"application/json","x-persona-apikey":this.apiKey,...(i==null?void 0:i.headers)??{}}});if(!h.ok)throw new Error(await h.text());return await h.json()}async getSubscription(o){return this.request(`/projects/${o}/subscription`)}async changeSubscriptionPlan(o,i){return this.request(`/projects/${o}/subscription/actions/change-plan`,{method:"POST",body:JSON.stringify({toPlanType:i})})}async addSubscriptionCredits(o,i){return this.request(`/projects/${o}/subscription/actions/add-credits`,{method:"POST",body:JSON.stringify({credits:i})})}}exports.PersonaConsoleLogger=h_;exports.PersonaProtocolBase=En;exports.PersonaRESTProtocol=ts;exports.PersonaRuntimeProvider=l_;exports.PersonaSessionStorage=Na;exports.PersonaTransactionProtocol=Wa;exports.PersonaWebRTCProtocol=ns;exports.PersonaWebSocketProtocol=es;exports.ProjectsApi=y_;exports.createParameter=ke;exports.createTool=Ar;exports.createToolFromFunction=Ma;exports.createToolRegistry=g_;exports.generateToolSchema=Fa;exports.navigateToToolExample=p_;exports.sumTool=d_;exports.useAgentState=u_;exports.usePersonaRenameThread=i_;exports.usePersonaRuntime=e_;exports.usePersonaRuntimeEndpoint=n_;exports.usePersonaRuntimeMessages=s_;exports.usePersonaRuntimeProtocol=Ua;exports.usePersonaRuntimeWebRTCProtocol=r_;exports.useSteerAgent=a_;exports.validateToolParameters=__;
|
|
28
28
|
//# sourceMappingURL=bundle.cjs.js.map
|