import{r as t,d as i,h as s,a as e}from"./p-a599f720.js";import{e as a,i as r,F as n}from"./p-9811c98c.js";import{S as h}from"./p-af705ed1.js";var o=function(t,i,s,e){var a,r=arguments.length,n=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,i,s,e);else for(var h=t.length-1;h>=0;h--)(a=t[h])&&(n=(r<3?a(n):r>3?a(i,s,n):a(i,s))||n);return r>3&&n&&Object.defineProperty(i,s,n),n};const l=class{constructor(s){t(this,s),this.stateUpdate=i(this,"rtkStateUpdate",7),this.apiError=i(this,"rtkApiError",7),this.variant="button",this.iconPack=a,this.t=r(),this.livestreamState="IDLE",this.livestreamStateListener=t=>{this.livestreamState=t,"LIVESTREAMING"!==t&&"IDLE"!==t||this.stateUpdate.emit({activeMoreMenu:!1})},this.isLoading=()=>!this.meeting||"STARTING"===this.livestreamState||"STOPPING"===this.livestreamState}connectedCallback(){this.meetingChanged(this.meeting)}disconnectedCallback(){this.clearListeners()}meetingChanged(t){var i,s;t&&(this.livestreamState=null===(i=this.meeting.livestream)||void 0===i?void 0:i.state,null===(s=this.meeting.livestream)||void 0===s||s.on("livestreamUpdate",this.livestreamStateListener))}async toggleLivestream(){var t,i;if("LIVESTREAMING"===this.livestreamState)try{await(null===(t=this.meeting.livestream)||void 0===t?void 0:t.stop())}catch(t){this.apiError.emit({trace:this.t("livestream.stop"),message:this.t("livestream.error.stop")})}else try{await(null===(i=this.meeting.livestream)||void 0===i?void 0:i.start())}catch(t){this.apiError.emit({trace:this.t("livestream.start"),message:this.t("livestream.error.start")})}}clearListeners(){var t;null===(t=this.meeting.livestream)||void 0===t||t.removeListener("livestreamUpdate",this.livestreamStateListener)}getLivestreamLabel(){switch(this.livestreamState){case"IDLE":return this.t("livestream.go_live");case"LIVESTREAMING":return this.t("livestream.end_live");case"WAITING_ON_MANUAL_INGESTION":return this.t("livestream.waiting_on_manual_ingestion");case"STARTING":return this.t("livestream.starting");case"STOPPING":return this.t("livestream.stopping");default:return this.t("livestream.error")}}getLivestreamIcon(){switch(this.livestreamState){case"IDLE":case"WAITING_ON_MANUAL_INGESTION":return this.iconPack.start_livestream;default:return this.iconPack.stop_livestream}}render(){return this.meeting?n(this.meeting)?s(e,null,s("rtk-controlbar-button",{part:"controlbar-button",size:this.size,iconPack:this.iconPack,isLoading:this.isLoading(),class:{"active-livestream":"LIVESTREAMING"===this.livestreamState},onClick:()=>this.toggleLivestream(),icon:this.getLivestreamIcon(),disabled:this.isLoading(),label:this.t(this.getLivestreamLabel()),variant:this.variant})):s(e,{"data-hidden":!0}):null}static get watchers(){return{meeting:["meetingChanged"]}}};o([h()],l.prototype,"meeting",void 0),o([h()],l.prototype,"iconPack",void 0),o([h()],l.prototype,"t",void 0),l.style=":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{display:block}:host([data-hidden]){display:none}";export{l as rtk_livestream_toggle}