@applica-software-guru/persona-sdk 0.1.79 → 0.1.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var Sd=Object.defineProperty;var Ad=(y,g,i)=>g in y?Sd(y,g,{enumerable:!0,configurable:!0,writable:!0,value:i}):y[g]=i;var E=(y,g,i)=>Ad(y,typeof g!="symbol"?g+"":g,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const vn=require("react"),vr=require("@assistant-ui/react");var me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Cd(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var bo={exports:{}},ye={};/**
1
+ "use strict";var sb=Object.defineProperty;var ib=(n,i,r)=>i in n?sb(n,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[i]=r;var S=(n,i,r)=>ib(n,typeof i!="symbol"?i+"":i,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react");var $n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Bu={exports:{}},qn={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,31 +6,35 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Ao;function bd(){if(Ao)return ye;Ao=1;var y=Symbol.for("react.transitional.element"),g=Symbol.for("react.fragment");function i(w,m,C){var b=null;if(C!==void 0&&(b=""+C),m.key!==void 0&&(b=""+m.key),"key"in m){C={};for(var I in m)I!=="key"&&(C[I]=m[I])}else C=m;return m=C.ref,{$$typeof:y,type:w,key:b,ref:m!==void 0?m:null,props:C}}return ye.Fragment=g,ye.jsx=i,ye.jsxs=i,ye}bo.exports=bd();var qi=bo.exports;function Rd(y){return y.filter(g=>g.finishReason==="stop"?g.text!==null&&g.text.trim()!=="":!0)}function Co(y){const g=[];let i=null;for(const m of y)m.type!=="transaction"&&(m.functionCalls?(i&&g.push(i),g.push(m),i=null):m.functionResponse?g[g.length-1]={...g[g.length-1],functionResponse:m.functionResponse}:i&&m.type===i.type&&m.protocol===i.protocol&&i.role===m.role?(i.text+=m.file?"":m.text,i.file=i.file||m.file):(i&&g.push(i),i={...m}));return i&&g.push(i),Rd(g)}function Td(y){var i;const g=y.file?[{type:"file",data:y.file.url,mimeType:y.file.contentType}]:[];return y.role==="function"?{id:y.id,role:"assistant",status:(y==null?void 0:y.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((i=y.functionCalls)==null?void 0:i.map(w=>{var m;return{type:"tool-call",toolName:w.name,toolCallId:w.id,args:w.args,result:(m=y.functionResponse)==null?void 0:m.result}}))??[]}:{id:y.id,role:y.role,content:y.type==="reasoning"?[{type:"reasoning",text:y.text},...g]:[{type:"text",text:y.text},...g]}}class xe{constructor(){E(this,"statusChangeCallbacks",[]);E(this,"messageCallbacks",[])}addStatusChangeListener(g){this.statusChangeCallbacks.push(g)}addPacketListener(g){this.messageCallbacks.push(g)}async syncSession(g){this.session=g}async notifyPacket(g){this.messageCallbacks.forEach(i=>i(g))}async notifyPackets(g){g.forEach(i=>{this.messageCallbacks.forEach(w=>w(i))})}async setSession(g){this.session=g}async setStatus(g){const i=this.status!==g;this.status=g,i&&this.statusChangeCallbacks.forEach(w=>w(g))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(g){}}class Gi extends xe{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 q,tn,Cn,en,bn;const{apiUrl:w,apiKey:m,agentId:C}=this.config,b=this.session??"new";if(i.type==="command"&&((q=i==null?void 0:i.payload)==null?void 0:q.command)=="set_initial_context"){this.context=(tn=i==null?void 0:i.payload)==null?void 0:tn.arguments;return}else if(i.type==="command"&&((Cn=i==null?void 0:i.payload)==null?void 0:Cn.command)=="set_local_tools"){const hn=(en=i==null?void 0:i.payload)==null?void 0:en.arguments.tools;(hn==null?void 0:hn.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const I=i.payload;try{const Rn=await(await fetch(`${w}/sessions/${b}/messages`,{body:JSON.stringify({agentId:C,userMessage:I,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":m}})).json();this.notifyPackets(Rn.response.messages.map(ct=>({type:"message",payload:ct})))}catch(hn){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(bn=this.config.logger)==null||bn.error("Error sending packet:",hn)}}}class ki extends xe{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"webSocket");this.config=i,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(i){var w;(w=this.config.logger)==null||w.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var I;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const w=i||this.session||"new";(I=this.config.logger)==null||I.debug("Connecting to WebSocket with sessionId:",w);const m=encodeURIComponent(this.config.apiKey),C=this.config.agentId,b=`${this.config.webSocketUrl}?sessionCode=${w}&agentId=${C}&apiKey=${m}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(b),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",q=>{const tn=JSON.parse(q.data);this.notifyPacket(tn)}),this.webSocket.addEventListener("close",q=>{var tn;this.setStatus("disconnected"),this.webSocket=null,q.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(tn=this.config.logger)==null||tn.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var q;this.setStatus("disconnected"),this.webSocket=null,(q=this.config.logger)==null||q.error("WebSocket connection error")}),Promise.resolve(w)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(i){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(i)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class Pd{constructor(g){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=g}async connect(g){var w;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(m){(w=this.config.logger)==null||w.error("Error accessing microphone:",m);return}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers||[{urls:"stun:34.38.108.251:3478"},{urls:"turn:34.38.108.251:3478",username:"webrtc",credential:"webrtc"}]}),this.localStream.getTracks().forEach(m=>{this.pc.addTrack(m,this.localStream)}),this.pc.ontrack=m=>{m.streams[0].getTracks().forEach(b=>{this.remoteStream.addTrack(b)}),this.audioCtx||this._startAnalyzers();const C=new Audio;C.srcObject=this.remoteStream,C.play().catch(b=>{var I;(I=this.config.logger)==null||I.error("Error playing remote audio:",b)})},this.pc.onicecandidate=m=>{var C;m.candidate&&((C=this.ws)==null?void 0:C.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:m.candidate}}))},this.pc.ondatachannel=m=>{const C=m.channel;C.onmessage=b=>{this.messageCallbacks.forEach(I=>{I(b)})},C.onopen=()=>{var b;for(;this.queuedMessages.length>0;){const I=this.queuedMessages.shift();I&&(C.send(JSON.stringify(I)),(b=this.config.logger)==null||b.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,q;const m=await this.pc.createOffer();await this.pc.setLocalDescription(m);const C={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:g};(I=this.config.logger)==null||I.debug("Opening connection to WebRTC server: ",C);const b={type:"OFFER",src:((q=crypto.randomUUID)==null?void 0:q.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:m.sdp,type:m.type},connectionId:(Date.now()%1e6).toString(),metadata:C}};this.ws.send(JSON.stringify(b))},this.ws.onmessage=async m=>{var b;const C=JSON.parse(m.data);if(C.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(C.payload.sdp));else if(C.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(C.payload.candidate))}catch(I){(b=this.config.logger)==null||b.error("Error adding ICE candidate:",I)}},this.ws.onclose=m=>{m.code!==1e3&&this.errorCallbacks.forEach(C=>{C("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var g;this.isConnected&&(this.isConnected=!1,((g=this.ws)==null?void 0:g.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(g){this.visualizerCallbacks.push(g)}addMessageCallback(g){this.messageCallbacks.push(g)}addErrorCallback(g){this.errorCallbacks.push(g)}createDataChannel(g="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(g),this.dataChannel.onopen=()=>{var i,w;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const m=this.queuedMessages.shift();m&&(this.dataChannel.send(JSON.stringify(m)),(w=this.config.logger)==null||w.info("Sent queued message:",m))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(w=>{w(i)})})}sendPacket(g){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(g);return}this.dataChannel.send(JSON.stringify(g)),(i=this.config.logger)==null||i.info("Sent message:",g)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const g=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,g.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const w=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const m=new Uint8Array(this.localAnalyser.frequencyBinCount),C=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(m),this.remoteAnalyser.getByteFrequencyData(C);const b=m.reduce((q,tn)=>q+tn,0)/m.length,I=C.reduce((q,tn)=>q+tn,0)/C.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(q=>{q({localAmplitude:b,remoteAmplitude:I})}),this.analyzerFrame=requestAnimationFrame(w)};this.analyzerFrame=requestAnimationFrame(w)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class zi extends xe{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 Pd(i),this.webRTCClient.addMessageCallback(w=>{const m=JSON.parse(w.data);this.notifyPacket(m)}),this.webRTCClient.addErrorCallback(w=>{var m;(m=this.config.logger)==null||m.error("WebRTC error:",w),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:w}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(i){super.syncSession(i),this.status==="connected"&&(await this.disconnect(),await this.connect(i))}async connect(i){var w;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(w=this.config.logger)==null||w.debug("Connecting to WebRTC with sessionId:",this.session),await this.webRTCClient.connect(this.session),this.setStatus("connected"),await this.webRTCClient.createDataChannel(),this.session)}async disconnect(){var i,w,m;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(m=(w=this.config)==null?void 0:w.logger)==null||m.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var wr={exports:{}};/**
9
+ */var mu;function ob(){if(mu)return qn;mu=1;var n=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function r(a,h,f){var p=null;if(f!==void 0&&(p=""+f),h.key!==void 0&&(p=""+h.key),"key"in h){f={};for(var m in h)m!=="key"&&(f[m]=h[m])}else f=h;return h=f.ref,{$$typeof:n,type:a,key:p,ref:h!==void 0?h:null,props:f}}return qn.Fragment=i,qn.jsx=r,qn.jsxs=r,qn}Bu.exports=ob();var Pe=Bu.exports,ab=n=>Array.from(n).map(r=>r.getModelContext()).sort((r,a)=>(a.priority??0)-(r.priority??0)).reduce((r,a)=>{var h;if(a.system&&(r.system?r.system+=`
10
+
11
+ ${a.system}`:r.system=a.system),a.tools)for(const[f,p]of Object.entries(a.tools)){const m=(h=r.tools)==null?void 0:h[f];if(m&&m!==p)throw new Error(`You tried to define a tool with the name ${f}, but it already exists.`);r.tools||(r.tools={}),r.tools[f]=p}return a.config&&(r.config={...r.config,...a.config}),a.callSettings&&(r.callSettings={...r.callSettings,...a.callSettings}),r},{}),ku=class{constructor(){S(this,"_providers",new Set);S(this,"_subscribers",new Set)}getModelContext(){return ab(this._providers)}registerModelContextProvider(n){var r;this._providers.add(n);const i=(r=n.subscribe)==null?void 0:r.call(n,()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(n),i==null||i(),this.notifySubscribers()}}notifySubscribers(){for(const n of this._subscribers)n()}subscribe(n){return this._subscribers.add(n),()=>this._subscribers.delete(n)}},ub=class{constructor(){S(this,"_contextProvider",new ku)}registerModelContextProvider(n){return this._contextProvider.registerModelContextProvider(n)}getModelContextProvider(){return this._contextProvider}},cb=class{constructor(){S(this,"_subscribers",new Set)}subscribe(n){return this._subscribers.add(n),()=>this._subscribers.delete(n)}waitForUpdate(){return new Promise(n=>{const i=this.subscribe(()=>{i(),n()})})}_notifySubscribers(){const n=[];for(const i of this._subscribers)try{i()}catch(r){n.push(r)}if(n.length>0)throw n.length===1?n[0]:new AggregateError(n)}},hb=n=>n.status.type==="complete",Du=class extends cb{constructor(){super(...arguments);S(this,"isEditing",!0);S(this,"_attachments",[]);S(this,"_text","");S(this,"_role","user");S(this,"_runConfig",{});S(this,"_eventSubscribers",new Map)}get attachmentAccept(){var i;return((i=this.getAttachmentAdapter())==null?void 0:i.accept)??"*"}get attachments(){return this._attachments}setAttachments(i){this._attachments=i,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}get text(){return this._text}get role(){return this._role}get runConfig(){return this._runConfig}setText(i){this._text!==i&&(this._text=i,this._notifySubscribers())}setRole(i){this._role!==i&&(this._role=i,this._notifySubscribers())}setRunConfig(i){this._runConfig!==i&&(this._runConfig=i,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}async _onClearAttachments(){const i=this.getAttachmentAdapter();i&&await Promise.all(this._attachments.map(r=>i.remove(r)))}async reset(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0)return;this._role="user",this._runConfig={};const i=this._onClearAttachments();this._emptyTextAndAttachments(),await i}async clearAttachments(){const i=this._onClearAttachments();this.setAttachments([]),await i}async send(){const i=this.getAttachmentAdapter(),r=i&&this.attachments.length>0?Promise.all(this.attachments.map(async f=>hb(f)?f:await i.send(f))):[],a=this.text;this._emptyTextAndAttachments();const h={createdAt:new Date,role:this.role,content:a?[{type:"text",text:a}]:[],attachments:await r,runConfig:this.runConfig,metadata:{custom:{}}};this.handleSend(h),this._notifyEventSubscribers("send")}cancel(){this.handleCancel()}async addAttachment(i){const r=this.getAttachmentAdapter();if(!r)throw new Error("Attachments are not supported");const a=f=>{const p=this._attachments.findIndex(m=>m.id===f.id);p!==-1?this._attachments=[...this._attachments.slice(0,p),f,...this._attachments.slice(p+1)]:this._attachments=[...this._attachments,f],this._notifySubscribers()},h=r.add({file:i});if(Symbol.asyncIterator in h)for await(const f of h)a(f);else a(await h);this._notifyEventSubscribers("attachment-add"),this._notifySubscribers()}async removeAttachment(i){const r=this.getAttachmentAdapter();if(!r)throw new Error("Attachments are not supported");const a=this._attachments.findIndex(f=>f.id===i);if(a===-1)throw new Error("Attachment not found");const h=this._attachments[a];await r.remove(h),this._attachments=[...this._attachments.slice(0,a),...this._attachments.slice(a+1)],this._notifySubscribers()}_notifyEventSubscribers(i){const r=this._eventSubscribers.get(i);if(r)for(const a of r)a()}unstable_on(i,r){const a=this._eventSubscribers.get(i);return a?a.add(r):this._eventSubscribers.set(i,new Set([r])),()=>{const h=this._eventSubscribers.get(i);h&&h.delete(r)}}},lb=class extends Du{constructor(i){super();S(this,"_canCancel",!1);this.runtime=i,this.connect()}get canCancel(){return this._canCancel}get attachments(){return super.attachments}getAttachmentAdapter(){var i;return(i=this.runtime.adapters)==null?void 0:i.attachments}connect(){return this.runtime.subscribe(()=>{this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,this._notifySubscribers())})}async handleSend(i){var r;this.runtime.append({...i,parentId:((r=this.runtime.messages.at(-1))==null?void 0:r.id)??null,sourceId:null})}async handleCancel(){this.runtime.cancelRun()}};let fb=(n,i=21)=>(r=i)=>{let a="",h=r|0;for(;h--;)a+=n[Math.random()*n.length|0];return a};var Li=fb("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),db="__optimistic__",pb=()=>`${db}${Li()}`,bn=Symbol("autoStatus"),gb=Object.freeze(Object.assign({type:"running"},{[bn]:!0})),_b=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[bn]:!0}));Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[bn]:!0}));Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[bn]:!0}));var bb=n=>n[bn]===!0,Nu=(n,i,r,a,h)=>n&&h?Object.assign({type:"incomplete",reason:"error",error:h},{[bn]:!0}):n&&i?gb:_b,mn={exports:{}};const mb=typeof Buffer<"u",vu=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,wu=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Fu(n,i,r){r==null&&i!==null&&typeof i=="object"&&(r=i,i=void 0),mb&&Buffer.isBuffer(n)&&(n=n.toString()),n&&n.charCodeAt(0)===65279&&(n=n.slice(1));const a=JSON.parse(n,i);if(a===null||typeof a!="object")return a;const h=r&&r.protoAction||"error",f=r&&r.constructorAction||"error";if(h==="ignore"&&f==="ignore")return a;if(h!=="ignore"&&f!=="ignore"){if(vu.test(n)===!1&&wu.test(n)===!1)return a}else if(h!=="ignore"&&f==="ignore"){if(vu.test(n)===!1)return a}else if(wu.test(n)===!1)return a;return Uu(a,{protoAction:h,constructorAction:f,safe:r&&r.safe})}function Uu(n,{protoAction:i="error",constructorAction:r="error",safe:a}={}){let h=[n];for(;h.length;){const f=h;h=[];for(const p of f){if(i!=="ignore"&&Object.prototype.hasOwnProperty.call(p,"__proto__")){if(a===!0)return null;if(i==="error")throw new SyntaxError("Object contains forbidden prototype property");delete p.__proto__}if(r!=="ignore"&&Object.prototype.hasOwnProperty.call(p,"constructor")&&p.constructor!==null&&typeof p.constructor=="object"&&Object.prototype.hasOwnProperty.call(p.constructor,"prototype")){if(a===!0)return null;if(r==="error")throw new SyntaxError("Object contains forbidden prototype property");delete p.constructor}for(const m in p){const w=p[m];w&&typeof w=="object"&&h.push(w)}}}return n}function Bi(n,i,r){const{stackTraceLimit:a}=Error;Error.stackTraceLimit=0;try{return Fu(n,i,r)}finally{Error.stackTraceLimit=a}}function vb(n,i){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return Fu(n,i,{safe:!0})}catch{return}finally{Error.stackTraceLimit=r}}mn.exports=Bi;mn.exports.default=Bi;mn.exports.parse=Bi;mn.exports.safeParse=vb;mn.exports.scan=Uu;var wb=mn.exports;const yu=Lu(wb);function yb(n){const i=["ROOT"];let r=-1,a=null;const h=[];let f;function p(){f!==void 0&&(h.push(JSON.parse('"'+f+'"')),f=void 0)}function m(C,A,R){switch(C){case'"':{r=A,i.pop(),i.push(R),i.push("INSIDE_STRING"),p();break}case"f":case"t":case"n":{r=A,a=A,i.pop(),i.push(R),i.push("INSIDE_LITERAL");break}case"-":{i.pop(),i.push(R),i.push("INSIDE_NUMBER"),p();break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=A,i.pop(),i.push(R),i.push("INSIDE_NUMBER"),p();break}case"{":{r=A,i.pop(),i.push(R),i.push("INSIDE_OBJECT_START"),p();break}case"[":{r=A,i.pop(),i.push(R),i.push("INSIDE_ARRAY_START"),p();break}}}function w(C,A){switch(C){case",":{i.pop(),i.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=A,i.pop(),f=h.pop();break}}}function I(C,A){switch(C){case",":{i.pop(),i.push("INSIDE_ARRAY_AFTER_COMMA"),f=(Number(f)+1).toString();break}case"]":{r=A,i.pop(),f=h.pop();break}}}for(let C=0;C<n.length;C++){const A=n[C];switch(i[i.length-1]){case"ROOT":m(A,C,"FINISH");break;case"INSIDE_OBJECT_START":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_KEY"),f="";break}case"}":{r=C,i.pop(),f=h.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_KEY"),f="";break}}break}case"INSIDE_OBJECT_KEY":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_AFTER_KEY");break}case"\\":{i.push("INSIDE_STRING_ESCAPE"),f+=A;break}default:{f+=A;break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(A){case":":{i.pop(),i.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{m(A,C,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{w(A,C);break}case"INSIDE_STRING":{switch(A){case'"':{i.pop(),r=C,f=h.pop();break}case"\\":{i.push("INSIDE_STRING_ESCAPE");break}default:r=C}break}case"INSIDE_ARRAY_START":{switch(A){case"]":{r=C,i.pop(),f=h.pop();break}default:{r=C,f="0",m(A,C,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(A){case",":{i.pop(),i.push("INSIDE_ARRAY_AFTER_COMMA"),f=(Number(f)+1).toString();break}case"]":{r=C,i.pop(),f=h.pop();break}default:{r=C;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{m(A,C,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{i.pop(),i[i.length-1]==="INSIDE_STRING"?r=C:i[i.length-1]==="INSIDE_OBJECT_KEY"&&(f+=A);break}case"INSIDE_NUMBER":{switch(A){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=C;break}case"e":case"E":case"-":case".":break;case",":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&w(A,C);break}case"}":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&w(A,C);break}case"]":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C);break}default:{i.pop(),f=h.pop();break}}break}case"INSIDE_LITERAL":{const K=n.substring(a,C+1);!"false".startsWith(K)&&!"true".startsWith(K)&&!"null".startsWith(K)?(i.pop(),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?w(A,C):i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C)):r=C;break}}}let P=n.slice(0,r+1);for(let C=i.length-1;C>=0;C--)switch(i[C]){case"INSIDE_STRING":{P+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{P+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{P+="]";break}case"INSIDE_LITERAL":{const R=n.substring(a,n.length);"true".startsWith(R)?P+="true".slice(R.length):"false".startsWith(R)?P+="false".slice(R.length):"null".startsWith(R)&&(P+="null".slice(R.length))}}return[P,h]}var yi=Symbol("aui.parse-partial-json-object.meta"),Sb=n=>{if(n.length===0)return{[yi]:{state:"partial",partialPath:[]}};try{const i=yu.parse(n);if(typeof i!="object"||i===null)throw new Error("argsText is expected to be an object");return i[yi]={state:"complete",partialPath:[]},i}catch{try{const[i,r]=yb(n),a=yu.parse(i);if(typeof a!="object"||a===null)throw new Error("argsText is expected to be an object");return a[yi]={state:"partial",partialPath:r},a}catch{return}}},ki=(n,i,r)=>{const{role:a,id:h,createdAt:f,attachments:p,status:m,metadata:w}=n,I={id:h??i,createdAt:f??new Date},P=typeof n.content=="string"?[{type:"text",text:n.content}]:n.content,C=({image:A,...R})=>A.match(/^data:image\/(png|jpeg|jpg|gif|webp);base64,(.*)$/)?{...R,image:A}:(console.warn("Invalid image data format detected"),null);if(a!=="user"&&(p!=null&&p.length))throw new Error("attachments are only supported for user messages");if(a!=="assistant"&&m)throw new Error("status is only supported for assistant messages");if(a!=="assistant"&&(w!=null&&w.steps))throw new Error("metadata.steps is only supported for assistant messages");switch(a){case"assistant":return{...I,role:a,content:P.map(A=>{const R=A.type;switch(R){case"text":case"reasoning":return A.text.trim().length===0?null:A;case"file":case"source":return A;case"image":return C(A);case"data":return A;case"tool-call":{const{parentId:K,messages:Tt,...pt}=A,ut={...pt,toolCallId:A.toolCallId??`tool-${Li()}`,...K!==void 0&&{parentId:K},...Tt!==void 0&&{messages:Tt}};return A.args?{...ut,args:A.args,argsText:A.argsText??JSON.stringify(A.args)}:{...ut,args:Sb(A.argsText??"")??{},argsText:A.argsText??""}}default:{const K=R;throw new Error(`Unsupported assistant message part type: ${K}`)}}}).filter(A=>!!A),status:m??r,metadata:{unstable_state:(w==null?void 0:w.unstable_state)??null,unstable_annotations:(w==null?void 0:w.unstable_annotations)??[],unstable_data:(w==null?void 0:w.unstable_data)??[],custom:(w==null?void 0:w.custom)??{},steps:(w==null?void 0:w.steps)??[],...(w==null?void 0:w.submittedFeedback)&&{submittedFeedback:w.submittedFeedback}}};case"user":return{...I,role:a,content:P.map(A=>{const R=A.type;switch(R){case"text":case"image":case"audio":case"file":return A;default:{const K=R;throw new Error(`Unsupported user message part type: ${K}`)}}}),attachments:p??[],metadata:{custom:(w==null?void 0:w.custom)??{}}};case"system":if(P.length!==1||P[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...I,role:a,content:P,metadata:{custom:(w==null?void 0:w.custom)??{}}};default:{const A=a;throw new Error(`Unknown message role: ${A}`)}}},Di={fromArray:n=>{const i=n.map(r=>ki(r,Li(),Nu(!1,!1,!1,!1,void 0)));return{messages:i.map((r,a)=>({parentId:a>0?i[a-1].id:null,message:r}))}}},Kr=n=>n.next?Kr(n.next):"current"in n?n:null,xb=class{constructor(n){S(this,"_value",null);this.func=n}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Wu=class{constructor(){S(this,"messages",new Map);S(this,"head",null);S(this,"root",{children:[],next:null});S(this,"_messages",new xb(()=>{var i;const n=new Array((((i=this.head)==null?void 0:i.level)??-1)+1);for(let r=this.head;r;r=r.prev)n[r.level]=r.current;return n}))}updateLevels(n,i){n.level=i;for(const r of n.children){const a=this.messages.get(r);a&&this.updateLevels(a,i+1)}}performOp(n,i,r){const a=i.prev??this.root,h=n??this.root;if(!(r==="relink"&&a===h)){if(r!=="link"&&(a.children=a.children.filter(f=>f!==i.current.id),a.next===i)){const f=a.children.at(-1),p=f?this.messages.get(f):null;if(p===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");a.next=p}if(r!=="cut"){for(let p=n;p;p=p.prev)if(p.current.id===i.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");h.children=[...h.children,i.current.id],(Kr(i)===this.head||h.next===null)&&(h.next=i),i.prev=n;const f=n?n.level+1:0;this.updateLevels(i,f)}}}get headId(){var n;return((n=this.head)==null?void 0:n.current.id)??null}getMessages(n){var a;if(n===void 0||n===((a=this.head)==null?void 0:a.current.id))return this._messages.value;const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const r=new Array(i.level+1);for(let h=i;h;h=h.prev)r[h.level]=h.current;return r}addOrUpdateMessage(n,i){const r=this.messages.get(i.id),a=n?this.messages.get(n):null;if(a===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(r){r.current=i,this.performOp(a,r,"relink"),this._messages.dirty();return}const h={prev:a,current:i,next:null,children:[],level:a?a.level+1:0};this.messages.set(i.id,h),this.performOp(a,h,"link"),this.head===a&&(this.head=h),this._messages.dirty()}getMessage(n){var r;const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:((r=i.prev)==null?void 0:r.current.id)??null,message:i.current,index:i.level}}appendOptimisticMessage(n,i){let r;do r=pb();while(this.messages.has(r));return this.addOrUpdateMessage(n,ki(i,r,{type:"running"})),r}deleteMessage(n,i){const r=this.messages.get(n);if(!r)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const a=i===void 0?r.prev:i===null?null:this.messages.get(i);if(a===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const h of r.children){const f=this.messages.get(h);if(!f)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(a,f,"relink")}this.performOp(null,r,"cut"),this.messages.delete(n),this.head===r&&(this.head=Kr(a??this.root)),this._messages.dirty()}getBranches(n){const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:r}=i.prev??this.root;return r}switchToBranch(n){const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const r=i.prev??this.root;r.next=i,this.head=Kr(i),this._messages.dirty()}resetHead(n){if(n===null){this.clear();return}const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");if(i.children.length>0){const r=a=>{for(const h of a.children){const f=this.messages.get(h);f&&(r(f),this.messages.delete(h))}};r(i),i.children=[],i.next=null}this.head=i;for(let r=i;r;r=r.prev)r.prev&&(r.prev.next=r);this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){var i,r;const n=[];for(const[,a]of this.messages)n.push({message:a.current,parentId:((i=a.prev)==null?void 0:i.current.id)??null});return{headId:((r=this.head)==null?void 0:r.current.id)??null,messages:n}}import({headId:n,messages:i}){var r;for(const{message:a,parentId:h}of i)this.addOrUpdateMessage(h,a);this.resetHead(n??((r=i.at(-1))==null?void 0:r.message.id)??null)}},Xr=class{constructor(){S(this,"_subscriptions",new Set);S(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(){for(const n of this._subscriptions)n()}_updateConnection(){var n;if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else(n=this._connection)==null||n.call(this),this._connection=void 0}subscribe(n){return this._subscriptions.add(n),this._updateConnection(),()=>{this._subscriptions.delete(n),this._updateConnection()}}},re=Symbol("skip-update"),Ni=class extends Xr{constructor(i){super();S(this,"_previousStateDirty",!0);S(this,"_previousState");S(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const i=this.binding.getState();i!==re&&(this._previousState=i),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=i}get path(){return this.binding.path}_connect(){const i=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(i)}},Hr=class{constructor(n,i){this._core=n,this._threadListBinding=i,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(){const n=this._core.getState();return this._threadListBinding.switchToThread(n.id)}rename(n){const i=this._core.getState();return this._threadListBinding.rename(i.id,n)}archive(){const n=this._core.getState();return this._threadListBinding.archive(n.id)}unarchive(){const n=this._core.getState();return this._threadListBinding.unarchive(n.id)}delete(){const n=this._core.getState();return this._threadListBinding.delete(n.id)}initialize(){const n=this._core.getState();return this._threadListBinding.initialize(n.id)}generateTitle(){const n=this._core.getState();return this._threadListBinding.generateTitle(n.id)}unstable_on(n,i){let r=this._core.getState().isMain,a=this._core.getState().id;return this.subscribe(()=>{const h=this._core.getState(),f=h.isMain,p=h.id;r===f&&a===p||(r=f,a=p,!(n==="switched-to"&&!f)&&(n==="switched-away"&&f||i()))})}subscribe(n){return this._core.subscribe(n)}detach(){const n=this._core.getState();this._threadListBinding.detach(n.id)}__internal_getRuntime(){return this}};function Eb(n,i){if(n===void 0&&i===void 0)return!0;if(n===void 0||i===void 0)return!1;for(const r of Object.keys(n)){const a=n[r],h=i[r];if(!Object.is(a,h))return!1}return!0}var ne=class extends Xr{constructor(i){super();S(this,"_previousState");S(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=i;const r=i.getState();if(r===re)throw new Error("Entry not available in the store");this._previousState=r}get path(){return this.binding.path}_syncState(){const i=this.binding.getState();return i===re||Eb(i,this._previousState)?!1:(this._previousState=i,!0)}_connect(){const i=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(i)}},_n=Symbol("innerMessage"),Tb=n=>n[_n],Jn=n=>n.content.filter(r=>r.type==="text").map(r=>r.text).join(`
12
+
13
+ `),$u=class{constructor(n){this._core=n,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(n){return this._core.subscribe(n)}},qu=class extends $u{constructor(n,i){super(n),this._composerApi=i}remove(){const n=this._composerApi.getState();if(!n)throw new Error("Composer is not available");return n.removeAttachment(this.getState().id)}},Ab=class extends qu{get source(){return"thread-composer"}},Cb=class extends qu{get source(){return"edit-composer"}},Ib=class extends $u{get source(){return"message"}constructor(n){super(n)}remove(){throw new Error("Message attachments cannot be removed")}},zu=class extends Xr{constructor(n){super(),this.config=n}getState(){return this.config.binding.getState()}outerSubscribe(n){return this.config.binding.subscribe(n)}_connect(){const n=()=>{this.notifySubscribers()};let i=this.config.binding.getState(),r=i==null?void 0:i.unstable_on(this.config.event,n);const a=()=>{var p;const f=this.config.binding.getState();f!==i&&(i=f,r==null||r(),r=(p=this.config.binding.getState())==null?void 0:p.unstable_on(this.config.event,n))},h=this.outerSubscribe(a);return()=>{h==null||h(),r==null||r()}}},Hu=Object.freeze([]),Ju=Object.freeze({}),Rb=n=>Object.freeze({type:"thread",isEditing:(n==null?void 0:n.isEditing)??!1,canCancel:(n==null?void 0:n.canCancel)??!1,isEmpty:(n==null?void 0:n.isEmpty)??!0,attachments:(n==null?void 0:n.attachments)??Hu,text:(n==null?void 0:n.text)??"",role:(n==null?void 0:n.role)??"user",runConfig:(n==null?void 0:n.runConfig)??Ju,attachmentAccept:(n==null?void 0:n.attachmentAccept)??"",value:(n==null?void 0:n.text)??""}),Mb=n=>Object.freeze({type:"edit",isEditing:(n==null?void 0:n.isEditing)??!1,canCancel:(n==null?void 0:n.canCancel)??!1,isEmpty:(n==null?void 0:n.isEmpty)??!0,text:(n==null?void 0:n.text)??"",role:(n==null?void 0:n.role)??"user",attachments:(n==null?void 0:n.attachments)??Hu,runConfig:(n==null?void 0:n.runConfig)??Ju,attachmentAccept:(n==null?void 0:n.attachmentAccept)??"",value:(n==null?void 0:n.text)??""}),Gu=class{constructor(n){S(this,"_eventSubscriptionSubjects",new Map);this._core=n}get path(){return this._core.path}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setText(n)}setRunConfig(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setRunConfig(n)}addAttachment(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");return i.addAttachment(n)}reset(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");return n.reset()}clearAttachments(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");return n.clearAttachments()}send(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.send()}cancel(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.cancel()}setRole(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setRole(n)}subscribe(n){return this._core.subscribe(n)}unstable_on(n,i){let r=this._eventSubscriptionSubjects.get(n);return r||(r=new zu({event:n,binding:this._core}),this._eventSubscriptionSubjects.set(n,r)),r.subscribe(i)}},Pb=class extends Gu{constructor(i){const r=new Ni({path:i.path,getState:()=>Rb(i.getState()),subscribe:a=>i.subscribe(a)});super({path:i.path,getState:()=>i.getState(),subscribe:a=>r.subscribe(a)});S(this,"_getState");this._getState=r.getState.bind(r),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(i){return new Ab(new ne({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:i},ref:`${this.path.ref}${this.path.ref}.attachments[${i}]`},getState:()=>{const a=this.getState().attachments[i];return a?{...a,source:"thread-composer"}:re},subscribe:r=>this._core.subscribe(r)}),this._core)}},Ob=class extends Gu{constructor(i,r){const a=new Ni({path:i.path,getState:()=>Mb(i.getState()),subscribe:h=>i.subscribe(h)});super({path:i.path,getState:()=>i.getState(),subscribe:h=>a.subscribe(h)});S(this,"_getState");this._beginEdit=r,this._getState=a.getState.bind(a),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(i){return new Cb(new ne({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:i},ref:`${this.path.ref}${this.path.ref}.attachments[${i}]`},getState:()=>{const a=this.getState().attachments[i];return a?{...a,source:"edit-composer"}:re},subscribe:r=>this._core.subscribe(r)}),this._core)}},Su=Symbol.for("aui.tool-response"),Lb=class Ci{constructor(i){S(this,"artifact");S(this,"result");S(this,"isError");i.artifact!==void 0&&(this.artifact=i.artifact),this.result=i.result,this.isError=i.isError??!1}get[Su](){return!0}static[Symbol.hasInstance](i){return typeof i=="object"&&i!==null&&Su in i}static toResponse(i){return i instanceof Ci?i:new Ci({result:i===void 0?"<no result>":i})}},xu=class{constructor(n,i,r){this.contentBinding=n,this.messageApi=i,this.threadApi=r,this.__internal_bindMethods()}get path(){return this.contentBinding.path}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(n){const i=this.contentBinding.getState();if(!i)throw new Error("Message part is not available");if(i.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const r=this.messageApi.getState();if(!r)throw new Error("Message is not available");const a=i.toolName,h=i.toolCallId,f=Lb.toResponse(n);this.threadApi.getState().addToolResult({messageId:r.id,toolName:a,toolCallId:h,result:f.result,artifact:f.artifact,isError:f.isError})}resumeToolCall(n){const i=this.contentBinding.getState();if(!i)throw new Error("Message part is not available");if(i.type!=="tool-call")throw new Error("Tried to resume tool call on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");const r=i.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:r,payload:n})}subscribe(n){return this.contentBinding.subscribe(n)}},Yr=class extends Xr{constructor(n){super(),this.binding=n}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(n){return this.binding.subscribe(n)}_connect(){const n=()=>{this.notifySubscribers()};let i=this.binding.getState(),r=i==null?void 0:i.subscribe(n);const a=()=>{var p;const f=this.binding.getState();f!==i&&(i=f,r==null||r(),r=(p=this.binding.getState())==null?void 0:p.subscribe(n),n())},h=this.outerSubscribe(a);return()=>{h==null||h(),r==null||r()}}},Jr=Object.freeze({type:"complete"}),Bb=(n,i,r)=>{if(n.role!=="assistant")return Jr;if(r.type==="tool-call")return r.result?Jr:n.status;const a=i===Math.max(0,n.content.length-1);return n.status.type==="requires-action"?Jr:a?n.status:Jr},Eu=(n,i)=>{const r=n.content[i];if(!r)return re;const a=Bb(n,i,r);return Object.freeze({...r,[_n]:r[_n],status:a})},kb=class{constructor(n,i){S(this,"composer");S(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=n,this._threadBinding=i,this.composer=new Ob(new Yr({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"edit"},getState:this._getEditComposerRuntimeCore,subscribe:r=>this._threadBinding.subscribe(r)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.reload=this.reload.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}getState(){return this._core.getState()}reload(n={}){const i=this._getEditComposerRuntimeCore(),r=i??this._threadBinding.getState().composer,a=i??r,{runConfig:h=a.runConfig}=n,f=this._core.getState();if(f.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:f.parentId,sourceId:f.id,runConfig:h})}speak(){const n=this._core.getState();return this._threadBinding.getState().speak(n.id)}stopSpeaking(){var r;const n=this._core.getState();if(((r=this._threadBinding.getState().speech)==null?void 0:r.messageId)===n.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:n}){const i=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:i.id,type:n})}switchToBranch({position:n,branchId:i}){const r=this._core.getState();if(i&&n)throw new Error("May not specify both branchId and position");if(!i&&!n)throw new Error("Must specify either branchId or position");const h=this._threadBinding.getState().getBranches(r.id);let f=i;if(n==="previous"?f=h[r.branchNumber-2]:n==="next"&&(f=h[r.branchNumber]),!f)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(f)}unstable_getCopyText(){return Jn(this.getState())}subscribe(n){return this._core.subscribe(n)}getMessagePartByIndex(n){if(n<0)throw new Error("Message part index must be >= 0");return new xu(new ne({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${n}]`,messagePartSelector:{type:"index",index:n}},getState:()=>Eu(this.getState(),n),subscribe:i=>this._core.subscribe(i)}),this._core,this._threadBinding)}getMessagePartByToolCallId(n){return new xu(new ne({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(n)}]`,messagePartSelector:{type:"toolCallId",toolCallId:n}},getState:()=>{const i=this._core.getState(),r=i.content.findIndex(a=>a.type==="tool-call"&&a.toolCallId===n);return r===-1?re:Eu(i,r)},subscribe:i=>this._core.subscribe(i)}),this._core,this._threadBinding)}getAttachmentByIndex(n){return new Ib(new ne({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${n}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:n}},getState:()=>{const i=this.getState().attachments,r=i==null?void 0:i[n];return r?{...r,source:"message"}:re},subscribe:i=>this._core.subscribe(i)}))}},Db=n=>({parentId:n.parentId??null,sourceId:n.sourceId??null,runConfig:n.runConfig??{},...n.stream?{stream:n.stream}:{}}),Nb=n=>({parentId:n.parentId??null,sourceId:n.sourceId??null,runConfig:n.runConfig??{}}),Fb=(n,i)=>{var r,a;return typeof i=="string"?{createdAt:new Date,parentId:((r=n.at(-1))==null?void 0:r.id)??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:i}],attachments:[],metadata:{custom:{}}}:{createdAt:i.createdAt??new Date,parentId:i.parentId??((a=n.at(-1))==null?void 0:a.id)??null,sourceId:i.sourceId??null,role:i.role??"user",content:i.content,attachments:i.attachments??[],metadata:i.metadata??{custom:{}},runConfig:i.runConfig??{},startRun:i.startRun}},Ub=(n,i)=>{const r=n.messages.at(-1);return Object.freeze({threadId:i.id,metadata:i,capabilities:n.capabilities,isDisabled:n.isDisabled,isLoading:n.isLoading,isRunning:(r==null?void 0:r.role)!=="assistant"?!1:r.status.type==="running",messages:n.messages,state:n.state,suggestions:n.suggestions,extras:n.extras,speech:n.speech})},Wb=class{constructor(n,i){S(this,"_threadBinding");S(this,"composer");S(this,"_eventSubscriptionSubjects",new Map);const r=new ne({path:n.path,getState:()=>Ub(n.getState(),i.getState()),subscribe:a=>{const h=n.subscribe(a),f=i.subscribe(a);return()=>{h(),f()}}});this._threadBinding={path:n.path,getState:()=>n.getState(),getStateState:()=>r.getState(),outerSubscribe:a=>n.outerSubscribe(a),subscribe:a=>n.subscribe(a)},this.composer=new Pb(new Yr({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"thread"},getState:()=>this._threadBinding.getState().composer,subscribe:a=>this._threadBinding.subscribe(a)})),this.__internal_bindMethods()}get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}__internal_bindMethods(){this.append=this.append.bind(this),this.unstable_resumeRun=this.unstable_resumeRun.bind(this),this.unstable_loadExternalState=this.unstable_loadExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getModelConfig=this.getModelConfig.bind(this),this.getState=this.getState.bind(this)}getState(){return this._threadBinding.getStateState()}append(n){this._threadBinding.getState().append(Fb(this._threadBinding.getState().messages,n))}subscribe(n){return this._threadBinding.subscribe(n)}getModelContext(){return this._threadBinding.getState().getModelContext()}getModelConfig(){return this.getModelContext()}startRun(n){const i=n===null||typeof n=="string"?{parentId:n}:n;return this._threadBinding.getState().startRun(Nb(i))}unstable_resumeRun(n){return this._threadBinding.getState().resumeRun(Db(n))}unstable_loadExternalState(n){this._threadBinding.getState().unstable_loadExternalState(n)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}export(){return this._threadBinding.getState().export()}import(n){this._threadBinding.getState().import(n)}reset(n){this._threadBinding.getState().reset(n)}getMessageByIndex(n){if(n<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:`${this.path.ref}${this.path.ref}.messages[${n}]`,messageSelector:{type:"index",index:n}},()=>{var a;const i=this._threadBinding.getState().messages,r=i[n];if(r)return{message:r,parentId:((a=i[n-1])==null?void 0:a.id)??null,index:n}})}getMessageById(n){return this._getMessageRuntime({...this.path,ref:this.path.ref+`${this.path.ref}.messages[messageId=${JSON.stringify(n)}]`,messageSelector:{type:"messageId",messageId:n}},()=>this._threadBinding.getState().getMessageById(n))}_getMessageRuntime(n,i){return new kb(new ne({path:n,getState:()=>{var P;const{message:r,parentId:a,index:h}=i()??{},{messages:f,speech:p}=this._threadBinding.getState();if(!r||a===void 0||h===void 0)return re;const w=this._threadBinding.getState().getBranches(r.id),I=r.metadata.submittedFeedback;return{...r,[_n]:r[_n],index:h,isLast:((P=f.at(-1))==null?void 0:P.id)===r.id,parentId:a,branchNumber:w.indexOf(r.id)+1,branchCount:w.length,speech:(p==null?void 0:p.messageId)===r.id?p:void 0,submittedFeedback:I}},subscribe:r=>this._threadBinding.subscribe(r)}),this._threadBinding)}unstable_on(n,i){let r=this._eventSubscriptionSubjects.get(n);return r||(r=new zu({event:n,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(n,r)),r.subscribe(i)}},$b=n=>({mainThreadId:n.mainThreadId,newThread:n.newThreadId,threads:n.threadIds,archivedThreads:n.archivedThreadIds,isLoading:n.isLoading,threadItems:n.threadData}),Gr=(n,i)=>{if(i===void 0)return re;const r=n.getItemById(i);return r?{id:r.id,threadId:r.id,remoteId:r.remoteId,externalId:r.externalId,title:r.title,status:r.status,isMain:r.id===n.mainThreadId}:re},qb=class{constructor(n,i=Wb){S(this,"_getState");S(this,"_mainThreadListItemRuntime");S(this,"main");this._core=n,this._runtimeFactory=i;const r=new Ni({path:{},getState:()=>$b(n),subscribe:a=>n.subscribe(a)});this._getState=r.getState.bind(r),this._mainThreadListItemRuntime=new Hr(new ne({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>Gr(this._core,this._core.mainThreadId),subscribe:a=>this._core.subscribe(a)}),this._core),this.main=new i(new Yr({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>n.getMainThreadRuntimeCore(),subscribe:a=>n.subscribe(a)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(n){return this._core.switchToThread(n)}switchToNewThread(){return this._core.switchToNewThread()}getState(){return this._getState()}subscribe(n){return this._core.subscribe(n)}get mainItem(){return this._mainThreadListItemRuntime}getById(n){return new this._runtimeFactory(new Yr({path:{ref:`threads[threadId=${JSON.stringify(n)}]`,threadSelector:{type:"threadId",threadId:n}},getState:()=>this._core.getThreadRuntimeCore(n),subscribe:i=>this._core.subscribe(i)}),this.mainItem)}getItemByIndex(n){return new Hr(new ne({path:{ref:`threadItems[${n}]`,threadSelector:{type:"index",index:n}},getState:()=>Gr(this._core,this._core.threadIds[n]),subscribe:i=>this._core.subscribe(i)}),this._core)}getArchivedItemByIndex(n){return new Hr(new ne({path:{ref:`archivedThreadItems[${n}]`,threadSelector:{type:"archiveIndex",index:n}},getState:()=>Gr(this._core,this._core.archivedThreadIds[n]),subscribe:i=>this._core.subscribe(i)}),this._core)}getItemById(n){return new Hr(new ne({path:{ref:`threadItems[threadId=${n}]`,threadSelector:{type:"threadId",threadId:n}},getState:()=>Gr(this._core,n),subscribe:i=>this._core.subscribe(i)}),this._core)}},zb=class{constructor(){S(this,"accept","image/*")}async add(n){return{id:n.file.name,type:"image",name:n.file.name,contentType:n.file.type,file:n.file,status:{type:"requires-action",reason:"composer-send"}}}async send(n){return{...n,status:{type:"complete"},content:[{type:"image",image:await Hb(n.file)}]}}async remove(){}},Hb=n=>new Promise((i,r)=>{const a=new FileReader;a.onload=()=>i(a.result),a.onerror=h=>r(h),a.readAsDataURL(n)});function Si(n,i){if(i==="*")return!0;const r=i.split(",").map(f=>f.trim().toLowerCase()),a=`.${n.name.split(".").pop().toLowerCase()}`,h=n.type.toLowerCase();for(const f of r){if(f.startsWith(".")&&f===a||f.includes("/")&&f===h)return!0;if((f==="image/*"||f==="video/*"||f==="audio/*")&&f.endsWith("/*")){const p=f.split("/")[0];if(h.startsWith(`${p}/`))return!0}}return!1}var Jb=class{constructor(n){S(this,"_adapters");S(this,"accept");this._adapters=n;const i=n.findIndex(r=>r.accept==="*");if(i!==-1){if(i!==n.length-1)throw new Error("A wildcard adapter (handling all files) can only be specified as the last adapter.");this.accept="*"}else this.accept=n.map(r=>r.accept).join(",")}add(n){for(const i of this._adapters)if(Si(n.file,i.accept))return i.add(n);throw new Error("No matching adapter found for file")}async send(n){const i=this._adapters.slice();for(const r of i)if(Si(n.file,r.accept))return r.send(n);throw new Error("No matching adapter found for attachment")}async remove(n){const i=this._adapters.slice();for(const r of i)if(Si({name:n.name,type:n.contentType},r.accept))return r.remove(n);throw new Error("No matching adapter found for attachment")}},Gb=U.createContext(null),Kb=()=>U.useContext(Gb),Je=Object.freeze([]),Ge="DEFAULT_THREAD_ID",Yb=Object.freeze([Ge]),Ku=Object.freeze({id:Ge,remoteId:void 0,externalId:void 0,status:"regular"}),Vb=Promise.resolve(),Tu=Object.freeze({[Ge]:Ku}),Zb=class{constructor(n={},i){S(this,"_mainThreadId",Ge);S(this,"_threads",Yb);S(this,"_archivedThreads",Je);S(this,"_threadData",Tu);S(this,"_mainThread");S(this,"_subscriptions",new Set);this.adapter=n,this.threadFactory=i,this._mainThread=this.threadFactory(),this.__internal_setAdapter(n,!0)}get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadData(){return this._threadData}getLoadThreadsPromise(){return Vb}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(n){for(const i of this.adapter.threads??[])if(i.id===n)return i;for(const i of this.adapter.archivedThreads??[])if(i.id===n)return i;if(n===Ge)return Ku}__internal_setAdapter(n,i=!1){var I,P,C,A;const r=this.adapter;this.adapter=n;const a=n.threadId??Ge,h=n.threads??Je,f=n.archivedThreads??Je,p=r.threadId??Ge,m=r.threads??Je,w=r.archivedThreads??Je;!i&&p===a&&m===h&&w===f||(this._threadData={...Tu,...Object.fromEntries(((I=n.threads)==null?void 0:I.map(R=>[R.id,{...R,remoteId:R.remoteId,externalId:R.externalId,status:"regular"}]))??[]),...Object.fromEntries(((P=n.archivedThreads)==null?void 0:P.map(R=>[R.id,{...R,remoteId:R.remoteId,externalId:R.externalId,status:"archived"}]))??[])},m!==h&&(this._threads=((C=this.adapter.threads)==null?void 0:C.map(R=>R.id))??Je),w!==f&&(this._archivedThreads=((A=this.adapter.archivedThreads)==null?void 0:A.map(R=>R.id))??Je),p!==a&&(this._mainThreadId=a,this._mainThread=this.threadFactory()),this._notifySubscribers())}async switchToThread(n){if(this._mainThreadId===n)return;const i=this.adapter.onSwitchToThread;if(!i)throw new Error("External store adapter does not support switching to thread");i(n)}async switchToNewThread(){const n=this.adapter.onSwitchToNewThread;if(!n)throw new Error("External store adapter does not support switching to new thread");n()}async rename(n,i){const r=this.adapter.onRename;if(!r)throw new Error("External store adapter does not support renaming");r(n,i)}async detach(){}async archive(n){const i=this.adapter.onArchive;if(!i)throw new Error("External store adapter does not support archiving");i(n)}async unarchive(n){const i=this.adapter.onUnarchive;if(!i)throw new Error("External store adapter does not support unarchiving");i(n)}async delete(n){const i=this.adapter.onDelete;if(!i)throw new Error("External store adapter does not support deleting");i(n)}initialize(n){return Promise.resolve({remoteId:n,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}subscribe(n){return this._subscriptions.add(n),()=>this._subscriptions.delete(n)}_notifySubscribers(){for(const n of this._subscriptions)n()}},Au=class{constructor(){S(this,"cache",new WeakMap)}convertMessages(n,i){return n.map((r,a)=>{const h=this.cache.get(r),f=i(h,r,a);return this.cache.set(r,f),f})}},Xb=class extends Du{constructor(i,r,{parentId:a,message:h}){super();S(this,"_nonTextParts");S(this,"_previousText");S(this,"_parentId");S(this,"_sourceId");this.runtime=i,this.endEditCallback=r,this._parentId=a,this._sourceId=h.id,this._previousText=Jn(h),this.setText(this._previousText),this.setRole(h.role),this.setAttachments(h.attachments??[]),this._nonTextParts=h.content.filter(f=>f.type!=="text"),this.setRunConfig({...i.composer.runConfig})}get canCancel(){return!0}getAttachmentAdapter(){var i;return(i=this.runtime.adapters)==null?void 0:i.attachments}async handleSend(i){Jn(i)!==this._previousText&&this.runtime.append({...i,content:[...i.content,...this._nonTextParts],parentId:this._parentId,sourceId:this._sourceId}),this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},Qb=class{constructor(n){S(this,"_subscriptions",new Set);S(this,"_isInitialized",!1);S(this,"repository",new Wu);S(this,"composer",new lb(this));S(this,"_editComposers",new Map);S(this,"_stopSpeaking");S(this,"speech");S(this,"_eventSubscribers",new Map);this._contextProvider=n}get messages(){return this.repository.getMessages()}get state(){let n;for(const i of this.messages)if(i.role==="assistant"){n=i;break}return(n==null?void 0:n.metadata.unstable_state)??null}getModelContext(){return this._contextProvider.getModelContext()}getEditComposer(n){return this._editComposers.get(n)}beginEdit(n){if(this._editComposers.has(n))throw new Error("Edit already in progress");this._editComposers.set(n,new Xb(this,()=>this._editComposers.delete(n),this.repository.getMessage(n))),this._notifySubscribers()}getMessageById(n){try{return this.repository.getMessage(n)}catch{return}}getBranches(n){return this.repository.getBranches(n)}switchToBranch(n){this.repository.switchToBranch(n),this._notifySubscribers()}_notifySubscribers(){for(const n of this._subscriptions)n()}_notifyEventSubscribers(n){const i=this._eventSubscribers.get(n);if(i)for(const r of i)r()}subscribe(n){return this._subscriptions.add(n),()=>this._subscriptions.delete(n)}submitFeedback({messageId:n,type:i}){var f;const r=(f=this.adapters)==null?void 0:f.feedback;if(!r)throw new Error("Feedback adapter not configured");const{message:a,parentId:h}=this.repository.getMessage(n);if(r.submit({message:a,type:i}),a.role==="assistant"){const p={...a,metadata:{...a.metadata,submittedFeedback:{type:i}}};this.repository.addOrUpdateMessage(h,p)}this._notifySubscribers()}speak(n){var f,p;const i=(f=this.adapters)==null?void 0:f.speech;if(!i)throw new Error("Speech adapter not configured");const{message:r}=this.repository.getMessage(n);(p=this._stopSpeaking)==null||p.call(this);const a=i.speak(Jn(r)),h=a.subscribe(()=>{a.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:n,status:a.status},this._notifySubscribers()});this.speech={messageId:n,status:a.status},this._notifySubscribers(),this._stopSpeaking=()=>{a.cancel(),h(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize"))}export(){return this.repository.export()}import(n){this.ensureInitialized(),this.repository.clear(),this.repository.import(n),this._notifySubscribers()}reset(n){this.import(Di.fromArray(n??[]))}unstable_on(n,i){var a,h;if(n==="model-context-update")return((h=(a=this._contextProvider).subscribe)==null?void 0:h.call(a,i))??(()=>{});const r=this._eventSubscribers.get(n);return r?r.add(i):this._eventSubscribers.set(n,new Set([i])),()=>{this._eventSubscribers.get(n).delete(i)}}},jb=Object.freeze([]),tm=(n,i)=>{var r;return n&&((r=i[i.length-1])==null?void 0:r.role)!=="assistant"},em=class extends Qb{constructor(i,r){super(i);S(this,"_assistantOptimisticId",null);S(this,"_capabilities",{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,attachments:!1,feedback:!1});S(this,"_messages");S(this,"isDisabled");S(this,"suggestions",[]);S(this,"extras");S(this,"_converter",new Au);S(this,"_store");S(this,"updateMessages",i=>{var a,h,f,p;this._store.convertMessage!==void 0?(h=(a=this._store).setMessages)==null||h.call(a,i.flatMap(Tb).filter(m=>m!=null)):(p=(f=this._store).setMessages)==null||p.call(f,i)});this.__internal_setAdapter(r)}get capabilities(){return this._capabilities}get isLoading(){return this._store.isLoading??!1}get messages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}beginEdit(i){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(i)}__internal_setAdapter(i){var f,p,m,w,I,P;if(this._store===i)return;const r=i.isRunning??!1;this.isDisabled=i.isDisabled??!1;const a=this._store;this._store=i,this.extras=i.extras,this.suggestions=i.suggestions??jb,this._capabilities={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:((f=this._store.adapters)==null?void 0:f.speech)!==void 0,unstable_copy:((p=this._store.unstable_capabilities)==null?void 0:p.copy)!==!1,attachments:!!((m=this._store.adapters)!=null&&m.attachments),feedback:!!((w=this._store.adapters)!=null&&w.feedback)};let h;if(i.messageRepository){if(a&&a.isRunning===i.isRunning&&a.messageRepository===i.messageRepository){this._notifySubscribers();return}this.repository.clear(),this._assistantOptimisticId=null,this.repository.import(i.messageRepository),h=this.repository.getMessages()}else if(i.messages){if(a){if(a.convertMessage!==i.convertMessage)this._converter=new Au;else if(a.isRunning===i.isRunning&&a.messages===i.messages){this._notifySubscribers();return}}h=i.convertMessage?this._converter.convertMessages(i.messages,(C,A,R)=>{if(!i.convertMessage)return A;const K=R===i.messages.length-1,Tt=Nu(K,r,!1,!1,void 0);if(C&&(C.role!=="assistant"||!bb(C.status)||C.status===Tt))return C;const pt=i.convertMessage(A,R),ut=ki(pt,R.toString(),Tt);return ut[_n]=A,ut}):i.messages;for(let C=0;C<h.length;C++){const A=h[C],R=h[C-1];this.repository.addOrUpdateMessage((R==null?void 0:R.id)??null,A)}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");h.length>0&&this.ensureInitialized(),((a==null?void 0:a.isRunning)??!1)!==(i.isRunning??!1)&&(i.isRunning?this._notifyEventSubscribers("run-start"):this._notifyEventSubscribers("run-end")),this._assistantOptimisticId&&(this.repository.deleteMessage(this._assistantOptimisticId),this._assistantOptimisticId=null),tm(r,h)&&(this._assistantOptimisticId=this.repository.appendOptimisticMessage(((I=h.at(-1))==null?void 0:I.id)??null,{role:"assistant",content:[]})),this.repository.resetHead(this._assistantOptimisticId??((P=h.at(-1))==null?void 0:P.id)??null),this._messages=this.repository.getMessages(),this._notifySubscribers()}switchToBranch(i){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");this._store.isRunning||(this.repository.switchToBranch(i),this.updateMessages(this.repository.getMessages()))}async append(i){var r;if(i.parentId!==(((r=this.messages.at(-1))==null?void 0:r.id)??null)){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");await this._store.onEdit(i)}else await this._store.onNew(i)}async startRun(i){if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");await this._store.onReload(i.parentId,i)}async resumeRun(i){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");await this._store.onResume(i)}unstable_loadExternalState(i){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing states.");this._store.onLoadExternalState(i)}cancelRun(){var a;if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");this._store.onCancel(),this._assistantOptimisticId&&(this.repository.deleteMessage(this._assistantOptimisticId),this._assistantOptimisticId=null);let i=this.repository.getMessages();const r=i[i.length-1];(r==null?void 0:r.role)==="user"&&r.id===((a=i.at(-1))==null?void 0:a.id)?(this.repository.deleteMessage(r.id),this.composer.text.trim()||this.composer.setText(Jn(r)),i=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(i)},0)}addToolResult(i){var r,a;if(!this._store.onAddToolResult&&!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");(a=(r=this._store).onAddToolResult)==null||a.call(r,i)}resumeToolCall(i){if(!this._store.onResumeToolCall)throw new Error("Runtime does not support resuming tool calls.");this._store.onResumeToolCall(i)}reset(i){const r=new Wu;r.import(Di.fromArray(i??[])),this.updateMessages(r.getMessages())}import(i){this._assistantOptimisticId=null,super.import(i),this._store.onImport&&this._store.onImport(this.repository.getMessages())}},Cu=n=>{var i;return((i=n.adapters)==null?void 0:i.threadList)??{}},nm=class extends ub{constructor(i){super();S(this,"threads");this.threads=new Zb(Cu(i),()=>new em(this._contextProvider,i))}setAdapter(i){this.threads.__internal_setAdapter(Cu(i)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(i)}},rm=n=>{const[i]=U.useState(()=>new nm(n));U.useEffect(()=>{i.setAdapter(n)});const{modelContext:r}=Kb()??{};return U.useEffect(()=>{if(r)return i.registerModelContextProvider(r)},[r,i]),U.useMemo(()=>new av(i),[i])};function sm(n,i){n.commitTasks.forEach(r=>{const a=r.cellIndex,h=i.cells[a];if(h.type!=="effect")throw new Error("Cannot find effect cell");let f=!0;if(h.deps!==void 0&&r.deps!==void 0&&(f=h.deps.length!==r.deps.length||h.deps.some((p,m)=>!Object.is(p,r.deps[m]))),f){if(h.mounted){if(typeof h.deps!=typeof r.deps)throw new Error("tapEffect called with and without dependencies across re-renders");try{h.mounted&&h.cleanup&&h.cleanup()}finally{h.mounted=!1}}try{const p=r.effect();if(p!==void 0&&typeof p!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof p}`);h.mounted=!0,h.cleanup=typeof p=="function"?p:void 0,h.deps=r.deps}catch(p){throw p}}})}function im(n){let i=null;for(let r=n.cells.length-1;r>=0;r--){const a=n.cells[r];if((a==null?void 0:a.type)==="effect"&&a.mounted&&a.cleanup)try{a.cleanup()}catch(h){i==null&&(i=h)}finally{a.mounted=!1}}if(i!=null)throw i}var zn=null;function om(n,i){n.currentIndex=0;const r=zn;zn=n;try{if(i(),n.isFirstRender=!1,n.cells.length!==n.currentIndex)throw new Error(`Rendered ${n.currentIndex} hooks but expected ${n.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{zn=r}}function Fi(){if(!zn)throw new Error("No resource fiber available");return zn}function Yu(n,i){const r=n[Vu];if(!r)throw new Error("ResourceElement.type is not a valid Resource");return r(i)}var Vu=Symbol("fnSymbol");function Qr(n,i){return{resource:n,scheduleRerender:i,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function pn(n){n.isMounted=!1,im(n)}function Gn(n,i){const r={commitTasks:[],props:i,state:void 0};return om(n,()=>{n.renderContext=r;try{r.state=Yu(n.resource,i)}finally{n.renderContext=void 0}}),r}function gn(n,i){n.isMounted=!0,n.isNeverMounted=!1,sm(i,n)}var am=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,Iu=am?U.useEffect:U.useLayoutEffect;function um(n){const[,i]=U.useState({}),r=U.useMemo(()=>Qr(n.type,()=>i({})),[n.type,i]),a=Gn(r,n.props);return Iu(()=>()=>pn(r),[]),Iu(()=>{gn(r,a)}),a.state}var Zu=n=>typeof n=="string"?{scope:n.split(".")[0],event:n}:{scope:n.scope,event:n.event},xi=(n,i,r)=>i===n,dn,Ei=()=>{if(dn)return dn;const n=()=>({apis:new Map,nextId:0,listeners:new Set});if(typeof window>"u")return dn=n(),dn;const i=window.__ASSISTANT_UI_DEVTOOLS_HOOK__;if(i)return dn=i,i;const r=n();return window.__ASSISTANT_UI_DEVTOOLS_HOOK__=r,dn=r,r},ee,cm=(ee=class{static register(i){var m,w;const r=Ei();for(const I of r.apis.values())if(I.api===i)return()=>{};const a=r.nextId++,h={api:i,logs:[]},f=(m=i.on)==null?void 0:m.call(i,"*",I=>{const P=r.apis.get(a);P&&(P.logs.push({time:new Date,event:I.event,data:I.payload}),P.logs.length>ee.MAX_EVENT_LOGS_PER_API&&(P.logs=P.logs.slice(-200)),ee.notifyListeners(a))}),p=(w=i.subscribe)==null?void 0:w.call(i,()=>{ee.notifyListeners(a)});return r.apis.set(a,h),ee.notifyListeners(a),()=>{const I=Ei();I.apis.get(a)&&(f==null||f(),p==null||p(),I.apis.delete(a),ee.notifyListeners(a))}}static notifyListeners(i){Ei().listeners.forEach(a=>a(i))}},S(ee,"MAX_EVENT_LOGS_PER_API",200),ee);function dt(n){const i=(r,a)=>({type:i,props:r,...(a==null?void 0:a.key)!==void 0&&{key:a.key}});return i[Vu]=n,i}var hm=n=>{if(n.renderContext)throw new Error("Resource updated during render");if(n.isNeverMounted)throw new Error("Resource updated before mount");n.isMounted&&n.scheduleRerender()};function lm(n){const i=Fi(),r=i.currentIndex++;if(!i.isFirstRender&&r>=i.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!i.cells[r]){const f={type:"state",value:typeof n=="function"?n():n,set:p=>{const m=f.value,w=typeof p=="function"?p(m):p;Object.is(m,w)||(f.value=w,hm(i))}};i.cells[r]=f}const a=i.cells[r];if(a.type!=="state")throw new Error("Hook order changed between renders");return a}function ce(n){const i=lm(n);return[i.value,i.set]}function fm(){const n=Fi(),i=n.currentIndex++;if(!n.isFirstRender&&i>=n.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!n.cells[i]){const a={type:"effect",mounted:!1};n.cells[i]=a}if(n.cells[i].type!=="effect")throw new Error("Hook order changed between renders");return i}function Dt(n,i){const r=Fi(),a=fm();r.renderContext.commitTasks.push({effect:n,deps:i,cellIndex:a})}function Vr(n){const[i]=ce(()=>({current:n}));return i}var dm=(n,i)=>{if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++)if(!Object.is(n[r],i[r]))return!1;return!0},rt=(n,i)=>{const r=Vr();return r.current||(r.current={value:n(),deps:i}),dm(r.current.deps,i)||(r.current.value=n(),r.current.deps=i),r.current.value};function Ti(n,i){const[r,a]=ce({}),h=rt(()=>Qr(n.type,()=>a({})),[n.type]),f=i?rt(()=>n.props,i):n.props,p=rt(()=>Gn(h,f),[h,f,r]);return Dt(()=>()=>pn(h),[h]),Dt(()=>{gn(h,p)},[h,p]),p.state}function se(n){return Yu(n.type,n.props)}function pm(n){const i=new Set;n.forEach((m,w)=>{if(m.key===void 0)throw new Error(`tapResources: All resource elements must have a key. Element at index ${w} is missing a key.`);if(i.has(m.key))throw new Error(`tapResources: Duplicate key "${m.key}" found. All keys must be unique.`);i.add(m.key)});const[r,a]=ce({}),h=rt(()=>new Map(n.map(m=>[m.key,m])),[n]),[f]=ce(()=>new Map),p=rt(()=>{const m=new Map,w=new Set;return h.forEach((I,P)=>{w.add(P);let C=f.get(P);(!C||C.resource!==I.type)&&(C&&pn(C),C=Qr(I.type,()=>a({})),f.set(P,C));const A=Gn(C,I.props);m.set(P,A)}),f.forEach((I,P)=>{w.has(P)||(pn(I),f.delete(P))}),m},[h,r]);return Dt(()=>{p.forEach((m,w)=>{const I=f.get(w);I&&gn(I,m)})},[p,f]),Dt(()=>()=>{f.forEach(m=>{pn(m)}),f.clear()},[f]),rt(()=>n.map(m=>{var w;return(w=p.get(m.key))==null?void 0:w.state}),[n,p])}var Ii=[],Ri=!1;function gm(){Ri=!1;const n=Ii;Ii=[];for(const i of n)try{i()}catch(r){console.error("Error in scheduled task:",r)}}function _m(n){Ii.push(n),Ri||(Ri=!0,queueMicrotask(gm))}var Ke,bm=(Ke=class{constructor(i){S(this,"_isDirty",!1);S(this,"_hasScheduledTask",!1);S(this,"_isFlushing",!1);this._task=i}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,!(this._hasScheduledTask||this._isFlushing)&&(this._hasScheduledTask=!0,_m(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let i=0;try{for(;this._isDirty;){if(i++,i>Ke.MAX_FLUSH_DEPTH)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");this._isDirty=!1,this._task()}}finally{this._isFlushing=!1}}},S(Ke,"MAX_FLUSH_DEPTH",50),Ke),mm=dt(({element:n,onUpdateInput:i,onFlushSync:r,onDispose:a})=>{const[h,f]=ce(n.props),p=se({type:n.type,props:h}),m=Vr(new Set).current,w=Vr(p);return Dt(()=>{p!==w.current&&(w.current=p,m.forEach(P=>P()))}),rt(()=>({getState:()=>w.current,subscribe:P=>(m.add(P),()=>m.delete(P)),updateInput:P=>{i(),f(()=>P)},flushSync:r,dispose:a}),[])}),vm=(n,i=!1)=>{let r=!i;const a={element:n,onUpdateInput:()=>{r||(r=!0,gn(f,p))},onFlushSync:()=>{h.flushSync()},onDispose:()=>pn(f)},h=new bm(()=>{p=Gn(f,a),r&&gn(f,p)}),f=Qr(mm,()=>h.markDirty());let p=Gn(f,a);return r&&gn(f,p),p.state},Hn=Symbol("tap.Context"),Xu=n=>({[Hn]:n}),Qu=(n,i,r)=>{const a=n[Hn];n[Hn]=i;try{return r()}finally{n[Hn]=a}},ju=n=>n[Hn];const Ru=n=>{let i;const r=new Set,a=(I,P)=>{const C=typeof I=="function"?I(i):I;if(!Object.is(C,i)){const A=i;i=P??(typeof C!="object"||C===null)?C:Object.assign({},i,C),r.forEach(R=>R(i,A))}},h=()=>i,m={setState:a,getState:h,getInitialState:()=>w,subscribe:I=>(r.add(I),()=>r.delete(I))},w=i=n(a,h,m);return m},wm=n=>n?Ru(n):Ru,ym=n=>n;function Sm(n,i=ym){const r=U.useSyncExternalStore(n.subscribe,U.useCallback(()=>i(n.getState()),[n,i]),U.useCallback(()=>i(n.getInitialState()),[n,i]));return U.useDebugValue(r),r}const Mu=n=>{const i=wm(n),r=a=>Sm(i,a);return Object.assign(r,i),r},xm=n=>n?Mu(n):Mu;var Em=dt(n=>{const i=rt(()=>vm(n,!0),[n.type]);return Dt(()=>{i.updateInput(n.props)}),i}),Tm=class{constructor(n){this.getApi=n}get(n,i){return this.getApi()[i]}ownKeys(){return Object.keys(this.getApi())}has(n,i){return i in this.getApi()}getOwnPropertyDescriptor(n,i){return Object.getOwnPropertyDescriptor(this.getApi(),i)}set(){return!1}defineProperty(){return!1}deleteProperty(){return!1}},he=(n,i)=>{const r=Vr(n);Dt(()=>{r.current=n});const a=rt(()=>new Proxy({},new Tm(()=>r.current)),[]),h=i==null?void 0:i.key,f=n.getState();return rt(()=>({key:h,state:f,api:a}),[f,h])},tc=Xu(null),Am=(n,i)=>Qu(tc,n,i),ec=()=>{const n=ju(tc);if(!n)throw new Error("Model context is not available in this context");return n},Cm=dt(({toolkit:n})=>{const[i,r]=ce(()=>({tools:{}})),a=ec();Dt(()=>{if(!n)return;const f=[];for(const[w,I]of Object.entries(n))I.render&&f.push(h(w,I.render));const p=Object.entries(n).reduce((w,[I,P])=>{const{render:C,...A}=P;return w[I]=A,w},{}),m={getModelContext:()=>({tools:p})};return f.push(a.register(m)),()=>{f.forEach(w=>w())}},[n,a]);const h=(f,p)=>(r(m=>({...m,tools:{...m.tools,[f]:[...m.tools[f]??[],p]}})),()=>{r(m=>{var w;return{...m,tools:{...m.tools,[f]:((w=m.tools[f])==null?void 0:w.filter(I=>I!==p))??[]}}})});return he({getState:()=>i,setToolUI:h})}),Im=dt(()=>rt(()=>{const i=new Map;return{on:(r,a)=>{i.has(r)||i.set(r,new Set);const h=i.get(r);return h.add(a),()=>{h.delete(a),h.size===0&&i.delete(r)}},emit:(r,a)=>{const h=i.get(r),f=i.get("*");!h&&!f||queueMicrotask(()=>{if(h)for(const p of h)p(a);if(f)for(const p of f)p({event:r,payload:a})})}}},[])),nc=Xu(null),Rm=(n,i)=>Qu(nc,n,i),Ui=()=>{const n=ju(nc);if(!n)throw new Error("Events context is not available");return n},Mm=dt(()=>{const[n]=ce(()=>({})),i=new ku;return he({getState:()=>n,getModelContext:()=>i.getModelContext(),subscribe:r=>i.subscribe(r),register:r=>i.registerModelContextProvider(r)})}),Pm=dt(({threads:n,modelContext:i,tools:r})=>{const a=se(Im()),{threads:h,tools:f,modelContext:p}=Rm(a,()=>{const w=Ti(i??Mm(),[i]);return Am(w.api,()=>({modelContext:w,tools:Ti(r??Cm({}),[r]),threads:Ti(n,[n])}))}),m=rt(()=>({threads:h.state,tools:f.state,modelContext:p.state}),[h.state,f.state,p.state]);return he({getState:()=>m,threads:h.api,tools:f.api,modelContext:p.api,on:a.on})}),Om=n=>{const i=()=>n.getState().api.threads.item("main");return{threads:Et({source:"root",query:{},get:()=>n.getState().api.threads}),tools:Et({source:"root",query:{},get:()=>n.getState().api.tools}),modelContext:Et({source:"root",query:{},get:()=>n.getState().api.modelContext}),thread:Et({source:"threads",query:{type:"main"},get:()=>n.getState().api.threads.thread("main")}),threadListItem:Et({source:"threads",query:{type:"main"},get:()=>i()}),composer:Et({source:"thread",query:{},get:()=>n.getState().api.threads.thread("main").composer}),on(r,a){const{event:h,scope:f}=Zu(r);if(f==="*")return n.getState().api.on(h,a);if(xi("thread",f)||xi("thread-list-item",f)||xi("composer",f))return n.getState().api.on(h,p=>{p.threadId===i().getState().id&&a(p)});throw new Error(`Event scope is not available in this component: ${f}`)},subscribe:n.subscribe,flushSync:n.flushSync}},Lm=n=>{const i=sc(),r=um(Em(Pm(n))),a=U.useMemo(()=>Om(r),[r]);return U.useMemo(()=>Fm(i,a),[i,a])},Et=n=>{const i=n.get;return i.source=n.source,i.query=n.query,i},Oe=()=>()=>{},rc=U.createContext({threads:Et({source:null,query:{},get:()=>{throw new Error("Threads is only available inside <AssistantProvider />")}}),tools:Et({source:null,query:{},get:()=>{throw new Error("Tools is only available inside <AssistantProvider />")}}),modelContext:Et({source:null,query:{},get:()=>{throw new Error("ModelContext is only available inside <AssistantProvider />")}}),threadListItem:Et({source:null,query:{},get:()=>{throw new Error("ThreadListItem is only available inside <AssistantProvider />")}}),thread:Et({source:null,query:{},get:()=>{throw new Error("Thread is only available inside <AssistantProvider />")}}),composer:Et({source:null,query:{},get:()=>{throw new Error("Composer is only available inside <AssistantProvider />")}}),message:Et({source:null,query:{},get:()=>{throw new Error("Message is only available inside <ThreadPrimitive.Messages />")}}),part:Et({source:null,query:{},get:()=>{throw new Error("Part is only available inside <MessagePrimitive.Parts />")}}),attachment:Et({source:null,query:{},get:()=>{throw new Error("Attachment is only available inside <MessagePrimitive.Attachments /> or <ComposerPrimitive.Attachments />")}}),subscribe:Oe,flushSync:Oe,on:n=>{const{scope:i}=Zu(n);throw new Error(`Event scope is not available in this component: ${i}`)}}),sc=()=>U.useContext(rc),Bm=n=>Lm(n);function km(n){return n?Bm(n):sc()}var Dm=(n,i)=>n===Oe?i:i===Oe?n:(...r)=>{n(...r),i(...r)},Nm=(n,i)=>n===Oe?i:i===Oe?n:(...r)=>{const a=n(...r),h=i(...r);return()=>{a(),h()}},Fm=(n,i)=>{const r=i.subscribe,a=i.flushSync;return{...n,...i,subscribe:Nm(n.subscribe,r??Oe),flushSync:Dm(n.flushSync,a??Oe)}},Um=({api:n,children:i,devToolsVisible:r=!0})=>(U.useEffect(()=>{if(!(!r||!n.subscribe))return cm.register(n)},[n,r]),Pe.jsx(rc.Provider,{value:n,children:i}));function Wm(n,i){function r(a){const h=U.useContext(n);if(!(a!=null&&a.optional)&&!h)throw new Error(`This component must be used within ${i}.`);return h}return r}function $m(n,i){function r(h){const f=n(h);return f?f[i]:null}function a(h){let f=!1,p;typeof h=="function"?p=h:h&&typeof h=="object"&&(f=!!h.optional,p=h.selector);const m=r({optional:f});return m?p?m(p):m():null}return{[i]:a,[`${i}Store`]:r}}var ic=U.createContext(null),qm=Wm(ic,"ThreadPrimitive.Viewport"),{useThreadViewportStore:zm}=$m(qm,"useThreadViewport"),Ve=n=>{const[,i]=ce(n.getState);return Dt(()=>(i(n.getState()),n.subscribe(()=>{i(n.getState())})),[n]),n.getState()},Hm=dt(({runtime:n})=>{const i=Ve(n),r=Ui();return Dt(()=>{const a=[],h=["switched-to","switched-away"];for(const f of h){const p=n.unstable_on(f,()=>{r.emit(`thread-list-item.${f}`,{threadId:n.getState().id})});a.push(p)}return()=>{for(const f of a)f()}},[n,r]),he({getState:()=>i,switchTo:n.switchTo,rename:n.rename,archive:n.archive,unarchive:n.unarchive,delete:n.delete,generateTitle:n.generateTitle,initialize:n.initialize,detach:n.detach,__internal_getRuntime:()=>n},{key:i.id})}),Kn=n=>{const i=pm(n);return{state:i.map(r=>r.state),api:r=>{var h,f;const a="index"in r?(h=i[r.index])==null?void 0:h.api:(f=i.find(p=>p.key===r.key))==null?void 0:f.api;if(!a)throw new Error(`tapLookupResources: Resource not found for lookup: ${JSON.stringify(r)}`);return a}}},oc=dt(({runtime:n})=>{const i=Ve(n);return he({getState:()=>i,remove:n.remove,__internal_getRuntime:()=>n},{key:i.id})}),Jm=dt(({runtime:n,index:i})=>{const r=rt(()=>n.getAttachmentByIndex(i),[n,i]);return se(oc({runtime:r}))}),ac=dt(({threadIdRef:n,messageIdRef:i,runtime:r})=>{const a=Ve(r),h=Ui();Dt(()=>{const m=[],w=["send","attachment-add"];for(const I of w){const P=r.unstable_on(I,()=>{h.emit(`composer.${I}`,{threadId:n.current,...i&&{messageId:i.current}})});m.push(P)}return()=>{for(const I of m)I()}},[r,h,n,i]);const f=Kn(a.attachments.map((m,w)=>Jm({runtime:r,index:w},{key:w}))),p=rt(()=>({text:a.text,role:a.role,attachments:f.state,runConfig:a.runConfig,isEditing:a.isEditing,canCancel:a.canCancel,attachmentAccept:a.attachmentAccept,isEmpty:a.isEmpty,type:a.type??"thread"}),[a,f.state]);return he({getState:()=>p,setText:r.setText,setRole:r.setRole,setRunConfig:r.setRunConfig,addAttachment:r.addAttachment,reset:r.reset,clearAttachments:r.clearAttachments,send:r.send,cancel:r.cancel,beginEdit:r.beginEdit??(()=>{throw new Error("beginEdit is not supported in this runtime")}),attachment:m=>"id"in m?f.api({key:m.id}):f.api(m),__internal_getRuntime:()=>r})}),Gm=dt(({runtime:n})=>{const i=Ve(n);return he({getState:()=>i,addToolResult:a=>n.addToolResult(a),resumeToolCall:a=>n.resumeToolCall(a),__internal_getRuntime:()=>n},{key:i.type==="tool-call"?`toolCallId-${i.toolCallId}`:void 0})}),Km=dt(({runtime:n,index:i})=>{const r=rt(()=>n.getAttachmentByIndex(i),[n,i]);return se(oc({runtime:r}))}),Ym=dt(({runtime:n,index:i})=>{const r=rt(()=>n.getMessagePartByIndex(i),[n,i]);return se(Gm({runtime:r}))}),Vm=dt(({runtime:n,threadIdRef:i})=>{var A;const r=Ve(n),[a,h]=ce(!1),[f,p]=ce(!1),m=rt(()=>({get current(){return n.getState().id}}),[n]),w=se(ac({runtime:n.composer,threadIdRef:i,messageIdRef:m})),I=Kn(r.content.map((R,K)=>Ym({runtime:n,index:K},{key:K}))),P=Kn(((A=r.attachments)==null?void 0:A.map((R,K)=>Km({runtime:n,index:K},{key:K})))??[]),C=rt(()=>({...r,parts:I.state,composer:w.state,isCopied:a,isHovering:f}),[r,I.state,w.state,a,f]);return he({getState:()=>C,composer:w.api,reload:R=>n.reload(R),speak:()=>n.speak(),stopSpeaking:()=>n.stopSpeaking(),submitFeedback:R=>n.submitFeedback(R),switchToBranch:R=>n.switchToBranch(R),getCopyText:()=>n.unstable_getCopyText(),part:R=>"index"in R?I.api({index:R.index}):I.api({key:`toolCallId-${R.toolCallId}`}),attachment:R=>"id"in R?P.api({key:R.id}):P.api(R),setIsCopied:h,setIsHovering:p,__internal_getRuntime:()=>n},{key:r.id})}),Zm=dt(({runtime:n,id:i,threadIdRef:r})=>{const a=rt(()=>n.getMessageById(i),[n,i]);return se(Vm({runtime:a,threadIdRef:r}))}),Xm=dt(({runtime:n})=>{const i=Ve(n),r=Ui();Dt(()=>{const m=[],w=["run-start","run-end","initialize","model-context-update"];for(const I of w){const P=n.unstable_on(I,()=>{var A;const C=((A=n.getState())==null?void 0:A.threadId)||"unknown";r.emit(`thread.${I}`,{threadId:C})});m.push(P)}return()=>{for(const I of m)I()}},[n]);const a=rt(()=>({get current(){return n.getState().threadId}}),[n]),h=se(ac({runtime:n.composer,threadIdRef:a})),f=Kn(i.messages.map(m=>Zm({runtime:n,id:m.id,threadIdRef:a},{key:m.id}))),p=rt(()=>({isDisabled:i.isDisabled,isLoading:i.isLoading,isRunning:i.isRunning,capabilities:i.capabilities,state:i.state,suggestions:i.suggestions,extras:i.extras,speech:i.speech,composer:h.state,messages:f.state}),[i,f,h.state]);return he({getState:()=>p,composer:h.api,append:n.append,startRun:n.startRun,unstable_resumeRun:n.unstable_resumeRun,cancelRun:n.cancelRun,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,startVoice:async()=>{throw new Error("startVoice is not supported in this runtime")},stopVoice:async()=>{throw new Error("stopVoice is not supported in this runtime")},message:m=>"id"in m?f.api({key:m.id}):f.api(m),__internal_getRuntime:()=>n})}),Qm=dt(({runtime:n,id:i})=>{const r=rt(()=>n.getItemById(i),[n,i]);return se(Hm({runtime:r}))}),jm=dt(({runtime:n,__internal_assistantRuntime:i})=>{const r=Ve(n),a=se(Xm({runtime:n.main})),h=Kn(Object.keys(r.threadItems).map(p=>Qm({runtime:n,id:p},{key:p}))),f=rt(()=>({mainThreadId:r.mainThreadId,newThreadId:r.newThread??null,isLoading:r.isLoading,threadIds:r.threads,archivedThreadIds:r.archivedThreads,threadItems:h.state,main:a.state}),[r,h.state,a.state]);return he({getState:()=>f,thread:()=>a.api,item:p=>{if(p==="main")return h.api({key:f.mainThreadId});if("id"in p)return h.api({key:p.id});const{index:m,archived:w=!1}=p,I=w?f.archivedThreadIds[m]:f.threadIds[m];return h.api({key:I})},switchToThread:p=>{n.switchToThread(p)},switchToNewThread:()=>{n.switchToNewThread()},__internal_getAssistantRuntime:()=>i})}),tv=dt(n=>{const i=ec();return Dt(()=>n.registerModelContextProvider(i),[n,i]),se(jm({runtime:n.threads,__internal_assistantRuntime:n}))}),Ai=n=>{const i=new Map,r=()=>{let a=0;for(const h of i.values())a+=h;n(a)};return{register:()=>{const a=Symbol();return i.set(a,0),{setHeight:h=>{i.get(a)!==h&&(i.set(a,h),r())},unregister:()=>{i.delete(a),r()}}}}},ev=(n={})=>{const i=new Set,r=Ai(p=>{f.setState({height:{...f.getState().height,viewport:p}})}),a=Ai(p=>{f.setState({height:{...f.getState().height,inset:p}})}),h=Ai(p=>{f.setState({height:{...f.getState().height,userMessage:p}})}),f=xm(()=>({isAtBottom:!0,scrollToBottom:({behavior:p="auto"}={})=>{for(const m of i)m({behavior:p})},onScrollToBottom:p=>(i.add(p),()=>{i.delete(p)}),turnAnchor:n.turnAnchor??"bottom",height:{viewport:0,inset:0,userMessage:0},registerViewport:r.register,registerContentInset:a.register,registerUserMessageHeight:h.register}));return f},Pu=n=>n,nv=n=>{const i=zm({optional:!0}),[r]=U.useState(()=>ev(n));return U.useEffect(()=>i==null?void 0:i.getState().onScrollToBottom(()=>{r.getState().scrollToBottom()}),[i,r]),U.useEffect(()=>{if(i)return r.subscribe(a=>{i.getState().isAtBottom!==a.isAtBottom&&Pu(i).setState({isAtBottom:a.isAtBottom})})},[r,i]),U.useEffect(()=>{const a={turnAnchor:n.turnAnchor??"bottom"};r.getState().turnAnchor!==a.turnAnchor&&Pu(r).setState(a)},[r,n.turnAnchor]),r},rv=({children:n,options:i={}})=>{const r=nv(i),[a]=U.useState(()=>({useThreadViewport:r}));return Pe.jsx(ic.Provider,{value:a,children:n})},sv=n=>{var i;return(i=n._core)==null?void 0:i.RenderComponent},iv=({children:n,runtime:i})=>{const r=km({threads:tv(i)}),a=sv(i);return Pe.jsxs(Um,{api:r,children:[a&&Pe.jsx(a,{}),Pe.jsx(rv,{children:n})]})},ov=U.memo(iv),av=class{constructor(n){S(this,"threads");S(this,"_thread");this._core=n,this.threads=new qb(n.threads),this._thread=this.threads.main,this.__internal_bindMethods()}get threadList(){return this.threads}__internal_bindMethods(){this.switchToNewThread=this.switchToNewThread.bind(this),this.switchToThread=this.switchToThread.bind(this),this.registerModelContextProvider=this.registerModelContextProvider.bind(this),this.registerModelConfigProvider=this.registerModelConfigProvider.bind(this),this.reset=this.reset.bind(this)}get thread(){return this._thread}switchToNewThread(){return this._core.threads.switchToNewThread()}switchToThread(n){return this._core.threads.switchToThread(n)}registerModelContextProvider(n){return this._core.registerModelContextProvider(n)}registerModelConfigProvider(n){return this.registerModelContextProvider(n)}reset({initialMessages:n}={}){return this._core.threads.getMainThreadRuntimeCore().import(Di.fromArray(n??[]))}};function uv(n){return n.filter(i=>i.finishReason==="stop"?i.text!==null&&i.text.trim()!=="":!0)}function Ou(n){const i=[];let r=null;for(const h of n)if(h.type!=="transaction")if(h.file){r&&(i.push(r),r=null),i.push(h);continue}else h.functionCalls?(r&&i.push(r),i.push(h),r=null):h.functionResponse?i[i.length-1]={...i[i.length-1],functionResponse:h.functionResponse}:r&&h.type===r.type&&h.protocol===r.protocol&&r.role===h.role?(r.text+=h.text,r.file=r.file||h.file):(r&&i.push(r),r={...h,text:h.file?"":h.text,finishReason:h.file?void 0:h.finishReason});return r&&i.push(r),uv(i)}function cv(n){var r;const i=n.file?[{type:"file",data:n.file.url,mimeType:n.file.contentType}]:[];return n.role==="function"?{id:n.id,role:"assistant",status:(n==null?void 0:n.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((r=n.functionCalls)==null?void 0:r.map(a=>{var h;return{type:"tool-call",toolName:a.name,toolCallId:a.id,args:a.args,result:(h=n.functionResponse)==null?void 0:h.result}}))??[]}:{id:n.id,role:n.role,content:n.type==="reasoning"?[{type:"reasoning",text:n.text},...i]:[{type:"text",text:n.text},...i]}}class Yn{constructor(){S(this,"statusChangeCallbacks",[]);S(this,"messageCallbacks",[])}addStatusChangeListener(i){this.statusChangeCallbacks.push(i)}addPacketListener(i){this.messageCallbacks.push(i)}async syncSession(i){this.session=i}async notifyPacket(i){this.messageCallbacks.forEach(r=>r(i))}async notifyPackets(i){i.forEach(r=>{this.messageCallbacks.forEach(a=>a(r))})}async setSession(i){this.session=i}async setStatus(i){const r=this.status!==i;this.status=i,r&&this.statusChangeCallbacks.forEach(a=>a(i))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(i){}}class Mi extends Yn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"notify",!0);S(this,"context",{});S(this,"tools",[]);this.config=r,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 100}async connect(r){return this.setStatus("connected"),r}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(r){this.session=r}async sendPacket(r){var w,I,P,C,A;const{apiUrl:a,apiKey:h,agentId:f}=this.config,p=this.session??"new";if(r.type==="command"&&((w=r==null?void 0:r.payload)==null?void 0:w.command)=="set_initial_context"){this.context=(I=r==null?void 0:r.payload)==null?void 0:I.arguments;return}else if(r.type==="command"&&((P=r==null?void 0:r.payload)==null?void 0:P.command)=="set_local_tools"){const R=(C=r==null?void 0:r.payload)==null?void 0:C.arguments.tools;(R==null?void 0:R.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const m=r.payload;try{const K=await(await fetch(`${a}/sessions/${p}/messages`,{body:JSON.stringify({agentId:f,userMessage:m,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":h}})).json();this.notifyPackets(K.response.messages.map(Tt=>({type:"message",payload:Tt})))}catch(R){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(A=this.config.logger)==null||A.error("Error sending packet:",R)}}}class Pi extends Yn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"webSocket");this.config=r,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(r){var a;(a=this.config.logger)==null||a.debug("Syncing session with WebSocket protocol:",r),this.session=r,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(r))}connect(r){var m;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const a=r||this.session||"new";(m=this.config.logger)==null||m.debug("Connecting to WebSocket with sessionId:",a);const h=encodeURIComponent(this.config.apiKey),f=this.config.agentId,p=`${this.config.webSocketUrl}?sessionCode=${a}&agentId=${f}&apiKey=${h}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(p),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",w=>{const I=JSON.parse(w.data);this.notifyPacket(I)}),this.webSocket.addEventListener("close",w=>{var I;this.setStatus("disconnected"),this.webSocket=null,w.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(I=this.config.logger)==null||I.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var w;this.setStatus("disconnected"),this.webSocket=null,(w=this.config.logger)==null||w.error("WebSocket connection error")}),Promise.resolve(a)}disconnect(){var r;return(r=this.config.logger)==null||r.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(r){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(r)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class hv{constructor(i){S(this,"config");S(this,"pc",null);S(this,"ws",null);S(this,"localStream",null);S(this,"remoteStream",new MediaStream);S(this,"audioCtx",null);S(this,"localAnalyser",null);S(this,"remoteAnalyser",null);S(this,"analyzerFrame",null);S(this,"dataChannel",null);S(this,"isConnected",!1);S(this,"visualizerCallbacks",[]);S(this,"messageCallbacks",[]);S(this,"errorCallbacks",[]);S(this,"queuedMessages",[]);this.config=i}async connect(i){var a;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(h){(a=this.config.logger)==null||a.error("Error accessing microphone:",h);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(h=>{this.pc.addTrack(h,this.localStream)}),this.pc.ontrack=h=>{h.streams[0].getTracks().forEach(p=>{this.remoteStream.addTrack(p)}),this.audioCtx||this._startAnalyzers();const f=new Audio;f.srcObject=this.remoteStream,f.play().catch(p=>{var m;(m=this.config.logger)==null||m.error("Error playing remote audio:",p)})},this.pc.onicecandidate=h=>{var f;h.candidate&&((f=this.ws)==null?void 0:f.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:h.candidate}}))},this.pc.ondatachannel=h=>{const f=h.channel;f.onmessage=p=>{this.messageCallbacks.forEach(m=>{m(p)})},f.onopen=()=>{var p;for(;this.queuedMessages.length>0;){const m=this.queuedMessages.shift();m&&(f.send(JSON.stringify(m)),(p=this.config.logger)==null||p.info("Sent queued message:",m))}}};const r=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${r}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var m,w;const h=await this.pc.createOffer();await this.pc.setLocalDescription(h);const f={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:i};(m=this.config.logger)==null||m.debug("Opening connection to WebRTC server: ",f);const p={type:"OFFER",src:((w=crypto.randomUUID)==null?void 0:w.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:h.sdp,type:h.type},connectionId:(Date.now()%1e6).toString(),metadata:f}};this.ws.send(JSON.stringify(p))},this.ws.onmessage=async h=>{var p;const f=JSON.parse(h.data);if(f.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(f.payload.sdp));else if(f.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(f.payload.candidate))}catch(m){(p=this.config.logger)==null||p.error("Error adding ICE candidate:",m)}},this.ws.onclose=h=>{h.code!==1e3&&this.errorCallbacks.forEach(f=>{f("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var i;this.isConnected&&(this.isConnected=!1,((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(r=>r.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(i){this.visualizerCallbacks.push(i)}addMessageCallback(i){this.messageCallbacks.push(i)}addErrorCallback(i){this.errorCallbacks.push(i)}createDataChannel(i="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(i),this.dataChannel.onopen=()=>{var r,a;for((r=this.config.logger)==null||r.info("Data channel opened");this.queuedMessages.length>0;){const h=this.queuedMessages.shift();h&&(this.dataChannel.send(JSON.stringify(h)),(a=this.config.logger)==null||a.info("Sent queued message:",h))}},this.dataChannel.onmessage=r=>{this.messageCallbacks.forEach(a=>{a(r)})})}sendPacket(i){var r;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(i);return}this.dataChannel.send(JSON.stringify(i)),(r=this.config.logger)==null||r.info("Sent message:",i)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const i=this.audioCtx.createMediaStreamSource(this.localStream),r=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,i.connect(this.localAnalyser),r.connect(this.remoteAnalyser);const a=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const h=new Uint8Array(this.localAnalyser.frequencyBinCount),f=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(h),this.remoteAnalyser.getByteFrequencyData(f);const p=h.reduce((w,I)=>w+I,0)/h.length,m=f.reduce((w,I)=>w+I,0)/f.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(w=>{w({localAmplitude:p,remoteAmplitude:m})}),this.analyzerFrame=requestAnimationFrame(a)};this.analyzerFrame=requestAnimationFrame(a)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class Oi extends Yn{constructor(r){super();S(this,"status");S(this,"session");S(this,"autostart");S(this,"config");S(this,"webRTCClient");this.config=r,this.status="disconnected",this.session=null,this.autostart=(r==null?void 0:r.autostart)??!1,this.webRTCClient=new hv(r),this.webRTCClient.addMessageCallback(a=>{const h=JSON.parse(a.data);this.notifyPacket(h)}),this.webRTCClient.addErrorCallback(a=>{var h;(h=this.config.logger)==null||h.error("WebRTC error:",a),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:a}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(r){super.syncSession(r),this.status==="connected"&&(await this.disconnect(),await this.connect(r))}async connect(r){var a;return this.status==="connected"?Promise.resolve(this.session):(this.session=r||this.session||"new",this.setStatus("connecting"),(a=this.config.logger)==null||a.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 r,a,h;if(this.status==="disconnected")return(r=this.config.logger)==null||r.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(h=(a=this.config)==null?void 0:a.logger)==null||h.debug("Disconnected from WebRTC")}sendPacket(r){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(r),Promise.resolve())}}var Zr={exports:{}};/**
10
14
  * @license
11
15
  * Lodash <https://lodash.com/>
12
16
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
13
17
  * Released under MIT license <https://lodash.com/license>
14
18
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
15
19
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
16
- */wr.exports;(function(y,g){(function(){var i,w="4.17.21",m=200,C="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",b="Expected a function",I="Invalid `variable` option passed into `_.template`",q="__lodash_hash_undefined__",tn=500,Cn="__lodash_placeholder__",en=1,bn=2,hn=4,Rn=1,ct=2,wn=1,mn=2,Ae=4,kn=8,St=16,zn=32,At=64,F=128,nn=256,z=512,Wn=30,rn="...",Mn=800,X=16,gn=1,Io=2,Lo=3,Ct=1/0,ht=9007199254740991,Oo=17976931348623157e292,Ce=NaN,Qn=4294967295,Wo=Qn-1,Mo=Qn>>>1,Fo=[["ary",F],["bind",wn],["bindKey",mn],["curry",kn],["curryRight",St],["flip",z],["partial",zn],["partialRight",At],["rearg",nn]],Ft="[object Arguments]",be="[object Array]",Uo="[object AsyncFunction]",Qt="[object Boolean]",Vt="[object Date]",Do="[object DOMException]",Re="[object Error]",Te="[object Function]",Hi="[object GeneratorFunction]",Hn="[object Map]",jt="[object Number]",No="[object Null]",tt="[object Object]",Ki="[object Promise]",Bo="[object Proxy]",ne="[object RegExp]",Kn="[object Set]",te="[object String]",Pe="[object Symbol]",$o="[object Undefined]",ee="[object WeakMap]",qo="[object WeakSet]",re="[object ArrayBuffer]",Ut="[object DataView]",yr="[object Float32Array]",xr="[object Float64Array]",Sr="[object Int8Array]",Ar="[object Int16Array]",Cr="[object Int32Array]",br="[object Uint8Array]",Rr="[object Uint8ClampedArray]",Tr="[object Uint16Array]",Pr="[object Uint32Array]",Go=/\b__p \+= '';/g,ko=/\b(__p \+=) '' \+/g,zo=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ji=/&(?:amp|lt|gt|quot|#39);/g,Yi=/[&<>"']/g,Ho=RegExp(Ji.source),Ko=RegExp(Yi.source),Jo=/<%-([\s\S]+?)%>/g,Yo=/<%([\s\S]+?)%>/g,Zi=/<%=([\s\S]+?)%>/g,Zo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Xo=/^\w*$/,Qo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Er=/[\\^$.*+?()[\]{}|]/g,Vo=RegExp(Er.source),Ir=/^\s+/,jo=/\s/,na=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ta=/\{\n\/\* \[wrapped with (.+)\] \*/,ea=/,? & /,ra=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ia=/[()=,{}\[\]\/\s]/,ua=/\\(\\)?/g,sa=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Xi=/\w*$/,oa=/^[-+]0x[0-9a-f]+$/i,aa=/^0b[01]+$/i,fa=/^\[object .+?Constructor\]$/,la=/^0o[0-7]+$/i,ca=/^(?:0|[1-9]\d*)$/,ha=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ee=/($^)/,ga=/['\n\r\u2028\u2029\\]/g,Ie="\\ud800-\\udfff",pa="\\u0300-\\u036f",da="\\ufe20-\\ufe2f",_a="\\u20d0-\\u20ff",Qi=pa+da+_a,Vi="\\u2700-\\u27bf",ji="a-z\\xdf-\\xf6\\xf8-\\xff",va="\\xac\\xb1\\xd7\\xf7",wa="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ma="\\u2000-\\u206f",ya=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",nu="A-Z\\xc0-\\xd6\\xd8-\\xde",tu="\\ufe0e\\ufe0f",eu=va+wa+ma+ya,Lr="['’]",xa="["+Ie+"]",ru="["+eu+"]",Le="["+Qi+"]",iu="\\d+",Sa="["+Vi+"]",uu="["+ji+"]",su="[^"+Ie+eu+iu+Vi+ji+nu+"]",Or="\\ud83c[\\udffb-\\udfff]",Aa="(?:"+Le+"|"+Or+")",ou="[^"+Ie+"]",Wr="(?:\\ud83c[\\udde6-\\uddff]){2}",Mr="[\\ud800-\\udbff][\\udc00-\\udfff]",Dt="["+nu+"]",au="\\u200d",fu="(?:"+uu+"|"+su+")",Ca="(?:"+Dt+"|"+su+")",lu="(?:"+Lr+"(?:d|ll|m|re|s|t|ve))?",cu="(?:"+Lr+"(?:D|LL|M|RE|S|T|VE))?",hu=Aa+"?",gu="["+tu+"]?",ba="(?:"+au+"(?:"+[ou,Wr,Mr].join("|")+")"+gu+hu+")*",Ra="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ta="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",pu=gu+hu+ba,Pa="(?:"+[Sa,Wr,Mr].join("|")+")"+pu,Ea="(?:"+[ou+Le+"?",Le,Wr,Mr,xa].join("|")+")",Ia=RegExp(Lr,"g"),La=RegExp(Le,"g"),Fr=RegExp(Or+"(?="+Or+")|"+Ea+pu,"g"),Oa=RegExp([Dt+"?"+uu+"+"+lu+"(?="+[ru,Dt,"$"].join("|")+")",Ca+"+"+cu+"(?="+[ru,Dt+fu,"$"].join("|")+")",Dt+"?"+fu+"+"+lu,Dt+"+"+cu,Ta,Ra,iu,Pa].join("|"),"g"),Wa=RegExp("["+au+Ie+Qi+tu+"]"),Ma=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fa=["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"],Ua=-1,J={};J[yr]=J[xr]=J[Sr]=J[Ar]=J[Cr]=J[br]=J[Rr]=J[Tr]=J[Pr]=!0,J[Ft]=J[be]=J[re]=J[Qt]=J[Ut]=J[Vt]=J[Re]=J[Te]=J[Hn]=J[jt]=J[tt]=J[ne]=J[Kn]=J[te]=J[ee]=!1;var K={};K[Ft]=K[be]=K[re]=K[Ut]=K[Qt]=K[Vt]=K[yr]=K[xr]=K[Sr]=K[Ar]=K[Cr]=K[Hn]=K[jt]=K[tt]=K[ne]=K[Kn]=K[te]=K[Pe]=K[br]=K[Rr]=K[Tr]=K[Pr]=!0,K[Re]=K[Te]=K[ee]=!1;var Da={À:"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"},Na={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ba={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},$a={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},qa=parseFloat,Ga=parseInt,du=typeof me=="object"&&me&&me.Object===Object&&me,ka=typeof self=="object"&&self&&self.Object===Object&&self,an=du||ka||Function("return this")(),Ur=g&&!g.nodeType&&g,bt=Ur&&!0&&y&&!y.nodeType&&y,_u=bt&&bt.exports===Ur,Dr=_u&&du.process,Fn=function(){try{var l=bt&&bt.require&&bt.require("util").types;return l||Dr&&Dr.binding&&Dr.binding("util")}catch{}}(),vu=Fn&&Fn.isArrayBuffer,wu=Fn&&Fn.isDate,mu=Fn&&Fn.isMap,yu=Fn&&Fn.isRegExp,xu=Fn&&Fn.isSet,Su=Fn&&Fn.isTypedArray;function Tn(l,p,h){switch(h.length){case 0:return l.call(p);case 1:return l.call(p,h[0]);case 2:return l.call(p,h[0],h[1]);case 3:return l.call(p,h[0],h[1],h[2])}return l.apply(p,h)}function za(l,p,h,S){for(var L=-1,$=l==null?0:l.length;++L<$;){var un=l[L];p(S,un,h(un),l)}return S}function Un(l,p){for(var h=-1,S=l==null?0:l.length;++h<S&&p(l[h],h,l)!==!1;);return l}function Ha(l,p){for(var h=l==null?0:l.length;h--&&p(l[h],h,l)!==!1;);return l}function Au(l,p){for(var h=-1,S=l==null?0:l.length;++h<S;)if(!p(l[h],h,l))return!1;return!0}function gt(l,p){for(var h=-1,S=l==null?0:l.length,L=0,$=[];++h<S;){var un=l[h];p(un,h,l)&&($[L++]=un)}return $}function Oe(l,p){var h=l==null?0:l.length;return!!h&&Nt(l,p,0)>-1}function Nr(l,p,h){for(var S=-1,L=l==null?0:l.length;++S<L;)if(h(p,l[S]))return!0;return!1}function Y(l,p){for(var h=-1,S=l==null?0:l.length,L=Array(S);++h<S;)L[h]=p(l[h],h,l);return L}function pt(l,p){for(var h=-1,S=p.length,L=l.length;++h<S;)l[L+h]=p[h];return l}function Br(l,p,h,S){var L=-1,$=l==null?0:l.length;for(S&&$&&(h=l[++L]);++L<$;)h=p(h,l[L],L,l);return h}function Ka(l,p,h,S){var L=l==null?0:l.length;for(S&&L&&(h=l[--L]);L--;)h=p(h,l[L],L,l);return h}function $r(l,p){for(var h=-1,S=l==null?0:l.length;++h<S;)if(p(l[h],h,l))return!0;return!1}var Ja=qr("length");function Ya(l){return l.split("")}function Za(l){return l.match(ra)||[]}function Cu(l,p,h){var S;return h(l,function(L,$,un){if(p(L,$,un))return S=$,!1}),S}function We(l,p,h,S){for(var L=l.length,$=h+(S?1:-1);S?$--:++$<L;)if(p(l[$],$,l))return $;return-1}function Nt(l,p,h){return p===p?af(l,p,h):We(l,bu,h)}function Xa(l,p,h,S){for(var L=h-1,$=l.length;++L<$;)if(S(l[L],p))return L;return-1}function bu(l){return l!==l}function Ru(l,p){var h=l==null?0:l.length;return h?kr(l,p)/h:Ce}function qr(l){return function(p){return p==null?i:p[l]}}function Gr(l){return function(p){return l==null?i:l[p]}}function Tu(l,p,h,S,L){return L(l,function($,un,H){h=S?(S=!1,$):p(h,$,un,H)}),h}function Qa(l,p){var h=l.length;for(l.sort(p);h--;)l[h]=l[h].value;return l}function kr(l,p){for(var h,S=-1,L=l.length;++S<L;){var $=p(l[S]);$!==i&&(h=h===i?$:h+$)}return h}function zr(l,p){for(var h=-1,S=Array(l);++h<l;)S[h]=p(h);return S}function Va(l,p){return Y(p,function(h){return[h,l[h]]})}function Pu(l){return l&&l.slice(0,Ou(l)+1).replace(Ir,"")}function Pn(l){return function(p){return l(p)}}function Hr(l,p){return Y(p,function(h){return l[h]})}function ie(l,p){return l.has(p)}function Eu(l,p){for(var h=-1,S=l.length;++h<S&&Nt(p,l[h],0)>-1;);return h}function Iu(l,p){for(var h=l.length;h--&&Nt(p,l[h],0)>-1;);return h}function ja(l,p){for(var h=l.length,S=0;h--;)l[h]===p&&++S;return S}var nf=Gr(Da),tf=Gr(Na);function ef(l){return"\\"+$a[l]}function rf(l,p){return l==null?i:l[p]}function Bt(l){return Wa.test(l)}function uf(l){return Ma.test(l)}function sf(l){for(var p,h=[];!(p=l.next()).done;)h.push(p.value);return h}function Kr(l){var p=-1,h=Array(l.size);return l.forEach(function(S,L){h[++p]=[L,S]}),h}function Lu(l,p){return function(h){return l(p(h))}}function dt(l,p){for(var h=-1,S=l.length,L=0,$=[];++h<S;){var un=l[h];(un===p||un===Cn)&&(l[h]=Cn,$[L++]=h)}return $}function Me(l){var p=-1,h=Array(l.size);return l.forEach(function(S){h[++p]=S}),h}function of(l){var p=-1,h=Array(l.size);return l.forEach(function(S){h[++p]=[S,S]}),h}function af(l,p,h){for(var S=h-1,L=l.length;++S<L;)if(l[S]===p)return S;return-1}function ff(l,p,h){for(var S=h+1;S--;)if(l[S]===p)return S;return S}function $t(l){return Bt(l)?cf(l):Ja(l)}function Jn(l){return Bt(l)?hf(l):Ya(l)}function Ou(l){for(var p=l.length;p--&&jo.test(l.charAt(p)););return p}var lf=Gr(Ba);function cf(l){for(var p=Fr.lastIndex=0;Fr.test(l);)++p;return p}function hf(l){return l.match(Fr)||[]}function gf(l){return l.match(Oa)||[]}var pf=function l(p){p=p==null?an:qt.defaults(an.Object(),p,qt.pick(an,Fa));var h=p.Array,S=p.Date,L=p.Error,$=p.Function,un=p.Math,H=p.Object,Jr=p.RegExp,df=p.String,Dn=p.TypeError,Fe=h.prototype,_f=$.prototype,Gt=H.prototype,Ue=p["__core-js_shared__"],De=_f.toString,k=Gt.hasOwnProperty,vf=0,Wu=function(){var n=/[^.]+$/.exec(Ue&&Ue.keys&&Ue.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),Ne=Gt.toString,wf=De.call(H),mf=an._,yf=Jr("^"+De.call(k).replace(Er,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Be=_u?p.Buffer:i,_t=p.Symbol,$e=p.Uint8Array,Mu=Be?Be.allocUnsafe:i,qe=Lu(H.getPrototypeOf,H),Fu=H.create,Uu=Gt.propertyIsEnumerable,Ge=Fe.splice,Du=_t?_t.isConcatSpreadable:i,ue=_t?_t.iterator:i,Rt=_t?_t.toStringTag:i,ke=function(){try{var n=Lt(H,"defineProperty");return n({},"",{}),n}catch{}}(),xf=p.clearTimeout!==an.clearTimeout&&p.clearTimeout,Sf=S&&S.now!==an.Date.now&&S.now,Af=p.setTimeout!==an.setTimeout&&p.setTimeout,ze=un.ceil,He=un.floor,Yr=H.getOwnPropertySymbols,Cf=Be?Be.isBuffer:i,Nu=p.isFinite,bf=Fe.join,Rf=Lu(H.keys,H),sn=un.max,ln=un.min,Tf=S.now,Pf=p.parseInt,Bu=un.random,Ef=Fe.reverse,Zr=Lt(p,"DataView"),se=Lt(p,"Map"),Xr=Lt(p,"Promise"),kt=Lt(p,"Set"),oe=Lt(p,"WeakMap"),ae=Lt(H,"create"),Ke=oe&&new oe,zt={},If=Ot(Zr),Lf=Ot(se),Of=Ot(Xr),Wf=Ot(kt),Mf=Ot(oe),Je=_t?_t.prototype:i,fe=Je?Je.valueOf:i,$u=Je?Je.toString:i;function s(n){if(Q(n)&&!O(n)&&!(n instanceof N)){if(n instanceof Nn)return n;if(k.call(n,"__wrapped__"))return qs(n)}return new Nn(n)}var Ht=function(){function n(){}return function(t){if(!Z(t))return{};if(Fu)return Fu(t);n.prototype=t;var e=new n;return n.prototype=i,e}}();function Ye(){}function Nn(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}s.templateSettings={escape:Jo,evaluate:Yo,interpolate:Zi,variable:"",imports:{_:s}},s.prototype=Ye.prototype,s.prototype.constructor=s,Nn.prototype=Ht(Ye.prototype),Nn.prototype.constructor=Nn;function N(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Qn,this.__views__=[]}function Ff(){var n=new N(this.__wrapped__);return n.__actions__=yn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=yn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=yn(this.__views__),n}function Uf(){if(this.__filtered__){var n=new N(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function Df(){var n=this.__wrapped__.value(),t=this.__dir__,e=O(n),r=t<0,u=e?n.length:0,o=Zl(0,u,this.__views__),a=o.start,f=o.end,c=f-a,d=r?f:a-1,_=this.__iteratees__,v=_.length,x=0,A=ln(c,this.__takeCount__);if(!e||!r&&u==c&&A==c)return ls(n,this.__actions__);var T=[];n:for(;c--&&x<A;){d+=t;for(var M=-1,P=n[d];++M<v;){var D=_[M],B=D.iteratee,Ln=D.type,_n=B(P);if(Ln==Io)P=_n;else if(!_n){if(Ln==gn)continue n;break n}}T[x++]=P}return T}N.prototype=Ht(Ye.prototype),N.prototype.constructor=N;function Tt(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function Nf(){this.__data__=ae?ae(null):{},this.size=0}function Bf(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}function $f(n){var t=this.__data__;if(ae){var e=t[n];return e===q?i:e}return k.call(t,n)?t[n]:i}function qf(n){var t=this.__data__;return ae?t[n]!==i:k.call(t,n)}function Gf(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=ae&&t===i?q:t,this}Tt.prototype.clear=Nf,Tt.prototype.delete=Bf,Tt.prototype.get=$f,Tt.prototype.has=qf,Tt.prototype.set=Gf;function et(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function kf(){this.__data__=[],this.size=0}function zf(n){var t=this.__data__,e=Ze(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():Ge.call(t,e,1),--this.size,!0}function Hf(n){var t=this.__data__,e=Ze(t,n);return e<0?i:t[e][1]}function Kf(n){return Ze(this.__data__,n)>-1}function Jf(n,t){var e=this.__data__,r=Ze(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}et.prototype.clear=kf,et.prototype.delete=zf,et.prototype.get=Hf,et.prototype.has=Kf,et.prototype.set=Jf;function rt(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function Yf(){this.size=0,this.__data__={hash:new Tt,map:new(se||et),string:new Tt}}function Zf(n){var t=or(this,n).delete(n);return this.size-=t?1:0,t}function Xf(n){return or(this,n).get(n)}function Qf(n){return or(this,n).has(n)}function Vf(n,t){var e=or(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}rt.prototype.clear=Yf,rt.prototype.delete=Zf,rt.prototype.get=Xf,rt.prototype.has=Qf,rt.prototype.set=Vf;function Pt(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new rt;++t<e;)this.add(n[t])}function jf(n){return this.__data__.set(n,q),this}function nl(n){return this.__data__.has(n)}Pt.prototype.add=Pt.prototype.push=jf,Pt.prototype.has=nl;function Yn(n){var t=this.__data__=new et(n);this.size=t.size}function tl(){this.__data__=new et,this.size=0}function el(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}function rl(n){return this.__data__.get(n)}function il(n){return this.__data__.has(n)}function ul(n,t){var e=this.__data__;if(e instanceof et){var r=e.__data__;if(!se||r.length<m-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new rt(r)}return e.set(n,t),this.size=e.size,this}Yn.prototype.clear=tl,Yn.prototype.delete=el,Yn.prototype.get=rl,Yn.prototype.has=il,Yn.prototype.set=ul;function qu(n,t){var e=O(n),r=!e&&Wt(n),u=!e&&!r&&xt(n),o=!e&&!r&&!u&&Zt(n),a=e||r||u||o,f=a?zr(n.length,df):[],c=f.length;for(var d in n)(t||k.call(n,d))&&!(a&&(d=="length"||u&&(d=="offset"||d=="parent")||o&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||ot(d,c)))&&f.push(d);return f}function Gu(n){var t=n.length;return t?n[oi(0,t-1)]:i}function sl(n,t){return ar(yn(n),Et(t,0,n.length))}function ol(n){return ar(yn(n))}function Qr(n,t,e){(e!==i&&!Zn(n[t],e)||e===i&&!(t in n))&&it(n,t,e)}function le(n,t,e){var r=n[t];(!(k.call(n,t)&&Zn(r,e))||e===i&&!(t in n))&&it(n,t,e)}function Ze(n,t){for(var e=n.length;e--;)if(Zn(n[e][0],t))return e;return-1}function al(n,t,e,r){return vt(n,function(u,o,a){t(r,u,e(u),a)}),r}function ku(n,t){return n&&jn(t,on(t),n)}function fl(n,t){return n&&jn(t,Sn(t),n)}function it(n,t,e){t=="__proto__"&&ke?ke(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function Vr(n,t){for(var e=-1,r=t.length,u=h(r),o=n==null;++e<r;)u[e]=o?i:Oi(n,t[e]);return u}function Et(n,t,e){return n===n&&(e!==i&&(n=n<=e?n:e),t!==i&&(n=n>=t?n:t)),n}function Bn(n,t,e,r,u,o){var a,f=t&en,c=t&bn,d=t&hn;if(e&&(a=u?e(n,r,u,o):e(n)),a!==i)return a;if(!Z(n))return n;var _=O(n);if(_){if(a=Ql(n),!f)return yn(n,a)}else{var v=cn(n),x=v==Te||v==Hi;if(xt(n))return gs(n,f);if(v==tt||v==Ft||x&&!u){if(a=c||x?{}:Os(n),!f)return c?$l(n,fl(a,n)):Bl(n,ku(a,n))}else{if(!K[v])return u?n:{};a=Vl(n,v,f)}}o||(o=new Yn);var A=o.get(n);if(A)return A;o.set(n,a),oo(n)?n.forEach(function(P){a.add(Bn(P,t,e,P,n,o))}):uo(n)&&n.forEach(function(P,D){a.set(D,Bn(P,t,e,D,n,o))});var T=d?c?wi:vi:c?Sn:on,M=_?i:T(n);return Un(M||n,function(P,D){M&&(D=P,P=n[D]),le(a,D,Bn(P,t,e,D,n,o))}),a}function ll(n){var t=on(n);return function(e){return zu(e,n,t)}}function zu(n,t,e){var r=e.length;if(n==null)return!r;for(n=H(n);r--;){var u=e[r],o=t[u],a=n[u];if(a===i&&!(u in n)||!o(a))return!1}return!0}function Hu(n,t,e){if(typeof n!="function")throw new Dn(b);return ve(function(){n.apply(i,e)},t)}function ce(n,t,e,r){var u=-1,o=Oe,a=!0,f=n.length,c=[],d=t.length;if(!f)return c;e&&(t=Y(t,Pn(e))),r?(o=Nr,a=!1):t.length>=m&&(o=ie,a=!1,t=new Pt(t));n:for(;++u<f;){var _=n[u],v=e==null?_:e(_);if(_=r||_!==0?_:0,a&&v===v){for(var x=d;x--;)if(t[x]===v)continue n;c.push(_)}else o(t,v,r)||c.push(_)}return c}var vt=ws(Vn),Ku=ws(ni,!0);function cl(n,t){var e=!0;return vt(n,function(r,u,o){return e=!!t(r,u,o),e}),e}function Xe(n,t,e){for(var r=-1,u=n.length;++r<u;){var o=n[r],a=t(o);if(a!=null&&(f===i?a===a&&!In(a):e(a,f)))var f=a,c=o}return c}function hl(n,t,e,r){var u=n.length;for(e=W(e),e<0&&(e=-e>u?0:u+e),r=r===i||r>u?u:W(r),r<0&&(r+=u),r=e>r?0:fo(r);e<r;)n[e++]=t;return n}function Ju(n,t){var e=[];return vt(n,function(r,u,o){t(r,u,o)&&e.push(r)}),e}function fn(n,t,e,r,u){var o=-1,a=n.length;for(e||(e=nc),u||(u=[]);++o<a;){var f=n[o];t>0&&e(f)?t>1?fn(f,t-1,e,r,u):pt(u,f):r||(u[u.length]=f)}return u}var jr=ms(),Yu=ms(!0);function Vn(n,t){return n&&jr(n,t,on)}function ni(n,t){return n&&Yu(n,t,on)}function Qe(n,t){return gt(t,function(e){return at(n[e])})}function It(n,t){t=mt(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[nt(t[e++])];return e&&e==r?n:i}function Zu(n,t,e){var r=t(n);return O(n)?r:pt(r,e(n))}function pn(n){return n==null?n===i?$o:No:Rt&&Rt in H(n)?Yl(n):oc(n)}function ti(n,t){return n>t}function gl(n,t){return n!=null&&k.call(n,t)}function pl(n,t){return n!=null&&t in H(n)}function dl(n,t,e){return n>=ln(t,e)&&n<sn(t,e)}function ei(n,t,e){for(var r=e?Nr:Oe,u=n[0].length,o=n.length,a=o,f=h(o),c=1/0,d=[];a--;){var _=n[a];a&&t&&(_=Y(_,Pn(t))),c=ln(_.length,c),f[a]=!e&&(t||u>=120&&_.length>=120)?new Pt(a&&_):i}_=n[0];var v=-1,x=f[0];n:for(;++v<u&&d.length<c;){var A=_[v],T=t?t(A):A;if(A=e||A!==0?A:0,!(x?ie(x,T):r(d,T,e))){for(a=o;--a;){var M=f[a];if(!(M?ie(M,T):r(n[a],T,e)))continue n}x&&x.push(T),d.push(A)}}return d}function _l(n,t,e,r){return Vn(n,function(u,o,a){t(r,e(u),o,a)}),r}function he(n,t,e){t=mt(t,n),n=Us(n,t);var r=n==null?n:n[nt(qn(t))];return r==null?i:Tn(r,n,e)}function Xu(n){return Q(n)&&pn(n)==Ft}function vl(n){return Q(n)&&pn(n)==re}function wl(n){return Q(n)&&pn(n)==Vt}function ge(n,t,e,r,u){return n===t?!0:n==null||t==null||!Q(n)&&!Q(t)?n!==n&&t!==t:ml(n,t,e,r,ge,u)}function ml(n,t,e,r,u,o){var a=O(n),f=O(t),c=a?be:cn(n),d=f?be:cn(t);c=c==Ft?tt:c,d=d==Ft?tt:d;var _=c==tt,v=d==tt,x=c==d;if(x&&xt(n)){if(!xt(t))return!1;a=!0,_=!1}if(x&&!_)return o||(o=new Yn),a||Zt(n)?Es(n,t,e,r,u,o):Kl(n,t,c,e,r,u,o);if(!(e&Rn)){var A=_&&k.call(n,"__wrapped__"),T=v&&k.call(t,"__wrapped__");if(A||T){var M=A?n.value():n,P=T?t.value():t;return o||(o=new Yn),u(M,P,e,r,o)}}return x?(o||(o=new Yn),Jl(n,t,e,r,u,o)):!1}function yl(n){return Q(n)&&cn(n)==Hn}function ri(n,t,e,r){var u=e.length,o=u,a=!r;if(n==null)return!o;for(n=H(n);u--;){var f=e[u];if(a&&f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++u<o;){f=e[u];var c=f[0],d=n[c],_=f[1];if(a&&f[2]){if(d===i&&!(c in n))return!1}else{var v=new Yn;if(r)var x=r(d,_,c,n,t,v);if(!(x===i?ge(_,d,Rn|ct,r,v):x))return!1}}return!0}function Qu(n){if(!Z(n)||ec(n))return!1;var t=at(n)?yf:fa;return t.test(Ot(n))}function xl(n){return Q(n)&&pn(n)==ne}function Sl(n){return Q(n)&&cn(n)==Kn}function Al(n){return Q(n)&&pr(n.length)&&!!J[pn(n)]}function Vu(n){return typeof n=="function"?n:n==null?An:typeof n=="object"?O(n)?ts(n[0],n[1]):ns(n):xo(n)}function ii(n){if(!_e(n))return Rf(n);var t=[];for(var e in H(n))k.call(n,e)&&e!="constructor"&&t.push(e);return t}function Cl(n){if(!Z(n))return sc(n);var t=_e(n),e=[];for(var r in n)r=="constructor"&&(t||!k.call(n,r))||e.push(r);return e}function ui(n,t){return n<t}function ju(n,t){var e=-1,r=xn(n)?h(n.length):[];return vt(n,function(u,o,a){r[++e]=t(u,o,a)}),r}function ns(n){var t=yi(n);return t.length==1&&t[0][2]?Ms(t[0][0],t[0][1]):function(e){return e===n||ri(e,n,t)}}function ts(n,t){return Si(n)&&Ws(t)?Ms(nt(n),t):function(e){var r=Oi(e,n);return r===i&&r===t?Wi(e,n):ge(t,r,Rn|ct)}}function Ve(n,t,e,r,u){n!==t&&jr(t,function(o,a){if(u||(u=new Yn),Z(o))bl(n,t,a,e,Ve,r,u);else{var f=r?r(Ci(n,a),o,a+"",n,t,u):i;f===i&&(f=o),Qr(n,a,f)}},Sn)}function bl(n,t,e,r,u,o,a){var f=Ci(n,e),c=Ci(t,e),d=a.get(c);if(d){Qr(n,e,d);return}var _=o?o(f,c,e+"",n,t,a):i,v=_===i;if(v){var x=O(c),A=!x&&xt(c),T=!x&&!A&&Zt(c);_=c,x||A||T?O(f)?_=f:V(f)?_=yn(f):A?(v=!1,_=gs(c,!0)):T?(v=!1,_=ps(c,!0)):_=[]:we(c)||Wt(c)?(_=f,Wt(f)?_=lo(f):(!Z(f)||at(f))&&(_=Os(c))):v=!1}v&&(a.set(c,_),u(_,c,r,o,a),a.delete(c)),Qr(n,e,_)}function es(n,t){var e=n.length;if(e)return t+=t<0?e:0,ot(t,e)?n[t]:i}function rs(n,t,e){t.length?t=Y(t,function(o){return O(o)?function(a){return It(a,o.length===1?o[0]:o)}:o}):t=[An];var r=-1;t=Y(t,Pn(R()));var u=ju(n,function(o,a,f){var c=Y(t,function(d){return d(o)});return{criteria:c,index:++r,value:o}});return Qa(u,function(o,a){return Nl(o,a,e)})}function Rl(n,t){return is(n,t,function(e,r){return Wi(n,r)})}function is(n,t,e){for(var r=-1,u=t.length,o={};++r<u;){var a=t[r],f=It(n,a);e(f,a)&&pe(o,mt(a,n),f)}return o}function Tl(n){return function(t){return It(t,n)}}function si(n,t,e,r){var u=r?Xa:Nt,o=-1,a=t.length,f=n;for(n===t&&(t=yn(t)),e&&(f=Y(n,Pn(e)));++o<a;)for(var c=0,d=t[o],_=e?e(d):d;(c=u(f,_,c,r))>-1;)f!==n&&Ge.call(f,c,1),Ge.call(n,c,1);return n}function us(n,t){for(var e=n?t.length:0,r=e-1;e--;){var u=t[e];if(e==r||u!==o){var o=u;ot(u)?Ge.call(n,u,1):li(n,u)}}return n}function oi(n,t){return n+He(Bu()*(t-n+1))}function Pl(n,t,e,r){for(var u=-1,o=sn(ze((t-n)/(e||1)),0),a=h(o);o--;)a[r?o:++u]=n,n+=e;return a}function ai(n,t){var e="";if(!n||t<1||t>ht)return e;do t%2&&(e+=n),t=He(t/2),t&&(n+=n);while(t);return e}function U(n,t){return bi(Fs(n,t,An),n+"")}function El(n){return Gu(Xt(n))}function Il(n,t){var e=Xt(n);return ar(e,Et(t,0,e.length))}function pe(n,t,e,r){if(!Z(n))return n;t=mt(t,n);for(var u=-1,o=t.length,a=o-1,f=n;f!=null&&++u<o;){var c=nt(t[u]),d=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(u!=a){var _=f[c];d=r?r(_,c,f):i,d===i&&(d=Z(_)?_:ot(t[u+1])?[]:{})}le(f,c,d),f=f[c]}return n}var ss=Ke?function(n,t){return Ke.set(n,t),n}:An,Ll=ke?function(n,t){return ke(n,"toString",{configurable:!0,enumerable:!1,value:Fi(t),writable:!0})}:An;function Ol(n){return ar(Xt(n))}function $n(n,t,e){var r=-1,u=n.length;t<0&&(t=-t>u?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=h(u);++r<u;)o[r]=n[r+t];return o}function Wl(n,t){var e;return vt(n,function(r,u,o){return e=t(r,u,o),!e}),!!e}function je(n,t,e){var r=0,u=n==null?r:n.length;if(typeof t=="number"&&t===t&&u<=Mo){for(;r<u;){var o=r+u>>>1,a=n[o];a!==null&&!In(a)&&(e?a<=t:a<t)?r=o+1:u=o}return u}return fi(n,t,An,e)}function fi(n,t,e,r){var u=0,o=n==null?0:n.length;if(o===0)return 0;t=e(t);for(var a=t!==t,f=t===null,c=In(t),d=t===i;u<o;){var _=He((u+o)/2),v=e(n[_]),x=v!==i,A=v===null,T=v===v,M=In(v);if(a)var P=r||T;else d?P=T&&(r||x):f?P=T&&x&&(r||!A):c?P=T&&x&&!A&&(r||!M):A||M?P=!1:P=r?v<=t:v<t;P?u=_+1:o=_}return ln(o,Wo)}function os(n,t){for(var e=-1,r=n.length,u=0,o=[];++e<r;){var a=n[e],f=t?t(a):a;if(!e||!Zn(f,c)){var c=f;o[u++]=a===0?0:a}}return o}function as(n){return typeof n=="number"?n:In(n)?Ce:+n}function En(n){if(typeof n=="string")return n;if(O(n))return Y(n,En)+"";if(In(n))return $u?$u.call(n):"";var t=n+"";return t=="0"&&1/n==-Ct?"-0":t}function wt(n,t,e){var r=-1,u=Oe,o=n.length,a=!0,f=[],c=f;if(e)a=!1,u=Nr;else if(o>=m){var d=t?null:zl(n);if(d)return Me(d);a=!1,u=ie,c=new Pt}else c=t?[]:f;n:for(;++r<o;){var _=n[r],v=t?t(_):_;if(_=e||_!==0?_:0,a&&v===v){for(var x=c.length;x--;)if(c[x]===v)continue n;t&&c.push(v),f.push(_)}else u(c,v,e)||(c!==f&&c.push(v),f.push(_))}return f}function li(n,t){return t=mt(t,n),n=Us(n,t),n==null||delete n[nt(qn(t))]}function fs(n,t,e,r){return pe(n,t,e(It(n,t)),r)}function nr(n,t,e,r){for(var u=n.length,o=r?u:-1;(r?o--:++o<u)&&t(n[o],o,n););return e?$n(n,r?0:o,r?o+1:u):$n(n,r?o+1:0,r?u:o)}function ls(n,t){var e=n;return e instanceof N&&(e=e.value()),Br(t,function(r,u){return u.func.apply(u.thisArg,pt([r],u.args))},e)}function ci(n,t,e){var r=n.length;if(r<2)return r?wt(n[0]):[];for(var u=-1,o=h(r);++u<r;)for(var a=n[u],f=-1;++f<r;)f!=u&&(o[u]=ce(o[u]||a,n[f],t,e));return wt(fn(o,1),t,e)}function cs(n,t,e){for(var r=-1,u=n.length,o=t.length,a={};++r<u;){var f=r<o?t[r]:i;e(a,n[r],f)}return a}function hi(n){return V(n)?n:[]}function gi(n){return typeof n=="function"?n:An}function mt(n,t){return O(n)?n:Si(n,t)?[n]:$s(G(n))}var Ml=U;function yt(n,t,e){var r=n.length;return e=e===i?r:e,!t&&e>=r?n:$n(n,t,e)}var hs=xf||function(n){return an.clearTimeout(n)};function gs(n,t){if(t)return n.slice();var e=n.length,r=Mu?Mu(e):new n.constructor(e);return n.copy(r),r}function pi(n){var t=new n.constructor(n.byteLength);return new $e(t).set(new $e(n)),t}function Fl(n,t){var e=t?pi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}function Ul(n){var t=new n.constructor(n.source,Xi.exec(n));return t.lastIndex=n.lastIndex,t}function Dl(n){return fe?H(fe.call(n)):{}}function ps(n,t){var e=t?pi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}function ds(n,t){if(n!==t){var e=n!==i,r=n===null,u=n===n,o=In(n),a=t!==i,f=t===null,c=t===t,d=In(t);if(!f&&!d&&!o&&n>t||o&&a&&c&&!f&&!d||r&&a&&c||!e&&c||!u)return 1;if(!r&&!o&&!d&&n<t||d&&e&&u&&!r&&!o||f&&e&&u||!a&&u||!c)return-1}return 0}function Nl(n,t,e){for(var r=-1,u=n.criteria,o=t.criteria,a=u.length,f=e.length;++r<a;){var c=ds(u[r],o[r]);if(c){if(r>=f)return c;var d=e[r];return c*(d=="desc"?-1:1)}}return n.index-t.index}function _s(n,t,e,r){for(var u=-1,o=n.length,a=e.length,f=-1,c=t.length,d=sn(o-a,0),_=h(c+d),v=!r;++f<c;)_[f]=t[f];for(;++u<a;)(v||u<o)&&(_[e[u]]=n[u]);for(;d--;)_[f++]=n[u++];return _}function vs(n,t,e,r){for(var u=-1,o=n.length,a=-1,f=e.length,c=-1,d=t.length,_=sn(o-f,0),v=h(_+d),x=!r;++u<_;)v[u]=n[u];for(var A=u;++c<d;)v[A+c]=t[c];for(;++a<f;)(x||u<o)&&(v[A+e[a]]=n[u++]);return v}function yn(n,t){var e=-1,r=n.length;for(t||(t=h(r));++e<r;)t[e]=n[e];return t}function jn(n,t,e,r){var u=!e;e||(e={});for(var o=-1,a=t.length;++o<a;){var f=t[o],c=r?r(e[f],n[f],f,e,n):i;c===i&&(c=n[f]),u?it(e,f,c):le(e,f,c)}return e}function Bl(n,t){return jn(n,xi(n),t)}function $l(n,t){return jn(n,Is(n),t)}function tr(n,t){return function(e,r){var u=O(e)?za:al,o=t?t():{};return u(e,n,R(r,2),o)}}function Kt(n){return U(function(t,e){var r=-1,u=e.length,o=u>1?e[u-1]:i,a=u>2?e[2]:i;for(o=n.length>3&&typeof o=="function"?(u--,o):i,a&&dn(e[0],e[1],a)&&(o=u<3?i:o,u=1),t=H(t);++r<u;){var f=e[r];f&&n(t,f,r,o)}return t})}function ws(n,t){return function(e,r){if(e==null)return e;if(!xn(e))return n(e,r);for(var u=e.length,o=t?u:-1,a=H(e);(t?o--:++o<u)&&r(a[o],o,a)!==!1;);return e}}function ms(n){return function(t,e,r){for(var u=-1,o=H(t),a=r(t),f=a.length;f--;){var c=a[n?f:++u];if(e(o[c],c,o)===!1)break}return t}}function ql(n,t,e){var r=t&wn,u=de(n);function o(){var a=this&&this!==an&&this instanceof o?u:n;return a.apply(r?e:this,arguments)}return o}function ys(n){return function(t){t=G(t);var e=Bt(t)?Jn(t):i,r=e?e[0]:t.charAt(0),u=e?yt(e,1).join(""):t.slice(1);return r[n]()+u}}function Jt(n){return function(t){return Br(mo(wo(t).replace(Ia,"")),n,"")}}function de(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var e=Ht(n.prototype),r=n.apply(e,t);return Z(r)?r:e}}function Gl(n,t,e){var r=de(n);function u(){for(var o=arguments.length,a=h(o),f=o,c=Yt(u);f--;)a[f]=arguments[f];var d=o<3&&a[0]!==c&&a[o-1]!==c?[]:dt(a,c);if(o-=d.length,o<e)return bs(n,t,er,u.placeholder,i,a,d,i,i,e-o);var _=this&&this!==an&&this instanceof u?r:n;return Tn(_,this,a)}return u}function xs(n){return function(t,e,r){var u=H(t);if(!xn(t)){var o=R(e,3);t=on(t),e=function(f){return o(u[f],f,u)}}var a=n(t,e,r);return a>-1?u[o?t[a]:a]:i}}function Ss(n){return st(function(t){var e=t.length,r=e,u=Nn.prototype.thru;for(n&&t.reverse();r--;){var o=t[r];if(typeof o!="function")throw new Dn(b);if(u&&!a&&sr(o)=="wrapper")var a=new Nn([],!0)}for(r=a?r:e;++r<e;){o=t[r];var f=sr(o),c=f=="wrapper"?mi(o):i;c&&Ai(c[0])&&c[1]==(F|kn|zn|nn)&&!c[4].length&&c[9]==1?a=a[sr(c[0])].apply(a,c[3]):a=o.length==1&&Ai(o)?a[f]():a.thru(o)}return function(){var d=arguments,_=d[0];if(a&&d.length==1&&O(_))return a.plant(_).value();for(var v=0,x=e?t[v].apply(this,d):_;++v<e;)x=t[v].call(this,x);return x}})}function er(n,t,e,r,u,o,a,f,c,d){var _=t&F,v=t&wn,x=t&mn,A=t&(kn|St),T=t&z,M=x?i:de(n);function P(){for(var D=arguments.length,B=h(D),Ln=D;Ln--;)B[Ln]=arguments[Ln];if(A)var _n=Yt(P),On=ja(B,_n);if(r&&(B=_s(B,r,u,A)),o&&(B=vs(B,o,a,A)),D-=On,A&&D<d){var j=dt(B,_n);return bs(n,t,er,P.placeholder,e,B,j,f,c,d-D)}var Xn=v?e:this,lt=x?Xn[n]:n;return D=B.length,f?B=ac(B,f):T&&D>1&&B.reverse(),_&&c<D&&(B.length=c),this&&this!==an&&this instanceof P&&(lt=M||de(lt)),lt.apply(Xn,B)}return P}function As(n,t){return function(e,r){return _l(e,n,t(r),{})}}function rr(n,t){return function(e,r){var u;if(e===i&&r===i)return t;if(e!==i&&(u=e),r!==i){if(u===i)return r;typeof e=="string"||typeof r=="string"?(e=En(e),r=En(r)):(e=as(e),r=as(r)),u=n(e,r)}return u}}function di(n){return st(function(t){return t=Y(t,Pn(R())),U(function(e){var r=this;return n(t,function(u){return Tn(u,r,e)})})})}function ir(n,t){t=t===i?" ":En(t);var e=t.length;if(e<2)return e?ai(t,n):t;var r=ai(t,ze(n/$t(t)));return Bt(t)?yt(Jn(r),0,n).join(""):r.slice(0,n)}function kl(n,t,e,r){var u=t&wn,o=de(n);function a(){for(var f=-1,c=arguments.length,d=-1,_=r.length,v=h(_+c),x=this&&this!==an&&this instanceof a?o:n;++d<_;)v[d]=r[d];for(;c--;)v[d++]=arguments[++f];return Tn(x,u?e:this,v)}return a}function Cs(n){return function(t,e,r){return r&&typeof r!="number"&&dn(t,e,r)&&(e=r=i),t=ft(t),e===i?(e=t,t=0):e=ft(e),r=r===i?t<e?1:-1:ft(r),Pl(t,e,r,n)}}function ur(n){return function(t,e){return typeof t=="string"&&typeof e=="string"||(t=Gn(t),e=Gn(e)),n(t,e)}}function bs(n,t,e,r,u,o,a,f,c,d){var _=t&kn,v=_?a:i,x=_?i:a,A=_?o:i,T=_?i:o;t|=_?zn:At,t&=~(_?At:zn),t&Ae||(t&=-4);var M=[n,t,u,A,v,T,x,f,c,d],P=e.apply(i,M);return Ai(n)&&Ds(P,M),P.placeholder=r,Ns(P,n,t)}function _i(n){var t=un[n];return function(e,r){if(e=Gn(e),r=r==null?0:ln(W(r),292),r&&Nu(e)){var u=(G(e)+"e").split("e"),o=t(u[0]+"e"+(+u[1]+r));return u=(G(o)+"e").split("e"),+(u[0]+"e"+(+u[1]-r))}return t(e)}}var zl=kt&&1/Me(new kt([,-0]))[1]==Ct?function(n){return new kt(n)}:Ni;function Rs(n){return function(t){var e=cn(t);return e==Hn?Kr(t):e==Kn?of(t):Va(t,n(t))}}function ut(n,t,e,r,u,o,a,f){var c=t&mn;if(!c&&typeof n!="function")throw new Dn(b);var d=r?r.length:0;if(d||(t&=-97,r=u=i),a=a===i?a:sn(W(a),0),f=f===i?f:W(f),d-=u?u.length:0,t&At){var _=r,v=u;r=u=i}var x=c?i:mi(n),A=[n,t,e,r,u,_,v,o,a,f];if(x&&uc(A,x),n=A[0],t=A[1],e=A[2],r=A[3],u=A[4],f=A[9]=A[9]===i?c?0:n.length:sn(A[9]-d,0),!f&&t&(kn|St)&&(t&=-25),!t||t==wn)var T=ql(n,t,e);else t==kn||t==St?T=Gl(n,t,f):(t==zn||t==(wn|zn))&&!u.length?T=kl(n,t,e,r):T=er.apply(i,A);var M=x?ss:Ds;return Ns(M(T,A),n,t)}function Ts(n,t,e,r){return n===i||Zn(n,Gt[e])&&!k.call(r,e)?t:n}function Ps(n,t,e,r,u,o){return Z(n)&&Z(t)&&(o.set(t,n),Ve(n,t,i,Ps,o),o.delete(t)),n}function Hl(n){return we(n)?i:n}function Es(n,t,e,r,u,o){var a=e&Rn,f=n.length,c=t.length;if(f!=c&&!(a&&c>f))return!1;var d=o.get(n),_=o.get(t);if(d&&_)return d==t&&_==n;var v=-1,x=!0,A=e&ct?new Pt:i;for(o.set(n,t),o.set(t,n);++v<f;){var T=n[v],M=t[v];if(r)var P=a?r(M,T,v,t,n,o):r(T,M,v,n,t,o);if(P!==i){if(P)continue;x=!1;break}if(A){if(!$r(t,function(D,B){if(!ie(A,B)&&(T===D||u(T,D,e,r,o)))return A.push(B)})){x=!1;break}}else if(!(T===M||u(T,M,e,r,o))){x=!1;break}}return o.delete(n),o.delete(t),x}function Kl(n,t,e,r,u,o,a){switch(e){case Ut:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case re:return!(n.byteLength!=t.byteLength||!o(new $e(n),new $e(t)));case Qt:case Vt:case jt:return Zn(+n,+t);case Re:return n.name==t.name&&n.message==t.message;case ne:case te:return n==t+"";case Hn:var f=Kr;case Kn:var c=r&Rn;if(f||(f=Me),n.size!=t.size&&!c)return!1;var d=a.get(n);if(d)return d==t;r|=ct,a.set(n,t);var _=Es(f(n),f(t),r,u,o,a);return a.delete(n),_;case Pe:if(fe)return fe.call(n)==fe.call(t)}return!1}function Jl(n,t,e,r,u,o){var a=e&Rn,f=vi(n),c=f.length,d=vi(t),_=d.length;if(c!=_&&!a)return!1;for(var v=c;v--;){var x=f[v];if(!(a?x in t:k.call(t,x)))return!1}var A=o.get(n),T=o.get(t);if(A&&T)return A==t&&T==n;var M=!0;o.set(n,t),o.set(t,n);for(var P=a;++v<c;){x=f[v];var D=n[x],B=t[x];if(r)var Ln=a?r(B,D,x,t,n,o):r(D,B,x,n,t,o);if(!(Ln===i?D===B||u(D,B,e,r,o):Ln)){M=!1;break}P||(P=x=="constructor")}if(M&&!P){var _n=n.constructor,On=t.constructor;_n!=On&&"constructor"in n&&"constructor"in t&&!(typeof _n=="function"&&_n instanceof _n&&typeof On=="function"&&On instanceof On)&&(M=!1)}return o.delete(n),o.delete(t),M}function st(n){return bi(Fs(n,i,zs),n+"")}function vi(n){return Zu(n,on,xi)}function wi(n){return Zu(n,Sn,Is)}var mi=Ke?function(n){return Ke.get(n)}:Ni;function sr(n){for(var t=n.name+"",e=zt[t],r=k.call(zt,t)?e.length:0;r--;){var u=e[r],o=u.func;if(o==null||o==n)return u.name}return t}function Yt(n){var t=k.call(s,"placeholder")?s:n;return t.placeholder}function R(){var n=s.iteratee||Ui;return n=n===Ui?Vu:n,arguments.length?n(arguments[0],arguments[1]):n}function or(n,t){var e=n.__data__;return tc(t)?e[typeof t=="string"?"string":"hash"]:e.map}function yi(n){for(var t=on(n),e=t.length;e--;){var r=t[e],u=n[r];t[e]=[r,u,Ws(u)]}return t}function Lt(n,t){var e=rf(n,t);return Qu(e)?e:i}function Yl(n){var t=k.call(n,Rt),e=n[Rt];try{n[Rt]=i;var r=!0}catch{}var u=Ne.call(n);return r&&(t?n[Rt]=e:delete n[Rt]),u}var xi=Yr?function(n){return n==null?[]:(n=H(n),gt(Yr(n),function(t){return Uu.call(n,t)}))}:Bi,Is=Yr?function(n){for(var t=[];n;)pt(t,xi(n)),n=qe(n);return t}:Bi,cn=pn;(Zr&&cn(new Zr(new ArrayBuffer(1)))!=Ut||se&&cn(new se)!=Hn||Xr&&cn(Xr.resolve())!=Ki||kt&&cn(new kt)!=Kn||oe&&cn(new oe)!=ee)&&(cn=function(n){var t=pn(n),e=t==tt?n.constructor:i,r=e?Ot(e):"";if(r)switch(r){case If:return Ut;case Lf:return Hn;case Of:return Ki;case Wf:return Kn;case Mf:return ee}return t});function Zl(n,t,e){for(var r=-1,u=e.length;++r<u;){var o=e[r],a=o.size;switch(o.type){case"drop":n+=a;break;case"dropRight":t-=a;break;case"take":t=ln(t,n+a);break;case"takeRight":n=sn(n,t-a);break}}return{start:n,end:t}}function Xl(n){var t=n.match(ta);return t?t[1].split(ea):[]}function Ls(n,t,e){t=mt(t,n);for(var r=-1,u=t.length,o=!1;++r<u;){var a=nt(t[r]);if(!(o=n!=null&&e(n,a)))break;n=n[a]}return o||++r!=u?o:(u=n==null?0:n.length,!!u&&pr(u)&&ot(a,u)&&(O(n)||Wt(n)))}function Ql(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&k.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Os(n){return typeof n.constructor=="function"&&!_e(n)?Ht(qe(n)):{}}function Vl(n,t,e){var r=n.constructor;switch(t){case re:return pi(n);case Qt:case Vt:return new r(+n);case Ut:return Fl(n,e);case yr:case xr:case Sr:case Ar:case Cr:case br:case Rr:case Tr:case Pr:return ps(n,e);case Hn:return new r;case jt:case te:return new r(n);case ne:return Ul(n);case Kn:return new r;case Pe:return Dl(n)}}function jl(n,t){var e=t.length;if(!e)return n;var r=e-1;return t[r]=(e>1?"& ":"")+t[r],t=t.join(e>2?", ":" "),n.replace(na,`{
17
- /* [wrapped with `+t+`] */
18
- `)}function nc(n){return O(n)||Wt(n)||!!(Du&&n&&n[Du])}function ot(n,t){var e=typeof n;return t=t??ht,!!t&&(e=="number"||e!="symbol"&&ca.test(n))&&n>-1&&n%1==0&&n<t}function dn(n,t,e){if(!Z(e))return!1;var r=typeof t;return(r=="number"?xn(e)&&ot(t,e.length):r=="string"&&t in e)?Zn(e[t],n):!1}function Si(n,t){if(O(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||In(n)?!0:Xo.test(n)||!Zo.test(n)||t!=null&&n in H(t)}function tc(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function Ai(n){var t=sr(n),e=s[t];if(typeof e!="function"||!(t in N.prototype))return!1;if(n===e)return!0;var r=mi(e);return!!r&&n===r[0]}function ec(n){return!!Wu&&Wu in n}var rc=Ue?at:$i;function _e(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Gt;return n===e}function Ws(n){return n===n&&!Z(n)}function Ms(n,t){return function(e){return e==null?!1:e[n]===t&&(t!==i||n in H(e))}}function ic(n){var t=hr(n,function(r){return e.size===tn&&e.clear(),r}),e=t.cache;return t}function uc(n,t){var e=n[1],r=t[1],u=e|r,o=u<(wn|mn|F),a=r==F&&e==kn||r==F&&e==nn&&n[7].length<=t[8]||r==(F|nn)&&t[7].length<=t[8]&&e==kn;if(!(o||a))return n;r&wn&&(n[2]=t[2],u|=e&wn?0:Ae);var f=t[3];if(f){var c=n[3];n[3]=c?_s(c,f,t[4]):f,n[4]=c?dt(n[3],Cn):t[4]}return f=t[5],f&&(c=n[5],n[5]=c?vs(c,f,t[6]):f,n[6]=c?dt(n[5],Cn):t[6]),f=t[7],f&&(n[7]=f),r&F&&(n[8]=n[8]==null?t[8]:ln(n[8],t[8])),n[9]==null&&(n[9]=t[9]),n[0]=t[0],n[1]=u,n}function sc(n){var t=[];if(n!=null)for(var e in H(n))t.push(e);return t}function oc(n){return Ne.call(n)}function Fs(n,t,e){return t=sn(t===i?n.length-1:t,0),function(){for(var r=arguments,u=-1,o=sn(r.length-t,0),a=h(o);++u<o;)a[u]=r[t+u];u=-1;for(var f=h(t+1);++u<t;)f[u]=r[u];return f[t]=e(a),Tn(n,this,f)}}function Us(n,t){return t.length<2?n:It(n,$n(t,0,-1))}function ac(n,t){for(var e=n.length,r=ln(t.length,e),u=yn(n);r--;){var o=t[r];n[r]=ot(o,e)?u[o]:i}return n}function Ci(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Ds=Bs(ss),ve=Af||function(n,t){return an.setTimeout(n,t)},bi=Bs(Ll);function Ns(n,t,e){var r=t+"";return bi(n,jl(r,fc(Xl(r),e)))}function Bs(n){var t=0,e=0;return function(){var r=Tf(),u=X-(r-e);if(e=r,u>0){if(++t>=Mn)return arguments[0]}else t=0;return n.apply(i,arguments)}}function ar(n,t){var e=-1,r=n.length,u=r-1;for(t=t===i?r:t;++e<t;){var o=oi(e,u),a=n[o];n[o]=n[e],n[e]=a}return n.length=t,n}var $s=ic(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(Qo,function(e,r,u,o){t.push(u?o.replace(ua,"$1"):r||e)}),t});function nt(n){if(typeof n=="string"||In(n))return n;var t=n+"";return t=="0"&&1/n==-Ct?"-0":t}function Ot(n){if(n!=null){try{return De.call(n)}catch{}try{return n+""}catch{}}return""}function fc(n,t){return Un(Fo,function(e){var r="_."+e[0];t&e[1]&&!Oe(n,r)&&n.push(r)}),n.sort()}function qs(n){if(n instanceof N)return n.clone();var t=new Nn(n.__wrapped__,n.__chain__);return t.__actions__=yn(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function lc(n,t,e){(e?dn(n,t,e):t===i)?t=1:t=sn(W(t),0);var r=n==null?0:n.length;if(!r||t<1)return[];for(var u=0,o=0,a=h(ze(r/t));u<r;)a[o++]=$n(n,u,u+=t);return a}function cc(n){for(var t=-1,e=n==null?0:n.length,r=0,u=[];++t<e;){var o=n[t];o&&(u[r++]=o)}return u}function hc(){var n=arguments.length;if(!n)return[];for(var t=h(n-1),e=arguments[0],r=n;r--;)t[r-1]=arguments[r];return pt(O(e)?yn(e):[e],fn(t,1))}var gc=U(function(n,t){return V(n)?ce(n,fn(t,1,V,!0)):[]}),pc=U(function(n,t){var e=qn(t);return V(e)&&(e=i),V(n)?ce(n,fn(t,1,V,!0),R(e,2)):[]}),dc=U(function(n,t){var e=qn(t);return V(e)&&(e=i),V(n)?ce(n,fn(t,1,V,!0),i,e):[]});function _c(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),$n(n,t<0?0:t,r)):[]}function vc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),t=r-t,$n(n,0,t<0?0:t)):[]}function wc(n,t){return n&&n.length?nr(n,R(t,3),!0,!0):[]}function mc(n,t){return n&&n.length?nr(n,R(t,3),!0):[]}function yc(n,t,e,r){var u=n==null?0:n.length;return u?(e&&typeof e!="number"&&dn(n,t,e)&&(e=0,r=u),hl(n,t,e,r)):[]}function Gs(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:W(e);return u<0&&(u=sn(r+u,0)),We(n,R(t,3),u)}function ks(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r-1;return e!==i&&(u=W(e),u=e<0?sn(r+u,0):ln(u,r-1)),We(n,R(t,3),u,!0)}function zs(n){var t=n==null?0:n.length;return t?fn(n,1):[]}function xc(n){var t=n==null?0:n.length;return t?fn(n,Ct):[]}function Sc(n,t){var e=n==null?0:n.length;return e?(t=t===i?1:W(t),fn(n,t)):[]}function Ac(n){for(var t=-1,e=n==null?0:n.length,r={};++t<e;){var u=n[t];r[u[0]]=u[1]}return r}function Hs(n){return n&&n.length?n[0]:i}function Cc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:W(e);return u<0&&(u=sn(r+u,0)),Nt(n,t,u)}function bc(n){var t=n==null?0:n.length;return t?$n(n,0,-1):[]}var Rc=U(function(n){var t=Y(n,hi);return t.length&&t[0]===n[0]?ei(t):[]}),Tc=U(function(n){var t=qn(n),e=Y(n,hi);return t===qn(e)?t=i:e.pop(),e.length&&e[0]===n[0]?ei(e,R(t,2)):[]}),Pc=U(function(n){var t=qn(n),e=Y(n,hi);return t=typeof t=="function"?t:i,t&&e.pop(),e.length&&e[0]===n[0]?ei(e,i,t):[]});function Ec(n,t){return n==null?"":bf.call(n,t)}function qn(n){var t=n==null?0:n.length;return t?n[t-1]:i}function Ic(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r;return e!==i&&(u=W(e),u=u<0?sn(r+u,0):ln(u,r-1)),t===t?ff(n,t,u):We(n,bu,u,!0)}function Lc(n,t){return n&&n.length?es(n,W(t)):i}var Oc=U(Ks);function Ks(n,t){return n&&n.length&&t&&t.length?si(n,t):n}function Wc(n,t,e){return n&&n.length&&t&&t.length?si(n,t,R(e,2)):n}function Mc(n,t,e){return n&&n.length&&t&&t.length?si(n,t,i,e):n}var Fc=st(function(n,t){var e=n==null?0:n.length,r=Vr(n,t);return us(n,Y(t,function(u){return ot(u,e)?+u:u}).sort(ds)),r});function Uc(n,t){var e=[];if(!(n&&n.length))return e;var r=-1,u=[],o=n.length;for(t=R(t,3);++r<o;){var a=n[r];t(a,r,n)&&(e.push(a),u.push(r))}return us(n,u),e}function Ri(n){return n==null?n:Ef.call(n)}function Dc(n,t,e){var r=n==null?0:n.length;return r?(e&&typeof e!="number"&&dn(n,t,e)?(t=0,e=r):(t=t==null?0:W(t),e=e===i?r:W(e)),$n(n,t,e)):[]}function Nc(n,t){return je(n,t)}function Bc(n,t,e){return fi(n,t,R(e,2))}function $c(n,t){var e=n==null?0:n.length;if(e){var r=je(n,t);if(r<e&&Zn(n[r],t))return r}return-1}function qc(n,t){return je(n,t,!0)}function Gc(n,t,e){return fi(n,t,R(e,2),!0)}function kc(n,t){var e=n==null?0:n.length;if(e){var r=je(n,t,!0)-1;if(Zn(n[r],t))return r}return-1}function zc(n){return n&&n.length?os(n):[]}function Hc(n,t){return n&&n.length?os(n,R(t,2)):[]}function Kc(n){var t=n==null?0:n.length;return t?$n(n,1,t):[]}function Jc(n,t,e){return n&&n.length?(t=e||t===i?1:W(t),$n(n,0,t<0?0:t)):[]}function Yc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),t=r-t,$n(n,t<0?0:t,r)):[]}function Zc(n,t){return n&&n.length?nr(n,R(t,3),!1,!0):[]}function Xc(n,t){return n&&n.length?nr(n,R(t,3)):[]}var Qc=U(function(n){return wt(fn(n,1,V,!0))}),Vc=U(function(n){var t=qn(n);return V(t)&&(t=i),wt(fn(n,1,V,!0),R(t,2))}),jc=U(function(n){var t=qn(n);return t=typeof t=="function"?t:i,wt(fn(n,1,V,!0),i,t)});function nh(n){return n&&n.length?wt(n):[]}function th(n,t){return n&&n.length?wt(n,R(t,2)):[]}function eh(n,t){return t=typeof t=="function"?t:i,n&&n.length?wt(n,i,t):[]}function Ti(n){if(!(n&&n.length))return[];var t=0;return n=gt(n,function(e){if(V(e))return t=sn(e.length,t),!0}),zr(t,function(e){return Y(n,qr(e))})}function Js(n,t){if(!(n&&n.length))return[];var e=Ti(n);return t==null?e:Y(e,function(r){return Tn(t,i,r)})}var rh=U(function(n,t){return V(n)?ce(n,t):[]}),ih=U(function(n){return ci(gt(n,V))}),uh=U(function(n){var t=qn(n);return V(t)&&(t=i),ci(gt(n,V),R(t,2))}),sh=U(function(n){var t=qn(n);return t=typeof t=="function"?t:i,ci(gt(n,V),i,t)}),oh=U(Ti);function ah(n,t){return cs(n||[],t||[],le)}function fh(n,t){return cs(n||[],t||[],pe)}var lh=U(function(n){var t=n.length,e=t>1?n[t-1]:i;return e=typeof e=="function"?(n.pop(),e):i,Js(n,e)});function Ys(n){var t=s(n);return t.__chain__=!0,t}function ch(n,t){return t(n),n}function fr(n,t){return t(n)}var hh=st(function(n){var t=n.length,e=t?n[0]:0,r=this.__wrapped__,u=function(o){return Vr(o,n)};return t>1||this.__actions__.length||!(r instanceof N)||!ot(e)?this.thru(u):(r=r.slice(e,+e+(t?1:0)),r.__actions__.push({func:fr,args:[u],thisArg:i}),new Nn(r,this.__chain__).thru(function(o){return t&&!o.length&&o.push(i),o}))});function gh(){return Ys(this)}function ph(){return new Nn(this.value(),this.__chain__)}function dh(){this.__values__===i&&(this.__values__=ao(this.value()));var n=this.__index__>=this.__values__.length,t=n?i:this.__values__[this.__index__++];return{done:n,value:t}}function _h(){return this}function vh(n){for(var t,e=this;e instanceof Ye;){var r=qs(e);r.__index__=0,r.__values__=i,t?u.__wrapped__=r:t=r;var u=r;e=e.__wrapped__}return u.__wrapped__=n,t}function wh(){var n=this.__wrapped__;if(n instanceof N){var t=n;return this.__actions__.length&&(t=new N(this)),t=t.reverse(),t.__actions__.push({func:fr,args:[Ri],thisArg:i}),new Nn(t,this.__chain__)}return this.thru(Ri)}function mh(){return ls(this.__wrapped__,this.__actions__)}var yh=tr(function(n,t,e){k.call(n,e)?++n[e]:it(n,e,1)});function xh(n,t,e){var r=O(n)?Au:cl;return e&&dn(n,t,e)&&(t=i),r(n,R(t,3))}function Sh(n,t){var e=O(n)?gt:Ju;return e(n,R(t,3))}var Ah=xs(Gs),Ch=xs(ks);function bh(n,t){return fn(lr(n,t),1)}function Rh(n,t){return fn(lr(n,t),Ct)}function Th(n,t,e){return e=e===i?1:W(e),fn(lr(n,t),e)}function Zs(n,t){var e=O(n)?Un:vt;return e(n,R(t,3))}function Xs(n,t){var e=O(n)?Ha:Ku;return e(n,R(t,3))}var Ph=tr(function(n,t,e){k.call(n,e)?n[e].push(t):it(n,e,[t])});function Eh(n,t,e,r){n=xn(n)?n:Xt(n),e=e&&!r?W(e):0;var u=n.length;return e<0&&(e=sn(u+e,0)),dr(n)?e<=u&&n.indexOf(t,e)>-1:!!u&&Nt(n,t,e)>-1}var Ih=U(function(n,t,e){var r=-1,u=typeof t=="function",o=xn(n)?h(n.length):[];return vt(n,function(a){o[++r]=u?Tn(t,a,e):he(a,t,e)}),o}),Lh=tr(function(n,t,e){it(n,e,t)});function lr(n,t){var e=O(n)?Y:ju;return e(n,R(t,3))}function Oh(n,t,e,r){return n==null?[]:(O(t)||(t=t==null?[]:[t]),e=r?i:e,O(e)||(e=e==null?[]:[e]),rs(n,t,e))}var Wh=tr(function(n,t,e){n[e?0:1].push(t)},function(){return[[],[]]});function Mh(n,t,e){var r=O(n)?Br:Tu,u=arguments.length<3;return r(n,R(t,4),e,u,vt)}function Fh(n,t,e){var r=O(n)?Ka:Tu,u=arguments.length<3;return r(n,R(t,4),e,u,Ku)}function Uh(n,t){var e=O(n)?gt:Ju;return e(n,gr(R(t,3)))}function Dh(n){var t=O(n)?Gu:El;return t(n)}function Nh(n,t,e){(e?dn(n,t,e):t===i)?t=1:t=W(t);var r=O(n)?sl:Il;return r(n,t)}function Bh(n){var t=O(n)?ol:Ol;return t(n)}function $h(n){if(n==null)return 0;if(xn(n))return dr(n)?$t(n):n.length;var t=cn(n);return t==Hn||t==Kn?n.size:ii(n).length}function qh(n,t,e){var r=O(n)?$r:Wl;return e&&dn(n,t,e)&&(t=i),r(n,R(t,3))}var Gh=U(function(n,t){if(n==null)return[];var e=t.length;return e>1&&dn(n,t[0],t[1])?t=[]:e>2&&dn(t[0],t[1],t[2])&&(t=[t[0]]),rs(n,fn(t,1),[])}),cr=Sf||function(){return an.Date.now()};function kh(n,t){if(typeof t!="function")throw new Dn(b);return n=W(n),function(){if(--n<1)return t.apply(this,arguments)}}function Qs(n,t,e){return t=e?i:t,t=n&&t==null?n.length:t,ut(n,F,i,i,i,i,t)}function Vs(n,t){var e;if(typeof t!="function")throw new Dn(b);return n=W(n),function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=i),e}}var Pi=U(function(n,t,e){var r=wn;if(e.length){var u=dt(e,Yt(Pi));r|=zn}return ut(n,r,t,e,u)}),js=U(function(n,t,e){var r=wn|mn;if(e.length){var u=dt(e,Yt(js));r|=zn}return ut(t,r,n,e,u)});function no(n,t,e){t=e?i:t;var r=ut(n,kn,i,i,i,i,i,t);return r.placeholder=no.placeholder,r}function to(n,t,e){t=e?i:t;var r=ut(n,St,i,i,i,i,i,t);return r.placeholder=to.placeholder,r}function eo(n,t,e){var r,u,o,a,f,c,d=0,_=!1,v=!1,x=!0;if(typeof n!="function")throw new Dn(b);t=Gn(t)||0,Z(e)&&(_=!!e.leading,v="maxWait"in e,o=v?sn(Gn(e.maxWait)||0,t):o,x="trailing"in e?!!e.trailing:x);function A(j){var Xn=r,lt=u;return r=u=i,d=j,a=n.apply(lt,Xn),a}function T(j){return d=j,f=ve(D,t),_?A(j):a}function M(j){var Xn=j-c,lt=j-d,So=t-Xn;return v?ln(So,o-lt):So}function P(j){var Xn=j-c,lt=j-d;return c===i||Xn>=t||Xn<0||v&&lt>=o}function D(){var j=cr();if(P(j))return B(j);f=ve(D,M(j))}function B(j){return f=i,x&&r?A(j):(r=u=i,a)}function Ln(){f!==i&&hs(f),d=0,r=c=u=f=i}function _n(){return f===i?a:B(cr())}function On(){var j=cr(),Xn=P(j);if(r=arguments,u=this,c=j,Xn){if(f===i)return T(c);if(v)return hs(f),f=ve(D,t),A(c)}return f===i&&(f=ve(D,t)),a}return On.cancel=Ln,On.flush=_n,On}var zh=U(function(n,t){return Hu(n,1,t)}),Hh=U(function(n,t,e){return Hu(n,Gn(t)||0,e)});function Kh(n){return ut(n,z)}function hr(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new Dn(b);var e=function(){var r=arguments,u=t?t.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var a=n.apply(this,r);return e.cache=o.set(u,a)||o,a};return e.cache=new(hr.Cache||rt),e}hr.Cache=rt;function gr(n){if(typeof n!="function")throw new Dn(b);return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function Jh(n){return Vs(2,n)}var Yh=Ml(function(n,t){t=t.length==1&&O(t[0])?Y(t[0],Pn(R())):Y(fn(t,1),Pn(R()));var e=t.length;return U(function(r){for(var u=-1,o=ln(r.length,e);++u<o;)r[u]=t[u].call(this,r[u]);return Tn(n,this,r)})}),Ei=U(function(n,t){var e=dt(t,Yt(Ei));return ut(n,zn,i,t,e)}),ro=U(function(n,t){var e=dt(t,Yt(ro));return ut(n,At,i,t,e)}),Zh=st(function(n,t){return ut(n,nn,i,i,i,t)});function Xh(n,t){if(typeof n!="function")throw new Dn(b);return t=t===i?t:W(t),U(n,t)}function Qh(n,t){if(typeof n!="function")throw new Dn(b);return t=t==null?0:sn(W(t),0),U(function(e){var r=e[t],u=yt(e,0,t);return r&&pt(u,r),Tn(n,this,u)})}function Vh(n,t,e){var r=!0,u=!0;if(typeof n!="function")throw new Dn(b);return Z(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),eo(n,t,{leading:r,maxWait:t,trailing:u})}function jh(n){return Qs(n,1)}function ng(n,t){return Ei(gi(t),n)}function tg(){if(!arguments.length)return[];var n=arguments[0];return O(n)?n:[n]}function eg(n){return Bn(n,hn)}function rg(n,t){return t=typeof t=="function"?t:i,Bn(n,hn,t)}function ig(n){return Bn(n,en|hn)}function ug(n,t){return t=typeof t=="function"?t:i,Bn(n,en|hn,t)}function sg(n,t){return t==null||zu(n,t,on(t))}function Zn(n,t){return n===t||n!==n&&t!==t}var og=ur(ti),ag=ur(function(n,t){return n>=t}),Wt=Xu(function(){return arguments}())?Xu:function(n){return Q(n)&&k.call(n,"callee")&&!Uu.call(n,"callee")},O=h.isArray,fg=vu?Pn(vu):vl;function xn(n){return n!=null&&pr(n.length)&&!at(n)}function V(n){return Q(n)&&xn(n)}function lg(n){return n===!0||n===!1||Q(n)&&pn(n)==Qt}var xt=Cf||$i,cg=wu?Pn(wu):wl;function hg(n){return Q(n)&&n.nodeType===1&&!we(n)}function gg(n){if(n==null)return!0;if(xn(n)&&(O(n)||typeof n=="string"||typeof n.splice=="function"||xt(n)||Zt(n)||Wt(n)))return!n.length;var t=cn(n);if(t==Hn||t==Kn)return!n.size;if(_e(n))return!ii(n).length;for(var e in n)if(k.call(n,e))return!1;return!0}function pg(n,t){return ge(n,t)}function dg(n,t,e){e=typeof e=="function"?e:i;var r=e?e(n,t):i;return r===i?ge(n,t,i,e):!!r}function Ii(n){if(!Q(n))return!1;var t=pn(n);return t==Re||t==Do||typeof n.message=="string"&&typeof n.name=="string"&&!we(n)}function _g(n){return typeof n=="number"&&Nu(n)}function at(n){if(!Z(n))return!1;var t=pn(n);return t==Te||t==Hi||t==Uo||t==Bo}function io(n){return typeof n=="number"&&n==W(n)}function pr(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=ht}function Z(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function Q(n){return n!=null&&typeof n=="object"}var uo=mu?Pn(mu):yl;function vg(n,t){return n===t||ri(n,t,yi(t))}function wg(n,t,e){return e=typeof e=="function"?e:i,ri(n,t,yi(t),e)}function mg(n){return so(n)&&n!=+n}function yg(n){if(rc(n))throw new L(C);return Qu(n)}function xg(n){return n===null}function Sg(n){return n==null}function so(n){return typeof n=="number"||Q(n)&&pn(n)==jt}function we(n){if(!Q(n)||pn(n)!=tt)return!1;var t=qe(n);if(t===null)return!0;var e=k.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&De.call(e)==wf}var Li=yu?Pn(yu):xl;function Ag(n){return io(n)&&n>=-ht&&n<=ht}var oo=xu?Pn(xu):Sl;function dr(n){return typeof n=="string"||!O(n)&&Q(n)&&pn(n)==te}function In(n){return typeof n=="symbol"||Q(n)&&pn(n)==Pe}var Zt=Su?Pn(Su):Al;function Cg(n){return n===i}function bg(n){return Q(n)&&cn(n)==ee}function Rg(n){return Q(n)&&pn(n)==qo}var Tg=ur(ui),Pg=ur(function(n,t){return n<=t});function ao(n){if(!n)return[];if(xn(n))return dr(n)?Jn(n):yn(n);if(ue&&n[ue])return sf(n[ue]());var t=cn(n),e=t==Hn?Kr:t==Kn?Me:Xt;return e(n)}function ft(n){if(!n)return n===0?n:0;if(n=Gn(n),n===Ct||n===-Ct){var t=n<0?-1:1;return t*Oo}return n===n?n:0}function W(n){var t=ft(n),e=t%1;return t===t?e?t-e:t:0}function fo(n){return n?Et(W(n),0,Qn):0}function Gn(n){if(typeof n=="number")return n;if(In(n))return Ce;if(Z(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=Z(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=Pu(n);var e=aa.test(n);return e||la.test(n)?Ga(n.slice(2),e?2:8):oa.test(n)?Ce:+n}function lo(n){return jn(n,Sn(n))}function Eg(n){return n?Et(W(n),-ht,ht):n===0?n:0}function G(n){return n==null?"":En(n)}var Ig=Kt(function(n,t){if(_e(t)||xn(t)){jn(t,on(t),n);return}for(var e in t)k.call(t,e)&&le(n,e,t[e])}),co=Kt(function(n,t){jn(t,Sn(t),n)}),_r=Kt(function(n,t,e,r){jn(t,Sn(t),n,r)}),Lg=Kt(function(n,t,e,r){jn(t,on(t),n,r)}),Og=st(Vr);function Wg(n,t){var e=Ht(n);return t==null?e:ku(e,t)}var Mg=U(function(n,t){n=H(n);var e=-1,r=t.length,u=r>2?t[2]:i;for(u&&dn(t[0],t[1],u)&&(r=1);++e<r;)for(var o=t[e],a=Sn(o),f=-1,c=a.length;++f<c;){var d=a[f],_=n[d];(_===i||Zn(_,Gt[d])&&!k.call(n,d))&&(n[d]=o[d])}return n}),Fg=U(function(n){return n.push(i,Ps),Tn(ho,i,n)});function Ug(n,t){return Cu(n,R(t,3),Vn)}function Dg(n,t){return Cu(n,R(t,3),ni)}function Ng(n,t){return n==null?n:jr(n,R(t,3),Sn)}function Bg(n,t){return n==null?n:Yu(n,R(t,3),Sn)}function $g(n,t){return n&&Vn(n,R(t,3))}function qg(n,t){return n&&ni(n,R(t,3))}function Gg(n){return n==null?[]:Qe(n,on(n))}function kg(n){return n==null?[]:Qe(n,Sn(n))}function Oi(n,t,e){var r=n==null?i:It(n,t);return r===i?e:r}function zg(n,t){return n!=null&&Ls(n,t,gl)}function Wi(n,t){return n!=null&&Ls(n,t,pl)}var Hg=As(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=Ne.call(t)),n[t]=e},Fi(An)),Kg=As(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=Ne.call(t)),k.call(n,t)?n[t].push(e):n[t]=[e]},R),Jg=U(he);function on(n){return xn(n)?qu(n):ii(n)}function Sn(n){return xn(n)?qu(n,!0):Cl(n)}function Yg(n,t){var e={};return t=R(t,3),Vn(n,function(r,u,o){it(e,t(r,u,o),r)}),e}function Zg(n,t){var e={};return t=R(t,3),Vn(n,function(r,u,o){it(e,u,t(r,u,o))}),e}var Xg=Kt(function(n,t,e){Ve(n,t,e)}),ho=Kt(function(n,t,e,r){Ve(n,t,e,r)}),Qg=st(function(n,t){var e={};if(n==null)return e;var r=!1;t=Y(t,function(o){return o=mt(o,n),r||(r=o.length>1),o}),jn(n,wi(n),e),r&&(e=Bn(e,en|bn|hn,Hl));for(var u=t.length;u--;)li(e,t[u]);return e});function Vg(n,t){return go(n,gr(R(t)))}var jg=st(function(n,t){return n==null?{}:Rl(n,t)});function go(n,t){if(n==null)return{};var e=Y(wi(n),function(r){return[r]});return t=R(t),is(n,e,function(r,u){return t(r,u[0])})}function np(n,t,e){t=mt(t,n);var r=-1,u=t.length;for(u||(u=1,n=i);++r<u;){var o=n==null?i:n[nt(t[r])];o===i&&(r=u,o=e),n=at(o)?o.call(n):o}return n}function tp(n,t,e){return n==null?n:pe(n,t,e)}function ep(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:pe(n,t,e,r)}var po=Rs(on),_o=Rs(Sn);function rp(n,t,e){var r=O(n),u=r||xt(n)||Zt(n);if(t=R(t,4),e==null){var o=n&&n.constructor;u?e=r?new o:[]:Z(n)?e=at(o)?Ht(qe(n)):{}:e={}}return(u?Un:Vn)(n,function(a,f,c){return t(e,a,f,c)}),e}function ip(n,t){return n==null?!0:li(n,t)}function up(n,t,e){return n==null?n:fs(n,t,gi(e))}function sp(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:fs(n,t,gi(e),r)}function Xt(n){return n==null?[]:Hr(n,on(n))}function op(n){return n==null?[]:Hr(n,Sn(n))}function ap(n,t,e){return e===i&&(e=t,t=i),e!==i&&(e=Gn(e),e=e===e?e:0),t!==i&&(t=Gn(t),t=t===t?t:0),Et(Gn(n),t,e)}function fp(n,t,e){return t=ft(t),e===i?(e=t,t=0):e=ft(e),n=Gn(n),dl(n,t,e)}function lp(n,t,e){if(e&&typeof e!="boolean"&&dn(n,t,e)&&(t=e=i),e===i&&(typeof t=="boolean"?(e=t,t=i):typeof n=="boolean"&&(e=n,n=i)),n===i&&t===i?(n=0,t=1):(n=ft(n),t===i?(t=n,n=0):t=ft(t)),n>t){var r=n;n=t,t=r}if(e||n%1||t%1){var u=Bu();return ln(n+u*(t-n+qa("1e-"+((u+"").length-1))),t)}return oi(n,t)}var cp=Jt(function(n,t,e){return t=t.toLowerCase(),n+(e?vo(t):t)});function vo(n){return Mi(G(n).toLowerCase())}function wo(n){return n=G(n),n&&n.replace(ha,nf).replace(La,"")}function hp(n,t,e){n=G(n),t=En(t);var r=n.length;e=e===i?r:Et(W(e),0,r);var u=e;return e-=t.length,e>=0&&n.slice(e,u)==t}function gp(n){return n=G(n),n&&Ko.test(n)?n.replace(Yi,tf):n}function pp(n){return n=G(n),n&&Vo.test(n)?n.replace(Er,"\\$&"):n}var dp=Jt(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()}),_p=Jt(function(n,t,e){return n+(e?" ":"")+t.toLowerCase()}),vp=ys("toLowerCase");function wp(n,t,e){n=G(n),t=W(t);var r=t?$t(n):0;if(!t||r>=t)return n;var u=(t-r)/2;return ir(He(u),e)+n+ir(ze(u),e)}function mp(n,t,e){n=G(n),t=W(t);var r=t?$t(n):0;return t&&r<t?n+ir(t-r,e):n}function yp(n,t,e){n=G(n),t=W(t);var r=t?$t(n):0;return t&&r<t?ir(t-r,e)+n:n}function xp(n,t,e){return e||t==null?t=0:t&&(t=+t),Pf(G(n).replace(Ir,""),t||0)}function Sp(n,t,e){return(e?dn(n,t,e):t===i)?t=1:t=W(t),ai(G(n),t)}function Ap(){var n=arguments,t=G(n[0]);return n.length<3?t:t.replace(n[1],n[2])}var Cp=Jt(function(n,t,e){return n+(e?"_":"")+t.toLowerCase()});function bp(n,t,e){return e&&typeof e!="number"&&dn(n,t,e)&&(t=e=i),e=e===i?Qn:e>>>0,e?(n=G(n),n&&(typeof t=="string"||t!=null&&!Li(t))&&(t=En(t),!t&&Bt(n))?yt(Jn(n),0,e):n.split(t,e)):[]}var Rp=Jt(function(n,t,e){return n+(e?" ":"")+Mi(t)});function Tp(n,t,e){return n=G(n),e=e==null?0:Et(W(e),0,n.length),t=En(t),n.slice(e,e+t.length)==t}function Pp(n,t,e){var r=s.templateSettings;e&&dn(n,t,e)&&(t=i),n=G(n),t=_r({},t,r,Ts);var u=_r({},t.imports,r.imports,Ts),o=on(u),a=Hr(u,o),f,c,d=0,_=t.interpolate||Ee,v="__p += '",x=Jr((t.escape||Ee).source+"|"+_.source+"|"+(_===Zi?sa:Ee).source+"|"+(t.evaluate||Ee).source+"|$","g"),A="//# sourceURL="+(k.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ua+"]")+`
19
- `;n.replace(x,function(P,D,B,Ln,_n,On){return B||(B=Ln),v+=n.slice(d,On).replace(ga,ef),D&&(f=!0,v+=`' +
20
- __e(`+D+`) +
21
- '`),_n&&(c=!0,v+=`';
22
- `+_n+`;
23
- __p += '`),B&&(v+=`' +
24
- ((__t = (`+B+`)) == null ? '' : __t) +
25
- '`),d=On+P.length,P}),v+=`';
26
- `;var T=k.call(t,"variable")&&t.variable;if(!T)v=`with (obj) {
27
- `+v+`
20
+ */Zr.exports;(function(n,i){(function(){var r,a="4.17.21",h=200,f="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",p="Expected a function",m="Invalid `variable` option passed into `_.template`",w="__lodash_hash_undefined__",I=500,P="__lodash_placeholder__",C=1,A=2,R=4,K=1,Tt=2,pt=1,ut=2,Zn=4,Kt=8,Le=16,Yt=32,Be=64,q=128,ct=256,X=512,Nt=30,ht="...",Ft=800,st=16,wt=1,fc=2,dc=3,ke=1/0,ye=9007199254740991,pc=17976931348623157e292,Xn=NaN,ie=4294967295,gc=ie-1,_c=ie>>>1,bc=[["ary",q],["bind",pt],["bindKey",ut],["curry",Kt],["curryRight",Le],["flip",X],["partial",Yt],["partialRight",Be],["rearg",ct]],Ze="[object Arguments]",Qn="[object Array]",mc="[object AsyncFunction]",vn="[object Boolean]",wn="[object Date]",vc="[object DOMException]",jn="[object Error]",tr="[object Function]",Wi="[object GeneratorFunction]",Vt="[object Map]",yn="[object Number]",wc="[object Null]",le="[object Object]",$i="[object Promise]",yc="[object Proxy]",Sn="[object RegExp]",Zt="[object Set]",xn="[object String]",er="[object Symbol]",Sc="[object Undefined]",En="[object WeakMap]",xc="[object WeakSet]",Tn="[object ArrayBuffer]",Xe="[object DataView]",ts="[object Float32Array]",es="[object Float64Array]",ns="[object Int8Array]",rs="[object Int16Array]",ss="[object Int32Array]",is="[object Uint8Array]",os="[object Uint8ClampedArray]",as="[object Uint16Array]",us="[object Uint32Array]",Ec=/\b__p \+= '';/g,Tc=/\b(__p \+=) '' \+/g,Ac=/(__e\(.*?\)|\b__t\)) \+\n'';/g,qi=/&(?:amp|lt|gt|quot|#39);/g,zi=/[&<>"']/g,Cc=RegExp(qi.source),Ic=RegExp(zi.source),Rc=/<%-([\s\S]+?)%>/g,Mc=/<%([\s\S]+?)%>/g,Hi=/<%=([\s\S]+?)%>/g,Pc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Oc=/^\w*$/,Lc=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cs=/[\\^$.*+?()[\]{}|]/g,Bc=RegExp(cs.source),hs=/^\s+/,kc=/\s/,Dc=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Nc=/\{\n\/\* \[wrapped with (.+)\] \*/,Fc=/,? & /,Uc=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Wc=/[()=,{}\[\]\/\s]/,$c=/\\(\\)?/g,qc=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ji=/\w*$/,zc=/^[-+]0x[0-9a-f]+$/i,Hc=/^0b[01]+$/i,Jc=/^\[object .+?Constructor\]$/,Gc=/^0o[0-7]+$/i,Kc=/^(?:0|[1-9]\d*)$/,Yc=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,nr=/($^)/,Vc=/['\n\r\u2028\u2029\\]/g,rr="\\ud800-\\udfff",Zc="\\u0300-\\u036f",Xc="\\ufe20-\\ufe2f",Qc="\\u20d0-\\u20ff",Gi=Zc+Xc+Qc,Ki="\\u2700-\\u27bf",Yi="a-z\\xdf-\\xf6\\xf8-\\xff",jc="\\xac\\xb1\\xd7\\xf7",th="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",eh="\\u2000-\\u206f",nh=" \\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",Vi="A-Z\\xc0-\\xd6\\xd8-\\xde",Zi="\\ufe0e\\ufe0f",Xi=jc+th+eh+nh,ls="['’]",rh="["+rr+"]",Qi="["+Xi+"]",sr="["+Gi+"]",ji="\\d+",sh="["+Ki+"]",to="["+Yi+"]",eo="[^"+rr+Xi+ji+Ki+Yi+Vi+"]",fs="\\ud83c[\\udffb-\\udfff]",ih="(?:"+sr+"|"+fs+")",no="[^"+rr+"]",ds="(?:\\ud83c[\\udde6-\\uddff]){2}",ps="[\\ud800-\\udbff][\\udc00-\\udfff]",Qe="["+Vi+"]",ro="\\u200d",so="(?:"+to+"|"+eo+")",oh="(?:"+Qe+"|"+eo+")",io="(?:"+ls+"(?:d|ll|m|re|s|t|ve))?",oo="(?:"+ls+"(?:D|LL|M|RE|S|T|VE))?",ao=ih+"?",uo="["+Zi+"]?",ah="(?:"+ro+"(?:"+[no,ds,ps].join("|")+")"+uo+ao+")*",uh="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ch="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",co=uo+ao+ah,hh="(?:"+[sh,ds,ps].join("|")+")"+co,lh="(?:"+[no+sr+"?",sr,ds,ps,rh].join("|")+")",fh=RegExp(ls,"g"),dh=RegExp(sr,"g"),gs=RegExp(fs+"(?="+fs+")|"+lh+co,"g"),ph=RegExp([Qe+"?"+to+"+"+io+"(?="+[Qi,Qe,"$"].join("|")+")",oh+"+"+oo+"(?="+[Qi,Qe+so,"$"].join("|")+")",Qe+"?"+so+"+"+io,Qe+"+"+oo,ch,uh,ji,hh].join("|"),"g"),gh=RegExp("["+ro+rr+Gi+Zi+"]"),_h=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,bh=["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"],mh=-1,tt={};tt[ts]=tt[es]=tt[ns]=tt[rs]=tt[ss]=tt[is]=tt[os]=tt[as]=tt[us]=!0,tt[Ze]=tt[Qn]=tt[Tn]=tt[vn]=tt[Xe]=tt[wn]=tt[jn]=tt[tr]=tt[Vt]=tt[yn]=tt[le]=tt[Sn]=tt[Zt]=tt[xn]=tt[En]=!1;var j={};j[Ze]=j[Qn]=j[Tn]=j[Xe]=j[vn]=j[wn]=j[ts]=j[es]=j[ns]=j[rs]=j[ss]=j[Vt]=j[yn]=j[le]=j[Sn]=j[Zt]=j[xn]=j[er]=j[is]=j[os]=j[as]=j[us]=!0,j[jn]=j[tr]=j[En]=!1;var vh={À:"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"},wh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},yh={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Sh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xh=parseFloat,Eh=parseInt,ho=typeof $n=="object"&&$n&&$n.Object===Object&&$n,Th=typeof self=="object"&&self&&self.Object===Object&&self,_t=ho||Th||Function("return this")(),_s=i&&!i.nodeType&&i,De=_s&&!0&&n&&!n.nodeType&&n,lo=De&&De.exports===_s,bs=lo&&ho.process,Ut=function(){try{var _=De&&De.require&&De.require("util").types;return _||bs&&bs.binding&&bs.binding("util")}catch{}}(),fo=Ut&&Ut.isArrayBuffer,po=Ut&&Ut.isDate,go=Ut&&Ut.isMap,_o=Ut&&Ut.isRegExp,bo=Ut&&Ut.isSet,mo=Ut&&Ut.isTypedArray;function Mt(_,y,v){switch(v.length){case 0:return _.call(y);case 1:return _.call(y,v[0]);case 2:return _.call(y,v[0],v[1]);case 3:return _.call(y,v[0],v[1],v[2])}return _.apply(y,v)}function Ah(_,y,v,O){for(var N=-1,Y=_==null?0:_.length;++N<Y;){var lt=_[N];y(O,lt,v(lt),_)}return O}function Wt(_,y){for(var v=-1,O=_==null?0:_.length;++v<O&&y(_[v],v,_)!==!1;);return _}function Ch(_,y){for(var v=_==null?0:_.length;v--&&y(_[v],v,_)!==!1;);return _}function vo(_,y){for(var v=-1,O=_==null?0:_.length;++v<O;)if(!y(_[v],v,_))return!1;return!0}function Se(_,y){for(var v=-1,O=_==null?0:_.length,N=0,Y=[];++v<O;){var lt=_[v];y(lt,v,_)&&(Y[N++]=lt)}return Y}function ir(_,y){var v=_==null?0:_.length;return!!v&&je(_,y,0)>-1}function ms(_,y,v){for(var O=-1,N=_==null?0:_.length;++O<N;)if(v(y,_[O]))return!0;return!1}function et(_,y){for(var v=-1,O=_==null?0:_.length,N=Array(O);++v<O;)N[v]=y(_[v],v,_);return N}function xe(_,y){for(var v=-1,O=y.length,N=_.length;++v<O;)_[N+v]=y[v];return _}function vs(_,y,v,O){var N=-1,Y=_==null?0:_.length;for(O&&Y&&(v=_[++N]);++N<Y;)v=y(v,_[N],N,_);return v}function Ih(_,y,v,O){var N=_==null?0:_.length;for(O&&N&&(v=_[--N]);N--;)v=y(v,_[N],N,_);return v}function ws(_,y){for(var v=-1,O=_==null?0:_.length;++v<O;)if(y(_[v],v,_))return!0;return!1}var Rh=ys("length");function Mh(_){return _.split("")}function Ph(_){return _.match(Uc)||[]}function wo(_,y,v){var O;return v(_,function(N,Y,lt){if(y(N,Y,lt))return O=Y,!1}),O}function or(_,y,v,O){for(var N=_.length,Y=v+(O?1:-1);O?Y--:++Y<N;)if(y(_[Y],Y,_))return Y;return-1}function je(_,y,v){return y===y?zh(_,y,v):or(_,yo,v)}function Oh(_,y,v,O){for(var N=v-1,Y=_.length;++N<Y;)if(O(_[N],y))return N;return-1}function yo(_){return _!==_}function So(_,y){var v=_==null?0:_.length;return v?xs(_,y)/v:Xn}function ys(_){return function(y){return y==null?r:y[_]}}function Ss(_){return function(y){return _==null?r:_[y]}}function xo(_,y,v,O,N){return N(_,function(Y,lt,Q){v=O?(O=!1,Y):y(v,Y,lt,Q)}),v}function Lh(_,y){var v=_.length;for(_.sort(y);v--;)_[v]=_[v].value;return _}function xs(_,y){for(var v,O=-1,N=_.length;++O<N;){var Y=y(_[O]);Y!==r&&(v=v===r?Y:v+Y)}return v}function Es(_,y){for(var v=-1,O=Array(_);++v<_;)O[v]=y(v);return O}function Bh(_,y){return et(y,function(v){return[v,_[v]]})}function Eo(_){return _&&_.slice(0,Io(_)+1).replace(hs,"")}function Pt(_){return function(y){return _(y)}}function Ts(_,y){return et(y,function(v){return _[v]})}function An(_,y){return _.has(y)}function To(_,y){for(var v=-1,O=_.length;++v<O&&je(y,_[v],0)>-1;);return v}function Ao(_,y){for(var v=_.length;v--&&je(y,_[v],0)>-1;);return v}function kh(_,y){for(var v=_.length,O=0;v--;)_[v]===y&&++O;return O}var Dh=Ss(vh),Nh=Ss(wh);function Fh(_){return"\\"+Sh[_]}function Uh(_,y){return _==null?r:_[y]}function tn(_){return gh.test(_)}function Wh(_){return _h.test(_)}function $h(_){for(var y,v=[];!(y=_.next()).done;)v.push(y.value);return v}function As(_){var y=-1,v=Array(_.size);return _.forEach(function(O,N){v[++y]=[N,O]}),v}function Co(_,y){return function(v){return _(y(v))}}function Ee(_,y){for(var v=-1,O=_.length,N=0,Y=[];++v<O;){var lt=_[v];(lt===y||lt===P)&&(_[v]=P,Y[N++]=v)}return Y}function ar(_){var y=-1,v=Array(_.size);return _.forEach(function(O){v[++y]=O}),v}function qh(_){var y=-1,v=Array(_.size);return _.forEach(function(O){v[++y]=[O,O]}),v}function zh(_,y,v){for(var O=v-1,N=_.length;++O<N;)if(_[O]===y)return O;return-1}function Hh(_,y,v){for(var O=v+1;O--;)if(_[O]===y)return O;return O}function en(_){return tn(_)?Gh(_):Rh(_)}function Xt(_){return tn(_)?Kh(_):Mh(_)}function Io(_){for(var y=_.length;y--&&kc.test(_.charAt(y)););return y}var Jh=Ss(yh);function Gh(_){for(var y=gs.lastIndex=0;gs.test(_);)++y;return y}function Kh(_){return _.match(gs)||[]}function Yh(_){return _.match(ph)||[]}var Vh=function _(y){y=y==null?_t:nn.defaults(_t.Object(),y,nn.pick(_t,bh));var v=y.Array,O=y.Date,N=y.Error,Y=y.Function,lt=y.Math,Q=y.Object,Cs=y.RegExp,Zh=y.String,$t=y.TypeError,ur=v.prototype,Xh=Y.prototype,rn=Q.prototype,cr=y["__core-js_shared__"],hr=Xh.toString,Z=rn.hasOwnProperty,Qh=0,Ro=function(){var t=/[^.]+$/.exec(cr&&cr.keys&&cr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),lr=rn.toString,jh=hr.call(Q),tl=_t._,el=Cs("^"+hr.call(Z).replace(cs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),fr=lo?y.Buffer:r,Te=y.Symbol,dr=y.Uint8Array,Mo=fr?fr.allocUnsafe:r,pr=Co(Q.getPrototypeOf,Q),Po=Q.create,Oo=rn.propertyIsEnumerable,gr=ur.splice,Lo=Te?Te.isConcatSpreadable:r,Cn=Te?Te.iterator:r,Ne=Te?Te.toStringTag:r,_r=function(){try{var t=qe(Q,"defineProperty");return t({},"",{}),t}catch{}}(),nl=y.clearTimeout!==_t.clearTimeout&&y.clearTimeout,rl=O&&O.now!==_t.Date.now&&O.now,sl=y.setTimeout!==_t.setTimeout&&y.setTimeout,br=lt.ceil,mr=lt.floor,Is=Q.getOwnPropertySymbols,il=fr?fr.isBuffer:r,Bo=y.isFinite,ol=ur.join,al=Co(Q.keys,Q),ft=lt.max,mt=lt.min,ul=O.now,cl=y.parseInt,ko=lt.random,hl=ur.reverse,Rs=qe(y,"DataView"),In=qe(y,"Map"),Ms=qe(y,"Promise"),sn=qe(y,"Set"),Rn=qe(y,"WeakMap"),Mn=qe(Q,"create"),vr=Rn&&new Rn,on={},ll=ze(Rs),fl=ze(In),dl=ze(Ms),pl=ze(sn),gl=ze(Rn),wr=Te?Te.prototype:r,Pn=wr?wr.valueOf:r,Do=wr?wr.toString:r;function c(t){if(it(t)&&!F(t)&&!(t instanceof J)){if(t instanceof qt)return t;if(Z.call(t,"__wrapped__"))return Na(t)}return new qt(t)}var an=function(){function t(){}return function(e){if(!nt(e))return{};if(Po)return Po(e);t.prototype=e;var s=new t;return t.prototype=r,s}}();function yr(){}function qt(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=r}c.templateSettings={escape:Rc,evaluate:Mc,interpolate:Hi,variable:"",imports:{_:c}},c.prototype=yr.prototype,c.prototype.constructor=c,qt.prototype=an(yr.prototype),qt.prototype.constructor=qt;function J(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ie,this.__views__=[]}function _l(){var t=new J(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 bl(){if(this.__filtered__){var t=new J(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function ml(){var t=this.__wrapped__.value(),e=this.__dir__,s=F(t),o=e<0,u=s?t.length:0,l=Pf(0,u,this.__views__),d=l.start,g=l.end,b=g-d,x=o?g:d-1,E=this.__iteratees__,T=E.length,M=0,L=mt(b,this.__takeCount__);if(!s||!o&&u==b&&L==b)return oa(t,this.__actions__);var k=[];t:for(;b--&&M<L;){x+=e;for(var $=-1,D=t[x];++$<T;){var H=E[$],G=H.iteratee,Bt=H.type,xt=G(D);if(Bt==fc)D=xt;else if(!xt){if(Bt==wt)continue t;break t}}k[M++]=D}return k}J.prototype=an(yr.prototype),J.prototype.constructor=J;function Fe(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function vl(){this.__data__=Mn?Mn(null):{},this.size=0}function wl(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function yl(t){var e=this.__data__;if(Mn){var s=e[t];return s===w?r:s}return Z.call(e,t)?e[t]:r}function Sl(t){var e=this.__data__;return Mn?e[t]!==r:Z.call(e,t)}function xl(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Mn&&e===r?w:e,this}Fe.prototype.clear=vl,Fe.prototype.delete=wl,Fe.prototype.get=yl,Fe.prototype.has=Sl,Fe.prototype.set=xl;function fe(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function El(){this.__data__=[],this.size=0}function Tl(t){var e=this.__data__,s=Sr(e,t);if(s<0)return!1;var o=e.length-1;return s==o?e.pop():gr.call(e,s,1),--this.size,!0}function Al(t){var e=this.__data__,s=Sr(e,t);return s<0?r:e[s][1]}function Cl(t){return Sr(this.__data__,t)>-1}function Il(t,e){var s=this.__data__,o=Sr(s,t);return o<0?(++this.size,s.push([t,e])):s[o][1]=e,this}fe.prototype.clear=El,fe.prototype.delete=Tl,fe.prototype.get=Al,fe.prototype.has=Cl,fe.prototype.set=Il;function de(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function Rl(){this.size=0,this.__data__={hash:new Fe,map:new(In||fe),string:new Fe}}function Ml(t){var e=Br(this,t).delete(t);return this.size-=e?1:0,e}function Pl(t){return Br(this,t).get(t)}function Ol(t){return Br(this,t).has(t)}function Ll(t,e){var s=Br(this,t),o=s.size;return s.set(t,e),this.size+=s.size==o?0:1,this}de.prototype.clear=Rl,de.prototype.delete=Ml,de.prototype.get=Pl,de.prototype.has=Ol,de.prototype.set=Ll;function Ue(t){var e=-1,s=t==null?0:t.length;for(this.__data__=new de;++e<s;)this.add(t[e])}function Bl(t){return this.__data__.set(t,w),this}function kl(t){return this.__data__.has(t)}Ue.prototype.add=Ue.prototype.push=Bl,Ue.prototype.has=kl;function Qt(t){var e=this.__data__=new fe(t);this.size=e.size}function Dl(){this.__data__=new fe,this.size=0}function Nl(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s}function Fl(t){return this.__data__.get(t)}function Ul(t){return this.__data__.has(t)}function Wl(t,e){var s=this.__data__;if(s instanceof fe){var o=s.__data__;if(!In||o.length<h-1)return o.push([t,e]),this.size=++s.size,this;s=this.__data__=new de(o)}return s.set(t,e),this.size=s.size,this}Qt.prototype.clear=Dl,Qt.prototype.delete=Nl,Qt.prototype.get=Fl,Qt.prototype.has=Ul,Qt.prototype.set=Wl;function No(t,e){var s=F(t),o=!s&&He(t),u=!s&&!o&&Me(t),l=!s&&!o&&!u&&ln(t),d=s||o||u||l,g=d?Es(t.length,Zh):[],b=g.length;for(var x in t)(e||Z.call(t,x))&&!(d&&(x=="length"||u&&(x=="offset"||x=="parent")||l&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||be(x,b)))&&g.push(x);return g}function Fo(t){var e=t.length;return e?t[$s(0,e-1)]:r}function $l(t,e){return kr(At(t),We(e,0,t.length))}function ql(t){return kr(At(t))}function Ps(t,e,s){(s!==r&&!jt(t[e],s)||s===r&&!(e in t))&&pe(t,e,s)}function On(t,e,s){var o=t[e];(!(Z.call(t,e)&&jt(o,s))||s===r&&!(e in t))&&pe(t,e,s)}function Sr(t,e){for(var s=t.length;s--;)if(jt(t[s][0],e))return s;return-1}function zl(t,e,s,o){return Ae(t,function(u,l,d){e(o,u,s(u),d)}),o}function Uo(t,e){return t&&ae(e,gt(e),t)}function Hl(t,e){return t&&ae(e,It(e),t)}function pe(t,e,s){e=="__proto__"&&_r?_r(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function Os(t,e){for(var s=-1,o=e.length,u=v(o),l=t==null;++s<o;)u[s]=l?r:fi(t,e[s]);return u}function We(t,e,s){return t===t&&(s!==r&&(t=t<=s?t:s),e!==r&&(t=t>=e?t:e)),t}function zt(t,e,s,o,u,l){var d,g=e&C,b=e&A,x=e&R;if(s&&(d=u?s(t,o,u,l):s(t)),d!==r)return d;if(!nt(t))return t;var E=F(t);if(E){if(d=Lf(t),!g)return At(t,d)}else{var T=vt(t),M=T==tr||T==Wi;if(Me(t))return ca(t,g);if(T==le||T==Ze||M&&!u){if(d=b||M?{}:Ia(t),!g)return b?Sf(t,Hl(d,t)):yf(t,Uo(d,t))}else{if(!j[T])return u?t:{};d=Bf(t,T,g)}}l||(l=new Qt);var L=l.get(t);if(L)return L;l.set(t,d),ru(t)?t.forEach(function(D){d.add(zt(D,e,s,D,t,l))}):eu(t)&&t.forEach(function(D,H){d.set(H,zt(D,e,s,H,t,l))});var k=x?b?Qs:Xs:b?It:gt,$=E?r:k(t);return Wt($||t,function(D,H){$&&(H=D,D=t[H]),On(d,H,zt(D,e,s,H,t,l))}),d}function Jl(t){var e=gt(t);return function(s){return Wo(s,t,e)}}function Wo(t,e,s){var o=s.length;if(t==null)return!o;for(t=Q(t);o--;){var u=s[o],l=e[u],d=t[u];if(d===r&&!(u in t)||!l(d))return!1}return!0}function $o(t,e,s){if(typeof t!="function")throw new $t(p);return Un(function(){t.apply(r,s)},e)}function Ln(t,e,s,o){var u=-1,l=ir,d=!0,g=t.length,b=[],x=e.length;if(!g)return b;s&&(e=et(e,Pt(s))),o?(l=ms,d=!1):e.length>=h&&(l=An,d=!1,e=new Ue(e));t:for(;++u<g;){var E=t[u],T=s==null?E:s(E);if(E=o||E!==0?E:0,d&&T===T){for(var M=x;M--;)if(e[M]===T)continue t;b.push(E)}else l(e,T,o)||b.push(E)}return b}var Ae=pa(oe),qo=pa(Bs,!0);function Gl(t,e){var s=!0;return Ae(t,function(o,u,l){return s=!!e(o,u,l),s}),s}function xr(t,e,s){for(var o=-1,u=t.length;++o<u;){var l=t[o],d=e(l);if(d!=null&&(g===r?d===d&&!Lt(d):s(d,g)))var g=d,b=l}return b}function Kl(t,e,s,o){var u=t.length;for(s=W(s),s<0&&(s=-s>u?0:u+s),o=o===r||o>u?u:W(o),o<0&&(o+=u),o=s>o?0:iu(o);s<o;)t[s++]=e;return t}function zo(t,e){var s=[];return Ae(t,function(o,u,l){e(o,u,l)&&s.push(o)}),s}function bt(t,e,s,o,u){var l=-1,d=t.length;for(s||(s=Df),u||(u=[]);++l<d;){var g=t[l];e>0&&s(g)?e>1?bt(g,e-1,s,o,u):xe(u,g):o||(u[u.length]=g)}return u}var Ls=ga(),Ho=ga(!0);function oe(t,e){return t&&Ls(t,e,gt)}function Bs(t,e){return t&&Ho(t,e,gt)}function Er(t,e){return Se(e,function(s){return me(t[s])})}function $e(t,e){e=Ie(e,t);for(var s=0,o=e.length;t!=null&&s<o;)t=t[ue(e[s++])];return s&&s==o?t:r}function Jo(t,e,s){var o=e(t);return F(t)?o:xe(o,s(t))}function yt(t){return t==null?t===r?Sc:wc:Ne&&Ne in Q(t)?Mf(t):zf(t)}function ks(t,e){return t>e}function Yl(t,e){return t!=null&&Z.call(t,e)}function Vl(t,e){return t!=null&&e in Q(t)}function Zl(t,e,s){return t>=mt(e,s)&&t<ft(e,s)}function Ds(t,e,s){for(var o=s?ms:ir,u=t[0].length,l=t.length,d=l,g=v(l),b=1/0,x=[];d--;){var E=t[d];d&&e&&(E=et(E,Pt(e))),b=mt(E.length,b),g[d]=!s&&(e||u>=120&&E.length>=120)?new Ue(d&&E):r}E=t[0];var T=-1,M=g[0];t:for(;++T<u&&x.length<b;){var L=E[T],k=e?e(L):L;if(L=s||L!==0?L:0,!(M?An(M,k):o(x,k,s))){for(d=l;--d;){var $=g[d];if(!($?An($,k):o(t[d],k,s)))continue t}M&&M.push(k),x.push(L)}}return x}function Xl(t,e,s,o){return oe(t,function(u,l,d){e(o,s(u),l,d)}),o}function Bn(t,e,s){e=Ie(e,t),t=Oa(t,e);var o=t==null?t:t[ue(Jt(e))];return o==null?r:Mt(o,t,s)}function Go(t){return it(t)&&yt(t)==Ze}function Ql(t){return it(t)&&yt(t)==Tn}function jl(t){return it(t)&&yt(t)==wn}function kn(t,e,s,o,u){return t===e?!0:t==null||e==null||!it(t)&&!it(e)?t!==t&&e!==e:tf(t,e,s,o,kn,u)}function tf(t,e,s,o,u,l){var d=F(t),g=F(e),b=d?Qn:vt(t),x=g?Qn:vt(e);b=b==Ze?le:b,x=x==Ze?le:x;var E=b==le,T=x==le,M=b==x;if(M&&Me(t)){if(!Me(e))return!1;d=!0,E=!1}if(M&&!E)return l||(l=new Qt),d||ln(t)?Ta(t,e,s,o,u,l):If(t,e,b,s,o,u,l);if(!(s&K)){var L=E&&Z.call(t,"__wrapped__"),k=T&&Z.call(e,"__wrapped__");if(L||k){var $=L?t.value():t,D=k?e.value():e;return l||(l=new Qt),u($,D,s,o,l)}}return M?(l||(l=new Qt),Rf(t,e,s,o,u,l)):!1}function ef(t){return it(t)&&vt(t)==Vt}function Ns(t,e,s,o){var u=s.length,l=u,d=!o;if(t==null)return!l;for(t=Q(t);u--;){var g=s[u];if(d&&g[2]?g[1]!==t[g[0]]:!(g[0]in t))return!1}for(;++u<l;){g=s[u];var b=g[0],x=t[b],E=g[1];if(d&&g[2]){if(x===r&&!(b in t))return!1}else{var T=new Qt;if(o)var M=o(x,E,b,t,e,T);if(!(M===r?kn(E,x,K|Tt,o,T):M))return!1}}return!0}function Ko(t){if(!nt(t)||Ff(t))return!1;var e=me(t)?el:Jc;return e.test(ze(t))}function nf(t){return it(t)&&yt(t)==Sn}function rf(t){return it(t)&&vt(t)==Zt}function sf(t){return it(t)&&$r(t.length)&&!!tt[yt(t)]}function Yo(t){return typeof t=="function"?t:t==null?Rt:typeof t=="object"?F(t)?Xo(t[0],t[1]):Zo(t):_u(t)}function Fs(t){if(!Fn(t))return al(t);var e=[];for(var s in Q(t))Z.call(t,s)&&s!="constructor"&&e.push(s);return e}function of(t){if(!nt(t))return qf(t);var e=Fn(t),s=[];for(var o in t)o=="constructor"&&(e||!Z.call(t,o))||s.push(o);return s}function Us(t,e){return t<e}function Vo(t,e){var s=-1,o=Ct(t)?v(t.length):[];return Ae(t,function(u,l,d){o[++s]=e(u,l,d)}),o}function Zo(t){var e=ti(t);return e.length==1&&e[0][2]?Ma(e[0][0],e[0][1]):function(s){return s===t||Ns(s,t,e)}}function Xo(t,e){return ni(t)&&Ra(e)?Ma(ue(t),e):function(s){var o=fi(s,t);return o===r&&o===e?di(s,t):kn(e,o,K|Tt)}}function Tr(t,e,s,o,u){t!==e&&Ls(e,function(l,d){if(u||(u=new Qt),nt(l))af(t,e,d,s,Tr,o,u);else{var g=o?o(si(t,d),l,d+"",t,e,u):r;g===r&&(g=l),Ps(t,d,g)}},It)}function af(t,e,s,o,u,l,d){var g=si(t,s),b=si(e,s),x=d.get(b);if(x){Ps(t,s,x);return}var E=l?l(g,b,s+"",t,e,d):r,T=E===r;if(T){var M=F(b),L=!M&&Me(b),k=!M&&!L&&ln(b);E=b,M||L||k?F(g)?E=g:ot(g)?E=At(g):L?(T=!1,E=ca(b,!0)):k?(T=!1,E=ha(b,!0)):E=[]:Wn(b)||He(b)?(E=g,He(g)?E=ou(g):(!nt(g)||me(g))&&(E=Ia(b))):T=!1}T&&(d.set(b,E),u(E,b,o,l,d),d.delete(b)),Ps(t,s,E)}function Qo(t,e){var s=t.length;if(s)return e+=e<0?s:0,be(e,s)?t[e]:r}function jo(t,e,s){e.length?e=et(e,function(l){return F(l)?function(d){return $e(d,l.length===1?l[0]:l)}:l}):e=[Rt];var o=-1;e=et(e,Pt(B()));var u=Vo(t,function(l,d,g){var b=et(e,function(x){return x(l)});return{criteria:b,index:++o,value:l}});return Lh(u,function(l,d){return wf(l,d,s)})}function uf(t,e){return ta(t,e,function(s,o){return di(t,o)})}function ta(t,e,s){for(var o=-1,u=e.length,l={};++o<u;){var d=e[o],g=$e(t,d);s(g,d)&&Dn(l,Ie(d,t),g)}return l}function cf(t){return function(e){return $e(e,t)}}function Ws(t,e,s,o){var u=o?Oh:je,l=-1,d=e.length,g=t;for(t===e&&(e=At(e)),s&&(g=et(t,Pt(s)));++l<d;)for(var b=0,x=e[l],E=s?s(x):x;(b=u(g,E,b,o))>-1;)g!==t&&gr.call(g,b,1),gr.call(t,b,1);return t}function ea(t,e){for(var s=t?e.length:0,o=s-1;s--;){var u=e[s];if(s==o||u!==l){var l=u;be(u)?gr.call(t,u,1):Hs(t,u)}}return t}function $s(t,e){return t+mr(ko()*(e-t+1))}function hf(t,e,s,o){for(var u=-1,l=ft(br((e-t)/(s||1)),0),d=v(l);l--;)d[o?l:++u]=t,t+=s;return d}function qs(t,e){var s="";if(!t||e<1||e>ye)return s;do e%2&&(s+=t),e=mr(e/2),e&&(t+=t);while(e);return s}function z(t,e){return ii(Pa(t,e,Rt),t+"")}function lf(t){return Fo(fn(t))}function ff(t,e){var s=fn(t);return kr(s,We(e,0,s.length))}function Dn(t,e,s,o){if(!nt(t))return t;e=Ie(e,t);for(var u=-1,l=e.length,d=l-1,g=t;g!=null&&++u<l;){var b=ue(e[u]),x=s;if(b==="__proto__"||b==="constructor"||b==="prototype")return t;if(u!=d){var E=g[b];x=o?o(E,b,g):r,x===r&&(x=nt(E)?E:be(e[u+1])?[]:{})}On(g,b,x),g=g[b]}return t}var na=vr?function(t,e){return vr.set(t,e),t}:Rt,df=_r?function(t,e){return _r(t,"toString",{configurable:!0,enumerable:!1,value:gi(e),writable:!0})}:Rt;function pf(t){return kr(fn(t))}function Ht(t,e,s){var o=-1,u=t.length;e<0&&(e=-e>u?0:u+e),s=s>u?u:s,s<0&&(s+=u),u=e>s?0:s-e>>>0,e>>>=0;for(var l=v(u);++o<u;)l[o]=t[o+e];return l}function gf(t,e){var s;return Ae(t,function(o,u,l){return s=e(o,u,l),!s}),!!s}function Ar(t,e,s){var o=0,u=t==null?o:t.length;if(typeof e=="number"&&e===e&&u<=_c){for(;o<u;){var l=o+u>>>1,d=t[l];d!==null&&!Lt(d)&&(s?d<=e:d<e)?o=l+1:u=l}return u}return zs(t,e,Rt,s)}function zs(t,e,s,o){var u=0,l=t==null?0:t.length;if(l===0)return 0;e=s(e);for(var d=e!==e,g=e===null,b=Lt(e),x=e===r;u<l;){var E=mr((u+l)/2),T=s(t[E]),M=T!==r,L=T===null,k=T===T,$=Lt(T);if(d)var D=o||k;else x?D=k&&(o||M):g?D=k&&M&&(o||!L):b?D=k&&M&&!L&&(o||!$):L||$?D=!1:D=o?T<=e:T<e;D?u=E+1:l=E}return mt(l,gc)}function ra(t,e){for(var s=-1,o=t.length,u=0,l=[];++s<o;){var d=t[s],g=e?e(d):d;if(!s||!jt(g,b)){var b=g;l[u++]=d===0?0:d}}return l}function sa(t){return typeof t=="number"?t:Lt(t)?Xn:+t}function Ot(t){if(typeof t=="string")return t;if(F(t))return et(t,Ot)+"";if(Lt(t))return Do?Do.call(t):"";var e=t+"";return e=="0"&&1/t==-ke?"-0":e}function Ce(t,e,s){var o=-1,u=ir,l=t.length,d=!0,g=[],b=g;if(s)d=!1,u=ms;else if(l>=h){var x=e?null:Af(t);if(x)return ar(x);d=!1,u=An,b=new Ue}else b=e?[]:g;t:for(;++o<l;){var E=t[o],T=e?e(E):E;if(E=s||E!==0?E:0,d&&T===T){for(var M=b.length;M--;)if(b[M]===T)continue t;e&&b.push(T),g.push(E)}else u(b,T,s)||(b!==g&&b.push(T),g.push(E))}return g}function Hs(t,e){return e=Ie(e,t),t=Oa(t,e),t==null||delete t[ue(Jt(e))]}function ia(t,e,s,o){return Dn(t,e,s($e(t,e)),o)}function Cr(t,e,s,o){for(var u=t.length,l=o?u:-1;(o?l--:++l<u)&&e(t[l],l,t););return s?Ht(t,o?0:l,o?l+1:u):Ht(t,o?l+1:0,o?u:l)}function oa(t,e){var s=t;return s instanceof J&&(s=s.value()),vs(e,function(o,u){return u.func.apply(u.thisArg,xe([o],u.args))},s)}function Js(t,e,s){var o=t.length;if(o<2)return o?Ce(t[0]):[];for(var u=-1,l=v(o);++u<o;)for(var d=t[u],g=-1;++g<o;)g!=u&&(l[u]=Ln(l[u]||d,t[g],e,s));return Ce(bt(l,1),e,s)}function aa(t,e,s){for(var o=-1,u=t.length,l=e.length,d={};++o<u;){var g=o<l?e[o]:r;s(d,t[o],g)}return d}function Gs(t){return ot(t)?t:[]}function Ks(t){return typeof t=="function"?t:Rt}function Ie(t,e){return F(t)?t:ni(t,e)?[t]:Da(V(t))}var _f=z;function Re(t,e,s){var o=t.length;return s=s===r?o:s,!e&&s>=o?t:Ht(t,e,s)}var ua=nl||function(t){return _t.clearTimeout(t)};function ca(t,e){if(e)return t.slice();var s=t.length,o=Mo?Mo(s):new t.constructor(s);return t.copy(o),o}function Ys(t){var e=new t.constructor(t.byteLength);return new dr(e).set(new dr(t)),e}function bf(t,e){var s=e?Ys(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}function mf(t){var e=new t.constructor(t.source,Ji.exec(t));return e.lastIndex=t.lastIndex,e}function vf(t){return Pn?Q(Pn.call(t)):{}}function ha(t,e){var s=e?Ys(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}function la(t,e){if(t!==e){var s=t!==r,o=t===null,u=t===t,l=Lt(t),d=e!==r,g=e===null,b=e===e,x=Lt(e);if(!g&&!x&&!l&&t>e||l&&d&&b&&!g&&!x||o&&d&&b||!s&&b||!u)return 1;if(!o&&!l&&!x&&t<e||x&&s&&u&&!o&&!l||g&&s&&u||!d&&u||!b)return-1}return 0}function wf(t,e,s){for(var o=-1,u=t.criteria,l=e.criteria,d=u.length,g=s.length;++o<d;){var b=la(u[o],l[o]);if(b){if(o>=g)return b;var x=s[o];return b*(x=="desc"?-1:1)}}return t.index-e.index}function fa(t,e,s,o){for(var u=-1,l=t.length,d=s.length,g=-1,b=e.length,x=ft(l-d,0),E=v(b+x),T=!o;++g<b;)E[g]=e[g];for(;++u<d;)(T||u<l)&&(E[s[u]]=t[u]);for(;x--;)E[g++]=t[u++];return E}function da(t,e,s,o){for(var u=-1,l=t.length,d=-1,g=s.length,b=-1,x=e.length,E=ft(l-g,0),T=v(E+x),M=!o;++u<E;)T[u]=t[u];for(var L=u;++b<x;)T[L+b]=e[b];for(;++d<g;)(M||u<l)&&(T[L+s[d]]=t[u++]);return T}function At(t,e){var s=-1,o=t.length;for(e||(e=v(o));++s<o;)e[s]=t[s];return e}function ae(t,e,s,o){var u=!s;s||(s={});for(var l=-1,d=e.length;++l<d;){var g=e[l],b=o?o(s[g],t[g],g,s,t):r;b===r&&(b=t[g]),u?pe(s,g,b):On(s,g,b)}return s}function yf(t,e){return ae(t,ei(t),e)}function Sf(t,e){return ae(t,Aa(t),e)}function Ir(t,e){return function(s,o){var u=F(s)?Ah:zl,l=e?e():{};return u(s,t,B(o,2),l)}}function un(t){return z(function(e,s){var o=-1,u=s.length,l=u>1?s[u-1]:r,d=u>2?s[2]:r;for(l=t.length>3&&typeof l=="function"?(u--,l):r,d&&St(s[0],s[1],d)&&(l=u<3?r:l,u=1),e=Q(e);++o<u;){var g=s[o];g&&t(e,g,o,l)}return e})}function pa(t,e){return function(s,o){if(s==null)return s;if(!Ct(s))return t(s,o);for(var u=s.length,l=e?u:-1,d=Q(s);(e?l--:++l<u)&&o(d[l],l,d)!==!1;);return s}}function ga(t){return function(e,s,o){for(var u=-1,l=Q(e),d=o(e),g=d.length;g--;){var b=d[t?g:++u];if(s(l[b],b,l)===!1)break}return e}}function xf(t,e,s){var o=e&pt,u=Nn(t);function l(){var d=this&&this!==_t&&this instanceof l?u:t;return d.apply(o?s:this,arguments)}return l}function _a(t){return function(e){e=V(e);var s=tn(e)?Xt(e):r,o=s?s[0]:e.charAt(0),u=s?Re(s,1).join(""):e.slice(1);return o[t]()+u}}function cn(t){return function(e){return vs(pu(du(e).replace(fh,"")),t,"")}}function Nn(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 s=an(t.prototype),o=t.apply(s,e);return nt(o)?o:s}}function Ef(t,e,s){var o=Nn(t);function u(){for(var l=arguments.length,d=v(l),g=l,b=hn(u);g--;)d[g]=arguments[g];var x=l<3&&d[0]!==b&&d[l-1]!==b?[]:Ee(d,b);if(l-=x.length,l<s)return ya(t,e,Rr,u.placeholder,r,d,x,r,r,s-l);var E=this&&this!==_t&&this instanceof u?o:t;return Mt(E,this,d)}return u}function ba(t){return function(e,s,o){var u=Q(e);if(!Ct(e)){var l=B(s,3);e=gt(e),s=function(g){return l(u[g],g,u)}}var d=t(e,s,o);return d>-1?u[l?e[d]:d]:r}}function ma(t){return _e(function(e){var s=e.length,o=s,u=qt.prototype.thru;for(t&&e.reverse();o--;){var l=e[o];if(typeof l!="function")throw new $t(p);if(u&&!d&&Lr(l)=="wrapper")var d=new qt([],!0)}for(o=d?o:s;++o<s;){l=e[o];var g=Lr(l),b=g=="wrapper"?js(l):r;b&&ri(b[0])&&b[1]==(q|Kt|Yt|ct)&&!b[4].length&&b[9]==1?d=d[Lr(b[0])].apply(d,b[3]):d=l.length==1&&ri(l)?d[g]():d.thru(l)}return function(){var x=arguments,E=x[0];if(d&&x.length==1&&F(E))return d.plant(E).value();for(var T=0,M=s?e[T].apply(this,x):E;++T<s;)M=e[T].call(this,M);return M}})}function Rr(t,e,s,o,u,l,d,g,b,x){var E=e&q,T=e&pt,M=e&ut,L=e&(Kt|Le),k=e&X,$=M?r:Nn(t);function D(){for(var H=arguments.length,G=v(H),Bt=H;Bt--;)G[Bt]=arguments[Bt];if(L)var xt=hn(D),kt=kh(G,xt);if(o&&(G=fa(G,o,u,L)),l&&(G=da(G,l,d,L)),H-=kt,L&&H<x){var at=Ee(G,xt);return ya(t,e,Rr,D.placeholder,s,G,at,g,b,x-H)}var te=T?s:this,we=M?te[t]:t;return H=G.length,g?G=Hf(G,g):k&&H>1&&G.reverse(),E&&b<H&&(G.length=b),this&&this!==_t&&this instanceof D&&(we=$||Nn(we)),we.apply(te,G)}return D}function va(t,e){return function(s,o){return Xl(s,t,e(o),{})}}function Mr(t,e){return function(s,o){var u;if(s===r&&o===r)return e;if(s!==r&&(u=s),o!==r){if(u===r)return o;typeof s=="string"||typeof o=="string"?(s=Ot(s),o=Ot(o)):(s=sa(s),o=sa(o)),u=t(s,o)}return u}}function Vs(t){return _e(function(e){return e=et(e,Pt(B())),z(function(s){var o=this;return t(e,function(u){return Mt(u,o,s)})})})}function Pr(t,e){e=e===r?" ":Ot(e);var s=e.length;if(s<2)return s?qs(e,t):e;var o=qs(e,br(t/en(e)));return tn(e)?Re(Xt(o),0,t).join(""):o.slice(0,t)}function Tf(t,e,s,o){var u=e&pt,l=Nn(t);function d(){for(var g=-1,b=arguments.length,x=-1,E=o.length,T=v(E+b),M=this&&this!==_t&&this instanceof d?l:t;++x<E;)T[x]=o[x];for(;b--;)T[x++]=arguments[++g];return Mt(M,u?s:this,T)}return d}function wa(t){return function(e,s,o){return o&&typeof o!="number"&&St(e,s,o)&&(s=o=r),e=ve(e),s===r?(s=e,e=0):s=ve(s),o=o===r?e<s?1:-1:ve(o),hf(e,s,o,t)}}function Or(t){return function(e,s){return typeof e=="string"&&typeof s=="string"||(e=Gt(e),s=Gt(s)),t(e,s)}}function ya(t,e,s,o,u,l,d,g,b,x){var E=e&Kt,T=E?d:r,M=E?r:d,L=E?l:r,k=E?r:l;e|=E?Yt:Be,e&=~(E?Be:Yt),e&Zn||(e&=-4);var $=[t,e,u,L,T,k,M,g,b,x],D=s.apply(r,$);return ri(t)&&La(D,$),D.placeholder=o,Ba(D,t,e)}function Zs(t){var e=lt[t];return function(s,o){if(s=Gt(s),o=o==null?0:mt(W(o),292),o&&Bo(s)){var u=(V(s)+"e").split("e"),l=e(u[0]+"e"+(+u[1]+o));return u=(V(l)+"e").split("e"),+(u[0]+"e"+(+u[1]-o))}return e(s)}}var Af=sn&&1/ar(new sn([,-0]))[1]==ke?function(t){return new sn(t)}:mi;function Sa(t){return function(e){var s=vt(e);return s==Vt?As(e):s==Zt?qh(e):Bh(e,t(e))}}function ge(t,e,s,o,u,l,d,g){var b=e&ut;if(!b&&typeof t!="function")throw new $t(p);var x=o?o.length:0;if(x||(e&=-97,o=u=r),d=d===r?d:ft(W(d),0),g=g===r?g:W(g),x-=u?u.length:0,e&Be){var E=o,T=u;o=u=r}var M=b?r:js(t),L=[t,e,s,o,u,E,T,l,d,g];if(M&&$f(L,M),t=L[0],e=L[1],s=L[2],o=L[3],u=L[4],g=L[9]=L[9]===r?b?0:t.length:ft(L[9]-x,0),!g&&e&(Kt|Le)&&(e&=-25),!e||e==pt)var k=xf(t,e,s);else e==Kt||e==Le?k=Ef(t,e,g):(e==Yt||e==(pt|Yt))&&!u.length?k=Tf(t,e,s,o):k=Rr.apply(r,L);var $=M?na:La;return Ba($(k,L),t,e)}function xa(t,e,s,o){return t===r||jt(t,rn[s])&&!Z.call(o,s)?e:t}function Ea(t,e,s,o,u,l){return nt(t)&&nt(e)&&(l.set(e,t),Tr(t,e,r,Ea,l),l.delete(e)),t}function Cf(t){return Wn(t)?r:t}function Ta(t,e,s,o,u,l){var d=s&K,g=t.length,b=e.length;if(g!=b&&!(d&&b>g))return!1;var x=l.get(t),E=l.get(e);if(x&&E)return x==e&&E==t;var T=-1,M=!0,L=s&Tt?new Ue:r;for(l.set(t,e),l.set(e,t);++T<g;){var k=t[T],$=e[T];if(o)var D=d?o($,k,T,e,t,l):o(k,$,T,t,e,l);if(D!==r){if(D)continue;M=!1;break}if(L){if(!ws(e,function(H,G){if(!An(L,G)&&(k===H||u(k,H,s,o,l)))return L.push(G)})){M=!1;break}}else if(!(k===$||u(k,$,s,o,l))){M=!1;break}}return l.delete(t),l.delete(e),M}function If(t,e,s,o,u,l,d){switch(s){case Xe:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Tn:return!(t.byteLength!=e.byteLength||!l(new dr(t),new dr(e)));case vn:case wn:case yn:return jt(+t,+e);case jn:return t.name==e.name&&t.message==e.message;case Sn:case xn:return t==e+"";case Vt:var g=As;case Zt:var b=o&K;if(g||(g=ar),t.size!=e.size&&!b)return!1;var x=d.get(t);if(x)return x==e;o|=Tt,d.set(t,e);var E=Ta(g(t),g(e),o,u,l,d);return d.delete(t),E;case er:if(Pn)return Pn.call(t)==Pn.call(e)}return!1}function Rf(t,e,s,o,u,l){var d=s&K,g=Xs(t),b=g.length,x=Xs(e),E=x.length;if(b!=E&&!d)return!1;for(var T=b;T--;){var M=g[T];if(!(d?M in e:Z.call(e,M)))return!1}var L=l.get(t),k=l.get(e);if(L&&k)return L==e&&k==t;var $=!0;l.set(t,e),l.set(e,t);for(var D=d;++T<b;){M=g[T];var H=t[M],G=e[M];if(o)var Bt=d?o(G,H,M,e,t,l):o(H,G,M,t,e,l);if(!(Bt===r?H===G||u(H,G,s,o,l):Bt)){$=!1;break}D||(D=M=="constructor")}if($&&!D){var xt=t.constructor,kt=e.constructor;xt!=kt&&"constructor"in t&&"constructor"in e&&!(typeof xt=="function"&&xt instanceof xt&&typeof kt=="function"&&kt instanceof kt)&&($=!1)}return l.delete(t),l.delete(e),$}function _e(t){return ii(Pa(t,r,Wa),t+"")}function Xs(t){return Jo(t,gt,ei)}function Qs(t){return Jo(t,It,Aa)}var js=vr?function(t){return vr.get(t)}:mi;function Lr(t){for(var e=t.name+"",s=on[e],o=Z.call(on,e)?s.length:0;o--;){var u=s[o],l=u.func;if(l==null||l==t)return u.name}return e}function hn(t){var e=Z.call(c,"placeholder")?c:t;return e.placeholder}function B(){var t=c.iteratee||_i;return t=t===_i?Yo:t,arguments.length?t(arguments[0],arguments[1]):t}function Br(t,e){var s=t.__data__;return Nf(e)?s[typeof e=="string"?"string":"hash"]:s.map}function ti(t){for(var e=gt(t),s=e.length;s--;){var o=e[s],u=t[o];e[s]=[o,u,Ra(u)]}return e}function qe(t,e){var s=Uh(t,e);return Ko(s)?s:r}function Mf(t){var e=Z.call(t,Ne),s=t[Ne];try{t[Ne]=r;var o=!0}catch{}var u=lr.call(t);return o&&(e?t[Ne]=s:delete t[Ne]),u}var ei=Is?function(t){return t==null?[]:(t=Q(t),Se(Is(t),function(e){return Oo.call(t,e)}))}:vi,Aa=Is?function(t){for(var e=[];t;)xe(e,ei(t)),t=pr(t);return e}:vi,vt=yt;(Rs&&vt(new Rs(new ArrayBuffer(1)))!=Xe||In&&vt(new In)!=Vt||Ms&&vt(Ms.resolve())!=$i||sn&&vt(new sn)!=Zt||Rn&&vt(new Rn)!=En)&&(vt=function(t){var e=yt(t),s=e==le?t.constructor:r,o=s?ze(s):"";if(o)switch(o){case ll:return Xe;case fl:return Vt;case dl:return $i;case pl:return Zt;case gl:return En}return e});function Pf(t,e,s){for(var o=-1,u=s.length;++o<u;){var l=s[o],d=l.size;switch(l.type){case"drop":t+=d;break;case"dropRight":e-=d;break;case"take":e=mt(e,t+d);break;case"takeRight":t=ft(t,e-d);break}}return{start:t,end:e}}function Of(t){var e=t.match(Nc);return e?e[1].split(Fc):[]}function Ca(t,e,s){e=Ie(e,t);for(var o=-1,u=e.length,l=!1;++o<u;){var d=ue(e[o]);if(!(l=t!=null&&s(t,d)))break;t=t[d]}return l||++o!=u?l:(u=t==null?0:t.length,!!u&&$r(u)&&be(d,u)&&(F(t)||He(t)))}function Lf(t){var e=t.length,s=new t.constructor(e);return e&&typeof t[0]=="string"&&Z.call(t,"index")&&(s.index=t.index,s.input=t.input),s}function Ia(t){return typeof t.constructor=="function"&&!Fn(t)?an(pr(t)):{}}function Bf(t,e,s){var o=t.constructor;switch(e){case Tn:return Ys(t);case vn:case wn:return new o(+t);case Xe:return bf(t,s);case ts:case es:case ns:case rs:case ss:case is:case os:case as:case us:return ha(t,s);case Vt:return new o;case yn:case xn:return new o(t);case Sn:return mf(t);case Zt:return new o;case er:return vf(t)}}function kf(t,e){var s=e.length;if(!s)return t;var o=s-1;return e[o]=(s>1?"& ":"")+e[o],e=e.join(s>2?", ":" "),t.replace(Dc,`{
21
+ /* [wrapped with `+e+`] */
22
+ `)}function Df(t){return F(t)||He(t)||!!(Lo&&t&&t[Lo])}function be(t,e){var s=typeof t;return e=e??ye,!!e&&(s=="number"||s!="symbol"&&Kc.test(t))&&t>-1&&t%1==0&&t<e}function St(t,e,s){if(!nt(s))return!1;var o=typeof e;return(o=="number"?Ct(s)&&be(e,s.length):o=="string"&&e in s)?jt(s[e],t):!1}function ni(t,e){if(F(t))return!1;var s=typeof t;return s=="number"||s=="symbol"||s=="boolean"||t==null||Lt(t)?!0:Oc.test(t)||!Pc.test(t)||e!=null&&t in Q(e)}function Nf(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function ri(t){var e=Lr(t),s=c[e];if(typeof s!="function"||!(e in J.prototype))return!1;if(t===s)return!0;var o=js(s);return!!o&&t===o[0]}function Ff(t){return!!Ro&&Ro in t}var Uf=cr?me:wi;function Fn(t){var e=t&&t.constructor,s=typeof e=="function"&&e.prototype||rn;return t===s}function Ra(t){return t===t&&!nt(t)}function Ma(t,e){return function(s){return s==null?!1:s[t]===e&&(e!==r||t in Q(s))}}function Wf(t){var e=Ur(t,function(o){return s.size===I&&s.clear(),o}),s=e.cache;return e}function $f(t,e){var s=t[1],o=e[1],u=s|o,l=u<(pt|ut|q),d=o==q&&s==Kt||o==q&&s==ct&&t[7].length<=e[8]||o==(q|ct)&&e[7].length<=e[8]&&s==Kt;if(!(l||d))return t;o&pt&&(t[2]=e[2],u|=s&pt?0:Zn);var g=e[3];if(g){var b=t[3];t[3]=b?fa(b,g,e[4]):g,t[4]=b?Ee(t[3],P):e[4]}return g=e[5],g&&(b=t[5],t[5]=b?da(b,g,e[6]):g,t[6]=b?Ee(t[5],P):e[6]),g=e[7],g&&(t[7]=g),o&q&&(t[8]=t[8]==null?e[8]:mt(t[8],e[8])),t[9]==null&&(t[9]=e[9]),t[0]=e[0],t[1]=u,t}function qf(t){var e=[];if(t!=null)for(var s in Q(t))e.push(s);return e}function zf(t){return lr.call(t)}function Pa(t,e,s){return e=ft(e===r?t.length-1:e,0),function(){for(var o=arguments,u=-1,l=ft(o.length-e,0),d=v(l);++u<l;)d[u]=o[e+u];u=-1;for(var g=v(e+1);++u<e;)g[u]=o[u];return g[e]=s(d),Mt(t,this,g)}}function Oa(t,e){return e.length<2?t:$e(t,Ht(e,0,-1))}function Hf(t,e){for(var s=t.length,o=mt(e.length,s),u=At(t);o--;){var l=e[o];t[o]=be(l,s)?u[l]:r}return t}function si(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var La=ka(na),Un=sl||function(t,e){return _t.setTimeout(t,e)},ii=ka(df);function Ba(t,e,s){var o=e+"";return ii(t,kf(o,Jf(Of(o),s)))}function ka(t){var e=0,s=0;return function(){var o=ul(),u=st-(o-s);if(s=o,u>0){if(++e>=Ft)return arguments[0]}else e=0;return t.apply(r,arguments)}}function kr(t,e){var s=-1,o=t.length,u=o-1;for(e=e===r?o:e;++s<e;){var l=$s(s,u),d=t[l];t[l]=t[s],t[s]=d}return t.length=e,t}var Da=Wf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Lc,function(s,o,u,l){e.push(u?l.replace($c,"$1"):o||s)}),e});function ue(t){if(typeof t=="string"||Lt(t))return t;var e=t+"";return e=="0"&&1/t==-ke?"-0":e}function ze(t){if(t!=null){try{return hr.call(t)}catch{}try{return t+""}catch{}}return""}function Jf(t,e){return Wt(bc,function(s){var o="_."+s[0];e&s[1]&&!ir(t,o)&&t.push(o)}),t.sort()}function Na(t){if(t instanceof J)return t.clone();var e=new qt(t.__wrapped__,t.__chain__);return e.__actions__=At(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}function Gf(t,e,s){(s?St(t,e,s):e===r)?e=1:e=ft(W(e),0);var o=t==null?0:t.length;if(!o||e<1)return[];for(var u=0,l=0,d=v(br(o/e));u<o;)d[l++]=Ht(t,u,u+=e);return d}function Kf(t){for(var e=-1,s=t==null?0:t.length,o=0,u=[];++e<s;){var l=t[e];l&&(u[o++]=l)}return u}function Yf(){var t=arguments.length;if(!t)return[];for(var e=v(t-1),s=arguments[0],o=t;o--;)e[o-1]=arguments[o];return xe(F(s)?At(s):[s],bt(e,1))}var Vf=z(function(t,e){return ot(t)?Ln(t,bt(e,1,ot,!0)):[]}),Zf=z(function(t,e){var s=Jt(e);return ot(s)&&(s=r),ot(t)?Ln(t,bt(e,1,ot,!0),B(s,2)):[]}),Xf=z(function(t,e){var s=Jt(e);return ot(s)&&(s=r),ot(t)?Ln(t,bt(e,1,ot,!0),r,s):[]});function Qf(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),Ht(t,e<0?0:e,o)):[]}function jf(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),e=o-e,Ht(t,0,e<0?0:e)):[]}function td(t,e){return t&&t.length?Cr(t,B(e,3),!0,!0):[]}function ed(t,e){return t&&t.length?Cr(t,B(e,3),!0):[]}function nd(t,e,s,o){var u=t==null?0:t.length;return u?(s&&typeof s!="number"&&St(t,e,s)&&(s=0,o=u),Kl(t,e,s,o)):[]}function Fa(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=s==null?0:W(s);return u<0&&(u=ft(o+u,0)),or(t,B(e,3),u)}function Ua(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=o-1;return s!==r&&(u=W(s),u=s<0?ft(o+u,0):mt(u,o-1)),or(t,B(e,3),u,!0)}function Wa(t){var e=t==null?0:t.length;return e?bt(t,1):[]}function rd(t){var e=t==null?0:t.length;return e?bt(t,ke):[]}function sd(t,e){var s=t==null?0:t.length;return s?(e=e===r?1:W(e),bt(t,e)):[]}function id(t){for(var e=-1,s=t==null?0:t.length,o={};++e<s;){var u=t[e];o[u[0]]=u[1]}return o}function $a(t){return t&&t.length?t[0]:r}function od(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=s==null?0:W(s);return u<0&&(u=ft(o+u,0)),je(t,e,u)}function ad(t){var e=t==null?0:t.length;return e?Ht(t,0,-1):[]}var ud=z(function(t){var e=et(t,Gs);return e.length&&e[0]===t[0]?Ds(e):[]}),cd=z(function(t){var e=Jt(t),s=et(t,Gs);return e===Jt(s)?e=r:s.pop(),s.length&&s[0]===t[0]?Ds(s,B(e,2)):[]}),hd=z(function(t){var e=Jt(t),s=et(t,Gs);return e=typeof e=="function"?e:r,e&&s.pop(),s.length&&s[0]===t[0]?Ds(s,r,e):[]});function ld(t,e){return t==null?"":ol.call(t,e)}function Jt(t){var e=t==null?0:t.length;return e?t[e-1]:r}function fd(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=o;return s!==r&&(u=W(s),u=u<0?ft(o+u,0):mt(u,o-1)),e===e?Hh(t,e,u):or(t,yo,u,!0)}function dd(t,e){return t&&t.length?Qo(t,W(e)):r}var pd=z(qa);function qa(t,e){return t&&t.length&&e&&e.length?Ws(t,e):t}function gd(t,e,s){return t&&t.length&&e&&e.length?Ws(t,e,B(s,2)):t}function _d(t,e,s){return t&&t.length&&e&&e.length?Ws(t,e,r,s):t}var bd=_e(function(t,e){var s=t==null?0:t.length,o=Os(t,e);return ea(t,et(e,function(u){return be(u,s)?+u:u}).sort(la)),o});function md(t,e){var s=[];if(!(t&&t.length))return s;var o=-1,u=[],l=t.length;for(e=B(e,3);++o<l;){var d=t[o];e(d,o,t)&&(s.push(d),u.push(o))}return ea(t,u),s}function oi(t){return t==null?t:hl.call(t)}function vd(t,e,s){var o=t==null?0:t.length;return o?(s&&typeof s!="number"&&St(t,e,s)?(e=0,s=o):(e=e==null?0:W(e),s=s===r?o:W(s)),Ht(t,e,s)):[]}function wd(t,e){return Ar(t,e)}function yd(t,e,s){return zs(t,e,B(s,2))}function Sd(t,e){var s=t==null?0:t.length;if(s){var o=Ar(t,e);if(o<s&&jt(t[o],e))return o}return-1}function xd(t,e){return Ar(t,e,!0)}function Ed(t,e,s){return zs(t,e,B(s,2),!0)}function Td(t,e){var s=t==null?0:t.length;if(s){var o=Ar(t,e,!0)-1;if(jt(t[o],e))return o}return-1}function Ad(t){return t&&t.length?ra(t):[]}function Cd(t,e){return t&&t.length?ra(t,B(e,2)):[]}function Id(t){var e=t==null?0:t.length;return e?Ht(t,1,e):[]}function Rd(t,e,s){return t&&t.length?(e=s||e===r?1:W(e),Ht(t,0,e<0?0:e)):[]}function Md(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),e=o-e,Ht(t,e<0?0:e,o)):[]}function Pd(t,e){return t&&t.length?Cr(t,B(e,3),!1,!0):[]}function Od(t,e){return t&&t.length?Cr(t,B(e,3)):[]}var Ld=z(function(t){return Ce(bt(t,1,ot,!0))}),Bd=z(function(t){var e=Jt(t);return ot(e)&&(e=r),Ce(bt(t,1,ot,!0),B(e,2))}),kd=z(function(t){var e=Jt(t);return e=typeof e=="function"?e:r,Ce(bt(t,1,ot,!0),r,e)});function Dd(t){return t&&t.length?Ce(t):[]}function Nd(t,e){return t&&t.length?Ce(t,B(e,2)):[]}function Fd(t,e){return e=typeof e=="function"?e:r,t&&t.length?Ce(t,r,e):[]}function ai(t){if(!(t&&t.length))return[];var e=0;return t=Se(t,function(s){if(ot(s))return e=ft(s.length,e),!0}),Es(e,function(s){return et(t,ys(s))})}function za(t,e){if(!(t&&t.length))return[];var s=ai(t);return e==null?s:et(s,function(o){return Mt(e,r,o)})}var Ud=z(function(t,e){return ot(t)?Ln(t,e):[]}),Wd=z(function(t){return Js(Se(t,ot))}),$d=z(function(t){var e=Jt(t);return ot(e)&&(e=r),Js(Se(t,ot),B(e,2))}),qd=z(function(t){var e=Jt(t);return e=typeof e=="function"?e:r,Js(Se(t,ot),r,e)}),zd=z(ai);function Hd(t,e){return aa(t||[],e||[],On)}function Jd(t,e){return aa(t||[],e||[],Dn)}var Gd=z(function(t){var e=t.length,s=e>1?t[e-1]:r;return s=typeof s=="function"?(t.pop(),s):r,za(t,s)});function Ha(t){var e=c(t);return e.__chain__=!0,e}function Kd(t,e){return e(t),t}function Dr(t,e){return e(t)}var Yd=_e(function(t){var e=t.length,s=e?t[0]:0,o=this.__wrapped__,u=function(l){return Os(l,t)};return e>1||this.__actions__.length||!(o instanceof J)||!be(s)?this.thru(u):(o=o.slice(s,+s+(e?1:0)),o.__actions__.push({func:Dr,args:[u],thisArg:r}),new qt(o,this.__chain__).thru(function(l){return e&&!l.length&&l.push(r),l}))});function Vd(){return Ha(this)}function Zd(){return new qt(this.value(),this.__chain__)}function Xd(){this.__values__===r&&(this.__values__=su(this.value()));var t=this.__index__>=this.__values__.length,e=t?r:this.__values__[this.__index__++];return{done:t,value:e}}function Qd(){return this}function jd(t){for(var e,s=this;s instanceof yr;){var o=Na(s);o.__index__=0,o.__values__=r,e?u.__wrapped__=o:e=o;var u=o;s=s.__wrapped__}return u.__wrapped__=t,e}function tp(){var t=this.__wrapped__;if(t instanceof J){var e=t;return this.__actions__.length&&(e=new J(this)),e=e.reverse(),e.__actions__.push({func:Dr,args:[oi],thisArg:r}),new qt(e,this.__chain__)}return this.thru(oi)}function ep(){return oa(this.__wrapped__,this.__actions__)}var np=Ir(function(t,e,s){Z.call(t,s)?++t[s]:pe(t,s,1)});function rp(t,e,s){var o=F(t)?vo:Gl;return s&&St(t,e,s)&&(e=r),o(t,B(e,3))}function sp(t,e){var s=F(t)?Se:zo;return s(t,B(e,3))}var ip=ba(Fa),op=ba(Ua);function ap(t,e){return bt(Nr(t,e),1)}function up(t,e){return bt(Nr(t,e),ke)}function cp(t,e,s){return s=s===r?1:W(s),bt(Nr(t,e),s)}function Ja(t,e){var s=F(t)?Wt:Ae;return s(t,B(e,3))}function Ga(t,e){var s=F(t)?Ch:qo;return s(t,B(e,3))}var hp=Ir(function(t,e,s){Z.call(t,s)?t[s].push(e):pe(t,s,[e])});function lp(t,e,s,o){t=Ct(t)?t:fn(t),s=s&&!o?W(s):0;var u=t.length;return s<0&&(s=ft(u+s,0)),qr(t)?s<=u&&t.indexOf(e,s)>-1:!!u&&je(t,e,s)>-1}var fp=z(function(t,e,s){var o=-1,u=typeof e=="function",l=Ct(t)?v(t.length):[];return Ae(t,function(d){l[++o]=u?Mt(e,d,s):Bn(d,e,s)}),l}),dp=Ir(function(t,e,s){pe(t,s,e)});function Nr(t,e){var s=F(t)?et:Vo;return s(t,B(e,3))}function pp(t,e,s,o){return t==null?[]:(F(e)||(e=e==null?[]:[e]),s=o?r:s,F(s)||(s=s==null?[]:[s]),jo(t,e,s))}var gp=Ir(function(t,e,s){t[s?0:1].push(e)},function(){return[[],[]]});function _p(t,e,s){var o=F(t)?vs:xo,u=arguments.length<3;return o(t,B(e,4),s,u,Ae)}function bp(t,e,s){var o=F(t)?Ih:xo,u=arguments.length<3;return o(t,B(e,4),s,u,qo)}function mp(t,e){var s=F(t)?Se:zo;return s(t,Wr(B(e,3)))}function vp(t){var e=F(t)?Fo:lf;return e(t)}function wp(t,e,s){(s?St(t,e,s):e===r)?e=1:e=W(e);var o=F(t)?$l:ff;return o(t,e)}function yp(t){var e=F(t)?ql:pf;return e(t)}function Sp(t){if(t==null)return 0;if(Ct(t))return qr(t)?en(t):t.length;var e=vt(t);return e==Vt||e==Zt?t.size:Fs(t).length}function xp(t,e,s){var o=F(t)?ws:gf;return s&&St(t,e,s)&&(e=r),o(t,B(e,3))}var Ep=z(function(t,e){if(t==null)return[];var s=e.length;return s>1&&St(t,e[0],e[1])?e=[]:s>2&&St(e[0],e[1],e[2])&&(e=[e[0]]),jo(t,bt(e,1),[])}),Fr=rl||function(){return _t.Date.now()};function Tp(t,e){if(typeof e!="function")throw new $t(p);return t=W(t),function(){if(--t<1)return e.apply(this,arguments)}}function Ka(t,e,s){return e=s?r:e,e=t&&e==null?t.length:e,ge(t,q,r,r,r,r,e)}function Ya(t,e){var s;if(typeof e!="function")throw new $t(p);return t=W(t),function(){return--t>0&&(s=e.apply(this,arguments)),t<=1&&(e=r),s}}var ui=z(function(t,e,s){var o=pt;if(s.length){var u=Ee(s,hn(ui));o|=Yt}return ge(t,o,e,s,u)}),Va=z(function(t,e,s){var o=pt|ut;if(s.length){var u=Ee(s,hn(Va));o|=Yt}return ge(e,o,t,s,u)});function Za(t,e,s){e=s?r:e;var o=ge(t,Kt,r,r,r,r,r,e);return o.placeholder=Za.placeholder,o}function Xa(t,e,s){e=s?r:e;var o=ge(t,Le,r,r,r,r,r,e);return o.placeholder=Xa.placeholder,o}function Qa(t,e,s){var o,u,l,d,g,b,x=0,E=!1,T=!1,M=!0;if(typeof t!="function")throw new $t(p);e=Gt(e)||0,nt(s)&&(E=!!s.leading,T="maxWait"in s,l=T?ft(Gt(s.maxWait)||0,e):l,M="trailing"in s?!!s.trailing:M);function L(at){var te=o,we=u;return o=u=r,x=at,d=t.apply(we,te),d}function k(at){return x=at,g=Un(H,e),E?L(at):d}function $(at){var te=at-b,we=at-x,bu=e-te;return T?mt(bu,l-we):bu}function D(at){var te=at-b,we=at-x;return b===r||te>=e||te<0||T&&we>=l}function H(){var at=Fr();if(D(at))return G(at);g=Un(H,$(at))}function G(at){return g=r,M&&o?L(at):(o=u=r,d)}function Bt(){g!==r&&ua(g),x=0,o=b=u=g=r}function xt(){return g===r?d:G(Fr())}function kt(){var at=Fr(),te=D(at);if(o=arguments,u=this,b=at,te){if(g===r)return k(b);if(T)return ua(g),g=Un(H,e),L(b)}return g===r&&(g=Un(H,e)),d}return kt.cancel=Bt,kt.flush=xt,kt}var Ap=z(function(t,e){return $o(t,1,e)}),Cp=z(function(t,e,s){return $o(t,Gt(e)||0,s)});function Ip(t){return ge(t,X)}function Ur(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new $t(p);var s=function(){var o=arguments,u=e?e.apply(this,o):o[0],l=s.cache;if(l.has(u))return l.get(u);var d=t.apply(this,o);return s.cache=l.set(u,d)||l,d};return s.cache=new(Ur.Cache||de),s}Ur.Cache=de;function Wr(t){if(typeof t!="function")throw new $t(p);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 Rp(t){return Ya(2,t)}var Mp=_f(function(t,e){e=e.length==1&&F(e[0])?et(e[0],Pt(B())):et(bt(e,1),Pt(B()));var s=e.length;return z(function(o){for(var u=-1,l=mt(o.length,s);++u<l;)o[u]=e[u].call(this,o[u]);return Mt(t,this,o)})}),ci=z(function(t,e){var s=Ee(e,hn(ci));return ge(t,Yt,r,e,s)}),ja=z(function(t,e){var s=Ee(e,hn(ja));return ge(t,Be,r,e,s)}),Pp=_e(function(t,e){return ge(t,ct,r,r,r,e)});function Op(t,e){if(typeof t!="function")throw new $t(p);return e=e===r?e:W(e),z(t,e)}function Lp(t,e){if(typeof t!="function")throw new $t(p);return e=e==null?0:ft(W(e),0),z(function(s){var o=s[e],u=Re(s,0,e);return o&&xe(u,o),Mt(t,this,u)})}function Bp(t,e,s){var o=!0,u=!0;if(typeof t!="function")throw new $t(p);return nt(s)&&(o="leading"in s?!!s.leading:o,u="trailing"in s?!!s.trailing:u),Qa(t,e,{leading:o,maxWait:e,trailing:u})}function kp(t){return Ka(t,1)}function Dp(t,e){return ci(Ks(e),t)}function Np(){if(!arguments.length)return[];var t=arguments[0];return F(t)?t:[t]}function Fp(t){return zt(t,R)}function Up(t,e){return e=typeof e=="function"?e:r,zt(t,R,e)}function Wp(t){return zt(t,C|R)}function $p(t,e){return e=typeof e=="function"?e:r,zt(t,C|R,e)}function qp(t,e){return e==null||Wo(t,e,gt(e))}function jt(t,e){return t===e||t!==t&&e!==e}var zp=Or(ks),Hp=Or(function(t,e){return t>=e}),He=Go(function(){return arguments}())?Go:function(t){return it(t)&&Z.call(t,"callee")&&!Oo.call(t,"callee")},F=v.isArray,Jp=fo?Pt(fo):Ql;function Ct(t){return t!=null&&$r(t.length)&&!me(t)}function ot(t){return it(t)&&Ct(t)}function Gp(t){return t===!0||t===!1||it(t)&&yt(t)==vn}var Me=il||wi,Kp=po?Pt(po):jl;function Yp(t){return it(t)&&t.nodeType===1&&!Wn(t)}function Vp(t){if(t==null)return!0;if(Ct(t)&&(F(t)||typeof t=="string"||typeof t.splice=="function"||Me(t)||ln(t)||He(t)))return!t.length;var e=vt(t);if(e==Vt||e==Zt)return!t.size;if(Fn(t))return!Fs(t).length;for(var s in t)if(Z.call(t,s))return!1;return!0}function Zp(t,e){return kn(t,e)}function Xp(t,e,s){s=typeof s=="function"?s:r;var o=s?s(t,e):r;return o===r?kn(t,e,r,s):!!o}function hi(t){if(!it(t))return!1;var e=yt(t);return e==jn||e==vc||typeof t.message=="string"&&typeof t.name=="string"&&!Wn(t)}function Qp(t){return typeof t=="number"&&Bo(t)}function me(t){if(!nt(t))return!1;var e=yt(t);return e==tr||e==Wi||e==mc||e==yc}function tu(t){return typeof t=="number"&&t==W(t)}function $r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ye}function nt(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function it(t){return t!=null&&typeof t=="object"}var eu=go?Pt(go):ef;function jp(t,e){return t===e||Ns(t,e,ti(e))}function tg(t,e,s){return s=typeof s=="function"?s:r,Ns(t,e,ti(e),s)}function eg(t){return nu(t)&&t!=+t}function ng(t){if(Uf(t))throw new N(f);return Ko(t)}function rg(t){return t===null}function sg(t){return t==null}function nu(t){return typeof t=="number"||it(t)&&yt(t)==yn}function Wn(t){if(!it(t)||yt(t)!=le)return!1;var e=pr(t);if(e===null)return!0;var s=Z.call(e,"constructor")&&e.constructor;return typeof s=="function"&&s instanceof s&&hr.call(s)==jh}var li=_o?Pt(_o):nf;function ig(t){return tu(t)&&t>=-ye&&t<=ye}var ru=bo?Pt(bo):rf;function qr(t){return typeof t=="string"||!F(t)&&it(t)&&yt(t)==xn}function Lt(t){return typeof t=="symbol"||it(t)&&yt(t)==er}var ln=mo?Pt(mo):sf;function og(t){return t===r}function ag(t){return it(t)&&vt(t)==En}function ug(t){return it(t)&&yt(t)==xc}var cg=Or(Us),hg=Or(function(t,e){return t<=e});function su(t){if(!t)return[];if(Ct(t))return qr(t)?Xt(t):At(t);if(Cn&&t[Cn])return $h(t[Cn]());var e=vt(t),s=e==Vt?As:e==Zt?ar:fn;return s(t)}function ve(t){if(!t)return t===0?t:0;if(t=Gt(t),t===ke||t===-ke){var e=t<0?-1:1;return e*pc}return t===t?t:0}function W(t){var e=ve(t),s=e%1;return e===e?s?e-s:e:0}function iu(t){return t?We(W(t),0,ie):0}function Gt(t){if(typeof t=="number")return t;if(Lt(t))return Xn;if(nt(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=nt(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Eo(t);var s=Hc.test(t);return s||Gc.test(t)?Eh(t.slice(2),s?2:8):zc.test(t)?Xn:+t}function ou(t){return ae(t,It(t))}function lg(t){return t?We(W(t),-ye,ye):t===0?t:0}function V(t){return t==null?"":Ot(t)}var fg=un(function(t,e){if(Fn(e)||Ct(e)){ae(e,gt(e),t);return}for(var s in e)Z.call(e,s)&&On(t,s,e[s])}),au=un(function(t,e){ae(e,It(e),t)}),zr=un(function(t,e,s,o){ae(e,It(e),t,o)}),dg=un(function(t,e,s,o){ae(e,gt(e),t,o)}),pg=_e(Os);function gg(t,e){var s=an(t);return e==null?s:Uo(s,e)}var _g=z(function(t,e){t=Q(t);var s=-1,o=e.length,u=o>2?e[2]:r;for(u&&St(e[0],e[1],u)&&(o=1);++s<o;)for(var l=e[s],d=It(l),g=-1,b=d.length;++g<b;){var x=d[g],E=t[x];(E===r||jt(E,rn[x])&&!Z.call(t,x))&&(t[x]=l[x])}return t}),bg=z(function(t){return t.push(r,Ea),Mt(uu,r,t)});function mg(t,e){return wo(t,B(e,3),oe)}function vg(t,e){return wo(t,B(e,3),Bs)}function wg(t,e){return t==null?t:Ls(t,B(e,3),It)}function yg(t,e){return t==null?t:Ho(t,B(e,3),It)}function Sg(t,e){return t&&oe(t,B(e,3))}function xg(t,e){return t&&Bs(t,B(e,3))}function Eg(t){return t==null?[]:Er(t,gt(t))}function Tg(t){return t==null?[]:Er(t,It(t))}function fi(t,e,s){var o=t==null?r:$e(t,e);return o===r?s:o}function Ag(t,e){return t!=null&&Ca(t,e,Yl)}function di(t,e){return t!=null&&Ca(t,e,Vl)}var Cg=va(function(t,e,s){e!=null&&typeof e.toString!="function"&&(e=lr.call(e)),t[e]=s},gi(Rt)),Ig=va(function(t,e,s){e!=null&&typeof e.toString!="function"&&(e=lr.call(e)),Z.call(t,e)?t[e].push(s):t[e]=[s]},B),Rg=z(Bn);function gt(t){return Ct(t)?No(t):Fs(t)}function It(t){return Ct(t)?No(t,!0):of(t)}function Mg(t,e){var s={};return e=B(e,3),oe(t,function(o,u,l){pe(s,e(o,u,l),o)}),s}function Pg(t,e){var s={};return e=B(e,3),oe(t,function(o,u,l){pe(s,u,e(o,u,l))}),s}var Og=un(function(t,e,s){Tr(t,e,s)}),uu=un(function(t,e,s,o){Tr(t,e,s,o)}),Lg=_e(function(t,e){var s={};if(t==null)return s;var o=!1;e=et(e,function(l){return l=Ie(l,t),o||(o=l.length>1),l}),ae(t,Qs(t),s),o&&(s=zt(s,C|A|R,Cf));for(var u=e.length;u--;)Hs(s,e[u]);return s});function Bg(t,e){return cu(t,Wr(B(e)))}var kg=_e(function(t,e){return t==null?{}:uf(t,e)});function cu(t,e){if(t==null)return{};var s=et(Qs(t),function(o){return[o]});return e=B(e),ta(t,s,function(o,u){return e(o,u[0])})}function Dg(t,e,s){e=Ie(e,t);var o=-1,u=e.length;for(u||(u=1,t=r);++o<u;){var l=t==null?r:t[ue(e[o])];l===r&&(o=u,l=s),t=me(l)?l.call(t):l}return t}function Ng(t,e,s){return t==null?t:Dn(t,e,s)}function Fg(t,e,s,o){return o=typeof o=="function"?o:r,t==null?t:Dn(t,e,s,o)}var hu=Sa(gt),lu=Sa(It);function Ug(t,e,s){var o=F(t),u=o||Me(t)||ln(t);if(e=B(e,4),s==null){var l=t&&t.constructor;u?s=o?new l:[]:nt(t)?s=me(l)?an(pr(t)):{}:s={}}return(u?Wt:oe)(t,function(d,g,b){return e(s,d,g,b)}),s}function Wg(t,e){return t==null?!0:Hs(t,e)}function $g(t,e,s){return t==null?t:ia(t,e,Ks(s))}function qg(t,e,s,o){return o=typeof o=="function"?o:r,t==null?t:ia(t,e,Ks(s),o)}function fn(t){return t==null?[]:Ts(t,gt(t))}function zg(t){return t==null?[]:Ts(t,It(t))}function Hg(t,e,s){return s===r&&(s=e,e=r),s!==r&&(s=Gt(s),s=s===s?s:0),e!==r&&(e=Gt(e),e=e===e?e:0),We(Gt(t),e,s)}function Jg(t,e,s){return e=ve(e),s===r?(s=e,e=0):s=ve(s),t=Gt(t),Zl(t,e,s)}function Gg(t,e,s){if(s&&typeof s!="boolean"&&St(t,e,s)&&(e=s=r),s===r&&(typeof e=="boolean"?(s=e,e=r):typeof t=="boolean"&&(s=t,t=r)),t===r&&e===r?(t=0,e=1):(t=ve(t),e===r?(e=t,t=0):e=ve(e)),t>e){var o=t;t=e,e=o}if(s||t%1||e%1){var u=ko();return mt(t+u*(e-t+xh("1e-"+((u+"").length-1))),e)}return $s(t,e)}var Kg=cn(function(t,e,s){return e=e.toLowerCase(),t+(s?fu(e):e)});function fu(t){return pi(V(t).toLowerCase())}function du(t){return t=V(t),t&&t.replace(Yc,Dh).replace(dh,"")}function Yg(t,e,s){t=V(t),e=Ot(e);var o=t.length;s=s===r?o:We(W(s),0,o);var u=s;return s-=e.length,s>=0&&t.slice(s,u)==e}function Vg(t){return t=V(t),t&&Ic.test(t)?t.replace(zi,Nh):t}function Zg(t){return t=V(t),t&&Bc.test(t)?t.replace(cs,"\\$&"):t}var Xg=cn(function(t,e,s){return t+(s?"-":"")+e.toLowerCase()}),Qg=cn(function(t,e,s){return t+(s?" ":"")+e.toLowerCase()}),jg=_a("toLowerCase");function t_(t,e,s){t=V(t),e=W(e);var o=e?en(t):0;if(!e||o>=e)return t;var u=(e-o)/2;return Pr(mr(u),s)+t+Pr(br(u),s)}function e_(t,e,s){t=V(t),e=W(e);var o=e?en(t):0;return e&&o<e?t+Pr(e-o,s):t}function n_(t,e,s){t=V(t),e=W(e);var o=e?en(t):0;return e&&o<e?Pr(e-o,s)+t:t}function r_(t,e,s){return s||e==null?e=0:e&&(e=+e),cl(V(t).replace(hs,""),e||0)}function s_(t,e,s){return(s?St(t,e,s):e===r)?e=1:e=W(e),qs(V(t),e)}function i_(){var t=arguments,e=V(t[0]);return t.length<3?e:e.replace(t[1],t[2])}var o_=cn(function(t,e,s){return t+(s?"_":"")+e.toLowerCase()});function a_(t,e,s){return s&&typeof s!="number"&&St(t,e,s)&&(e=s=r),s=s===r?ie:s>>>0,s?(t=V(t),t&&(typeof e=="string"||e!=null&&!li(e))&&(e=Ot(e),!e&&tn(t))?Re(Xt(t),0,s):t.split(e,s)):[]}var u_=cn(function(t,e,s){return t+(s?" ":"")+pi(e)});function c_(t,e,s){return t=V(t),s=s==null?0:We(W(s),0,t.length),e=Ot(e),t.slice(s,s+e.length)==e}function h_(t,e,s){var o=c.templateSettings;s&&St(t,e,s)&&(e=r),t=V(t),e=zr({},e,o,xa);var u=zr({},e.imports,o.imports,xa),l=gt(u),d=Ts(u,l),g,b,x=0,E=e.interpolate||nr,T="__p += '",M=Cs((e.escape||nr).source+"|"+E.source+"|"+(E===Hi?qc:nr).source+"|"+(e.evaluate||nr).source+"|$","g"),L="//# sourceURL="+(Z.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++mh+"]")+`
23
+ `;t.replace(M,function(D,H,G,Bt,xt,kt){return G||(G=Bt),T+=t.slice(x,kt).replace(Vc,Fh),H&&(g=!0,T+=`' +
24
+ __e(`+H+`) +
25
+ '`),xt&&(b=!0,T+=`';
26
+ `+xt+`;
27
+ __p += '`),G&&(T+=`' +
28
+ ((__t = (`+G+`)) == null ? '' : __t) +
29
+ '`),x=kt+D.length,D}),T+=`';
30
+ `;var k=Z.call(e,"variable")&&e.variable;if(!k)T=`with (obj) {
31
+ `+T+`
28
32
  }
29
- `;else if(ia.test(T))throw new L(I);v=(c?v.replace(Go,""):v).replace(ko,"$1").replace(zo,"$1;"),v="function("+(T||"obj")+`) {
30
- `+(T?"":`obj || (obj = {});
31
- `)+"var __t, __p = ''"+(f?", __e = _.escape":"")+(c?`, __j = Array.prototype.join;
33
+ `;else if(Wc.test(k))throw new N(m);T=(b?T.replace(Ec,""):T).replace(Tc,"$1").replace(Ac,"$1;"),T="function("+(k||"obj")+`) {
34
+ `+(k?"":`obj || (obj = {});
35
+ `)+"var __t, __p = ''"+(g?", __e = _.escape":"")+(b?`, __j = Array.prototype.join;
32
36
  function print() { __p += __j.call(arguments, '') }
33
37
  `:`;
34
- `)+v+`return __p
35
- }`;var M=yo(function(){return $(o,A+"return "+v).apply(i,a)});if(M.source=v,Ii(M))throw M;return M}function Ep(n){return G(n).toLowerCase()}function Ip(n){return G(n).toUpperCase()}function Lp(n,t,e){if(n=G(n),n&&(e||t===i))return Pu(n);if(!n||!(t=En(t)))return n;var r=Jn(n),u=Jn(t),o=Eu(r,u),a=Iu(r,u)+1;return yt(r,o,a).join("")}function Op(n,t,e){if(n=G(n),n&&(e||t===i))return n.slice(0,Ou(n)+1);if(!n||!(t=En(t)))return n;var r=Jn(n),u=Iu(r,Jn(t))+1;return yt(r,0,u).join("")}function Wp(n,t,e){if(n=G(n),n&&(e||t===i))return n.replace(Ir,"");if(!n||!(t=En(t)))return n;var r=Jn(n),u=Eu(r,Jn(t));return yt(r,u).join("")}function Mp(n,t){var e=Wn,r=rn;if(Z(t)){var u="separator"in t?t.separator:u;e="length"in t?W(t.length):e,r="omission"in t?En(t.omission):r}n=G(n);var o=n.length;if(Bt(n)){var a=Jn(n);o=a.length}if(e>=o)return n;var f=e-$t(r);if(f<1)return r;var c=a?yt(a,0,f).join(""):n.slice(0,f);if(u===i)return c+r;if(a&&(f+=c.length-f),Li(u)){if(n.slice(f).search(u)){var d,_=c;for(u.global||(u=Jr(u.source,G(Xi.exec(u))+"g")),u.lastIndex=0;d=u.exec(_);)var v=d.index;c=c.slice(0,v===i?f:v)}}else if(n.indexOf(En(u),f)!=f){var x=c.lastIndexOf(u);x>-1&&(c=c.slice(0,x))}return c+r}function Fp(n){return n=G(n),n&&Ho.test(n)?n.replace(Ji,lf):n}var Up=Jt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Mi=ys("toUpperCase");function mo(n,t,e){return n=G(n),t=e?i:t,t===i?uf(n)?gf(n):Za(n):n.match(t)||[]}var yo=U(function(n,t){try{return Tn(n,i,t)}catch(e){return Ii(e)?e:new L(e)}}),Dp=st(function(n,t){return Un(t,function(e){e=nt(e),it(n,e,Pi(n[e],n))}),n});function Np(n){var t=n==null?0:n.length,e=R();return n=t?Y(n,function(r){if(typeof r[1]!="function")throw new Dn(b);return[e(r[0]),r[1]]}):[],U(function(r){for(var u=-1;++u<t;){var o=n[u];if(Tn(o[0],this,r))return Tn(o[1],this,r)}})}function Bp(n){return ll(Bn(n,en))}function Fi(n){return function(){return n}}function $p(n,t){return n==null||n!==n?t:n}var qp=Ss(),Gp=Ss(!0);function An(n){return n}function Ui(n){return Vu(typeof n=="function"?n:Bn(n,en))}function kp(n){return ns(Bn(n,en))}function zp(n,t){return ts(n,Bn(t,en))}var Hp=U(function(n,t){return function(e){return he(e,n,t)}}),Kp=U(function(n,t){return function(e){return he(n,e,t)}});function Di(n,t,e){var r=on(t),u=Qe(t,r);e==null&&!(Z(t)&&(u.length||!r.length))&&(e=t,t=n,n=this,u=Qe(t,on(t)));var o=!(Z(e)&&"chain"in e)||!!e.chain,a=at(n);return Un(u,function(f){var c=t[f];n[f]=c,a&&(n.prototype[f]=function(){var d=this.__chain__;if(o||d){var _=n(this.__wrapped__),v=_.__actions__=yn(this.__actions__);return v.push({func:c,args:arguments,thisArg:n}),_.__chain__=d,_}return c.apply(n,pt([this.value()],arguments))})}),n}function Jp(){return an._===this&&(an._=mf),this}function Ni(){}function Yp(n){return n=W(n),U(function(t){return es(t,n)})}var Zp=di(Y),Xp=di(Au),Qp=di($r);function xo(n){return Si(n)?qr(nt(n)):Tl(n)}function Vp(n){return function(t){return n==null?i:It(n,t)}}var jp=Cs(),nd=Cs(!0);function Bi(){return[]}function $i(){return!1}function td(){return{}}function ed(){return""}function rd(){return!0}function id(n,t){if(n=W(n),n<1||n>ht)return[];var e=Qn,r=ln(n,Qn);t=R(t),n-=Qn;for(var u=zr(r,t);++e<n;)t(e);return u}function ud(n){return O(n)?Y(n,nt):In(n)?[n]:yn($s(G(n)))}function sd(n){var t=++vf;return G(n)+t}var od=rr(function(n,t){return n+t},0),ad=_i("ceil"),fd=rr(function(n,t){return n/t},1),ld=_i("floor");function cd(n){return n&&n.length?Xe(n,An,ti):i}function hd(n,t){return n&&n.length?Xe(n,R(t,2),ti):i}function gd(n){return Ru(n,An)}function pd(n,t){return Ru(n,R(t,2))}function dd(n){return n&&n.length?Xe(n,An,ui):i}function _d(n,t){return n&&n.length?Xe(n,R(t,2),ui):i}var vd=rr(function(n,t){return n*t},1),wd=_i("round"),md=rr(function(n,t){return n-t},0);function yd(n){return n&&n.length?kr(n,An):0}function xd(n,t){return n&&n.length?kr(n,R(t,2)):0}return s.after=kh,s.ary=Qs,s.assign=Ig,s.assignIn=co,s.assignInWith=_r,s.assignWith=Lg,s.at=Og,s.before=Vs,s.bind=Pi,s.bindAll=Dp,s.bindKey=js,s.castArray=tg,s.chain=Ys,s.chunk=lc,s.compact=cc,s.concat=hc,s.cond=Np,s.conforms=Bp,s.constant=Fi,s.countBy=yh,s.create=Wg,s.curry=no,s.curryRight=to,s.debounce=eo,s.defaults=Mg,s.defaultsDeep=Fg,s.defer=zh,s.delay=Hh,s.difference=gc,s.differenceBy=pc,s.differenceWith=dc,s.drop=_c,s.dropRight=vc,s.dropRightWhile=wc,s.dropWhile=mc,s.fill=yc,s.filter=Sh,s.flatMap=bh,s.flatMapDeep=Rh,s.flatMapDepth=Th,s.flatten=zs,s.flattenDeep=xc,s.flattenDepth=Sc,s.flip=Kh,s.flow=qp,s.flowRight=Gp,s.fromPairs=Ac,s.functions=Gg,s.functionsIn=kg,s.groupBy=Ph,s.initial=bc,s.intersection=Rc,s.intersectionBy=Tc,s.intersectionWith=Pc,s.invert=Hg,s.invertBy=Kg,s.invokeMap=Ih,s.iteratee=Ui,s.keyBy=Lh,s.keys=on,s.keysIn=Sn,s.map=lr,s.mapKeys=Yg,s.mapValues=Zg,s.matches=kp,s.matchesProperty=zp,s.memoize=hr,s.merge=Xg,s.mergeWith=ho,s.method=Hp,s.methodOf=Kp,s.mixin=Di,s.negate=gr,s.nthArg=Yp,s.omit=Qg,s.omitBy=Vg,s.once=Jh,s.orderBy=Oh,s.over=Zp,s.overArgs=Yh,s.overEvery=Xp,s.overSome=Qp,s.partial=Ei,s.partialRight=ro,s.partition=Wh,s.pick=jg,s.pickBy=go,s.property=xo,s.propertyOf=Vp,s.pull=Oc,s.pullAll=Ks,s.pullAllBy=Wc,s.pullAllWith=Mc,s.pullAt=Fc,s.range=jp,s.rangeRight=nd,s.rearg=Zh,s.reject=Uh,s.remove=Uc,s.rest=Xh,s.reverse=Ri,s.sampleSize=Nh,s.set=tp,s.setWith=ep,s.shuffle=Bh,s.slice=Dc,s.sortBy=Gh,s.sortedUniq=zc,s.sortedUniqBy=Hc,s.split=bp,s.spread=Qh,s.tail=Kc,s.take=Jc,s.takeRight=Yc,s.takeRightWhile=Zc,s.takeWhile=Xc,s.tap=ch,s.throttle=Vh,s.thru=fr,s.toArray=ao,s.toPairs=po,s.toPairsIn=_o,s.toPath=ud,s.toPlainObject=lo,s.transform=rp,s.unary=jh,s.union=Qc,s.unionBy=Vc,s.unionWith=jc,s.uniq=nh,s.uniqBy=th,s.uniqWith=eh,s.unset=ip,s.unzip=Ti,s.unzipWith=Js,s.update=up,s.updateWith=sp,s.values=Xt,s.valuesIn=op,s.without=rh,s.words=mo,s.wrap=ng,s.xor=ih,s.xorBy=uh,s.xorWith=sh,s.zip=oh,s.zipObject=ah,s.zipObjectDeep=fh,s.zipWith=lh,s.entries=po,s.entriesIn=_o,s.extend=co,s.extendWith=_r,Di(s,s),s.add=od,s.attempt=yo,s.camelCase=cp,s.capitalize=vo,s.ceil=ad,s.clamp=ap,s.clone=eg,s.cloneDeep=ig,s.cloneDeepWith=ug,s.cloneWith=rg,s.conformsTo=sg,s.deburr=wo,s.defaultTo=$p,s.divide=fd,s.endsWith=hp,s.eq=Zn,s.escape=gp,s.escapeRegExp=pp,s.every=xh,s.find=Ah,s.findIndex=Gs,s.findKey=Ug,s.findLast=Ch,s.findLastIndex=ks,s.findLastKey=Dg,s.floor=ld,s.forEach=Zs,s.forEachRight=Xs,s.forIn=Ng,s.forInRight=Bg,s.forOwn=$g,s.forOwnRight=qg,s.get=Oi,s.gt=og,s.gte=ag,s.has=zg,s.hasIn=Wi,s.head=Hs,s.identity=An,s.includes=Eh,s.indexOf=Cc,s.inRange=fp,s.invoke=Jg,s.isArguments=Wt,s.isArray=O,s.isArrayBuffer=fg,s.isArrayLike=xn,s.isArrayLikeObject=V,s.isBoolean=lg,s.isBuffer=xt,s.isDate=cg,s.isElement=hg,s.isEmpty=gg,s.isEqual=pg,s.isEqualWith=dg,s.isError=Ii,s.isFinite=_g,s.isFunction=at,s.isInteger=io,s.isLength=pr,s.isMap=uo,s.isMatch=vg,s.isMatchWith=wg,s.isNaN=mg,s.isNative=yg,s.isNil=Sg,s.isNull=xg,s.isNumber=so,s.isObject=Z,s.isObjectLike=Q,s.isPlainObject=we,s.isRegExp=Li,s.isSafeInteger=Ag,s.isSet=oo,s.isString=dr,s.isSymbol=In,s.isTypedArray=Zt,s.isUndefined=Cg,s.isWeakMap=bg,s.isWeakSet=Rg,s.join=Ec,s.kebabCase=dp,s.last=qn,s.lastIndexOf=Ic,s.lowerCase=_p,s.lowerFirst=vp,s.lt=Tg,s.lte=Pg,s.max=cd,s.maxBy=hd,s.mean=gd,s.meanBy=pd,s.min=dd,s.minBy=_d,s.stubArray=Bi,s.stubFalse=$i,s.stubObject=td,s.stubString=ed,s.stubTrue=rd,s.multiply=vd,s.nth=Lc,s.noConflict=Jp,s.noop=Ni,s.now=cr,s.pad=wp,s.padEnd=mp,s.padStart=yp,s.parseInt=xp,s.random=lp,s.reduce=Mh,s.reduceRight=Fh,s.repeat=Sp,s.replace=Ap,s.result=np,s.round=wd,s.runInContext=l,s.sample=Dh,s.size=$h,s.snakeCase=Cp,s.some=qh,s.sortedIndex=Nc,s.sortedIndexBy=Bc,s.sortedIndexOf=$c,s.sortedLastIndex=qc,s.sortedLastIndexBy=Gc,s.sortedLastIndexOf=kc,s.startCase=Rp,s.startsWith=Tp,s.subtract=md,s.sum=yd,s.sumBy=xd,s.template=Pp,s.times=id,s.toFinite=ft,s.toInteger=W,s.toLength=fo,s.toLower=Ep,s.toNumber=Gn,s.toSafeInteger=Eg,s.toString=G,s.toUpper=Ip,s.trim=Lp,s.trimEnd=Op,s.trimStart=Wp,s.truncate=Mp,s.unescape=Fp,s.uniqueId=sd,s.upperCase=Up,s.upperFirst=Mi,s.each=Zs,s.eachRight=Xs,s.first=Hs,Di(s,function(){var n={};return Vn(s,function(t,e){k.call(s.prototype,e)||(n[e]=t)}),n}(),{chain:!1}),s.VERSION=w,Un(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){s[n].placeholder=s}),Un(["drop","take"],function(n,t){N.prototype[n]=function(e){e=e===i?1:sn(W(e),0);var r=this.__filtered__&&!t?new N(this):this.clone();return r.__filtered__?r.__takeCount__=ln(e,r.__takeCount__):r.__views__.push({size:ln(e,Qn),type:n+(r.__dir__<0?"Right":"")}),r},N.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()}}),Un(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==gn||e==Lo;N.prototype[n]=function(u){var o=this.clone();return o.__iteratees__.push({iteratee:R(u,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),Un(["head","last"],function(n,t){var e="take"+(t?"Right":"");N.prototype[n]=function(){return this[e](1).value()[0]}}),Un(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");N.prototype[n]=function(){return this.__filtered__?new N(this):this[e](1)}}),N.prototype.compact=function(){return this.filter(An)},N.prototype.find=function(n){return this.filter(n).head()},N.prototype.findLast=function(n){return this.reverse().find(n)},N.prototype.invokeMap=U(function(n,t){return typeof n=="function"?new N(this):this.map(function(e){return he(e,n,t)})}),N.prototype.reject=function(n){return this.filter(gr(R(n)))},N.prototype.slice=function(n,t){n=W(n);var e=this;return e.__filtered__&&(n>0||t<0)?new N(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=W(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},N.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},N.prototype.toArray=function(){return this.take(Qn)},Vn(N.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),u=s[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);u&&(s.prototype[t]=function(){var a=this.__wrapped__,f=r?[1]:arguments,c=a instanceof N,d=f[0],_=c||O(a),v=function(D){var B=u.apply(s,pt([D],f));return r&&x?B[0]:B};_&&e&&typeof d=="function"&&d.length!=1&&(c=_=!1);var x=this.__chain__,A=!!this.__actions__.length,T=o&&!x,M=c&&!A;if(!o&&_){a=M?a:new N(this);var P=n.apply(a,f);return P.__actions__.push({func:fr,args:[v],thisArg:i}),new Nn(P,x)}return T&&M?n.apply(this,f):(P=this.thru(v),T?r?P.value()[0]:P.value():P)})}),Un(["pop","push","shift","sort","splice","unshift"],function(n){var t=Fe[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);s.prototype[n]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(O(o)?o:[],u)}return this[e](function(a){return t.apply(O(a)?a:[],u)})}}),Vn(N.prototype,function(n,t){var e=s[t];if(e){var r=e.name+"";k.call(zt,r)||(zt[r]=[]),zt[r].push({name:t,func:e})}}),zt[er(i,mn).name]=[{name:"wrapper",func:i}],N.prototype.clone=Ff,N.prototype.reverse=Uf,N.prototype.value=Df,s.prototype.at=hh,s.prototype.chain=gh,s.prototype.commit=ph,s.prototype.next=dh,s.prototype.plant=vh,s.prototype.reverse=wh,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=mh,s.prototype.first=s.prototype.head,ue&&(s.prototype[ue]=_h),s},qt=pf();bt?((bt.exports=qt)._=qt,Ur._=qt):an._=qt}).call(me)})(wr,wr.exports);var Ed=wr.exports;const Id=Cd(Ed);class Ld{constructor(g){E(this,"config");this.config=g}async complete(g,i){var w;await this.persist(g,{...i,success:!0}),(w=this.config.logger)==null||w.debug("Transaction completed:",g)}async fail(g,i){var w;await this.persist(g,{...i,success:!1}),(w=this.config.logger)==null||w.debug("Transaction failed:",{...g,...i})}async persist(g,i){await fetch(`${this.config.apiUrl}/transactions/${g.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Od{constructor(g,i){E(this,"transaction");E(this,"manager");this.transaction=g,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(g,i){var I;const w=this.transaction.functionCall;if(!w){await this.fail("No function call found");return}const m=w.name,C=w.args,b=g[m];if(!b){await this.fail(`Tool ${m} not found`);return}try{const q=Id.get(i,"schema.config.parameters.properties",{}),Cn=(q&&Object.keys(q).length>0?Object.keys(q):((I=b.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:I[1].split(",").map(bn=>bn.trim()).filter(Boolean))||[]).map(bn=>C[bn]),en=await b.apply(null,Cn);await this.complete(en)}catch(q){await this.fail(`Error executing tool ${m}: ${q}`)}}async complete(g){await this.manager.complete(this.transaction,{success:!0,output:g,error:null})}async fail(g){await this.manager.fail(this.transaction,{success:!1,output:null,error:g})}}class Ro extends xe{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"notify",!0);E(this,"_tools");E(this,"_toolSchema",{});if(this.config=i,this.status="disconnected",this.autostart=!0,Array.isArray(i.tools)){this._tools={};for(const w of i.tools)w.schema&&w.implementation&&(this._tools[w.schema.name]=w.implementation,this._toolSchema[w.schema.name]=w)}else this._tools=i.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(i){return this._toolSchema[i]}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){}onTransaction(i){const w=new Ld(this.config),m=new Od(i,w);if(this.config.onTransaction)this.config.onTransaction(m);else{const C=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;m.invoke(this._tools,C)}}getTools(){return this._tools}}const Se=vn.createContext(void 0);function Wd(y){return new Promise((g,i)=>{const w=new FileReader;w.readAsDataURL(y),w.onload=()=>{const C=w.result.split(";base64,")[1];g(C)},w.onerror=m=>{i(m)}})}function Md(y){const g={rest:i=>i.config.apiUrl,webrtc:i=>i.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:i=>i.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const i of y){const w=g[i.getName()];if(w)return w(i)}return null}function Fd({dev:y=!1,baseUrl:g,protocols:i,logger:w,children:m,session:C="new",transformMessages:b,...I}){const[q,tn]=vn.useState(!1),[Cn,en]=vn.useState([]),[bn,hn]=vn.useState(C),[Rn,ct]=vn.useState(new Map),wn=vn.useRef(!1),mn=vn.useMemo(()=>{if(Array.isArray(i))return i;if(typeof i=="object"&&i!==null){const F=y?"localhost:8000":g||"persona.applica.guru/api",nn=y?"http":"https",z=y?"ws":"wss";let Wn=Object.keys(i).map(rn=>{switch(rn){case"rest":const Mn=i[rn];return Mn===!0?new Gi({apiUrl:`${nn}://${F}`,apiKey:I.apiKey,agentId:I.agentId,logger:w}):typeof Mn=="object"&&Mn!==null?new Gi(Mn):null;case"webrtc":const X=i[rn];return X===!0?new zi({webrtcUrl:`${z}://${F}/webrtc`,apiKey:I.apiKey,agentId:I.agentId,logger:w}):typeof X=="object"&&X!==null?new zi(X):null;case"websocket":const gn=i[rn];return gn===!0?new ki({webSocketUrl:`${z}://${F}/websocket`,apiKey:I.apiKey,agentId:I.agentId,logger:w}):typeof gn=="object"&&gn!==null?new ki(gn):null;default:throw new Error(`Unknown protocol: ${rn}`)}}).filter(rn=>rn!==null);return I.tools&&Wn.push(new Ro({apiUrl:`${nn}://${F}`,apiKey:I.apiKey,agentId:I.agentId,tools:I.tools,logger:w})),Wn}throw new Error("Invalid protocols configuration")},[]);vn.useEffect(()=>{wn.current||(wn.current=!0,w==null||w.debug("Initializing protocols: ",mn.map(F=>F.getName())),mn.forEach(F=>{F.setSession(bn),F.clearListeners(),F.addStatusChangeListener(nn=>{w==null||w.debug(`${F.getName()} has notified new status: ${nn}`),Rn.set(F.getName(),nn),nn==="connected"&&(I.context&&F.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:I.context}}),I.tools&&Array.isArray(I.tools)&&F.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:I.tools.map(z=>z.schema)}}})),ct(new Map(Rn))}),F.addPacketListener(nn=>{if(nn.type==="message"){const z=nn.payload;(z==null?void 0:z.finishReason)==="stop"&&!(z!=null&&z.functionResponse)&&!(z!=null&&z.thought)&&tn(!1),z.thought&&(z.type="reasoning"),en(Wn=>{const rn=Co([...Wn,{...z,protocol:F.getName()}]);return b?b(rn):rn})}else if(nn.type==="reasoning"){const Wn={type:"reasoning",text:nn.payload.thought,role:"assistant",finishReason:"stop"};en(rn=>{const Mn=Co([...rn,{...Wn,protocol:F.getName()}]);return b?b(Mn):Mn})}else nn.type==="transaction"&&mn.filter(z=>z!==F).forEach(z=>z.onTransaction(nn.payload))}),F.autostart&&F.status==="disconnected"&&(w==null||w.debug(`Connecting to protocol: ${F.getName()}`),F.connect(bn),tn(!1))}))},[bn,mn,w,Rn,b]);const Ae=async F=>{var Mn;if(((Mn=F.content[0])==null?void 0:Mn.type)!=="text")throw new Error("Only text messages are supported");if(!mn.some(X=>X.getName()!=="transaction"&&X.status==="connected")){en(X=>{const gn=[...X,{role:"assistant",type:"text",text:"No protocol is connected."}];return b?b(gn):gn});return}const z=F.content[0].text;en(X=>{const gn=[...X,{role:"user",type:"text",text:z}];return b?b(gn):gn}),tn(!0);const Wn=mn.sort((X,gn)=>gn.getPriority()-X.getPriority()).find(X=>X.status==="connected"),rn=[];if(F.attachments)for(const X of F.attachments)X.contentType.startsWith("image/")&&X.file&&rn.push({role:"user",image:{contentType:X.contentType,content:await Wd(X.file)},text:"",type:"text"});F.content&&rn.push({role:"user",text:F.content[0].text,type:"text"}),w==null||w.debug("Sending message:",rn),await(Wn==null?void 0:Wn.sendPacket({type:"request",payload:rn}))},kn=vn.useCallback(()=>(tn(!1),en([]),hn("new"),Promise.resolve()),[]),St=vn.useCallback(()=>Promise.resolve(),[]),zn=vn.useCallback(()=>Cn,[Cn]),At=vr.useExternalStoreRuntime({isRunning:q,messages:Cn,convertMessage:Td,onNew:Ae,onCancel:kn,onReload:St,adapters:{attachments:new vr.CompositeAttachmentAdapter([new vr.SimpleImageAttachmentAdapter])}});return qi.jsx(Se.Provider,{value:{protocols:mn,protocolsStatus:Rn,getMessages:zn},children:qi.jsx(vr.AssistantRuntimeProvider,{runtime:At,children:m})})}function Ud({children:y,...g}){return qi.jsx(Fd,{...g,children:y})}function Dd(){const y=vn.useContext(Se);if(!y)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return y}function To(y){const g=vn.useContext(Se);if(!g)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=g.protocols.find(m=>m.getName()===y);if(!i)return null;const w=g.protocolsStatus.get(i.getName());return{...i,connect:i.connect.bind(i),disconnect:i.disconnect.bind(i),sendPacket:i.sendPacket.bind(i),setSession:i.setSession.bind(i),addStatusChangeListener:i.addStatusChangeListener.bind(i),addPacketListener:i.addPacketListener.bind(i),getName:i.getName.bind(i),getPriority:i.getPriority.bind(i),status:w||i.status}}function Nd(){const y=vn.useContext(Se);if(!y)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return Md(y.protocols)}function Bd(){return To("webrtc")}function $d(){const y=vn.useContext(Se);if(!y)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return y.getMessages()}class qd{constructor(){E(this,"prefix","[Persona]")}log(g,...i){console.log(`${this.prefix} - ${g}`,...i)}info(g,...i){console.info(`${this.prefix} - ${g}`,...i)}warn(g,...i){console.warn(`${this.prefix} - ${g}`,...i)}error(g,...i){console.error(`${this.prefix} - ${g}`,...i)}debug(g,...i){console.debug(`${this.prefix} - ${g}`,...i)}}function Mt(y,g,i){return{type:y,description:g,...i}}function Po(y){const g=Object.entries(y.parameters).filter(([i,w])=>w.required).map(([i])=>i);return{type:"local",name:y.name,description:y.description,config:{timeout:y.timeout||60,parameters:{type:"object",title:y.title||`${y.name} parameters`,required:g,properties:y.parameters},output:{type:"object",title:`${y.name} output`,properties:y.output}}}}function mr(y){return{schema:Po(y),implementation:y.implementation}}function Eo(y,g,i,w,m,C){const b={name:y,description:g,title:C==null?void 0:C.title,timeout:C==null?void 0:C.timeout,parameters:w,output:m,implementation:i};return mr(b)}const Gd=Eo("sum","Sum two numbers",function(g,i){return{result:g+i}},{a:Mt("number","First number to sum",{required:!0}),b:Mt("number","Second number to sum",{required:!0})},{result:Mt("number","Sum of two numbers")}),kd=mr({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:Mt("number","First number to sum"),b:Mt("number","Seconth number to sum")},output:{result:Mt("number","Sum of two numbers")},implementation:function(g,i){return{result:g+i}}});function zd(y){const g=[],i={};return y.forEach(w=>{const{schema:m,implementation:C}=mr(w);g.push(m),i[w.name]=C}),{schemas:g,implementations:i}}function Hd(y,g){const{required:i,properties:w}=g.config.parameters;for(const m of i)if(!(m in y))throw new Error(`Missing required parameter: ${m}`);for(const[m,C]of Object.entries(y)){const b=w[m];if(b){if(b.type==="number"&&typeof C!="number")throw new Error(`Parameter ${m} should be a number`);if(b.type==="string"&&typeof C!="string")throw new Error(`Parameter ${m} should be a string`);if(b.type==="boolean"&&typeof C!="boolean")throw new Error(`Parameter ${m} should be a boolean`)}}return!0}exports.PersonaConsoleLogger=qd;exports.PersonaProtocolBase=xe;exports.PersonaRESTProtocol=Gi;exports.PersonaRuntimeProvider=Ud;exports.PersonaTransactionProtocol=Ro;exports.PersonaWebRTCProtocol=zi;exports.PersonaWebSocketProtocol=ki;exports.createParameter=Mt;exports.createTool=mr;exports.createToolFromFunction=Eo;exports.createToolRegistry=zd;exports.generateToolSchema=Po;exports.navigateToToolExample=kd;exports.sumTool=Gd;exports.usePersonaRuntime=Dd;exports.usePersonaRuntimeEndpoint=Nd;exports.usePersonaRuntimeMessages=$d;exports.usePersonaRuntimeProtocol=To;exports.usePersonaRuntimeWebRTCProtocol=Bd;exports.validateToolParameters=Hd;
38
+ `)+T+`return __p
39
+ }`;var $=gu(function(){return Y(l,L+"return "+T).apply(r,d)});if($.source=T,hi($))throw $;return $}function l_(t){return V(t).toLowerCase()}function f_(t){return V(t).toUpperCase()}function d_(t,e,s){if(t=V(t),t&&(s||e===r))return Eo(t);if(!t||!(e=Ot(e)))return t;var o=Xt(t),u=Xt(e),l=To(o,u),d=Ao(o,u)+1;return Re(o,l,d).join("")}function p_(t,e,s){if(t=V(t),t&&(s||e===r))return t.slice(0,Io(t)+1);if(!t||!(e=Ot(e)))return t;var o=Xt(t),u=Ao(o,Xt(e))+1;return Re(o,0,u).join("")}function g_(t,e,s){if(t=V(t),t&&(s||e===r))return t.replace(hs,"");if(!t||!(e=Ot(e)))return t;var o=Xt(t),u=To(o,Xt(e));return Re(o,u).join("")}function __(t,e){var s=Nt,o=ht;if(nt(e)){var u="separator"in e?e.separator:u;s="length"in e?W(e.length):s,o="omission"in e?Ot(e.omission):o}t=V(t);var l=t.length;if(tn(t)){var d=Xt(t);l=d.length}if(s>=l)return t;var g=s-en(o);if(g<1)return o;var b=d?Re(d,0,g).join(""):t.slice(0,g);if(u===r)return b+o;if(d&&(g+=b.length-g),li(u)){if(t.slice(g).search(u)){var x,E=b;for(u.global||(u=Cs(u.source,V(Ji.exec(u))+"g")),u.lastIndex=0;x=u.exec(E);)var T=x.index;b=b.slice(0,T===r?g:T)}}else if(t.indexOf(Ot(u),g)!=g){var M=b.lastIndexOf(u);M>-1&&(b=b.slice(0,M))}return b+o}function b_(t){return t=V(t),t&&Cc.test(t)?t.replace(qi,Jh):t}var m_=cn(function(t,e,s){return t+(s?" ":"")+e.toUpperCase()}),pi=_a("toUpperCase");function pu(t,e,s){return t=V(t),e=s?r:e,e===r?Wh(t)?Yh(t):Ph(t):t.match(e)||[]}var gu=z(function(t,e){try{return Mt(t,r,e)}catch(s){return hi(s)?s:new N(s)}}),v_=_e(function(t,e){return Wt(e,function(s){s=ue(s),pe(t,s,ui(t[s],t))}),t});function w_(t){var e=t==null?0:t.length,s=B();return t=e?et(t,function(o){if(typeof o[1]!="function")throw new $t(p);return[s(o[0]),o[1]]}):[],z(function(o){for(var u=-1;++u<e;){var l=t[u];if(Mt(l[0],this,o))return Mt(l[1],this,o)}})}function y_(t){return Jl(zt(t,C))}function gi(t){return function(){return t}}function S_(t,e){return t==null||t!==t?e:t}var x_=ma(),E_=ma(!0);function Rt(t){return t}function _i(t){return Yo(typeof t=="function"?t:zt(t,C))}function T_(t){return Zo(zt(t,C))}function A_(t,e){return Xo(t,zt(e,C))}var C_=z(function(t,e){return function(s){return Bn(s,t,e)}}),I_=z(function(t,e){return function(s){return Bn(t,s,e)}});function bi(t,e,s){var o=gt(e),u=Er(e,o);s==null&&!(nt(e)&&(u.length||!o.length))&&(s=e,e=t,t=this,u=Er(e,gt(e)));var l=!(nt(s)&&"chain"in s)||!!s.chain,d=me(t);return Wt(u,function(g){var b=e[g];t[g]=b,d&&(t.prototype[g]=function(){var x=this.__chain__;if(l||x){var E=t(this.__wrapped__),T=E.__actions__=At(this.__actions__);return T.push({func:b,args:arguments,thisArg:t}),E.__chain__=x,E}return b.apply(t,xe([this.value()],arguments))})}),t}function R_(){return _t._===this&&(_t._=tl),this}function mi(){}function M_(t){return t=W(t),z(function(e){return Qo(e,t)})}var P_=Vs(et),O_=Vs(vo),L_=Vs(ws);function _u(t){return ni(t)?ys(ue(t)):cf(t)}function B_(t){return function(e){return t==null?r:$e(t,e)}}var k_=wa(),D_=wa(!0);function vi(){return[]}function wi(){return!1}function N_(){return{}}function F_(){return""}function U_(){return!0}function W_(t,e){if(t=W(t),t<1||t>ye)return[];var s=ie,o=mt(t,ie);e=B(e),t-=ie;for(var u=Es(o,e);++s<t;)e(s);return u}function $_(t){return F(t)?et(t,ue):Lt(t)?[t]:At(Da(V(t)))}function q_(t){var e=++Qh;return V(t)+e}var z_=Mr(function(t,e){return t+e},0),H_=Zs("ceil"),J_=Mr(function(t,e){return t/e},1),G_=Zs("floor");function K_(t){return t&&t.length?xr(t,Rt,ks):r}function Y_(t,e){return t&&t.length?xr(t,B(e,2),ks):r}function V_(t){return So(t,Rt)}function Z_(t,e){return So(t,B(e,2))}function X_(t){return t&&t.length?xr(t,Rt,Us):r}function Q_(t,e){return t&&t.length?xr(t,B(e,2),Us):r}var j_=Mr(function(t,e){return t*e},1),tb=Zs("round"),eb=Mr(function(t,e){return t-e},0);function nb(t){return t&&t.length?xs(t,Rt):0}function rb(t,e){return t&&t.length?xs(t,B(e,2)):0}return c.after=Tp,c.ary=Ka,c.assign=fg,c.assignIn=au,c.assignInWith=zr,c.assignWith=dg,c.at=pg,c.before=Ya,c.bind=ui,c.bindAll=v_,c.bindKey=Va,c.castArray=Np,c.chain=Ha,c.chunk=Gf,c.compact=Kf,c.concat=Yf,c.cond=w_,c.conforms=y_,c.constant=gi,c.countBy=np,c.create=gg,c.curry=Za,c.curryRight=Xa,c.debounce=Qa,c.defaults=_g,c.defaultsDeep=bg,c.defer=Ap,c.delay=Cp,c.difference=Vf,c.differenceBy=Zf,c.differenceWith=Xf,c.drop=Qf,c.dropRight=jf,c.dropRightWhile=td,c.dropWhile=ed,c.fill=nd,c.filter=sp,c.flatMap=ap,c.flatMapDeep=up,c.flatMapDepth=cp,c.flatten=Wa,c.flattenDeep=rd,c.flattenDepth=sd,c.flip=Ip,c.flow=x_,c.flowRight=E_,c.fromPairs=id,c.functions=Eg,c.functionsIn=Tg,c.groupBy=hp,c.initial=ad,c.intersection=ud,c.intersectionBy=cd,c.intersectionWith=hd,c.invert=Cg,c.invertBy=Ig,c.invokeMap=fp,c.iteratee=_i,c.keyBy=dp,c.keys=gt,c.keysIn=It,c.map=Nr,c.mapKeys=Mg,c.mapValues=Pg,c.matches=T_,c.matchesProperty=A_,c.memoize=Ur,c.merge=Og,c.mergeWith=uu,c.method=C_,c.methodOf=I_,c.mixin=bi,c.negate=Wr,c.nthArg=M_,c.omit=Lg,c.omitBy=Bg,c.once=Rp,c.orderBy=pp,c.over=P_,c.overArgs=Mp,c.overEvery=O_,c.overSome=L_,c.partial=ci,c.partialRight=ja,c.partition=gp,c.pick=kg,c.pickBy=cu,c.property=_u,c.propertyOf=B_,c.pull=pd,c.pullAll=qa,c.pullAllBy=gd,c.pullAllWith=_d,c.pullAt=bd,c.range=k_,c.rangeRight=D_,c.rearg=Pp,c.reject=mp,c.remove=md,c.rest=Op,c.reverse=oi,c.sampleSize=wp,c.set=Ng,c.setWith=Fg,c.shuffle=yp,c.slice=vd,c.sortBy=Ep,c.sortedUniq=Ad,c.sortedUniqBy=Cd,c.split=a_,c.spread=Lp,c.tail=Id,c.take=Rd,c.takeRight=Md,c.takeRightWhile=Pd,c.takeWhile=Od,c.tap=Kd,c.throttle=Bp,c.thru=Dr,c.toArray=su,c.toPairs=hu,c.toPairsIn=lu,c.toPath=$_,c.toPlainObject=ou,c.transform=Ug,c.unary=kp,c.union=Ld,c.unionBy=Bd,c.unionWith=kd,c.uniq=Dd,c.uniqBy=Nd,c.uniqWith=Fd,c.unset=Wg,c.unzip=ai,c.unzipWith=za,c.update=$g,c.updateWith=qg,c.values=fn,c.valuesIn=zg,c.without=Ud,c.words=pu,c.wrap=Dp,c.xor=Wd,c.xorBy=$d,c.xorWith=qd,c.zip=zd,c.zipObject=Hd,c.zipObjectDeep=Jd,c.zipWith=Gd,c.entries=hu,c.entriesIn=lu,c.extend=au,c.extendWith=zr,bi(c,c),c.add=z_,c.attempt=gu,c.camelCase=Kg,c.capitalize=fu,c.ceil=H_,c.clamp=Hg,c.clone=Fp,c.cloneDeep=Wp,c.cloneDeepWith=$p,c.cloneWith=Up,c.conformsTo=qp,c.deburr=du,c.defaultTo=S_,c.divide=J_,c.endsWith=Yg,c.eq=jt,c.escape=Vg,c.escapeRegExp=Zg,c.every=rp,c.find=ip,c.findIndex=Fa,c.findKey=mg,c.findLast=op,c.findLastIndex=Ua,c.findLastKey=vg,c.floor=G_,c.forEach=Ja,c.forEachRight=Ga,c.forIn=wg,c.forInRight=yg,c.forOwn=Sg,c.forOwnRight=xg,c.get=fi,c.gt=zp,c.gte=Hp,c.has=Ag,c.hasIn=di,c.head=$a,c.identity=Rt,c.includes=lp,c.indexOf=od,c.inRange=Jg,c.invoke=Rg,c.isArguments=He,c.isArray=F,c.isArrayBuffer=Jp,c.isArrayLike=Ct,c.isArrayLikeObject=ot,c.isBoolean=Gp,c.isBuffer=Me,c.isDate=Kp,c.isElement=Yp,c.isEmpty=Vp,c.isEqual=Zp,c.isEqualWith=Xp,c.isError=hi,c.isFinite=Qp,c.isFunction=me,c.isInteger=tu,c.isLength=$r,c.isMap=eu,c.isMatch=jp,c.isMatchWith=tg,c.isNaN=eg,c.isNative=ng,c.isNil=sg,c.isNull=rg,c.isNumber=nu,c.isObject=nt,c.isObjectLike=it,c.isPlainObject=Wn,c.isRegExp=li,c.isSafeInteger=ig,c.isSet=ru,c.isString=qr,c.isSymbol=Lt,c.isTypedArray=ln,c.isUndefined=og,c.isWeakMap=ag,c.isWeakSet=ug,c.join=ld,c.kebabCase=Xg,c.last=Jt,c.lastIndexOf=fd,c.lowerCase=Qg,c.lowerFirst=jg,c.lt=cg,c.lte=hg,c.max=K_,c.maxBy=Y_,c.mean=V_,c.meanBy=Z_,c.min=X_,c.minBy=Q_,c.stubArray=vi,c.stubFalse=wi,c.stubObject=N_,c.stubString=F_,c.stubTrue=U_,c.multiply=j_,c.nth=dd,c.noConflict=R_,c.noop=mi,c.now=Fr,c.pad=t_,c.padEnd=e_,c.padStart=n_,c.parseInt=r_,c.random=Gg,c.reduce=_p,c.reduceRight=bp,c.repeat=s_,c.replace=i_,c.result=Dg,c.round=tb,c.runInContext=_,c.sample=vp,c.size=Sp,c.snakeCase=o_,c.some=xp,c.sortedIndex=wd,c.sortedIndexBy=yd,c.sortedIndexOf=Sd,c.sortedLastIndex=xd,c.sortedLastIndexBy=Ed,c.sortedLastIndexOf=Td,c.startCase=u_,c.startsWith=c_,c.subtract=eb,c.sum=nb,c.sumBy=rb,c.template=h_,c.times=W_,c.toFinite=ve,c.toInteger=W,c.toLength=iu,c.toLower=l_,c.toNumber=Gt,c.toSafeInteger=lg,c.toString=V,c.toUpper=f_,c.trim=d_,c.trimEnd=p_,c.trimStart=g_,c.truncate=__,c.unescape=b_,c.uniqueId=q_,c.upperCase=m_,c.upperFirst=pi,c.each=Ja,c.eachRight=Ga,c.first=$a,bi(c,function(){var t={};return oe(c,function(e,s){Z.call(c.prototype,s)||(t[s]=e)}),t}(),{chain:!1}),c.VERSION=a,Wt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){c[t].placeholder=c}),Wt(["drop","take"],function(t,e){J.prototype[t]=function(s){s=s===r?1:ft(W(s),0);var o=this.__filtered__&&!e?new J(this):this.clone();return o.__filtered__?o.__takeCount__=mt(s,o.__takeCount__):o.__views__.push({size:mt(s,ie),type:t+(o.__dir__<0?"Right":"")}),o},J.prototype[t+"Right"]=function(s){return this.reverse()[t](s).reverse()}}),Wt(["filter","map","takeWhile"],function(t,e){var s=e+1,o=s==wt||s==dc;J.prototype[t]=function(u){var l=this.clone();return l.__iteratees__.push({iteratee:B(u,3),type:s}),l.__filtered__=l.__filtered__||o,l}}),Wt(["head","last"],function(t,e){var s="take"+(e?"Right":"");J.prototype[t]=function(){return this[s](1).value()[0]}}),Wt(["initial","tail"],function(t,e){var s="drop"+(e?"":"Right");J.prototype[t]=function(){return this.__filtered__?new J(this):this[s](1)}}),J.prototype.compact=function(){return this.filter(Rt)},J.prototype.find=function(t){return this.filter(t).head()},J.prototype.findLast=function(t){return this.reverse().find(t)},J.prototype.invokeMap=z(function(t,e){return typeof t=="function"?new J(this):this.map(function(s){return Bn(s,t,e)})}),J.prototype.reject=function(t){return this.filter(Wr(B(t)))},J.prototype.slice=function(t,e){t=W(t);var s=this;return s.__filtered__&&(t>0||e<0)?new J(s):(t<0?s=s.takeRight(-t):t&&(s=s.drop(t)),e!==r&&(e=W(e),s=e<0?s.dropRight(-e):s.take(e-t)),s)},J.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},J.prototype.toArray=function(){return this.take(ie)},oe(J.prototype,function(t,e){var s=/^(?:filter|find|map|reject)|While$/.test(e),o=/^(?:head|last)$/.test(e),u=c[o?"take"+(e=="last"?"Right":""):e],l=o||/^find/.test(e);u&&(c.prototype[e]=function(){var d=this.__wrapped__,g=o?[1]:arguments,b=d instanceof J,x=g[0],E=b||F(d),T=function(H){var G=u.apply(c,xe([H],g));return o&&M?G[0]:G};E&&s&&typeof x=="function"&&x.length!=1&&(b=E=!1);var M=this.__chain__,L=!!this.__actions__.length,k=l&&!M,$=b&&!L;if(!l&&E){d=$?d:new J(this);var D=t.apply(d,g);return D.__actions__.push({func:Dr,args:[T],thisArg:r}),new qt(D,M)}return k&&$?t.apply(this,g):(D=this.thru(T),k?o?D.value()[0]:D.value():D)})}),Wt(["pop","push","shift","sort","splice","unshift"],function(t){var e=ur[t],s=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",o=/^(?:pop|shift)$/.test(t);c.prototype[t]=function(){var u=arguments;if(o&&!this.__chain__){var l=this.value();return e.apply(F(l)?l:[],u)}return this[s](function(d){return e.apply(F(d)?d:[],u)})}}),oe(J.prototype,function(t,e){var s=c[e];if(s){var o=s.name+"";Z.call(on,o)||(on[o]=[]),on[o].push({name:e,func:s})}}),on[Rr(r,ut).name]=[{name:"wrapper",func:r}],J.prototype.clone=_l,J.prototype.reverse=bl,J.prototype.value=ml,c.prototype.at=Yd,c.prototype.chain=Vd,c.prototype.commit=Zd,c.prototype.next=Xd,c.prototype.plant=jd,c.prototype.reverse=tp,c.prototype.toJSON=c.prototype.valueOf=c.prototype.value=ep,c.prototype.first=c.prototype.head,Cn&&(c.prototype[Cn]=Qd),c},nn=Vh();De?((De.exports=nn)._=nn,_s._=nn):_t._=nn}).call($n)})(Zr,Zr.exports);var lv=Zr.exports;const fv=Lu(lv);class dv{constructor(i){S(this,"config");this.config=i}async complete(i,r){var a;await this.persist(i,{...r,success:!0}),(a=this.config.logger)==null||a.debug("Transaction completed:",i)}async fail(i,r){var a;await this.persist(i,{...r,success:!1}),(a=this.config.logger)==null||a.debug("Transaction failed:",{...i,...r})}async persist(i,r){await fetch(`${this.config.apiUrl}/transactions/${i.id}`,{body:JSON.stringify(r),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class pv{constructor(i,r){S(this,"transaction");S(this,"manager");this.transaction=i,this.manager=r}getFunctionCall(){return this.transaction.functionCall}async invoke(i,r){var m;const a=this.transaction.functionCall;if(!a){await this.fail("No function call found");return}const h=a.name,f=a.args,p=i[h];if(!p){await this.fail(`Tool ${h} not found`);return}try{const w=fv.get(r,"schema.config.parameters.properties",{}),P=(w&&Object.keys(w).length>0?Object.keys(w):((m=p.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:m[1].split(",").map(A=>A.trim()).filter(Boolean))||[]).map(A=>f[A]),C=await p.apply(null,P);await this.complete(C)}catch(w){await this.fail(`Error executing tool ${h}: ${w}`)}}async complete(i){await this.manager.complete(this.transaction,{success:!0,output:i,error:null})}async fail(i){await this.manager.fail(this.transaction,{success:!1,output:null,error:i})}}class uc extends Yn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"notify",!0);S(this,"_tools");S(this,"_toolSchema",{});if(this.config=r,this.status="disconnected",this.autostart=!0,Array.isArray(r.tools)){this._tools={};for(const a of r.tools)a.schema&&a.implementation&&(this._tools[a.schema.name]=a.implementation,this._toolSchema[a.schema.name]=a)}else this._tools=r.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(r){return this._toolSchema[r]}async connect(r){return this.setStatus("connected"),r}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(r){this.session=r}async sendPacket(r){}onTransaction(r){const a=new dv(this.config),h=new pv(r,a);if(this.config.onTransaction)this.config.onTransaction(h);else{const f=r.functionCall?this.getToolInstance(r.functionCall.name):void 0;h.invoke(this._tools,f)}}getTools(){return this._tools}}const Vn=U.createContext(void 0);function gv(n){return new Promise((i,r)=>{const a=new FileReader;a.readAsDataURL(n),a.onload=()=>{const f=a.result.split(";base64,")[1];i(f)},a.onerror=h=>{r(h)}})}function _v(n){const i={rest:r=>r.config.apiUrl,webrtc:r=>r.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:r=>r.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const r of n){const a=i[r.getName()];if(a)return a(r)}return null}function bv({dev:n=!1,baseUrl:i,protocols:r,logger:a,children:h,session:f="new",transformMessages:p,...m}){const[w,I]=U.useState(!1),[P,C]=U.useState([]),[A,R]=U.useState(f),[K,Tt]=U.useState(new Map),pt=U.useRef(!1),ut=U.useMemo(()=>{if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const q=n?"localhost:8000":i||"persona.applica.guru/api",ct=n?"http":"https",X=n?"ws":"wss";let Nt=Object.keys(r).map(ht=>{switch(ht){case"rest":const Ft=r[ht];return Ft===!0?new Mi({apiUrl:`${ct}://${q}`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof Ft=="object"&&Ft!==null?new Mi(Ft):null;case"webrtc":const st=r[ht];return st===!0?new Oi({webrtcUrl:`${X}://${q}/webrtc`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof st=="object"&&st!==null?new Oi(st):null;case"websocket":const wt=r[ht];return wt===!0?new Pi({webSocketUrl:`${X}://${q}/websocket`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof wt=="object"&&wt!==null?new Pi(wt):null;default:throw new Error(`Unknown protocol: ${ht}`)}}).filter(ht=>ht!==null);return m.tools&&Nt.push(new uc({apiUrl:`${ct}://${q}`,apiKey:m.apiKey,agentId:m.agentId,tools:m.tools,logger:a})),Nt}throw new Error("Invalid protocols configuration")},[]);U.useEffect(()=>{pt.current||(pt.current=!0,a==null||a.debug("Initializing protocols: ",ut.map(q=>q.getName())),ut.forEach(q=>{q.setSession(A),q.clearListeners(),q.addStatusChangeListener(ct=>{a==null||a.debug(`${q.getName()} has notified new status: ${ct}`),K.set(q.getName(),ct),ct==="connected"&&(m.context&&q.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:m.context}}),m.tools&&Array.isArray(m.tools)&&q.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:m.tools.map(X=>X.schema)}}})),Tt(new Map(K))}),q.addPacketListener(ct=>{if(ct.type==="message"){const X=ct.payload;(X==null?void 0:X.finishReason)==="stop"&&!(X!=null&&X.functionResponse)&&!(X!=null&&X.thought)&&I(!1),X.thought&&(X.type="reasoning"),C(Nt=>{const ht=Ou([...Nt,{...X,protocol:q.getName()}]);return p?p(ht):ht})}else if(ct.type==="reasoning"){const Nt={type:"reasoning",text:ct.payload.thought,role:"assistant",finishReason:"stop"};C(ht=>{const Ft=Ou([...ht,{...Nt,protocol:q.getName()}]);return p?p(Ft):Ft})}else ct.type==="transaction"&&ut.filter(X=>X!==q).forEach(X=>X.onTransaction(ct.payload))}),q.autostart&&q.status==="disconnected"&&(a==null||a.debug(`Connecting to protocol: ${q.getName()}`),q.connect(A),I(!1))}))},[A,ut,a,K,p]);const Zn=async q=>{var Ft;if(((Ft=q.content[0])==null?void 0:Ft.type)!=="text")throw new Error("Only text messages are supported");if(!ut.some(st=>st.getName()!=="transaction"&&st.status==="connected")){C(st=>{const wt=[...st,{role:"assistant",type:"text",text:"No protocol is connected."}];return p?p(wt):wt});return}const X=q.content[0].text;C(st=>{const wt=[...st,{role:"user",type:"text",text:X}];return p?p(wt):wt}),I(!0);const Nt=ut.sort((st,wt)=>wt.getPriority()-st.getPriority()).find(st=>st.status==="connected"),ht=[];if(q.attachments)for(const st of q.attachments)st.contentType.startsWith("image/")&&st.file&&ht.push({role:"user",image:{contentType:st.contentType,content:await gv(st.file)},text:"",type:"text"});q.content&&ht.push({role:"user",text:q.content[0].text,type:"text"}),a==null||a.debug("Sending message:",ht),await(Nt==null?void 0:Nt.sendPacket({type:"request",payload:ht}))},Kt=U.useCallback(()=>(I(!1),C([]),R("new"),Promise.resolve()),[]),Le=U.useCallback(()=>Promise.resolve(),[]),Yt=U.useCallback(()=>P,[P]),Be=rm({isRunning:w,messages:P,convertMessage:cv,onNew:Zn,onCancel:Kt,onReload:Le,adapters:{attachments:new Jb([new zb])}});return Pe.jsx(Vn.Provider,{value:{protocols:ut,protocolsStatus:K,getMessages:Yt},children:Pe.jsx(ov,{runtime:Be,children:h})})}function mv({children:n,...i}){return Pe.jsx(bv,{...i,children:n})}function vv(){const n=U.useContext(Vn);if(!n)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return n}function cc(n){const i=U.useContext(Vn);if(!i)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const r=i.protocols.find(h=>h.getName()===n);if(!r)return null;const a=i.protocolsStatus.get(r.getName());return{...r,connect:r.connect.bind(r),disconnect:r.disconnect.bind(r),sendPacket:r.sendPacket.bind(r),setSession:r.setSession.bind(r),addStatusChangeListener:r.addStatusChangeListener.bind(r),addPacketListener:r.addPacketListener.bind(r),getName:r.getName.bind(r),getPriority:r.getPriority.bind(r),status:a||r.status}}function wv(){const n=U.useContext(Vn);if(!n)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return _v(n.protocols)}function yv(){return cc("webrtc")}function Sv(){const n=U.useContext(Vn);if(!n)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return n.getMessages()}class xv{constructor(){S(this,"prefix","[Persona]")}log(i,...r){console.log(`${this.prefix} - ${i}`,...r)}info(i,...r){console.info(`${this.prefix} - ${i}`,...r)}warn(i,...r){console.warn(`${this.prefix} - ${i}`,...r)}error(i,...r){console.error(`${this.prefix} - ${i}`,...r)}debug(i,...r){console.debug(`${this.prefix} - ${i}`,...r)}}function Ye(n,i,r){return{type:n,description:i,...r}}function hc(n){const i=Object.entries(n.parameters).filter(([r,a])=>a.required).map(([r])=>r);return{type:"local",name:n.name,description:n.description,config:{timeout:n.timeout||60,parameters:{type:"object",title:n.title||`${n.name} parameters`,required:i,properties:n.parameters},output:{type:"object",title:`${n.name} output`,properties:n.output}}}}function jr(n){return{schema:hc(n),implementation:n.implementation}}function lc(n,i,r,a,h,f){const p={name:n,description:i,title:f==null?void 0:f.title,timeout:f==null?void 0:f.timeout,parameters:a,output:h,implementation:r};return jr(p)}const Ev=lc("sum","Sum two numbers",function(i,r){return{result:i+r}},{a:Ye("number","First number to sum",{required:!0}),b:Ye("number","Second number to sum",{required:!0})},{result:Ye("number","Sum of two numbers")}),Tv=jr({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:Ye("number","First number to sum"),b:Ye("number","Seconth number to sum")},output:{result:Ye("number","Sum of two numbers")},implementation:function(i,r){return{result:i+r}}});function Av(n){const i=[],r={};return n.forEach(a=>{const{schema:h,implementation:f}=jr(a);i.push(h),r[a.name]=f}),{schemas:i,implementations:r}}function Cv(n,i){const{required:r,properties:a}=i.config.parameters;for(const h of r)if(!(h in n))throw new Error(`Missing required parameter: ${h}`);for(const[h,f]of Object.entries(n)){const p=a[h];if(p){if(p.type==="number"&&typeof f!="number")throw new Error(`Parameter ${h} should be a number`);if(p.type==="string"&&typeof f!="string")throw new Error(`Parameter ${h} should be a string`);if(p.type==="boolean"&&typeof f!="boolean")throw new Error(`Parameter ${h} should be a boolean`)}}return!0}exports.PersonaConsoleLogger=xv;exports.PersonaProtocolBase=Yn;exports.PersonaRESTProtocol=Mi;exports.PersonaRuntimeProvider=mv;exports.PersonaTransactionProtocol=uc;exports.PersonaWebRTCProtocol=Oi;exports.PersonaWebSocketProtocol=Pi;exports.createParameter=Ye;exports.createTool=jr;exports.createToolFromFunction=lc;exports.createToolRegistry=Av;exports.generateToolSchema=hc;exports.navigateToToolExample=Tv;exports.sumTool=Ev;exports.usePersonaRuntime=vv;exports.usePersonaRuntimeEndpoint=wv;exports.usePersonaRuntimeMessages=Sv;exports.usePersonaRuntimeProtocol=cc;exports.usePersonaRuntimeWebRTCProtocol=yv;exports.validateToolParameters=Cv;
36
40
  //# sourceMappingURL=bundle.cjs.js.map