Loading
function(e,t,n){n.d(t,{$C:()=>u,BC:()=>g,BG:()=>p,Mz:()=>f,TV:()=>d,qy:()=>a,rS:()=>c});var s=n(73153),r=n(975189),o=n(260498),i=n(664619),l=n(722701);let a={publish_notice(e,t){let{projectId:n}=t;s.h.dispatch({type:"CONJURE_CHAT_PUBLISH_NOTICE",projectId:n,id:e.id,content:e.content,timestamp:e.ts,publishNotice:e.publish_notice})}},c={publish_cta(e,t){let{projectId:n}=t;null!=e.publish_cta&&s.h.dispatch({type:"CONJURE_CHAT_TURN_PATCH",projectId:n,turnId:e.turn_id,patch:{publishCta:{surface:S(e.publish_cta.surface)}}})},publish_status(e,t){let{projectId:n}=t;s.h.dispatch({type:"CONJURE_PROJECT_PUBLISH_STATUS_UPDATE",projectId:n,published:!0===e.published,hasUnpublishedChanges:!0===e.has_unpublished_changes,surface:S(e.surface),previewAppChannels:Array.isArray(e.preview_app_channels)?e.preview_app_channels.filter(e=>"string"==typeof e):[],publishedRevision:"number"==typeof e.published_revision?e.published_revision:null,publishedAt:"string"==typeof e.published_at?e.published_at:null,publishing:!0===e.publishing,patchNotesSent:Array.isArray(e.patch_notes_sent)?e.patch_notes_sent.flatMap(e=>"number"==typeof e?.published_revision&&"string"==typeof e.guild_id&&"string"==typeof e.channel_id&&"string"==typeof e.message_id?[{publishedRevision:e.published_revision,guildId:e.guild_id,channelId:e.channel_id,messageId:e.message_id}]:[]):void 0})},publish_result(e,t){let{projectId:n}=t,r=h.get(n);if(h.delete(n),null!=r&&(clearTimeout(r.timeout),r.resolve(e)),!0!==e.ok)(0,i.Is)(n,e.error??"publish_result not ok",!1);else{let e=l.A.getPublishStatus(n);null!=e&&s.h.dispatch({type:"CONJURE_PROJECT_PUBLISH_STATUS_UPDATE",projectId:n,published:!0,hasUnpublishedChanges:!1,surface:e.surface,previewAppChannels:e.previewAppChannels,publishedRevision:e.publishedRevision,publishedAt:e.publishedAt})}},patch_notes_draft(e,t){let{projectId:n}=t,s=_.get(n);null!=s&&s.nonce===e.nonce&&(_.delete(n),clearTimeout(s.timeout),s.resolve(e))}};function d(e){let t=!1;return new Promise((n,o)=>{let i=(0,r.KY)(e);if(null==i)return void o(Error("Not connected"));if(h.has(e))return void o(Error("Publish already in flight"));let l=setTimeout(()=>{f(e,"Publish timed out")},9e5);h.set(e,{resolve:n,reject:o,timeout:l}),t=!0,s.h.dispatch({type:"CONJURE_PROJECT_PUBLISH_START",projectId:e});try{i.sendPublish()}catch(t){h.delete(e),clearTimeout(l),o(t instanceof Error?t:Error("publish send failed"))}}).catch(t=>{throw(0,i.Is)(e,t instanceof Error?t.message:"publish failed",!1),t}).finally(()=>{t&&s.h.dispatch({type:"CONJURE_PROJECT_PUBLISH_SETTLE",projectId:e})})}function u(e){return new Promise((t,n)=>{let s=(0,r.KY)(e);if(null==s)return void n(Error("Not connected"));g(e,"Superseded by a newer draft request");let i=`${Date.now()}-${Math.random().toString(36).slice(2)}`,l=setTimeout(()=>{g(e,"Draft timed out")},45e3);_.set(e,{resolve:t,reject:n,timeout:l,nonce:i});try{s.sendDraftPatchNotes(i,o.Ay.getProject(e)?.name)}catch(t){_.delete(e),clearTimeout(l),n(t instanceof Error?t:Error("draft send failed"))}})}function p(e,t,n){s.h.dispatch({type:"CONJURE_PROJECT_PATCH_NOTES_SENT",projectId:e,sent:t});try{let s=(0,r.KY)(e);if(null==s)throw Error("Not connected");s.sendPatchNotesSent(t,n)}catch(t){console.warn("[vibegrations] could not record sent patch notes",e,t)}}let h=new Map;function f(e,t){let n=h.get(e);null!=n&&(h.delete(e),clearTimeout(n.timeout),n.reject(Error(t)))}let _=new Map;function g(e,t){let n=_.get(e);null!=n&&(_.delete(e),clearTimeout(n.timeout),n.reject(Error(t)))}let E=new Set(["activity","automod","widget","bot"]);function S(e){return null!=e&&E.has(e)?e:null}}