-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathaiAgent.js
More file actions
1 lines (1 loc) · 27.9 KB
/
aiAgent.js
File metadata and controls
1 lines (1 loc) · 27.9 KB
1
import{c as t,A as n,bx as e,f as r,h as i,j as a,a as s,a2 as o,d as u,bE as h,a5 as d,bw as p,g,_ as f,q as v,r as _,ab as y,W as U,a1 as I,b,N as A,V as w,as as S,aX as F,t as E,F as T,B as P,ba as O,u as M}from"./lib/__bundle-667ebc2f.js";export{bF as AIAgentInfo}from"./lib/__bundle-667ebc2f.js";import{C as q,c as R,b as x,d as L,e as D,A as Q,f as N,g as G,h as K}from"./lib/__bundle-b3367837.js";export{C as Conversation,m as ConversationChannelInfo,k as ConversationHandoff,l as ConversationResolution,c as ConversationStatus,j as ConversationType,H as HelpdeskInfo}from"./lib/__bundle-b3367837.js";import"./lib/__bundle-471dda46.js";import"./lib/__bundle-aa3838f4.js";import"./lib/__bundle-e743ea39.js";import"./lib/__bundle-acd77193.js";var X,B,V=function(i){function a(t){var a=t.aiAgentId,s=t.userId,o=t.language,c=t.country,u=t.context,l=t.forceCreateChannel,h=t.knownActiveChannelUrl,d=t.shouldSendFirstMessage,p=t.agentVersion,g=i.call(this)||this;return g.method=n.POST,g.path="".concat(e,"/ai_agents/").concat(encodeURIComponent(a),"/messenger_settings"),g.requireAuth=!1,g.params=r({user_id:s,country:c,language:o,context:u,force_create:l,known_active_channel_url:h,should_send_first_message:d,agent_version:p}),g}return t(a,i),a}(i),z=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.settings=e,r}return t(e,n),e}(a),J=function(i){function a(t){var a=this,s=t.token,o=t.limit,c=t.aiAgentId,u=t.status,l=t.reverse,h=t.order;return(a=i.call(this)||this).method=n.GET,a.path="".concat(e,"/my_conversations"),a.params=r({token:s,limit:o,reverse:l,order:h,status:u,bot_userid:c}),a}return t(a,i),a}(i),W=function(n){function e(t,e){var r=n.call(this,t,e)||this;r.conversations=[];var i=e.next_token,a=e.conversations;return r.token=i,a&&a.length>0&&(r.conversations=a.map((function(t){return new q(t)}))),r}return t(e,n),e}(a),Y={limit:10},Z=function(i){function a(t){var a=this,s=t.limit,o=void 0===s?Y.limit:s,c=t.keys,u=t.token;return(a=i.call(this)||this).method=n.GET,a.path="".concat(e,"/sdk_message_templates"),a.params=r({limit:o,keys:c,token:u}),a}return t(a,i),a}(i),$=function(n){function e(t,e){var r=n.call(this,t,e)||this,i=e.templates,a=e.template_list_token;return r.token=a,r.templates=i.map((function(t){return{template:JSON.stringify(t)}})),r}return t(e,n),e}(a),tt=function(r){function i(t){var i=this,a=t.key;return(i=r.call(this)||this).method=n.GET,i.path="".concat(e,"/sdk_message_templates/").concat(a),i}return t(i,r),i}(i),nt=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.template=JSON.stringify(e),r}return t(e,n),e}(a);!function(t){t.INCLUDE="include",t.EXCLUDE="exclude"}(X||(X={})),function(t){t.INCLUDE="include",t.EXCLUDE="exclude"}(B||(B={}));var et,rt={aiAgentChannelFilter:X.INCLUDE,aiAgentConversationStatusFilter:[R.OPEN,R.CLOSED],aiAgentIds:[],deskChannelFilter:B.INCLUDE,pinnedChannelUrls:[],copilotConversationOnly:!1,copilotSupportChannelUrl:void 0},it=function(e){function i(t){var i=e.call(this)||this,a=u(u({},rt),t),s=a.aiAgentChannelFilter,o=a.aiAgentIds,c=a.deskChannelFilter,l=a.aiAgentConversationStatusFilter,d=a.pinnedChannelUrls,p=a.copilotConversationOnly,g=a.copilotSupportChannelUrl,m=a.userId,f=a.token,v=a.limit;return i.method=n.GET,i.path="".concat(h,"/").concat(encodeURIComponent(m),"/my_group_channels"),i.params=r({token:f,limit:v,ai_agent_channel_filter:s,desk_channel_filter:c,copilot_conversation_only:p,copilot_support_channel_url:g}),l&&l.length>0&&(i.params.ai_agent_conversation_status_filter=l),o&&o.length>0&&(i.params.ai_agent_ids=o),d&&d.length>0&&(i.params.pinned_channel_urls=d),i}return t(i,e),i}(i),at=function(n){function e(t,e){var r=n.call(this,t,e)||this;r.channels=[];var i=e.next,a=e.channels,s=e.ts;return r.token=i,a&&a.length>0&&(r.channels=a.map((function(n){return n.ts=s,new x(t,n)}))),r.ts=null!=s?s:0,r}return t(e,n),e}(a),st={aiAgentChannelFilter:X.INCLUDE,aiAgentIds:[],deskChannelFilter:B.INCLUDE,pinnedChannelUrls:[],copilotConversationOnly:!1,copilotSupportChannelUrl:void 0},ot=function(t){return d(X,t.aiAgentChannelFilter,!0)&&o("string",t.aiAgentIds,!0)&&d(B,t.deskChannelFilter,!0)&&o("string",t.pinnedChannelUrls,!0)&&s("boolean",t.copilotConversationOnly,!0)&&s("string",t.copilotSupportChannelUrl,!0)},ct=function(e){function i(t){var i=t.userId,a=t.ts,s=t.token,o=t.params,c=e.call(this)||this,l=u(u({},st),o),d=l.aiAgentChannelFilter,p=l.aiAgentIds,g=l.deskChannelFilter,m=l.pinnedChannelUrls,f=l.copilotConversationOnly,v=l.copilotSupportChannelUrl;return c.method=n.GET,c.path="".concat(h,"/").concat(encodeURIComponent(i),"/my_group_channels/changelogs"),c.params=r({token:s,change_ts:a,ai_agent_channel_filter:d,desk_channel_filter:g,copilot_conversation_only:f,copilot_support_channel_url:v}),p&&p.length>0&&(c.params.ai_agent_ids=p),m&&m.length>0&&(c.params.pinned_channel_urls=m),c}return t(i,e),i}(i),ut=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.updatedChannels=e.updated.map((function(n){var r=Object.assign(n,{ts:e.ts});return new x(t,r)})),r.deletedChannelUrls=e.deleted,r.hasMore=e.has_more,r.token=e.next,r.ts=e.ts,r}return t(e,n),e}(a),lt={aiAgentChannelFilter:X.INCLUDE,aiAgentConversationStatusFilter:[R.OPEN,R.CLOSED],aiAgentIds:[],deskChannelFilter:B.INCLUDE,pinnedChannelUrls:[],copilotConversationOnly:!1,copilotSupportChannelUrl:void 0},ht=function(e){function i(t){var i=t.userId,a=t.params,s=e.call(this)||this,o=u(u({},lt),a),c=o.aiAgentChannelFilter,l=o.aiAgentConversationStatusFilter,d=o.aiAgentIds,p=o.deskChannelFilter,g=o.pinnedChannelUrls,m=o.copilotConversationOnly,f=o.copilotSupportChannelUrl;return s.method=n.GET,s.path="".concat(h,"/").concat(encodeURIComponent(i),"/my_group_channels/unread_message_count"),s.params=r({ai_agent_channel_filter:c,desk_channel_filter:p,copilot_conversation_only:m,copilot_support_channel_url:f}),l&&l.length>0&&(s.params.ai_agent_conversation_status_filter=l),d&&d.length>0&&(s.params.ai_agent_ids=d),g&&g.length>0&&(s.params.pinned_channel_urls=g),s}return t(i,e),i}(i),dt=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.total=e.total,r.aiAgentChannelCount=e.ai_agent_channel,r.deskChannelCount=e.desk_channel,r.pinnedChannel=e.pinned_channel.map((function(t){return{channelUrl:t.channel_url,count:t.count}})),r}return t(e,n),e}(a),pt=function(e){function i(t){var i=t.channelUrl,a=t.messageId,s=t.key,o=t.data,c=e.call(this)||this;return c.method=n.POST,c.path="".concat(p,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/forms/").concat(encodeURIComponent(s),"/submit"),c.params=r(g({data:o})),c}return t(i,e),i}(i),gt=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.result=null!=e?e:{},r}return t(e,n),e}(a),mt=function(e){function r(t){var r=t.channelUrl,i=t.messageId,a=t.key,s=e.call(this)||this;return s.method=n.POST,s.path="".concat(p,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/forms/").concat(encodeURIComponent(a),"/cancel"),s.params={},s}return t(r,e),r}(i),ft=function(e){function i(t){var i=t.channelUrl,a=t.messageId,s=t.key,o=t.channel,c=t.data,u=e.call(this)||this;return u.method=n.POST,u.path="".concat(p,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/otps/").concat(encodeURIComponent(s),"/request"),u.params=r(g({channel:o,data:c})),u}return t(i,e),i}(i),vt=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.result=null!=e?e:{},r}return t(e,n),e}(a),Ct=function(e){function i(t){var i=t.channelUrl,a=t.messageId,s=t.key,o=t.code,c=e.call(this)||this;return c.method=n.POST,c.path="".concat(p,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/otps/").concat(encodeURIComponent(s),"/verify"),c.params=r(g({code:o})),c}return t(i,e),i}(i),_t=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.result=null!=e?e:{},r}return t(e,n),e}(a),yt=function(e){function r(t){var r=t.channelUrl,i=t.messageId,a=t.key,s=e.call(this)||this;return s.method=n.POST,s.path="".concat(p,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/otps/").concat(encodeURIComponent(a),"/cancel"),s.params={},s}return t(r,e),r}(i),Ut=function(e){function i(t){var i=t.channelUrl,a=t.messageId,s=t.rating,o=t.comment,c=e.call(this)||this;return c.method=n.POST,c.path="".concat(p,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/feedback"),c.params=r(g({rating:s,comment:o})),c}return t(i,e),i}(i),It=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.id=e.id,r.rating=e.rating,r.comment=e.comment,r}return t(e,n),e}(a),bt=function(e){function i(t){var i=t.channelUrl,a=t.messageId,s=t.rating,o=t.comment,c=e.call(this)||this;return c.method=n.PUT,c.path="".concat(p,"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(a),"/feedback"),c.params=r(g({rating:s,comment:o})),c}return t(i,e),i}(i),kt=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r.id=e.id,r.rating=e.rating,r.comment=e.comment,r}return t(e,n),e}(a),At=function(e){function r(t){var r=t.channelUrl,i=t.messageId,a=e.call(this)||this;return a.method=n.DELETE,a.path="".concat(p,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/feedback"),a.params={},a}return t(r,e),r}(i),wt=function(e){function r(t){var r=t.channelUrl,i=t.messageId,a=t.status,s=t.detail,o=e.call(this)||this;return o.method=n.POST,o.path="".concat(p,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/user_action_messages"),o.params={status:a,detail:null!=s?s:""},o}return t(r,e),r}(i),St=function(e){function r(t){var r=t.channelUrl,i=t.messageId,a=e.call(this)||this;return a.method=n.POST,a.path="".concat(p,"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/steward_tasks/cancel"),a.params={},a}return t(r,e),r}(i),Ft={},Et=function(){function t(t,n){var e=n.sdkState,r=n.requestQueue,i=n.logger,a=n.dispatcher,s=this;this._iid=t,this._sdkState=e,this._requestQueue=r,this._logger=i,this._dispatcher=a,this._aiAgentHandlers=new Map,this._dispatcher.on((function(t){t instanceof U&&s._handleEvent(t).catch((function(t){if(I(t)&&"foreground"===s._sdkState.appState)throw t}))})),Ft[t]=this}return t.prototype._handleEvent=function(t){return f(this,void 0,void 0,(function(){var n=this;return b(this,(function(e){return"AIEV"===t.code&&A((function(){return f(n,void 0,void 0,(function(){return b(this,(function(n){return this._aiAgentHandlers.forEach((function(n){n(t.payload)})),[2]}))}))})),[2]}))}))},t.of=function(t){return Ft[t]},Object.defineProperty(t.prototype,"handlers",{get:function(){return v([],_(this._aiAgentHandlers.values()),!1)},enumerable:!1,configurable:!0}),t.prototype.addEventHandler=function(t,n){this._aiAgentHandlers.set(t,n)},t.prototype.removeEventHandler=function(t){this._aiAgentHandlers.delete(t)},t.prototype.clearEventHandler=function(){this._aiAgentHandlers.clear()},t.prototype.requestMessengerSettings=function(t){return f(this,void 0,void 0,(function(){var n,e,r;return b(this,(function(i){switch(i.label){case 0:return n=w.of(this._iid).requestQueue,e=new V(t),[4,n.forceSend(e)];case 1:return r=i.sent(),[2,r.as(z).settings]}}))}))},t.prototype.getConversations=function(t,n,e){return f(this,void 0,void 0,(function(){var r,i,a,s,o,c;return b(this,(function(l){switch(l.label){case 0:return r=w.of(this._iid).requestQueue,i=new J(u(u({},n),{token:t,limit:e})),[4,r.send(i)];case 1:return a=l.sent(),s=a.as(W),o=s.conversations,c=s.token,[2,{conversations:o,token:c}]}}))}))},t.prototype.getMessageTemplates=function(t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n,e,r,i,a,s,o;return b(this,(function(c){switch(c.label){case 0:return n=t.keys,e=t.limit,r=new Z({keys:n,limit:e}),[4,this._requestQueue.send(r)];case 1:return i=c.sent(),a=i.as($),s=a.templates,o=a.token,[2,{templates:s,token:o}]}}))}))},t.prototype.getMessageTemplate=function(t){return f(this,void 0,void 0,(function(){var n,e;return b(this,(function(r){switch(r.label){case 0:return n=new tt({key:t}),[4,this._requestQueue.send(n)];case 1:return e=r.sent(),[2,{template:e.as(nt).template}]}}))}))},t.prototype.getMyGroupChannels=function(t,n,e,r){return void 0===r&&(r=y.REQUEST_CHANNEL),f(this,void 0,void 0,(function(){var i,a,s,o,c,l;return b(this,(function(h){switch(h.label){case 0:return i=new it(u(u({},n),{userId:this._sdkState.userId,token:t,limit:e})),[4,this._requestQueue.send(i)];case 1:return a=h.sent(),s=a.as(at),o=s.channels,c=s.token,l=s.ts,this._dispatcher.dispatch(new L({channels:o,context:{source:r}})),[2,{channels:o,token:c,ts:l}]}}))}))},t.prototype.getMyGroupChannelChangeLogs=function(t,n,e){return void 0===e&&(e=y.REQUEST_CHANNEL_CHANGELOGS),f(this,void 0,void 0,(function(){var r,i,a,s,o,c,u,l,h;return b(this,(function(d){switch(d.label){case 0:return r="string"==typeof t?t:null,i="number"==typeof t?t:null,a=new ct(g({userId:this._sdkState.userId,ts:i,token:r,params:n})),[4,this._requestQueue.send(a)];case 1:return s=d.sent(),o=s.as(ut),c=o.updatedChannels,u=o.deletedChannelUrls,l=o.hasMore,h=o.ts,c.length>0&&this._dispatcher.dispatch(new L({channels:c,context:{source:e},ts:h})),u.length>0&&this._dispatcher.dispatch(new D({channelUrls:u,context:{source:e}})),[2,{updatedChannels:c,deletedChannelUrls:u,hasMore:l,token:o.token}]}}))}))},t.prototype.getUnreadMessageCount=function(t){return f(this,void 0,void 0,(function(){var n,e,r,i,a,s,o;return b(this,(function(c){switch(c.label){case 0:return n=new ht({userId:this._sdkState.userId,params:t}),[4,this._requestQueue.send(n)];case 1:return e=c.sent(),r=e.as(dt),i=r.total,a=r.aiAgentChannelCount,s=r.deskChannelCount,o=r.pinnedChannel,[2,{total:i,aiAgentChannelCount:a,deskChannelCount:s,pinnedChannel:o}]}}))}))},t.prototype.submitForm=function(t){return f(this,void 0,void 0,(function(){var n,e,r;return b(this,(function(i){switch(i.label){case 0:return n=w.of(this._iid).requestQueue,e=new pt({channelUrl:t.channelUrl,messageId:t.messageId,key:t.formKey,data:t.formData}),[4,n.send(e)];case 1:return r=i.sent(),[2,r.as(gt).result]}}))}))},t.prototype.cancelForm=function(t){return f(this,void 0,void 0,(function(){var n,e;return b(this,(function(r){switch(r.label){case 0:return n=w.of(this._iid).requestQueue,e=new mt({channelUrl:t.channelUrl,messageId:t.messageId,key:t.formKey}),[4,n.send(e)];case 1:return r.sent(),[2]}}))}))},t.prototype.requestOTP=function(t){return f(this,void 0,void 0,(function(){var n,e,r;return b(this,(function(i){switch(i.label){case 0:return n=w.of(this._iid).requestQueue,e=new ft({channelUrl:t.channelUrl,messageId:t.messageId,key:t.otpKey,channel:t.otpChannel,data:t.otpData}),[4,n.send(e)];case 1:return r=i.sent(),[2,r.as(vt).result]}}))}))},t.prototype.verifyOTP=function(t){return f(this,void 0,void 0,(function(){var n,e,r;return b(this,(function(i){switch(i.label){case 0:return n=w.of(this._iid).requestQueue,e=new Ct({channelUrl:t.channelUrl,messageId:t.messageId,key:t.otpKey,code:t.code}),[4,n.send(e)];case 1:return r=i.sent(),[2,r.as(_t).result]}}))}))},t.prototype.cancelOTP=function(t){return f(this,void 0,void 0,(function(){var n,e;return b(this,(function(r){switch(r.label){case 0:return n=w.of(this._iid).requestQueue,e=new yt({channelUrl:t.channelUrl,messageId:t.messageId,key:t.otpKey}),[4,n.send(e)];case 1:return r.sent(),[2]}}))}))},t.prototype.createMessageFeedback=function(t){return f(this,void 0,void 0,(function(){var n,e,r,i;return b(this,(function(a){switch(a.label){case 0:return n=w.of(this._iid).requestQueue,e=new Ut({channelUrl:t.channelUrl,messageId:t.messageId,rating:t.rating,comment:t.comment}),[4,n.send(e)];case 1:return r=a.sent(),[2,{id:(i=r.as(It)).id,rating:i.rating,comment:i.comment}]}}))}))},t.prototype.updateMessageFeedback=function(t){return f(this,void 0,void 0,(function(){var n,e,r,i;return b(this,(function(a){switch(a.label){case 0:return n=w.of(this._iid).requestQueue,e=new bt({channelUrl:t.channelUrl,messageId:t.messageId,rating:t.rating,comment:t.comment}),[4,n.send(e)];case 1:return r=a.sent(),[2,{id:(i=r.as(kt)).id,rating:i.rating,comment:i.comment}]}}))}))},t.prototype.deleteMessageFeedback=function(t){return f(this,void 0,void 0,(function(){var n,e;return b(this,(function(r){switch(r.label){case 0:return n=w.of(this._iid).requestQueue,e=new At({channelUrl:t.channelUrl,messageId:t.messageId}),[4,n.send(e)];case 1:return r.sent(),[2]}}))}))},t.prototype.submitUserActionMessage=function(t){return f(this,void 0,void 0,(function(){var n,e;return b(this,(function(r){switch(r.label){case 0:return n=w.of(this._iid).requestQueue,e=new wt({channelUrl:t.channelUrl,messageId:t.messageId,status:t.status,detail:t.detail}),[4,n.send(e)];case 1:return r.sent(),[2]}}))}))},t.prototype.updateContext=function(t,n,e){return f(this,void 0,void 0,(function(){var r,i,a;return b(this,(function(s){switch(s.label){case 0:return r=w.of(this._iid).requestQueue,i=new N({aiAgentId:t,channelUrl:n,context:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Q).contextObject]}}))}))},t.prototype.cancelStewardTask=function(t){return f(this,void 0,void 0,(function(){var n,e;return b(this,(function(r){switch(r.label){case 0:return n=w.of(this._iid).requestQueue,e=new St({channelUrl:t.channelUrl,messageId:t.messageId}),[4,n.send(e)];case 1:return r.sent(),[2]}}))}))},t.prototype.patchContext=function(t,n,e){return f(this,void 0,void 0,(function(){var r,i,a;return b(this,(function(s){switch(s.label){case 0:return r=w.of(this._iid).requestQueue,i=new K({aiAgentId:t,channelUrl:n,context:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(G).contextObject]}}))}))},t}();!function(t){t.CREATED_AT="created_at",t.UPDATED_AT="updated_at"}(et||(et={}));var Tt,Pt={status:void 0,aiAgentId:void 0,reverse:!1,order:et.UPDATED_AT},Ot=function(n){function e(t,e){var r,i,a,s,o=this;return(o=n.call(this,t,e)||this).status=null!==(r=e.status)&&void 0!==r?r:void 0,o.aiAgentId=null!==(i=e.aiAgentId)&&void 0!==i?i:void 0,o.reverse=null!==(a=e.reverse)&&void 0!==a?a:Pt.reverse,o.order=null!==(s=e.order)&&void 0!==s?s:Pt.order,o}return t(e,n),e.prototype._validate=function(){return n.prototype._validate.call(this)&&d(R,this.status,!0)&&s("string",this.aiAgentId,!0)&&s("boolean",this.reverse)&&d(et,this.order)},e.prototype.serialize=function(){return S(this)},e.prototype.next=function(){return f(this,void 0,void 0,(function(){var t,n,e,r;return b(this,(function(i){switch(i.label){case 0:return t=Et.of(this._iid),this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,t.getConversations(this._token,g(u({},this)),this.limit)]):[3,2]:[3,5];case 1:return n=i.sent(),e=n.conversations,r=n.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},e}(F),Mt=function(n){function e(t,e){var r=n.call(this,t,e)||this;return r._ts=0,r.aiAgentChannelFilter=rt.aiAgentChannelFilter,r.aiAgentIds=rt.aiAgentIds,r.deskChannelFilter=rt.deskChannelFilter,r.pinnedChannelUrls=rt.pinnedChannelUrls,r.copilotConversationOnly=rt.copilotConversationOnly,r.copilotSupportChannelUrl=rt.copilotSupportChannelUrl,e.aiAgentChannelFilter&&(r.aiAgentChannelFilter=e.aiAgentChannelFilter),e.aiAgentConversationStatusFilter&&(r.aiAgentConversationStatusFilter=e.aiAgentConversationStatusFilter),e.aiAgentIds&&(r.aiAgentIds=e.aiAgentIds),e.deskChannelFilter&&(r.deskChannelFilter=e.deskChannelFilter),e.pinnedChannelUrls&&(r.pinnedChannelUrls=e.pinnedChannelUrls),e.copilotConversationOnly&&(r.copilotConversationOnly=e.copilotConversationOnly),e.copilotSupportChannelUrl&&(r.copilotSupportChannelUrl=e.copilotSupportChannelUrl),r}return t(e,n),e.prototype._validate=function(){return n.prototype._validate.call(this)&&d(X,this.aiAgentChannelFilter)&&o(R,this.aiAgentConversationStatusFilter,!0)&&o("string",this.aiAgentIds)&&d(B,this.deskChannelFilter)&&o("string",this.pinnedChannelUrls)&&s("boolean",this.copilotConversationOnly,!0)&&s("string",this.copilotSupportChannelUrl,!0)},e.prototype.serialize=function(){return S(this)},Object.defineProperty(e.prototype,"lastResponseAt",{get:function(){return this._ts},enumerable:!1,configurable:!0}),e.prototype.belongsTo=function(t){if(this.pinnedChannelUrls.includes(t.url))return!0;if(t.isAIAgent){if(!t.conversation)return!1;if(this.aiAgentChannelFilter===X.EXCLUDE)return!1;if(this.aiAgentIds&&this.aiAgentIds.length>0&&!this.aiAgentIds.includes(t.conversation.aiAgentId))return!1;if(this.aiAgentConversationStatusFilter&&this.aiAgentConversationStatusFilter.length>0)if(!this.aiAgentConversationStatusFilter.some((function(n){var e;return(null===(e=t.conversation)||void 0===e?void 0:e.status)===n})))return!1;return!0}return!!t.isDesk&&this.deskChannelFilter!==B.EXCLUDE},e.prototype.next=function(){return f(this,void 0,void 0,(function(){var t,n,e,r,i,a;return b(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=Et.of(this._iid),n=g({aiAgentChannelFilter:this.aiAgentChannelFilter,aiAgentConversationStatusFilter:this.aiAgentConversationStatusFilter,aiAgentIds:this.aiAgentIds,deskChannelFilter:this.deskChannelFilter,pinnedChannelUrls:this.pinnedChannelUrls,copilotConversationOnly:this.copilotConversationOnly,copilotSupportChannelUrl:this.copilotSupportChannelUrl}),[4,t.getMyGroupChannels(this._token,n,this.limit)]):[3,2]:[3,5];case 1:return e=s.sent(),r=e.channels,i=e.token,a=e.ts,this._token=i,this._hasNext=!!i,this._isLoading=!1,this._ts=a,[2,r];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},e}(F);!function(t){t.GOOD="good",t.BAD="bad"}(Tt||(Tt={}));var qt=function(n){function e(){var t=null!==n&&n.apply(this,arguments)||this;return t.name="aiAgent",t._runtimeId=M(),t}return t(e,n),e.prototype.init=function(t,e){var r=e.sdkState,i=e.dispatcher,a=e.sessionManager,s=e.requestQueue,o=e.logger,c=e.onlineDetector,u=e.cacheContext;n.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:a,requestQueue:s,logger:o,onlineDetector:c,cacheContext:u}),this._manager=new Et(t,{sdkState:r,requestQueue:s,logger:o,dispatcher:i})},e.prototype.addEventHandler=function(t,n){T(s("string",t)).throw(E.invalidParameters),this._manager.addEventHandler(t,n)},e.prototype.removeEventHandler=function(t){T(s("string",t)).throw(E.invalidParameters),this._manager.removeEventHandler(t)},e.prototype.removeAllEventHandlers=function(){this._manager.clearEventHandler()},e.prototype.updateContext=function(t,n,e){return f(this,void 0,void 0,(function(){return b(this,(function(r){return T(s("string",t)&&s("string",n)&&s("object",e)).throw(E.invalidParameters),[2,this._manager.updateContext(t,n,e)]}))}))},e.prototype.patchContext=function(t,n,e){return f(this,void 0,void 0,(function(){return b(this,(function(r){return T(s("string",t)&&s("string",n)&&s("object",e)).throw(E.invalidParameters),[2,this._manager.patchContext(t,n,e)]}))}))},e.prototype.requestMessengerSettings=function(t){return f(this,void 0,void 0,(function(){var n,e,r,i,a,o,c,u,l;return b(this,(function(h){return n=t.aiAgentId,e=t.userId,r=t.language,i=t.country,a=t.context,o=t.forceCreateChannel,c=t.knownActiveChannelUrl,u=t.shouldSendFirstMessage,l=t.agentVersion,T(s("string",n)&&s("string",e,!0)&&s("string",r,!0)&&s("string",i,!0)&&s("object",a,!0)&&s("boolean",o,!0)&&s("string",c,!0)&&s("boolean",u,!0)&&s("number",l,!0)).throw(E.invalidParameters),[2,this._manager.requestMessengerSettings(t)]}))}))},e.prototype.createConversationListQuery=function(t){return void 0===t&&(t={}),new Ot(this._iid,t)},e.prototype.createMyGroupChannelListQuery=function(t){return void 0===t&&(t={}),new Mt(this._iid,t)},e.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),f(this,void 0,void 0,(function(){var e;return b(this,(function(r){switch(r.label){case 0:return e=u(u({},st),n),T(s("string",t)&&ot(e)).throw(E.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,r.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),f(this,void 0,void 0,(function(){var e;return b(this,(function(r){switch(r.label){case 0:return e=u(u({},st),n),T(s("number",t)&&ot(e)).throw(E.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,r.sent()]}}))}))},e.prototype.getUnreadMessageCount=function(t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n;return b(this,(function(e){return n=u(u({},lt),t),T(d(X,n.aiAgentChannelFilter,!0)&&o(R,n.aiAgentConversationStatusFilter,!0)&&o("string",n.aiAgentIds,!0)&&d(B,n.deskChannelFilter,!0)&&o("string",n.pinnedChannelUrls,!0)&&s("boolean",n.copilotConversationOnly,!0)&&s("string",n.copilotSupportChannelUrl,!0)).throw(E.invalidParameters),[2,this._manager.getUnreadMessageCount(n)]}))}))},e.prototype.getMessageTemplates=function(t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n;return b(this,(function(e){return n=u(u({},Y),t),T(function(t){return s("number",t.limit,!0)&&o("string",t.keys,!0)}(n)).throw(E.invalidParameters),[2,this._manager.getMessageTemplates(t)]}))}))},e.prototype.getMessageTemplate=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t)).throw(E.invalidParameters),[2,this._manager.getMessageTemplate(t)]}))}))},e.prototype.submitForm=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.formKey)&&s("object",t.formData)).throw(E.invalidParameters),[2,this._manager.submitForm(t)]}))}))},e.prototype.cancelForm=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.formKey)).throw(E.invalidParameters),[2,this._manager.cancelForm(t)]}))}))},e.prototype.createMessageFeedback=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)&&d(Tt,t.rating)&&s("string",t.comment,!0)).throw(E.invalidParameters),[2,this._manager.createMessageFeedback(t)]}))}))},e.prototype.updateMessageFeedback=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)&&d(Tt,t.rating)&&s("string",t.comment,!0)).throw(E.invalidParameters),[2,this._manager.updateMessageFeedback(t)]}))}))},e.prototype.requestOTP=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.otpKey)&&s("string",t.otpChannel)&&s("object",t.otpData)).throw(E.invalidParameters),[2,this._manager.requestOTP(t)]}))}))},e.prototype.verifyOTP=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.otpKey)&&s("string",t.code)).throw(E.invalidParameters),[2,this._manager.verifyOTP(t)]}))}))},e.prototype.cancelOTP=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.otpKey)).throw(E.invalidParameters),[2,this._manager.cancelOTP(t)]}))}))},e.prototype.deleteMessageFeedback=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)).throw(E.invalidParameters),[2,this._manager.deleteMessageFeedback(t)]}))}))},e.prototype.submitUserActionMessage=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)&&s("string",t.status)&&s("string",t.detail,!0)).throw(E.invalidParameters),[2,this._manager.submitUserActionMessage(t)]}))}))},e.prototype.cancelStewardTask=function(t){return f(this,void 0,void 0,(function(){return b(this,(function(n){return T(s("string",t.channelUrl)&&s("number",t.messageId)).throw(E.invalidParameters),[2,this._manager.cancelStewardTask(t)]}))}))},e.prototype.appendStat=function(t,n){return t===P.AI_AGENT_SDK_STATS&&w.of(this._iid).statManager.appendStat(t,n,this._runtimeId)},e}(O);export{X as AIAgentChannelFilter,Mt as AIAgentGroupChannelListQuery,Tt as AIAgentMessageFeedbackRating,qt as AIAgentModule,et as ConversationListOrder,Ot as ConversationListQuery,B as DeskChannelFilter};