import{r as t,d as i,h as r,a as s}from"./p-a599f720.js";import{i as e,e as n}from"./p-9811c98c.js";import{S as a}from"./p-af705ed1.js";var o=function(t,i,r,s){var e,n=arguments.length,a=n<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,i,r,s);else for(var o=t.length-1;o>=0;o--)(e=t[o])&&(a=(n<3?e(a):n>3?e(i,r,a):e(i,r))||a);return n>3&&a&&Object.defineProperty(i,r,a),a};const c=class{constructor(r){t(this,r),this.apiError=i(this,"rtkApiError",7),this.variant="button",this.t=e(),this.iconPack=n,this.disabled=!1,this.canRecord=!1,this.permissionsUpdateListener=()=>{this.canRecord=!0===this.meeting.self.permissions.canRecord},this.toggleRecording=async()=>{var t,i,r;if(!this.isLoading()&&!this.disabled)switch(this.recordingState){case"IDLE":try{return void await(null===(t=this.meeting)||void 0===t?void 0:t.recording.start())}catch(t){this.apiError.emit({trace:this.t("recording.start"),message:this.t("recording.error.start")})}return;case"RECORDING":try{return void await(null===(i=this.meeting)||void 0===i?void 0:i.recording.stop())}catch(t){this.apiError.emit({trace:this.t("recording.stop"),message:this.t("recording.error.stop")})}return;case"PAUSED":try{return void await(null===(r=this.meeting)||void 0===r?void 0:r.recording.resume())}catch(t){this.apiError.emit({trace:this.t("recording.resume"),message:this.t("recording.error.resume")})}return;default:return}},this.isLoading=()=>!this.meeting||"STARTING"===this.recordingState||"STOPPING"===this.recordingState}connectedCallback(){this.meetingChanged(this.meeting)}disconnectedCallback(){var t,i;this.recordingStateUpdateListener&&(null===(t=this.meeting)||void 0===t||t.recording.removeListener("recordingUpdate",this.recordingStateUpdateListener)),null===(i=this.meeting)||void 0===i||i.self.permissions.removeListener("permissionsUpdate",this.permissionsUpdateListener)}meetingChanged(t){null!=t&&(this.recordingState=t.recording.recordingState,this.permissionsUpdateListener(),this.recordingStateUpdateListener=t=>{this.recordingState=t},t.recording.addListener("recordingUpdate",this.recordingStateUpdateListener),t.self.permissions.addListener("permissionsUpdate",this.permissionsUpdateListener))}getLabel(){switch(this.recordingState){case"IDLE":return"recording.idle";case"RECORDING":return"recording.stop";case"STARTING":return"recording.starting";case"STOPPING":return"recording.stopping";case"PAUSED":return"recording.resume";default:return"recording.loading"}}getIcon(){switch(this.recordingState){case"IDLE":case"STARTING":case"STOPPING":default:return this.iconPack.recording;case"RECORDING":return this.iconPack.stop_recording}}render(){return this.meeting?this.canRecord?r(s,{title:this.t("RECORDING"===this.recordingState?"recording.stop":"recording.idle")},r("rtk-controlbar-button",{part:"controlbar-button",size:this.size,iconPack:this.iconPack,onClick:this.toggleRecording,icon:this.getIcon(),isLoading:this.isLoading(),label:this.t(this.getLabel()),variant:this.variant,disabled:this.disabled})):void 0:null}static get watchers(){return{meeting:["meetingChanged"]}}};o([a()],c.prototype,"meeting",void 0),o([a()],c.prototype,"t",void 0),o([a()],c.prototype,"iconPack",void 0),c.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}";export{c as rtk_recording_toggle}