From 14b1a062ce8c002b3449ea99a778a42ecf83e2aa Mon Sep 17 00:00:00 2001 From: thedist Date: Tue, 27 Aug 2024 10:47:03 +0000 Subject: [PATCH] update tellyo-streamstudio to v2.0.1 --- tellyo-streamstudio/.build-info | 6 +++--- tellyo-streamstudio/companion/manifest.json | 2 +- tellyo-streamstudio/main.js | 2 +- tellyo-streamstudio/package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tellyo-streamstudio/.build-info b/tellyo-streamstudio/.build-info index 6ef07ccc..a2d6b820 100644 --- a/tellyo-streamstudio/.build-info +++ b/tellyo-streamstudio/.build-info @@ -1,4 +1,4 @@ MODULE_NAME=tellyo-streamstudio -GIT_REF=v1.1.4 -RUN_URL=https://github.com/bitfocus/companion-bundled-modules/actions/runs/8986768505 -UPDATE_DATE=2024-05-07 +GIT_REF=v2.0.1 +RUN_URL=https://github.com/bitfocus/companion-bundled-modules/actions/runs/10576615679 +UPDATE_DATE=2024-08-27 diff --git a/tellyo-streamstudio/companion/manifest.json b/tellyo-streamstudio/companion/manifest.json index 8c739865..16e9a971 100644 --- a/tellyo-streamstudio/companion/manifest.json +++ b/tellyo-streamstudio/companion/manifest.json @@ -1 +1 @@ -{"id":"companion-module-tellyo-streamstudio","name":"tellyo-streamstudio","shortname":"streamstudio","description":"Module to control Tellyo Stream Studio instances through Studio Controller","version":"1.1.4","license":"MIT","repository":"git+https://gitlab.tellyo.com/tellyo/companion-module-tellyo-streamstudio.git","bugs":"https://github.com/bitfocus/companion-module-companion-module-tellyo-streamstudio/issues","maintainers":[{"name":"Paweł Jaśpiński","email":"pawel.jaspinski@tellyo.com","url":"https://tellyo.com/"}],"legacyIds":[],"runtime":{"type":"node18","api":"nodejs-ipc","apiVersion":"1.8.0","entrypoint":"../main.js"},"manufacturer":"Tellyo","products":["Stream Studio"],"keywords":["Software","Vision Mixer","Cloud"]} \ No newline at end of file +{"id":"tellyo-streamstudio","name":"tellyo-streamstudio","shortname":"streamstudio","description":"Module to control Tellyo Stream Studio instances through Studio Controller","version":"2.0.1","license":"MIT","repository":"git+https://gitlab.tellyo.com/tellyo/companion-module-tellyo-streamstudio.git","bugs":"https://github.com/bitfocus/companion-module-companion-module-tellyo-streamstudio/issues","maintainers":[{"name":"Paweł Jaśpiński","email":"pawel.jaspinski@tellyo.com","url":"https://tellyo.com/"}],"legacyIds":[],"runtime":{"type":"node18","api":"nodejs-ipc","apiVersion":"1.10.0","entrypoint":"../main.js"},"manufacturer":"Tellyo","products":["Stream Studio"],"keywords":["Software","Vision Mixer","Cloud"]} \ No newline at end of file diff --git a/tellyo-streamstudio/main.js b/tellyo-streamstudio/main.js index f1e0caf4..2803f583 100644 --- a/tellyo-streamstudio/main.js +++ b/tellyo-streamstudio/main.js @@ -1 +1 @@ -(()=>{var e={2351:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertParamOptionsToChoices=t.getParameterTopic=void 0;const s=n(412),i=n(6787),o=n(6230),r=n(3105),a=[s.CommandParameterType.BOOLEAN,s.CommandParameterType.STRING,s.CommandParameterType.CONST,s.CommandParameterType.NUMBER,s.CommandParameterType.SELECT],c=["SetDirectEditScene/active","SetDirectEditLayer/active","SetProgramMuted/muted","audiomixer.output.muted/muted"];t.getParameterTopic=(e,t)=>`${e}/${t}`;const g="default_option",l={id:g,label:"Select an option..."};t.convertParamOptionsToChoices=e=>0===e.length?[l]:"string"==typeof e[0]?[l,...e.map((e=>{const t=e;return{id:t,label:(0,i.transformToTitleCase)(t)}}))]:[l,...e.map((e=>{const t=e;return{id:void 0===t.id?"undefined":t.id,label:t.value}}))];const d=(e,n)=>(r,a)=>{const l=(0,i.generateMessageId)(),d={"request-type":e.type,"message-id":l},I={messageId:l,parametersConfirmations:[]};let u=!1;e.parameters.forEach((a=>{if(a.type===s.CommandParameterType.BOOLEAN){if(a.property!==s.CommandParameterProperty.CONTROLLABLE)return;const i=(0,t.getParameterTopic)(e.id,a.id);if(c.includes(i)){const e=!(0,o.getBooleanState)(i,r.options,n.projectState);return d[a.id]=e,void I.parametersConfirmations.push({topic:i,newValue:e})}}let l=r.options[a.id];if(void 0===l){if(a.type!==s.CommandParameterType.CONST||a.property!==s.CommandParameterProperty.REQUIRED)return;a.value&&(l=a.value)}l!==g?((0,i.setValueAtPath)(d,l,a.id),I.parametersConfirmations.push({topic:(0,t.getParameterTopic)(e.id,a.id),newValue:l})):a.property===s.CommandParameterProperty.REQUIRED&&(u=!0)})),u&&n.log("error",`Executing ${e.id} ${e.description} command aborted because not all required parameters are set.`),n.sendByWs(d),n.addAwaitedConfirmation(I)};t.default=(e,n)=>{const o={};return e.forEach((e=>{e.templates.forEach((l=>{const I=(0,i.transformToTitleCase)(e.name),u=[];l.parameters.forEach((e=>{e.type!==s.CommandParameterType.CONST&&(e.property===s.CommandParameterProperty.CONTROLLABLE&&e.type===s.CommandParameterType.BOOLEAN&&c.includes((0,t.getParameterTopic)(l.id,e.id))||u.push(((e,n,o)=>{var r,a;switch((0,i.commandParameterTypeToInputType)(e.type)){case"number":{const t=e.range?`${e.description} (min ${e.range.min}, max ${e.range.max})`:e.description;return{type:"number",id:e.id,label:t,default:"number"==typeof e.value?e.value:0,min:(null===(r=e.range)||void 0===r?void 0:r.min)||0,max:(null===(a=e.range)||void 0===a?void 0:a.max)||0}}case"textinput":return{type:"textinput",id:e.id,label:e.description,default:"string"==typeof e.value?e.value:void 0};case"checkbox":return{type:"checkbox",id:e.id,label:e.description,default:"boolean"==typeof e.value&&e.value};case"dropdown":{const i=((e,n,i)=>{if(e.type===s.CommandParameterType.SELECT&&e.options)return(0,t.convertParamOptionsToChoices)(e.options);const o=(0,t.getParameterTopic)(n,e.id);return void 0!==i[o]?(0,t.convertParamOptionsToChoices)(i[o]):[{id:0,label:"No options available."}]})(e,n.id,o.options);return{type:"dropdown",id:e.id,label:`${e.description}${e.property===s.CommandParameterProperty.REQUIRED?" (required)":""}`,choices:i,default:g}}}})(e,l,n)))}));const p={name:`${I}: ${l.description}`,options:u,callback:d(l,n),subscribe:e=>{l.parameters.forEach((t=>{if(!a.includes(t.type))switch(n.getOptions(l.id,t.id),l.id){case"SetProgramMuted":n.addAwaitedRequest(r.RequestType.AUDIOMIXER_OUTPUT_MUTED,{output:"Master"});break;case"audiomixer.output.muted":n.addAwaitedRequest(r.RequestType.AUDIOMIXER_OUTPUT_MUTED,{output:e.options.output});break;case"SetDirectEditScene":case"SetDirectEditLayer":n.addAwaitedRequest(r.RequestType.GET_DIRECT_EDIT)}}))}};o[l.id]=p}))})),o}},1610:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getConfigFields=void 0;const s=n(8049);t.getConfigFields=()=>[{type:"static-text",id:"info",width:12,label:"Studio Controller",value:"This module connects to the Studio Controller app. Launch it and connect to the producer in order to control it using your Stream Deck."},{type:"textinput",id:"ip",label:"Studio Controller IP address",width:8,default:"127.0.0.1",regex:s.Regex.IP},{type:"number",id:"port",label:"Studio Controller port",width:4,default:5656,min:1,max:65535,step:1}]},2631:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.processConfirmation=void 0;const s=n(1658),i=n(6230),o=n(6787);t.processConfirmation=(e,t)=>{const n=t.getAwaitedConfirmation(e["message-id"]);n&&n.parametersConfirmations.forEach((n=>{switch(n.topic){case"audiomixer.output.muted/muted":case"SetProgramMuted/muted":{const i=(0,o.getValueAtPath)(e,"name"),r=t.projectState.audioOutputs[i];if(void 0===r)break;r.muted=n.newValue,t.checkFeedbacks(s.Feedback.AUDIO_OUTPUT_MUTED);break}default:{const e=i.parametersTopicToProjectStateFieldMap[n.topic];if(void 0===e)return;(0,o.setValueAtPath)(t.projectState,n.newValue,e);const s=i.parametersTopicToFeedbackNamesMap[n.topic];t.checkFeedbacks(...s);break}}}))}},1658:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Feedback=t.Color=void 0;const s=n(8049),i=n(2351),o=n(3105),r="default_option";var a,c;!function(e){e[e.WHITE=(0,s.combineRgb)(255,255,255)]="WHITE",e[e.BLACK=(0,s.combineRgb)(0,0,0)]="BLACK",e[e.GREEN=(0,s.combineRgb)(0,255,0)]="GREEN",e[e.RED=(0,s.combineRgb)(255,0,0)]="RED",e[e.PURPLE=(0,s.combineRgb)(204,0,204)]="PURPLE"}(a||(t.Color=a={})),function(e){e.MONITORED_AUDIO="PlayAudio/channel",e.DIRECT_EDIT_SCENE="SetDirectEditScene/active",e.DIRECT_EDIT_LAYER="SetDirectEditLayer/active",e.PROGRAM_SCENE_INDEX="ProgramSceneIndex/active",e.PREVIEW_SCENE_INDEX="PreviewSceneIndex/active",e.PROGRAM_SCENE_NAME="ProgramSceneName/active",e.PREVIEW_SCENE_NAME="PreviewSceneName/active",e.REPLAYS_PLAYBACK_SPEED_PREDEFINED="ReplaysPlaybackSpeedPredefined",e.REPLAYS_PLAYBACK_SPEED="ReplaysPlaybackSpeed",e.REPLAYS_SELECTED_SLOT="ReplaysSelectedSlot",e.AUDIO_OUTPUT_MUTED="AudioOutputMuted"}(c||(t.Feedback=c={}));const g=(e,t,n)=>{const s=(0,i.getParameterTopic)(t,e);return void 0!==n[s]?(0,i.convertParamOptionsToChoices)(n[s]):[{id:0,label:"No options available."}]};t.default=e=>{const t={};return t[c.MONITORED_AUDIO]={type:"boolean",name:"Video Mixer: Monitored audio (PREVIEW or PROGRAM)",defaultStyle:{bgcolor:a.RED,color:a.BLACK},options:[{type:"dropdown",label:"Monitored audio",choices:[{id:"preview",label:"Preview"},{id:"program",label:"Program"}],id:"source",default:"preview"}],callback:t=>t.options.source===e.projectState.monitoredAudio,subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_AUDIO_MIXER_STATE),e.addListenedUpdate({feedbackId:t.id,updateType:"PlayAudio"})},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.DIRECT_EDIT_SCENE]={type:"boolean",name:"Video Mixer: Direct Edit - Scenes (active)",defaultStyle:{bgcolor:a.RED,color:a.BLACK},options:[],callback:t=>e.projectState.directEditScene,subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_DIRECT_EDIT),e.addListenedUpdate({feedbackId:t.id,updateType:"SetDirectEditScene"})},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.DIRECT_EDIT_LAYER]={type:"boolean",name:"Video Mixer: Direct Edit - Layers (active)",defaultStyle:{bgcolor:a.RED,color:a.BLACK},options:[],callback:t=>e.projectState.directEditLayer,subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_DIRECT_EDIT),e.addListenedUpdate({feedbackId:t.id,updateType:"SetDirectEditLayer"})},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.PROGRAM_SCENE_INDEX]={type:"boolean",name:"Video Mixer: Program Scene by index (active)",defaultStyle:{bgcolor:a.RED,color:a.BLACK},options:[{type:"dropdown",id:"scene-index",label:"Scene index",choices:g("sceneIndex","SetCurrentSceneByIndex",e.options),default:r}],callback:t=>e.projectState.currentProgramSceneIndex===t.options["scene-index"],subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_LATEST_PROJECT),e.addListenedUpdate({feedbackId:t.id,updateType:"ProgramSceneChanged"}),e.getOptions("SetCurrentSceneByIndex","sceneIndex")},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.PREVIEW_SCENE_INDEX]={type:"boolean",name:"Video Mixer: Preview Scene by index (active)",defaultStyle:{bgcolor:a.GREEN,color:a.BLACK},options:[{type:"dropdown",id:"scene-index",label:"Scene index",choices:g("sceneIndex","SetPreviewSceneByIndex",e.options),default:r}],callback:t=>e.projectState.currentPreviewSceneIndex===t.options["scene-index"],subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_LATEST_PROJECT),e.addListenedUpdate({feedbackId:t.id,updateType:"PreviewSceneChanged"}),e.getOptions("SetPreviewSceneByIndex","sceneIndex")},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.PROGRAM_SCENE_NAME]={type:"boolean",name:"Video Mixer: Program Scene by name (active)",defaultStyle:{bgcolor:a.RED,color:a.BLACK},options:[{type:"dropdown",id:"scene-name",label:"Scene name",choices:g("scene-name","SetCurrentSceneByName",e.options),default:r}],callback:t=>e.projectState.currentProgramSceneName===t.options["scene-name"],subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_LATEST_PROJECT),e.addListenedUpdate({feedbackId:t.id,updateType:"ProgramSceneChanged"}),e.getOptions("SetCurrentSceneByName","scene-name")},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.PREVIEW_SCENE_NAME]={type:"boolean",name:"Video Mixer: Preview Scene by name (active)",defaultStyle:{bgcolor:a.GREEN,color:a.BLACK},options:[{type:"dropdown",id:"scene-name",label:"Scene name",choices:g("scene-name","SetPreviewScene",e.options),default:r}],callback:t=>e.projectState.currentPreviewSceneName===t.options["scene-name"],subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_LATEST_PROJECT),e.addListenedUpdate({feedbackId:t.id,updateType:"PreviewSceneChanged"}),e.getOptions("SetPreviewScene","scene-name")},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.REPLAYS_PLAYBACK_SPEED_PREDEFINED]={type:"boolean",name:"Replays: Playback speed (predefined, all slots)",defaultStyle:{bgcolor:a.PURPLE,color:a.BLACK},options:[{type:"dropdown",id:"speed",label:"Speed [%]",choices:[{id:25,label:"25%"},{id:33,label:"33%"},{id:50,label:"50%"},{id:75,label:"75%"},{id:100,label:"100%"}],default:100}],callback:t=>e.projectState.replaysPlaybackSpeed===t.options.speed,subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_LATEST_PROJECT),e.addListenedUpdate({feedbackId:t.id,updateType:"replays.slot.playback.speed"})},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.REPLAYS_PLAYBACK_SPEED]={type:"boolean",name:"Replays: Playback speed (all slots)",defaultStyle:{bgcolor:a.PURPLE,color:a.BLACK},options:[{type:"number",id:"speed",label:"Speed [%] (min 1, max 200)",default:100,min:1,max:200}],callback:t=>e.projectState.replaysPlaybackSpeed===t.options.speed,subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_LATEST_PROJECT),e.addListenedUpdate({feedbackId:t.id,updateType:"replays.slot.playback.speed"})},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.REPLAYS_SELECTED_SLOT]={type:"boolean",name:"Replays: Selected slot",defaultStyle:{bgcolor:a.PURPLE,color:a.BLACK},options:[{type:"dropdown",id:"slot",label:"Slot index",choices:g("slot","replays.slot.select",e.options),default:r}],callback:t=>e.projectState.replaysSelectedSlot===t.options.slot,subscribe:t=>{e.addAwaitedRequest(o.RequestType.GET_LATEST_PROJECT),e.addListenedUpdate({feedbackId:t.id,updateType:"replays.slot.select"}),e.getOptions("replays.slot.select","slot")},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t[c.AUDIO_OUTPUT_MUTED]={type:"boolean",name:"Audio Mixer Outputs: Output mute state",defaultStyle:{bgcolor:a.RED,color:a.BLACK},options:[{type:"dropdown",id:"output",label:"Output",choices:g("output","audiomixer.output.muted",e.options),default:r}],callback:t=>{const n=t.options.output,s=e.projectState.audioOutputs[n];return void 0!==s&&s.muted},subscribe:t=>{e.addAwaitedRequest(o.RequestType.AUDIOMIXER_OUTPUT_MUTED,{output:t.options.output}),e.addListenedUpdate({feedbackId:t.id,updateType:"audiomixer.output.muted"}),e.getOptions("audiomixer.output.muted","output")},unsubscribe:t=>{e.removeListenedUpdate(t.id)}},t}},5590:function(e,t,n){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,i)}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&s(t,e,n);return i(t,e),t},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const a=n(8049),c=n(1610),g=o(n(1970)),l=n(8780),d=o(n(2351)),I=r(n(1658)),u=n(6787),p=n(6230),h=n(6923),b=n(6178),C=n(2631),m=n(9671);class Z extends a.InstanceBase{constructor(e){super(e),this.ws=new g.default(this,!0),this.options={},this.commandsTemplates=[],this.activeOptionsCalls=0,this.projectState=p.initProjectState,this.listenedUpdates=[],this.awaitedConfirmations=[],this.awaitedRequests=[],this.config={ip:"",port:0},this.reconnectTimer=null,this.connectToWsServer=()=>{const{ip:e,port:t}=this.config;this.log("debug",`Connecting to ${e} at port ${t}.`),this.ws.connect(e,t)},this.startReconnecting=()=>{this.updateStatus(a.InstanceStatus.Disconnected,"Trying to reconnect"),this.reconnectTimer=setTimeout((()=>{this.log("debug","Reconnecting..."),this.connectToWsServer(),this.reconnectTimer=null}),1e3)},this.stopReconnecting=()=>{null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)},this.addListenedUpdate=e=>{this.listenedUpdates.push(e)},this.removeListenedUpdate=e=>{this.listenedUpdates=this.listenedUpdates.filter((t=>t.feedbackId!==e))},this.addAwaitedConfirmation=e=>{this.awaitedConfirmations.push(e)},this.getAwaitedConfirmation=e=>this.awaitedConfirmations.find((t=>t.messageId===e)),this.removeAwaitedConfrimation=e=>{this.awaitedConfirmations=this.awaitedConfirmations.filter((t=>t.messageId!==e))},this.addAwaitedRequest=(e,t)=>{if(this.awaitedRequests.find((t=>t.requestType===e))&&void 0===t)return;const n=(0,u.generateMessageId)();this.awaitedRequests.push({messageId:n,requestType:e}),this.sendRequest(e,n,t)},this.removeAwaitedRequest=e=>{this.awaitedRequests=this.awaitedRequests.filter((t=>t.messageId!==e))},this.getCommandsTemplates=()=>{this.ws.send({"request-type":"GetCommandsTemplates","message-id":l.WebSocketMessageId.GET_COMMANDS_TEMPLATES_MSG_ID})},this.getOptions=(e,t)=>{this.ws.send({"request-type":"GetOptions","message-id":l.WebSocketMessageId.GET_PARAM_OPTIONS_MSG_ID,commandId:e,paramId:t}),this.activeOptionsCalls++},this.sendByWs=e=>{this.ws.send(e)},this.sendRequest=(e,t,n)=>{this.ws.send({"request-type":e,"message-id":t,...n})},this.cancelUnnecessaryNotifications=()=>{[].forEach((e=>{this.ws.send({"request-type":"TurnNotificationOff","message-id":(0,u.generateMessageId)(),notyficationType:e})}),this)},this.updateActions=()=>{this.setActionDefinitions((0,d.default)(this.commandsTemplates,this))},this.updateFeedbacks=()=>{this.setFeedbackDefinitions((0,I.default)(this))}}async init(e){this.config=e,this.ws.addListener(g.WebSocketEventType.STATUS_CHANGED,(e=>{switch(this.log("debug",`WebSocket status changed to ${e}`),e){case g.WebSocketStatus.OPEN:this.updateStatus(a.InstanceStatus.Ok),this.getCommandsTemplates();break;case g.WebSocketStatus.CONNECTING:this.updateStatus(a.InstanceStatus.Connecting);break;case g.WebSocketStatus.CLOSED:this.startReconnecting();break;case g.WebSocketStatus.CLOSING:this.updateStatus(a.InstanceStatus.Disconnected);break;case g.WebSocketStatus.ERROR:this.updateStatus(a.InstanceStatus.ConnectionFailure)}})),this.ws.addListener(g.WebSocketEventType.MESSAGE,(e=>{switch(e["message-id"]){case l.WebSocketMessageId.GET_COMMANDS_TEMPLATES_MSG_ID:{const t=e;this.log("debug",`Got ${t.templatesGroups.length} command groups.`),this.commandsTemplates=t.templatesGroups,this.updateActions(),this.updateFeedbacks();break}case l.WebSocketMessageId.GET_PARAM_OPTIONS_MSG_ID:{const t=e;this.activeOptionsCalls--;const n=(0,d.getParameterTopic)(t.command,t.parameter);this.options[n]=t.options,this.log("debug",`Got options for ${n}`),0===this.activeOptionsCalls&&(this.log("debug","All options calls finished, updating actions."),this.updateActions(),this.updateFeedbacks());break}case void 0:{const t=e,n=t["update-type"];if(void 0===n)return;if(n===l.WebSocketUpdateTypes.GATEWAY_CONNECTION){const t=e;if(t.connected)return this.cancelUnnecessaryNotifications(),this.subscribeActions(),this.subscribeFeedbacks(),void this.setPresetDefinitions((0,m.generatePresets)());t.connected||this.updateStatus(a.InstanceStatus.ConnectionFailure,"Connection to producer lost.")}Array.from(new Set(this.listenedUpdates.map((e=>e.updateType)))).includes(n)&&(0,b.processUpdate)(t,this);break}default:{const t=e["message-id"],n=this.awaitedRequests.find((e=>e.messageId===t));if(n){const s=e;(0,h.processRequest)(s,n.requestType,this),this.removeAwaitedRequest(t)}if(this.awaitedConfirmations.some((e=>e.messageId===t))){const n=e;(0,C.processConfirmation)(n,this),this.removeAwaitedConfrimation(t)}}}})),this.connectToWsServer()}async configUpdated(e){this.config=e,this.ws.disconnect(),this.stopReconnecting(),e.ip&&e.port?this.connectToWsServer():this.updateStatus(a.InstanceStatus.BadConfig,"Missing Studio Controller IP and/or port.")}getConfigFields(){return(0,c.getConfigFields)()}async destroy(){this.stopReconnecting(),this.ws.disconnect(),this.commandsTemplates=[],this.options={},this.activeOptionsCalls=0,this.listenedUpdates=[],this.awaitedConfirmations=[],this.awaitedRequests=[]}}(0,a.runEntrypoint)(Z,[]),e.exports=Z},9671:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generatePresets=void 0;const s=n(1658);var i;!function(e){e.VIDEO_MIXER="Video Mixer",e.REPLAYS="Replays"}(i||(i={})),t.generatePresets=()=>{const e={};return Array.from(Array(8)).forEach(((t,n)=>{const o=n+1;e[`PreviewScene${o}`]={type:"button",category:i.VIDEO_MIXER,name:`Preview Scene ${o}`,style:{text:`PRV ${o}`,size:"auto",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"SetPreviewSceneByIndex",options:{sceneIndex:n}}],up:[]}],feedbacks:[{feedbackId:s.Feedback.PREVIEW_SCENE_INDEX,options:{"scene-index":n},style:{color:s.Color.BLACK,bgcolor:s.Color.GREEN}}]}})),Array.from(Array(8)).forEach(((t,n)=>{const o=n+1;e[`ProgramScene${o}`]={type:"button",category:i.VIDEO_MIXER,name:`Program Scene ${o}`,style:{text:`PGM ${o}`,size:"auto",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"SetCurrentSceneByIndex",options:{sceneIndex:n}}],up:[]}],feedbacks:[{feedbackId:s.Feedback.PROGRAM_SCENE_INDEX,options:{"scene-index":n},style:{color:s.Color.BLACK,bgcolor:s.Color.RED}}]}})),e.Cut={type:"button",category:i.VIDEO_MIXER,name:"Cut",style:{text:"Cut",size:"24",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"Cut",options:{}}],up:[]}],feedbacks:[]},e.Fade={type:"button",category:i.VIDEO_MIXER,name:"Fade",style:{text:"Fade",size:"24",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"TransitionToProgramCustom",options:{"with-transition.duration":500,"with-transition.name":"Fade"}}],up:[]}],feedbacks:[]},Array.from(Array(4)).forEach(((t,n)=>{const o=n+1;e[`SelectReplaysSlot${o}`]={type:"button",category:i.REPLAYS,name:`Replays Slot ${o}`,style:{text:`REPLAY ${o}`,size:"auto",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"replays.slot.select",options:{slot:n}}],up:[]}],feedbacks:[{feedbackId:s.Feedback.REPLAYS_SELECTED_SLOT,options:{slot:n},style:{color:s.Color.BLACK,bgcolor:s.Color.PURPLE}}]}})),[25,33,50,75,100].forEach((t=>{e[`ReplaysPlaybackSpeed${t}`]={type:"button",category:i.REPLAYS,name:`Replays Playback Speed ${t}%`,style:{text:`${t}%`,size:"auto",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"replays.slot.playback.speed",options:{speed_percent:t,slot:"all"}}],up:[]}],feedbacks:[{feedbackId:s.Feedback.REPLAYS_PLAYBACK_SPEED,options:{speed:t,slot:"all"},style:{color:s.Color.BLACK,bgcolor:s.Color.PURPLE}}]}})),e}},6230:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBooleanState=t.parametersTopicToFeedbackNamesMap=t.parametersTopicToProjectStateFieldMap=t.initProjectState=void 0;const s=n(1658),i=n(6787);t.initProjectState={monitoredAudio:"preview",directEditScene:!1,directEditLayer:!1,currentProgramSceneIndex:0,currentPreviewSceneIndex:0,currentPreviewSceneName:"",currentProgramSceneName:"",sceneNames:[],replaysPlaybackSpeed:100,replaysSelectedSlot:"all",audioOutputs:{}},t.parametersTopicToProjectStateFieldMap={"PlayAudio/channel":"monitoredAudio","SetDirectEditScene/active":"directEditScene","SetDirectEditLayer/active":"directEditLayer","SetCurrentSceneByIndex/sceneIndex":"currentProgramSceneIndex","SetPreviewSceneByIndex/sceneIndex":"currentPreviewSceneIndex","replays.slot.playback.speed.select/speed_percent":"replaysPlaybackSpeed","replays.slot.playback.speed/speed_percent":"replaysPlaybackSpeed","replays.slot.select/slot":"replaysSelectedSlot"},t.parametersTopicToFeedbackNamesMap={"PlayAudio/channel":[s.Feedback.MONITORED_AUDIO],"SetDirectEditScene/active":[s.Feedback.DIRECT_EDIT_SCENE],"SetDirectEditLayer/active":[s.Feedback.DIRECT_EDIT_LAYER],"SetCurrentSceneByIndex/sceneIndex":[s.Feedback.PROGRAM_SCENE_INDEX],"SetPreviewSceneByIndex/sceneIndex":[s.Feedback.PREVIEW_SCENE_INDEX],"replays.slot.playback.speed.select/speed_percent":[s.Feedback.REPLAYS_PLAYBACK_SPEED_PREDEFINED,s.Feedback.REPLAYS_PLAYBACK_SPEED],"replays.slot.playback.speed/speed_percent":[s.Feedback.REPLAYS_PLAYBACK_SPEED_PREDEFINED,s.Feedback.REPLAYS_PLAYBACK_SPEED],"replays.slot.select/slot":[s.Feedback.REPLAYS_SELECTED_SLOT]},t.getBooleanState=(e,n,s)=>{switch(e){case"audiomixer.output.muted/muted":{const e=s.audioOutputs[n.output];return void 0!==e&&e.muted}case"SetProgramMuted/muted":{const e=s.audioOutputs.Master;return void 0!==e&&e.muted}default:return(0,i.getValueAtPath)(s,t.parametersTopicToProjectStateFieldMap[e])}}},6923:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.processRequest=void 0;const s=n(1658),i=n(3105),o=n(6787);t.processRequest=(e,t,n)=>{switch(t){case i.RequestType.GET_AUDIO_MIXER_STATE:n.projectState.monitoredAudio=(0,o.getValueAtPath)(e,"monitoringChannel"),n.checkFeedbacks(s.Feedback.MONITORED_AUDIO);break;case i.RequestType.GET_DIRECT_EDIT:{const t=(0,o.getValueAtPath)(e,"directEdit");n.projectState.directEditLayer="LAYER"===t,n.projectState.directEditScene="SCENE"===t,n.checkFeedbacks(s.Feedback.DIRECT_EDIT_LAYER,s.Feedback.DIRECT_EDIT_SCENE);break}case i.RequestType.GET_LATEST_PROJECT:{const t=(0,o.getValueAtPath)(e,"update.producer.currentScene"),i=(0,o.getValueAtPath)(e,"update.producer.previewScene");n.projectState.currentProgramSceneIndex=t,n.projectState.currentPreviewSceneIndex=i;const r=(0,o.getValueAtPath)(e,"update.producer.scenes");n.projectState.currentPreviewSceneName=r[i].name,n.projectState.currentProgramSceneName=r[t].name,n.projectState.sceneNames=(0,o.getValueAtPath)(e,"update.producer.scenes").map((e=>e.name)),n.checkFeedbacks(s.Feedback.PREVIEW_SCENE_INDEX,s.Feedback.PREVIEW_SCENE_NAME,s.Feedback.PROGRAM_SCENE_INDEX,s.Feedback.PROGRAM_SCENE_NAME),n.projectState.replaysPlaybackSpeed=(0,o.getValueAtPath)(e,"update.replay.motionSpeed"),n.projectState.replaysSelectedSlot=(0,o.getValueAtPath)(e,"update.replay.activeSlot"),n.checkFeedbacks(s.Feedback.REPLAYS_PLAYBACK_SPEED_PREDEFINED,s.Feedback.REPLAYS_PLAYBACK_SPEED,s.Feedback.REPLAYS_SELECTED_SLOT);break}case i.RequestType.AUDIOMIXER_OUTPUT_MUTED:{const t=(0,o.getValueAtPath)(e,"name");let i=n.projectState.audioOutputs[t];void 0===i&&(i={muted:!1},n.projectState.audioOutputs[t]=i),i.muted,(0,o.getValueAtPath)(e,"mixer.mutted"),n.checkFeedbacks(s.Feedback.AUDIO_OUTPUT_MUTED)}}}},412:(e,t)=>{"use strict";var n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.CommandParameterType=t.CommandParameterProperty=void 0,function(e){e.ID="id",e.OPTIONAL_ID="optional_id",e.CONTROLLABLE="controllable",e.REQUIRED="required",e.OPTIONAL="optional",e.READ_ONLY_CONTROLLABLE="read_only_controllable"}(n||(t.CommandParameterProperty=n={})),function(e){e.CONST="const",e.NUMBER="number",e.BOOLEAN="boolean",e.STRING="string",e.SOURCE_NAME="SourceName",e.SCENE_NAME="SceneName",e.PLAYOUT_INDEX="PlayoutIndex",e.PLAYOUT_NAME="PlayoutName",e.PLAYLIST="Playlist",e.SELECT="select",e.REPLAYS_SLOT="ReplaysSlot",e.TRANSITION_NAME="TransitionName",e.SCENE_INDEX="SceneIndex",e.LAYER_INDEX="LayerIndex",e.SOURCE_INDEX="SourceIndex",e.AUDIO_OUTPUT_NAME="AudioOutputName"}(s||(t.CommandParameterType=s={}))},3105:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.RequestType=void 0,function(e){e.GET_LATEST_PROJECT="GetLatestProject",e.GET_DIRECT_EDIT="GetDirectEdit",e.GET_AUDIO_MIXER_STATE="GetAudioMixerState",e.AUDIOMIXER_OUTPUT_MUTED="audiomixer.output.muted"}(n||(t.RequestType=n={}))},8780:(e,t)=>{"use strict";var n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketUpdateTypes=t.WebSocketMessageId=void 0,function(e){e.GET_COMMANDS_TEMPLATES_MSG_ID="commands_templates",e.GET_PARAM_OPTIONS_MSG_ID="param_options"}(n||(t.WebSocketMessageId=n={})),function(e){e.GATEWAY_CONNECTION="gateway-connection"}(s||(t.WebSocketUpdateTypes=s={}))},6178:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.processUpdate=void 0;const s=n(1658),i=n(6787);t.processUpdate=(e,t)=>{switch(e["update-type"]){case"PlayAudio":t.projectState.monitoredAudio=(0,i.getValueAtPath)(e,"channel"),t.checkFeedbacks(s.Feedback.MONITORED_AUDIO);break;case"SetDirectEditScene":{const n=(0,i.getValueAtPath)(e,"active");t.projectState.directEditScene=n,t.checkFeedbacks(s.Feedback.DIRECT_EDIT_SCENE);break}case"SetDirectEditLayer":{const n=(0,i.getValueAtPath)(e,"active");t.projectState.directEditLayer=n,t.checkFeedbacks(s.Feedback.DIRECT_EDIT_LAYER);break}case"ProgramSceneChanged":{const n=(0,i.getValueAtPath)(e,"scene-name"),o=t.projectState.sceneNames.findIndex((e=>e===n));if(-1===o){t.log("error",`Failed to process ProgramSceneChanged update. There is no scene with name ${n}.`);break}t.projectState.currentProgramSceneIndex=o,t.projectState.currentProgramSceneName=n,t.checkFeedbacks(s.Feedback.PROGRAM_SCENE_INDEX,s.Feedback.PROGRAM_SCENE_NAME);break}case"PreviewSceneChanged":{const n=(0,i.getValueAtPath)(e,"scene-name"),o=t.projectState.sceneNames.findIndex((e=>e===n));if(-1===o){t.log("error",`Failed to process PreviewSceneChanged update. There is no scene with name ${n}.`);break}t.projectState.currentPreviewSceneIndex=o,t.projectState.currentPreviewSceneName=n,t.checkFeedbacks(s.Feedback.PREVIEW_SCENE_INDEX,s.Feedback.PREVIEW_SCENE_NAME);break}case"replays.slot.playback.speed":t.projectState.replaysPlaybackSpeed=(0,i.getValueAtPath)(e,"speed_percent"),t.checkFeedbacks(s.Feedback.REPLAYS_PLAYBACK_SPEED,s.Feedback.REPLAYS_PLAYBACK_SPEED_PREDEFINED);break;case"replays.slot.select":t.projectState.replaysSelectedSlot=(0,i.getValueAtPath)(e,"slot"),t.checkFeedbacks(s.Feedback.REPLAYS_SELECTED_SLOT);break;case"audiomixer.output.muted":{const n=(0,i.getValueAtPath)(e,"output"),o=t.projectState.audioOutputs[n];if(void 0===o)break;o.muted=(0,i.getValueAtPath)(e,"muted"),t.checkFeedbacks(s.Feedback.AUDIO_OUTPUT_MUTED);break}}}},6787:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getValueAtPath=t.setValueAtPath=t.trimText=t.generateMessageId=t.commandParameterTypeToInputType=t.transformToTitleCase=void 0;const s=n(412),i=n(2600);t.transformToTitleCase=e=>e.split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" "),t.commandParameterTypeToInputType=e=>{switch(e){case s.CommandParameterType.NUMBER:return"number";case s.CommandParameterType.BOOLEAN:return"checkbox";case s.CommandParameterType.STRING:return"textinput";default:return"dropdown"}},t.generateMessageId=()=>`COMPANION_MODULE_TELLYO_STREAMSTUDIO_${(0,i.v4)()}`,t.trimText=(e,t)=>`${e.substring(0,t)}${e.length>t?"...":""}`,t.setValueAtPath=(e,t,n)=>{const s=n.split(".");let i=e;for(let e=0;e{const n=t.split(".");let s=e;for(let e=0;e{this.ws||(this.wsUrl=`ws://${e}:${t}`,this.ws=new o.default(this.wsUrl),this.updateStatus(),this.ws.onopen=()=>this.updateStatus(),this.ws.onclose=()=>{this.updateStatus(),delete this.ws},this.ws.onmessage=e=>{if("string"!=typeof e.data)return;const t=JSON.parse(e.data);this.logMessages&&this.logMessage(e.data,this.ssInstance),this.emit(c.MESSAGE,t)},this.ws.onerror=()=>this.emit(c.STATUS_CHANGED,a.ERROR))},this.send=e=>{var t;1===(null===(t=this.ws)||void 0===t?void 0:t.readyState)&&(this.logMessages&&this.ssInstance.log("debug",`Sending: ${JSON.stringify(e)}`),this.ws.send(JSON.stringify(e)))},this.disconnect=()=>{var e;1===(null===(e=this.ws)||void 0===e?void 0:e.readyState)&&(this.ws.close(),delete this.ws)},this.getStatus=()=>{var e;return void 0===(null===(e=this.ws)||void 0===e?void 0:e.readyState)?a.CLOSED:this.ws.readyState},this.updateStatus=()=>{this.emit(c.STATUS_CHANGED,this.getStatus())},this.logMessage=(e,t)=>{g.some((t=>e.includes(t)))||t.log("debug",`Received: ${(0,r.trimText)(JSON.stringify(e),150)}`)},this.ssInstance=e,this.logMessages=t}}t.default=l},7056:(e,t,n)=>{"use strict";const s=n(4063);s.code='require("ajv/dist/runtime/equal").default',t.Z=s},7513:(e,t,n)=>{"use strict";n.d(t,{X:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},758:(e,t,n)=>{"use strict";n.d(t,{r:()=>r});var s=n(5659),i=n(3207),o=n(2176);function r(){(0,i.T)(),(0,o.KV)()&&function(){const t=(0,s.cu)();if(!t.__SENTRY__)return;const n={mongodb:()=>new((0,o.l$)(e,"./node/integrations/mongo").Mongo),mongoose:()=>new((0,o.l$)(e,"./node/integrations/mongo").Mongo),mysql:()=>new((0,o.l$)(e,"./node/integrations/mysql").Mysql),pg:()=>new((0,o.l$)(e,"./node/integrations/postgres").Postgres)},i=Object.keys(n).filter((e=>!!(0,o.$y)(e))).map((e=>{try{return n[e]()}catch(e){return}})).filter((e=>e));i.length>0&&(t.__SENTRY__.integrations=[...t.__SENTRY__.integrations||[],...i])}()}e=n.hmd(e)},2716:(e,t,n)=>{"use strict";n.d(t,{_:()=>d});var s=n(4307),i=n(2176),o=n(2343),r=n(535),a=n(2844),c=n(7597),g=n(7513),l=n(7990);class d{static __initStatic(){this.id="Apollo"}constructor(e={useNestjs:!1}){this.name=d.id,this._useNest=!!e.useNestjs}loadDependency(){return this._useNest?this._module=this._module||(0,i.$y)("@nestjs/graphql"):this._module=this._module||(0,i.$y)("apollo-server-core"),this._module}setupOnce(e,t){if((0,l.K)(t))g.X&&o.kg.log("Apollo Integration is skipped because of instrumenter configuration.");else if(this._useNest){const e=this.loadDependency();if(!e)return void(g.X&&o.kg.error("Apollo-NestJS Integration was unable to require @nestjs/graphql package."));(0,r.hl)(e.GraphQLFactory.prototype,"mergeWithSchema",(function(e){return function(...n){return(0,r.hl)(this.resolversExplorerService,"explore",(function(e){return function(){return I((0,a.lE)(e.call(this)),t)}})),e.call(this,...n)}}))}else{const e=this.loadDependency();if(!e)return void(g.X&&o.kg.error("Apollo Integration was unable to require apollo-server-core package."));(0,r.hl)(e.ApolloServerBase.prototype,"constructSchema",(function(e){return function(){if(!this.config.resolvers)return g.X&&(this.config.schema?(o.kg.warn("Apollo integration is not able to trace `ApolloServer` instances constructed via `schema` property.If you are using NestJS with Apollo, please use `Sentry.Integrations.Apollo({ useNestjs: true })` instead."),o.kg.warn()):this.config.modules&&o.kg.warn("Apollo integration is not able to trace `ApolloServer` instances constructed via `modules` property."),o.kg.error("Skipping tracing as no resolvers found on the `ApolloServer` instance.")),e.call(this);const n=(0,a.lE)(this.config.resolvers);return this.config.resolvers=I(n,t),e.call(this)}}))}}}function I(e,t){return e.map((e=>(Object.keys(e).forEach((n=>{Object.keys(e[n]).forEach((i=>{"function"==typeof e[n][i]&&function(e,t,n,i){(0,r.hl)(e[t],n,(function(e){return function(...o){const r=i().getScope().getSpan(),a=(0,s.x)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:`${t}.${n}`,op:"graphql.resolve",origin:"auto.graphql.apollo"})]),g=e.call(this,...o);return(0,c.J8)(g)?g.then((e=>((0,s.x)([a,"optionalAccess",e=>e.end,"call",e=>e()]),e))):((0,s.x)([a,"optionalAccess",e=>e.end,"call",e=>e()]),g)}}))}(e,n,i,t)}))})),e)))}d.__initStatic()},8737:(e,t,n)=>{"use strict";n.d(t,{N1:()=>u});var s=n(4307),i=n(3371),o=n(6754),r=n(2343),a=n(6956),c=n(771),g=n(7597),l=n(1235),d=n(7513),I=n(7990);class u{static __initStatic(){this.id="Express"}constructor(e={}){this.name=u.id,this._router=e.router||e.app,this._methods=(Array.isArray(e.methods)?e.methods:[]).concat("use")}setupOnce(e,t){this._router?(0,I.K)(t)?d.X&&r.kg.log("Express Integration is skipped because of instrumenter configuration."):(function(e,t=[]){t.forEach((t=>function(e,t){const n=e[t];return e[t]=function(...e){return n.call(this,...function(e,t){return e.map((e=>"function"==typeof e?p(e,t):Array.isArray(e)?e.map((e=>"function"==typeof e?p(e,t):e)):e))}(e,t))},e}(e,t)))}(this._router,this._methods),function(e){const t="settings"in e;t&&void 0===e._router&&e.lazyrouter&&e.lazyrouter();const n=t?e._router:e;if(!n)return d.X&&r.kg.debug("Cannot instrument router for URL Parameterization (did not find a valid router)."),void(d.X&&r.kg.debug("Routing instrumentation is currently only supported in Express 4."));const I=Object.getPrototypeOf(n),u=I.process_params;I.process_params=function(e,t,n,r,d){n._reconstructedRoute||(n._reconstructedRoute="");const{layerRoutePath:I,isRegex:p,isArray:b,numExtraSegments:C}=function(e){let t=(0,s.x)([e,"access",e=>e.route,"optionalAccess",e=>e.path]);const n=(0,g.Kj)(t),i=Array.isArray(t);if(!t){const[n]=l.GLOBAL_OBJ.process.versions.node.split(".").map(Number);n>=16&&(t=h(e.path,e.regexp,e.keys))}if(!t)return{isRegex:n,isArray:i,numExtraSegments:0};const o=i?Math.max(t.reduce(((e,t)=>e+(0,a.$A)(t.toString())),0)-(0,a.$A)(e.path||""),0):0,r=function(e,t){return e?t.map((e=>e.toString())).join(","):t&&t.toString()}(i,t);return{layerRoutePath:r,isRegex:n,isArray:i,numExtraSegments:o}}(e);let m;(I||p||b)&&(n._hasParameters=!0),m=I||function(e,t,n){const i=(0,a.rt)(e||""),o=(0,s.x)([i,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>!!e))]);let r=0;const c=(0,s.x)([t,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>!!e)),"access",e=>e.length])||0;return(0,s.x)([n,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>(0,s.x)([o,"optionalAccess",e=>e[c+r]])===e&&(r+=1,!0))),"access",e=>e.join,"call",e=>e("/")])}(n.originalUrl,n._reconstructedRoute,e.path)||"";const Z=m.split("/").filter((e=>e.length>0&&(p||b||!e.includes("*")))).join("/");if(Z&&Z.length>0&&(n._reconstructedRoute+=`/${Z}${p?"/":""}`),(0,a.$A)((0,a.rt)(n.originalUrl||""))+C===(0,a.$A)(n._reconstructedRoute)){n._hasParameters||n._reconstructedRoute!==n.originalUrl&&(n._reconstructedRoute=n.originalUrl?(0,a.rt)(n.originalUrl):n.originalUrl);const e=r.__sentry_transaction,t=e&&(0,i.XU)(e).data||{};if(e&&"custom"!==t[o.Zj]){const t=n._reconstructedRoute||"/",[s,i]=(0,c.oA)(n,{path:!0,method:!0,customRoute:t});e.updateName(s),e.setAttribute(o.Zj,i)}}return u.call(this,e,t,n,r,d)}}(this._router)):d.X&&r.kg.error("ExpressIntegration is missing an Express instance")}}function p(e,t){const n=e.length;switch(n){case 2:return function(n,s){const i=s.__sentry_transaction;if(i){const n=i.startChild({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"});s.once("finish",(()=>{n.end()}))}return e.call(this,n,s)};case 3:return function(n,i,o){const r=i.__sentry_transaction,a=(0,s.x)([r,"optionalAccess",e=>e.startChild,"call",n=>n({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"})]);e.call(this,n,i,(function(...e){(0,s.x)([a,"optionalAccess",e=>e.end,"call",e=>e()]),o.call(this,...e)}))};case 4:return function(n,i,o,r){const a=o.__sentry_transaction,c=(0,s.x)([a,"optionalAccess",e=>e.startChild,"call",n=>n({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"})]);e.call(this,n,i,o,(function(...e){(0,s.x)([c,"optionalAccess",e=>e.end,"call",e=>e()]),r.call(this,...e)}))};default:throw new Error(`Express middleware takes 2-4 arguments. Got: ${n}`)}}u.__initStatic();const h=(e,t,n)=>{if(!(e&&t&&n&&0!==Object.keys(n).length&&(0,s.x)([n,"access",e=>e[0],"optionalAccess",e=>e.offset])))return;const i=n.sort(((e,t)=>e.offset-t.offset)),o=new RegExp(t,`${t.flags}d`).exec(e);if(!o||!o.indices)return;const[,...r]=o.indices;if(r.length!==i.length)return;let a=e,c=0;return r.forEach(((e,t)=>{if(e){const[n,s]=e,o=a.substring(0,n-c),r=`:${i[t].name}`,g=a.substring(s-c);a=o+r+g,c+=s-n-r.length}})),a}},1791:(e,t,n)=>{"use strict";n.d(t,{k:()=>l});var s=n(4307),i=n(2176),o=n(2343),r=n(535),a=n(7597),c=n(7513),g=n(7990);class l{static __initStatic(){this.id="GraphQL"}constructor(){this.name=l.id}loadDependency(){return this._module=this._module||(0,i.$y)("graphql/execution/execute.js")}setupOnce(e,t){if((0,g.K)(t))return void(c.X&&o.kg.log("GraphQL Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();n?(0,r.hl)(n,"execute",(function(e){return function(...n){const i=t().getScope(),o=i.getSpan(),r=(0,s.x)([o,"optionalAccess",e=>e.startChild,"call",e=>e({description:"execute",op:"graphql.execute",origin:"auto.graphql.graphql"})]);(0,s.x)([i,"optionalAccess",e=>e.setSpan,"call",e=>e(r)]);const c=e.call(this,...n);return(0,a.J8)(c)?c.then((e=>((0,s.x)([r,"optionalAccess",e=>e.end,"call",e=>e()]),(0,s.x)([i,"optionalAccess",e=>e.setSpan,"call",e=>e(o)]),e))):((0,s.x)([r,"optionalAccess",e=>e.end,"call",e=>e()]),(0,s.x)([i,"optionalAccess",e=>e.setSpan,"call",e=>e(o)]),c)}})):c.X&&o.kg.error("GraphQL Integration was unable to require graphql/execution package.")}}l.__initStatic()},6046:(e,t,n)=>{"use strict";n.d(t,{G:()=>i});var s=n(2176);e=n.hmd(e);const i=[()=>new((0,s.l$)(e,"./apollo").Apollo),()=>new((0,s.l$)(e,"./apollo").Apollo)({useNestjs:!0}),()=>new((0,s.l$)(e,"./graphql").GraphQL),()=>new((0,s.l$)(e,"./mongo").Mongo),()=>new((0,s.l$)(e,"./mongo").Mongo)({mongoose:!0}),()=>new((0,s.l$)(e,"./mysql").Mysql),()=>new((0,s.l$)(e,"./postgres").Postgres)]},6169:(e,t,n)=>{"use strict";n.d(t,{_:()=>I});var s=n(4307),i=n(2176),o=n(2343),r=n(535),a=n(7597),c=n(7513),g=n(7990);const l=["aggregate","bulkWrite","countDocuments","createIndex","createIndexes","deleteMany","deleteOne","distinct","drop","dropIndex","dropIndexes","estimatedDocumentCount","find","findOne","findOneAndDelete","findOneAndReplace","findOneAndUpdate","indexes","indexExists","indexInformation","initializeOrderedBulkOp","insertMany","insertOne","isCapped","mapReduce","options","parallelCollectionScan","rename","replaceOne","stats","updateMany","updateOne"],d={bulkWrite:["operations"],countDocuments:["query"],createIndex:["fieldOrSpec"],createIndexes:["indexSpecs"],deleteMany:["filter"],deleteOne:["filter"],distinct:["key","query"],dropIndex:["indexName"],find:["query"],findOne:["query"],findOneAndDelete:["filter"],findOneAndReplace:["filter","replacement"],findOneAndUpdate:["filter","update"],indexExists:["indexes"],insertMany:["docs"],insertOne:["doc"],mapReduce:["map","reduce"],rename:["newName"],replaceOne:["filter","doc"],updateMany:["filter","update"],updateOne:["filter","update"]};class I{static __initStatic(){this.id="Mongo"}constructor(e={}){this.name=I.id,this._operations=Array.isArray(e.operations)?e.operations:l,this._describeOperations=!("describeOperations"in e)||e.describeOperations,this._useMongoose=!!e.useMongoose}loadDependency(){const e=this._useMongoose?"mongoose":"mongodb";return this._module=this._module||(0,i.$y)(e)}setupOnce(e,t){if((0,g.K)(t))return void(c.X&&o.kg.log("Mongo Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(n)this._instrumentOperations(n.Collection,this._operations,t);else{const e=this._useMongoose?"mongoose":"mongodb";c.X&&o.kg.error(`Mongo Integration was unable to require \`${e}\` package.`)}}_instrumentOperations(e,t,n){t.forEach((t=>this._patchOperation(e,t,n)))}_patchOperation(e,t,n){if(!(t in e.prototype))return;const i=this._getSpanContextFromOperationArguments.bind(this);(0,r.hl)(e.prototype,t,(function(e){return function(...o){const r=o[o.length-1],c=n(),g=c.getScope(),l=c.getClient(),d=g.getSpan(),I=(0,s.x)([l,"optionalAccess",e=>e.getOptions,"call",e=>e(),"access",e=>e.sendDefaultPii]);if("function"!=typeof r||"mapReduce"===t&&2===o.length){const n=(0,s.x)([d,"optionalAccess",e=>e.startChild,"call",e=>e(i(this,t,o,I))]),r=e.call(this,...o);if((0,a.J8)(r))return r.then((e=>((0,s.x)([n,"optionalAccess",e=>e.end,"call",e=>e()]),e)));if((u=r)&&"object"==typeof u&&u.once&&"function"==typeof u.once){const e=r;try{e.once("close",(()=>{(0,s.x)([n,"optionalAccess",e=>e.end,"call",e=>e()])}))}catch(e){(0,s.x)([n,"optionalAccess",e=>e.end,"call",e=>e()])}return e}return(0,s.x)([n,"optionalAccess",e=>e.end,"call",e=>e()]),r}var u;const p=(0,s.x)([d,"optionalAccess",e=>e.startChild,"call",e=>e(i(this,t,o.slice(0,-1)))]);return e.call(this,...o.slice(0,-1),(function(e,t){(0,s.x)([p,"optionalAccess",e=>e.end,"call",e=>e()]),r(e,t)}))}}))}_getSpanContextFromOperationArguments(e,t,n,s=!1){const i={"db.system":"mongodb","db.name":e.dbName,"db.operation":t,"db.mongodb.collection":e.collectionName},o={op:"db",origin:"auto.db.mongo",description:t,data:i},r=d[t],a=Array.isArray(this._describeOperations)?this._describeOperations.includes(t):this._describeOperations;if(!r||!a||!s)return o;try{if("mapReduce"===t){const[e,t]=n;i[r[0]]="string"==typeof e?e:e.name||"",i[r[1]]="string"==typeof t?t:t.name||""}else for(let e=0;e{"use strict";n.d(t,{m:()=>g});var s=n(4307),i=n(2176),o=n(2343),r=n(535),a=n(7513),c=n(7990);class g{static __initStatic(){this.id="Mysql"}constructor(){this.name=g.id}loadDependency(){return this._module=this._module||(0,i.$y)("mysql/lib/Connection.js")}setupOnce(e,t){if((0,c.K)(t))return void(a.X&&o.kg.log("Mysql Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(!n)return void(a.X&&o.kg.error("Mysql Integration was unable to require `mysql` package."));let i;try{n.prototype.connect=new Proxy(n.prototype.connect,{apply:(e,t,n)=>(i||(i=t.config),e.apply(t,n))})}catch(e){a.X&&o.kg.error("Mysql Integration was unable to instrument `mysql` config.")}function g(e){if(!e)return;const t=i?{"server.address":i.host,"server.port":i.port,"db.user":i.user}:{};Object.keys(t).forEach((n=>{e.setAttribute(n,t[n])})),e.end()}(0,r.hl)(n,"createQuery",(function(e){return function(n,i,o){const r=t().getScope().getSpan(),a=(0,s.x)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:"string"==typeof n?n:n.sql,op:"db",origin:"auto.db.mysql",data:{"db.system":"mysql"}})]);if("function"==typeof o)return e.call(this,n,i,(function(e,t,n){g(a),o(e,t,n)}));if("function"==typeof i)return e.call(this,n,(function(e,t,n){g(a),i(e,t,n)}));const c=e.call(this,n,i);return c.on("end",(()=>{g(a)})),c}}))}}g.__initStatic()},1370:(e,t,n)=>{"use strict";n.d(t,{E:()=>l});var s=n(4307),i=n(2176),o=n(2343),r=n(535),a=n(7597),c=n(7513),g=n(7990);class l{static __initStatic(){this.id="Postgres"}constructor(e={}){this.name=l.id,this._usePgNative=!!e.usePgNative,this._module=e.module}loadDependency(){return this._module=this._module||(0,i.$y)("pg")}setupOnce(e,t){if((0,g.K)(t))return void(c.X&&o.kg.log("Postgres Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(!n)return void(c.X&&o.kg.error("Postgres Integration was unable to require `pg` package."));const i=this._usePgNative?(0,s.x)([n,"access",e=>e.native,"optionalAccess",e=>e.Client]):n.Client;i?(0,r.hl)(i.prototype,"query",(function(e){return function(n,i,o){const r=t().getScope().getSpan(),c={"db.system":"postgresql"};try{this.database&&(c["db.name"]=this.database),this.host&&(c["server.address"]=this.host),this.port&&(c["server.port"]=this.port),this.user&&(c["db.user"]=this.user)}catch(e){}const g=(0,s.x)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:"string"==typeof n?n:n.text,op:"db",origin:"auto.db.postgres",data:c})]);if("function"==typeof o)return e.call(this,n,i,(function(e,t){(0,s.x)([g,"optionalAccess",e=>e.end,"call",e=>e()]),o(e,t)}));if("function"==typeof i)return e.call(this,n,(function(e,t){(0,s.x)([g,"optionalAccess",e=>e.end,"call",e=>e()]),i(e,t)}));const l=void 0!==i?e.call(this,n,i):e.call(this,n);return(0,a.J8)(l)?l.then((e=>((0,s.x)([g,"optionalAccess",e=>e.end,"call",e=>e()]),e))):((0,s.x)([g,"optionalAccess",e=>e.end,"call",e=>e()]),l)}})):c.X&&o.kg.error("Postgres Integration was unable to access 'pg-native' bindings.")}}l.__initStatic()},9889:(e,t,n)=>{"use strict";n.d(t,{g:()=>l});var s=n(5659),i=n(4317),o=n(6754),r=n(535),a=n(2343),c=n(7513),g=n(7990);class l{static __initStatic(){this.id="Prisma"}constructor(e={}){if(this.name=l.id,(t=e.client)&&t.$use&&!e.client._sentryInstrumented){(0,r.xp)(e.client,"_sentryInstrumented",!0);const t={};try{const n=e.client._engineConfig;if(n){const{activeProvider:e,clientVersion:s}=n;e&&(t["db.system"]=e),s&&(t["db.prisma.version"]=s)}}catch(e){}e.client.$use(((e,n)=>{if((0,g.K)(s.Gd))return n(e);const r=e.action,a=e.model;return(0,i.GK)({name:a?`${a} ${r}`:r,onlyIfParent:!0,op:"db.prisma",attributes:{[o.S3]:"auto.db.prisma"},data:{...t,"db.operation":r}},(()=>n(e)))}))}else c.X&&a.kg.warn("Unsupported Prisma client provided to PrismaIntegration. Provided client:",e.client);var t}setupOnce(){}}l.__initStatic()},7990:(e,t,n)=>{"use strict";n.d(t,{K:()=>i});var s=n(4307);function i(e){const t=(0,s.x)([e,"call",e=>e(),"access",e=>e.getClient,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]);return"sentry"!==((0,s.x)([t,"optionalAccess",e=>e.instrumenter])||"sentry")}},1131:(e,t,n)=>{"use strict";n.d(t,{J:()=>s});const s="production"},1703:(e,t,n)=>{"use strict";n.d(t,{X:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},1195:(e,t,n)=>{"use strict";n.d(t,{RP:()=>l,cc:()=>g,fH:()=>c});var s=n(1235),i=n(6893),o=n(2343),r=n(7597),a=n(1703);function c(){return(0,s.Y)("globalEventProcessors",(()=>[]))}function g(e){c().push(e)}function l(e,t,n,s=0){return new i.cW(((i,c)=>{const g=e[s];if(null===t||"function"!=typeof g)i(t);else{const d=g({...t},n);a.X&&g.id&&null===d&&o.kg.log(`Event processor "${g.id}" dropped event`),(0,r.J8)(d)?d.then((t=>l(e,t,n,s+1).then(i))).then(null,c):l(e,d,n,s+1).then(i).then(null,c)}}))}},4487:(e,t,n)=>{"use strict";n.d(t,{$e:()=>W,TM:()=>_,Tb:()=>u,YA:()=>B,Yr:()=>v,_d:()=>V,av:()=>A,c:()=>R,cg:()=>F,dk:()=>w,e:()=>b,eN:()=>h,eW:()=>H,mG:()=>y,nZ:()=>k,n_:()=>C,rJ:()=>Z,s3:()=>N,sU:()=>G,sV:()=>S,uT:()=>p,v:()=>m,wi:()=>f,xv:()=>Y,yj:()=>K,yl:()=>X});var s=n(2343),i=n(2844),o=n(1170),r=n(7597),a=n(1235),c=n(1131),g=n(1703),l=n(5659),d=n(9015),I=n(8942);function u(e,t){return(0,l.Gd)().captureException(e,(0,I.U0)(t))}function p(e,t){const n="string"==typeof t?t:void 0,s="string"!=typeof t?{captureContext:t}:void 0;return(0,l.Gd)().captureMessage(e,n,s)}function h(e,t){return(0,l.Gd)().captureEvent(e,t)}function b(e){(0,l.Gd)().configureScope(e)}function C(e,t){(0,l.Gd)().addBreadcrumb(e,t)}function m(e,t){(0,l.Gd)().setContext(e,t)}function Z(e){(0,l.Gd)().setExtras(e)}function G(e,t){(0,l.Gd)().setExtra(e,t)}function y(e){(0,l.Gd)().setTags(e)}function B(e,t){(0,l.Gd)().setTag(e,t)}function A(e){(0,l.Gd)().setUser(e)}function W(...e){const t=(0,l.Gd)();if(2===e.length){const[n,s]=e;return n?t.withScope((()=>(t.getStackTop().scope=n,s(n)))):t.withScope(s)}return t.withScope(e[0])}function f(e){return(0,l.Ok)((()=>e((0,l.aF)())))}function V(e,t){return W((n=>(n.setSpan(e),t(n))))}function v(e,t){return(0,l.Gd)().startTransaction({...e},t)}function R(e,t){const n=k(),o=N();if(o){if(o.captureCheckIn)return o.captureCheckIn(e,t,n);g.X&&s.kg.warn("Cannot capture check-in. Client does not support sending check-ins.")}else g.X&&s.kg.warn("Cannot capture check-in. No client defined.");return(0,i.DM)()}function S(e,t,n){const s=R({monitorSlug:e,status:"in_progress"},n),i=(0,o.ph)();function a(t){R({monitorSlug:e,status:t,checkInId:s,duration:(0,o.ph)()-i})}let c;try{c=t()}catch(e){throw a("error"),e}return(0,r.J8)(c)?Promise.resolve(c).then((()=>{a("ok")}),(()=>{a("error")})):a("ok"),c}async function X(e){const t=N();return t?t.flush(e):(g.X&&s.kg.warn("Cannot flush events. No client defined."),Promise.resolve(!1))}async function Y(e){const t=N();return t?t.close(e):(g.X&&s.kg.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))}function H(){return(0,l.Gd)().lastEventId()}function N(){return(0,l.Gd)().getClient()}function w(){return!!N()}function k(){return(0,l.Gd)().getScope()}function K(e){const t=N(),n=(0,l.aF)(),s=k(),{release:i,environment:o=c.J}=t&&t.getOptions()||{},{userAgent:r}=a.GLOBAL_OBJ.navigator||{},g=(0,d.Hv)({release:i,environment:o,user:s.getUser()||n.getUser(),...r&&{userAgent:r},...e}),I=n.getSession();return I&&"ok"===I.status&&(0,d.CT)(I,{status:"exited"}),_(),n.setSession(g),s.setSession(g),g}function _(){const e=(0,l.aF)(),t=k(),n=t.getSession()||e.getSession();n&&(0,d.RJ)(n),J(),e.setSession(),t.setSession()}function J(){const e=(0,l.aF)(),t=k(),n=N(),s=t.getSession()||e.getSession();s&&n&&n.captureSession&&n.captureSession(s)}function F(e=!1){e?_():J()}},5659:(e,t,n)=>{"use strict";n.d(t,{$b:()=>B,Gd:()=>m,Ok:()=>A,Xb:()=>h,aF:()=>Z,cu:()=>b,j0:()=>V,pj:()=>C,uZ:()=>y,vi:()=>f});var s=n(7597),i=n(2844),o=n(1170),r=n(2343),a=n(1235),c=n(1131),g=n(1703),l=n(350),d=n(9015),I=n(105);const u=parseFloat(I.J),p=100;class h{constructor(e,t,n,s=u){let i,o;this._version=s,t?i=t:(i=new l.sX,i.setClient(e)),n?o=n:(o=new l.sX,o.setClient(e)),this._stack=[{scope:i}],e&&this.bindClient(e),this._isolationScope=o}isOlderThan(e){return this._version(this.popScope(),e)),(e=>{throw this.popScope(),e})):(this.popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}captureException(e,t){const n=this._lastEventId=t&&t.event_id?t.event_id:(0,i.DM)(),s=new Error("Sentry syntheticException");return this.getScope().captureException(e,{originalException:e,syntheticException:s,...t,event_id:n}),n}captureMessage(e,t,n){const s=this._lastEventId=n&&n.event_id?n.event_id:(0,i.DM)(),o=new Error(e);return this.getScope().captureMessage(e,t,{originalException:e,syntheticException:o,...n,event_id:s}),s}captureEvent(e,t){const n=t&&t.event_id?t.event_id:(0,i.DM)();return e.type||(this._lastEventId=n),this.getScope().captureEvent(e,{...t,event_id:n}),n}lastEventId(){return this._lastEventId}addBreadcrumb(e,t){const{scope:n,client:s}=this.getStackTop();if(!s)return;const{beforeBreadcrumb:i=null,maxBreadcrumbs:a=p}=s.getOptions&&s.getOptions()||{};if(a<=0)return;const c={timestamp:(0,o.yW)(),...e},g=i?(0,r.Cf)((()=>i(c,t))):c;null!==g&&(s.emit&&s.emit("beforeAddBreadcrumb",g,t),n.addBreadcrumb(g,a))}setUser(e){this.getScope().setUser(e),this.getIsolationScope().setUser(e)}setTags(e){this.getScope().setTags(e),this.getIsolationScope().setTags(e)}setExtras(e){this.getScope().setExtras(e),this.getIsolationScope().setExtras(e)}setTag(e,t){this.getScope().setTag(e,t),this.getIsolationScope().setTag(e,t)}setExtra(e,t){this.getScope().setExtra(e,t),this.getIsolationScope().setExtra(e,t)}setContext(e,t){this.getScope().setContext(e,t),this.getIsolationScope().setContext(e,t)}configureScope(e){const{scope:t,client:n}=this.getStackTop();n&&e(t)}run(e){const t=C(this);try{e(this)}finally{C(t)}}getIntegration(e){const t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch(t){return g.X&&r.kg.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,t){const n=this._callExtensionMethod("startTransaction",e,t);return g.X&&!n&&(this.getClient()?r.kg.warn("Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':\nSentry.addTracingExtensions();\nSentry.init({...});\n"):r.kg.warn("Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'")),n}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){const e=this.getStackTop().scope,t=e.getSession();t&&(0,d.RJ)(t),this._sendSessionUpdate(),e.setSession()}startSession(e){const{scope:t,client:n}=this.getStackTop(),{release:s,environment:i=c.J}=n&&n.getOptions()||{},{userAgent:o}=a.GLOBAL_OBJ.navigator||{},r=(0,d.Hv)({release:s,environment:i,user:t.getUser(),...o&&{userAgent:o},...e}),g=t.getSession&&t.getSession();return g&&"ok"===g.status&&(0,d.CT)(g,{status:"exited"}),this.endSession(),t.setSession(r),r}shouldSendDefaultPii(){const e=this.getClient(),t=e&&e.getOptions();return Boolean(t&&t.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:t}=this.getStackTop(),n=e.getSession();n&&t&&t.captureSession&&t.captureSession(n)}_callExtensionMethod(e,...t){const n=b().__SENTRY__;if(n&&n.extensions&&"function"==typeof n.extensions[e])return n.extensions[e].apply(this,t);g.X&&r.kg.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function b(){return a.GLOBAL_OBJ.__SENTRY__=a.GLOBAL_OBJ.__SENTRY__||{extensions:{},hub:void 0},a.GLOBAL_OBJ}function C(e){const t=b(),n=f(t);return V(t,e),n}function m(){const e=b();if(e.__SENTRY__&&e.__SENTRY__.acs){const t=e.__SENTRY__.acs.getCurrentHub();if(t)return t}return G(e)}function Z(){return m().getIsolationScope()}function G(e=b()){return W(e)&&!f(e).isOlderThan(u)||V(e,new h),f(e)}function y(e,t=G()){if(!W(e)||f(e).isOlderThan(u)){const n=t.getClient(),s=t.getScope(),i=t.getIsolationScope();V(e,new h(n,s.clone(),i.clone()))}}function B(e){const t=b();t.__SENTRY__=t.__SENTRY__||{},t.__SENTRY__.acs=e}function A(e,t={}){const n=b();return n.__SENTRY__&&n.__SENTRY__.acs?n.__SENTRY__.acs.runWithAsyncContext(e,t):e()}function W(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function f(e){return(0,a.Y)("hub",(()=>new h),e)}function V(e,t){return!!e&&((e.__SENTRY__=e.__SENTRY__||{}).hub=t,!0)}},2967:(e,t,n)=>{"use strict";n.d(t,{M5:()=>p,RN:()=>h,_I:()=>b,m7:()=>u,m8:()=>l,q4:()=>d,uf:()=>I});var s=n(2844),i=n(2343),o=n(1703),r=n(1195),a=n(4487),c=n(5659);const g=[];function l(e){const t=e.defaultIntegrations||[],n=e.integrations;let i;t.forEach((e=>{e.isDefaultInstance=!0})),i=Array.isArray(n)?[...t,...n]:"function"==typeof n?(0,s.lE)(n(t)):t;const o=function(e){const t={};return e.forEach((e=>{const{name:n}=e,s=t[n];s&&!s.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)})),Object.keys(t).map((e=>t[e]))}(i),r=function(e,t){for(let t=0;t{t&&u(e,t,n)})),n}function I(e,t){for(const n of t)n&&n.afterAllSetup&&n.afterAllSetup(e)}function u(e,t,n){if(n[t.name])o.X&&i.kg.log(`Integration skipped because it was already installed: ${t.name}`);else{if(n[t.name]=t,-1===g.indexOf(t.name)&&(t.setupOnce(r.cc,c.Gd),g.push(t.name)),t.setup&&"function"==typeof t.setup&&t.setup(e),e.on&&"function"==typeof t.preprocessEvent){const n=t.preprocessEvent.bind(t);e.on("preprocessEvent",((t,s)=>n(t,s,e)))}if(e.addEventProcessor&&"function"==typeof t.processEvent){const n=t.processEvent.bind(t),s=Object.assign(((t,s)=>n(t,s,e)),{id:t.name});e.addEventProcessor(s)}o.X&&i.kg.log(`Integration installed: ${t.name}`)}}function p(e){const t=(0,a.s3)();t&&t.addIntegration?t.addIntegration(e):o.X&&i.kg.warn(`Cannot add integration "${e.name}" because no SDK Client is available.`)}function h(e,t){return Object.assign((function(...e){return t(...e)}),{id:e})}function b(e){return e}},5986:(e,t,n)=>{"use strict";n.d(t,{v:()=>c,y:()=>a});var s=n(535),i=n(4317);let o;function r(e){return o?o.get(e):void 0}function a(e){const t=r(e);if(!t)return;const n={};for(const[,[e,i]]of t)n[e]||(n[e]=[]),n[e].push((0,s.Jr)(i));return n}function c(e,t,n,s,a,c){const g=(0,i.HN)();if(g){const i=r(g)||new Map,l=`${e}:${t}@${s}`,d=i.get(c);if(d){const[,e]=d;i.set(c,[l,{min:Math.min(e.min,n),max:Math.max(e.max,n),count:e.count+=1,sum:e.sum+=n,tags:e.tags}])}else i.set(c,[l,{min:n,max:n,count:1,sum:n,tags:a}]);o||(o=new WeakMap),o.set(g,i)}}},350:(e,t,n)=>{"use strict";n.d(t,{lW:()=>I,sX:()=>d});var s=n(7597),i=n(1170),o=n(2844),r=n(2343),a=n(1195),c=n(9015),g=n(3379);let l;class d{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=u()}static clone(e){return e?e.clone():new d}clone(){const e=new d;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._span=this._span,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e}setClient(e){this._client=e}getClient(){return this._client}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,segment:void 0,username:void 0},this._session&&(0,c.CT)(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this._tags={...this._tags,[e]:t},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){const e=this._span;return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const t="function"==typeof e?e(this):e;if(t instanceof d){const e=t.getScopeData();this._tags={...this._tags,...e.tags},this._extra={...this._extra,...e.extra},this._contexts={...this._contexts,...e.contexts},e.user&&Object.keys(e.user).length&&(this._user=e.user),e.level&&(this._level=e.level),e.fingerprint.length&&(this._fingerprint=e.fingerprint),t.getRequestSession()&&(this._requestSession=t.getRequestSession()),e.propagationContext&&(this._propagationContext=e.propagationContext)}else if((0,s.PO)(t)){const t=e;this._tags={...this._tags,...t.tags},this._extra={...this._extra,...t.extra},this._contexts={...this._contexts,...t.contexts},t.user&&(this._user=t.user),t.level&&(this._level=t.level),t.fingerprint&&(this._fingerprint=t.fingerprint),t.requestSession&&(this._requestSession=t.requestSession),t.propagationContext&&(this._propagationContext=t.propagationContext)}return this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this._propagationContext=u(),this}addBreadcrumb(e,t){const n="number"==typeof t?t:100;if(n<=0)return this;const s={timestamp:(0,i.yW)(),...e},o=this._breadcrumbs;return o.push(s),this._breadcrumbs=o.length>n?o.slice(-n):o,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this.getScopeData().attachments}clearAttachments(){return this._attachments=[],this}getScopeData(){const{_breadcrumbs:e,_attachments:t,_contexts:n,_tags:s,_extra:i,_user:o,_level:r,_fingerprint:a,_eventProcessors:c,_propagationContext:g,_sdkProcessingMetadata:l,_transactionName:d,_span:I}=this;return{breadcrumbs:e,attachments:t,contexts:n,tags:s,extra:i,user:o,level:r,fingerprint:a||[],eventProcessors:c,propagationContext:g,sdkProcessingMetadata:l,transactionName:d,span:I}}applyToEvent(e,t={},n=[]){(0,g.gi)(e,this.getScopeData());const s=[...n,...(0,a.fH)(),...this._eventProcessors];return(0,a.RP)(s,e,t)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){const n=t&&t.event_id?t.event_id:(0,o.DM)();if(!this._client)return r.kg.warn("No client configured on scope - will not capture exception!"),n;const s=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:s,...t,event_id:n},this),n}captureMessage(e,t,n){const s=n&&n.event_id?n.event_id:(0,o.DM)();if(!this._client)return r.kg.warn("No client configured on scope - will not capture message!"),s;const i=new Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:s},this),s}captureEvent(e,t){const n=t&&t.event_id?t.event_id:(0,o.DM)();return this._client?(this._client.captureEvent(e,{...t,event_id:n},this),n):(r.kg.warn("No client configured on scope - will not capture event!"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((e=>{e(this)})),this._notifyingListeners=!1)}}function I(){return l||(l=new d),l}function u(){return{traceId:(0,o.DM)(),spanId:(0,o.DM)().substring(16)}}},6754:(e,t,n)=>{"use strict";n.d(t,{$J:()=>o,S3:()=>r,TE:()=>i,Zj:()=>s,p6:()=>a});const s="sentry.source",i="sentry.sample_rate",o="sentry.op",r="sentry.origin",a="profile_id"},9015:(e,t,n)=>{"use strict";n.d(t,{CT:()=>a,Hv:()=>r,RJ:()=>c});var s=n(1170),i=n(2844),o=n(535);function r(e){const t=(0,s.ph)(),n={sid:(0,i.DM)(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return(0,o.Jr)({sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}})}(n)};return e&&a(n,e),n}function a(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||(0,s.ph)(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:(0,i.DM)()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function c(e,t){let n={};t?n={status:t}:"ok"===e.status&&(n={status:"exited"}),a(e,n)}},454:(e,t,n)=>{"use strict";n.d(t,{_:()=>c,j:()=>g});var s=n(535),i=n(1131),o=n(4487),r=n(5102),a=n(3371);function c(e,t,n){const o=t.getOptions(),{publicKey:r}=t.getDsn()||{},{segment:a}=n&&n.getUser()||{},c=(0,s.Jr)({environment:o.environment||i.J,release:o.release,user_segment:a,public_key:r,trace_id:e});return t.emit&&t.emit("createDsc",c),c}function g(e){const t=(0,o.s3)();if(!t)return{};const n=c((0,a.XU)(e).trace_id||"",t,(0,o.nZ)()),s=(0,r.G)(e);if(!s)return n;const i=s&&s._frozenDynamicSamplingContext;if(i)return i;const{sampleRate:g,source:l}=s.metadata;null!=g&&(n.sample_rate=`${g}`);const d=(0,a.XU)(s);return l&&"url"!==l&&(n.transaction=d.description),n.sampled=String((0,a.Tt)(s)),t.emit&&t.emit("createDsc",n),n}},3207:(e,t,n)=>{"use strict";n.d(t,{T:()=>B,l:()=>y});var s=n(2343),i=n(1703),o=n(5659),r=n(3371),a=n(1235),c=n(9729);let g=null;function l(){g=a.GLOBAL_OBJ.onerror,a.GLOBAL_OBJ.onerror=function(e,t,n,s,i){const o={column:s,error:i,line:n,msg:e,url:t};return(0,c.rK)("error",o),!(!g||g.__SENTRY_LOADER__)&&g.apply(this,arguments)},a.GLOBAL_OBJ.onerror.__SENTRY_INSTRUMENTED__=!0}let d=null;function I(){d=a.GLOBAL_OBJ.onunhandledrejection,a.GLOBAL_OBJ.onunhandledrejection=function(e){const t=e;return(0,c.rK)("unhandledrejection",t),!(d&&!d.__SENTRY_LOADER__)||d.apply(this,arguments)},a.GLOBAL_OBJ.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}var u=n(9791);let p=!1;function h(){const e=(0,u.x1)();if(e){const t="internal_error";i.X&&s.kg.log(`[Tracing] Transaction: ${t} -> Global error occured`),e.setStatus(t)}}h.tag="sentry_tracingErrorCallback";var b=n(5544),C=n(1221),m=n(8069);function Z(){const e=this.getScope().getSpan();return e?{"sentry-trace":(0,r.Hb)(e)}:{}}function G(e,t){const n=this.getClient(),o=n&&n.getOptions()||{},r=o.instrumenter||"sentry",a=e.instrumenter||"sentry";r!==a&&(i.X&&s.kg.error(`A transaction was started with instrumenter=\`${a}\`, but the SDK is configured with the \`${r}\` instrumenter.\nThe transaction will not be sampled. Please use the ${r} instrumentation to start transactions.`),e.sampled=!1);let c=new m.Y(e,this);return c=(0,C.f)(c,o,{name:e.name,parentSampled:e.parentSampled,transactionContext:e,attributes:{...e.data,...e.attributes},...t}),c.isRecording()&&c.initSpanRecorder(o._experiments&&o._experiments.maxSpans),n&&n.emit&&n.emit("startTransaction",c),c}function y(e,t,n,s,i,o,r,a=!1){const c=e.getClient(),g=c&&c.getOptions()||{};let l=new b.io(t,e,n,s,r,i,a);return l=(0,C.f)(l,g,{name:t.name,parentSampled:t.parentSampled,transactionContext:t,attributes:{...t.data,...t.attributes},...o}),l.isRecording()&&l.initSpanRecorder(g._experiments&&g._experiments.maxSpans),c&&c.emit&&c.emit("startTransaction",l),l}function B(){const e=(0,o.cu)();e.__SENTRY__&&(e.__SENTRY__.extensions=e.__SENTRY__.extensions||{},e.__SENTRY__.extensions.startTransaction||(e.__SENTRY__.extensions.startTransaction=G),e.__SENTRY__.extensions.traceHeaders||(e.__SENTRY__.extensions.traceHeaders=Z),p||(p=!0,function(e){const t="error";(0,c.Hj)(t,e),(0,c.D2)(t,l)}(h),function(e){const t="unhandledrejection";(0,c.Hj)(t,e),(0,c.D2)(t,I)}(h)))}},5544:(e,t,n)=>{"use strict";n.d(t,{AT:()=>g,io:()=>I});var s=n(2343),i=n(1170),o=n(1703),r=n(3371),a=n(8903),c=n(8069);const g={idleTimeout:1e3,finalTimeout:3e4,heartbeatInterval:5e3},l=["heartbeatFailed","idleTimeout","documentHidden","finalTimeout","externalFinish","cancelled"];class d extends a.g{constructor(e,t,n,s){super(s),this._pushActivity=e,this._popActivity=t,this.transactionSpanId=n}add(e){if(e.spanContext().spanId!==this.transactionSpanId){const t=e.end;e.end=(...n)=>(this._popActivity(e.spanContext().spanId),t.apply(e,n)),void 0===(0,r.XU)(e).timestamp&&this._pushActivity(e.spanContext().spanId)}super.add(e)}}class I extends c.Y{constructor(e,t,n=g.idleTimeout,i=g.finalTimeout,r=g.heartbeatInterval,a=!1,c=!1){super(e,t),this._idleHub=t,this._idleTimeout=n,this._finalTimeout=i,this._heartbeatInterval=r,this._onScope=a,this.activities={},this._heartbeatCounter=0,this._finished=!1,this._idleTimeoutCanceledPermanently=!1,this._beforeFinishCallbacks=[],this._finishReason=l[4],this._autoFinishAllowed=!c,a&&(o.X&&s.kg.log(`Setting idle transaction on scope. Span ID: ${this.spanContext().spanId}`),t.getScope().setSpan(this)),c||this._restartIdleTimeout(),setTimeout((()=>{this._finished||(this.setStatus("deadline_exceeded"),this._finishReason=l[3],this.end())}),this._finalTimeout)}end(e){const t=(0,r.$k)(e);if(this._finished=!0,this.activities={},"ui.action.click"===this.op&&this.setAttribute("finishReason",this._finishReason),this.spanRecorder){o.X&&s.kg.log("[Tracing] finishing IdleTransaction",new Date(1e3*t).toISOString(),this.op);for(const e of this._beforeFinishCallbacks)e(this,t);this.spanRecorder.spans=this.spanRecorder.spans.filter((e=>{if(e.spanContext().spanId===this.spanContext().spanId)return!0;(0,r.XU)(e).timestamp||(e.setStatus("cancelled"),e.end(t),o.X&&s.kg.log("[Tracing] cancelling span since transaction ended early",JSON.stringify(e,void 0,2)));const{start_timestamp:n,timestamp:i}=(0,r.XU)(e),a=n&&n{this._finished||this._pushActivity(e)},n=e=>{this._finished||this._popActivity(e)};this.spanRecorder=new d(t,n,this.spanContext().spanId,e),o.X&&s.kg.log("Starting heartbeat"),this._pingHeartbeat()}this.spanRecorder.add(this)}cancelIdleTimeout(e,{restartOnChildSpanChange:t}={restartOnChildSpanChange:!0}){this._idleTimeoutCanceledPermanently=!1===t,this._idleTimeoutID&&(clearTimeout(this._idleTimeoutID),this._idleTimeoutID=void 0,0===Object.keys(this.activities).length&&this._idleTimeoutCanceledPermanently&&(this._finishReason=l[5],this.end(e)))}setFinishReason(e){this._finishReason=e}sendAutoFinishSignal(){this._autoFinishAllowed||(o.X&&s.kg.log("[Tracing] Received finish signal for idle transaction."),this._restartIdleTimeout(),this._autoFinishAllowed=!0)}_restartIdleTimeout(e){this.cancelIdleTimeout(),this._idleTimeoutID=setTimeout((()=>{this._finished||0!==Object.keys(this.activities).length||(this._finishReason=l[1],this.end(e))}),this._idleTimeout)}_pushActivity(e){this.cancelIdleTimeout(void 0,{restartOnChildSpanChange:!this._idleTimeoutCanceledPermanently}),o.X&&s.kg.log(`[Tracing] pushActivity: ${e}`),this.activities[e]=!0,o.X&&s.kg.log("[Tracing] new activities count",Object.keys(this.activities).length)}_popActivity(e){if(this.activities[e]&&(o.X&&s.kg.log(`[Tracing] popActivity ${e}`),delete this.activities[e],o.X&&s.kg.log("[Tracing] new activities count",Object.keys(this.activities).length)),0===Object.keys(this.activities).length){const e=(0,i.ph)();this._idleTimeoutCanceledPermanently?this._autoFinishAllowed&&(this._finishReason=l[5],this.end(e)):this._restartIdleTimeout(e+this._idleTimeout/1e3)}}_beat(){if(this._finished)return;const e=Object.keys(this.activities).join("");e===this._prevHeartbeatString?this._heartbeatCounter++:this._heartbeatCounter=1,this._prevHeartbeatString=e,this._heartbeatCounter>=3?this._autoFinishAllowed&&(o.X&&s.kg.log("[Tracing] Transaction finished because of no change for 3 heart beats"),this.setStatus("deadline_exceeded"),this._finishReason=l[0],this.end()):this._pingHeartbeat()}_pingHeartbeat(){o.X&&s.kg.log(`pinging Heartbeat -> current counter: ${this._heartbeatCounter}`),setTimeout((()=>{this._beat()}),this._heartbeatInterval)}}},9080:(e,t,n)=>{"use strict";n.d(t,{o:()=>i});var s=n(9791);function i(e,t,n){const i=(0,s.x1)();i&&i.setMeasurement(e,t,n)}},1221:(e,t,n)=>{"use strict";n.d(t,{X:()=>l,f:()=>g});var s=n(2343),i=n(7597),o=n(1703),r=n(6754),a=n(7522),c=n(3371);function g(e,t,n){if(!(0,a.z)(t))return e.sampled=!1,e;if(void 0!==e.sampled)return e.setAttribute(r.TE,Number(e.sampled)),e;let i;return"function"==typeof t.tracesSampler?(i=t.tracesSampler(n),e.setAttribute(r.TE,Number(i))):void 0!==n.parentSampled?i=n.parentSampled:void 0!==t.tracesSampleRate?(i=t.tracesSampleRate,e.setAttribute(r.TE,Number(i))):(i=1,e.setAttribute(r.TE,i)),l(i)?i?(e.sampled=Math.random()1)||(o.X&&s.kg.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${e}.`),!1)}},8903:(e,t,n)=>{"use strict";n.d(t,{D:()=>p,g:()=>u});var s=n(2844),i=n(1170),o=n(2343),r=n(535),a=n(1703),c=n(5986),g=n(6754),l=n(5102),d=n(3371),I=n(7387);class u{constructor(e=1e3){this._maxlen=e,this.spans=[]}add(e){this.spans.length>this._maxlen?e.spanRecorder=void 0:this.spans.push(e)}}class p{constructor(e={}){this._traceId=e.traceId||(0,s.DM)(),this._spanId=e.spanId||(0,s.DM)().substring(16),this._startTime=e.startTimestamp||(0,i.ph)(),this.tags=e.tags?{...e.tags}:{},this.data=e.data?{...e.data}:{},this.instrumenter=e.instrumenter||"sentry",this._attributes={},this.setAttributes({[g.S3]:e.origin||"manual",[g.$J]:e.op,...e.attributes}),this._name=e.name||e.description,e.parentSpanId&&(this._parentSpanId=e.parentSpanId),"sampled"in e&&(this._sampled=e.sampled),e.status&&(this._status=e.status),e.endTimestamp&&(this._endTime=e.endTimestamp),void 0!==e.exclusiveTime&&(this._exclusiveTime=e.exclusiveTime),this._measurements=e.measurements?{...e.measurements}:{}}get name(){return this._name||""}set name(e){this.updateName(e)}get description(){return this._name}set description(e){this._name=e}get traceId(){return this._traceId}set traceId(e){this._traceId=e}get spanId(){return this._spanId}set spanId(e){this._spanId=e}set parentSpanId(e){this._parentSpanId=e}get parentSpanId(){return this._parentSpanId}get sampled(){return this._sampled}set sampled(e){this._sampled=e}get attributes(){return this._attributes}set attributes(e){this._attributes=e}get startTimestamp(){return this._startTime}set startTimestamp(e){this._startTime=e}get endTimestamp(){return this._endTime}set endTimestamp(e){this._endTime=e}get status(){return this._status}set status(e){this._status=e}get op(){return this._attributes[g.$J]}set op(e){this.setAttribute(g.$J,e)}get origin(){return this._attributes[g.S3]}set origin(e){this.setAttribute(g.S3,e)}spanContext(){const{_spanId:e,_traceId:t,_sampled:n}=this;return{spanId:e,traceId:t,traceFlags:n?d.i0:d.ve}}startChild(e){const t=new p({...e,parentSpanId:this._spanId,sampled:this._sampled,traceId:this._traceId});t.spanRecorder=this.spanRecorder,t.spanRecorder&&t.spanRecorder.add(t);const n=(0,l.G)(this);if(t.transaction=n,a.X&&n){const s=`[Tracing] Starting '${e&&e.op||"< unknown op >"}' span on transaction '${(0,d.XU)(t).description||"< unknown name >"}' (${n.spanContext().spanId}).`;o.kg.log(s),this._logMessage=s}return t}setTag(e,t){return this.tags={...this.tags,[e]:t},this}setData(e,t){return this.data={...this.data,[e]:t},this}setAttribute(e,t){void 0===t?delete this._attributes[e]:this._attributes[e]=t}setAttributes(e){Object.keys(e).forEach((t=>this.setAttribute(t,e[t])))}setStatus(e){return this._status=e,this}setHttpStatus(e){return(0,I.Q0)(this,e),this}setName(e){this.updateName(e)}updateName(e){return this._name=e,this}isSuccess(){return"ok"===this._status}finish(e){return this.end(e)}end(e){if(this._endTime)return;const t=(0,l.G)(this);if(a.X&&t&&t.spanContext().spanId!==this._spanId){const e=this._logMessage;e&&o.kg.log(e.replace("Starting","Finishing"))}this._endTime=(0,d.$k)(e)}toTraceparent(){return(0,d.Hb)(this)}toContext(){return(0,r.Jr)({data:this._getData(),description:this._name,endTimestamp:this._endTime,op:this.op,parentSpanId:this._parentSpanId,sampled:this._sampled,spanId:this._spanId,startTimestamp:this._startTime,status:this._status,tags:this.tags,traceId:this._traceId})}updateWithContext(e){return this.data=e.data||{},this._name=e.name||e.description,this._endTime=e.endTimestamp,this.op=e.op,this._parentSpanId=e.parentSpanId,this._sampled=e.sampled,this._spanId=e.spanId||this._spanId,this._startTime=e.startTimestamp||this._startTime,this._status=e.status,this.tags=e.tags||{},this._traceId=e.traceId||this._traceId,this}getTraceContext(){return(0,d.wy)(this)}getSpanJSON(){return(0,r.Jr)({data:this._getData(),description:this._name,op:this._attributes[g.$J],parent_span_id:this._parentSpanId,span_id:this._spanId,start_timestamp:this._startTime,status:this._status,tags:Object.keys(this.tags).length>0?this.tags:void 0,timestamp:this._endTime,trace_id:this._traceId,origin:this._attributes[g.S3],_metrics_summary:(0,c.y)(this),profile_id:this._attributes[g.p6],exclusive_time:this._exclusiveTime,measurements:Object.keys(this._measurements).length>0?this._measurements:void 0})}isRecording(){return!this._endTime&&!!this._sampled}toJSON(){return this.getSpanJSON()}_getData(){const{data:e,_attributes:t}=this,n=Object.keys(e).length>0,s=Object.keys(t).length>0;if(n||s)return n&&s?{...e,...t}:n?e:t}}},7387:(e,t,n)=>{"use strict";var s;function i(e){if(e<400&&e>=100)return"ok";if(e>=400&&e<500)switch(e){case 401:return"unauthenticated";case 403:return"permission_denied";case 404:return"not_found";case 409:return"already_exists";case 413:return"failed_precondition";case 429:return"resource_exhausted";default:return"invalid_argument"}if(e>=500&&e<600)switch(e){case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline_exceeded";default:return"internal_error"}return"unknown_error"}n.d(t,{Q0:()=>r,Zd:()=>o,ix:()=>i,pN:()=>s}),function(e){e.Ok="ok",e.DeadlineExceeded="deadline_exceeded",e.Unauthenticated="unauthenticated",e.PermissionDenied="permission_denied",e.NotFound="not_found",e.ResourceExhausted="resource_exhausted",e.InvalidArgument="invalid_argument",e.Unimplemented="unimplemented",e.Unavailable="unavailable",e.InternalError="internal_error",e.UnknownError="unknown_error",e.Cancelled="cancelled",e.AlreadyExists="already_exists",e.FailedPrecondition="failed_precondition",e.Aborted="aborted",e.OutOfRange="out_of_range",e.DataLoss="data_loss"}(s||(s={}));const o=i;function r(e,t){e.setTag("http.status_code",String(t)),e.setData("http.response.status_code",t);const n=i(t);"unknown_error"!==n&&e.setStatus(n)}},4317:(e,t,n)=>{"use strict";n.d(t,{yn:()=>G,HN:()=>Z,I1:()=>f,y_:()=>b,qp:()=>m,GK:()=>h,V0:()=>C,g4:()=>p});var s=n(7638),i=n(2343),o=n(535),r=n(1703),a=n(5659),c=n(3371),g=n(454),l=n(4487),d=n(7597);function I(e,t,n=(()=>{})){let s;try{s=e()}catch(e){throw t(e),n(),e}return function(e,t,n){return(0,d.J8)(e)?e.then((e=>(n(),e)),(e=>{throw t(e),n(),e})):(n(),e)}(s,t,n)}var u=n(7522);function p(e,t,n=(()=>{}),s=(()=>{})){const i=(0,a.Gd)(),o=(0,l.nZ)(),r=o.getSpan(),c=B(e),g=y(i,{parentSpan:r,spanContext:c,forceTransaction:!1,scope:o});return o.setSpan(g),I((()=>t(g)),(e=>{g&&g.setStatus("internal_error"),n(e,g)}),(()=>{g&&g.end(),o.setSpan(r),s()}))}function h(e,t){const n=B(e);return(0,a.Ok)((()=>(0,l.$e)(e.scope,(s=>{const i=(0,a.Gd)(),o=s.getSpan(),r=e.onlyIfParent&&!o?void 0:y(i,{parentSpan:o,spanContext:n,forceTransaction:e.forceTransaction,scope:s});return I((()=>t(r)),(()=>{if(r){const{status:e}=(0,c.XU)(r);e&&"ok"!==e||r.setStatus("internal_error")}}),(()=>r&&r.end()))}))))}const b=h;function C(e,t){const n=B(e);return(0,a.Ok)((()=>(0,l.$e)(e.scope,(s=>{const i=(0,a.Gd)(),o=s.getSpan(),r=e.onlyIfParent&&!o?void 0:y(i,{parentSpan:o,spanContext:n,forceTransaction:e.forceTransaction,scope:s});function g(){r&&r.end()}return I((()=>t(r,g)),(()=>{if(r&&r.isRecording()){const{status:e}=(0,c.XU)(r);e&&"ok"!==e||r.setStatus("internal_error")}}))}))))}function m(e){if(!(0,u.z)())return;const t=B(e),n=(0,a.Gd)(),s=e.scope?e.scope.getSpan():Z();if(e.onlyIfParent&&!s)return;const i=(e.scope||(0,l.nZ)()).clone();return y(n,{parentSpan:s,spanContext:t,forceTransaction:e.forceTransaction,scope:i})}function Z(){return(0,l.nZ)().getSpan()}const G=({sentryTrace:e,baggage:t},n)=>{const c=(0,l.nZ)(),{traceparentData:g,dynamicSamplingContext:d,propagationContext:I}=(0,s.KA)(e,t);c.setPropagationContext(I),r.X&&g&&i.kg.log(`[Tracing] Continuing trace ${g.traceId}.`);const u={...g,metadata:(0,o.Jr)({dynamicSamplingContext:d})};return n?(0,a.Ok)((()=>n(u))):u};function y(e,{parentSpan:t,spanContext:n,forceTransaction:s,scope:i}){if(!(0,u.z)())return;const r=(0,a.aF)();let l;if(t&&!s)l=t.startChild(n);else if(t){const s=(0,g.j)(t),{traceId:i,spanId:o}=t.spanContext(),r=(0,c.Tt)(t);l=e.startTransaction({traceId:i,parentSpanId:o,parentSampled:r,...n,metadata:{dynamicSamplingContext:s,...n.metadata}})}else{const{traceId:t,dsc:s,parentSpanId:o,sampled:a}={...r.getPropagationContext(),...i.getPropagationContext()};l=e.startTransaction({traceId:t,parentSpanId:o,parentSampled:a,...n,metadata:{dynamicSamplingContext:s,...n.metadata}})}return i.setSpan(l),function(e,t,n){e&&((0,o.xp)(e,W,n),(0,o.xp)(e,A,t))}(l,i,r),l}function B(e){if(e.startTime){const t={...e};return t.startTimestamp=(0,c.$k)(e.startTime),delete t.startTime,t}return e}const A="_sentryScope",W="_sentryIsolationScope";function f(e){return{scope:e[A],isolationScope:e[W]}}},8069:(e,t,n)=>{"use strict";n.d(t,{Y:()=>u});var s=n(535),i=n(2343),o=n(1703),r=n(5659),a=n(5986),c=n(6754),g=n(3371),l=n(454),d=n(8903),I=n(4317);class u extends d.D{constructor(e,t){super(e),this._contexts={},this._hub=t||(0,r.Gd)(),this._name=e.name||"",this._metadata={...e.metadata},this._trimEnd=e.trimEnd,this.transaction=this;const n=this._metadata.dynamicSamplingContext;n&&(this._frozenDynamicSamplingContext={...n})}get name(){return this._name}set name(e){this.setName(e)}get metadata(){return{source:"custom",spanMetadata:{},...this._metadata,...this._attributes[c.Zj]&&{source:this._attributes[c.Zj]},...this._attributes[c.TE]&&{sampleRate:this._attributes[c.TE]}}}set metadata(e){this._metadata=e}setName(e,t="custom"){this._name=e,this.setAttribute(c.Zj,t)}updateName(e){return this._name=e,this}initSpanRecorder(e=1e3){this.spanRecorder||(this.spanRecorder=new d.g(e)),this.spanRecorder.add(this)}setContext(e,t){null===t?delete this._contexts[e]:this._contexts[e]=t}setMeasurement(e,t,n=""){this._measurements[e]={value:t,unit:n}}setMetadata(e){this._metadata={...this._metadata,...e}}end(e){const t=(0,g.$k)(e),n=this._finishTransaction(t);if(n)return this._hub.captureEvent(n)}toContext(){const e=super.toContext();return(0,s.Jr)({...e,name:this._name,trimEnd:this._trimEnd})}updateWithContext(e){return super.updateWithContext(e),this._name=e.name||"",this._trimEnd=e.trimEnd,this}getDynamicSamplingContext(){return(0,l.j)(this)}setHub(e){this._hub=e}getProfileId(){if(void 0!==this._contexts&&void 0!==this._contexts.profile)return this._contexts.profile.profile_id}_finishTransaction(e){if(void 0!==this._endTime)return;this._name||(o.X&&i.kg.warn("Transaction has no name, falling back to ``."),this._name=""),super.end(e);const t=this._hub.getClient();if(t&&t.emit&&t.emit("finishTransaction",this),!0!==this._sampled)return o.X&&i.kg.log("[Tracing] Discarding transaction because its trace was not chosen to be sampled."),void(t&&t.recordDroppedEvent("sample_rate","transaction"));const n=this.spanRecorder?this.spanRecorder.spans.filter((e=>e!==this&&(0,g.XU)(e).timestamp)):[];if(this._trimEnd&&n.length>0){const e=n.map((e=>(0,g.XU)(e).timestamp)).filter(Boolean);this._endTime=e.reduce(((e,t)=>e>t?e:t))}const{scope:r,isolationScope:c}=(0,I.I1)(this),{metadata:d}=this,{source:u}=d,p={contexts:{...this._contexts,trace:(0,g.wy)(this)},spans:n,start_timestamp:this._startTime,tags:this.tags,timestamp:this._endTime,transaction:this._name,type:"transaction",sdkProcessingMetadata:{...d,capturedSpanScope:r,capturedSpanIsolationScope:c,...(0,s.Jr)({dynamicSamplingContext:(0,l.j)(this)})},_metrics_summary:(0,a.y)(this),...u&&{transaction_info:{source:u}}};return Object.keys(this._measurements).length>0&&(o.X&&i.kg.log("[Measurements] Adding measurements to transaction",JSON.stringify(this._measurements,void 0,2)),p.measurements=this._measurements),o.X&&i.kg.log(`[Tracing] Finishing ${this.op} transaction: ${this._name}.`),p}}},9791:(e,t,n)=>{"use strict";n.d(t,{qG:()=>r,x1:()=>o});var s=n(7638),i=n(5659);function o(e){return(e||(0,i.Gd)()).getScope().getTransaction()}const r=s.qG},3379:(e,t,n)=>{"use strict";n.d(t,{gi:()=>c,yo:()=>g});var s=n(535),i=n(2844),o=n(454),r=n(5102),a=n(3371);function c(e,t){const{fingerprint:n,span:c,breadcrumbs:g,sdkProcessingMetadata:l}=t;!function(e,t){const{extra:n,tags:i,user:o,contexts:r,level:a,transactionName:c}=t,g=(0,s.Jr)(n);g&&Object.keys(g).length&&(e.extra={...g,...e.extra});const l=(0,s.Jr)(i);l&&Object.keys(l).length&&(e.tags={...l,...e.tags});const d=(0,s.Jr)(o);d&&Object.keys(d).length&&(e.user={...d,...e.user});const I=(0,s.Jr)(r);I&&Object.keys(I).length&&(e.contexts={...I,...e.contexts}),a&&(e.level=a),c&&(e.transaction=c)}(e,t),c&&function(e,t){e.contexts={trace:(0,a.wy)(t),...e.contexts};const n=(0,r.G)(t);if(n){e.sdkProcessingMetadata={dynamicSamplingContext:(0,o.j)(t),...e.sdkProcessingMetadata};const s=(0,a.XU)(n).description;s&&(e.tags={transaction:s,...e.tags})}}(e,c),function(e,t){e.fingerprint=e.fingerprint?(0,i.lE)(e.fingerprint):[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint}(e,n),function(e,t){const n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}(e,g),function(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}(e,l)}function g(e,t){const{extra:n,tags:s,user:i,contexts:o,level:r,sdkProcessingMetadata:a,breadcrumbs:c,fingerprint:g,eventProcessors:d,attachments:I,propagationContext:u,transactionName:p,span:h}=t;l(e,"extra",n),l(e,"tags",s),l(e,"user",i),l(e,"contexts",o),l(e,"sdkProcessingMetadata",a),r&&(e.level=r),p&&(e.transactionName=p),h&&(e.span=h),c.length&&(e.breadcrumbs=[...e.breadcrumbs,...c]),g.length&&(e.fingerprint=[...e.fingerprint,...g]),d.length&&(e.eventProcessors=[...e.eventProcessors,...d]),I.length&&(e.attachments=[...e.attachments,...I]),e.propagationContext={...e.propagationContext,...u}}function l(e,t,n){if(n&&Object.keys(n).length){e[t]={...e[t]};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[t][s]=n[s])}}},5102:(e,t,n)=>{"use strict";function s(e){return e.transaction}n.d(t,{G:()=>s})},7522:(e,t,n)=>{"use strict";n.d(t,{z:()=>i});var s=n(4487);function i(e){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const t=(0,s.s3)(),n=e||t&&t.getOptions();return!!n&&(n.enableTracing||"tracesSampleRate"in n||"tracesSampler"in n)}},8942:(e,t,n)=>{"use strict";n.d(t,{R:()=>u,U0:()=>h});var s=n(2844),i=n(1170),o=n(7321),r=n(1235),a=n(8007),c=n(1131),g=n(1195),l=n(350),d=n(3379),I=n(3371);function u(e,t,n,u,h,b){const{normalizeDepth:C=3,normalizeMaxBreadth:m=1e3}=e,Z={...t,event_id:t.event_id||n.event_id||(0,s.DM)(),timestamp:t.timestamp||(0,i.yW)()},G=n.integrations||e.integrations.map((e=>e.name));!function(e,t){const{environment:n,release:s,dist:i,maxValueLength:r=250}=t;"environment"in e||(e.environment="environment"in t?n:c.J),void 0===e.release&&void 0!==s&&(e.release=s),void 0===e.dist&&void 0!==i&&(e.dist=i),e.message&&(e.message=(0,o.$G)(e.message,r));const a=e.exception&&e.exception.values&&e.exception.values[0];a&&a.value&&(a.value=(0,o.$G)(a.value,r));const g=e.request;g&&g.url&&(g.url=(0,o.$G)(g.url,r))}(Z,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(Z,G),void 0===t.type&&function(e,t){const n=r.GLOBAL_OBJ._sentryDebugIds;if(!n)return;let s;const i=p.get(t);i?s=i:(s=new Map,p.set(t,s));const o=Object.keys(n).reduce(((e,i)=>{let o;const r=s.get(i);r?o=r:(o=t(i),s.set(i,o));for(let t=o.length-1;t>=0;t--){const s=o[t];if(s.filename){e[s.filename]=n[i];break}}return e}),{});try{e.exception.values.forEach((e=>{e.stacktrace.frames.forEach((e=>{e.filename&&(e.debug_id=o[e.filename])}))}))}catch(e){}}(Z,e.stackParser);const y=function(e,t){if(!t)return e;const n=e?e.clone():new l.sX;return n.update(t),n}(u,n.captureContext);n.mechanism&&(0,s.EG)(Z,n.mechanism);const B=h&&h.getEventProcessors?h.getEventProcessors():[],A=(0,l.lW)().getScopeData();if(b){const e=b.getScopeData();(0,d.yo)(A,e)}if(y){const e=y.getScopeData();(0,d.yo)(A,e)}const W=[...n.attachments||[],...A.attachments];W.length&&(n.attachments=W),(0,d.gi)(Z,A);const f=[...B,...(0,g.fH)(),...A.eventProcessors];return(0,g.RP)(f,Z,n).then((e=>(e&&function(e){const t={};try{e.exception.values.forEach((e=>{e.stacktrace.frames.forEach((e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)}))}))}catch(e){}if(0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const n=e.debug_meta.images;Object.keys(t).forEach((e=>{n.push({type:"sourcemap",code_file:e,debug_id:t[e]})}))}(e),"number"==typeof C&&C>0?function(e,t,n){if(!e)return null;const s={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map((e=>({...e,...e.data&&{data:(0,a.Fv)(e.data,t,n)}})))},...e.user&&{user:(0,a.Fv)(e.user,t,n)},...e.contexts&&{contexts:(0,a.Fv)(e.contexts,t,n)},...e.extra&&{extra:(0,a.Fv)(e.extra,t,n)}};return e.contexts&&e.contexts.trace&&s.contexts&&(s.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(s.contexts.trace.data=(0,a.Fv)(e.contexts.trace.data,t,n))),e.spans&&(s.spans=e.spans.map((e=>{const s=(0,I.XU)(e).data;return s&&(e.data=(0,a.Fv)(s,t,n)),e}))),s}(e,C,m):e)))}const p=new WeakMap;function h(e){if(e)return function(e){return e instanceof l.sX||"function"==typeof e}(e)||function(e){return Object.keys(e).some((e=>b.includes(e)))}(e)?{captureContext:e}:e}const b=["user","level","extra","contexts","tags","fingerprint","requestSession","propagationContext"]},3371:(e,t,n)=>{"use strict";n.d(t,{$k:()=>l,Hb:()=>g,Tt:()=>u,XU:()=>I,i0:()=>a,ve:()=>r,wy:()=>c});var s=n(535),i=n(7638),o=n(1170);const r=0,a=1;function c(e){const{spanId:t,traceId:n}=e.spanContext(),{data:i,op:o,parent_span_id:r,status:a,tags:c,origin:g}=I(e);return(0,s.Jr)({data:i,op:o,parent_span_id:r,span_id:t,status:a,tags:c,trace_id:n,origin:g})}function g(e){const{traceId:t,spanId:n}=e.spanContext(),s=u(e);return(0,i.$p)(t,n,s)}function l(e){return"number"==typeof e?d(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?d(e.getTime()):(0,o.ph)()}function d(e){return e>9999999999?e/1e3:e}function I(e){return function(e){return"function"==typeof e.getSpanJSON}(e)?e.getSpanJSON():"function"==typeof e.toJSON?e.toJSON():{}}function u(e){const{traceFlags:t}=e.spanContext();return Boolean(t&a)}},105:(e,t,n)=>{"use strict";n.d(t,{J:()=>s});const s="7.113.0"},5773:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DEFAULT_USER_INCLUDES:()=>Ce.rC,Handlers:()=>i,Http:()=>en,Hub:()=>U.Xb,Integrations:()=>Os,NodeClient:()=>Ee,SDK_VERSION:()=>Ae.J,SEMANTIC_ATTRIBUTE_SENTRY_OP:()=>We.$J,SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN:()=>We.S3,SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE:()=>We.TE,SEMANTIC_ATTRIBUTE_SENTRY_SOURCE:()=>We.Zj,Scope:()=>fe.sX,Undici:()=>Xn,addBreadcrumb:()=>c.n_,addEventProcessor:()=>te,addGlobalEventProcessor:()=>Ve.cc,addIntegration:()=>g.M5,addRequestDataToEvent:()=>Ce.S6,anrIntegration:()=>zn.z,autoDiscoverNodePerformanceMonitoringIntegrations:()=>He,captureCheckIn:()=>c.c,captureConsoleIntegration:()=>ps,captureEvent:()=>c.eN,captureException:()=>c.Tb,captureMessage:()=>c.uT,captureSession:()=>c.cg,close:()=>c.xv,configureScope:()=>c.e,consoleIntegration:()=>Bt,contextLinesIntegration:()=>Et,continueTrace:()=>ve.yn,createGetModuleFromFilename:()=>Kn,createTransport:()=>ie,cron:()=>Ps,debugIntegration:()=>bs,dedupeIntegration:()=>Zs,deepReadDirSync:()=>Tn,defaultIntegrations:()=>_n,defaultStackParser:()=>xn,enableAnrDetection:()=>Ln,endSession:()=>c.TM,extraErrorDataIntegration:()=>fs,extractRequestData:()=>Ce.XQ,extractTraceparentData:()=>Re.qG,flush:()=>c.yl,functionToStringIntegration:()=>u,getActiveSpan:()=>ve.HN,getActiveTransaction:()=>Re.x1,getClient:()=>c.s3,getCurrentHub:()=>U.Gd,getCurrentScope:()=>c.nZ,getDefaultIntegrations:()=>Jn,getGlobalScope:()=>fe.lW,getHubFromCarrier:()=>U.vi,getIsolationScope:()=>U.aF,getModuleFromFilename:()=>js,getSentryRelease:()=>Un,getSpanStatusFromHttpCode:()=>Se.ix,hapiErrorPlugin:()=>ts,hapiIntegration:()=>is,httpClientIntegration:()=>Xs,httpIntegration:()=>$t,inboundFiltersIntegration:()=>B,init:()=>Fn,isInitialized:()=>c.dk,lastEventId:()=>c.eW,linkedErrorsIntegration:()=>w,localVariablesIntegration:()=>dn,makeMain:()=>U.pj,makeNodeTransport:()=>it,metrics:()=>he,modulesIntegration:()=>hn,nativeNodeFetchintegration:()=>Sn,nodeContextIntegration:()=>Xt,onUncaughtExceptionIntegration:()=>Zn,onUnhandledRejectionIntegration:()=>Bn,parameterize:()=>be,reportingObserverIntegration:()=>Fs,requestDataIntegration:()=>Ge,rewriteFramesIntegration:()=>Us,runWithAsyncContext:()=>U.Ok,sessionTimingIntegration:()=>Ts,setContext:()=>c.v,setCurrentClient:()=>Be,setExtra:()=>c.sU,setExtras:()=>c.rJ,setHttpStatus:()=>Se.Q0,setMeasurement:()=>Xe.o,setTag:()=>c.YA,setTags:()=>c.mG,setUser:()=>c.av,spanStatusfromHttpCode:()=>Se.Zd,spotlightIntegration:()=>fn,startActiveSpan:()=>ve.y_,startInactiveSpan:()=>ve.qp,startSession:()=>c.yj,startSpan:()=>ve.GK,startSpanManual:()=>ve.V0,startTransaction:()=>c.Yr,trace:()=>ve.g4,trpcMiddleware:()=>Qn,withActiveSpan:()=>c._d,withIsolationScope:()=>c.wi,withMonitor:()=>c.sV,withScope:()=>c.$e});var s={};n.r(s),n.d(s,{FunctionToString:()=>p,InboundFilters:()=>A,LinkedErrors:()=>k});var i={};n.r(i),n.d(i,{errorHandler:()=>qn,extractRequestData:()=>jn,parseRequest:()=>On,requestHandler:()=>Mn,tracingHandler:()=>Pn,trpcMiddleware:()=>$n});var o={};n.r(o),n.d(o,{Anr:()=>zn.q,Console:()=>At,Context:()=>Yt,ContextLines:()=>Ut,Hapi:()=>os,Http:()=>en,LocalVariables:()=>ln,Modules:()=>bn,OnUncaughtException:()=>Gn,OnUnhandledRejection:()=>An,RequestData:()=>ye,Spotlight:()=>Vn,Undici:()=>Xn});var r={};n.r(r),n.d(r,{Apollo:()=>rs._,Express:()=>as.N1,GraphQL:()=>cs.k,Mongo:()=>gs._,Mysql:()=>ls.m,Postgres:()=>ds.E,Prisma:()=>Is.g});var a=n(535),c=n(4487),g=n(2967);let l;const d="FunctionToString",I=new WeakMap,u=(0,g._I)((()=>({name:d,setupOnce(){l=Function.prototype.toString;try{Function.prototype.toString=function(...e){const t=(0,a.HK)(this),n=I.has((0,c.s3)())&&void 0!==t?t:this;return l.apply(n,e)}}catch(e){}},setup(e){I.set(e,!0)}}))),p=(0,g.RN)(d,u);var h=n(2343),b=n(2844),C=n(7321),m=n(1703);const Z=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/],G=[/^.*\/healthcheck$/,/^.*\/healthy$/,/^.*\/live$/,/^.*\/ready$/,/^.*\/heartbeat$/,/^.*\/health$/,/^.*\/healthz$/],y="InboundFilters",B=(0,g._I)(((e={})=>({name:y,setupOnce(){},processEvent(t,n,s){const i=s.getOptions(),o=function(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:Z],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[],...e.disableTransactionDefaults?[]:G],ignoreInternal:void 0===e.ignoreInternal||e.ignoreInternal}}(e,i);return function(e,t){return t.ignoreInternal&&function(e){try{return"SentryError"===e.exception.values[0].type}catch(e){}return!1}(e)?(m.X&&h.kg.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${(0,b.jH)(e)}`),!0):function(e,t){return!(e.type||!t||!t.length)&&function(e){const t=[];let n;e.message&&t.push(e.message);try{n=e.exception.values[e.exception.values.length-1]}catch(e){}return n&&n.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`)),m.X&&0===t.length&&h.kg.error(`Could not extract message for event ${(0,b.jH)(e)}`),t}(e).some((e=>(0,C.U0)(e,t)))}(e,t.ignoreErrors)?(m.X&&h.kg.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${(0,b.jH)(e)}`),!0):function(e,t){if("transaction"!==e.type||!t||!t.length)return!1;const n=e.transaction;return!!n&&(0,C.U0)(n,t)}(e,t.ignoreTransactions)?(m.X&&h.kg.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${(0,b.jH)(e)}`),!0):function(e,t){if(!t||!t.length)return!1;const n=W(e);return!!n&&(0,C.U0)(n,t)}(e,t.denyUrls)?(m.X&&h.kg.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${(0,b.jH)(e)}.\nUrl: ${W(e)}`),!0):!function(e,t){if(!t||!t.length)return!0;const n=W(e);return!n||(0,C.U0)(n,t)}(e,t.allowUrls)&&(m.X&&h.kg.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${(0,b.jH)(e)}.\nUrl: ${W(e)}`),!0)}(t,o)?null:t}}))),A=(0,g.RN)(y,B);function W(e){try{let t;try{t=e.exception.values[0].stacktrace.frames}catch(e){}return t?function(e=[]){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&""!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null}(t):null}catch(t){return m.X&&h.kg.error(`Cannot extract url for event ${(0,b.jH)(e)}`),null}}var f=n(7597);function V(e,t,n=250,s,i,o,r){if(!(o.exception&&o.exception.values&&r&&(0,f.V9)(r.originalException,Error)))return;const a=o.exception.values.length>0?o.exception.values[o.exception.values.length-1]:void 0;var c,g;a&&(o.exception.values=(c=v(e,t,i,r.originalException,s,o.exception.values,a,0),g=n,c.map((e=>(e.value&&(e.value=(0,C.$G)(e.value,g)),e)))))}function v(e,t,n,s,i,o,r,a){if(o.length>=n+1)return o;let c=[...o];if((0,f.V9)(s[i],Error)){R(r,a);const o=e(t,s[i]),g=c.length;S(o,i,g,a),c=v(e,t,n,s[i],i,[o,...c],o,g)}return Array.isArray(s.errors)&&s.errors.forEach(((s,o)=>{if((0,f.V9)(s,Error)){R(r,a);const g=e(t,s),l=c.length;S(g,`errors[${o}]`,l,a),c=v(e,t,n,s,i,[g,...c],g,l)}})),c}function R(e,t){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,..."AggregateError"===e.type&&{is_exception_group:!0},exception_id:t}}function S(e,t,n,s){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,type:"chained",source:t,exception_id:n,parent_id:s}}var X=n(8007);function Y(e,t){return e(t.stack||"",1)}function H(e,t){const n={type:t.name||t.constructor.name,value:t.message},s=Y(e,t);return s.length&&(n.stacktrace={frames:s}),n}const N="LinkedErrors",w=(0,g._I)(((e={})=>{const t=e.limit||5,n=e.key||"cause";return{name:N,setupOnce(){},preprocessEvent(e,s,i){const o=i.getOptions();V(H,o.stackParser,o.maxValueLength,n,t,e,s)}}})),k=(0,g.RN)(N,w),K=s;var _=n(292),J=n(6893),F=n(8725);class E extends Error{constructor(e,t="warn"){super(e),this.message=e,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=t}}var U=n(5659);function x(e,t,n,s){return`${e}${t}${n}${Object.entries((0,a.Jr)(s)).sort(((e,t)=>e[0].localeCompare(t[0])))}`}function T(e){return e.replace(/[^\w]+/gi,"_")}function z(e){return e.replace(/[^\w\-.]+/gi,"_")}function L(e){return e.replace(/[^\w\-./]+/gi,"")}const Q=[["\n","\\n"],["\r","\\r"],["\t","\\t"],["\\","\\\\"],["|","\\u{7c}"],[",","\\u{2c}"]];function j(e){const t={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[L(s)]=(n=String(e[s]),[...n].reduce(((e,t)=>e+function(e){for(const[t,n]of Q)if(e===t)return n;return e}(t)),"")));var n;return t}var O=n(9015),P=n(454),M=n(8942);const D="Not capturing exception because it's already been captured.";class q{constructor(e){if(this._options=e,this._integrations={},this._integrationsInitialized=!1,this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=(0,_.vK)(e.dsn):m.X&&h.kg.warn("No DSN provided, client will not send events."),this._dsn){const t=function(e,t={}){const n="string"==typeof t?t:t.tunnel,s="string"!=typeof t&&t._metadata?t._metadata.sdk:void 0;return n||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",n=e.port?`:${e.port}`:"";return`${t}//${e.host}${n}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(e)}?${function(e,t){return(0,a._j)({sentry_key:e.publicKey,sentry_version:"7",...t&&{sentry_client:`${t.name}/${t.version}`}})}(e,s)}`}(this._dsn,e);this._transport=e.transport({recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}}captureException(e,t,n){if((0,b.YO)(e))return void(m.X&&h.kg.log(D));let s=t&&t.event_id;return this._process(this.eventFromException(e,t).then((e=>this._captureEvent(e,t,n))).then((e=>{s=e}))),s}captureMessage(e,t,n,s){let i=n&&n.event_id;const o=(0,f.Le)(e)?e:String(e),r=(0,f.pt)(e)?this.eventFromMessage(o,t,n):this.eventFromException(e,n);return this._process(r.then((e=>this._captureEvent(e,n,s))).then((e=>{i=e}))),i}captureEvent(e,t,n){if(t&&t.originalException&&(0,b.YO)(t.originalException))return void(m.X&&h.kg.log(D));let s=t&&t.event_id;const i=(e.sdkProcessingMetadata||{}).capturedSpanScope;return this._process(this._captureEvent(e,t,i||n).then((e=>{s=e}))),s}captureSession(e){"string"!=typeof e.release?m.X&&h.kg.warn("Discarded session because of missing or non-string release"):(this.sendSession(e),(0,O.CT)(e,{init:!1}))}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){const t=this._transport;return t?(this.metricsAggregator&&this.metricsAggregator.flush(),this._isClientDoneProcessing(e).then((n=>t.flush(e).then((e=>n&&e))))):(0,J.WD)(!0)}close(e){return this.flush(e).then((e=>(this.getOptions().enabled=!1,this.metricsAggregator&&this.metricsAggregator.close(),e)))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}setupIntegrations(e){(e&&!this._integrationsInitialized||this._isEnabled()&&!this._integrationsInitialized)&&this._setupIntegrations()}init(){this._isEnabled()&&this._setupIntegrations()}getIntegrationById(e){return this.getIntegrationByName(e)}getIntegrationByName(e){return this._integrations[e]}getIntegration(e){try{return this._integrations[e.id]||null}catch(t){return m.X&&h.kg.warn(`Cannot retrieve integration ${e.id} from the current Client`),null}}addIntegration(e){const t=this._integrations[e.name];(0,g.m7)(this,e,this._integrations),t||(0,g.uf)(this,[e])}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);let n=function(e,t,n,s){const i=(0,F.HY)(n),o=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){t&&(e.sdk=e.sdk||{},e.sdk.name=e.sdk.name||t.name,e.sdk.version=e.sdk.version||t.version,e.sdk.integrations=[...e.sdk.integrations||[],...t.integrations||[]],e.sdk.packages=[...e.sdk.packages||[],...t.packages||[]])}(e,n&&n.sdk);const r=(0,F.Cd)(e,i,s,t);delete e.sdkProcessingMetadata;const a=[{type:o},e];return(0,F.Jd)(r,[a])}(e,this._dsn,this._options._metadata,this._options.tunnel);for(const e of t.attachments||[])n=(0,F.BO)(n,(0,F.zQ)(e,this._options.transportOptions&&this._options.transportOptions.textEncoder));const s=this._sendEnvelope(n);s&&s.then((t=>this.emit("afterSendEvent",e,t)),null)}sendSession(e){const t=function(e,t,n,s){const i=(0,F.HY)(n),o={sent_at:(new Date).toISOString(),...i&&{sdk:i},...!!s&&t&&{dsn:(0,_.RA)(t)}},r="aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()];return(0,F.Jd)(o,[r])}(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}recordDroppedEvent(e,t,n){if(this._options.sendClientReports){const n=`${e}:${t}`;m.X&&h.kg.log(`Adding outcome: "${n}"`),this._outcomes[n]=this._outcomes[n]+1||1}}captureAggregateMetrics(e){m.X&&h.kg.log(`Flushing aggregated metrics, number of metrics: ${e.length}`);const t=function(e,t,n,s){const i={sent_at:(new Date).toISOString()};n&&n.sdk&&(i.sdk={name:n.sdk.name,version:n.sdk.version}),s&&t&&(i.dsn=(0,_.RA)(t));const o=function(e){const t=function(e){let t="";for(const n of e){const e=Object.entries(n.tags),s=e.length>0?`|#${e.map((([e,t])=>`${e}:${t}`)).join(",")}`:"";t+=`${n.name}@${n.unit}:${n.metric}|${n.metricType}${s}|T${n.timestamp}\n`}return t}(e);return[{type:"statsd",length:t.length},t]}(e);return(0,F.Jd)(i,[o])}(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}on(e,t){this._hooks[e]||(this._hooks[e]=[]),this._hooks[e].push(t)}emit(e,...t){this._hooks[e]&&this._hooks[e].forEach((e=>e(...t)))}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=(0,g.q4)(this,e),(0,g.uf)(this,e),this._integrationsInitialized=!0}_updateSessionFromEvent(e,t){let n=!1,s=!1;const i=t.exception&&t.exception.values;if(i){s=!0;for(const e of i){const t=e.mechanism;if(t&&!1===t.handled){n=!0;break}}}const o="ok"===e.status;(o&&0===e.errors||o&&n)&&((0,O.CT)(e,{...n&&{status:"crashed"},errors:e.errors||Number(s||n)}),this.captureSession(e))}_isClientDoneProcessing(e){return new J.cW((t=>{let n=0;const s=setInterval((()=>{0==this._numProcessing?(clearInterval(s),t(!0)):(n+=1,e&&n>=e&&(clearInterval(s),t(!1)))}),1)}))}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._transport}_prepareEvent(e,t,n,s=(0,U.aF)()){const i=this.getOptions(),o=Object.keys(this._integrations);return!t.integrations&&o.length>0&&(t.integrations=o),this.emit("preprocessEvent",e,t),(0,M.R)(i,e,t,n,this,s).then((e=>{if(null===e)return e;const t={...s.getPropagationContext(),...n?n.getPropagationContext():void 0};if((!e.contexts||!e.contexts.trace)&&t){const{traceId:s,spanId:i,parentSpanId:o,dsc:r}=t;e.contexts={trace:{trace_id:s,span_id:i,parent_span_id:o},...e.contexts};const a=r||(0,P._)(s,this,n);e.sdkProcessingMetadata={dynamicSamplingContext:a,...e.sdkProcessingMetadata}}return e}))}_captureEvent(e,t={},n){return this._processEvent(e,t,n).then((e=>e.event_id),(e=>{if(m.X){const t=e;"log"===t.logLevel?h.kg.log(t.message):h.kg.warn(t)}}))}_processEvent(e,t,n){const s=this.getOptions(),{sampleRate:i}=s,o=ee(e),r=$(e),a=e.type||"error",c=`before send for type \`${a}\``;if(r&&"number"==typeof i&&Math.random()>i)return this.recordDroppedEvent("sample_rate","error",e),(0,J.$2)(new E(`Discarding event because it's not included in the random sample (sampling rate = ${i})`,"log"));const g="replay_event"===a?"replay":a,l=(e.sdkProcessingMetadata||{}).capturedSpanIsolationScope;return this._prepareEvent(e,t,n,l).then((n=>{if(null===n)throw this.recordDroppedEvent("event_processor",g,e),new E("An event processor returned `null`, will not send event.","log");if(t.data&&!0===t.data.__sentry__)return n;const i=function(e,t,n){const{beforeSend:s,beforeSendTransaction:i}=e;return $(t)&&s?s(t,n):ee(t)&&i?i(t,n):t}(s,n,t);return function(e,t){const n=`${t} must return \`null\` or a valid event.`;if((0,f.J8)(e))return e.then((e=>{if(!(0,f.PO)(e)&&null!==e)throw new E(n);return e}),(e=>{throw new E(`${t} rejected with ${e}`)}));if(!(0,f.PO)(e)&&null!==e)throw new E(n);return e}(i,c)})).then((s=>{if(null===s)throw this.recordDroppedEvent("before_send",g,e),new E(`${c} returned \`null\`, will not send event.`,"log");const i=n&&n.getSession();!o&&i&&this._updateSessionFromEvent(i,s);const r=s.transaction_info;if(o&&r&&s.transaction!==e.transaction){const e="custom";s.transaction_info={...r,source:e}}return this.sendEvent(s,t),s})).then(null,(e=>{if(e instanceof E)throw e;throw this.captureException(e,{data:{__sentry__:!0},originalException:e}),new E(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`)}))}_process(e){this._numProcessing++,e.then((e=>(this._numProcessing--,e)),(e=>(this._numProcessing--,e)))}_sendEnvelope(e){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)return this._transport.send(e).then(null,(e=>{m.X&&h.kg.error("Error while sending event:",e)}));m.X&&h.kg.error("Transport disabled")}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.keys(e).map((t=>{const[n,s]=t.split(":");return{reason:n,category:s,quantity:e[t]}}))}}function $(e){return void 0===e.type}function ee(e){return"transaction"===e.type}function te(e){const t=(0,c.s3)();t&&t.addEventProcessor&&t.addEventProcessor(e)}const ne=6e4;const se=30;function ie(e,t,n=function(e){const t=[];function n(e){return t.splice(t.indexOf(e),1)[0]}return{$:t,add:function(s){if(!(void 0===e||t.lengthn(i))).then(null,(()=>n(i).then(null,(()=>{})))),i},drain:function(e){return new J.cW(((n,s)=>{let i=t.length;if(!i)return n(!0);const o=setTimeout((()=>{e&&e>0&&n(!1)}),e);t.forEach((e=>{(0,J.WD)(e).then((()=>{--i||(clearTimeout(o),n(!0))}),s)}))}))}}}(e.bufferSize||se)){let s={};function i(i){const o=[];if((0,F.gv)(i,((t,n)=>{const i=(0,F.mL)(n);if(function(e,t,n=Date.now()){return function(e,t){return e[t]||e.all||0}(e,t)>n}(s,i)){const s=oe(t,n);e.recordDroppedEvent("ratelimit_backoff",i,s)}else o.push(t)})),0===o.length)return(0,J.WD)();const r=(0,F.Jd)(i[0],o),a=t=>{(0,F.gv)(r,((n,s)=>{const i=oe(n,s);e.recordDroppedEvent(t,(0,F.mL)(s),i)}))};return n.add((()=>t({body:(0,F.V$)(r,e.textEncoder)}).then((e=>(void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&m.X&&h.kg.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),s=function(e,{statusCode:t,headers:n},s=Date.now()){const i={...e},o=n&&n["x-sentry-rate-limits"],r=n&&n["retry-after"];if(o)for(const e of o.trim().split(",")){const[t,n,,,o]=e.split(":",5),r=parseInt(t,10),a=1e3*(isNaN(r)?60:r);if(n)for(const e of n.split(";"))"metric_bucket"===e&&o&&!o.split(";").includes("custom")||(i[e]=s+a);else i.all=s+a}else r?i.all=s+function(e,t=Date.now()){const n=parseInt(`${e}`,10);if(!isNaN(n))return 1e3*n;const s=Date.parse(`${e}`);return isNaN(s)?ne:s-t}(r,s):429===t&&(i.all=s+6e4);return i}(s,e),e)),(e=>{throw a("network_error"),e})))).then((e=>e),(e=>{if(e instanceof E)return m.X&&h.kg.error("Skipped sending event because buffer is full."),a("queue_overflow"),(0,J.WD)();throw e}))}return i.__sentry__baseTransport__=!0,{send:i,flush:e=>n.drain(e)}}function oe(e,t){if("event"===t||"transaction"===t)return Array.isArray(e)?e[1]:void 0}var re=n(3371);const ae="s";var ce=n(1170);const ge={c:class{constructor(e){this._value=e}get weight(){return 1}add(e){this._value+=e}toString(){return`${this._value}`}},g:class{constructor(e){this._last=e,this._min=e,this._max=e,this._sum=e,this._count=1}get weight(){return 5}add(e){this._last=e,ethis._max&&(this._max=e),this._sum+=e,this._count++}toString(){return`${this._last}:${this._min}:${this._max}:${this._sum}:${this._count}`}},d:class{constructor(e){this._value=[e]}get weight(){return this._value.length}add(e){this._value.push(e)}toString(){return this._value.join(":")}},[ae]:class{constructor(e){this.first=e,this._value=new Set([e])}get weight(){return this._value.size}add(e){this._value.add(e)}toString(){return Array.from(this._value).map((e=>"string"==typeof e?function(e){let t=0;for(let n=0;n>>0}(e):e)).join(":")}}};var le=n(5986);class de{constructor(e){this._client=e,this._buckets=new Map,this._interval=setInterval((()=>this.flush()),5e3)}add(e,t,n,s="none",i={},o=(0,ce.ph)()){const r=Math.floor(o),a=z(t),c=j(i),g=T(s),l=x(e,a,g,c);let d=this._buckets.get(l);const I=d&&e===ae?d.metric.weight:0;d?(d.metric.add(n),d.timestampe));this._client.captureAggregateMetrics(e)}this._buckets.clear()}}close(){clearInterval(this._interval),this.flush()}}const Ie="MetricsAggregator",ue=(0,g._I)((()=>({name:Ie,setupOnce(){},setup(e){e.metricsAggregator=new de(e)}})));function pe(e,t,n,s={}){const i=(0,c.s3)(),o=(0,c.nZ)();if(i){if(!i.metricsAggregator)return void(m.X&&h.kg.warn("No metrics aggregator enabled. Please add the MetricsAggregator integration to use metrics APIs"));const{unit:r,tags:a,timestamp:c}=s,{release:g,environment:l}=i.getOptions(),d=o.getTransaction(),I={};g&&(I.release=g),l&&(I.environment=l),d&&(I.transaction=(0,re.XU)(d).description||""),m.X&&h.kg.log(`Adding value of ${n} to ${e} metric ${t}`),i.metricsAggregator.add(e,t,n,r,{...I,...a},c)}}const he={increment:function(e,t=1,n){pe("c",e,t,n)},distribution:function(e,t,n){pe("d",e,t,n)},set:function(e,t,n){pe(ae,e,t,n)},gauge:function(e,t,n){pe("g",e,t,n)},MetricsAggregator:(0,g.RN)(Ie,ue),metricsAggregatorIntegration:ue};function be(e,...t){const n=new String(String.raw(e,...t));return n.__sentry_template_string__=e.join("\0").replace(/%/g,"%%").replace(/\0/g,"%s"),n.__sentry_template_values__=t,n}var Ce=n(771);const me={include:{cookies:!0,data:!0,headers:!0,ip:!1,query_string:!0,url:!0,user:{id:!0,username:!0,email:!0}},transactionNamingScheme:"methodPath"},Ze="RequestData",Ge=(0,g._I)(((e={})=>{const t=Ce.S6,n={...me,...e,include:{method:!0,...me.include,...e.include,user:e.include&&"boolean"==typeof e.include.user?e.include.user:{...me.include.user,...(e.include||{}).user}}};return{name:Ze,setupOnce(){},processEvent(e,s,i){const{transactionNamingScheme:o}=n,{sdkProcessingMetadata:r={}}=e,a=r.request;if(!a)return e;const c=r.requestDataOptionsFromExpressHandler||r.requestDataOptionsFromGCPWrapper||function(e){const{transactionNamingScheme:t,include:{ip:n,user:s,...i}}=e,o=[];for(const[e,t]of Object.entries(i))t&&o.push(e);let r;if(void 0===s)r=!0;else if("boolean"==typeof s)r=s;else{const e=[];for(const[t,n]of Object.entries(s))n&&e.push(t);r=e}return{include:{ip:n,user:r,request:0!==o.length?o:void 0,transaction:t}}}(n),g=t(e,a,c);if("transaction"===e.type||"handler"===o)return g;const l=a._sentryTransaction;if(l){const e=(0,re.XU)(l).description||"",t="sentry.javascript.nextjs"===function(e){try{return e.getOptions()._metadata.sdk.name}catch(e){return}}(i)?e.startsWith("/api"):"path"!==o,[n]=(0,Ce.oA)(a,{path:!0,method:t,customRoute:e});g.transaction=n}return g}}})),ye=(0,g.RN)(Ze,Ge);function Be(e){const t=(0,U.Gd)().getStackTop();t.client=e,t.scope.setClient(e)}var Ae=n(105),We=n(6754),fe=n(350),Ve=n(1195),ve=n(4317),Re=n(9791),Se=n(7387),Xe=n(9080),Ye=n(6046);function He(){const e=Ye.G.map((e=>{try{return e()}catch(e){return}})).filter((e=>!!e));return 0===e.length&&h.kg.warn("Performance monitoring integrations could not be automatically loaded."),e.filter((e=>!!e.loadDependency()))}const Ne=require("os"),we=require("util");class ke{constructor(e){this._client=e,this._buckets=new Map,this._bucketsTotalWeight=0,this._interval=setInterval((()=>this._flush()),1e4),this._interval.unref&&this._interval.unref(),this._flushShift=Math.floor(1e4*Math.random()/1e3),this._forceFlush=!1}add(e,t,n,s="none",i={},o=(0,ce.ph)()){const r=Math.floor(o),a=z(t),c=j(i),g=T(s),l=x(e,a,g,c);let d=this._buckets.get(l);const I=d&&e===ae?d.metric.weight:0;d?(d.metric.add(n),d.timestamp=1e4&&this.flush()}flush(){this._forceFlush=!0,this._flush()}close(){this._forceFlush=!0,clearInterval(this._interval),this._flush()}_flush(){if(this._forceFlush)return this._forceFlush=!1,this._bucketsTotalWeight=0,this._captureMetrics(this._buckets),void this._buckets.clear();const e=Math.floor((0,ce.ph)())-10-this._flushShift,t=new Map;for(const[n,s]of this._buckets)s.timestamp<=e&&(t.set(n,s),this._bucketsTotalWeight-=s.metric.weight);for(const[e]of t)this._buckets.delete(e);this._captureMetrics(t)}_captureMetrics(e){if(e.size>0&&this._client.captureAggregateMetrics){const t=Array.from(e).map((([,e])=>e));this._client.captureAggregateMetrics(t)}}}class Ke{constructor(e,t){this._client=e,this.flushTimeout=60,this._pendingAggregates={},this._isEnabled=!0,this._intervalId=setInterval((()=>this.flush()),1e3*this.flushTimeout),this._intervalId.unref&&this._intervalId.unref(),this._sessionAttrs=t}flush(){const e=this.getSessionAggregates();0!==e.aggregates.length&&(this._pendingAggregates={},this._client.sendSession(e))}getSessionAggregates(){const e=Object.keys(this._pendingAggregates).map((e=>this._pendingAggregates[parseInt(e)])),t={attrs:this._sessionAttrs,aggregates:e};return(0,a.Jr)(t)}close(){clearInterval(this._intervalId),this._isEnabled=!1,this.flush()}incrementSessionStatusCount(){if(!this._isEnabled)return;const e=(0,c.nZ)(),t=e.getRequestSession();t&&t.status&&(this._incrementSessionStatusCount(t.status,new Date),e.setRequestSession(void 0))}_incrementSessionStatusCount(e,t){const n=new Date(t).setSeconds(0,0);this._pendingAggregates[n]=this._pendingAggregates[n]||{};const s=this._pendingAggregates[n];switch(s.started||(s.started=new Date(n).toISOString()),e){case"errored":return s.errored=(s.errored||0)+1,s.errored;case"ok":return s.exited=(s.exited||0)+1,s.exited;default:return s.crashed=(s.crashed||0)+1,s.crashed}}}var _e=n(3207),Je=n(5102);class Fe extends q{constructor(e){(0,_e.T)(),super(e),e._experiments&&e._experiments.metricsAggregator&&(this.metricsAggregator=new ke(this))}eventFromException(e,t){return(0,J.WD)(function(e,t,n,s){const i="function"==typeof e?e().getClient():e;let o=n;const r=s&&s.data&&s.data.mechanism||{handled:!0,type:"generic"};let c;if(!(0,f.VZ)(n)){if((0,f.PO)(n)){const e=i&&i.getOptions().normalizeDepth;c={__serialized__:(0,X.Qy)(n,e)};const t=function(e){if("name"in e&&"string"==typeof e.name){let t=`'${e.name}' captured as exception`;return"message"in e&&"string"==typeof e.message&&(t+=` with message '${e.message}'`),t}return"message"in e&&"string"==typeof e.message?e.message:`Object captured as exception with keys: ${(0,a.zf)(e)}`}(n);o=s&&s.syntheticException||new Error(t),o.message=t}else o=s&&s.syntheticException||new Error(n),o.message=n;r.synthetic=!0}const g={exception:{values:[H(t,o)]}};return c&&(g.extra=c),(0,b.Db)(g,void 0,void 0),(0,b.EG)(g,r),{...g,event_id:s&&s.event_id}}((0,c.s3)(),this._options.stackParser,e,t))}eventFromMessage(e,t="info",n){return(0,J.WD)(function(e,t,n="info",s,i){const o={event_id:s&&s.event_id,level:n};if(i&&s&&s.syntheticException){const n=Y(e,s.syntheticException);n.length&&(o.exception={values:[{value:t,stacktrace:{frames:n}}]})}if((0,f.Le)(t)){const{__sentry_template_string__:e,__sentry_template_values__:n}=t;return o.logentry={message:e,params:n},o}return o.message=t,o}(this._options.stackParser,e,t,n,this._options.attachStacktrace))}captureException(e,t,n){if(this._options.autoSessionTracking&&this._sessionFlusher&&n){const e=n.getRequestSession();e&&"ok"===e.status&&(e.status="errored")}return super.captureException(e,t,n)}captureEvent(e,t,n){if(this._options.autoSessionTracking&&this._sessionFlusher&&n&&"exception"===(e.type||"exception")&&e.exception&&e.exception.values&&e.exception.values.length>0){const e=n.getRequestSession();e&&"ok"===e.status&&(e.status="errored")}return super.captureEvent(e,t,n)}close(e){return this._sessionFlusher&&this._sessionFlusher.close(),super.close(e)}initSessionFlusher(){const{release:e,environment:t}=this._options;e?this._sessionFlusher=new Ke(this,{release:e,environment:t}):m.X&&h.kg.warn("Cannot initialise an instance of SessionFlusher if no release is provided!")}captureCheckIn(e,t,n){const s="checkInId"in e&&e.checkInId?e.checkInId:(0,b.DM)();if(!this._isEnabled())return m.X&&h.kg.warn("SDK not enabled, will not capture checkin."),s;const i=this.getOptions(),{release:o,environment:r,tunnel:c}=i,g={check_in_id:s,monitor_slug:e.monitorSlug,status:e.status,release:o,environment:r};"duration"in e&&(g.duration=e.duration),t&&(g.monitor_config={schedule:t.schedule,checkin_margin:t.checkinMargin,max_runtime:t.maxRuntime,timezone:t.timezone});const[l,d]=this._getTraceInfoFromScope(n);d&&(g.contexts={trace:d});const I=function(e,t,n,s,i){const o={sent_at:(new Date).toISOString()};n&&n.sdk&&(o.sdk={name:n.sdk.name,version:n.sdk.version}),s&&i&&(o.dsn=(0,_.RA)(i)),t&&(o.trace=(0,a.Jr)(t));const r=function(e){return[{type:"check_in"},e]}(e);return(0,F.Jd)(o,[r])}(g,l,this.getSdkMetadata(),c,this.getDsn());return m.X&&h.kg.info("Sending checkin:",e.monitorSlug,e.status),this._sendEnvelope(I),s}_captureRequestSession(){this._sessionFlusher?this._sessionFlusher.incrementSessionStatusCount():m.X&&h.kg.warn("Discarded request mode session because autoSessionTracking option was disabled")}_prepareEvent(e,t,n,s){return this._options.platform&&(e.platform=e.platform||this._options.platform),this._options.runtime&&(e.contexts={...e.contexts,runtime:(e.contexts||{}).runtime||this._options.runtime}),this._options.serverName&&(e.server_name=e.server_name||this._options.serverName),super._prepareEvent(e,t,n,s)}_getTraceInfoFromScope(e){if(!e)return[void 0,void 0];const t=e.getSpan();if(t)return[(0,Je.G)(t)?(0,P.j)(t):void 0,(0,re.wy)(t)];const{traceId:n,spanId:s,parentSpanId:i,dsc:o}=e.getPropagationContext(),r={trace_id:n,span_id:s,parent_span_id:i};return o?[o,r]:[(0,P._)(n,this,e),r]}}class Ee extends Fe{constructor(e){!function(e,t,n=[t],s="npm"){const i=e._metadata||{};i.sdk||(i.sdk={name:`sentry.javascript.${t}`,packages:n.map((e=>({name:`${s}:@sentry/${e}`,version:Ae.J}))),version:Ae.J}),e._metadata=i}(e,"node"),e.transportOptions={textEncoder:new we.TextEncoder,...e.transportOptions},super({...e,platform:"node",runtime:{name:"node",version:global.process.version},serverName:e.serverName||global.process.env.SENTRY_NAME||Ne.hostname()})}}function Ue(e,t){return null!=e?e:t()}var xe=n(3685),Te=n(5687),ze=n(2781),Le=n(7310),Qe=n(9796),je=n(4307),Oe=n(1808),Pe=n(4404);const Me=Symbol("AgentBaseInternalState");class De extends xe.Agent{constructor(e){super(e),this[Me]={}}isSecureEndpoint(e){if(e){if("boolean"==typeof e.secureEndpoint)return e.secureEndpoint;if("string"==typeof e.protocol)return"https:"===e.protocol}const{stack:t}=new Error;return"string"==typeof t&&t.split("\n").some((e=>-1!==e.indexOf("(https.js:")||-1!==e.indexOf("node:https:")))}createSocket(e,t,n){const s={...t,secureEndpoint:this.isSecureEndpoint(t)};Promise.resolve().then((()=>this.connect(e,s))).then((i=>{if(i instanceof xe.Agent)return i.addRequest(e,s);this[Me].currentSocket=i,super.createSocket(e,t,n)}),n)}createConnection(){const e=this[Me].currentSocket;if(this[Me].currentSocket=void 0,!e)throw new Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return Ue(this[Me].defaultPort,(()=>"https:"===this.protocol?443:80))}set defaultPort(e){this[Me]&&(this[Me].defaultPort=e)}get protocol(){return Ue(this[Me].protocol,(()=>this.isSecureEndpoint()?"https:":"http:"))}set protocol(e){this[Me]&&(this[Me].protocol=e)}}function qe(...e){h.kg.log("[https-proxy-agent:parse-proxy-response]",...e)}function $e(...e){h.kg.log("[https-proxy-agent]",...e)}class et extends De{static __initStatic(){this.protocols=["http","https"]}constructor(e,t){super(t),this.options={},this.proxy="string"==typeof e?new Le.URL(e):e,this.proxyHeaders=Ue((0,je.x)([t,"optionalAccess",e=>e.headers]),(()=>({}))),$e("Creating new HttpsProxyAgent instance: %o",this.proxy.href);const n=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),s=this.proxy.port?parseInt(this.proxy.port,10):"https:"===this.proxy.protocol?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...t?nt(t,"headers"):null,host:n,port:s}}async connect(e,t){const{proxy:n}=this;if(!t.host)throw new TypeError('No "host" provided');let s;if("https:"===n.protocol){$e("Creating `tls.Socket`: %o",this.connectOpts);const e=this.connectOpts.servername||this.connectOpts.host;s=Pe.connect({...this.connectOpts,servername:e&&Oe.isIP(e)?void 0:e})}else $e("Creating `net.Socket`: %o",this.connectOpts),s=Oe.connect(this.connectOpts);const i="function"==typeof this.proxyHeaders?this.proxyHeaders():{...this.proxyHeaders},o=Oe.isIPv6(t.host)?`[${t.host}]`:t.host;let r=`CONNECT ${o}:${t.port} HTTP/1.1\r\n`;if(n.username||n.password){const e=`${decodeURIComponent(n.username)}:${decodeURIComponent(n.password)}`;i["Proxy-Authorization"]=`Basic ${Buffer.from(e).toString("base64")}`}i.Host=`${o}:${t.port}`,i["Proxy-Connection"]||(i["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(const e of Object.keys(i))r+=`${e}: ${i[e]}\r\n`;const a=function(e){return new Promise(((t,n)=>{let s=0;const i=[];function o(){const a=e.read();a?function(a){i.push(a),s+=a.length;const c=Buffer.concat(i,s),g=c.indexOf("\r\n\r\n");if(-1===g)return qe("have not received end of HTTP headers yet..."),void o();const l=c.slice(0,g).toString("ascii").split("\r\n"),d=l.shift();if(!d)return e.destroy(),n(new Error("No header received from proxy CONNECT response"));const I=d.split(" "),u=+I[1],p=I.slice(2).join(" "),h={};for(const t of l){if(!t)continue;const s=t.indexOf(":");if(-1===s)return e.destroy(),n(new Error(`Invalid header from proxy CONNECT response: "${t}"`));const i=t.slice(0,s).toLowerCase(),o=t.slice(s+1).trimStart(),r=h[i];"string"==typeof r?h[i]=[r,o]:Array.isArray(r)?r.push(o):h[i]=o}qe("got proxy server response: %o %o",d,h),r(),t({connect:{statusCode:u,statusText:p,headers:h},buffered:c})}(a):e.once("readable",o)}function r(){e.removeListener("end",a),e.removeListener("error",c),e.removeListener("readable",o)}function a(){r(),qe("onend"),n(new Error("Proxy connection ended before receiving CONNECT response"))}function c(e){r(),qe("onerror %o",e),n(e)}e.on("error",c),e.on("end",a),o()}))}(s);s.write(`${r}\r\n`);const{connect:c,buffered:g}=await a;if(e.emit("proxyConnect",c),this.emit("proxyConnect",c,e),200===c.statusCode){if(e.once("socket",tt),t.secureEndpoint){$e("Upgrading socket connection to TLS");const e=t.servername||t.host;return Pe.connect({...nt(t,"host","path","port"),socket:s,servername:Oe.isIP(e)?void 0:e})}return s}s.destroy();const l=new Oe.Socket({writable:!1});return l.readable=!0,e.once("socket",(e=>{$e("Replaying proxy buffer for failed request"),e.push(g),e.push(null)})),l}}function tt(e){e.resume()}function nt(e,...t){const n={};let s;for(s in e)t.includes(s)||(n[s]=e[s]);return n}et.__initStatic();const st=32768;function it(e){let t;try{t=new Le.URL(e.url)}catch(t){return(0,h.Cf)((()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")})),ie(e,(()=>Promise.resolve({})))}const n="https:"===t.protocol,s=function(e,t){const{no_proxy:n}=process.env;return n&&n.split(",").some((t=>e.host.endsWith(t)||e.hostname.endsWith(t)))?void 0:t}(t,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),i=n?Te:xe,o=void 0!==e.keepAlive&&e.keepAlive,r=s?new et(s):new i.Agent({keepAlive:o,maxSockets:30,timeout:2e3}),a=function(e,t,n){const{hostname:s,pathname:i,port:o,protocol:r,search:a}=new Le.URL(e.url);return function(c){return new Promise(((g,l)=>{let d=function(e){return new ze.Readable({read(){this.push(e),this.push(null)}})}(c.body);const I={...e.headers};c.body.length>st&&(I["content-encoding"]="gzip",d=d.pipe((0,Qe.createGzip)()));const u=t.request({method:"POST",agent:n,headers:I,hostname:s,path:`${i}${a}`,port:o,protocol:r,ca:e.caCerts},(e=>{e.on("data",(()=>{})),e.on("end",(()=>{})),e.setEncoding("utf8");const t=Ue(e.headers["retry-after"],(()=>null)),n=Ue(e.headers["x-sentry-rate-limits"],(()=>null));g({statusCode:e.statusCode,headers:{"retry-after":t,"x-sentry-rate-limits":Array.isArray(n)?n[0]:n}})}));u.on("error",l),d.pipe(u)}))}}(e,Ue(e.httpModule,(()=>i)),r);return ie(e,a)}var ot=n(6147),rt=n(1235),at=n(7638),ct=n(9656);const gt=require("domain");function lt(){return gt.active}function dt(){const e=lt();if(e)return(0,U.uZ)(e),(0,U.vi)(e)}function It(e,t){const n=lt();if(n&&(0,je.x)([t,"optionalAccess",e=>e.reuseExisting]))return e();const s=gt.create(),i=function(e){const t={};return(0,U.uZ)(t,e),(0,U.vi)(t)}(n?(0,U.vi)(n):void 0);return(0,U.j0)(s,i),s.bind((()=>e()))()}const ut=require("async_hooks");let pt;function ht(){ct.V.major>=14?function(){function e(){return pt.getStore()}pt||(pt=new ut.AsyncLocalStorage),(0,U.$b)({getCurrentHub:e,runWithAsyncContext:function(t,n){const s=e();if(s&&(0,je.x)([n,"optionalAccess",e=>e.reuseExisting]))return t();const i=function(e){const t={};return(0,U.uZ)(t,e),(0,U.vi)(t)}(s);return pt.run(i,(()=>t()))}})}():(0,U.$b)({getCurrentHub:dt,runWithAsyncContext:It})}var bt=n(9729);function Ct(e){const t="console";(0,bt.Hj)(t,e),(0,bt.D2)(t,mt)}function mt(){"console"in rt.GLOBAL_OBJ&&h.RU.forEach((function(e){e in rt.GLOBAL_OBJ.console&&(0,a.hl)(rt.GLOBAL_OBJ.console,e,(function(t){return h.LD[e]=t,function(...t){const n={args:t,level:e};(0,bt.rK)("console",n);const s=h.LD[e];s&&s.apply(rt.GLOBAL_OBJ.console,t)}}))}))}const Zt=["fatal","error","warning","log","info","debug"];function Gt(e){return"warn"===e?"warning":Zt.includes(e)?e:"log"}const yt="Console",Bt=(0,g._I)((()=>({name:yt,setupOnce(){},setup(e){Ct((({args:t,level:n})=>{(0,c.s3)()===e&&(0,c.n_)({category:"console",level:Gt(n),message:we.format.apply(void 0,t)},{input:[...t],level:n})}))}}))),At=(0,g.RN)(yt,Bt),Wt=require("child_process"),ft=require("fs");var Vt=n(1017);const vt=(0,we.promisify)(ft.readFile),Rt=(0,we.promisify)(ft.readdir),St="Context",Xt=(0,g._I)(((e={})=>{let t;const n={app:!0,os:!0,device:!0,culture:!0,cloudResource:!0,...e};return{name:St,setupOnce(){},processEvent:e=>async function(e){void 0===t&&(t=async function(){const e={};if(n.os&&(e.os=await async function(){const e=Ne.platform();switch(e){case"darwin":return async function(){const e={kernel_version:Ne.release(),name:"Mac OS X",version:"10."+(Number(Ne.release().split(".")[0])-4)};try{const t=await new Promise(((e,t)=>{(0,Wt.execFile)("/usr/bin/sw_vers",((n,s)=>{n?t(n):e(s)}))}));e.name=kt(/^ProductName:\s+(.*)$/m,t),e.version=kt(/^ProductVersion:\s+(.*)$/m,t),e.build=kt(/^BuildVersion:\s+(.*)$/m,t)}catch(e){}return e}();case"linux":return async function(){const e={kernel_version:Ne.release(),name:"Linux"};try{const t=await Rt("/etc"),n=Nt.find((e=>t.includes(e.name)));if(!n)return e;const s=(0,Vt.join)("/etc",n.name),i=(await vt(s,{encoding:"utf-8"})).toLowerCase(),{distros:o}=n;e.name=o.find((e=>i.indexOf(Kt(e))>=0))||o[0];const r=Kt(e.name);e.version=wt[r](i)}catch(e){}return e}();default:return{name:Ht[e]||e,version:Ne.release()}}}()),n.app&&(e.app=function(){const e=process.memoryUsage().rss;return{app_start_time:new Date(Date.now()-1e3*process.uptime()).toISOString(),app_memory:e}}()),n.device&&(e.device=function(e){const t={};let n;try{n=Ne.uptime&&Ne.uptime()}catch(e){}if("number"==typeof n&&(t.boot_time=new Date(Date.now()-1e3*n).toISOString()),t.arch=Ne.arch(),(!0===e||e.memory)&&(t.memory_size=Ne.totalmem(),t.free_memory=Ne.freemem()),!0===e||e.cpu){const e=Ne.cpus();if(e&&e.length){const n=e[0];t.processor_count=e.length,t.cpu_description=n.model,t.processor_frequency=n.speed}}return t}(n.device)),n.culture){const t=function(){try{if("string"!=typeof process.versions.icu)return;const e=new Date(9e8);if("enero"===new Intl.DateTimeFormat("es",{month:"long"}).format(e)){const e=Intl.DateTimeFormat().resolvedOptions();return{locale:e.locale,timezone:e.timeZone}}}catch(e){}}();t&&(e.culture=t)}return n.cloudResource&&(e.cloud_resource=process.env.VERCEL?{"cloud.provider":"vercel","cloud.region":process.env.VERCEL_REGION}:process.env.AWS_REGION?{"cloud.provider":"aws","cloud.region":process.env.AWS_REGION,"cloud.platform":process.env.AWS_EXECUTION_ENV}:process.env.GCP_PROJECT?{"cloud.provider":"gcp"}:process.env.ALIYUN_REGION_ID?{"cloud.provider":"alibaba_cloud","cloud.region":process.env.ALIYUN_REGION_ID}:process.env.WEBSITE_SITE_NAME&&process.env.REGION_NAME?{"cloud.provider":"azure","cloud.region":process.env.REGION_NAME}:process.env.IBM_CLOUD_REGION?{"cloud.provider":"ibm_cloud","cloud.region":process.env.IBM_CLOUD_REGION}:process.env.TENCENTCLOUD_REGION?{"cloud.provider":"tencent_cloud","cloud.region":process.env.TENCENTCLOUD_REGION,"cloud.account.id":process.env.TENCENTCLOUD_APPID,"cloud.availability_zone":process.env.TENCENTCLOUD_ZONE}:process.env.NETLIFY?{"cloud.provider":"netlify"}:process.env.FLY_REGION?{"cloud.provider":"fly.io","cloud.region":process.env.FLY_REGION}:process.env.DYNO?{"cloud.provider":"heroku"}:void 0),e}());const s=(i=await t,(0,je.x)([i,"optionalAccess",e=>e.app,"optionalAccess",e=>e.app_memory])&&(i.app.app_memory=process.memoryUsage().rss),(0,je.x)([i,"optionalAccess",e=>e.device,"optionalAccess",e=>e.free_memory])&&(i.device.free_memory=Ne.freemem()),i);var i;return e.contexts={...e.contexts,app:{...s.app,...(0,je.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.app])},os:{...s.os,...(0,je.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.os])},device:{...s.device,...(0,je.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.device])},culture:{...s.culture,...(0,je.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.culture])},cloud_resource:{...s.cloud_resource,...(0,je.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.cloud_resource])}},e}(e)}})),Yt=(0,g.RN)(St,Xt),Ht={aix:"IBM AIX",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",win32:"Windows"},Nt=[{name:"fedora-release",distros:["Fedora"]},{name:"redhat-release",distros:["Red Hat Linux","Centos"]},{name:"redhat_version",distros:["Red Hat Linux"]},{name:"SuSE-release",distros:["SUSE Linux"]},{name:"lsb-release",distros:["Ubuntu Linux","Arch Linux"]},{name:"debian_version",distros:["Debian"]},{name:"debian_release",distros:["Debian"]},{name:"arch-release",distros:["Arch Linux"]},{name:"gentoo-release",distros:["Gentoo Linux"]},{name:"novell-release",distros:["SUSE Linux"]},{name:"alpine-release",distros:["Alpine Linux"]}],wt={alpine:e=>e,arch:e=>kt(/distrib_release=(.*)/,e),centos:e=>kt(/release ([^ ]+)/,e),debian:e=>e,fedora:e=>kt(/release (..)/,e),mint:e=>kt(/distrib_release=(.*)/,e),red:e=>kt(/release ([^ ]+)/,e),suse:e=>kt(/VERSION = (.*)\n/,e),ubuntu:e=>kt(/distrib_release=(.*)/,e)};function kt(e,t){const n=e.exec(t);return n?n[1]:void 0}function Kt(e){return e.split(" ")[0].toLowerCase()}class _t{constructor(e){this._maxSize=e,this._cache=new Map}get size(){return this._cache.size}get(e){const t=this._cache.get(e);if(void 0!==t)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){this._cache.size>=this._maxSize&&this._cache.delete(this._cache.keys().next().value),this._cache.set(e,t)}remove(e){const t=this._cache.get(e);return t&&this._cache.delete(e),t}clear(){this._cache.clear()}keys(){return Array.from(this._cache.keys())}values(){const e=[];return this._cache.forEach((t=>e.push(t))),e}}const Jt=new _t(100),Ft="ContextLines",Et=(0,g._I)(((e={})=>{const t=void 0!==e.frameContextLines?e.frameContextLines:7;return{name:Ft,setupOnce(){},processEvent:e=>async function(e,t){const n={},s=[];if(t>0&&(0,je.x)([e,"access",e=>e.exception,"optionalAccess",e=>e.values]))for(const t of e.exception.values)if((0,je.x)([t,"access",e=>e.stacktrace,"optionalAccess",e=>e.frames]))for(let e=t.stacktrace.frames.length-1;e>=0;e--){const i=t.stacktrace.frames[e];!i.filename||n[i.filename]||Jt.get(i.filename)||(s.push(Tt(i.filename)),n[i.filename]=1)}if(s.length>0&&await Promise.all(s),t>0&&(0,je.x)([e,"access",e=>e.exception,"optionalAccess",e=>e.values]))for(const n of e.exception.values)n.stacktrace&&n.stacktrace.frames&&await xt(n.stacktrace.frames,t);return e}(e,t)}})),Ut=(0,g.RN)(Ft,Et);function xt(e,t){for(const n of e)if(n.filename&&void 0===n.context_line){const e=Jt.get(n.filename);if(e)try{(0,b.go)(e,n,t)}catch(e){}}}async function Tt(e){const t=Jt.get(e);if(null===t)return null;if(void 0!==t)return t;let n=null;try{const t=await(s=e,new Promise(((e,t)=>{(0,ft.readFile)(s,"utf8",((n,s)=>{n?t(n):e(s)}))})));n=t.split("\n")}catch(e){}var s;return Jt.set(e,n),n}function zt(e,t){const n=t&&function(e){return void 0!==e.getClient}(t)?t.getClient():t,s=n&&n.getDsn(),i=n&&n.getOptions().tunnel;return function(e,t){return!!t&&e.includes(t.host)}(e,s)||function(e,t){return!!t&&Lt(e)===Lt(t)}(e,i)}function Lt(e){return"/"===e[e.length-1]?e.slice(0,-1):e}var Qt=n(7522),jt=n(9181);const Ot="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function Pt(e){const{protocol:t,hostname:n,port:s}=qt(e),i=e.pathname||"/";return`${t}//${e.auth?function(e){const[t,n]=e.split(":");return`${t?"[Filtered]":""}:${n?"[Filtered]":""}@`}(e.auth):""}${n}${s}${i}`}function Mt(e,t,n){if(!e)return e;let[s,i]=e.split(" ");return t.host&&!t.protocol&&(t.protocol=(0,je.x)([n,"optionalAccess",e=>e.agent,"optionalAccess",e=>e.protocol]),i=Pt(t)),(0,je.x)([i,"optionalAccess",e=>e.startsWith,"call",e=>e("///")])&&(i=i.slice(2)),`${s} ${i}`}function Dt(e){const t={protocol:e.protocol,hostname:"string"==typeof e.hostname&&e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,hash:e.hash,search:e.search,pathname:e.pathname,path:`${e.pathname||""}${e.search||""}`,href:e.href};return""!==e.port&&(t.port=Number(e.port)),(e.username||e.password)&&(t.auth=`${e.username}:${e.password}`),t}function qt(e){const t=e.protocol||"",n=e.hostname||e.host||"";return{protocol:t,hostname:n,port:!e.port||80===e.port||443===e.port||/^(.*):(\d+)$/.test(n)?"":`:${e.port}`}}const $t=(0,g._I)(((e={})=>{const{breadcrumbs:t,tracing:n,shouldCreateSpanForRequest:s}=e,i={breadcrumbs:t,tracing:!1!==n&&(0,a.Jr)({enableIfHasTracingEnabled:!0!==n||void 0,shouldCreateSpanForRequest:s})};return new en(i)}));class en{static __initStatic(){this.id="Http"}__init(){this.name=en.id}constructor(e={}){en.prototype.__init.call(this),this._breadcrumbs=void 0===e.breadcrumbs||e.breadcrumbs,this._tracing=e.tracing?!0===e.tracing?{}:e.tracing:void 0}setupOnce(e,t){const s=(0,je.x)([t,"call",e=>e(),"access",e=>e.getClient,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]),i=function(e,t){return void 0!==e&&(!e.enableIfHasTracingEnabled||(0,Qt.z)(t))}(this._tracing,s);if(!this._breadcrumbs&&!i)return;if(s&&"sentry"!==s.instrumenter)return void(Ot&&h.kg.log("HTTP Integration is skipped because of instrumenter configuration."));const o=function(e,t,n){return e?(0,je.x)([t,"optionalAccess",e=>e.shouldCreateSpanForRequest])||(0,je.x)([n,"optionalAccess",e=>e.shouldCreateSpanForRequest]):()=>!1}(i,this._tracing,s),r=(0,je.x)([s,"optionalAccess",e=>e.tracePropagationTargets])||(0,je.x)([this,"access",e=>e._tracing,"optionalAccess",e=>e.tracePropagationTargets]),c=n(3685),g=tn(c,this._breadcrumbs,o,r);if((0,a.hl)(c,"get",g),(0,a.hl)(c,"request",g),ct.V.major>8){const e=n(5687),t=tn(e,this._breadcrumbs,o,r);(0,a.hl)(e,"get",t),(0,a.hl)(e,"request",t)}}}function tn(e,t,n,s){const i=new _t(100),o=new _t(100);function r(e,t,n,s){(0,U.Gd)().getIntegration(en)&&(0,c.n_)({category:"http",data:{status_code:s&&s.statusCode,...t},type:"http"},{event:e,request:n,response:s})}return function(a){return function(...g){const l=function(e,t){let n,s;if("function"==typeof t[t.length-1]&&(n=t.pop()),"string"==typeof t[0])s=Dt(new Le.URL(t[0]));else if(t[0]instanceof Le.URL)s=Dt(t[0]);else{s=t[0];try{const e=new Le.URL(s.path||"",`${s.protocol||"http:"}//${s.hostname}`);s={pathname:e.pathname,search:e.search,hash:e.hash,...s}}catch(e){}}return 2===t.length&&(s={...s,...t[1]}),void 0===s.protocol&&(ct.V.major>8?s.protocol=(0,je.x)([(0,je.x)([e,"optionalAccess",e=>e.globalAgent]),"optionalAccess",e=>e.protocol])||(0,je.x)([s.agent,"optionalAccess",e=>e.protocol])||(0,je.x)([s._defaultAgent,"optionalAccess",e=>e.protocol]):s.protocol=(0,je.x)([s.agent,"optionalAccess",e=>e.protocol])||(0,je.x)([s._defaultAgent,"optionalAccess",e=>e.protocol])||(0,je.x)([(0,je.x)([e,"optionalAccess",e=>e.globalAgent]),"optionalAccess",e=>e.protocol])),n?[s,n]:[s]}(e,g),d=l[0],I=function(e){const{protocol:t,hostname:n,port:s}=qt(e);return`${t}//${n}${s}${e.path?e.path:"/"}`}(d),u=Pt(d),p=(0,c.s3)();if(zt(u,p))return a.apply(e,l);const b=(0,c.nZ)(),m=(0,U.aF)(),Z=(0,ve.HN)(),G=function(e,t){const n={url:e,"http.method":t.method||"GET"};return t.hash&&(n["http.fragment"]=t.hash.substring(1)),t.search&&(n["http.query"]=t.search.substring(1)),n}(u,d),y=(e=>{if(void 0===n)return!0;const t=i.get(e);if(void 0!==t)return t;const s=n(e);return i.set(e,s),s})(I)?(0,je.x)([Z,"optionalAccess",e=>e.startChild,"call",e=>e({op:"http.client",origin:"auto.http.node.http",description:`${G["http.method"]} ${G.url}`,data:G})]):void 0;if(p&&(e=>{if(void 0===s)return!0;const t=o.get(e);if(void 0!==t)return t;const n=(0,C.U0)(e,s);return o.set(e,n),n})(I)){const{traceId:e,spanId:t,sampled:n,dsc:s}={...m.getPropagationContext(),...b.getPropagationContext()},i=y?(0,re.Hb)(y):(0,at.$p)(e,t,n),o=(0,jt.IQ)(s||(y?(0,P.j)(y):(0,P._)(e,p,b)));!function(e,t,n,s){(e.headers||{})["sentry-trace"]||(Ot&&h.kg.log(`[Tracing] Adding sentry-trace header ${n} to outgoing request to "${t}": `),e.headers={...e.headers,"sentry-trace":n,...s&&s.length>0&&{baggage:nn(e,s)}})}(d,u,i,o)}else Ot&&h.kg.log(`[Tracing] Not adding sentry-trace header to outgoing request (${u}) due to mismatching tracePropagationTargets option.`);return a.apply(e,l).once("response",(function(e){t&&r("response",G,this,e),y&&(e.statusCode&&(0,Se.Q0)(y,e.statusCode),y.updateName(Mt((0,re.XU)(y).description||"",d,this)||""),y.end())})).once("error",(function(){t&&r("error",G,this),y&&((0,Se.Q0)(y,500),y.updateName(Mt((0,re.XU)(y).description||"",d,this)||""),y.end())}))}}}function nn(e,t){return e.headers&&e.headers.baggage?t?Array.isArray(e.headers.baggage)?[...e.headers.baggage,t]:[e.headers.baggage,t]:e.headers.baggage:t}function sn(e){return void 0!==e&&(0===e.length||"?"===e||""===e)}function on(e){if(void 0!==e)return e.slice(-10).reduce(((e,t)=>`${e},${t.function},${t.lineno},${t.colno}`),"")}function rn(e){let t=[],n=!1;function s(s){t=[],n||(n=!0,e(s))}return t.push(s),{add:function(e){t.push(e)},next:function(e){const n=t.pop()||s;try{n(e)}catch(t){s(e)}}}}en.__initStatic();class an{constructor(){const{Session:e}=n(1405);this._session=new e}configureAndConnect(e,t){this._session.connect(),this._session.on("Debugger.paused",(t=>{e(t,(()=>{this._session.post("Debugger.resume")}))})),this._session.post("Debugger.enable"),this._session.post("Debugger.setPauseOnExceptions",{state:t?"all":"uncaught"})}setPauseOnExceptions(e){this._session.post("Debugger.setPauseOnExceptions",{state:e?"all":"uncaught"})}getLocalVariables(e,t){this._getProperties(e,(e=>{const{add:n,next:s}=rn(t);for(const t of e)if((0,je.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.objectId])&&"Array"===(0,je.x)([t,"optionalAccess",e=>e.value,"access",e=>e.className])){const e=t.value.objectId;n((n=>this._unrollArray(e,t.name,n,s)))}else if((0,je.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.objectId])&&"Object"===(0,je.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.className])){const e=t.value.objectId;n((n=>this._unrollObject(e,t.name,n,s)))}else null==(0,je.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])&&null==(0,je.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.description])||n((e=>this._unrollOther(t,e,s)));s({})}))}_getProperties(e,t){this._session.post("Runtime.getProperties",{objectId:e,ownProperties:!0},((e,n)=>{t(e?[]:n.result)}))}_unrollArray(e,t,n,s){this._getProperties(e,(e=>{n[t]=e.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>(0,je.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value]))),s(n)}))}_unrollObject(e,t,n,s){this._getProperties(e,(e=>{n[t]=e.map((e=>[e.name,(0,je.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])])).reduce(((e,[t,n])=>(e[t]=n,e)),{}),s(n)}))}_unrollOther(e,t,n){null!=(0,je.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])?t[e.name]=e.value.value:null!=(0,je.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.description])&&"function"!==(0,je.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.type])&&(t[e.name]=`<${e.value.description}>`),n(t)}}const cn="LocalVariables",gn=(0,g._I)(((e={},t=function(){try{return new an}catch(e){return}}())=>{const n=new _t(20);let s,i=!1;function o(e){const t=on((0,je.x)([e,"optionalAccess",e=>e.stacktrace,"optionalAccess",e=>e.frames]));if(void 0===t)return;const s=n.remove(t);if(void 0===s)return;const i=((0,je.x)([e,"access",e=>e.stacktrace,"optionalAccess",e=>e.frames])||[]).filter((e=>"new Promise"!==e.function));for(let e=0;ee.getOptions,"call",e=>e()]);if(t&&(0,je.x)([r,"optionalAccess",e=>e.includeLocalVariables])){if(ct.V.major<18)return void h.kg.log("The `LocalVariables` integration is only supported on Node >= v18.");const o=!1!==e.captureAllExceptions;if(t.configureAndConnect(((e,i)=>function(e,{params:{reason:i,data:o,callFrames:r}},a){if("exception"!==i&&"promiseRejection"!==i)return void a();(0,je.x)([s,"optionalCall",e=>e()]);const c=function(e,t){if(void 0!==t)return on(e(t,1))}(e,(0,je.x)([o,"optionalAccess",e=>e.description]));if(null==c)return void a();const{add:g,next:l}=rn((e=>{n.set(c,e),a()}));for(let e=0;e"local"===e.type)),a="global"!==i.className&&i.className?`${i.className}.${s}`:s;if(void 0===(0,je.x)([o,"optionalAccess",e=>e.object,"access",e=>e.objectId]))g((t=>{t[e]={function:a},l(t)}));else{const n=o.object.objectId;g((s=>(0,je.x)([t,"optionalAccess",e=>e.getLocalVariables,"call",t=>t(n,(t=>{s[e]={function:a,vars:t},l(s)}))])))}}l([])}(r.stackParser,e,i)),o),o){const n=e.maxExceptionsPerSecond||50;s=function(e,n,s){let i=0,o=5,r=0;return setInterval((()=>{var n;0===r?i>e&&(o*=2,n=o,h.kg.log(`Local variables rate-limit exceeded. Disabling capturing of caught exceptions for ${n} seconds.`),(0,je.x)([t,"optionalAccess",e=>e.setPauseOnExceptions,"call",e=>e(!1)]),o>86400&&(o=86400),r=o):(r-=1,0===r&&(h.kg.log("Local variables rate-limit lifted."),(0,je.x)([t,"optionalAccess",e=>e.setPauseOnExceptions,"call",e=>e(!0)]))),i=0}),1e3).unref(),()=>{i+=1}}(n)}i=!0}},processEvent:e=>i?function(e){for(const t of(0,je.x)([e,"optionalAccess",e=>e.exception,"optionalAccess",e=>e.values])||[])o(t);return e}(e):e,_getCachedFramesCount:()=>n.size,_getFirstCachedFrame:()=>n.values()[0]}})),ln=(0,g.RN)(cn,gn),dn=gn;let In;const un="Modules";function pn(){const e=n.c[n.s]&&n.c[n.s].paths||[],t=function(){try{return n.c?Object.keys(n.c):[]}catch(e){return[]}}(),s={},i={};return t.forEach((t=>{let n=t;const o=()=>{const t=n;if(n=(0,Vt.dirname)(t),!n||t===n||i[t])return;if(e.indexOf(n)<0)return o();const r=(0,Vt.join)(t,"package.json");if(i[t]=!0,!(0,ft.existsSync)(r))return o();try{const e=JSON.parse((0,ft.readFileSync)(r,"utf8"));s[e.name]=e.version}catch(e){}};o()})),s}const hn=(0,g._I)((()=>({name:un,setupOnce(){},processEvent:e=>(e.modules={...e.modules,...(In||(In=pn()),In)},e)}))),bn=(0,g.RN)(un,hn);function Cn(e){(0,h.Cf)((()=>{console.error(e)}));const t=(0,c.s3)();void 0===t&&(Ot&&h.kg.warn("No NodeClient was defined, we are exiting the process now."),global.process.exit(1));const n=t.getOptions(),s=n&&n.shutdownTimeout&&n.shutdownTimeout>0&&n.shutdownTimeout||2e3;t.close(s).then((e=>{e||Ot&&h.kg.warn("We reached the timeout for emptying the request buffer, still exiting now!"),global.process.exit(1)}),(e=>{Ot&&h.kg.error(e)}))}const mn="OnUncaughtException",Zn=(0,g._I)(((e={})=>{const t={exitEvenIfOtherHandlersAreRegistered:!0,...e};return{name:mn,setupOnce(){},setup(e){global.process.on("uncaughtException",function(e,t){let n,s=!1,i=!1,o=!1;const r=e.getOptions();return Object.assign((a=>{let g=Cn;t.onFatalError?g=t.onFatalError:r.onFatalError&&(g=r.onFatalError);const l=0===global.process.listeners("uncaughtException").reduce(((e,t)=>"domainUncaughtExceptionClear"===t.name||t.tag&&"sentry_tracingErrorCallback"===t.tag||t._errorHandler?e:e+1),0),d=t.exitEvenIfOtherHandlersAreRegistered||l;s?d&&(o?(Ot&&h.kg.warn("uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown"),Cn(a)):i||(i=!0,setTimeout((()=>{o||(o=!0,g(n,a))}),2e3))):(n=a,s=!0,(0,c.s3)()===e&&(0,c.Tb)(a,{originalException:a,captureContext:{level:"fatal"},mechanism:{handled:!1,type:"onuncaughtexception"}}),!o&&d&&(o=!0,g(a)))}),{_errorHandler:!0})}(e,t))}}})),Gn=(0,g.RN)(mn,Zn),yn="OnUnhandledRejection",Bn=(0,g._I)(((e={})=>{const t=e.mode||"warn";return{name:yn,setupOnce(){},setup(e){global.process.on("unhandledRejection",function(e,t){return function(n,s){(0,c.s3)()===e&&((0,c.Tb)(n,{originalException:s,captureContext:{extra:{unhandledPromiseRejection:!0}},mechanism:{handled:!1,type:"onunhandledrejection"}}),function(e,t){const n="This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:";"warn"===t.mode?(0,h.Cf)((()=>{console.warn(n),console.error(e&&e.stack?e.stack:e)})):"strict"===t.mode&&((0,h.Cf)((()=>{console.warn(n)})),Cn(e))}(n,t))}}(e,{mode:t}))}}})),An=(0,g.RN)(yn,Bn),Wn="Spotlight",fn=(0,g._I)(((e={})=>{const t={sidecarUrl:e.sidecarUrl||"http://localhost:8969/stream"};return{name:Wn,setupOnce(){},setup(e){"object"==typeof process&&process.env&&h.kg.warn("[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?"),function(e,t){const n=function(e){try{return new Le.URL(`${e}`)}catch(t){return void h.kg.warn(`[Spotlight] Invalid sidecar URL: ${e}`)}}(t.sidecarUrl);if(!n)return;let s=0;"function"==typeof e.on?e.on("beforeEnvelope",(e=>{if(s>3)return void h.kg.warn("[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests");const t=(0,F.V$)(e),i=function(){const{request:e}=xe;return"__sentry_original__"in e?e.__sentry_original__:e}()({method:"POST",path:n.pathname,hostname:n.hostname,port:n.port,headers:{"Content-Type":"application/x-sentry-envelope"}},(e=>{e.on("data",(()=>{})),e.on("end",(()=>{})),e.setEncoding("utf8")}));i.on("error",(()=>{s++,h.kg.warn("[Spotlight] Failed to send envelope to Spotlight Sidecar")})),i.write(t),i.end()})):h.kg.warn("[Spotlight] Cannot connect to spotlight due to missing method on SDK client (`client.on`)")}(e,t)}}})),Vn=(0,g.RN)(Wn,fn);var vn,Rn=n(6956);!function(e){e.RequestCreate="undici:request:create",e.RequestEnd="undici:request:headers",e.RequestError="undici:request:error"}(vn||(vn={}));const Sn=(0,g._I)((e=>new Xn(e)));class Xn{static __initStatic(){this.id="Undici"}__init(){this.name=Xn.id}__init2(){this._createSpanUrlMap=new _t(100)}__init3(){this._headersUrlMap=new _t(100)}constructor(e={}){Xn.prototype.__init.call(this),Xn.prototype.__init2.call(this),Xn.prototype.__init3.call(this),Xn.prototype.__init4.call(this),Xn.prototype.__init5.call(this),Xn.prototype.__init6.call(this),this._options={breadcrumbs:void 0===e.breadcrumbs||e.breadcrumbs,tracing:e.tracing,shouldCreateSpanForRequest:e.shouldCreateSpanForRequest}}setupOnce(e){if(ct.V.major<16)return;let t;try{t=n(7643)}catch(e){}t&&t.subscribe&&(t.subscribe(vn.RequestCreate,this._onRequestCreate),t.subscribe(vn.RequestEnd,this._onRequestEnd),t.subscribe(vn.RequestError,this._onRequestError))}_shouldCreateSpan(e){if(!1===this._options.tracing||void 0===this._options.tracing&&!(0,Qt.z)())return!1;if(void 0===this._options.shouldCreateSpanForRequest)return!0;const t=this._createSpanUrlMap.get(e);if(void 0!==t)return t;const n=this._options.shouldCreateSpanForRequest(e);return this._createSpanUrlMap.set(e,n),n}__init4(){this._onRequestCreate=e=>{if(!(0,je.x)([c.s3,"call",e=>e(),"optionalAccess",e=>e.getIntegration,"call",e=>e(Xn)]))return;const{request:t}=e,n=t.origin?t.origin.toString()+t.path:t.path,s=(0,c.s3)();if(!s)return;if(zt(n,s)||void 0!==t.__sentry_span__)return;const i=s.getOptions(),o=(0,c.nZ)(),r=(0,U.aF)(),a=(0,ve.HN)(),g=this._shouldCreateSpan(n)?function(e,t,n){const s=(0,Rn.en)(n),i=t.method||"GET",o={"http.method":i};return s.search&&(o["http.query"]=s.search),s.hash&&(o["http.fragment"]=s.hash),(0,je.x)([e,"optionalAccess",e=>e.startChild,"call",e=>e({op:"http.client",origin:"auto.http.node.undici",description:`${i} ${(0,Rn.tF)(s)}`,data:o})])}(a,t,n):void 0;if(g&&(t.__sentry_span__=g),(e=>{if(void 0===i.tracePropagationTargets)return!0;const t=this._headersUrlMap.get(e);if(void 0!==t)return t;const n=(0,C.U0)(e,i.tracePropagationTargets);return this._headersUrlMap.set(e,n),n})(n)){const{traceId:e,spanId:n,sampled:i,dsc:a}={...r.getPropagationContext(),...o.getPropagationContext()};!function(e,t,n){let s;s=Array.isArray(e.headers)?e.headers.some((e=>"sentry-trace"===e)):e.headers.split("\r\n").some((e=>e.startsWith("sentry-trace:"))),s||(e.addHeader("sentry-trace",t),n&&e.addHeader("baggage",n))}(t,g?(0,re.Hb)(g):(0,at.$p)(e,n,i),(0,jt.IQ)(a||(g?(0,P.j)(g):(0,P._)(e,s,o))))}}}__init5(){this._onRequestEnd=e=>{if(!(0,je.x)([c.s3,"call",e=>e(),"optionalAccess",e=>e.getIntegration,"call",e=>e(Xn)]))return;const{request:t,response:n}=e,s=t.origin?t.origin.toString()+t.path:t.path;if(zt(s,(0,c.s3)()))return;const i=t.__sentry_span__;i&&((0,Se.Q0)(i,n.statusCode),i.end()),this._options.breadcrumbs&&(0,c.n_)({category:"http",data:{method:t.method,status_code:n.statusCode,url:s},type:"http"},{event:"response",request:t,response:n})}}__init6(){this._onRequestError=e=>{if(!(0,je.x)([c.s3,"call",e=>e(),"optionalAccess",e=>e.getIntegration,"call",e=>e(Xn)]))return;const{request:t}=e,n=t.origin?t.origin.toString()+t.path:t.path;if(zt(n,(0,c.s3)()))return;const s=t.__sentry_span__;s&&(s.setStatus("internal_error"),s.end()),this._options.breadcrumbs&&(0,c.n_)({category:"http",data:{method:t.method,url:n},level:"error",type:"http"},{event:"error",request:t})}}}Xn.__initStatic();const Yn=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function Hn(e){const t=e.length>1024?`${e.slice(-1024)}`:e,n=Yn.exec(t);return n?n.slice(1):[]}function Nn(...e){let t="",n=!1;for(let s=e.length-1;s>=-1&&!n;s--){const i=s>=0?e[s]:"/";i&&(t=`${i}/${t}`,n="/"===i.charAt(0))}return t=function(e,t){let n=0;for(let t=e.length-1;t>=0;t--){const s=e[t];"."===s?e.splice(t,1):".."===s?(e.splice(t,1),n++):n&&(e.splice(t,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}(t.split("/").filter((e=>!!e)),!n).join("/"),(n?"/":"")+t||"."}function wn(e){let t=0;for(;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}function kn(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function Kn(e=(process.argv[1]?function(e){const t=Hn(process.argv[1]),n=t[0];let s=t[1];return n||s?(s&&(s=s.slice(0,s.length-1)),n+s):"."}():process.cwd()),t="\\"===Vt.sep){const n=t?kn(e):e;return e=>{if(!e)return;const s=t?kn(e):e;let{dir:i,base:o,ext:r}=Vt.posix.parse(s);".js"!==r&&".mjs"!==r&&".cjs"!==r||(o=o.slice(0,-1*r.length)),i||(i=".");const a=i.lastIndexOf("/node_modules");if(a>-1)return`${i.slice(a+14).replace(/\//g,".")}:${o}`;if(i.startsWith(n)){let e=i.slice(n.length+1).replace(/\//g,".");return e&&(e+=":"),e+=o,e}return o}}const _n=[B(),u(),w(),Ge(),Bt(),$t(),Sn(),Zn(),Bn(),Et(),dn(),Xt(),hn()];function Jn(e){const t=(0,U.cu)(),n=(0,je.x)([t,"access",e=>e.__SENTRY__,"optionalAccess",e=>e.integrations])||[];return[..._n,...n]}function Fn(e={}){ht(),void 0===e.defaultIntegrations&&(e.defaultIntegrations=Jn()),void 0===e.dsn&&process.env.SENTRY_DSN&&(e.dsn=process.env.SENTRY_DSN);const t=process.env.SENTRY_TRACES_SAMPLE_RATE;if(void 0===e.tracesSampleRate&&t){const n=parseFloat(t);isFinite(n)&&(e.tracesSampleRate=n)}if(void 0===e.release){const t=Un();void 0!==t?e.release=t:e.autoSessionTracking=!1}void 0===e.environment&&process.env.SENTRY_ENVIRONMENT&&(e.environment=process.env.SENTRY_ENVIRONMENT),void 0===e.autoSessionTracking&&void 0!==e.dsn&&(e.autoSessionTracking=!0),void 0===e.instrumenter&&(e.instrumenter="sentry");const n={...e,stackParser:(0,ot.Sq)(e.stackParser||xn),integrations:(0,g.m8)(e),transport:e.transport||it};if(function(e,t){!0===t.debug&&(m.X?h.kg.enable():(0,h.Cf)((()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")}))),(0,c.nZ)().update(t.initialScope);const n=new e(t);Be(n),function(e){e.init?e.init():e.setupIntegrations&&e.setupIntegrations()}(n)}(e.clientClass||Ee,n),e.autoSessionTracking&&((0,c.yj)(),process.on("beforeExit",(()=>{const e=(0,U.aF)().getSession();e&&!["exited","crashed"].includes(e.status)&&(0,c.TM)()}))),function(){const e=(process.env.SENTRY_USE_ENVIRONMENT||"").toLowerCase();if(!["false","n","no","off","0"].includes(e)){const e=process.env.SENTRY_TRACE,t=process.env.SENTRY_BAGGAGE,n=(0,at.pT)(e,t);(0,c.nZ)().setPropagationContext(n)}}(),e.spotlight){const t=(0,c.s3)();if(t&&t.addIntegration){const n=t.getOptions().integrations;for(const e of n)t.addIntegration(e);t.addIntegration(fn({sidecarUrl:"string"==typeof e.spotlight?e.spotlight:void 0}))}}}function En(e){if(void 0===e)return!1;const t=e&&e.getOptions();return!(!t||void 0===t.autoSessionTracking)&&t.autoSessionTracking}function Un(e){return process.env.SENTRY_RELEASE?process.env.SENTRY_RELEASE:rt.GLOBAL_OBJ.SENTRY_RELEASE&&rt.GLOBAL_OBJ.SENTRY_RELEASE.id?rt.GLOBAL_OBJ.SENTRY_RELEASE.id:process.env.GITHUB_SHA||process.env.COMMIT_REF||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA||process.env.CF_PAGES_COMMIT_SHA||e}const xn=(0,ot.pE)((0,ot.Ep)(Kn()));function Tn(e){const t=Vt.resolve(e);if(!ft.existsSync(t))throw new Error(`Cannot read contents of ${t}. Directory does not exist.`);if(!ft.statSync(t).isDirectory())throw new Error(`Cannot read contents of ${t}, because it is not a directory.`);const n=e=>ft.readdirSync(e).reduce(((t,s)=>{const i=Vt.join(e,s);return ft.statSync(i).isDirectory()?t.concat(n(i)):(t.push(i),t)}),[]);return n(t).map((e=>Vt.relative(t,e)))}var zn=n(6751);function Ln(e){const t=(0,c.s3)();return new zn.q(e).setup(t),Promise.resolve()}function Qn(e={}){return function({path:t,type:n,next:s,rawInput:i}){const o=(0,je.x)([c.s3,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]),r=(0,c.nZ)().getTransaction();if(r){r.updateName(`trpc/${t}`),r.setAttribute(We.Zj,"route"),r.op="rpc.server";const s={procedure_type:n};(void 0!==e.attachRpcInput?e.attachRpcInput:(0,je.x)([o,"optionalAccess",e=>e.sendDefaultPii]))&&(s.input=(0,X.Fv)(i)),r.setContext("trpc",s)}function a(e){e.ok||(0,c.Tb)(e.error,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}})}let g;try{g=s()}catch(e){throw(0,c.Tb)(e,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}}),e}return(0,f.J8)(g)?Promise.resolve(g).then((e=>{a(e)}),(e=>{(0,c.Tb)(e,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}})})):a(g),g}}function jn(e,t){return(0,Ce.XQ)(e,{include:t})}function On(e,t,n={}){return(0,Ce.S6)(e,t,{include:n})}function Pn(){return function(e,t,n){const s=(0,je.x)([c.s3,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]);if(!s||"sentry"!==s.instrumenter||"OPTIONS"===(0,je.x)([e,"access",e=>e.method,"optionalAccess",e=>e.toUpperCase,"call",e=>e()])||"HEAD"===(0,je.x)([e,"access",e=>e.method,"optionalAccess",e=>e.toUpperCase,"call",e=>e()]))return n();const i=e.headers&&(0,f.HD)(e.headers["sentry-trace"])?e.headers["sentry-trace"]:void 0,o=(0,je.x)([e,"access",e=>e.headers,"optionalAccess",e=>e.baggage]);if(!(0,Qt.z)(s))return n();const[r,a]=(0,Ce.oA)(e,{path:!0,method:!0}),g=(0,ve.yn)({sentryTrace:i,baggage:o},(t=>(0,c.Yr)({name:r,op:"http.server",origin:"auto.http.node.tracingHandler",...t,data:{[We.Zj]:a},metadata:{...t.metadata,request:e}},{request:(0,Ce.XQ)(e)})));(0,c.nZ)().setSpan(g),t.__sentry_transaction=g,t.once("finish",(()=>{setImmediate((()=>{(0,Ce.dB)(g,e),(0,Se.Q0)(g,t.statusCode),g.end()}))})),n()}}function Mn(e){const t=function(e={}){let t;if("include"in e)t={include:e.include};else{const{ip:n,request:s,transaction:i,user:o}=e;(n||s||i||o)&&(t={include:(0,a.Jr)({ip:n,request:s,transaction:i,user:o})})}return t}(e),n=(0,c.s3)();if(n&&En(n)){n.initSessionFlusher();const e=(0,c.nZ)();e.getSession()&&e.setSession()}return function(n,s,i){if(e&&e.flushTimeout&&e.flushTimeout>0){const t=s.end;s.end=function(n,s,i){(0,c.yl)(e.flushTimeout).then((()=>{t.call(this,n,s,i)})).then(null,(e=>{Ot&&h.kg.error(e),t.call(this,n,s,i)}))}}(0,U.Ok)((()=>{const e=(0,c.nZ)();e.setSDKProcessingMetadata({request:n,requestDataOptionsFromExpressHandler:t}),En((0,c.s3)())&&e.setRequestSession({status:"ok"}),s.once("finish",(()=>{const e=(0,c.s3)();En(e)&&setImmediate((()=>{e&&e._captureRequestSession&&e._captureRequestSession()}))})),i()}))}}function Dn(e){const t=function(e){const t=e.status||e.statusCode||e.status_code||e.output&&e.output.statusCode;return t?parseInt(t,10):500}(e);return t>=500}function qn(e){return function(t,n,s,i){(e&&e.shouldHandleError||Dn)(t)?(0,c.$e)((e=>{e.setSDKProcessingMetadata({request:n});const o=s.__sentry_transaction;o&&!(0,ve.HN)()&&e.setSpan(o);const r=(0,c.s3)();if(r&&En(r)&&void 0!==r._sessionFlusher){const t=e.getRequestSession();t&&void 0!==t.status&&(t.status="crashed")}const a=(0,c.Tb)(t,{mechanism:{type:"middleware",handled:!1}});s.sentry=a,i(t)})):i(t)}}const $n=Qn;function es(e){return e&&void 0!==e.statusCode}const ts={name:"SentryHapiErrorPlugin",version:Ae.J,register:async function(e){e.events.on("request",((e,t)=>{const n=(0,Re.x1)();var s;(function(e){return e&&void 0!==e.error})(t)&&(s=t.error,(0,c.Tb)(s,{mechanism:{type:"hapi",handled:!1,data:{function:"hapiErrorPlugin"}}})),n&&(n.setStatus("internal_error"),n.end())}))}},ns={name:"SentryHapiTracingPlugin",version:Ae.J,register:async function(e){const t=e;t.ext("onPreHandler",((e,t)=>{const n=(0,ve.yn)({sentryTrace:e.headers["sentry-trace"]||void 0,baggage:e.headers.baggage||void 0},(t=>(0,c.Yr)({...t,op:"hapi.request",name:e.route.path,description:`${e.route.method} ${e.path}`})));return(0,c.nZ)().setSpan(n),t.continue})),t.ext("onPreResponse",((e,t)=>{const n=(0,Re.x1)();if(e.response&&es(e.response)&&n){const t=e.response;t.header("sentry-trace",(0,re.Hb)(n));const s=(0,jt.IQ)((0,P.j)(n));s&&t.header("baggage",s)}return t.continue})),t.ext("onPostHandler",((e,t)=>{const n=(0,Re.x1)();return n&&(e.response&&es(e.response)&&(0,Se.Q0)(n,e.response.statusCode),n.end()),t.continue}))}},ss="Hapi",is=(0,g._I)(((e={})=>{const t=e.server;return{name:ss,setupOnce(){t&&(0,a.hl)(t,"start",(e=>async function(){return await this.register(ns),await this.register(ts),e.apply(this)}))}}})),os=(0,g.RN)(ss,is);var rs=n(2716),as=n(8737),cs=n(1791),gs=n(6169),ls=n(24),ds=n(1370),Is=n(9889);const us="CaptureConsole",ps=(0,g._I)(((e={})=>{const t=e.levels||h.RU;return{name:us,setupOnce(){},setup(e){"console"in rt.GLOBAL_OBJ&&Ct((({args:n,level:s})=>{(0,c.s3)()===e&&t.includes(s)&&function(e,t){const n={level:Gt(t),extra:{arguments:e}};(0,c.$e)((s=>{if(s.addEventProcessor((e=>(e.logger="console",(0,b.EG)(e,{handled:!1,type:"console"}),e))),"assert"===t&&!1===e[0]){const t=`Assertion failed: ${(0,C.nK)(e.slice(1)," ")||"console.assert"}`;return s.setExtra("arguments",e.slice(1)),void(0,c.uT)(t,n)}const i=e.find((e=>e instanceof Error));if("error"===t&&i)return void(0,c.Tb)(i,n);const o=(0,C.nK)(e," ");(0,c.uT)(o,n)}))}(n,s)}))}}}));(0,g.RN)(us,ps);const hs="Debug",bs=(0,g._I)(((e={})=>{const t={debugger:!1,stringify:!1,...e};return{name:hs,setupOnce(){},setup(e){e.on&&e.on("beforeSendEvent",((e,n)=>{t.debugger,(0,h.Cf)((()=>{t.stringify?(console.log(JSON.stringify(e,null,2)),n&&Object.keys(n).length&&console.log(JSON.stringify(n,null,2))):(console.log(e),n&&Object.keys(n).length&&console.log(n))}))}))}}})),Cs=((0,g.RN)(hs,bs),"undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__),ms="Dedupe",Zs=(0,g._I)((()=>{let e;return{name:ms,setupOnce(){},processEvent(t){if(t.type)return t;try{if(function(e,t){return!!t&&(!!function(e,t){const n=e.message,s=t.message;return!(!n&&!s)&&(!(n&&!s||!n&&s)&&(n===s&&(!!ys(e,t)&&!!Gs(e,t))))}(e,t)||!!function(e,t){const n=Bs(t),s=Bs(e);return!(!n||!s)&&(n.type===s.type&&n.value===s.value&&(!!ys(e,t)&&!!Gs(e,t)))}(e,t))}(t,e))return Cs&&h.kg.warn("Event dropped due to being a duplicate of previously captured event."),null}catch(e){}return e=t}}}));function Gs(e,t){let n=As(e),s=As(t);if(!n&&!s)return!0;if(n&&!s||!n&&s)return!1;if(s.length!==n.length)return!1;for(let e=0;e{const t=e.depth||3,n=e.captureErrorCause||!1;return{name:Ws,setupOnce(){},processEvent:(e,s)=>function(e,t={},n,s){if(!t.originalException||!(0,f.VZ)(t.originalException))return e;const i=t.originalException.name||t.originalException.constructor.name,o=function(e,t){try{const n=["name","message","stack","line","column","fileName","lineNumber","columnNumber","toJSON"],s={};for(const t of Object.keys(e)){if(-1!==n.indexOf(t))continue;const i=e[t];s[t]=(0,f.VZ)(i)?i.toString():i}if(t&&void 0!==e.cause&&(s.cause=(0,f.VZ)(e.cause)?e.cause.toString():e.cause),"function"==typeof e.toJSON){const t=e.toJSON();for(const e of Object.keys(t)){const n=t[e];s[e]=(0,f.VZ)(n)?n.toString():n}}return s}catch(e){Cs&&h.kg.error("Unable to extract extra data from the Error object:",e)}return null}(t.originalException,s);if(o){const t={...e.contexts},s=(0,X.Fv)(o,n);return(0,f.PO)(s)&&((0,a.xp)(s,"__sentry_skip_normalization__",!0),t[i]=s),{...e,contexts:t}}return e}(e,s,t,n)}}));(0,g.RN)(Ws,fs);var Vs=n(8823),vs=n(1394),Rs=n(5322);const Ss="HttpClient",Xs=(0,g._I)(((e={})=>{const t={failedRequestStatusCodes:[[500,599]],failedRequestTargets:[/.*/],...e};return{name:Ss,setupOnce(){},setup(e){!function(e,t){(0,Vs.t$)()&&(0,vs.U)((n=>{if((0,c.s3)()!==e)return;const{response:s,args:i}=n,[o,r]=i;s&&function(e,t,n,s){if(Ns(e,n.status,n.url)){const e=function(e,t){return!t&&e instanceof Request||e instanceof Request&&e.bodyUsed?e:new Request(e,t)}(t,s);let i,o,r,a;ks()&&([{headers:i,cookies:r},{headers:o,cookies:a}]=[{cookieHeader:"Cookie",obj:e},{cookieHeader:"Set-Cookie",obj:n}].map((({cookieHeader:e,obj:t})=>{const n=function(e){const t={};return e.forEach(((e,n)=>{t[n]=e})),t}(t.headers);let s;try{const t=n[e]||n[e.toLowerCase()]||void 0;t&&(s=Hs(t))}catch(t){Cs&&h.kg.log(`Could not extract cookies from header ${e}`)}return{headers:n,cookies:s}})));const g=ws({url:e.url,method:e.method,status:n.status,requestHeaders:i,responseHeaders:o,requestCookies:r,responseCookies:a});(0,c.eN)(g)}}(t,o,s,r)}))}(e,t),function(e,t){"XMLHttpRequest"in rt.GLOBAL_OBJ&&(0,Rs.UK)((n=>{if((0,c.s3)()!==e)return;const s=n.xhr,i=s[Rs.xU];if(!i)return;const{method:o,request_headers:r}=i;try{!function(e,t,n,s){if(Ns(e,t.status,t.responseURL)){let e,i,o;if(ks()){try{const e=t.getResponseHeader("Set-Cookie")||t.getResponseHeader("set-cookie")||void 0;e&&(i=Hs(e))}catch(e){Cs&&h.kg.log("Could not extract cookies from response headers")}try{o=function(e){const t=e.getAllResponseHeaders();return t?t.split("\r\n").reduce(((e,t)=>{const[n,s]=t.split(": ");return e[n]=s,e}),{}):{}}(t)}catch(e){Cs&&h.kg.log("Could not extract headers from response")}e=s}const r=ws({url:t.responseURL,method:n,status:t.status,requestHeaders:e,responseHeaders:o,responseCookies:i});(0,c.eN)(r)}}(t,s,o,r)}catch(e){Cs&&h.kg.warn("Error while extracting response event form XHR response",e)}}))}(e,t)}}}));function Ys(e){if(e){const t=e["Content-Length"]||e["content-length"];if(t)return parseInt(t,10)}}function Hs(e){return e.split("; ").reduce(((e,t)=>{const[n,s]=t.split("=");return e[n]=s,e}),{})}function Ns(e,t,n){return function(e,t){return e.some((e=>"number"==typeof e?e===t:t>=e[0]&&t<=e[1]))}(e.failedRequestStatusCodes,t)&&(s=e.failedRequestTargets,i=n,s.some((e=>"string"==typeof e?i.includes(e):e.test(i))))&&!zt(n,(0,c.s3)());var s,i}function ws(e){const t=`HTTP Client Error with status code: ${e.status}`,n={message:t,exception:{values:[{type:"Error",value:t}]},request:{url:e.url,method:e.method,headers:e.requestHeaders,cookies:e.requestCookies},contexts:{response:{status_code:e.status,headers:e.responseHeaders,cookies:e.responseCookies,body_size:Ys(e.responseHeaders)}}};return(0,b.EG)(n,{type:"http.client",handled:!1}),n}function ks(){const e=(0,c.s3)();return!!e&&Boolean(e.getOptions().sendDefaultPii)}(0,g.RN)(Ss,Xs);const Ks=rt.GLOBAL_OBJ,_s="ReportingObserver",Js=new WeakMap,Fs=(0,g._I)(((e={})=>{const t=e.types||["crash","deprecation","intervention"];function n(e){if(Js.has((0,c.s3)()))for(const t of e)(0,c.$e)((e=>{e.setExtra("url",t.url);const n=`ReportingObserver [${t.type}]`;let s="No details available";if(t.body){const n={};for(const e in t.body)n[e]=t.body[e];if(e.setExtra("body",n),"crash"===t.type){const e=t.body;s=[e.crashId||"",e.reason||""].join(" ").trim()||s}else s=t.body.message||s}(0,c.uT)(`${n}: ${s}`)}))}return{name:_s,setupOnce(){(0,Vs.zb)()&&new Ks.ReportingObserver(n,{buffered:!0,types:t}).observe()},setup(e){Js.set(e,!0)}}})),Es=((0,g.RN)(_s,Fs),"RewriteFrames"),Us=(0,g._I)(((e={})=>{const t=e.root,n=e.prefix||"app:///",s=e.iteratee||(e=>{if(!e.filename)return e;const s=/^[a-zA-Z]:\\/.test(e.filename)||e.filename.includes("\\")&&!e.filename.includes("/"),i=/^\//.test(e.filename);if(s||i){const i=s?e.filename.replace(/^[a-zA-Z]:/,"").replace(/\\/g,"/"):e.filename,o=t?function(e,t){e=Nn(e).slice(1),t=Nn(t).slice(1);const n=wn(e.split("/")),s=wn(t.split("/")),i=Math.min(n.length,s.length);let o=i;for(let e=0;es(e)))}}return{name:Es,setupOnce(){},processEvent(e){let t=e;return e.exception&&Array.isArray(e.exception.values)&&(t=function(e){try{return{...e,exception:{...e.exception,values:e.exception.values.map((e=>({...e,...e.stacktrace&&{stacktrace:i(e.stacktrace)}})))}}}catch(t){return e}}(t)),t}}})),xs=((0,g.RN)(Es,Us),"SessionTiming"),Ts=(0,g._I)((()=>{const e=Date.now();return{name:xs,setupOnce(){},processEvent(t){const n=Date.now();return{...t,extra:{...t.extra,"session:start":e,"session:duration":n-e,"session:end":n}}}}})),zs=((0,g.RN)(xs,Ts),[["january","1"],["february","2"],["march","3"],["april","4"],["may","5"],["june","6"],["july","7"],["august","8"],["september","9"],["october","10"],["november","11"],["december","12"],["jan","1"],["feb","2"],["mar","3"],["apr","4"],["may","5"],["jun","6"],["jul","7"],["aug","8"],["sep","9"],["oct","10"],["nov","11"],["dec","12"],["sunday","0"],["monday","1"],["tuesday","2"],["wednesday","3"],["thursday","4"],["friday","5"],["saturday","6"],["sun","0"],["mon","1"],["tue","2"],["wed","3"],["thu","4"],["fri","5"],["sat","6"]]);function Ls(e){return zs.reduce(((e,[t,n])=>e.replace(new RegExp(t,"gi"),n)),e)}const Qs="Automatic instrumentation of CronJob only supports crontab string",js=Kn(),Os={...K,...o,...r},Ps={instrumentCron:function(e,t){let n=!1;return new Proxy(e,{construct(e,s){const[i,o,r,a,g,...l]=s;if("string"!=typeof i)throw new Error(Qs);if(n)throw new Error(`A job named '${t}' has already been scheduled`);n=!0;const d=Ls(i);return new e(i,(function(e,n){return(0,c.sV)(t,(()=>o(e,n)),{schedule:{type:"crontab",value:d},timezone:g||void 0})}),r,a,g,...l)},get:(e,s)=>"from"===s?s=>{const{cronTime:i,onTick:o,timeZone:r}=s;if("string"!=typeof i)throw new Error(Qs);if(n)throw new Error(`A job named '${t}' has already been scheduled`);n=!0;const a=Ls(i);return s.onTick=(e,n)=>(0,c.sV)(t,(()=>o(e,n)),{schedule:{type:"crontab",value:a},timezone:r||void 0}),e.from(s)}:e[s]})},instrumentNodeCron:function(e){return new Proxy(e,{get:(e,t)=>"schedule"===t&&e.schedule?new Proxy(e.schedule,{apply(e,t,n){const[s,,i]=n;if(!(0,je.x)([i,"optionalAccess",e=>e.name]))throw new Error('Missing "name" for scheduled job. A name is required for Sentry check-in monitoring.');return(0,c.sV)(i.name,(()=>e.apply(t,n)),{schedule:{type:"crontab",value:Ls(s)},timezone:(0,je.x)([i,"optionalAccess",e=>e.timezone])})}}):e[t]})},instrumentNodeSchedule:function(e){return new Proxy(e,{get:(e,t)=>"scheduleJob"===t?new Proxy(e.scheduleJob,{apply(e,t,n){const[s,i]=n;if("string"!=typeof s||"string"!=typeof i)throw new Error("Automatic instrumentation of 'node-schedule' requires the first parameter of 'scheduleJob' to be a job name string and the second parameter to be a crontab string");const o=s,r=i;return(0,c.sV)(o,(()=>e.apply(t,n)),{schedule:{type:"crontab",value:Ls(r)}})}}):e[t]})}}},6751:(e,t,n)=>{"use strict";n.d(t,{q:()=>m,z:()=>C});var s=n(4307);function i(e){const t=(0,s.x)(e);return null==t||t}var o=n(7310),r=n(350),a=n(3379),c=n(5659),g=n(4487),l=n(2967),d=n(2343),I=n(1235),u=n(2176),p=n(9656);function h(e,...t){d.kg.log(`[ANR] ${e}`,...t)}function b(){const e=(0,r.lW)().getScopeData();return(0,a.yo)(e,(0,c.aF)().getScopeData()),(0,a.yo)(e,(0,g.nZ)().getScopeData()),e.attachments=[],e.eventProcessors=[],e}e=n.hmd(e);const C=(0,l._I)(((t={})=>{if(p.V.major<16||16===p.V.major&&p.V.minor<17)throw new Error("ANR detection requires Node 16.17.0 or later");let r,a;return I.GLOBAL_OBJ.__SENTRY_GET_SCOPES__=b,{name:"Anr",setupOnce(){},startWorker:()=>{r||a&&(r=async function(t,r){const a=t.getDsn();if(!a)return()=>{};const c=await async function(e){let t={message:"ANR"};const n={};for(const s of e.getEventProcessors()){if(null===t)break;t=await s(t,n)}return(0,s.x)([t,"optionalAccess",e=>e.contexts])||{}}(t);i([c,"access",e=>e.app,"optionalAccess",e=>delete e.app_memory]),i([c,"access",e=>e.device,"optionalAccess",e=>delete e.free_memory]);const l=t.getOptions(),I=t.getSdkMetadata()||{};I.sdk&&(I.sdk.integrations=l.integrations.map((e=>e.name)));const p={debug:d.kg.isEnabled(),dsn:a,environment:l.environment||"production",release:l.release,dist:l.dist,sdkMetadata:I,appRootPath:r.appRootPath,pollInterval:r.pollInterval||50,anrThreshold:r.anrThreshold||5e3,captureStackTrace:!!r.captureStackTrace,staticTags:r.staticTags||{},contexts:c};if(p.captureStackTrace){const e=n(1405);e.url()||e.open(0)}const{Worker:b}=(0,u.l$)(e,"worker_threads"),C=new b(new o.URL("data:application/javascript;base64,a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eSB7CiAgICAgIGV4ZWN1dG9yKHRoaXMuX3Jlc29sdmUsIHRoaXMuX3JlamVjdCk7CiAgICB9IGNhdGNoIChlKSB7CiAgICAgIHRoaXMuX3JlamVjdChlKTsKICAgIH0KICB9CgogIC8qKiBKU0RvYyAqLwogICB0aGVuKAogICAgb25mdWxmaWxsZWQsCiAgICBvbnJlamVjdGVkLAogICkgewogICAgcmV0dXJuIG5ldyBTeW5jUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgIHRoaXMuX2hhbmRsZXJzLnB1c2goWwogICAgICAgIGZhbHNlLAogICAgICAgIHJlc3VsdCA9PiB7CiAgICAgICAgICBpZiAoIW9uZnVsZmlsbGVkKSB7CiAgICAgICAgICAgIC8vIFRPRE86IMKvXF8o44OEKV8vwq8KICAgICAgICAgICAgLy8gVE9ETzogRklYTUUKICAgICAgICAgICAgcmVzb2x2ZShyZXN1bHQgKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgcmVzb2x2ZShvbmZ1bGZpbGxlZChyZXN1bHQpKTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgIHJlamVjdChlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgcmVhc29uID0+IHsKICAgICAgICAgIGlmICghb25yZWplY3RlZCkgewogICAgICAgICAgICByZWplY3QocmVhc29uKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgcmVzb2x2ZShvbnJlamVjdGVkKHJlYXNvbikpOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgXSk7CiAgICAgIHRoaXMuX2V4ZWN1dGVIYW5kbGVycygpOwogICAgfSk7CiAgfQoKICAvKiogSlNEb2MgKi8KICAgY2F0Y2goCiAgICBvbnJlamVjdGVkLAogICkgewogICAgcmV0dXJuIHRoaXMudGhlbih2YWwgPT4gdmFsLCBvbnJlamVjdGVkKTsKICB9CgogIC8qKiBKU0RvYyAqLwogICBmaW5hbGx5KG9uZmluYWxseSkgewogICAgcmV0dXJuIG5ldyBTeW5jUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgIGxldCB2YWw7CiAgICAgIGxldCBpc1JlamVjdGVkOwoKICAgICAgcmV0dXJuIHRoaXMudGhlbigKICAgICAgICB2YWx1ZSA9PiB7CiAgICAgICAgICBpc1JlamVjdGVkID0gZmFsc2U7CiAgICAgICAgICB2YWwgPSB2YWx1ZTsKICAgICAgICAgIGlmIChvbmZpbmFsbHkpIHsKICAgICAgICAgICAgb25maW5hbGx5KCk7CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICByZWFzb24gPT4gewogICAgICAgICAgaXNSZWplY3RlZCA9IHRydWU7CiAgICAgICAgICB2YWwgPSByZWFzb247CiAgICAgICAgICBpZiAob25maW5hbGx5KSB7CiAgICAgICAgICAgIG9uZmluYWxseSgpOwogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICkudGhlbigoKSA9PiB7CiAgICAgICAgaWYgKGlzUmVqZWN0ZWQpIHsKICAgICAgICAgIHJlamVjdCh2YWwpOwogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KCiAgICAgICAgcmVzb2x2ZSh2YWwgKTsKICAgICAgfSk7CiAgICB9KTsKICB9CgogIC8qKiBKU0RvYyAqLwogICAgX19pbml0KCkge3RoaXMuX3Jlc29sdmUgPSAodmFsdWUpID0+IHsKICAgIHRoaXMuX3NldFJlc3VsdChTdGF0ZXMuUkVTT0xWRUQsIHZhbHVlKTsKICB9O30KCiAgLyoqIEpTRG9jICovCiAgICBfX2luaXQyKCkge3RoaXMuX3JlamVjdCA9IChyZWFzb24pID0+IHsKICAgIHRoaXMuX3NldFJlc3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ICAgdGhpcy5fcmVxdWVzdFNlc3Npb24gPSByZXF1ZXN0U2Vzc2lvbjsKICAgIHJldHVybiB0aGlzOwogIH0KCiAgLyoqCiAgICogQGluaGVyaXREb2MKICAgKi8KICAgc2V0VGFncyh0YWdzKSB7CiAgICB0aGlzLl90YWdzID0gewogICAgICAuLi50aGlzLl90YWdzLAogICAgICAuLi50YWdzLAogICAgfTsKICAgIHRoaXMuX25vdGlmeVNjb3BlTGlzdGVuZXJzKCk7CiAgICByZXR1cm4gdGhpczsKICB9CgogIC8qKgogICAqIEBpbmhlcml0RG9jCiAgICovCiAgIHNldFRhZyhrZXksIHZhbHVlKSB7CiAgICB0aGlzLl90YWdzID0geyAuLi50aGlzLl90YWdzLCBba2V5XTogdmFsdWUgfTsKICAgIHRoaXMuX25vdGlmeVNjb3BlTGlzdGVuZXJzKCk7CiAgICByZXR1cm4gdGhpczsKICB9CgogIC8qKgogICAqIEBpbmhlcml0RG9jCiAgICovCiAgIHNldEV4dHJhcyhleHRyYXMpIHsKICAgIHRoaXMuX2V4dHJhID0gewogICAgICAuLi50aGlzLl9leHRyYSwKICAgICAgLi4uZXh0cmFzLAogICAgfTsKICAgIHRoaXMuX25vdGlmeVNjb3BlTGlzdGVuZXJzKCk7CiAgICByZXR1cm4gdGhpczsKICB9CgogIC8qKgogICAqIEBpbmhlcml0RG9jCiAgICovCiAgIHNldEV4dHJhKGtleSwgZXh0cmEpIHsKICAgIHRoaXMuX2V4dHJhID0geyAuLi50aGlzLl9leHRyYSwgW2tleV06IGV4dHJhIH07CiAgICB0aGlzLl9ub3RpZnlTY29wZUxpc3RlbmVycygpOwogICAgcmV0dXJuIHRoaXM7CiAgfQoKICAvKioKICAgKiBAaW5oZXJpdERvYwogICAqLwogICBzZXRGaW5nZXJwcmludChmaW5nZXJwcmludCkgewogICAgdGhpcy5fZmluZ2VycHJpbnQgPSBmaW5nZXJwcmludDsKICAgIHRoaXMuX25vdGlmeVNjb3BlTGlzdGVuZXJzKCk7CiAg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Y29wZUxpc3RlbmVycygpOwoKICAgIHJldHVybiB0aGlzOwogIH0KCiAgLyoqCiAgICogQGluaGVyaXREb2MKICAgKi8KICAgZ2V0TGFzdEJyZWFkY3J1bWIoKSB7CiAgICByZXR1cm4gdGhpcy5fYnJlYWRjcnVtYnNbdGhpcy5fYnJlYWRjcnVtYnMubGVuZ3RoIC0gMV07CiAgfQoKICAvKioKICAgKiBAaW5oZXJpdERvYwogICAqLwogICBjbGVhckJyZWFkY3J1bWJzKCkgewogICAgdGhpcy5fYnJlYWRjcnVtYnMgPSBbXTsKICAgIHRoaXMuX25vdGlmeVNjb3BlTGlzdGVuZXJzKCk7CiAgICByZXR1cm4gdGhpczsKICB9CgogIC8qKgogICAqIEBpbmhlcml0RG9jCiAgICovCiAgIGFkZEF0dGFjaG1lbnQoYXR0YWNobWVudCkgewogICAgdGhpcy5fYXR0YWNobWVudHMucHVzaChhdHRhY2htZW50KTsKICAgIHJldHVybiB0aGlzOwogIH0KCiAgLyoqCiAgICogQGluaGVyaXREb2MKICAgKiBAZGVwcmVjYXRlZCBVc2UgYGdldFNjb3BlRGF0YSgpYCBpbnN0ZWFkLgogICAqLwogICBnZXRBdHRhY2htZW50cygpIHsKICAgIGNvbnN0IGRhdGEgPSB0aGlzLmdldFNjb3BlRGF0YSgpOwoKICAgIHJldHVybiBkYXRhLmF0dGFjaG1lbnRzOwogIH0KCiAgLyoqCiAgICogQGluaGVyaXREb2MKICAgKi8KICAgY2xlYXJBdHRhY2htZW50cygpIHsKICAgIHRoaXMuX2F0dGFjaG1lbnRzID0gW107CiAgICByZXR1cm4gdGhpczsKICB9CgogIC8qKiBAaW5oZXJpdERvYyAqLwogICBnZXRTY29wZURhdGEoKSB7CiAgICBjb25zdCB7CiAgICAgIF9icmVhZGNydW1icywKICAgICAgX2F0dGFjaG1lbnRzLAogICAgICBfY29udGV4dHMsCiAgICAgIF90YWdzLAogICAgICBfZXh0cmEsCiAgICAgIF91c2VyLAogICAgICBfbGV2ZWwsCi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wogICAqIGh1Yi5iaW5kQ2xpZW50KGNsaWVudCk7CiAgICogbWFrZU1haW4oaHViKQogICAqIGBgYAogICAqCiAgICogaW5zdGVhZCBpbml0aWFsaXplIHRoZSBjbGllbnQgYXMgZm9sbG93czoKICAgKgogICAqIGBgYAogICAqIC8vIE5FVwogICAqIFNlbnRyeS53aXRoSXNvbGF0aW9uU2NvcGUoKCkgPT4gewogICAqICAgIFNlbnRyeS5zZXRDdXJyZW50Q2xpZW50KGNsaWVudCk7CiAgICogICAgY2xpZW50LmluaXQoKTsKICAgKiB9KTsKICAgKiBgYGAKICAgKgogICAqIElmIHlvdSBhcmUgdXNpbmcgdGhlIEh1YiB0byBjYXB0dXJlIGV2ZW50cyBsaWtlIHNvOgogICAqCiAgICogYGBgCiAgICogLy8gT0xECiAgICogY29uc3QgY2xpZW50ID0gbmV3IENsaWVudCgpOwogICAqIGNvbnN0IGh1YiA9IG5ldyBIdWIoY2xpZW50KTsKICAgKiBodWIuY2FwdHVyZUV4Y2VwdGlvbigpCiAgICogYGBgCiAgICoKICAgKiBpbnN0ZWFkIGNhcHR1cmUgaXNvbGF0ZWQgZXZlbnRzIGFzIGZvbGxvd3M6CiAgICoKICAgKiBgYGAKICAgKiAvLyBORVcKICAgKiBjb25zdCBjbGllbnQgPSBuZXcgQ2xpZW50KCk7CiAgICogY29uc3Qgc2NvcGUgPSBuZXcgU2NvcGUoKTsKICAgKiBzY29wZS5zZXRDbGllbnQoY2xpZW50KTsKICAgKiBzY29wZS5jYXB0dXJlRXhjZXB0aW9uKCk7CiAgICogYGBgCiAgICovCiAgIGNvbnN0cnVjdG9yKAogICAgY2xpZW50LAogICAgc2NvcGUsCiAgICBpc29sYXRpb25TY29wZSwKICAgICAgX3ZlcnNpb24gPSBBUElfVkVSU0lPTiwKICApIHt0aGlzLl92ZXJzaW9uID0gX3ZlcnNpb247CiAgICBsZXQgYXNzaWduZWRTY29wZTsKICAgIGlmICghc2NvcGUpIHsKICAgICAgYXNzaWduZWRT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0Y2ggKGUpIHsKICAgICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIGRlcHJlY2F0aW9uL2RlcHJlY2F0aW9uCiAgICAgIHRoaXMucG9wU2NvcGUoKTsKICAgICAgdGhyb3cgZTsKICAgIH0KCiAgICBpZiAoaXNUaGVuYWJsZShtYXliZVByb21pc2VSZXN1bHQpKSB7CiAgICAgIC8vIEB0cy1leHBlY3QtZXJyb3IgLSBpc1RoZW5hYmxlIHJldHVybnMgdGhlIHdyb25nIHR5cGUKICAgICAgcmV0dXJuIG1heWJlUHJvbWlzZVJlc3VsdC50aGVuKAogICAgICAgIHJlcyA9PiB7CiAgICAgICAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZGVwcmVjYXRpb24vZGVwcmVjYXRpb24KICAgICAgICAgIHRoaXMucG9wU2NvcGUoKTsKICAgICAgICAgIHJldHVybiByZXM7CiAgICAgICAgfSwKICAgICAgICBlID0+IHsKICAgICAgICAgIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBkZXByZWNhdGlvbi9kZXByZWNhdGlvbgogICAgICAgICAgdGhpcy5wb3BTY29wZSgpOwogICAgICAgICAgdGhyb3cgZTsKICAgICAgICB9LAogICAgICApOwogICAgfQoKICAgIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBkZXByZWNhdGlvbi9kZXByZWNhdGlvbgogICAgdGhpcy5wb3BTY29wZSgpOwogICAgcmV0dXJuIG1heWJlUHJvbWlzZVJlc3VsdDsKICB9CgogIC8qKgogICAqIEBpbmhlcml0RG9jCiAgICoKICAgKiBAZGVwcmVjYXRlZCBVc2UgYFNlbnRyeS5nZXRDbGllbnQoKWAgaW5zdGVhZC4KICAgKi8KICAgZ2V0Q2xpZW50KCkgewogICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIGRlcHJlY2F0aW9uL2RlcHJlY2F0aW9uCiAgICByZXR1cm4gdGhpcy5nZXRTdGFja1RvcCgpLmNs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lamVjdChuZXcgRXJyb3IoYEludmFsaWQgaGVhZGVyIGZyb20gcHJveHkgQ09OTkVDVCByZXNwb25zZTogIiR7aGVhZGVyfSJgKSk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGtleSA9IGhlYWRlci5zbGljZSgwLCBmaXJzdENvbG9uKS50b0xvd2VyQ2FzZSgpOwogICAgICAgIGNvbnN0IHZhbHVlID0gaGVhZGVyLnNsaWNlKGZpcnN0Q29sb24gKyAxKS50cmltU3RhcnQoKTsKICAgICAgICBjb25zdCBjdXJyZW50ID0gaGVhZGVyc1trZXldOwogICAgICAgIGlmICh0eXBlb2YgY3VycmVudCA9PT0gJ3N0cmluZycpIHsKICAgICAgICAgIGhlYWRlcnNba2V5XSA9IFtjdXJyZW50LCB2YWx1ZV07CiAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KGN1cnJlbnQpKSB7CiAgICAgICAgICBjdXJyZW50LnB1c2godmFsdWUpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBoZWFkZXJzW2tleV0gPSB2YWx1ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZGVidWckMSgnZ290IHByb3h5IHNlcnZlciByZXNwb25zZTogJW8gJW8nLCBmaXJzdExpbmUsIGhlYWRlcnMpOwogICAgICBjbGVhbnVwKCk7CiAgICAgIHJlc29sdmUoewogICAgICAgIGNvbm5lY3Q6IHsKICAgICAgICAgIHN0YXR1c0NvZGUsCiAgICAgICAgICBzdGF0dXNUZXh0LAogICAgICAgICAgaGVhZGVycywKICAgICAgICB9LAogICAgICAgIGJ1ZmZlcmVkLAogICAgICB9KTsKICAgIH0KCiAgICBzb2NrZXQub24oJ2Vycm9yJywgb25lcnJvcik7CiAgICBzb2NrZXQub24oJ2VuZCcsIG9uZW5kKTsKCiAgICByZWFkKCk7CiAgfSk7Cn0KCmZ1bmN0aW9uIF9udWxsaXNoQ29hbGVzY2UkMShsaHMsIHJoc0ZuKSB7IGlmIChsaHMgIT0gbnVs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mIChyZXF1ZXN0LmJvZHkubGVuZ3RoID4gR1pJUF9USFJFU0hPTEQpIHsKICAgICAgICBoZWFkZXJzWydjb250ZW50LWVuY29kaW5nJ10gPSAnZ3ppcCc7CiAgICAgICAgYm9keSA9IGJvZHkucGlwZShjcmVhdGVHemlwKCkpOwogICAgICB9CgogICAgICBjb25zdCByZXEgPSBodHRwTW9kdWxlLnJlcXVlc3QoCiAgICAgICAgewogICAgICAgICAgbWV0aG9kOiAnUE9TVCcsCiAgICAgICAgICBhZ2VudCwKICAgICAgICAgIGhlYWRlcnMsCiAgICAgICAgICBob3N0bmFtZSwKICAgICAgICAgIHBhdGg6IGAke3BhdGhuYW1lfSR7c2VhcmNofWAsCiAgICAgICAgICBwb3J0LAogICAgICAgICAgcHJvdG9jb2wsCiAgICAgICAgICBjYTogb3B0aW9ucy5jYUNlcnRzLAogICAgICAgIH0sCiAgICAgICAgcmVzID0+IHsKICAgICAgICAgIHJlcy5vbignZGF0YScsICgpID0+IHsKICAgICAgICAgICAgLy8gRHJhaW4gc29ja2V0CiAgICAgICAgICB9KTsKCiAgICAgICAgICByZXMub24oJ2VuZCcsICgpID0+IHsKICAgICAgICAgICAgLy8gRHJhaW4gc29ja2V0CiAgICAgICAgICB9KTsKCiAgICAgICAgICByZXMuc2V0RW5jb2RpbmcoJ3V0ZjgnKTsKCiAgICAgICAgICAvLyAiS2V5LXZhbHVlIHBhaXJzIG9mIGhlYWRlciBuYW1lcyBhbmQgdmFsdWVzLiBIZWFkZXIgbmFtZXMgYXJlIGxvd2VyLWNhc2VkLiIKICAgICAgICAgIC8vIGh0dHBzOi8vbm9kZWpzLm9yZy9hcGkvaHR0cC5odG1sI2h0dHBfbWVzc2FnZV9oZWFkZXJzCiAgICAgICAgICBjb25zdCByZXRyeUFmdGVySGVhZGVyID0gX251bGxpc2hDb2FsZXNjZShyZXMuaGVhZGVyc1sncmV0cnktYWZ0ZXInXSwgKCkgPT4gKCBudWxsKSk7CiAgICAgICAgICBjb25zdC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AobXNnLnNlc3Npb24pIHsKICAgIHNlc3Npb24gPSBtYWtlU2Vzc2lvbihtc2cuc2Vzc2lvbik7CiAgfQoKICBwb2xsKCk7Cn0pXSk7"),{workerData:p});process.on("exit",(()=>{C.terminate()}));const m=setInterval((()=>{try{const e=(0,g.nZ)().getSession(),t=e?{...e,toJSON:void 0}:void 0;C.postMessage({session:t})}catch(e){}}),p.pollInterval);return m.unref(),C.on("message",(e=>{"session-ended"===e&&(h("ANR event sent from ANR worker. Clearing session in this thread."),(0,g.nZ)().setSession(void 0))})),C.once("error",(e=>{clearInterval(m),h("ANR worker error",e)})),C.once("exit",(e=>{clearInterval(m),h("ANR worker exit",e)})),C.unref(),()=>{C.terminate(),clearInterval(m)}}(a,t))},stopWorker:()=>{r&&r.then((e=>{e(),r=void 0}))},setup(e){a=e,setImmediate((()=>this.startWorker()))}}})),m=(0,l.RN)("Anr",C)},9656:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});const s=(0,n(2844).J4)(process.versions.node)},1257:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BROWSER_TRACING_INTEGRATION_ID:()=>It,BrowserTracing:()=>ot,IdleTransaction:()=>Ct,Integrations:()=>yt,Span:()=>dt,SpanStatus:()=>Gt,TRACEPARENT_REGEXP:()=>bt,Transaction:()=>lt,addExtensionMethods:()=>rt,defaultRequestInstrumentationOptions:()=>ut,extractTraceparentData:()=>ct,getActiveTransaction:()=>at,hasTracingEnabled:()=>pt,instrumentOutgoingRequests:()=>mt,spanStatusfromHttpCode:()=>gt,startIdleTransaction:()=>Zt,stripUrlQueryAndFragment:()=>ht});var s=n(5544),i=n(3207),o=n(9791),r=n(6754),a=n(4487),c=n(2343),g=n(7638),l=n(8464),d=n(7513),I=n(3371),u=n(1235);const p=u.GLOBAL_OBJ;var h=n(6147);const b=(e,t,n)=>{let s,i;return o=>{t.value>=0&&(o||n)&&(i=t.value-(s||0),(i||void 0===s)&&(s=t.value,t.delta=i,e(t)))}},C=()=>p.__WEB_VITALS_POLYFILL__?p.performance&&(performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]||(()=>{const e=p.performance.timing,t=p.performance.navigation.type,n={entryType:"navigation",startTime:0,type:2==t?"back_forward":1===t?"reload":"navigate"};for(const t in e)"navigationStart"!==t&&"toJSON"!==t&&(n[t]=Math.max(e[t]-e.navigationStart,0));return n})()):p.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0],m=()=>{const e=C();return e&&e.activationStart||0},Z=(e,t)=>{const n=C();let s="navigate";return n&&(s=p.document&&p.document.prerendering||m()>0?"prerender":n.type.replace(/_/g,"-")),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:`v3-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:s}},G=(e,t,n)=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const s=new PerformanceObserver((e=>{t(e.getEntries())}));return s.observe(Object.assign({type:e,buffered:!0},n||{})),s}}catch(e){}},y=(e,t)=>{const n=s=>{"pagehide"!==s.type&&"hidden"!==p.document.visibilityState||(e(s),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};p.document&&(addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0))},B=e=>{const t=Z("CLS",0);let n,s=0,i=[];const o=e=>{e.forEach((e=>{if(!e.hadRecentInput){const o=i[0],r=i[i.length-1];s&&0!==i.length&&e.startTime-r.startTime<1e3&&e.startTime-o.startTime<5e3?(s+=e.value,i.push(e)):(s=e.value,i=[e]),s>t.value&&(t.value=s,t.entries=i,n&&n())}}))},r=G("layout-shift",o);if(r){n=b(e,t);const s=()=>{o(r.takeRecords()),n(!0)};return y(s),s}};let A=-1;const W=()=>(A<0&&(p.document&&p.document.visibilityState&&(A="hidden"!==p.document.visibilityState||p.document.prerendering?1/0:0),y((({timeStamp:e})=>{A=e}),!0)),{get firstHiddenTime(){return A}}),f=e=>{const t=W(),n=Z("FID");let s;const i=e=>{e.startTime{e.forEach(i)},r=G("first-input",o);s=b(e,n),r&&y((()=>{o(r.takeRecords()),r.disconnect()}),!0)};let V=0,v=1/0,R=0;const S=e=>{e.forEach((e=>{e.interactionId&&(v=Math.min(v,e.interactionId),R=Math.max(R,e.interactionId),V=R?(R-v)/7+1:0)}))};let X;const Y=()=>{"interactionCount"in performance||X||(X=G("event",S,{type:"event",buffered:!0,durationThreshold:0}))},H=()=>X?V:performance.interactionCount||0,N=[],w={},k=e=>{const t=N[N.length-1],n=w[e.interactionId];if(n||N.length<10||e.duration>t.latency){if(n)n.entries.push(e),n.latency=Math.max(n.latency,e.duration);else{const t={id:e.interactionId,latency:e.duration,entries:[e]};w[t.id]=t,N.push(t)}N.sort(((e,t)=>t.latency-e.latency)),N.splice(10).forEach((e=>{delete w[e.id]}))}},K=(e,t)=>{t=t||{},Y();const n=Z("INP");let s;const i=e=>{e.forEach((e=>{e.interactionId&&k(e),"first-input"===e.entryType&&!N.some((t=>t.entries.some((t=>e.duration===t.duration&&e.startTime===t.startTime))))&&k(e)}));const t=(()=>{const e=Math.min(N.length-1,Math.floor(H()/50));return N[e]})();t&&t.latency!==n.value&&(n.value=t.latency,n.entries=t.entries,s())},o=G("event",i,{durationThreshold:t.durationThreshold||40});s=b(e,n,t.reportAllChanges),o&&(o.observe({type:"first-input",buffered:!0}),y((()=>{i(o.takeRecords()),n.value<0&&H()>0&&(n.value=0,n.entries=[]),s(!0)})))},_={},J=e=>{const t=W(),n=Z("LCP");let s;const i=e=>{const i=e[e.length-1];if(i){const e=Math.max(i.startTime-m(),0);e{_[n.id]||(i(o.takeRecords()),o.disconnect(),_[n.id]=!0,s(!0))};return["keydown","click"].forEach((e=>{p.document&&addEventListener(e,t,{once:!0,capture:!0})})),y(t,!0),t}},F=e=>{p.document&&(p.document.prerendering?addEventListener("prerenderingchange",(()=>F(e)),!0):"complete"!==p.document.readyState?addEventListener("load",(()=>F(e)),!0):setTimeout(e,0))},E=(e,t)=>{t=t||{};const n=Z("TTFB"),s=b(e,n,t.reportAllChanges);F((()=>{const e=C();if(e){if(n.value=Math.max(e.responseStart-m(),0),n.value<0||n.value>performance.now())return;n.entries=[e],s(!0)}}))},U={},x={};let T,z,L,Q,j;function O(e,t){return ne(e,t),x[e]||(function(e){const t={};"event"===e&&(t.durationThreshold=0),G(e,(t=>{P(e,{entries:t})}),t)}(e),x[e]=!0),se(e,t)}function P(e,t){const n=U[e];if(n&&n.length)for(const s of n)try{s(t)}catch(t){d.X&&c.kg.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${(0,h.$P)(s)}\nError:`,t)}}function M(){return B((e=>{P("cls",{metric:e}),T=e}))}function D(){return f((e=>{P("fid",{metric:e}),z=e}))}function q(){return J((e=>{P("lcp",{metric:e}),L=e}))}function $(){return E((e=>{P("ttfb",{metric:e}),Q=e}))}function ee(){return K((e=>{P("inp",{metric:e}),j=e}))}function te(e,t,n,s,i=!1){let o;return ne(e,t),x[e]||(o=n(),x[e]=!0),s&&t({metric:s}),se(e,t,i?o:void 0)}function ne(e,t){U[e]=U[e]||[],U[e].push(t)}function se(e,t,n){return()=>{n&&n();const s=U[e];if(!s)return;const i=s.indexOf(t);-1!==i&&s.splice(i,1)}}var ie=n(8903),oe=n(292);n(8725);function re(e){return[{type:"span"},e]}var ae=n(9080),ce=n(7522),ge=n(1221),le=n(1170),de=n(6956);function Ie(e){return"number"==typeof e&&isFinite(e)}function ue(e,{startTimestamp:t,...n}){return t&&e.startTimestamp>t&&(e.startTimestamp=t),e.startChild({startTimestamp:t,...n})}const pe=2147483647;function he(e){return e/1e3}function be(){return p&&p.addEventListener&&p.performance}let Ce,me,Ze=0,Ge={};function ye(){const e=be();if(e&&le.Z1){e.mark&&p.performance.mark("sentry-tracing-init");const t=te("fid",(({metric:e})=>{const t=e.entries[e.entries.length-1];if(!t)return;const n=he(le.Z1),s=he(t.startTime);d.X&&c.kg.log("[Measurements] Adding FID"),Ge.fid={value:e.value,unit:"millisecond"},Ge["mark.fid"]={value:n+s,unit:"second"}}),D,z),n=function(e,t=!1){return te("cls",e,M,T,t)}((({metric:e})=>{const t=e.entries[e.entries.length-1];t&&(d.X&&c.kg.log("[Measurements] Adding CLS"),Ge.cls={value:e.value,unit:""},me=t)}),!0),s=function(e,t=!1){return te("lcp",e,q,L,t)}((({metric:e})=>{const t=e.entries[e.entries.length-1];t&&(d.X&&c.kg.log("[Measurements] Adding LCP"),Ge.lcp={value:e.value,unit:"millisecond"},Ce=t)}),!0),i=te("ttfb",(({metric:e})=>{e.entries[e.entries.length-1]&&(d.X&&c.kg.log("[Measurements] Adding TTFB"),Ge.ttfb={value:e.value,unit:"millisecond"})}),$,Q);return()=>{t(),n(),s(),i()}}return()=>{}}const Be={click:"click",pointerdown:"click",pointerup:"click",mousedown:"click",mouseup:"click",touchstart:"click",touchend:"click",mouseover:"hover",mouseout:"hover",mouseenter:"hover",mouseleave:"hover",pointerover:"hover",pointerout:"hover",pointerenter:"hover",pointerleave:"hover",dragstart:"drag",dragend:"drag",drag:"drag",dragenter:"drag",dragleave:"drag",dragover:"drag",drop:"drag",keydown:"press",keyup:"press",keypress:"press",input:"press"};function Ae(e,t,n,s,i,o){const r=o?t[o]:t[`${n}End`],a=t[`${n}Start`];a&&r&&ue(e,{op:"browser",origin:"auto.browser.browser.metrics",description:i||n,startTimestamp:s+he(a),endTimestamp:s+he(r)})}function We(e,t,n,s){const i=t[n];null!=i&&i!0,d=e=>function(e,t){return(0,Ye.U0)(e,t||we)}(e,s||i),u={};t&&(0,Se.U)((e=>{const t=function(e,t,n,s,i="auto.http.browser"){if(!(0,ce.z)()||!e.fetchData)return;const o=t(e.fetchData.url);if(e.endTimestamp&&o){const t=e.fetchData.__span;if(!t)return;const n=s[t];return void(n&&(function(e,t){if(t.response){(0,fe.Q0)(e,t.response.status);const n=t.response&&t.response.headers&&t.response.headers.get("content-length");if(n){const t=parseInt(n);t>0&&e.setAttribute("http.response_content_length",t)}}else t.error&&e.setStatus("internal_error");e.end()}(n,e),delete s[t]))}const c=(0,a.nZ)(),l=(0,a.s3)(),{method:d,url:u}=e.fetchData,p=function(e){try{return new URL(e).href}catch(e){return}}(u),h=p?(0,de.en)(p).host:void 0,b=o?(0,ve.qp)({name:`${d} ${u}`,onlyIfParent:!0,attributes:{url:u,type:"fetch","http.method":d,"http.url":p,"server.address":h,[r.S3]:i},op:"http.client"}):void 0;if(b&&(e.fetchData.__span=b.spanContext().spanId,s[b.spanContext().spanId]=b),n(e.fetchData.url)&&l){const t=e.args[0];e.args[1]=e.args[1]||{};const n=e.args[1];n.headers=function(e,t,n,s,i){const o=i||n.getSpan(),r=(0,Ve.aF)(),{traceId:a,spanId:c,sampled:l,dsc:d}={...r.getPropagationContext(),...n.getPropagationContext()},u=o?(0,I.Hb)(o):(0,g.$p)(a,c,l),p=(0,He.IQ)(d||(o?(0,Re.j)(o):(0,Re._)(a,t,n))),h=s.headers||("undefined"!=typeof Request&&(0,Ne.V9)(e,Request)?e.headers:void 0);if(h){if("undefined"!=typeof Headers&&(0,Ne.V9)(h,Headers)){const e=new Headers(h);return e.append("sentry-trace",u),p&&e.append(He.bU,p),e}if(Array.isArray(h)){const e=[...h,["sentry-trace",u]];return p&&e.push([He.bU,p]),e}{const e="baggage"in h?h.baggage:void 0,t=[];return Array.isArray(e)?t.push(...e):e&&t.push(e),p&&t.push(p),{...h,"sentry-trace":u,baggage:t.length>0?t.join(","):void 0}}}return{"sentry-trace":u,baggage:p}}(t,l,c,n,b)}return b}(e,l,d,u);if(t){const n=Fe(e.fetchData.url),s=n?(0,de.en)(n).host:void 0;t.setAttributes({"http.url":n,"server.address":s})}c&&t&&_e(t)})),n&&(0,Xe.UK)((e=>{const t=function(e,t,n,s){const i=e.xhr,o=i&&i[Xe.xU];if(!(0,ce.z)()||!i||i.__sentry_own_request__||!o)return;const c=t(o.url);if(e.endTimestamp&&c){const e=i.__sentry_xhr_span_id__;if(!e)return;const t=s[e];return void(t&&void 0!==o.status_code&&((0,fe.Q0)(t,o.status_code),t.end(),delete s[e]))}const l=(0,a.nZ)(),d=(0,Ve.aF)(),u=Fe(o.url),p=u?(0,de.en)(u).host:void 0,h=c?(0,ve.qp)({name:`${o.method} ${o.url}`,onlyIfParent:!0,attributes:{type:"xhr","http.method":o.method,"http.url":u,url:o.url,"server.address":p,[r.S3]:"auto.http.browser"},op:"http.client"}):void 0;h&&(i.__sentry_xhr_span_id__=h.spanContext().spanId,s[i.__sentry_xhr_span_id__]=h);const b=(0,a.s3)();if(i.setRequestHeader&&n(o.url)&&b){const{traceId:e,spanId:t,sampled:n,dsc:s}={...d.getPropagationContext(),...l.getPropagationContext()};!function(e,t,n){try{e.setRequestHeader("sentry-trace",t),n&&e.setRequestHeader(He.bU,n)}catch(e){}}(i,h?(0,I.Hb)(h):(0,g.$p)(e,t,n),(0,He.IQ)(s||(h?(0,Re.j)(h):(0,Re._)(e,b,l))))}return h}(e,l,d,u);c&&t&&_e(t)}))}function _e(e){const{url:t}=(0,I.XU)(e).data||{};if(!t||"string"!=typeof t)return;const n=O("resource",(({entries:s})=>{s.forEach((s=>{(function(e){return"resource"===e.entryType&&"initiatorType"in e&&"string"==typeof e.nextHopProtocol&&("fetch"===e.initiatorType||"xmlhttprequest"===e.initiatorType)})(s)&&s.name.endsWith(t)&&(function(e){const{name:t,version:n}=function(e){let t="unknown",n="unknown",s="";for(const i of e){if("/"===i){[t,n]=e.split("/");break}if(!isNaN(Number(i))){t="h"===s?"http":s,n=e.split(s)[1];break}s+=i}return s===e&&(t=s),{name:t,version:n}}(e.nextHopProtocol),s=[];return s.push(["network.protocol.version",n],["network.protocol.name",t]),le.Z1?[...s,["http.request.redirect_start",Je(e.redirectStart)],["http.request.fetch_start",Je(e.fetchStart)],["http.request.domain_lookup_start",Je(e.domainLookupStart)],["http.request.domain_lookup_end",Je(e.domainLookupEnd)],["http.request.connect_start",Je(e.connectStart)],["http.request.secure_connection_start",Je(e.secureConnectionStart)],["http.request.connection_end",Je(e.connectEnd)],["http.request.request_start",Je(e.requestStart)],["http.request.response_start",Je(e.responseStart)],["http.request.response_end",Je(e.responseEnd)]]:s}(s).forEach((t=>e.setAttribute(...t))),setTimeout(n))}))}))}function Je(e=0){return((le.Z1||performance.timeOrigin)+e)/1e3}function Fe(e){try{return new URL(e,p.location.origin).href}catch(e){return}}var Ee=n(535);const Ue=(0,u.R)();var xe=n(9729);const Te=u.GLOBAL_OBJ;let ze;function Le(){if(!function(){const e=Ue.chrome,t=e&&e.app&&e.app.runtime,n="history"in Ue&&!!Ue.history.pushState&&!!Ue.history.replaceState;return!t&&n}())return;const e=Te.onpopstate;function t(e){return function(...t){const n=t.length>2?t[2]:void 0;if(n){const e=ze,t=String(n);ze=t;const s={from:e,to:t};(0,xe.rK)("history",s)}return e.apply(this,t)}}Te.onpopstate=function(...t){const n=Te.location.href,s=ze;ze=n;const i={from:s,to:n};if((0,xe.rK)("history",i),e)try{return e.apply(this,t)}catch(e){}},(0,Ee.hl)(Te.history,"pushState",t),(0,Ee.hl)(Te.history,"replaceState",t)}const Qe="BrowserTracing",je={...s.AT,markBackgroundTransactions:!0,routingInstrumentation:function(e,t=!0,n=!0){if(!p||!p.location)return void(d.X&&c.kg.warn("Could not initialize routing instrumentation due to invalid location"));let s,i=p.location.href;t&&(s=e({name:p.location.pathname,startTimestamp:le.Z1?le.Z1/1e3:void 0,op:"pageload",origin:"auto.pageload.browser",metadata:{source:"url"}})),n&&function(t){const n="history";(0,xe.Hj)(n,(({to:t,from:n})=>{void 0===n&&i&&-1!==i.indexOf(t)?i=void 0:n!==t&&(i=void 0,s&&(d.X&&c.kg.log(`[Tracing] Finishing current transaction with op: ${s.op}`),s.end()),s=e({name:p.location.pathname,op:"navigation",origin:"auto.navigation.browser",metadata:{source:"url"}}))})),(0,xe.D2)(n,Le)}()},startTransactionOnLocationChange:!0,startTransactionOnPageLoad:!0,enableLongTask:!0,enableInp:!1,interactionsSampleRate:1,_experiments:{},...ke};function Oe(e){const t=(0,l.qT)(`meta[name=${e}]`);return t?t.getAttribute("content"):void 0}function Pe(e){const t=e.attributes&&e.attributes[r.Zj],n=e.data&&e.data[r.Zj],s=e.metadata&&e.metadata.source;return t||n||s}var Me=n(758),De=n(8069),qe=n(2716),$e=n(8737),et=n(1791),tt=n(6169),nt=n(24),st=n(1370),it=n(9889);const ot=class{constructor(e){this.name=Qe,this._hasSetTracePropagationTargets=!1,(0,i.T)(),d.X&&(this._hasSetTracePropagationTargets=!(!e||!e.tracePropagationTargets&&!e.tracingOrigins)),this.options={...je,...e},void 0!==this.options._experiments.enableLongTask&&(this.options.enableLongTask=this.options._experiments.enableLongTask),e&&!e.tracePropagationTargets&&e.tracingOrigins&&(this.options.tracePropagationTargets=e.tracingOrigins),this._collectWebVitals=ye(),this._interactionIdToRouteNameMapping={},this.options.enableInp&&function(e,t){if(be()&&le.Z1){const n=function(e,t){return n=({metric:n})=>{if(void 0===n.value)return;const s=n.entries.find((e=>e.duration===n.value&&void 0!==Be[e.name])),i=(0,a.s3)();if(!s||!i)return;const o=Be[s.name],r=i.getOptions(),g=he(le.Z1+s.startTime),I=he(n.value),u=void 0!==s.interactionId?e[s.interactionId]:void 0;if(void 0===u)return;const{routeName:h,parentContext:b,activeTransaction:C,user:m,replayId:Z}=u,G=void 0!==m?m.email||m.id||m.ip_address:void 0,y=void 0!==C?C.getProfileId():void 0,B=new ie.D({startTimestamp:g,endTimestamp:g+I,op:`ui.interaction.${o}`,name:(0,l.Rt)(s.target),attributes:{release:r.release,environment:r.environment,transaction:h,...void 0!==G&&""!==G?{user:G}:{},...void 0!==y?{profile_id:y}:{},...void 0!==Z?{replay_id:Z}:{}},exclusiveTime:n.value,measurements:{inp:{value:n.value,unit:"millisecond"}}}),A=function(e,t,n){if(!(0,ce.z)(t))return!1;let s;return s=void 0!==e&&"function"==typeof t.tracesSampler?t.tracesSampler({transactionContext:e,name:e.name,parentSampled:e.parentSampled,attributes:{...e.data,...e.attributes},location:p.location}):void 0!==e&&void 0!==e.sampled?e.sampled:void 0!==t.tracesSampleRate?t.tracesSampleRate:1,(0,ge.X)(s)?!0===s?n:!1===s?0:s*n:(d.X&&c.kg.warn("[Tracing] Discarding interaction span because of invalid sample rate."),!1)}(b,r,t);if(A&&Math.random(){d.X&&c.kg.error("Error while sending interaction:",e)}))}},te("inp",n,ee,j);var n}(e,t);return()=>{n()}}}(this._interactionIdToRouteNameMapping,this.options.interactionsSampleRate),this.options.enableLongTask&&O("longtask",(({entries:e})=>{for(const t of e){const e=(0,o.x1)();if(!e)return;const n=he(le.Z1+t.startTime),s=he(t.duration);e.startChild({description:"Main UI thread blocked",op:"ui.long-task",origin:"auto.ui.browser.metrics",startTimestamp:n,endTimestamp:n+s})}})),this.options._experiments.enableInteractions&&O("event",(({entries:e})=>{for(const t of e){const e=(0,o.x1)();if(!e)return;if("click"===t.name){const n=he(le.Z1+t.startTime),s=he(t.duration),i={description:(0,l.Rt)(t.target),op:`ui.interaction.${t.name}`,origin:"auto.ui.browser.metrics",startTimestamp:n,endTimestamp:n+s},o=(0,l.iY)(t.target);o&&(i.attributes={"ui.component_name":o}),e.startChild(i)}}})),this._latestRoute={name:void 0,context:void 0}}setupOnce(e,t){this._getCurrentHub=t;const n=t().getClient(),s=n&&n.getOptions(),{routingInstrumentation:i,startTransactionOnLocationChange:r,startTransactionOnPageLoad:a,markBackgroundTransactions:g,traceFetch:l,traceXHR:u,shouldCreateSpanForRequest:h,enableHTTPTimings:b,_experiments:C}=this.options,m=s&&s.tracePropagationTargets,Z=m||this.options.tracePropagationTargets;d.X&&this._hasSetTracePropagationTargets&&m&&c.kg.warn("[Tracing] The `tracePropagationTargets` option was set in the BrowserTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used."),i((e=>{const n=this._createRouteTransaction(e);return this.options._experiments.onStartRouteTransaction&&this.options._experiments.onStartRouteTransaction(n,e,t),n}),a,r),g&&(p.document?p.document.addEventListener("visibilitychange",(()=>{const e=(0,o.x1)();if(p.document.hidden&&e){const t="cancelled",{op:n,status:s}=(0,I.XU)(e);d.X&&c.kg.log(`[Tracing] Transaction: ${t} -> since tab moved to the background, op: ${n}`),s||e.setStatus(t),e.setTag("visibilitychange","document.hidden"),e.end()}})):d.X&&c.kg.warn("[Tracing] Could not set up background tab detection due to lack of global document")),C.enableInteractions&&this._registerInteractionListener(),this.options.enableInp&&this._registerInpInteractionListener(),Ke({traceFetch:l,traceXHR:u,tracePropagationTargets:Z,shouldCreateSpanForRequest:h,enableHTTPTimings:b})}_createRouteTransaction(e){if(!this._getCurrentHub)return void(d.X&&c.kg.warn(`[Tracing] Did not create ${e.op} transaction because _getCurrentHub is invalid.`));const t=this._getCurrentHub(),{beforeNavigate:n,idleTimeout:s,finalTimeout:o,heartbeatInterval:r}=this.options,a="pageload"===e.op;let u;if(a){const t=a?Oe("sentry-trace"):"",n=a?Oe("baggage"):void 0,{traceId:s,dsc:i,parentSpanId:o,sampled:r}=(0,g.pT)(t,n);u={traceId:s,parentSpanId:o,parentSampled:r,...e,metadata:{...e.metadata,dynamicSamplingContext:i},trimEnd:!0}}else u={trimEnd:!0,...e};const h="function"==typeof n?n(u):u,b=void 0===h?{...u,sampled:!1}:h;b.metadata=b.name!==u.name?{...b.metadata,source:"custom"}:b.metadata,this._latestRoute.name=b.name,this._latestRoute.context=b,!1===b.sampled&&d.X&&c.kg.log(`[Tracing] Will not send ${b.op} transaction because of beforeNavigate.`),d.X&&c.kg.log(`[Tracing] Starting ${b.op} transaction on scope`);const{location:m}=p,Z=(0,i.l)(t,b,s,o,!0,{location:m},r,a);return a&&p.document&&(p.document.addEventListener("readystatechange",(()=>{["interactive","complete"].includes(p.document.readyState)&&Z.sendAutoFinishSignal()})),["interactive","complete"].includes(p.document.readyState)&&Z.sendAutoFinishSignal()),Z.registerBeforeFinishCallback((e=>{this._collectWebVitals(),function(e){const t=be();if(!t||!p.performance.getEntries||!le.Z1)return;d.X&&c.kg.log("[Tracing] Adding & adjusting spans using Performance API");const n=he(le.Z1),s=t.getEntries(),{op:i,start_timestamp:o}=(0,I.XU)(e);if(s.slice(Ze).forEach((t=>{const s=he(t.startTime),i=he(t.duration);if(!("navigation"===e.op&&o&&n+s{Ae(e,t,s,n)})),Ae(e,t,"secureConnection",n,"TLS/SSL","connectEnd"),Ae(e,t,"fetch",n,"cache","domainLookupStart"),Ae(e,t,"domainLookup",n,"DNS"),function(e,t,n){t.responseEnd&&(ue(e,{op:"browser",origin:"auto.browser.browser.metrics",description:"request",startTimestamp:n+he(t.requestStart),endTimestamp:n+he(t.responseEnd)}),ue(e,{op:"browser",origin:"auto.browser.browser.metrics",description:"response",startTimestamp:n+he(t.responseStart),endTimestamp:n+he(t.responseEnd)}))}(e,t,n)}(e,t,n);break;case"mark":case"paint":case"measure":{!function(e,t,n,s,i){const o=i+n,r=o+s;ue(e,{description:t.name,endTimestamp:r,op:t.entryType,origin:"auto.resource.browser.metrics",startTimestamp:o})}(e,t,s,i,n);const o=W(),r=t.startTime{if(!Ge[e]||!o||n>=o)return;const t=Ge[e].value,s=n+he(t),i=Math.abs(1e3*(s-o)),r=i-t;d.X&&c.kg.log(`[Measurements] Normalized ${e} from ${t} to ${i} (${r})`),Ge[e].value=i}));const t=Ge["mark.fid"];t&&Ge.fid&&(ue(e,{description:"first input delay",endTimestamp:t.value+he(Ge.fid.value),op:"ui.action",origin:"auto.ui.browser.metrics",startTimestamp:t.value}),delete Ge["mark.fid"]),"fcp"in Ge||delete Ge.cls,Object.keys(Ge).forEach((e=>{(0,ae.o)(e,Ge[e].value,Ge[e].unit)})),function(e){Ce&&(d.X&&c.kg.log("[Measurements] Adding LCP Data"),Ce.element&&e.setTag("lcp.element",(0,l.Rt)(Ce.element)),Ce.id&&e.setTag("lcp.id",Ce.id),Ce.url&&e.setTag("lcp.url",Ce.url.trim().slice(0,200)),e.setTag("lcp.size",Ce.size)),me&&me.sources&&(d.X&&c.kg.log("[Measurements] Adding CLS Data"),me.sources.forEach(((t,n)=>e.setTag(`cls.source.${n+1}`,(0,l.Rt)(t.node)))))}(e)}Ce=void 0,me=void 0,Ge={}}(e)})),Z}_registerInteractionListener(){let e;const t=()=>{const{idleTimeout:t,finalTimeout:n,heartbeatInterval:s}=this.options,a="ui.action.click",g=(0,o.x1)();if(g&&g.op&&["navigation","pageload"].includes(g.op))return void(d.X&&c.kg.warn(`[Tracing] Did not create ${a} transaction because a pageload or navigation transaction is in progress.`));if(e&&(e.setFinishReason("interactionInterrupted"),e.end(),e=void 0),!this._getCurrentHub)return void(d.X&&c.kg.warn(`[Tracing] Did not create ${a} transaction because _getCurrentHub is invalid.`));if(!this._latestRoute.name)return void(d.X&&c.kg.warn(`[Tracing] Did not create ${a} transaction because _latestRouteName is missing.`));const l=this._getCurrentHub(),{location:I}=p,u={name:this._latestRoute.name,op:a,trimEnd:!0,data:{[r.Zj]:this._latestRoute.context?Pe(this._latestRoute.context):"url"}};e=(0,i.l)(l,u,t,n,!0,{location:I},s)};["click"].forEach((e=>{p.document&&addEventListener(e,t,{once:!1,capture:!0})}))}_registerInpInteractionListener(){const e=({entries:e})=>{const t=(0,a.s3)(),n=void 0!==t&&void 0!==t.getIntegrationByName?t.getIntegrationByName("Replay"):void 0,s=void 0!==n?n.getReplayId():void 0,i=(0,o.x1)(),r=(0,a.nZ)(),c=void 0!==r?r.getUser():void 0;e.forEach((e=>{if(function(e){return"duration"in e}(e)){const t=e.interactionId;if(void 0===t)return;const n=this._interactionIdToRouteNameMapping[t],o=e.duration,r=e.startTime,a=Object.keys(this._interactionIdToRouteNameMapping),g=a.length>0?a.reduce(((e,t)=>this._interactionIdToRouteNameMapping[e].durationthis._interactionIdToRouteNameMapping[e])).some((e=>e.duration===o&&e.startTime===r)))return;if(!t)return;if(n)n.duration=Math.max(n.duration,o);else if(a.length<10||void 0===g||o>this._interactionIdToRouteNameMapping[g].duration){const e=this._latestRoute.name,n=this._latestRoute.context;e&&n&&(g&&Object.keys(this._interactionIdToRouteNameMapping).length>=10&&delete this._interactionIdToRouteNameMapping[g],this._interactionIdToRouteNameMapping[t]={routeName:e,duration:o,parentContext:n,user:c,activeTransaction:i,replayId:s,startTime:r})}}}))};O("event",e),O("first-input",e)}},rt=Me.r,at=o.x1,ct=o.qG,gt=fe.Zd,lt=De.Y,dt=ie.D,It=Qe,ut=ke,pt=ce.z,ht=de.rt,bt=g.Ke,Ct=s.io,mt=Ke,Zt=i.l,Gt=fe.pN,yt={BrowserTracing:ot,Apollo:qe._,Express:$e.N1,GraphQL:et.k,Mongo:tt._,Mysql:nt.m,Postgres:st.E,Prisma:it.g};("undefined"==typeof __SENTRY_TRACING__||__SENTRY_TRACING__)&&(0,Me.r)()},9181:(e,t,n)=>{"use strict";n.d(t,{EN:()=>l,IQ:()=>d,bU:()=>r});var s=n(3897),i=n(7597),o=n(2343);const r="baggage",a="sentry-",c=/^sentry-/,g=8192;function l(e){if(!(0,i.HD)(e)&&!Array.isArray(e))return;let t={};if(Array.isArray(e))t=e.reduce(((e,t)=>{const n=I(t);for(const t of Object.keys(n))e[t]=n[t];return e}),{});else{if(!e)return;t=I(e)}const n=Object.entries(t).reduce(((e,[t,n])=>(t.match(c)&&(e[t.slice(a.length)]=n),e)),{});return Object.keys(n).length>0?n:void 0}function d(e){if(e)return function(e){if(0!==Object.keys(e).length)return Object.entries(e).reduce(((e,[t,n],i)=>{const r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`,a=0===i?r:`${e},${r}`;return a.length>g?(s.X&&o.kg.warn(`Not adding key: ${t} with val: ${n} to baggage header due to exceeding baggage size limits.`),e):a}),"")}(Object.entries(e).reduce(((e,[t,n])=>(n&&(e[`${a}${t}`]=n),e)),{}))}function I(e){return e.split(",").map((e=>e.split("=").map((e=>decodeURIComponent(e.trim()))))).reduce(((e,[t,n])=>(e[t]=n,e)),{})}},8464:(e,t,n)=>{"use strict";n.d(t,{Rt:()=>r,iY:()=>g,qT:()=>c});var s=n(7597);const i=(0,n(1235).R)(),o=80;function r(e,t={}){if(!e)return"";try{let n=e;const s=5,i=[];let r=0,c=0;const g=" > ",l=g.length;let d;const I=Array.isArray(t)?t:t.keyAttrs,u=!Array.isArray(t)&&t.maxStringLength||o;for(;n&&r++1&&c+i.length*l+d.length>=u));)i.push(d),c+=d.length,n=n.parentNode;return i.reverse().join(g)}catch(e){return""}}function a(e,t){const n=e,o=[];let r,a,c,g,l;if(!n||!n.tagName)return"";if(i.HTMLElement&&n instanceof HTMLElement&&n.dataset&&n.dataset.sentryComponent)return n.dataset.sentryComponent;o.push(n.tagName.toLowerCase());const d=t&&t.length?t.filter((e=>n.getAttribute(e))).map((e=>[e,n.getAttribute(e)])):null;if(d&&d.length)d.forEach((e=>{o.push(`[${e[0]}="${e[1]}"]`)}));else if(n.id&&o.push(`#${n.id}`),r=n.className,r&&(0,s.HD)(r))for(a=r.split(/\s+/),l=0;l{"use strict";function s(e){let t,n=e[0],s=1;for(;sn.call(t,...e))),t=void 0)}return n}n.d(t,{x:()=>s})},3897:(e,t,n)=>{"use strict";n.d(t,{X:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},292:(e,t,n)=>{"use strict";n.d(t,{RA:()=>r,vK:()=>c});var s=n(3897),i=n(2343);const o=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function r(e,t=!1){const{host:n,path:s,pass:i,port:o,projectId:r,protocol:a,publicKey:c}=e;return`${a}://${c}${t&&i?`:${i}`:""}@${n}${o?`:${o}`:""}/${s?`${s}/`:s}${r}`}function a(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}function c(e){const t="string"==typeof e?function(e){const t=o.exec(e);if(!t)return void(0,i.Cf)((()=>{console.error(`Invalid Sentry Dsn: ${e}`)}));const[n,s,r="",c,g="",l]=t.slice(1);let d="",I=l;const u=I.split("/");if(u.length>1&&(d=u.slice(0,-1).join("/"),I=u.pop()),I){const e=I.match(/^\d+/);e&&(I=e[0])}return a({host:c,pass:r,path:d,projectId:I,port:g,protocol:n,publicKey:s})}(e):a(e);if(t&&function(e){if(!s.X)return!0;const{port:t,projectId:n,protocol:o}=e;return!(["protocol","publicKey","host","projectId"].find((t=>!e[t]&&(i.kg.error(`Invalid Sentry Dsn: ${t} missing`),!0)))||(n.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(o)?t&&isNaN(parseInt(t,10))&&(i.kg.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(i.kg.error(`Invalid Sentry Dsn: Invalid protocol ${o}`),1):(i.kg.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),1)))}(t))return t}},8725:(e,t,n)=>{"use strict";n.d(t,{BO:()=>a,Cd:()=>h,HY:()=>p,Jd:()=>r,V$:()=>l,gv:()=>c,mL:()=>u,zQ:()=>d});var s=n(292),i=n(8007),o=n(535);function r(e,t=[]){return[e,t]}function a(e,t){const[n,s]=e;return[n,[...s,t]]}function c(e,t){const n=e[1];for(const e of n)if(t(e,e[0].type))return!0;return!1}function g(e,t){return(t||new TextEncoder).encode(e)}function l(e,t){const[n,s]=e;let o=JSON.stringify(n);function r(e){"string"==typeof o?o="string"==typeof e?o+e:[g(o,t),e]:o.push("string"==typeof e?g(e,t):e)}for(const e of s){const[t,n]=e;if(r(`\n${JSON.stringify(t)}\n`),"string"==typeof n||n instanceof Uint8Array)r(n);else{let e;try{e=JSON.stringify(n)}catch(t){e=JSON.stringify((0,i.Fv)(n))}r(e)}}return"string"==typeof o?o:function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);let s=0;for(const t of e)n.set(t,s),s+=t.length;return n}(o)}function d(e,t){const n="string"==typeof e.data?g(e.data,t):e.data;return[(0,o.Jr)({type:"attachment",length:n.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType}),n]}const I={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",statsd:"metric_bucket"};function u(e){return I[e]}function p(e){if(!e||!e.sdk)return;const{name:t,version:n}=e.sdk;return{name:t,version:n}}function h(e,t,n,i){const r=e.sdkProcessingMetadata&&e.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&{sdk:t},...!!n&&i&&{dsn:(0,s.RA)(i)},...r&&{trace:(0,o.Jr)({...r})}}}},9729:(e,t,n)=>{"use strict";n.d(t,{D2:()=>g,Hj:()=>c,rK:()=>l});var s=n(3897),i=n(2343),o=n(6147);const r={},a={};function c(e,t){r[e]=r[e]||[],r[e].push(t)}function g(e,t){a[e]||(t(),a[e]=!0)}function l(e,t){const n=e&&r[e];if(n)for(const r of n)try{r(t)}catch(t){s.X&&i.kg.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${(0,o.$P)(r)}\nError:`,t)}}},1394:(e,t,n)=>{"use strict";n.d(t,{U:()=>a});var s=n(535),i=n(8823),o=n(1235),r=n(9729);function a(e){const t="fetch";(0,r.Hj)(t,e),(0,r.D2)(t,c)}function c(){(0,i.t$)()&&(0,s.hl)(o.GLOBAL_OBJ,"fetch",(function(e){return function(...t){const{method:n,url:s}=function(e){if(0===e.length)return{method:"GET",url:""};if(2===e.length){const[t,n]=e;return{url:l(t),method:g(n,"method")?String(n.method).toUpperCase():"GET"}}const t=e[0];return{url:l(t),method:g(t,"method")?String(t.method).toUpperCase():"GET"}}(t),i={args:t,fetchData:{method:n,url:s},startTimestamp:Date.now()};return(0,r.rK)("fetch",{...i}),e.apply(o.GLOBAL_OBJ,t).then((e=>{const t={...i,endTimestamp:Date.now(),response:e};return(0,r.rK)("fetch",t),e}),(e=>{const t={...i,endTimestamp:Date.now(),error:e};throw(0,r.rK)("fetch",t),e}))}}))}function g(e,t){return!!e&&"object"==typeof e&&!!e[t]}function l(e){return"string"==typeof e?e:e?g(e,"url")?e.url:e.toString?e.toString():"":""}},5322:(e,t,n)=>{"use strict";n.d(t,{UK:()=>g,xU:()=>c});var s=n(7597),i=n(535),o=n(1235),r=n(9729);const a=o.GLOBAL_OBJ,c="__sentry_xhr_v3__";function g(e){(0,r.Hj)("xhr",e),(0,r.D2)("xhr",l)}function l(){if(!a.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;(0,i.hl)(e,"open",(function(e){return function(...t){const n=Date.now(),o=(0,s.HD)(t[0])?t[0].toUpperCase():void 0,a=function(e){if((0,s.HD)(e))return e;try{return e.toString()}catch(e){}}(t[1]);if(!o||!a)return e.apply(this,t);this[c]={method:o,url:a,request_headers:{}},"POST"===o&&a.match(/sentry_key/)&&(this.__sentry_own_request__=!0);const g=()=>{const e=this[c];if(e&&4===this.readyState){try{e.status_code=this.status}catch(e){}const t={args:[o,a],endTimestamp:Date.now(),startTimestamp:n,xhr:this};(0,r.rK)("xhr",t)}};return"onreadystatechange"in this&&"function"==typeof this.onreadystatechange?(0,i.hl)(this,"onreadystatechange",(function(e){return function(...t){return g(),e.apply(this,t)}})):this.addEventListener("readystatechange",g),(0,i.hl)(this,"setRequestHeader",(function(e){return function(...t){const[n,i]=t,o=this[c];return o&&(0,s.HD)(n)&&(0,s.HD)(i)&&(o.request_headers[n.toLowerCase()]=i),e.apply(this,t)}})),e.apply(this,t)}})),(0,i.hl)(e,"send",(function(e){return function(...t){const n=this[c];if(!n)return e.apply(this,t);void 0!==t[0]&&(n.body=t[0]);const s={args:[n.method,n.url],startTimestamp:Date.now(),xhr:this};return(0,r.rK)("xhr",s),e.apply(this,t)}}))}},7597:(e,t,n)=>{"use strict";n.d(t,{Cy:()=>p,HD:()=>r,J8:()=>u,Kj:()=>I,Le:()=>a,PO:()=>g,V9:()=>b,VZ:()=>i,cO:()=>l,i2:()=>h,kK:()=>d,pt:()=>c,y1:()=>C});const s=Object.prototype.toString;function i(e){switch(s.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return b(e,Error)}}function o(e,t){return s.call(e)===`[object ${t}]`}function r(e){return o(e,"String")}function a(e){return"object"==typeof e&&null!==e&&"__sentry_template_string__"in e&&"__sentry_template_values__"in e}function c(e){return null===e||a(e)||"object"!=typeof e&&"function"!=typeof e}function g(e){return o(e,"Object")}function l(e){return"undefined"!=typeof Event&&b(e,Event)}function d(e){return"undefined"!=typeof Element&&b(e,Element)}function I(e){return o(e,"RegExp")}function u(e){return Boolean(e&&e.then&&"function"==typeof e.then)}function p(e){return g(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e}function h(e){return"number"==typeof e&&e!=e}function b(e,t){try{return e instanceof t}catch(e){return!1}}function C(e){return!("object"!=typeof e||null===e||!e.__isVue&&!e._isVue)}},2343:(e,t,n)=>{"use strict";n.d(t,{Cf:()=>a,LD:()=>r,RU:()=>o,kg:()=>c});var s=n(3897),i=n(1235);const o=["debug","info","warn","error","log","assert","trace"],r={};function a(e){if(!("console"in i.GLOBAL_OBJ))return e();const t=i.GLOBAL_OBJ.console,n={},s=Object.keys(r);s.forEach((e=>{const s=r[e];n[e]=t[e],t[e]=s}));try{return e()}finally{s.forEach((e=>{t[e]=n[e]}))}}const c=function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return s.X?o.forEach((n=>{t[n]=(...t)=>{e&&a((()=>{i.GLOBAL_OBJ.console[n](`Sentry Logger [${n}]:`,...t)}))}})):o.forEach((e=>{t[e]=()=>{}})),t}()},2844:(e,t,n)=>{"use strict";n.d(t,{DM:()=>r,Db:()=>g,EG:()=>l,J4:()=>I,YO:()=>p,go:()=>u,jH:()=>c,lE:()=>h});var s=n(535),i=n(7321),o=n(1235);function r(){const e=o.GLOBAL_OBJ,t=e.crypto||e.msCrypto;let n=()=>16*Math.random();try{if(t&&t.randomUUID)return t.randomUUID().replace(/-/g,"");t&&t.getRandomValues&&(n=()=>{const e=new Uint8Array(1);return t.getRandomValues(e),e[0]})}catch(e){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(e=>(e^(15&n())>>e/4).toString(16)))}function a(e){return e.exception&&e.exception.values?e.exception.values[0]:void 0}function c(e){const{message:t,event_id:n}=e;if(t)return t;const s=a(e);return s?s.type&&s.value?`${s.type}: ${s.value}`:s.type||s.value||n||"":n||""}function g(e,t,n){const s=e.exception=e.exception||{},i=s.values=s.values||[],o=i[0]=i[0]||{};o.value||(o.value=t||""),o.type||(o.type=n||"Error")}function l(e,t){const n=a(e);if(!n)return;const s=n.mechanism;if(n.mechanism={type:"generic",handled:!0,...s,...t},t&&"data"in t){const e={...s&&s.data,...t.data};n.mechanism.data=e}}const d=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function I(e){const t=e.match(d)||[],n=parseInt(t[1],10),s=parseInt(t[2],10),i=parseInt(t[3],10);return{buildmetadata:t[5],major:isNaN(n)?void 0:n,minor:isNaN(s)?void 0:s,patch:isNaN(i)?void 0:i,prerelease:t[4]}}function u(e,t,n=5){if(void 0===t.lineno)return;const s=e.length,o=Math.max(Math.min(s-1,t.lineno-1),0);t.pre_context=e.slice(Math.max(0,o-n),o).map((e=>(0,i.JM)(e,0))),t.context_line=(0,i.JM)(e[Math.min(s-1,o)],t.colno||0),t.post_context=e.slice(Math.min(o+1,s),o+1+n).map((e=>(0,i.JM)(e,0)))}function p(e){if(e&&e.__sentry_captured__)return!0;try{(0,s.xp)(e,"__sentry_captured__",!0)}catch(e){}return!1}function h(e){return Array.isArray(e)?e:[e]}},2176:(e,t,n)=>{"use strict";function s(){return!("undefined"!=typeof __SENTRY_BROWSER_BUNDLE__&&__SENTRY_BROWSER_BUNDLE__)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}function i(e,t){return e.require(t)}function o(t){let n;try{n=i(e,t)}catch(e){}try{const{cwd:s}=i(e,"process");n=i(e,`${s()}/node_modules/${t}`)}catch(e){}return n}n.d(t,{l$:()=>i,KV:()=>s,$y:()=>o}),e=n.hmd(e)},8007:(e,t,n)=>{"use strict";n.d(t,{Fv:()=>r,Qy:()=>a});var s=n(7597),i=n(535),o=n(6147);function r(e,t=100,n=1/0){try{return c("",e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function a(e,t=3,n=102400){const s=r(e,t);return i=s,function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(i))>n?a(e,t-1,n):s;var i}function c(e,t,n=1/0,r=1/0,a=function(){const e="function"==typeof WeakSet,t=e?new WeakSet:[];return[function(n){if(e)return!!t.has(n)||(t.add(n),!1);for(let e=0;e=r){p[e]="[MaxProperties ~]";break}const t=b[e];p[e]=c(e,t,I-1,r,a),h++}return l(t),p}},535:(e,t,n)=>{"use strict";n.d(t,{HK:()=>l,Jr:()=>b,Sh:()=>I,_j:()=>d,hl:()=>c,xp:()=>g,zf:()=>h});var s=n(8464),i=n(3897),o=n(7597),r=n(2343),a=n(7321);function c(e,t,n){if(!(t in e))return;const s=e[t],i=n(s);"function"==typeof i&&function(e,t){try{const n=t.prototype||{};e.prototype=t.prototype=n,g(e,"__sentry_original__",t)}catch(e){}}(i,s),e[t]=i}function g(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch(n){i.X&&r.kg.log(`Failed to add non-enumerable property "${t}" to object`,e)}}function l(e){return e.__sentry_original__}function d(e){return Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}function I(e){if((0,o.VZ)(e))return{message:e.message,name:e.name,stack:e.stack,...p(e)};if((0,o.cO)(e)){const t={type:e.type,target:u(e.target),currentTarget:u(e.currentTarget),...p(e)};return"undefined"!=typeof CustomEvent&&(0,o.V9)(e,CustomEvent)&&(t.detail=e.detail),t}return e}function u(e){try{return(0,o.kK)(e)?(0,s.Rt)(e):Object.prototype.toString.call(e)}catch(e){return""}}function p(e){if("object"==typeof e&&null!==e){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}return{}}function h(e,t=40){const n=Object.keys(I(e));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=t)return(0,a.$G)(n[0],t);for(let e=n.length;e>0;e--){const s=n.slice(0,e).join(", ");if(!(s.length>t))return e===n.length?s:(0,a.$G)(s,t)}return""}function b(e){return C(e,new Map)}function C(e,t){if(function(e){if(!(0,o.PO)(e))return!1;try{const t=Object.getPrototypeOf(e).constructor.name;return!t||"Object"===t}catch(e){return!0}}(e)){const n=t.get(e);if(void 0!==n)return n;const s={};t.set(e,s);for(const n of Object.keys(e))void 0!==e[n]&&(s[n]=C(e[n],t));return s}if(Array.isArray(e)){const n=t.get(e);if(void 0!==n)return n;const s=[];return t.set(e,s),e.forEach((e=>{s.push(C(e,t))})),s}return e}},771:(e,t,n)=>{"use strict";n.d(t,{rC:()=>c,S6:()=>I,dB:()=>g,oA:()=>l,XQ:()=>d});var s=n(7597),i=n(8007),o=n(6956);const r={ip:!1,request:!0,transaction:!0,user:!0},a=["cookies","data","headers","method","query_string","url"],c=["id","username","email"];function g(e,t,n){if(e){if(!e.metadata.source||"url"===e.metadata.source){const[n,s]=l(t,{path:!0,method:!0});e.updateName(n),e.setMetadata({source:s})}e.setAttribute("url",t.originalUrl||t.url),t.baseUrl&&e.setAttribute("baseUrl",t.baseUrl),e.setData("query",u(t,n))}}function l(e,t={}){const n=e.method&&e.method.toUpperCase();let s="",i="url";t.customRoute||e.route?(s=t.customRoute||`${e.baseUrl||""}${e.route&&e.route.path}`,i="route"):(e.originalUrl||e.url)&&(s=(0,o.rt)(e.originalUrl||e.url||""));let r="";return t.method&&n&&(r+=n),t.method&&t.path&&(r+=" "),t.path&&s&&(r+=s),[r,i]}function d(e,t){const{include:n=a,deps:o}=t||{},r={},c=e.headers||{},g=e.method,l=c.host||e.hostname||e.host||"",d="https"===e.protocol||e.socket&&e.socket.encrypted?"https":"http",I=e.originalUrl||e.url||"",p=I.startsWith(d)?I:`${d}://${l}${I}`;return n.forEach((t=>{switch(t){case"headers":r.headers=c,n.includes("cookies")||delete r.headers.cookie;break;case"method":r.method=g;break;case"url":r.url=p;break;case"cookies":r.cookies=e.cookies||c.cookie&&function(e){const t={};let n=0;for(;n{e&&t in e&&(n[t]=e[t])})),n}(t.user,i.user):{};Object.keys(n).length&&(e.user={...e.user,...n})}if(i.ip){const n=t.ip||t.socket&&t.socket.remoteAddress;n&&(e.user={...e.user,ip_address:n})}return i.transaction&&!e.transaction&&(e.transaction=function(e,t){switch(t){case"path":return l(e,{path:!0})[0];case"handler":return e.route&&e.route.stack&&e.route.stack[0]&&e.route.stack[0].name||"";default:return l(e,{path:!0,method:!0,customRoute:e._reconstructedRoute?e._reconstructedRoute:void 0})[0]}}(t,i.transaction)),e}function u(e,t){let n=e.originalUrl||e.url||"";if(n){n.startsWith("/")&&(n=`http://dogs.are.great${n}`);try{return e.query||"undefined"!=typeof URL&&new URL(n).search.slice(1)||t&&t.url&&t.url.parse(n).query||void 0}catch(e){return}}}},6147:(e,t,n)=>{"use strict";function s(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.match(/^[A-Z]:/)&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//)||void 0===e||e.includes("node_modules/"))}function i(e){const t=/^\s*[-]{4,}$/,n=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{const o=i.match(n);if(o){let t,n,i,r,a;if(o[1]){i=o[1];let e=i.lastIndexOf(".");if("."===i[e-1]&&e--,e>0){t=i.slice(0,e),n=i.slice(e+1);const s=t.indexOf(".Module");s>0&&(i=i.slice(s+1),t=t.slice(0,s))}r=void 0}n&&(r=t,a=n),""===n&&(a=void 0,i=void 0),void 0===i&&(a=a||"",i=r?`${r}.${a}`:a);let c=o[2]&&o[2].startsWith("file://")?o[2].slice(7):o[2];const g="native"===o[5];return c&&c.match(/\/[A-Z]:/)&&(c=c.slice(1)),c||!o[5]||g||(c=o[5]),{filename:c,module:e?e(c):void 0,function:i,lineno:parseInt(o[3],10)||void 0,colno:parseInt(o[4],10)||void 0,in_app:s(c,g)}}if(i.match(t))return{filename:i}}}n.d(t,{pE:()=>c,$P:()=>d,Ep:()=>I,Sq:()=>g});const o=50,r=/\(error: (.*)\)/,a=/captureMessage|captureException/;function c(...e){const t=e.sort(((e,t)=>e[0]-t[0])).map((e=>e[1]));return(e,n=0)=>{const s=[],i=e.split("\n");for(let e=n;e1024)continue;const a=r.test(n)?n.replace(r,"$1"):n;if(!a.match(/\S*Error: /)){for(const e of t){const t=e(a);if(t){s.push(t);break}}if(s.length>=o)break}}return function(e){if(!e.length)return[];const t=Array.from(e);return/sentryWrapped/.test(t[t.length-1].function||"")&&t.pop(),t.reverse(),a.test(t[t.length-1].function||"")&&(t.pop(),a.test(t[t.length-1].function||"")&&t.pop()),t.slice(0,o).map((e=>({...e,filename:e.filename||t[t.length-1].filename,function:e.function||"?"})))}(s)}}function g(e){return Array.isArray(e)?c(...e):e}const l="";function d(e){try{return e&&"function"==typeof e&&e.name||l}catch(e){return l}}function I(e){return[90,i(e)]}},7321:(e,t,n)=>{"use strict";n.d(t,{$G:()=>i,JM:()=>o,U0:()=>a,nK:()=>r});var s=n(7597);function i(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function o(e,t){let n=e;const s=n.length;if(s<=150)return n;t>s&&(t=s);let i=Math.max(t-60,0);i<5&&(i=0);let o=Math.min(i+140,s);return o>s-5&&(o=s),o===s&&(i=Math.max(o-140,0)),n=n.slice(i,o),i>0&&(n=`'{snip} ${n}`),ofunction(e,t,n=!1){return!!(0,s.HD)(e)&&((0,s.Kj)(t)?t.test(e):!!(0,s.HD)(t)&&(n?e===t:e.includes(t)))}(e,t,n)))}},8823:(e,t,n)=>{"use strict";n.d(t,{t$:()=>a,zb:()=>c});var s=n(3897),i=n(2343);const o=(0,n(1235).R)();function r(e){return e&&/^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function a(){if("string"==typeof EdgeRuntime)return!0;if(!function(){if(!("fetch"in o))return!1;try{return new Headers,new Request("http://www.example.com"),new Response,!0}catch(e){return!1}}())return!1;if(r(o.fetch))return!0;let e=!1;const t=o.document;if(t&&"function"==typeof t.createElement)try{const n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n),n.contentWindow&&n.contentWindow.fetch&&(e=r(n.contentWindow.fetch)),t.head.removeChild(n)}catch(e){s.X&&i.kg.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return e}function c(){return"ReportingObserver"in o}},6893:(e,t,n)=>{"use strict";n.d(t,{$2:()=>r,WD:()=>o,cW:()=>a});var s,i=n(7597);function o(e){return new a((t=>{t(e)}))}function r(e){return new a(((t,n)=>{n(e)}))}!function(e){e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.REJECTED=2]="REJECTED"}(s||(s={}));class a{constructor(e){a.prototype.__init.call(this),a.prototype.__init2.call(this),a.prototype.__init3.call(this),a.prototype.__init4.call(this),this._state=s.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}then(e,t){return new a(((n,s)=>{this._handlers.push([!1,t=>{if(e)try{n(e(t))}catch(e){s(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){s(e)}else s(e)}]),this._executeHandlers()}))}catch(e){return this.then((e=>e),e)}finally(e){return new a(((t,n)=>{let s,i;return this.then((t=>{i=!1,s=t,e&&e()}),(t=>{i=!0,s=t,e&&e()})).then((()=>{i?n(s):t(s)}))}))}__init(){this._resolve=e=>{this._setResult(s.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(s.REJECTED,e)}}__init3(){this._setResult=(e,t)=>{this._state===s.PENDING&&((0,i.J8)(t)?t.then(this._resolve,this._reject):(this._state=e,this._value=t,this._executeHandlers()))}}__init4(){this._executeHandlers=()=>{if(this._state===s.PENDING)return;const e=this._handlers.slice();this._handlers=[],e.forEach((e=>{e[0]||(this._state===s.RESOLVED&&e[1](this._value),this._state===s.REJECTED&&e[2](this._value),e[0]=!0)}))}}}},1170:(e,t,n)=>{"use strict";n.d(t,{Z1:()=>c,ph:()=>r,yW:()=>o});var s=n(1235);const i=1e3;function o(){return Date.now()/i}const r=function(){const{performance:e}=s.GLOBAL_OBJ;if(!e||!e.now)return o;const t=Date.now()-e.now(),n=null==e.timeOrigin?t:e.timeOrigin;return()=>(n+e.now())/i}();let a;const c=(()=>{const{performance:e}=s.GLOBAL_OBJ;if(!e||!e.now)return void(a="none");const t=36e5,n=e.now(),i=Date.now(),o=e.timeOrigin?Math.abs(e.timeOrigin+n-i):t,r=o{"use strict";n.d(t,{$p:()=>g,KA:()=>a,Ke:()=>o,pT:()=>c,qG:()=>r});var s=n(9181),i=n(2844);const o=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function r(e){if(!e)return;const t=e.match(o);if(!t)return;let n;return"1"===t[3]?n=!0:"0"===t[3]&&(n=!1),{traceId:t[1],parentSampled:n,parentSpanId:t[2]}}function a(e,t){const n=r(e),o=(0,s.EN)(t),{traceId:a,parentSpanId:c,parentSampled:g}=n||{};return n?{traceparentData:n,dynamicSamplingContext:o||{},propagationContext:{traceId:a||(0,i.DM)(),parentSpanId:c||(0,i.DM)().substring(16),spanId:(0,i.DM)().substring(16),sampled:g,dsc:o||{}}}:{traceparentData:n,dynamicSamplingContext:void 0,propagationContext:{traceId:a||(0,i.DM)(),spanId:(0,i.DM)().substring(16)}}}function c(e,t){const n=r(e),o=(0,s.EN)(t),{traceId:a,parentSpanId:c,parentSampled:g}=n||{};return n?{traceId:a||(0,i.DM)(),parentSpanId:c||(0,i.DM)().substring(16),spanId:(0,i.DM)().substring(16),sampled:g,dsc:o||{}}:{traceId:a||(0,i.DM)(),spanId:(0,i.DM)().substring(16)}}function g(e=(0,i.DM)(),t=(0,i.DM)().substring(16),n){let s="";return void 0!==n&&(s=n?"-1":"-0"),`${e}-${t}${s}`}},6956:(e,t,n)=>{"use strict";function s(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const n=t[6]||"",s=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:n,hash:s,relative:t[5]+n+s}}function i(e){return e.split(/[\?#]/,1)[0]}function o(e){return e.split(/\\?\//).filter((e=>e.length>0&&","!==e)).length}function r(e){const{protocol:t,host:n,path:s}=e;return`${t?`${t}://`:""}${n&&n.replace(/^.*@/,"[filtered]:[filtered]@").replace(/(:80)$/,"").replace(/(:443)$/,"")||""}${s}`}n.d(t,{$A:()=>o,en:()=>s,rt:()=>i,tF:()=>r})},1235:(e,t,n)=>{"use strict";function s(e){return e&&e.Math==Math?e:void 0}n.d(t,{GLOBAL_OBJ:()=>i,R:()=>o,Y:()=>r});const i="object"==typeof globalThis&&s(globalThis)||"object"==typeof window&&s(window)||"object"==typeof self&&s(self)||"object"==typeof global&&s(global)||function(){return this}()||{};function o(){return i}function r(e,t,n){const s=n||i,o=s.__SENTRY__=s.__SENTRY__||{};return o[e]||(o[e]=t())}},6872:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var n={grad:.9,turn:360,rad:360/(2*Math.PI)},s=function(e){return"string"==typeof e?e.length>0:"number"==typeof e},i=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},o=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),e>n?n:e>t?e:t},r=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},a=function(e){return{r:o(e.r,0,255),g:o(e.g,0,255),b:o(e.b,0,255),a:o(e.a)}},c=function(e){return{r:i(e.r),g:i(e.g),b:i(e.b),a:i(e.a,3)}},g=/^#([0-9a-f]{3,8})$/i,l=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},d=function(e){var t=e.r,n=e.g,s=e.b,i=e.a,o=Math.max(t,n,s),r=o-Math.min(t,n,s),a=r?o===t?(n-s)/r:o===n?2+(s-t)/r:4+(t-n)/r:0;return{h:60*(a<0?a+6:a),s:o?r/o*100:0,v:o/255*100,a:i}},I=function(e){var t=e.h,n=e.s,s=e.v,i=e.a;t=t/360*6,n/=100,s/=100;var o=Math.floor(t),r=s*(1-n),a=s*(1-(t-o)*n),c=s*(1-(1-t+o)*n),g=o%6;return{r:255*[s,a,r,r,c,s][g],g:255*[c,s,s,a,r,r][g],b:255*[r,r,c,s,s,a][g],a:i}},u=function(e){return{h:r(e.h),s:o(e.s,0,100),l:o(e.l,0,100),a:o(e.a)}},p=function(e){return{h:i(e.h),s:i(e.s),l:i(e.l),a:i(e.a,3)}},h=function(e){return I((n=(t=e).s,{h:t.h,s:(n*=((s=t.l)<50?s:100-s)/100)>0?2*n/(s+n)*100:0,v:s+n,a:t.a}));var t,n,s},b=function(e){return{h:(t=d(e)).h,s:(i=(200-(n=t.s))*(s=t.v)/100)>0&&i<200?n*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,s,i},C=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Z=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,G=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(e){var t=g.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?i(parseInt(e[3]+e[3],16)/255,2):1}:6===e.length||8===e.length?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:8===e.length?i(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=Z.exec(e)||G.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=C.exec(e)||m.exec(e);if(!t)return null;var s,i,o=u({h:(s=t[1],i=t[2],void 0===i&&(i="deg"),Number(s)*(n[i]||1)),s:Number(t[3]),l:Number(t[4]),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return h(o)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,i=e.b,o=e.a,r=void 0===o?1:o;return s(t)&&s(n)&&s(i)?a({r:Number(t),g:Number(n),b:Number(i),a:Number(r)}):null},"rgb"],[function(e){var t=e.h,n=e.s,i=e.l,o=e.a,r=void 0===o?1:o;if(!s(t)||!s(n)||!s(i))return null;var a=u({h:Number(t),s:Number(n),l:Number(i),a:Number(r)});return h(a)},"hsl"],[function(e){var t=e.h,n=e.s,i=e.v,a=e.a,c=void 0===a?1:a;if(!s(t)||!s(n)||!s(i))return null;var g=function(e){return{h:r(e.h),s:o(e.s,0,100),v:o(e.v,0,100),a:o(e.a)}}({h:Number(t),s:Number(n),v:Number(i),a:Number(c)});return I(g)},"hsv"]]},B=function(e,t){for(var n=0;n=.5},e.prototype.toHex=function(){return t=(e=c(this.rgba)).r,n=e.g,s=e.b,r=(o=e.a)<1?l(i(255*o)):"","#"+l(t)+l(n)+l(s)+r;var e,t,n,s,o,r},e.prototype.toRgb=function(){return c(this.rgba)},e.prototype.toRgbString=function(){return t=(e=c(this.rgba)).r,n=e.g,s=e.b,(i=e.a)<1?"rgba("+t+", "+n+", "+s+", "+i+")":"rgb("+t+", "+n+", "+s+")";var e,t,n,s,i},e.prototype.toHsl=function(){return p(b(this.rgba))},e.prototype.toHslString=function(){return t=(e=p(b(this.rgba))).h,n=e.s,s=e.l,(i=e.a)<1?"hsla("+t+", "+n+"%, "+s+"%, "+i+")":"hsl("+t+", "+n+"%, "+s+"%)";var e,t,n,s,i},e.prototype.toHsv=function(){return e=d(this.rgba),{h:i(e.h),s:i(e.s),v:i(e.v),a:i(e.a,3)};var e},e.prototype.invert=function(){return R({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return void 0===e&&(e=.1),R(W(this.rgba,e))},e.prototype.desaturate=function(e){return void 0===e&&(e=.1),R(W(this.rgba,-e))},e.prototype.grayscale=function(){return R(W(this.rgba,-1))},e.prototype.lighten=function(e){return void 0===e&&(e=.1),R(V(this.rgba,e))},e.prototype.darken=function(e){return void 0===e&&(e=.1),R(V(this.rgba,-e))},e.prototype.rotate=function(e){return void 0===e&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return"number"==typeof e?R({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):i(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=b(this.rgba);return"number"==typeof e?R({h:e,s:t.s,l:t.l,a:t.a}):i(t.h)},e.prototype.isEqual=function(e){return this.toHex()===R(e).toHex()},e}(),R=function(e){return e instanceof v?e:new v(e)},S=[];t.Colord=v,t.colord=R,t.extend=function(e){e.forEach((function(e){S.indexOf(e)<0&&(e(v,y),S.push(e))}))},t.getFormat=function(e){return A(e)[1]},t.random=function(){return new v({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}},2559:e=>{!function(){"use strict";var t=[,function(e,t){function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n255)throw new Error("Not ascii. Base64.encode can only take ascii strings.");e[n]=i}}for(var r=[],a=null,c=null,g=null,l=null,d=0;d>2&63,c=(3&e[d])<<4;break;case 1:c|=e[d]>>4&15,g=(15&e[d])<<2;break;case 2:g|=e[d]>>6&3,l=63&e[d],r.push(s(a)),r.push(s(c)),r.push(s(g)),r.push(s(l)),a=null,c=null,g=null,l=null}return null!=a&&(r.push(s(a)),r.push(s(c)),null==g?r.push("="):r.push(s(g)),null==l&&r.push("=")),r.join("")},decode:function(e){var t=Math.floor(3*e.length/4);"="==e.charAt(e.length-1)&&(t--,"="==e.charAt(e.length-2)&&t--);for(var s,i=o(t),r=null,a=null,c=null,g=0,l=0;l>4,i[g++]=r,a=(15&d)<<4;break;case 2:d>=0&&(a|=d>>2,i[g++]=a,c=(3&d)<<6);break;case 3:d>=0&&(i[g++]=c|d)}}return i},newBinary:o};t.Base64=r},function(e){e.exports={_noYieldsAllowed:function(e){return e()}}},function(e,t){function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function s(e){return JSON.stringify(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function e(t,i,o,r,a){var c=i[t];switch(n(c)){case"string":return s(c);case"number":return isFinite(c)?String(c):"null";case"boolean":return String(c);case"object":if(!c)return"null";var g,l=r+o,d=[];if(Array.isArray(c)||{}.hasOwnProperty.call(c,"callee")){for(var I=c.length,u=0;u0&&void 0!==arguments[0]&&arguments[0]?a:(0,o.convertMapToObject)(a)},r._getConverters=function(){return c};var g=function(e){for(var t=0;t=d.length||i!==d[s]||!r.equals(e[i],t[d[s]],n)||(s++,0))}))):(s=0,a=l.every((function(i){return!!(0,o.hasOwn)(t,i)&&!!r.equals(e[i],t[i],n)&&(s++,!0)}))),a&&s===d.length},r.clone=function(e){var t;if(!(0,o.isObject)(e))return e;if(null===e)return null;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return e;if(r.isBinary(e)){t=r.newBinary(e.length);for(var n=0;n{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function s(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,s,o,r){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new i(s,o||e,r),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,s,i=[];if(0===this._eventsCount)return i;for(s in e=this._events)t.call(e,s)&&i.push(n?s.slice(1):s);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var i=0,o=s.length,r=new Array(o);i{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var s,i,o;if(Array.isArray(t)){if((s=t.length)!=n.length)return!1;for(i=s;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((s=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=s;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=s;0!=i--;){var r=o[i];if(!e(t[r],n[r]))return!1}return!0}return t!=t&&n!=n}},4341:e=>{"use strict";const t=(e,t,s,i)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const o=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!n(o,r)&&i||Object.defineProperty(e,s,r)},n=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},s=(e,t)=>`/* Wrapped ${e}*/\n${t}`,i=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),o=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name");e.exports=(e,n,{ignoreNonConfigurable:r=!1}={})=>{const{name:a}=e;for(const s of Reflect.ownKeys(n))t(e,n,s,r);return((e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)})(e,n),((e,t,n)=>{const r=""===n?"":`with ${n.trim()}() `,a=s.bind(null,r,t.toString());Object.defineProperty(a,"name",o),Object.defineProperty(e,"toString",{...i,value:a})})(e,n,a),e}},7345:e=>{"use strict";e.exports=(e,t)=>(t=t||(()=>{}),e.then((e=>new Promise((e=>{e(t())})).then((()=>e))),(e=>new Promise((e=>{e(t())})).then((()=>{throw e})))))},5860:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(6729),i=n(6512),o=n(6506),r=()=>{},a=new i.TimeoutError;t.default=class extends s{constructor(e){var t,n,s,i;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=r,this._resolveIdle=r,!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:o.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==n?n:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(i=null===(s=e.interval)||void 0===s?void 0:s.toString())&&void 0!==i?i:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount{this._onResumeInterval()}),t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const t=this._queue.dequeue();return!!t&&(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0)}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((()=>{this._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,t={}){return new Promise(((n,s)=>{this._queue.enqueue((async()=>{this._pendingCount++,this._intervalCount++;try{const o=void 0===this._timeout&&void 0===t.timeout?e():i.default(Promise.resolve(e()),void 0===t.timeout?this._timeout:t.timeout,(()=>{(void 0===t.throwOnTimeout?this._throwOnTimeout:t.throwOnTimeout)&&s(a)}));n(await o)}catch(e){s(e)}this._next()}),t),this._tryToStartAnother(),this.emit("add")}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise((e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}}))}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise((e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}}))}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}}},7489:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){let s=0,i=e.length;for(;i>0;){const o=i/2|0;let r=s+o;n(e[r],t)<=0?(s=++r,i-=o+1):i=o}return s}},6506:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(7489);t.default=class{constructor(){this._queue=[]}enqueue(e,t){const n={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(n);const i=s.default(this._queue,n,((e,t)=>t.priority-e.priority));this._queue.splice(i,0,n)}dequeue(){const e=this._queue.shift();return null==e?void 0:e.run}filter(e){return this._queue.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this._queue.length}}},6512:(e,t,n)=>{"use strict";const s=n(7345);class i extends Error{constructor(e){super(e),this.name="TimeoutError"}}const o=(e,t,n)=>new Promise(((o,r)=>{if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0)return void o(e);const a=setTimeout((()=>{if("function"==typeof n){try{o(n())}catch(e){r(e)}return}const s=n instanceof Error?n:new i("string"==typeof n?n:`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),r(s)}),t);s(e.then(o,r),(()=>{clearTimeout(a)}))}));e.exports=o,e.exports.default=o,e.exports.TimeoutError=i},2600:(e,t,n)=>{"use strict";n.r(t),n.d(t,{NIL:()=>W,parse:()=>m,stringify:()=>I,v1:()=>C,v3:()=>G,v4:()=>B,v5:()=>A,validate:()=>g,version:()=>f});var s=n(6113),i=n.n(s);const o=new Uint8Array(256);let r=o.length;function a(){return r>o.length-16&&(i().randomFillSync(o),r=0),o.slice(r,r+=16)}const c=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,g=function(e){return"string"==typeof e&&c.test(e)},l=[];for(let e=0;e<256;++e)l.push((e+256).toString(16).slice(1));function d(e,t=0){return(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}const I=function(e,t=0){const n=d(e,t);if(!g(n))throw TypeError("Stringified UUID is invalid");return n};let u,p,h=0,b=0;const C=function(e,t,n){let s=t&&n||0;const i=t||new Array(16);let o=(e=e||{}).node||u,r=void 0!==e.clockseq?e.clockseq:p;if(null==o||null==r){const t=e.random||(e.rng||a)();null==o&&(o=u=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==r&&(r=p=16383&(t[6]<<8|t[7]))}let c=void 0!==e.msecs?e.msecs:Date.now(),g=void 0!==e.nsecs?e.nsecs:b+1;const l=c-h+(g-b)/1e4;if(l<0&&void 0===e.clockseq&&(r=r+1&16383),(l<0||c>h)&&void 0===e.nsecs&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=c,b=g,p=r,c+=122192928e5;const I=(1e4*(268435455&c)+g)%4294967296;i[s++]=I>>>24&255,i[s++]=I>>>16&255,i[s++]=I>>>8&255,i[s++]=255&I;const C=c/4294967296*1e4&268435455;i[s++]=C>>>8&255,i[s++]=255&C,i[s++]=C>>>24&15|16,i[s++]=C>>>16&255,i[s++]=r>>>8|128,i[s++]=255&r;for(let e=0;e<6;++e)i[s+e]=o[e];return t||d(i)},m=function(e){if(!g(e))throw TypeError("Invalid UUID");let t;const n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};function Z(e,t,n){function s(e,s,i,o){var r;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let n=0;n{"use strict";const s=n(8762);s.createWebSocketStream=n(404),s.Server=n(9284),s.Receiver=n(2957),s.Sender=n(7330),s.WebSocket=s,s.WebSocketServer=s.Server,e.exports=s},977:(e,t,n)=>{"use strict";const{EMPTY_BUFFER:s}=n(1872),i=Buffer[Symbol.species];function o(e,t,n,s,i){for(let o=0;o{"use strict";e.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},62:(e,t,n)=>{"use strict";const{kForOnEventAttribute:s,kListener:i}=n(1872),o=Symbol("kCode"),r=Symbol("kData"),a=Symbol("kError"),c=Symbol("kMessage"),g=Symbol("kReason"),l=Symbol("kTarget"),d=Symbol("kType"),I=Symbol("kWasClean");class u{constructor(e){this[l]=null,this[d]=e}get target(){return this[l]}get type(){return this[d]}}Object.defineProperty(u.prototype,"target",{enumerable:!0}),Object.defineProperty(u.prototype,"type",{enumerable:!0});class p extends u{constructor(e,t={}){super(e),this[o]=void 0===t.code?0:t.code,this[g]=void 0===t.reason?"":t.reason,this[I]=void 0!==t.wasClean&&t.wasClean}get code(){return this[o]}get reason(){return this[g]}get wasClean(){return this[I]}}Object.defineProperty(p.prototype,"code",{enumerable:!0}),Object.defineProperty(p.prototype,"reason",{enumerable:!0}),Object.defineProperty(p.prototype,"wasClean",{enumerable:!0});class h extends u{constructor(e,t={}){super(e),this[a]=void 0===t.error?null:t.error,this[c]=void 0===t.message?"":t.message}get error(){return this[a]}get message(){return this[c]}}Object.defineProperty(h.prototype,"error",{enumerable:!0}),Object.defineProperty(h.prototype,"message",{enumerable:!0});class b extends u{constructor(e,t={}){super(e),this[r]=void 0===t.data?null:t.data}get data(){return this[r]}}Object.defineProperty(b.prototype,"data",{enumerable:!0});const C={addEventListener(e,t,n={}){for(const o of this.listeners(e))if(!n[s]&&o[i]===t&&!o[s])return;let o;if("message"===e)o=function(e,n){const s=new b("message",{data:n?e:e.toString()});s[l]=this,m(t,this,s)};else if("close"===e)o=function(e,n){const s=new p("close",{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[l]=this,m(t,this,s)};else if("error"===e)o=function(e){const n=new h("error",{error:e,message:e.message});n[l]=this,m(t,this,n)};else{if("open"!==e)return;o=function(){const e=new u("open");e[l]=this,m(t,this,e)}}o[s]=!!n[s],o[i]=t,n.once?this.once(e,o):this.on(e,o)},removeEventListener(e,t){for(const n of this.listeners(e))if(n[i]===t&&!n[s]){this.removeListener(e,n);break}}};function m(e,t,n){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}e.exports={CloseEvent:p,ErrorEvent:h,Event:u,EventTarget:C,MessageEvent:b}},1503:(e,t,n)=>{"use strict";const{tokenChars:s}=n(6746);function i(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}e.exports={format:function(e){return Object.keys(e).map((t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map((e=>[t].concat(Object.keys(e).map((t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let n,o,r=Object.create(null),a=!1,c=!1,g=!1,l=-1,d=-1,I=-1,u=0;for(;u{"use strict";const t=Symbol("kDone"),n=Symbol("kRun");e.exports=class{constructor(e){this[t]=()=>{this.pending--,this[n]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[n]()}[n](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[t])}}}},5196:(e,t,n)=>{"use strict";const s=n(9796),i=n(977),o=n(305),{kStatusCode:r}=n(1872),a=Buffer[Symbol.species],c=Buffer.from([0,0,255,255]),g=Symbol("permessage-deflate"),l=Symbol("total-length"),d=Symbol("callback"),I=Symbol("buffers"),u=Symbol("error");let p;function h(e){this[I].push(e),this[l]+=e.length}function b(e){this[l]+=e.length,this[g]._maxPayload<1||this[l]<=this[g]._maxPayload?this[I].push(e):(this[u]=new RangeError("Max payload size exceeded"),this[u].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[u][r]=1009,this.removeListener("data",b),this.reset())}function C(e){this[g]._inflate=null,e[r]=1007,this[d](e)}e.exports=class{constructor(e,t,n){if(this._maxPayload=0|n,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!p){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;p=new o(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,n=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(n.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?n.client_max_window_bits=t.clientMaxWindowBits:!0!==n.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete n.client_max_window_bits,n}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let n=e[t];if(n.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(n=n[0],"client_max_window_bits"===t){if(!0!==n){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}else if("server_max_window_bits"===t){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==n)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}e[t]=n}))})),e}decompress(e,t,n){p.add((s=>{this._decompress(e,t,((e,t)=>{s(),n(e,t)}))}))}compress(e,t,n){p.add((s=>{this._compress(e,t,((e,t)=>{s(),n(e,t)}))}))}_decompress(e,t,n){const o=this._isServer?"client":"server";if(!this._inflate){const e=`${o}_max_window_bits`,t="number"!=typeof this.params[e]?s.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=s.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[g]=this,this._inflate[l]=0,this._inflate[I]=[],this._inflate.on("error",C),this._inflate.on("data",b)}this._inflate[d]=n,this._inflate.write(e),t&&this._inflate.write(c),this._inflate.flush((()=>{const e=this._inflate[u];if(e)return this._inflate.close(),this._inflate=null,void n(e);const s=i.concat(this._inflate[I],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[I]=[],t&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),n(null,s)}))}_compress(e,t,n){const o=this._isServer?"server":"client";if(!this._deflate){const e=`${o}_max_window_bits`,t="number"!=typeof this.params[e]?s.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=s.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[I]=[],this._deflate.on("data",h)}this._deflate[d]=n,this._deflate.write(e),this._deflate.flush(s.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=i.concat(this._deflate[I],this._deflate[l]);t&&(e=new a(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[l]=0,this._deflate[I]=[],t&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),n(null,e)}))}}},2957:(e,t,n)=>{"use strict";const{Writable:s}=n(2781),i=n(5196),{BINARY_TYPES:o,EMPTY_BUFFER:r,kStatusCode:a,kWebSocket:c}=n(1872),{concat:g,toArrayBuffer:l,unmask:d}=n(977),{isValidStatusCode:I,isValidUTF8:u}=n(6746),p=Buffer[Symbol.species];function h(e,t,n,s,i){const o=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,h),o.code=i,o[a]=s,o}e.exports=class extends s{constructor(e={}){super(),this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[c]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=0,this._loop=!1}_write(e,t,n){if(8===this._opcode&&0==this._state)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=n.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),s),this._buffers[0]=new p(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do{switch(this._state){case 0:t=this.getInfo();break;case 1:t=this.getPayloadLength16();break;case 2:t=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:t=this.getData(e);break;default:return void(this._loop=!1)}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2)return void(this._loop=!1);const e=this.consume(2);if(0!=(48&e[0]))return this._loop=!1,h(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");const t=64==(64&e[0]);if(t&&!this._extensions[i.extensionName])return this._loop=!1,h(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=128==(128&e[0]),this._opcode=15&e[0],this._payloadLength=127&e[1],0===this._opcode){if(t)return this._loop=!1,h(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,h(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return this._loop=!1,h(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else{if(!(this._opcode>7&&this._opcode<11))return this._loop=!1,h(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin)return this._loop=!1,h(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,h(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return this._loop=!1,h(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&e[1]),this._isServer){if(!this._masked)return this._loop=!1,h(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,h(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(126===this._payloadLength)this._state=1;else{if(127!==this._payloadLength)return this.haveLength();this._state=2}}getPayloadLength16(){if(!(this._bufferedBytes<2))return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength();this._loop=!1}getPayloadLength64(){if(this._bufferedBytes<8)return void(this._loop=!1);const e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,h(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,h(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=r;if(this._payloadLength){if(this._bufferedBytes7?this.controlMessage(t):this._compressed?(this._state=5,void this.decompress(t,e)):(t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage())}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,((e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(h(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(n)}const s=this.dataMessage();if(s)return t(s);this.startLoop(t)}))}dataMessage(){if(this._fin){const e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let n;n="nodebuffer"===this._binaryType?g(t,e):"arraybuffer"===this._binaryType?l(g(t,e)):t,this.emit("message",n,!0)}else{const n=g(t,e);if(!this._skipUTF8Validation&&!u(n))return this._loop=!1,h(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",n,!1)}}this._state=0}controlMessage(e){if(8===this._opcode)if(this._loop=!1,0===e.length)this.emit("conclude",1005,r),this.end();else{const t=e.readUInt16BE(0);if(!I(t))return h(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");const n=new p(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!u(n))return h(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,n),this.end()}else 9===this._opcode?this.emit("ping",e):this.emit("pong",e);this._state=0}}},7330:(e,t,n)=>{"use strict";n(1808),n(4404);const{randomFillSync:s}=n(6113),i=n(5196),{EMPTY_BUFFER:o}=n(1872),{isValidStatusCode:r}=n(6746),{mask:a,toBuffer:c}=n(977),g=Symbol("kByteLength"),l=Buffer.alloc(4);class d{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let n,i,o=!1,r=2,c=!1;t.mask&&(n=t.maskBuffer||l,t.generateMask?t.generateMask(n):s(n,0,4),c=0==(n[0]|n[1]|n[2]|n[3]),r=6),"string"==typeof e?i=t.mask&&!c||void 0===t[g]?(e=Buffer.from(e)).length:t[g]:(i=e.length,o=t.mask&&t.readOnly&&!c);let d=i;i>=65536?(r+=8,d=127):i>125&&(r+=2,d=126);const I=Buffer.allocUnsafe(o?i+r:r);return I[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(I[0]|=64),I[1]=d,126===d?I.writeUInt16BE(i,2):127===d&&(I[2]=I[3]=0,I.writeUIntBE(i,4,6)),t.mask?(I[1]|=128,I[r-4]=n[0],I[r-3]=n[1],I[r-2]=n[2],I[r-1]=n[3],c?[I,e]:o?(a(e,n,I,r,i),[I]):(a(e,n,e,0,i),[I,e])):[I,e]}close(e,t,n,s){let i;if(void 0===e)i=o;else{if("number"!=typeof e||!r(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const n=Buffer.byteLength(t);if(n>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+n),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}const a={[g]:i.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,i,!1,a,s]):this.sendFrame(d.frame(i,a),s)}ping(e,t,n){let s,i;if("string"==typeof e?(s=Buffer.byteLength(e),i=!1):(s=(e=c(e)).length,i=c.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[g]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(d.frame(e,o),n)}pong(e,t,n){let s,i;if("string"==typeof e?(s=Buffer.byteLength(e),i=!1):(s=(e=c(e)).length,i=c.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[g]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(d.frame(e,o),n)}send(e,t,n){const s=this._extensions[i.extensionName];let o,r,a=t.binary?2:1,l=t.compress;if("string"==typeof e?(o=Buffer.byteLength(e),r=!1):(o=(e=c(e)).length,r=c.readOnly),this._firstFragment?(this._firstFragment=!1,l&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=o>=s._threshold),this._compress=l):(l=!1,a=0),t.fin&&(this._firstFragment=!0),s){const s={[g]:o,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:r,rsv1:l};this._deflating?this.enqueue([this.dispatch,e,this._compress,s,n]):this.dispatch(e,this._compress,s,n)}else this.sendFrame(d.frame(e,{[g]:o,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:r,rsv1:!1}),n)}dispatch(e,t,n,s){if(!t)return void this.sendFrame(d.frame(e,n),s);const o=this._extensions[i.extensionName];this._bufferedBytes+=n[g],this._deflating=!0,o.compress(e,n.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof s&&s(e);for(let t=0;t{"use strict";const{Duplex:s}=n(2781);function i(e){e.emit("close")}function o(){!this.destroyed&&this._writableState.finished&&this.destroy()}function r(e){this.removeListener("error",r),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}e.exports=function(e,t){let n=!0;const a=new s({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,n){const s=!n&&a._readableState.objectMode?t.toString():t;a.push(s)||e.pause()})),e.once("error",(function(e){a.destroyed||(n=!1,a.destroy(e))})),e.once("close",(function(){a.destroyed||a.push(null)})),a._destroy=function(t,s){if(e.readyState===e.CLOSED)return s(t),void process.nextTick(i,a);let o=!1;e.once("error",(function(e){o=!0,s(e)})),e.once("close",(function(){o||s(t),process.nextTick(i,a)})),n&&e.terminate()},a._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),a._readableState.endEmitted&&a.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){a._final(t)}))},a._read=function(){e.isPaused&&e.resume()},a._write=function(t,n,s){e.readyState!==e.CONNECTING?e.send(t,s):e.once("open",(function(){a._write(t,n,s)}))},a.on("end",o),a.on("error",r),a}},640:(e,t,n)=>{"use strict";const{tokenChars:s}=n(6746);e.exports={parse:function(e){const t=new Set;let n=-1,i=-1,o=0;for(;o{"use strict";const{isUtf8:s}=n(4300);function i(e){const t=e.length;let n=0;for(;n=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}return!0}if(e.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:i,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},s)e.exports.isValidUTF8=function(e){return e.length<24?i(e):s(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=n(Object(function(){var e=new Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.isValidUTF8=function(e){return e.length<32?i(e):t(e)}}catch(e){}},9284:(e,t,n)=>{"use strict";const s=n(2361),i=n(3685),{createHash:o}=(n(5687),n(1808),n(4404),n(6113)),r=n(1503),a=n(5196),c=n(640),g=n(8762),{GUID:l,kWebSocket:d}=n(1872),I=/^[+/0-9A-Za-z]{22}==$/;function u(e){e._state=2,e.emit("close")}function p(){this.destroy()}function h(e,t,n,s){n=n||i.STATUS_CODES[t],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...s},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${i.STATUS_CODES[t]}\r\n`+Object.keys(s).map((e=>`${e}: ${s[e]}`)).join("\r\n")+"\r\n\r\n"+n)}function b(e,t,n,s,i){if(e.listenerCount("wsClientError")){const s=new Error(i);Error.captureStackTrace(s,b),e.emit("wsClientError",s,n,t)}else h(n,s,i)}e.exports=class extends s{constructor(e,t){if(super(),null==(e={maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:g,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=i.createServer(((e,t)=>{const n=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),t.end(n)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const n of Object.keys(t))e.on(n,t[n]);return function(){for(const n of Object.keys(t))e.removeListener(n,t[n])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,n,s)=>{this.handleUpgrade(t,n,s,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(u,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(u,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{u(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,s){t.on("error",p);const i=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if("GET"!==e.method)return void b(this,e,t,405,"Invalid HTTP method");if("websocket"!==e.headers.upgrade.toLowerCase())return void b(this,e,t,400,"Invalid Upgrade header");if(!i||!I.test(i))return void b(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");if(8!==o&&13!==o)return void b(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");if(!this.shouldHandle(e))return void h(t,400);const g=e.headers["sec-websocket-protocol"];let l=new Set;if(void 0!==g)try{l=c.parse(g)}catch(n){return void b(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const d=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&void 0!==d){const n=new a(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=r.parse(d);e[a.extensionName]&&(n.accept(e[a.extensionName]),u[a.extensionName]=n)}catch(n){return void b(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const r={origin:e.headers[8===o?"sec-websocket-origin":"origin"],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(r,((o,r,a,c)=>{if(!o)return h(t,r||401,a,c);this.completeUpgrade(u,i,l,e,t,n,s)}));if(!this.options.verifyClient(r))return h(t,401)}this.completeUpgrade(u,i,l,e,t,n,s)}completeUpgrade(e,t,n,s,i,c,g){if(!i.readable||!i.writable)return i.destroy();if(i[d])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return h(i,503);const I=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${o("sha1").update(t+l).digest("base64")}`],b=new this.options.WebSocket(null);if(n.size){const e=this.options.handleProtocols?this.options.handleProtocols(n,s):n.values().next().value;e&&(I.push(`Sec-WebSocket-Protocol: ${e}`),b._protocol=e)}if(e[a.extensionName]){const t=e[a.extensionName].params,n=r.format({[a.extensionName]:[t]});I.push(`Sec-WebSocket-Extensions: ${n}`),b._extensions=e}this.emit("headers",I,s),i.write(I.concat("\r\n").join("\r\n")),i.removeListener("error",p),b.setSocket(i,c,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(b),b.on("close",(()=>{this.clients.delete(b),this._shouldEmitClose&&!this.clients.size&&process.nextTick(u,this)}))),g(b,s)}}},8762:(e,t,n)=>{"use strict";const s=n(2361),i=n(5687),o=n(3685),r=n(1808),a=n(4404),{randomBytes:c,createHash:g}=n(6113),{Readable:l}=n(2781),{URL:d}=n(7310),I=n(5196),u=n(2957),p=n(7330),{BINARY_TYPES:h,EMPTY_BUFFER:b,GUID:C,kForOnEventAttribute:m,kListener:Z,kStatusCode:G,kWebSocket:y,NOOP:B}=n(1872),{EventTarget:{addEventListener:A,removeEventListener:W}}=n(62),{format:f,parse:V}=n(1503),{toBuffer:v}=n(977),R=Symbol("kAborted"),S=[8,13],X=["CONNECTING","OPEN","CLOSING","CLOSED"],Y=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class H extends s{constructor(e,t,n){super(),this._binaryType=h[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=b,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=H.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(n=t,t=[]):t=[t]),N(this,e,t,n)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){h.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,n){const s=new u({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation});this._sender=new p(e,this._extensions,n.generateMask),this._receiver=s,this._socket=e,s[y]=this,e[y]=this,s.on("conclude",F),s.on("drain",E),s.on("error",U),s.on("message",T),s.on("ping",z),s.on("pong",L),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",j),e.on("data",O),e.on("end",P),e.on("error",M),this._readyState=H.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=H.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[I.extensionName]&&this._extensions[I.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=H.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==H.CLOSED)if(this.readyState!==H.CONNECTING)this.readyState!==H.CLOSING?(this._readyState=H.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";_(this,this._req,e)}}pause(){this.readyState!==H.CONNECTING&&this.readyState!==H.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,n){if(this.readyState===H.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(n=e,e=t=void 0):"function"==typeof t&&(n=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===H.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||b,t,n)):J(this,e,n)}pong(e,t,n){if(this.readyState===H.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(n=e,e=t=void 0):"function"==typeof t&&(n=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===H.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||b,t,n)):J(this,e,n)}resume(){this.readyState!==H.CONNECTING&&this.readyState!==H.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,n){if(this.readyState===H.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(n=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==H.OPEN)return void J(this,e,n);const s={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[I.extensionName]||(s.compress=!1),this._sender.send(e||b,s,n)}terminate(){if(this.readyState!==H.CLOSED)if(this.readyState!==H.CONNECTING)this._socket&&(this._readyState=H.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";_(this,this._req,e)}}}function N(e,t,n,s){const r={protocolVersion:S[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(!S.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${S.join(", ")})`);let a;if(t instanceof d)a=t,e._url=t.href;else{try{a=new d(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}e._url=t}const l="wss:"===a.protocol,u="ws+unix:"===a.protocol;let p;if("ws:"===a.protocol||l||u?u&&!a.pathname?p="The URL's pathname is empty":a.hash&&(p="The URL contains a fragment identifier"):p='The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"',p){const t=new SyntaxError(p);if(0===e._redirects)throw t;return void w(e,t)}const h=l?443:80,b=c(16).toString("base64"),m=l?i.request:o.request,Z=new Set;let G,y;if(r.createConnection=l?K:k,r.defaultPort=r.defaultPort||h,r.port=a.port||h,r.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,r.headers={...r.headers,"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":b,Connection:"Upgrade",Upgrade:"websocket"},r.path=a.pathname+a.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(G=new I(!0!==r.perMessageDeflate?r.perMessageDeflate:{},!1,r.maxPayload),r.headers["Sec-WebSocket-Extensions"]=f({[I.extensionName]:G.offer()})),n.length){for(const e of n){if("string"!=typeof e||!Y.test(e)||Z.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");Z.add(e)}r.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(a.username||a.password)&&(r.auth=`${a.username}:${a.password}`),u){const e=r.path.split(":");r.socketPath=e[0],r.path=e[1]}if(r.followRedirects){if(0===e._redirects){e._originalIpc=u,e._originalSecure=l,e._originalHostOrSocketPath=u?r.socketPath:a.host;const t=s&&s.headers;if(s={...s,headers:{}},t)for(const[e,n]of Object.entries(t))s.headers[e.toLowerCase()]=n}else if(0===e.listenerCount("redirect")){const t=u?!!e._originalIpc&&r.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&a.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!l)&&(delete r.headers.authorization,delete r.headers.cookie,t||delete r.headers.host,r.auth=void 0)}r.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),y=e._req=m(r),e._redirects&&e.emit("redirect",e.url,y)}else y=e._req=m(r);r.timeout&&y.on("timeout",(()=>{_(e,y,"Opening handshake has timed out")})),y.on("error",(t=>{null===y||y[R]||(y=e._req=null,w(e,t))})),y.on("response",(i=>{const o=i.headers.location,a=i.statusCode;if(o&&r.followRedirects&&a>=300&&a<400){if(++e._redirects>r.maxRedirects)return void _(e,y,"Maximum redirects exceeded");let i;y.abort();try{i=new d(o,t)}catch(t){const n=new SyntaxError(`Invalid URL: ${o}`);return void w(e,n)}N(e,i,n,s)}else e.emit("unexpected-response",y,i)||_(e,y,`Unexpected server response: ${i.statusCode}`)})),y.on("upgrade",((t,n,s)=>{if(e.emit("upgrade",t),e.readyState!==H.CONNECTING)return;if(y=e._req=null,"websocket"!==t.headers.upgrade.toLowerCase())return void _(e,n,"Invalid Upgrade header");const i=g("sha1").update(b+C).digest("base64");if(t.headers["sec-websocket-accept"]!==i)return void _(e,n,"Invalid Sec-WebSocket-Accept header");const o=t.headers["sec-websocket-protocol"];let a;if(void 0!==o?Z.size?Z.has(o)||(a="Server sent an invalid subprotocol"):a="Server sent a subprotocol but none was requested":Z.size&&(a="Server sent no subprotocol"),a)return void _(e,n,a);o&&(e._protocol=o);const c=t.headers["sec-websocket-extensions"];if(void 0!==c){if(!G)return void _(e,n,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");let t;try{t=V(c)}catch(t){return void _(e,n,"Invalid Sec-WebSocket-Extensions header")}const s=Object.keys(t);if(1!==s.length||s[0]!==I.extensionName)return void _(e,n,"Server indicated an extension that was not requested");try{G.accept(t[I.extensionName])}catch(t){return void _(e,n,"Invalid Sec-WebSocket-Extensions header")}e._extensions[I.extensionName]=G}e.setSocket(n,s,{generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})})),r.finishRequest?r.finishRequest(y,e):y.end()}function w(e,t){e._readyState=H.CLOSING,e.emit("error",t),e.emitClose()}function k(e){return e.path=e.socketPath,r.connect(e)}function K(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=r.isIP(e.host)?"":e.host),a.connect(e)}function _(e,t,n){e._readyState=H.CLOSING;const s=new Error(n);Error.captureStackTrace(s,_),t.setHeader?(t[R]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(w,e,s)):(t.destroy(s),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function J(e,t,n){if(t){const n=v(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${X[e.readyState]})`);process.nextTick(n,t)}}function F(e,t){const n=this[y];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,void 0!==n._socket[y]&&(n._socket.removeListener("data",O),process.nextTick(Q,n._socket),1005===e?n.close():n.close(e,t))}function E(){const e=this[y];e.isPaused||e._socket.resume()}function U(e){const t=this[y];void 0!==t._socket[y]&&(t._socket.removeListener("data",O),process.nextTick(Q,t._socket),t.close(e[G])),t.emit("error",e)}function x(){this[y].emitClose()}function T(e,t){this[y].emit("message",e,t)}function z(e){const t=this[y];t.pong(e,!t._isServer,B),t.emit("ping",e)}function L(e){this[y].emit("pong",e)}function Q(e){e.resume()}function j(){const e=this[y];let t;this.removeListener("close",j),this.removeListener("data",O),this.removeListener("end",P),e._readyState=H.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[y]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",x),e._receiver.on("finish",x))}function O(e){this[y]._receiver.write(e)||this.pause()}function P(){const e=this[y];e._readyState=H.CLOSING,e._receiver.end(),this.end()}function M(){const e=this[y];this.removeListener("error",M),this.on("error",B),e&&(e._readyState=H.CLOSING,this.destroy())}Object.defineProperty(H,"CONNECTING",{enumerable:!0,value:X.indexOf("CONNECTING")}),Object.defineProperty(H.prototype,"CONNECTING",{enumerable:!0,value:X.indexOf("CONNECTING")}),Object.defineProperty(H,"OPEN",{enumerable:!0,value:X.indexOf("OPEN")}),Object.defineProperty(H.prototype,"OPEN",{enumerable:!0,value:X.indexOf("OPEN")}),Object.defineProperty(H,"CLOSING",{enumerable:!0,value:X.indexOf("CLOSING")}),Object.defineProperty(H.prototype,"CLOSING",{enumerable:!0,value:X.indexOf("CLOSING")}),Object.defineProperty(H,"CLOSED",{enumerable:!0,value:X.indexOf("CLOSED")}),Object.defineProperty(H.prototype,"CLOSED",{enumerable:!0,value:X.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(H.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(H.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[m])return t[Z];return null},set(t){for(const t of this.listeners(e))if(t[m]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[m]:!0})}})})),H.prototype.addEventListener=A,H.prototype.removeEventListener=W,e.exports=H},4300:e=>{"use strict";e.exports=require("buffer")},6113:e=>{"use strict";e.exports=require("crypto")},1891:e=>{"use strict";e.exports=require("dgram")},7643:e=>{"use strict";e.exports=require("diagnostics_channel")},2361:e=>{"use strict";e.exports=require("events")},3292:e=>{"use strict";e.exports=require("fs/promises")},3685:e=>{"use strict";e.exports=require("http")},5687:e=>{"use strict";e.exports=require("https")},1405:e=>{"use strict";e.exports=require("inspector")},1808:e=>{"use strict";e.exports=require("net")},1017:e=>{"use strict";e.exports=require("path")},2781:e=>{"use strict";e.exports=require("stream")},4404:e=>{"use strict";e.exports=require("tls")},7310:e=>{"use strict";e.exports=require("url")},9796:e=>{"use strict";e.exports=require("zlib")},2764:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},7359:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runEntrypoint=void 0;const s=n(7582),i=n(9913),o=s.__importDefault(n(3292)),r=n(2068),a=n(5773);n(1257);const c=n(8221),g=s.__importDefault(n(1017));let l,d=!1;t.runEntrypoint=function(e,t){Promise.resolve().then((async()=>{if(d)throw new Error("runEntrypoint can only be called once");d=!0;const n=process.env.MODULE_MANIFEST;if(!n)throw new Error("Module initialise is missing MODULE_MANIFEST");const s=await o.default.readFile(n),I=JSON.parse(s.toString());if(I.runtime?.api!==i.HostApiNodeJsIpc)throw new Error("Module manifest 'api' mismatch");if(!I.runtime.apiVersion)throw new Error("Module manifest 'apiVersion' missing");let u=I.runtime.apiVersion;if("0.0.0"===u)try{const e=await o.default.readFile(g.default.join(__dirname,"../package.json")),t=JSON.parse(e.toString());"@companion-module/base"===t.name&&(u=t.version)}catch(e){throw new Error("Failed to determine module api version")}if(!process.send)throw new Error("Module is not being run with ipc");console.log(`Starting up module class: ${e.name}`);const p=process.env.CONNECTION_ID;if("string"!=typeof p||!p)throw new Error("Module initialise is missing CONNECTION_ID");const h=process.env.VERIFICATION_TOKEN;if("string"!=typeof h||!h)throw new Error("Module initialise is missing VERIFICATION_TOKEN");const b=process.env.SENTRY_DSN,C=process.env.SENTRY_USERID,m=process.env.SENTRY_COMPANION_VERSION;b&&C&&"https://"==b.substring(0,8)?(console.log("Sentry enabled"),(0,a.init)({dsn:b,release:`${I.name}@${I.version}`,beforeSend:e=>(e.exception&&console.log("sentry","error",e.exception),e)}),(0,a.configureScope)((e=>{e.setUser({id:C}),e.setTag("companion",m)}))):console.log("Sentry disabled");const Z=new c.IpcWrapper({},(e=>{process.send(e)}),5e3);process.once("message",(e=>{Z.receivedMessage(e)})),l=new e((0,r.literal)({id:p,upgradeScripts:t,_isInstanceBaseProps:!0})),Z.sendWithCb("register",{apiVersion:u,connectionId:p,verificationToken:h}).then((()=>{console.log("Module-host accepted registration")}),(e=>{console.error("Module registration failed",e),process.exit(11)}))})).catch((e=>{console.error("Failed to startup module:"),console.error(e.stack||e.message),process.exit(1)}))}},1972:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UDPHelper=t.TelnetHelper=t.TCPHelper=void 0;var s=n(9159);Object.defineProperty(t,"TCPHelper",{enumerable:!0,get:function(){return s.TCPHelper}});var i=n(6226);Object.defineProperty(t,"TelnetHelper",{enumerable:!0,get:function(){return i.TelnetHelper}});var o=n(8473);Object.defineProperty(t,"UDPHelper",{enumerable:!0,get:function(){return o.UDPHelper}})},9159:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TCPHelper=void 0;const s=n(7582).__importDefault(n(1808)),i=n(6729),o=n(609);class r extends i.EventEmitter{#e;#t;_socket;#n;#s=!1;#i=!1;#o=!1;#r;#a;#c;get isConnected(){return this.#s}get isConnecting(){return this.#i}get isDestroyed(){return this.#o}constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n={reconnect_interval:2e3,reconnect:!0,...n},this._socket=new s.default.Socket,this._socket.setKeepAlive(!0),this._socket.setNoDelay(!0),this._socket.on("error",(e=>{this.#i=!1,this.#s=!1,this.#n.reconnect&&this.#g(),this.#l(o.InstanceStatus.UnknownError,e.message),this.emit("error",e)})),this._socket.on("ready",(()=>{this.#s=!0,this.#i=!1,this.#l(o.InstanceStatus.Ok),this.emit("connect")})),this._socket.on("end",(()=>{this.#s=!1,this.#l(o.InstanceStatus.Disconnected),!this.#i&&this.#n.reconnect&&this.#g(),this.emit("end")})),this._socket.on("data",(e=>this.emit("data",e))),this._socket.on("drain",(()=>this.emit("drain"))),setImmediate((()=>this.connect())),this.#c=setTimeout((()=>{this.#c=void 0,this.#o||this.listenerCount("error")||console.error(`Danger: TCP client for ${this.#e}:${this.#t} is missing an error handler!`)}),5e3)}connect(){if(this.#o)throw new Error("Cannot connect destroyed socket");return!this.#i&&(this.#i=!0,this._socket.connect(this.#t,this.#e),!0)}async send(e){if(this.#o||this._socket.destroyed)throw new Error("Cannot write to destroyed socket");if(!e||!e.length)throw new Error("No message to send");if(!this.#s)return!1;try{return new Promise(((t,n)=>{this._socket.write(e,(e=>{e?n(e):t(!0)}))}))}catch(e){this.#s=!1;const t=e instanceof Error?e:new Error(`${e}`);throw this.#l(o.InstanceStatus.UnknownError,t.message),this.emit("error",t),t}}destroy(){this.#o=!0,void 0!==this.#a&&(clearTimeout(this.#a),this.#a=void 0),void 0!==this.#c&&(clearTimeout(this.#c),this.#c=void 0),this._socket.removeAllListeners(),this.removeAllListeners(),this._socket.destroy()}#g(){void 0!==this.#a&&clearTimeout(this.#a),this.#a=setTimeout((()=>{this.#a=void 0,this.#l(o.InstanceStatus.Connecting),this.connect()}),this.#n.reconnect_interval)}#l(e,t){this.#r!=e&&(this.#r=e,this.emit("status_change",e,t))}}t.TCPHelper=r},6226:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TelnetHelper=void 0;const s=n(7582).__importDefault(n(6729)),i=n(2781),o=n(9159);class r extends s.default{#d;#I;#c;get isConnected(){return this.#d.isConnected}get isConnecting(){return this.#d.isConnecting}get isDestroyed(){return this.#d.isDestroyed}constructor(e,t,n){super(),this.#d=new o.TCPHelper(e,t,n),this.#I=new a,this.#d._socket.pipe(this.#I),this.#d.on("connect",(()=>this.emit("connect"))),this.#d.on("end",(()=>this.emit("end"))),this.#d.on("error",(e=>this.emit("error",e))),this.#d.on("status_change",((e,t)=>this.emit("status_change",e,t))),this.#I.on("iac",((e,t)=>this.emit("iac",e,t))),this.#I.on("sb",(e=>this.emit("sb",e))),this.#I.on("data",(e=>this.emit("data",e))),this.#I.on("drain",(()=>this.emit("drain"))),this.#c=setTimeout((()=>{this.#c=void 0,this.isDestroyed||this.listenerCount("error")||console.error(`Danger: Telnet client for ${e}:${t} is missing an error handler!`)}),5e3)}connect(){return this.#d.connect()}async send(e){return this.#d.send(e)}destroy(){this.#d.destroy(),void 0!==this.#c&&(clearTimeout(this.#c),this.#c=void 0),this.#I.removeAllListeners(),this.#I.destroy()}}t.TelnetHelper=r;class a extends i.Transform{#u;#p;#h;constructor(e){super(e),this.#u=Buffer.alloc(0),this.#p=Buffer.alloc(0),this.#h=0}_transform(e,t,n){for(let t=0;t=251&&this.#h<=254){let t;switch(this.#h){case 251:t="WILL";break;case 252:t="WONT";break;case 253:t="DO";break;case 254:t="DONT";break;default:return}return this.emit("iac",t,e),void(this.#h=0)}if(250===this.#h){if(240===e)return this.emit("sb",this.#p),this.#h=0,void(this.#p=Buffer.alloc(0));this.#p=Buffer.concat([this.#p,Buffer.from([e])])}}}#C(){const e=this.#u;return this.#u=Buffer.alloc(0),e}}},8473:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UDPHelper=void 0;const s=n(7582).__importDefault(n(1891)),i=n(6729),o=n(609);class r extends i.EventEmitter{#e;#t;#m;#n;#o=!1;#r;#c;get isDestroyed(){return this.#o}constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n={...n},this.#m=s.default.createSocket("udp4");try{this.#m.bind(this.#n.bind_port||0,this.#n.bind_ip)}catch(e){throw new Error(`Unable to bind to ip/port: ${this.#n.bind_ip}:${this.#n.bind_port}`)}this.#n.broadcast&&this.#m.setBroadcast(!0),void 0!==this.#n.ttl&&this.#m.setTTL(this.#n.ttl),void 0!==this.#n.multicast_ttl&&this.#m.setMulticastTTL(this.#n.multicast_ttl),this.#m.on("error",(e=>{this.#l(o.InstanceStatus.UnknownError,e.message),this.emit("error",e)})),this.#m.on("listening",(()=>{this.#n.multicast_interface&&this.#m.setMulticastInterface(this.#n.multicast_interface),this.#l(o.InstanceStatus.Ok),this.emit("listening")})),this.#m.on("message",(e=>this.emit("data",e))),this.#c=setTimeout((()=>{this.#o||this.listenerCount("error")||console.error(`Danger: UDP socket for ${this.#e}:${this.#t} is missing an error handler!`)}),5e3)}async send(e){if(this.#o)throw new Error("Cannot write to destroyed socket");if(!e||!e.length)throw new Error("No message to send");return new Promise(((t,n)=>{this.#m.send(e,this.#t,this.#e,(e=>{e?n(e):t()}))}))}destroy(){this.#o=!0,void 0!==this.#c&&(clearTimeout(this.#c),this.#c=void 0),this.#m.removeAllListeners(),this.#m.close(),this.removeAllListeners()}#l(e,t){this.#r!=e&&(this.#r=e,this.emit("status_change",e,t))}}t.UDPHelper=r},8221:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IpcWrapper=void 0;const s=n(7582),i=n(2068),o=s.__importDefault(n(2559));t.IpcWrapper=class{#Z;#G;#y;#B=1;#A=new Map;constructor(e,t,n){this.#Z=e,this.#G=t,this.#y=n}async sendWithCb(e,t,n,s=0){s<=0&&(s=this.#y);const i={timeout:void 0,resolve:()=>null,reject:()=>null},r=new Promise(((e,t)=>{i.resolve=e,i.reject=t}));this.#B>268435456&&(this.#B=1);const a=this.#B++;this.#A.set(a,i),this.#G({direction:"call",name:String(e),payload:o.default.stringify(t),callbackId:a});const c=new Error("Call timed out");return i.timeout=setTimeout((()=>{i.reject(n?n():c),this.#A.delete(a)}),s),r}sendWithNoCb(e,t){this.#G({direction:"call",name:String(e),payload:o.default.stringify(t),callbackId:void 0})}receivedMessage(e){const t=e;switch(e.direction){case"call":{const t=this.#Z[e.name];if(!t)return void(e.callbackId&&this.#G({direction:"response",callbackId:e.callbackId,success:!1,payload:o.default.stringify({message:`Unknown command "${e.name}"`})}));t(e.payload?o.default.parse(e.payload):void 0).then((t=>{e.callbackId&&this.#G({direction:"response",callbackId:e.callbackId,success:!0,payload:o.default.stringify(t)})}),(t=>{e.callbackId&&this.#G({direction:"response",callbackId:e.callbackId,success:!1,payload:t instanceof Error?JSON.stringify(t,Object.getOwnPropertyNames(t)):o.default.stringify(t)})}));break}case"response":{if(!e.callbackId)return void console.error("Ipc: Response message has no callbackId");const t=this.#A.get(e.callbackId);if(this.#A.delete(e.callbackId),!t)return;clearTimeout(t.timeout);const n=e.payload?o.default.parse(e.payload):void 0;if(e.success)t.resolve(n);else{let e=n;n&&"object"==typeof n&&"message"in n&&(e=new Error(n.message),n.stack&&(e.stack=n.stack)),t.reject(e)}break}default:(0,i.assertNever)(e),console.error(`Ipc: Message of unknown direction "${t.direction}"`)}}}},9913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HostApiNodeJsIpc=void 0,t.HostApiNodeJsIpc="nodejs-ipc"},8049:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runEntrypoint=t.assertNever=t.splitHex=t.splitHsv=t.splitHsl=t.splitRgb=t.combineRgb=t.literal=void 0;const s=n(7582);s.__exportStar(n(7517),t),s.__exportStar(n(4911),t),s.__exportStar(n(2764),t);var i=n(2068);Object.defineProperty(t,"literal",{enumerable:!0,get:function(){return i.literal}}),Object.defineProperty(t,"combineRgb",{enumerable:!0,get:function(){return i.combineRgb}}),Object.defineProperty(t,"splitRgb",{enumerable:!0,get:function(){return i.splitRgb}}),Object.defineProperty(t,"splitHsl",{enumerable:!0,get:function(){return i.splitHsl}}),Object.defineProperty(t,"splitHsv",{enumerable:!0,get:function(){return i.splitHsv}}),Object.defineProperty(t,"splitHex",{enumerable:!0,get:function(){return i.splitHex}}),Object.defineProperty(t,"assertNever",{enumerable:!0,get:function(){return i.assertNever}}),s.__exportStar(n(1972),t);var o=n(7359);Object.defineProperty(t,"runEntrypoint",{enumerable:!0,get:function(){return o.runEntrypoint}})},4391:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionManager=void 0;const s=n(2557);function i(e){return{id:e.id,actionId:e.actionId,controlId:e.controlId,options:e.options}}t.ActionManager=class{#W;#f;#V;#v=new Map;#R=new Map;constructor(e,t,n){this.#W=e,this.#f=t,this.#V=n}async handleExecuteAction(e){const t=this.#v.get(e.action.actionId);if(!t)throw new Error(`Unknown action: ${e.action.actionId}`);const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.action.controlId,actionInstanceId:e.action.id,feedbackInstanceId:void 0})).text};await t.callback({id:e.action.id,actionId:e.action.actionId,controlId:e.action.controlId,options:e.action.options,surfaceId:e.surfaceId},n)}handleUpdateActions(e){for(const[t,n]of Object.entries(e)){const e=this.#R.get(t);if(e){const t=this.#v.get(e.actionId);if(t?.unsubscribe){const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.unsubscribe(i(e),n)).catch((t=>{this.#V("error",`Action unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}if(!n||n.disabled)this.#R.delete(t);else{this.#R.set(t,n);const e=this.#v.get(n.actionId);if(e?.subscribe){const t={parseVariablesInString:async e=>(await this.#W({text:e,controlId:n.controlId,actionInstanceId:n.id,feedbackInstanceId:void 0})).text};Promise.resolve(e.subscribe(i(n),t)).catch((e=>{this.#V("error",`Action subscribe failed: ${JSON.stringify(n)} - ${e?.message??e} ${e?.stack}`)}))}}}}async handleLearnAction(e){const t=this.#v.get(e.action.actionId);if(t&&t.learn){const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.action.controlId,actionInstanceId:e.action.id,feedbackInstanceId:void 0})).text};return{options:await t.learn({id:e.action.id,actionId:e.action.actionId,controlId:e.action.controlId,options:e.action.options,surfaceId:void 0},n)}}return{options:void 0}}setActionDefinitions(e){const t=[];this.#v.clear();for(const[n,i]of Object.entries(e))i&&(t.push({id:n,name:i.name,description:i.description,options:(0,s.serializeIsVisibleFn)(i.options),hasLearn:!!i.learn,learnTimeout:i.learnTimeout}),this.#v.set(n,i));this.#f({actions:t})}_getAllActions(){return Array.from(this.#R.values()).map((e=>({id:e.id,actionId:e.actionId,controlId:e.controlId,options:e.options})))}subscribeActions(e){let t=Array.from(this.#R.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.actionId))));for(const e of t){const t=this.#v.get(e.actionId);if(t?.subscribe){const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.subscribe(i(e),n)).catch((t=>{this.#V("error",`Action subscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}unsubscribeActions(e){let t=Array.from(this.#R.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.actionId))));for(const e of t){const t=this.#v.get(e.actionId);if(t&&t.unsubscribe){const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.unsubscribe(i(e),n)).catch((t=>{this.#V("error",`Action unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}}},2557:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInstanceBaseProps=t.serializeIsVisibleFn=void 0,t.serializeIsVisibleFn=function(e){return(e??[]).map((e=>"isVisible"in e&&"function"==typeof e.isVisible?{...e,isVisibleFn:e.isVisible.toString(),isVisible:void 0}:{...e,isVisibleFn:void 0}))},t.isInstanceBaseProps=function(e){const t=e;return"object"==typeof t&&"string"==typeof t.id&&!0===t._isInstanceBaseProps}},7550:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeedbackManager=void 0;const s=n(7582),i=n(2557),o=s.__importDefault(n(3453));function r(e,t){return{type:e,id:t.id,feedbackId:t.feedbackId,controlId:t.controlId,options:t.options}}t.FeedbackManager=class{#W;#S;#X;#V;#Y=new Map;#H=new Map;#N=new Map;#w=new Map;#k;get parseVariablesContext(){return this.#k}constructor(e,t,n,s){this.#W=e,this.#S=t,this.#X=n,this.#V=s}getDefinitionIds(){return Array.from(this.#Y.keys())}getInstanceIds(){return Array.from(this.#H.keys())}handleUpdateFeedbacks(e){for(const[t,n]of Object.entries(e)){const e=this.#H.get(t);if(e){const t=this.#Y.get(e.feedbackId);if(t?.unsubscribe){const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.unsubscribe(r(t.type,e),n)).catch((t=>{this.#V("error",`Feedback unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}if(!n||n.disabled)this.#H.delete(t);else{this.#H.set(t,{...n,referencedVariables:null});const e=this.#Y.get(n.feedbackId);if(e?.subscribe){const t={parseVariablesInString:async e=>(await this.#W({text:e,controlId:n.controlId,actionInstanceId:void 0,feedbackInstanceId:n.id})).text};Promise.resolve(e.subscribe(r(e.type,n),t)).catch((e=>{this.#V("error",`Feedback subscribe failed: ${JSON.stringify(n)} - ${e?.message??e} ${e?.stack}`)}))}this.#K(t)}}}async handleLearnFeedback(e){const t=this.#Y.get(e.feedback.feedbackId);if(t&&t.learn){const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.feedback.controlId,actionInstanceId:void 0,feedbackInstanceId:e.feedback.id})).text};return{options:await t.learn({id:e.feedback.id,feedbackId:e.feedback.feedbackId,controlId:e.feedback.controlId,options:e.feedback.options,type:t.type},n)}}return{options:void 0}}handleVariablesChanged(e){if(!e.variablesIds.length)return;const t=new Set(e.variablesIds);for(const t of this.#w.values())for(const n of e.variablesIds)t.changedVariables.add(n);const n=new Set;for(const e of this.#H.values())if(!this.#w.has(e.id)&&e.referencedVariables)for(const s of e.referencedVariables)if(t.has(s)){n.add(e.id);break}for(const e of n)setImmediate((()=>{this.#K(e)}))}#K(e){const t=this.#w.get(e);if(t)return void(t.needsRecheck=!0);const n=this.#H.get(e);if(!n)return;const s=n,i={needsRecheck:!1,changedVariables:new Set};this.#w.set(e,i),Promise.resolve().then((async()=>{const t=this.#Y.get(s.feedbackId);let n;const i=new Set;if(t){this.#k=`Feedback ${s.feedbackId} (${e})`;const o={parseVariablesInString:async t=>{const n=await this.#W({text:t,controlId:s.controlId,actionInstanceId:void 0,feedbackInstanceId:e});if(n.variableIds&&n.variableIds.length)for(const e of n.variableIds)i.add(e);return n.text}};n="boolean"===t.type?t.callback({...r("boolean",s),type:"boolean"},o):t.callback({...r("advanced",s),type:"advanced",image:s.image},o),this.#k=void 0}const o=await n;this.#N.set(e,{id:e,controlId:s.controlId,value:o}),this.#_(),s.referencedVariables=i.size>0?Array.from(i):null})).catch((e=>{console.error(`Feedback check failed: ${JSON.stringify(s)} - ${e?.message??e} ${e?.stack}`)})).finally((()=>{this.#k=void 0,this.#w.delete(e);let t=!1;if(s.referencedVariables)for(const e of s.referencedVariables)if(i.changedVariables.has(e)){t=!0;break}(t||i.needsRecheck)&&setImmediate((()=>{this.#K(e)}))}))}#_=(0,o.default)((()=>{const e=this.#N;this.#N=new Map,e.size>0&&this.#S({values:Array.from(e.values())})}),{wait:5,maxWait:25});setFeedbackDefinitions(e){const t=[];this.#Y.clear();for(const[n,s]of Object.entries(e))s&&(t.push({id:n,name:s.name,description:s.description,options:(0,i.serializeIsVisibleFn)(s.options),type:s.type,defaultStyle:"boolean"===s.type?s.defaultStyle:void 0,hasLearn:!!s.learn,learnTimeout:s.learnTimeout,showInvert:"boolean"===s.type&&s.showInvert}),this.#Y.set(n,s));this.#X({feedbacks:t})}checkFeedbacks(e){const t=new Set(e);for(const[e,n]of this.#H.entries())this.#Y.get(n.feedbackId)&&(0===t.size||t.has(n.feedbackId))&&this.#K(e)}checkFeedbacksById(e){for(const t of e)this.#K(t)}_getAllFeedbacks(){return Array.from(this.#H.values()).map((e=>({id:e.id,feedbackId:e.feedbackId,controlId:e.controlId,options:e.options})))}subscribeFeedbacks(e){let t=Array.from(this.#H.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.feedbackId))));for(const e of t){const t=this.#Y.get(e.feedbackId);if(t?.subscribe){const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.subscribe(r(t.type,e),n)).catch((t=>{this.#V("error",`Feedback subscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}unsubscribeFeedbacks(e){let t=Array.from(this.#H.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.feedbackId))));for(const e of t){const t=this.#Y.get(e.feedbackId);if(t&&t.unsubscribe){const n={parseVariablesInString:async t=>(await this.#W({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.unsubscribe(r(t.type,e),n)).catch((t=>{this.#V("error",`Feedback unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}}},1806:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runThroughUpgradeScripts=void 0;const s=n(2068);function i(e){return JSON.parse(JSON.stringify(e))}t.runThroughUpgradeScripts=function(e,t,n,o,r,a){const c=new Map,g=e=>{let t=c.get(e);return t||(t={actions:[],feedbacks:[],config:!1},c.set(e,t)),t};for(const t of Object.values(e)){const e=t?.upgradeIndex??n;t&&"number"==typeof e&&g(e).actions.push(t.id)}for(const e of Object.values(t)){const t=e?.upgradeIndex??n;e&&"number"==typeof t&&g(t).feedbacks.push(e.id)}if(!a)for(let e=n??-1;e0){const a=Array.from(c.keys()).sort(),g=Math.min(...a,n??-1)+1,u=[],p=[],h=o.length;for(let n=g;n{const n=e[t];if(n)return(0,s.literal)({id:n.id,controlId:n.controlId,actionId:n.actionId,options:void 0!==n.options?i(n.options):{}})})).filter((e=>!!e)),feedbacks:p.map((e=>{const n=t[e];if(n)return(0,s.literal)({id:n.id,controlId:n.controlId,feedbackId:n.feedbackId,options:void 0!==n.options?i(n.options):{},isInverted:n.isInverted})})).filter((e=>!!e))});g&&b.updatedConfig&&(I=b.updatedConfig);for(const t of b.updatedActions)if(t){const n=e[t.id];n&&(n.actionId=t.actionId,n.options=t.options,d[t.id]=n)}for(const e of b.updatedFeedbacks)if(e){const n=t[e.id];n&&(n.feedbackId=e.feedbackId,n.options=e.options,l[e.id]={...n,style:l[e.id]?.style??e.style,isInverted:e.isInverted??!1})}}for(const[t,n]of Object.entries(e))d[t]||"number"!=typeof n?.upgradeIndex||(d[t]=n);for(const[e,n]of Object.entries(t))l[e]||"number"!=typeof n?.upgradeIndex||(l[e]=n)}return{updatedActions:d,updatedFeedbacks:l,updatedConfig:I}}},7517:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateManifest=void 0;const s=n(7582).__importDefault(n(4618));t.validateManifest=function(e){const t=JSON.stringify(e);if(t.includes("companion-module-your-module-name"))throw new Error("Manifest incorrectly references template module 'companion-module-your-module-name'");if(t.includes("module-shortname"))throw new Error("Manifest incorrectly references template module 'module-shortname'");if(t.includes("A short one line description of your module"))throw new Error("Manifest incorrectly references template module 'A short one line description of your module'");if(t.includes("Your name"))throw new Error("Manifest incorrectly references template module 'Your name'");if(t.includes("Your email"))throw new Error("Manifest incorrectly references template module 'Your email'");if(t.includes("Your company"))throw new Error("Manifest incorrectly references template module 'Your company'");if(t.includes("Your product"))throw new Error("Manifest incorrectly references template module 'Your product'");if(!(0,s.default)(e)){const e=s.default.errors;if(!e)throw new Error("Manifest failed validation with unknown reason");throw new Error(`Manifest validation failed: ${JSON.stringify(e)}`)}}},8322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5203:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceBase=void 0;const s=n(7582),i=n(2068),o=s.__importDefault(n(5860)),r=n(2557),a=n(1806),c=n(7550),g=n(8221),l=n(4391),d=n(9509);t.InstanceBase=class{#J;#F;id;#E=new o.default({concurrency:1});#U=!1;#x=!1;#T={};#z;#L;#Q=new Map;#j=new Map;#O=new Map;#n;#P;get instanceOptions(){return this.#n}get label(){return this.#P}constructor(e){if(!(0,r.isInstanceBaseProps)(e)||!e._isInstanceBaseProps)throw new Error("Module instance is being constructed incorrectly. Make sure you aren't trying to do this manually");this.createSharedUdpSocket=this.createSharedUdpSocket.bind(this),this.#n={disableVariableValidation:!1},this.#J=new g.IpcWrapper({init:this._handleInit.bind(this),destroy:this._handleDestroy.bind(this),updateConfigAndLabel:this._handleConfigUpdateAndLabel.bind(this),updateConfig:async()=>{},executeAction:this._handleExecuteAction.bind(this),updateFeedbacks:this._handleUpdateFeedbacks.bind(this),updateActions:this._handleUpdateActions.bind(this),getConfigFields:this._handleGetConfigFields.bind(this),handleHttpRequest:this._handleHttpRequest.bind(this),learnAction:this._handleLearnAction.bind(this),learnFeedback:this._handleLearnFeedback.bind(this),startStopRecordActions:this._handleStartStopRecordActions.bind(this),variablesChanged:this._handleVariablesChanged.bind(this),sharedUdpSocketMessage:this._handleSharedUdpSocketMessage.bind(this),sharedUdpSocketError:this._handleSharedUdpSocketError.bind(this)},(e=>{process.send(e)}),5e3),process.on("message",(e=>{this.#J.receivedMessage(e)})),this.#z=new l.ActionManager((async e=>this.#J.sendWithCb("parseVariablesInString",e)),(e=>this.#J.sendWithNoCb("setActionDefinitions",e)),this.log.bind(this)),this.#L=new c.FeedbackManager((async e=>this.#J.sendWithCb("parseVariablesInString",e)),(e=>this.#J.sendWithNoCb("updateFeedbackValues",e)),(e=>this.#J.sendWithNoCb("setFeedbackDefinitions",e)),this.log.bind(this)),this.#F=e.upgradeScripts,this.id=e.id,this.#P=e.id,this.log("debug","Initializing")}async _handleInit(e){return this.#E.add((async()=>{if(this.#U)throw new Error("Already initialized");const t=e.actions,n=e.feedbacks;if(this.#T=e.config,this.#P=e.label,e.isFirstInit){const t={},n=this.getConfigFields();for(const e of n)"default"in e&&(t[e.id]=e.default);this.#T=t,this.saveConfig(this.#T),e.lastUpgradeIndex=this.#F.length-1}const{updatedActions:s,updatedFeedbacks:i,updatedConfig:o}=(0,a.runThroughUpgradeScripts)(t,n,e.lastUpgradeIndex,this.#F,this.#T,!1);this.#T=o??this.#T;const r=this.#J.sendWithCb("upgradedItems",{updatedActions:s,updatedFeedbacks:i});try{await this.init(this.#T,!!e.isFirstInit),this.#U=!0}catch(e){throw console.trace(`Init failed: ${e}`),e}finally{await r}return setImmediate((()=>{this._handleUpdateActions({actions:t},!0).catch((e=>{this.log("error",`Receive actions failed: ${e}`)})),this._handleUpdateFeedbacks({feedbacks:n},!0).catch((e=>{this.log("error",`Receive feedbacks failed: ${e}`)}))})),{hasHttpHandler:"function"==typeof this.handleHttpRequest,hasRecordActionsHandler:"function"==typeof this.handleStartStopRecordActions,newUpgradeIndex:this.#F.length-1,updatedConfig:this.#T}}))}async _handleDestroy(){await this.#E.add((async()=>{if(!this.#U)throw new Error("Not initialized");await this.destroy(),this.#U=!1}))}async _handleConfigUpdateAndLabel(e){await this.#E.add((async()=>{if(!this.#U)throw new Error("Not initialized");this.#P=e.label,this.#T=e.config,await this.configUpdated(this.#T)}))}async _handleExecuteAction(e){return this.#z.handleExecuteAction(e)}async _handleUpdateFeedbacks(e,t){if(!t){const t=(0,a.runThroughUpgradeScripts)({},e.feedbacks,null,this.#F,this.#T,!0);this.#J.sendWithCb("upgradedItems",{updatedActions:t.updatedActions,updatedFeedbacks:t.updatedFeedbacks}).catch((e=>{this.log("error",`Failed to save upgraded feedbacks: ${e}`)}))}this.#L.handleUpdateFeedbacks(e.feedbacks)}async _handleUpdateActions(e,t){if(!t){const t=(0,a.runThroughUpgradeScripts)(e.actions,{},null,this.#F,this.#T,!0);this.#J.sendWithCb("upgradedItems",{updatedActions:t.updatedActions,updatedFeedbacks:t.updatedFeedbacks}).catch((e=>{this.log("error",`Failed to save upgraded actions: ${e}`)}))}this.#z.handleUpdateActions(e.actions)}async _handleGetConfigFields(e){return{fields:(0,r.serializeIsVisibleFn)(this.getConfigFields())}}async _handleHttpRequest(e){if(!this.handleHttpRequest)throw new Error("handleHttpRequest is not supported!");return{response:await this.handleHttpRequest(e.request)}}async _handleLearnAction(e){return this.#z.handleLearnAction(e)}async _handleLearnFeedback(e){return this.#L.handleLearnFeedback(e)}async _handleStartStopRecordActions(e){if(e.recording){if(this.#x)return}else if(!this.#x)return;if(!this.handleStartStopRecordActions)throw this.#x=!1,new Error("Recording actions is not supported by this module!");this.#x=e.recording,this.handleStartStopRecordActions(this.#x)}async _handleVariablesChanged(e){this.#L.handleVariablesChanged(e)}async _handleSharedUdpSocketMessage(e){for(const t of this.#Q.values())t.handleId===e.handleId&&t.receiveSocketMessage(e)}async _handleSharedUdpSocketError(e){for(const t of this.#Q.values())t.handleId===e.handleId&&t.receiveSocketError(e.error)}saveConfig(e){this.#T=e,this.#J.sendWithNoCb("saveConfig",{config:e})}setActionDefinitions(e){this.#z.setActionDefinitions(e)}setFeedbackDefinitions(e){this.#L.setFeedbackDefinitions(e)}setPresetDefinitions(e){const t=[];for(const[n,s]of Object.entries(e))s&&t.push({...s,id:n});this.#J.sendWithNoCb("setPresetDefinitions",{presets:t})}setVariableDefinitions(e){const t=[],n=[];this.#j.clear();for(const s of e)t.push({id:s.variableId,name:s.name}),this.#j.set(s.variableId,s),this.#O.has(s.variableId)||(this.#O.set(s.variableId,""),n.push({id:s.variableId,value:""}));if(!this.#n.disableVariableValidation){const e=new Set(this.#j.keys());for(const t of this.#O.keys())e.has(t)||(this.#O.delete(t),n.push({id:t,value:void 0}))}this.#J.sendWithNoCb("setVariableDefinitions",{variables:t,newValues:n})}setVariableValues(e){const t=[];for(const[n,s]of Object.entries(e))this.#n.disableVariableValidation?(void 0===s?this.#O.delete(n):this.#O.set(n,s),t.push({id:n,value:s})):this.#j.has(n)?(this.#O.set(n,s??""),t.push({id:n,value:s??""})):t.push({id:n,value:void 0});this.#J.sendWithNoCb("setVariableValues",{newValues:t})}getVariableValue(e){return this.#O.get(e)}async parseVariablesInString(e){const t=this.#L.parseVariablesContext;return t&&this.log("debug",`parseVariablesInString called while in: ${t}. You should use the parseVariablesInString provided to the callback instead`),(await this.#J.sendWithCb("parseVariablesInString",{text:e,controlId:void 0,actionInstanceId:void 0,feedbackInstanceId:void 0})).text}checkFeedbacks(...e){this.#L.checkFeedbacks(e)}checkFeedbacksById(...e){this.#L.checkFeedbacksById(e)}_getAllActions(){return this.#z._getAllActions()}subscribeActions(...e){this.#z.subscribeActions(e)}unsubscribeActions(...e){this.#z.unsubscribeActions(e)}_getAllFeedbacks(){return this.#L._getAllFeedbacks()}subscribeFeedbacks(...e){this.#L.subscribeFeedbacks(e)}unsubscribeFeedbacks(...e){this.#L.unsubscribeFeedbacks(e)}recordAction(e,t){if(!this.#x)throw new Error("Not currently recording actions");this.#J.sendWithNoCb("recordAction",{uniquenessId:t??null,actionId:e.actionId,options:e.options})}setCustomVariableValue(e,t){this.#J.sendWithNoCb("setCustomVariable",{customVariableId:e,value:t})}oscSend(e,t,n,s){this.#J.sendWithNoCb("send-osc",(0,i.literal)({host:e,port:t,path:n,args:s}))}updateStatus(e,t){this.#J.sendWithNoCb("set-status",(0,i.literal)({status:e,message:t??null}))}log(e,t){this.#J.sendWithNoCb("log-message",(0,i.literal)({level:e,message:t}))}createSharedUdpSocket(e,t){const n="string"==typeof e?{type:e}:e,s=new d.SharedUdpSocketImpl(this.#J,this.#Q,n);return t&&s.on("message",t),s}}},9051:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},609:(e,t)=>{"use strict";var n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Regex=t.InstanceStatus=void 0,function(e){e.Ok="ok",e.Connecting="connecting",e.Disconnected="disconnected",e.ConnectionFailure="connection_failure",e.BadConfig="bad_config",e.UnknownError="unknown_error",e.UnknownWarning="unknown_warning"}(n||(t.InstanceStatus=n={})),function(e){e.IP="/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/",e.HOSTNAME="/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/",e.BOOLEAN="/^(true|false|0|1)$/i",e.PORT="/^([1-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-4])$/",e.MAC_ADDRESS="/^(?:[a-fA-F0-9]{2}:){5}([a-fA-F0-9]{2})$/",e.PERCENT="/^(100|[0-9]|[0-9][0-9])$/",e.FLOAT="/^([0-9]*\\.)?[0-9]+$/",e.SIGNED_FLOAT="/^[+-]?([0-9]*\\.)?[0-9]+$/",e.FLOAT_OR_INT="/^([0-9]+)(\\.[0-9]+)?$/",e.NUMBER="/^\\d+$/",e.SIGNED_NUMBER="/^[+-]?\\d+$/",e.SOMETHING="/^.+$/",e.TIMECODE="/^(0*[0-9]|1[0-9]|2[0-4]):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[12][0-9]|30)$/"}(s||(t.Regex=s={}))},4334:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2490:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4911:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(7582);s.__exportStar(n(8322),t),s.__exportStar(n(5203),t),s.__exportStar(n(9051),t),s.__exportStar(n(609),t),s.__exportStar(n(4334),t),s.__exportStar(n(2490),t),s.__exportStar(n(3646),t),s.__exportStar(n(3558),t),s.__exportStar(n(4788),t),s.__exportStar(n(521),t),s.__exportStar(n(6870),t)},3646:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},9509:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharedUdpSocketImpl=void 0;const s=n(7582).__importDefault(n(6729)),i=n(2068);class o extends s.default{#J;#M;#n;get handleId(){return this.boundState?.handleId}get portNumber(){return this.boundState?.portNumber}get boundState(){return this.#h&&"object"==typeof this.#h?this.#h:void 0}#h="pending";constructor(e,t,n){super(),this.#J=e,this.#M=t,this.#n={...n}}bind(e,t,n){if(this.#h&&"object"==typeof this.#h)throw new Error("Socket is already bound");switch(this.#h){case"fatalError":throw new Error("Socket has encountered fatal error");case"binding":throw new Error("Socket is already bound");case"closed":throw new Error("Socket is closing");case"pending":break;default:throw(0,i.assertNever)(this.#h),new Error("Invalid socket state")}this.#h="binding",n&&this.on("listening",n),this.#J.sendWithCb("sharedUdpSocketJoin",{family:this.#n.type,portNumber:e}).then((t=>{this.#h={portNumber:e,handleId:t},this.#M.set(t,this),this.emit("listening")}),(e=>{this.#h="closed",this.emit("error",e instanceof Error?e:new Error(e))})).catch((()=>null))}close(e){if(this.#h&&"object"==typeof this.#h);else switch(this.#h){case"fatalError":throw new Error("Socket has encountered fatal error");case"pending":case"closed":case"binding":throw new Error("Socket is not open");default:throw(0,i.assertNever)(this.#h),new Error("Invalid socket state")}const t=this.#h.handleId;this.#h="closed",e&&this.on("close",e),this.#J.sendWithCb("sharedUdpSocketLeave",{handleId:t}).then((()=>{this.#M.delete(t),this.emit("close")}),(e=>{this.#M.delete(t),this.emit("error",e instanceof Error?e:new Error(e))})).catch((()=>null))}send(e,t,n,s,i,o){if("number"!=typeof t)throw new Error("Invalid arguments");if("number"==typeof n){if("number"!=typeof s||"string"!=typeof i)throw new Error("Invalid arguments");if(void 0!==o&&"number"!=typeof o)throw new Error("Invalid arguments");const r=this.#D(e,t,n);this.#q(r,s,i,o)}else{if("string"!=typeof n)throw new Error("Invalid arguments");{if(void 0!==s&&"function"!=typeof s)throw new Error("Invalid arguments");const i=this.#D(e,0,void 0);this.#q(i,t,n,s)}}}#D(e,t,n){let s;if("string"==typeof e)s=Buffer.from(e,"utf-8");else if(Buffer.isBuffer(e))s=e;else{if(Array.isArray(e))return Buffer.from(e);s=Buffer.from(e.buffer,e.byteOffset,e.byteLength)}return s.subarray(t,void 0!==n?n+t:void 0)}#q(e,t,n,s){if(!this.#h||"object"!=typeof this.#h)throw new Error("Socket is not open");this.#J.sendWithCb("sharedUdpSocketSend",{handleId:this.#h.handleId,message:e,address:n,port:t}).then((()=>{s?.()}),(e=>{this.emit("error",e instanceof Error?e:new Error(e))})).catch((()=>null))}receiveSocketMessage(e){try{this.emit("message",e.message,e.source)}catch(e){}}receiveSocketError(e){this.#h="fatalError";const t=this.boundState;t&&this.#M.delete(t.handleId);try{this.emit("error",e)}catch(e){}}}t.SharedUdpSocketImpl=o},4788:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},521:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateUseBuiltinInvertForFeedbacksUpgradeScript=t.CreateConvertToBooleanFeedbackUpgradeScript=t.EmptyUpgradeScript=void 0,t.EmptyUpgradeScript=()=>({updatedConfig:null,updatedActions:[],updatedFeedbacks:[]}),t.CreateConvertToBooleanFeedbackUpgradeScript=function(e){return(t,n)=>{const s=[];for(const t of n.feedbacks){let n=e[t.feedbackId];if(!0===n&&(n={bg:"bgcolor",bgcolor:"bgcolor",fg:"color",color:"color",png64:"png64",png:"png64"}),n){t.style||(t.style={});for(const[e,i]of Object.entries(n))void 0!==t.options[e]&&(t.style[i]=t.options[e],delete t.options[e],s.push(t))}}return{updatedConfig:null,updatedActions:[],updatedFeedbacks:s}}},t.CreateUseBuiltinInvertForFeedbacksUpgradeScript=function(e){return(t,n)=>{const s=[];for(const t of n.feedbacks){const n=e[t.feedbackId];if("string"!=typeof n)continue;const i=t.options[n];void 0!==i&&(delete t.options[n],t.isInverted="true"===i||!0===i||Number(i)>0,s.push(t))}return{updatedConfig:null,updatedActions:[],updatedFeedbacks:s}}}},6870:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2068:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitHex=t.splitHsv=t.splitHsl=t.splitRgb=t.combineRgb=t.assertNever=t.literal=void 0;const s=n(6872);function i(e){if("number"==typeof e)return e>16777215?{r:e>>16&255,g:e>>8&255,b:255&e,a:(255-(e>>24&255))/255}:{r:e>>16&255,g:e>>8&255,b:255&e,a:1};if("string"==typeof e&&(0,s.colord)(e).isValid()){const t=(0,s.colord)(e).toRgb();return{r:t.r,g:t.g,b:t.b,a:t.a}}return{r:0,g:0,b:0,a:1}}t.literal=function(e){return e},t.assertNever=function(e){},t.combineRgb=function(e,t,n,s){let i=(255&e)<<16|(255&t)<<8|255&n;return s&&s>=0&&s<1&&(i+=16777216*Math.round(255*(1-s))),i},t.splitRgb=i,t.splitHsl=function(e){const t=i(e);return(0,s.colord)(`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a})`).toHsl()},t.splitHsv=function(e){const t=i(e);return(0,s.colord)(`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a})`).toHsv()},t.splitHex=function(e){const t=i(e);return(0,s.colord)(`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a})`).toHex()}},4618:(e,t,n)=>{"use strict";e.exports=a,e.exports.default=a;const s={$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"ModuleManifest",properties:{$schema:{type:"string"},id:{type:"string",description:"Unique identifier for the module"},name:{type:"string",description:"Name of the module"},shortname:{type:"string"},description:{type:"string",description:"Description of the module "},version:{type:"string",description:"Current version of the module"},license:{type:"string",description:"SPDX identifier for license of the module"},repository:{type:"string",description:"URL to the source repository"},bugs:{type:"string",description:"URL to bug tracker"},maintainers:{type:"array",description:"List of active maintiners",uniqueItems:!0,items:{type:"object",title:"ModuleManifestMaintainer",properties:{name:{type:"string"},email:{type:"string"},github:{type:"string"}},required:["name"]}},legacyIds:{type:"array",description:"If the module had a different unique identifier previously, then specify it here",uniqueItems:!0,items:{type:"string"}},runtime:{type:"object",title:"ModuleManifestRuntime",description:"Information on how to execute the module",properties:{type:{type:"string",description:"Type of the module. Must be: node18"},api:{type:"string",description:"Which host-api does it use. In the future alternate options will be allowed",enum:["nodejs-ipc"]},apiVersion:{type:"string",description:"The version of the host-api used"},entrypoint:{type:"string",description:"Entrypoint to pass to the runtime. eg index.js"}},required:["type","api","apiVersion","entrypoint"]},manufacturer:{type:"string"},products:{type:"array",uniqueItems:!0,items:{type:"string"}},keywords:{type:"array",uniqueItems:!0,items:{type:"string"}},bonjourQueries:{type:"object",description:"If the device or software for your module supports bonjour announcements, Companion will offer an easy way to watch for these announcements.\nEach query you define must have a matching config field of type 'bonjour-device' with the same name",patternProperties:{"":{type:"object",title:"ModuleBonjourQuery",description:"",properties:{type:{type:"string"},protocol:{type:"string",enum:["tcp","udp"]},txt:{type:"object",description:"Match on any txt values returned in the query. This is useful to filter out devices of the same 'type' that are not supported",patternProperties:{"":{type:"string"}},additionalProperties:!1}},required:["type","protocol"],additionalProperties:!1}},additionalProperties:!1}},additionalProperties:!1,required:["id","name","shortname","description","version","license","repository","bugs","maintainers","legacyIds","runtime","manufacturer","products","keywords"]},i=Object.prototype.hasOwnProperty,o=n(7056).Z,r=new RegExp("","u");function a(e,{instancePath:t="",parentData:n,parentDataProperty:c,rootData:g=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return a.errors=[{instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let n;if(void 0===e.id&&(n="id")||void 0===e.name&&(n="name")||void 0===e.shortname&&(n="shortname")||void 0===e.description&&(n="description")||void 0===e.version&&(n="version")||void 0===e.license&&(n="license")||void 0===e.repository&&(n="repository")||void 0===e.bugs&&(n="bugs")||void 0===e.maintainers&&(n="maintainers")||void 0===e.legacyIds&&(n="legacyIds")||void 0===e.runtime&&(n="runtime")||void 0===e.manufacturer&&(n="manufacturer")||void 0===e.products&&(n="products")||void 0===e.keywords&&(n="keywords"))return a.errors=[{instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:n},message:"must have required property '"+n+"'"}],!1;{const n=0;for(const n in e)if(!i.call(s.properties,n))return a.errors=[{instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:n},message:"must NOT have additional properties"}],!1;if(0===n){if(void 0!==e.$schema){const n=0;if("string"!=typeof e.$schema)return a.errors=[{instancePath:t+"/$schema",schemaPath:"#/properties/%24schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=0===n}else l=!0;if(l){if(void 0!==e.id){const n=0;if("string"!=typeof e.id)return a.errors=[{instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.name){const n=0;if("string"!=typeof e.name)return a.errors=[{instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.shortname){const n=0;if("string"!=typeof e.shortname)return a.errors=[{instancePath:t+"/shortname",schemaPath:"#/properties/shortname/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.description){const n=0;if("string"!=typeof e.description)return a.errors=[{instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.version){const n=0;if("string"!=typeof e.version)return a.errors=[{instancePath:t+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.license){const n=0;if("string"!=typeof e.license)return a.errors=[{instancePath:t+"/license",schemaPath:"#/properties/license/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.repository){const n=0;if("string"!=typeof e.repository)return a.errors=[{instancePath:t+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.bugs){const n=0;if("string"!=typeof e.bugs)return a.errors=[{instancePath:t+"/bugs",schemaPath:"#/properties/bugs/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.maintainers){let n=e.maintainers;const s=0;if(0===s){if(!Array.isArray(n))return a.errors=[{instancePath:t+"/maintainers",schemaPath:"#/properties/maintainers/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var d=!0;const e=n.length;for(let s=0;s1)for(;s--;)for(e=s;e--;)if(o(n[s],n[e]))return a.errors=[{instancePath:t+"/maintainers",schemaPath:"#/properties/maintainers/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1}}}l=0===s}else l=!0;if(l){if(void 0!==e.legacyIds){let n=e.legacyIds;const s=0;if(0===s){if(!Array.isArray(n))return a.errors=[{instancePath:t+"/legacyIds",schemaPath:"#/properties/legacyIds/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var u=!0;const e=n.length;for(let s=0;s1){const i={};for(;s--;){let o=n[s];if("string"==typeof o){if("number"==typeof i[o])return e=i[o],a.errors=[{instancePath:t+"/legacyIds",schemaPath:"#/properties/legacyIds/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;i[o]=s}}}}}}l=0===s}else l=!0;if(l){if(void 0!==e.runtime){let n=e.runtime;const i=0;if(0===i){if(!n||"object"!=typeof n||Array.isArray(n))return a.errors=[{instancePath:t+"/runtime",schemaPath:"#/properties/runtime/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let e;if(void 0===n.type&&(e="type")||void 0===n.api&&(e="api")||void 0===n.apiVersion&&(e="apiVersion")||void 0===n.entrypoint&&(e="entrypoint"))return a.errors=[{instancePath:t+"/runtime",schemaPath:"#/properties/runtime/required",keyword:"required",params:{missingProperty:e},message:"must have required property '"+e+"'"}],!1;if(void 0!==n.type){const e=0;if("string"!=typeof n.type)return a.errors=[{instancePath:t+"/runtime/type",schemaPath:"#/properties/runtime/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=0===e}else p=!0;if(p){if(void 0!==n.api){let e=n.api;const i=0;if("string"!=typeof e)return a.errors=[{instancePath:t+"/runtime/api",schemaPath:"#/properties/runtime/properties/api/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if("nodejs-ipc"!==e)return a.errors=[{instancePath:t+"/runtime/api",schemaPath:"#/properties/runtime/properties/api/enum",keyword:"enum",params:{allowedValues:s.properties.runtime.properties.api.enum},message:"must be equal to one of the allowed values"}],!1;p=0===i}else p=!0;if(p){if(void 0!==n.apiVersion){const e=0;if("string"!=typeof n.apiVersion)return a.errors=[{instancePath:t+"/runtime/apiVersion",schemaPath:"#/properties/runtime/properties/apiVersion/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;p=0===e}else p=!0;if(p)if(void 0!==n.entrypoint){const e=0;if("string"!=typeof n.entrypoint)return a.errors=[{instancePath:t+"/runtime/entrypoint",schemaPath:"#/properties/runtime/properties/entrypoint/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;p=0===e}else p=!0}}}}l=0===i}else l=!0;if(l){if(void 0!==e.manufacturer){const n=0;if("string"!=typeof e.manufacturer)return a.errors=[{instancePath:t+"/manufacturer",schemaPath:"#/properties/manufacturer/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;l=0===n}else l=!0;if(l){if(void 0!==e.products){let n=e.products;const s=0;if(0===s){if(!Array.isArray(n))return a.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var h=!0;const e=n.length;for(let s=0;s1){const i={};for(;s--;){let o=n[s];if("string"==typeof o){if("number"==typeof i[o])return e=i[o],a.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;i[o]=s}}}}}}l=0===s}else l=!0;if(l){if(void 0!==e.keywords){let n=e.keywords;const s=0;if(0===s){if(!Array.isArray(n))return a.errors=[{instancePath:t+"/keywords",schemaPath:"#/properties/keywords/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var b=!0;const e=n.length;for(let s=0;s1){const i={};for(;s--;){let o=n[s];if("string"==typeof o){if("number"==typeof i[o])return e=i[o],a.errors=[{instancePath:t+"/keywords",schemaPath:"#/properties/keywords/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;i[o]=s}}}}}}l=0===s}else l=!0;if(l)if(void 0!==e.bonjourQueries){let n=e.bonjourQueries;const i=0;if(0===i){if(!n||"object"!=typeof n||Array.isArray(n))return a.errors=[{instancePath:t+"/bonjourQueries",schemaPath:"#/properties/bonjourQueries/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{const e=0;for(const e in n)if(!r.test(e))return a.errors=[{instancePath:t+"/bonjourQueries",schemaPath:"#/properties/bonjourQueries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:e},message:"must NOT have additional properties"}],!1;if(0===e)for(const e in n)if(r.test(e)){let i=n[e];const o=0;if(0===o){if(!i||"object"!=typeof i||Array.isArray(i))return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/bonjourQueries/patternProperties//type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let n;if(void 0===i.type&&(n="type")||void 0===i.protocol&&(n="protocol"))return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/bonjourQueries/patternProperties//required",keyword:"required",params:{missingProperty:n},message:"must have required property '"+n+"'"}],!1;{const n=0;for(const n in i)if("type"!==n&&"protocol"!==n&&"txt"!==n)return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/bonjourQueries/patternProperties//additionalProperties",keyword:"additionalProperties",params:{additionalProperty:n},message:"must NOT have additional properties"}],!1;if(0===n){if(void 0!==i.type){const n=0;if("string"!=typeof i.type)return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/type",schemaPath:"#/properties/bonjourQueries/patternProperties//properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var C=0===n}else C=!0;if(C){if(void 0!==i.protocol){let n=i.protocol;const o=0;if("string"!=typeof n)return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/protocol",schemaPath:"#/properties/bonjourQueries/patternProperties//properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if("tcp"!==n&&"udp"!==n)return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/protocol",schemaPath:"#/properties/bonjourQueries/patternProperties//properties/protocol/enum",keyword:"enum",params:{allowedValues:s.properties.bonjourQueries.patternProperties[""].properties.protocol.enum},message:"must be equal to one of the allowed values"}],!1;C=0===o}else C=!0;if(C)if(void 0!==i.txt){let n=i.txt;const s=0;if(0===s){if(!n||"object"!=typeof n||Array.isArray(n))return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/txt",schemaPath:"#/properties/bonjourQueries/patternProperties//properties/txt/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{const s=0;for(const s in n)if(!r.test(s))return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/txt",schemaPath:"#/properties/bonjourQueries/patternProperties//properties/txt/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:s},message:"must NOT have additional properties"}],!1;if(0===s)for(const s in n)if(r.test(s)){const i=0;if("string"!=typeof n[s])return a.errors=[{instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/txt/"+s.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/bonjourQueries/patternProperties//properties/txt/patternProperties//type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(0!==i)break}}}C=0===s}else C=!0}}}}}if(0!==o)break}}}l=0===i}else l=!0}}}}}}}}}}}}}}}}}return a.errors=null,!0}},3453:(e,t,n)=>{"use strict";const s=n(4341);e.exports=(e,t={})=>{if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:n=0,maxWait:i=0,before:o=!1,after:r=!0}=t;if(!o&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,c,g;const l=function(...t){const s=this,l=o&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,c&&(clearTimeout(c),c=void 0),r&&(g=e.apply(s,t))}),n),i>0&&!c&&r&&(c=setTimeout((()=>{c=void 0,a&&(clearTimeout(a),a=void 0),g=e.apply(s,t)}),i)),l&&(g=e.apply(s,t)),g};return s(l,e),l.cancel=()=>{a&&(clearTimeout(a),a=void 0),c&&(clearTimeout(c),c=void 0)},l}},7582:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__addDisposableResource:()=>w,__assign:()=>o,__asyncDelegator:()=>f,__asyncGenerator:()=>W,__asyncValues:()=>V,__await:()=>A,__awaiter:()=>p,__classPrivateFieldGet:()=>Y,__classPrivateFieldIn:()=>N,__classPrivateFieldSet:()=>H,__createBinding:()=>b,__decorate:()=>a,__disposeResources:()=>K,__esDecorate:()=>g,__exportStar:()=>C,__extends:()=>i,__generator:()=>h,__importDefault:()=>X,__importStar:()=>S,__makeTemplateObject:()=>v,__metadata:()=>u,__param:()=>c,__propKey:()=>d,__read:()=>Z,__rest:()=>r,__runInitializers:()=>l,__setFunctionName:()=>I,__spread:()=>G,__spreadArray:()=>B,__spreadArrays:()=>y,__values:()=>m,default:()=>_});var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},s(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){return o=Object.assign||function(e){for(var t,n=1,s=arguments.length;n=0;a--)(i=e[a])&&(r=(o<3?i(r):o>3?i(t,n,r):i(t,n))||r);return o>3&&r&&Object.defineProperty(t,n,r),r}function c(e,t){return function(n,s){t(n,s,e)}}function g(e,t,n,s,i,o){function r(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,c=s.kind,g="getter"===c?"get":"setter"===c?"set":"value",l=!t&&e?s.static?e:e.prototype:null,d=t||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),I=!1,u=n.length-1;u>=0;u--){var p={};for(var h in s)p[h]="access"===h?{}:s[h];for(var h in s.access)p.access[h]=s.access[h];p.addInitializer=function(e){if(I)throw new TypeError("Cannot add initializers after decoration has completed");o.push(r(e||null))};var b=(0,n[u])("accessor"===c?{get:d.get,set:d.set}:d[g],p);if("accessor"===c){if(void 0===b)continue;if(null===b||"object"!=typeof b)throw new TypeError("Object expected");(a=r(b.get))&&(d.get=a),(a=r(b.set))&&(d.set=a),(a=r(b.init))&&i.unshift(a)}else(a=r(b))&&("field"===c?i.unshift(a):d[g]=a)}l&&Object.defineProperty(l,s.name,d),I=!0}function l(e,t,n){for(var s=arguments.length>2,i=0;i0&&i[i.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Z(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var s,i,o=n.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(s=o.next()).done;)r.push(s.value)}catch(e){i={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return r}function G(){for(var e=[],t=0;t1||a(e,t)}))})}function a(e,t){try{(n=i[e](t)).value instanceof A?Promise.resolve(n.value.v).then(c,g):l(o[0][2],n)}catch(e){l(o[0][3],e)}var n}function c(e){a("next",e)}function g(e){a("throw",e)}function l(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function f(e){var t,n;return t={},s("next"),s("throw",(function(e){throw e})),s("return"),t[Symbol.iterator]=function(){return this},t;function s(s,i){t[s]=e[s]?function(t){return(n=!n)?{value:A(e[s](t)),done:!1}:i?i(t):t}:i}}function V(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=m(e),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(n){t[n]=e[n]&&function(t){return new Promise((function(s,i){!function(e,t,n,s){Promise.resolve(s).then((function(t){e({value:t,done:n})}),t)}(s,i,(t=e[n](t)).done,t.value)}))}}}function v(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var R=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function S(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&b(t,e,n);return R(t,e),t}function X(e){return e&&e.__esModule?e:{default:e}}function Y(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function H(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}function N(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function w(e,t,n){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(void 0===s){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose]}if("function"!=typeof s)throw new TypeError("Object not disposable.");e.stack.push({value:t,dispose:s,async:n})}else n&&e.stack.push({async:!0});return t}var k="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var s=new Error(n);return s.name="SuppressedError",s.error=e,s.suppressed=t,s};function K(e){function t(t){e.error=e.hasError?new k(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function n(){for(;e.stack.length;){var s=e.stack.pop();try{var i=s.dispose&&s.dispose.call(s.value);if(s.async)return Promise.resolve(i).then(n,(function(e){return t(e),n()}))}catch(e){t(e)}}if(e.hasError)throw e.error}()}const _={__extends:i,__assign:o,__rest:r,__decorate:a,__param:c,__metadata:u,__awaiter:p,__generator:h,__createBinding:b,__exportStar:C,__values:m,__read:Z,__spread:G,__spreadArrays:y,__spreadArray:B,__await:A,__asyncGenerator:W,__asyncDelegator:f,__asyncValues:V,__makeTemplateObject:v,__importStar:S,__importDefault:X,__classPrivateFieldGet:Y,__classPrivateFieldSet:H,__classPrivateFieldIn:N,__addDisposableResource:w,__disposeResources:K}}},t={};function n(s){var i=t[s];if(void 0!==i)return i.exports;var o=t[s]={id:s,loaded:!1,exports:{}};return e[s].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.c=t,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(n.s=5590)})(); \ No newline at end of file +(()=>{var e={2351:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertParamOptionsToChoices=t.getParameterTopic=void 0;const s=r(6787),n=r(8621),o=r(4339),i=r(6807);t.getParameterTopic=(e,t)=>`${e}/${t}`;const a="default_option",p={id:a,label:"Select an option..."};t.convertParamOptionsToChoices=e=>0===e.length?[p]:["string","number"].includes(typeof e[0])?[p,...e.map((e=>{const t="string"==typeof e?e:e.toString();return{id:t,label:t}}))]:[p,...e.map((e=>{const t=e;return{id:void 0===t.id?"undefined":t.id,label:t.value}}))];const d=(e,r,n)=>{var o,i;switch((0,s.commandParameterTypeToInputType)(e.type)){case"number":{const t=e.range?`${e.prettyName} (min ${e.range.min}, max ${e.range.max})`:e.prettyName;return{type:"number",id:e.id,label:t,default:"number"==typeof e.defaultValue?e.defaultValue:0,min:(null===(o=e.range)||void 0===o?void 0:o.min)||0,max:(null===(i=e.range)||void 0===i?void 0:i.max)||0}}case"textinput":return{type:"textinput",id:e.id,label:e.prettyName,default:"string"==typeof e.defaultValue?e.defaultValue:void 0};case"checkbox":return{type:"checkbox",id:e.id,label:e.prettyName,default:"boolean"==typeof e.defaultValue&&e.defaultValue};case"dropdown":{const s=((e,r,s)=>{if("select"===e.type&&e.values)return(0,t.convertParamOptionsToChoices)(e.values);const n=(0,t.getParameterTopic)(r,e.id);return void 0!==s[n]?(0,t.convertParamOptionsToChoices)(s[n]):[{id:0,label:"No options available."}]})(e,r.requestType,n.options);return{type:"dropdown",id:e.id,label:`${e.prettyName}${"required"===e.property?" (required)":""}`,choices:s,default:a}}}},c=(e,t)=>(r,s)=>{var n;const o={"request-type":e.requestType};let i=!1;null===(n=null==e?void 0:e.requestParams)||void 0===n||n.forEach((e=>{const{id:s,type:n,property:p,defaultValue:d}=e;if("boolean"===n&&"controllerValue"!==s){if(!["controllable","required"].includes(p))return;const e=!t.actionsState[r.controlId].value;return void(o[s]=e)}let c=r.options[s];if(void 0===c){if("required"!==p)return;d&&(c=d)}c!==a?o[s]=c:"required"===p&&(i=!0)})),i?t.log("error",`Executing ${e.requestType}: command aborted because not all required parameters are set.`):t.sendRequest(o)};t.default=e=>{const t={},{apiDefinition:r}=e;if(!r)return t;for(const[p,u]of Object.entries(r)){if(o.GROUPS_TO_SKIP.includes(p))continue;const r={name:(0,s.transformDotCaseToTitleCase)(p),id:p,requests:u};r.requests.forEach((p=>{if(""===p.pretty_name)return;const{requestType:u,requestParams:l,hidden:m}=p;if(m)return;if((0,s.getRequestMethod)(u)!==o.RequestMethod.SET)return;let y=!1,f=!1;const h=[];null==l||l.forEach((t=>{var r,s;const{type:n,property:o,id:i}=t;if(["controllable","required"].includes(o)){if("number"===n)return void(f=!0);if("boolean"===n)return void(y=!0)}t.property.includes("hidden")||"controllable"===t.property||("controllerMode"===i&&(t.prettyName="Mode",y&&t.values&&"string"==typeof t.values[0]&&(t.values=null===(r=t.values)||void 0===r?void 0:r.filter((e=>"relative"!==e)).map((e=>({id:e,value:"default"===e?"toggle":e})))),f&&t.values&&"string"==typeof t.values[0]&&(t.values=null===(s=t.values)||void 0===s?void 0:s.filter((e=>"default"!==e)))),"controllerValue"===i&&(t.prettyName="Value"),h.push(d(t,p,e)))}));const _=`${u.substring(0,u.length-3)}get`,b=r.requests.find((e=>e.requestType===_)),g={name:`${r.name}: ${p.pretty_name}`,options:h,callback:c(p,e),subscribe:t=>{var r;null===(r=null==p?void 0:p.requestParams)||void 0===r||r.forEach((r=>{var s;if("boolean"===r.type&&["controllable","required"].includes(r.property)){if(!b)return void e.log("error",`Request ${p.requestType} has boolean controllable param, but no get request.`);e.actionsState[t.controlId]={requestType:p.requestType,paramId:r.id,value:a,paramValues:t.options};const n={"request-type":b.requestType};let o=!0;null===(s=p.requestParams)||void 0===s||s.forEach((e=>{const r=t.options[e.id];r===a&&(o=!1),n[e.id]=r})),o&&e.sendValueRequest(n,t.controlId,r.id,i.CompanionControlType.ACTION),e.addListenedUpdate(p.requestType,t.controlId)}n.COMMAND_PARMS_TYPES_WITHOUT_OPTIONS_TO_GET.includes(r.type)||e.getOptions(u,r.id)}))},unsubscribe:t=>{e.removeListenedUpdate(t.controlId),e.removeListenedUpdate(t.controlId),delete e.actionsState[t.controlId]}};t[p.requestType]=g}))}return t}},1610:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getConfigFields=void 0;const s=r(8049);t.getConfigFields=()=>[{type:"static-text",id:"info",width:12,label:"Studio Controller",value:"This module connects to the Studio Controller app. Launch it and connect to the producer in order to control it using your Stream Deck."},{type:"textinput",id:"ip",label:"Studio Controller IP address",width:8,default:"127.0.0.1",regex:s.Regex.IP},{type:"number",id:"port",label:"Studio Controller port",width:4,default:5656,min:1,max:65535,step:1}]},1658:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Feedback=t.Color=void 0;const s=r(8049),n=r(2351),o=r(8621),i=r(4339),a=r(6787),p=r(6807),d="default_option";var c,u;!function(e){e[e.WHITE=(0,s.combineRgb)(255,255,255)]="WHITE",e[e.BLACK=(0,s.combineRgb)(0,0,0)]="BLACK",e[e.GREEN=(0,s.combineRgb)(0,255,0)]="GREEN",e[e.RED=(0,s.combineRgb)(255,0,0)]="RED",e[e.PURPLE=(0,s.combineRgb)(204,0,204)]="PURPLE"}(c||(t.Color=c={})),function(e){e.MONITORED_AUDIO="PlayAudio/channel",e.DIRECT_EDIT_SCENE="SetDirectEditScene/active",e.DIRECT_EDIT_LAYER="SetDirectEditLayer/active",e.PROGRAM_SCENE_INDEX="ProgramSceneIndex/active",e.PREVIEW_SCENE_INDEX="PreviewSceneIndex/active",e.PROGRAM_SCENE_NAME="ProgramSceneName/active",e.PREVIEW_SCENE_NAME="PreviewSceneName/active",e.REPLAYS_PLAYBACK_SPEED_PREDEFINED="ReplaysPlaybackSpeedPredefined",e.REPLAYS_PLAYBACK_SPEED="ReplaysPlaybackSpeed",e.REPLAYS_SELECTED_SLOT="ReplaysSelectedSlot",e.AUDIO_OUTPUT_MUTED="AudioOutputMuted"}(u||(t.Feedback=u={}));const l=(e,t,r)=>{var s,o;switch((0,a.commandParameterTypeToInputType)(e.type)){case"number":{const t=e.range?`${e.prettyName} (min ${e.range.min}, max ${e.range.max})`:e.prettyName;return{type:"number",id:e.id,label:t,default:"number"==typeof e.defaultValue?e.defaultValue:0,min:(null===(s=e.range)||void 0===s?void 0:s.min)||0,max:(null===(o=e.range)||void 0===o?void 0:o.max)||0}}case"textinput":return{type:"textinput",id:e.id,label:e.prettyName,default:"string"==typeof e.defaultValue?e.defaultValue:void 0};case"checkbox":return{type:"checkbox",id:e.id,label:e.prettyName,default:"boolean"==typeof e.defaultValue&&e.defaultValue};case"dropdown":{const s=((e,t,r)=>{if("select"===e.type&&e.values)return(0,n.convertParamOptionsToChoices)(e.values);const s=(0,n.getParameterTopic)(t,e.id);return void 0!==r[s]?(0,n.convertParamOptionsToChoices)(r[s]):[{id:0,label:"No options available."}]})(e,t.requestType,r.options);return{type:"dropdown",id:e.id,label:`${e.prettyName}${"required"===e.property?" (required)":""}`,choices:s,default:d}}}},m=(e,t,r)=>s=>{const n=e.feedbacksState[s.controlId].value;return"boolean"==typeof n?n:n!==d&&(r?n===s.options[r]:(e.log("error",`Request ${t} - no value for controlled param.`),!1))};t.default=e=>{const t={},{apiDefinition:r}=e;if(!r)return t;for(const[s,n]of Object.entries(r)){if(i.GROUPS_TO_SKIP.includes(s))continue;const r={name:(0,a.transformDotCaseToTitleCase)(s),id:s,requests:n};r.requests.forEach((s=>{if(""===s.pretty_name)return;const{requestType:n,requestParams:u,hidden:y,responseParams:f}=s;if(y)return;if((0,a.getRequestMethod)(n)!==i.RequestMethod.GET)return;const h=[];let _;null==u||u.forEach((t=>{h.push(l(t,s,e))})),null==f||f.forEach((t=>{const{property:r,type:n,id:o}=t;if(["controllable","required"].includes(r)){if("boolean"===n)return;h.push(l(t,s,e)),_=o}}));const b=`${n.substring(0,n.length-3)}set`,g={name:`${r.name}: ${s.pretty_name}`,options:h,type:"boolean",defaultStyle:{bgcolor:c.RED,color:c.BLACK},callback:m(e,n,_),subscribe:t=>{var r;null===(r=null==s?void 0:s.responseParams)||void 0===r||r.forEach((r=>{var n;if(["controllable","required"].includes(r.property)){e.feedbacksState[t.controlId]={requestType:b,paramId:r.id,value:d,paramValues:t.options,companionInstanceId:t.id,requestParamsIds:u?null==u?void 0:u.map((e=>e.id)):[]};const o={"request-type":s.requestType};let i=!0;null===(n=s.requestParams)||void 0===n||n.forEach((e=>{const r=t.options[e.id];r===d&&(i=!1),o[e.id]=r})),i&&e.sendValueRequest(o,t.controlId,r.id,p.CompanionControlType.FEEDBACK),e.addListenedUpdate(b,t.controlId)}})),null==u||u.forEach((t=>{o.COMMAND_PARMS_TYPES_WITHOUT_OPTIONS_TO_GET.includes(t.type)||e.getOptions(n,t.id)}))},unsubscribe:t=>{e.removeListenedUpdate(t.controlId),e.removeListenedUpdate(t.controlId),delete e.feedbacksState[t.controlId]}};t[s.requestType]=g}))}return t}},5590:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const a=r(8049),p=r(1610),d=o(r(2351)),c=i(r(1658)),u=r(9671),l=r(6807),m=r(5955),y=i(r(5721));class f extends a.InstanceBase{constructor(e){super(e),this.options={},this.apiDefinition=null,this.activeRequests=0,this.listenedUpdates={},this.config={ip:"",port:0},this.reconnectTimeout=null,this.actionsState={},this.feedbacksState={},this.onConnection=()=>{this.log("debug","Connected."),this.updateStatus(a.InstanceStatus.Ok),this.refreshAll(),this.subscribeActions(),this.subscribeFeedbacks()},this.refreshAll=()=>{this.updateActions(),this.updateFeedbacks(),this.checkFeedbacks(),(0,u.generatePresets)()},this.connectToWsServer=async()=>{this.updateStatus(a.InstanceStatus.Connecting);const{ip:e,port:t}=this.config;return this.log("debug",`Connecting to ${e} at port ${t}.`),this.client.connect(`ws://${e}:${t}`)},this.startReconnecting=async()=>{this.reconnectTimeout=setTimeout((async()=>{this.log("debug","Reconnecting..."),this.updateStatus(a.InstanceStatus.Disconnected,"Trying to reconnect");try{await this.connectToWsServer()}catch(e){return void this.log("error",JSON.stringify(e))}}),2e3)},this.stopReconnecting=()=>{null!==this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null)},this.handleUpdate=e=>{const t=e["update-type"];this.log("debug",`Got update: ${JSON.stringify(e)}`);const r=new Set;Object.values(this.actionsState).forEach((r=>{t===r.requestType&&Object.entries(r.paramValues).every((t=>{const[r,s]=t;return!!["controllerValue","controllerMode"].includes(r)||e[r]===s}))&&(r.value=e[r.paramId])})),Object.values(this.feedbacksState).forEach((s=>{const n=`${s.requestType.substring(0,s.requestType.length-3)}set`;t===n&&s.requestParamsIds.every((t=>e[t]===s.paramValues[t]))&&(s.value=e[s.paramId],r.add(s.companionInstanceId))})),this.log("debug",`Updating feedbacks: ${JSON.stringify(Array.from(r))}`),this.checkFeedbacksById(...Array.from(r))},this.addListenedUpdate=(e,t)=>{Object.values(this.listenedUpdates).includes(e)||(this.log("debug",`Subscribing notification: ${e}`),this.client.on(e,this.handleUpdate)),this.listenedUpdates[t]=e},this.removeListenedUpdate=e=>{const t=this.listenedUpdates[e];delete this.listenedUpdates[e],Object.values(this.listenedUpdates).some((e=>e===t))||this.client.off(t,this.handleUpdate)},this.removeAllUpdateListeners=()=>{Object.keys(this.listenedUpdates).forEach(this.removeListenedUpdate)},this.sendValueRequest=(e,t,r,s)=>{this.activeRequests++,this.log("debug",`Sending value request: ${JSON.stringify(e)}`),this.client.send(e).then((e=>{this.log("debug",`Got value request response: ${JSON.stringify(e)}`);const n=e[r];s===l.CompanionControlType.ACTION&&(this.actionsState[t].value=n),s===l.CompanionControlType.FEEDBACK&&(this.feedbacksState[t].value=n)})).catch((e=>{this.log("error",JSON.stringify(e))})).finally((()=>{this.activeRequests--,0===this.activeRequests&&this.refreshAll()}))},this.getOptions=(e,t)=>{const r={"request-type":"commands.parameter.options.get",requestType:e,parameterName:t};this.log("debug",`Sending options request: ${JSON.stringify(r)}`),this.activeRequests++,this.client.send(r).then((r=>{this.log("debug",`Options response: ${JSON.stringify(r)}`);const s=r.options,n=(0,d.getParameterTopic)(e,t);this.options[n]=s})).catch((e=>{this.log("error",JSON.stringify(e))})).finally((()=>{this.activeRequests--,0===this.activeRequests&&this.refreshAll()}))},this.sendRequest=async e=>{this.log("debug",`Sending request: ${JSON.stringify(e)}`);try{await this.client.send(e)}catch(e){this.log("error",JSON.stringify(e))}},this.cancelUnnecessaryNotifications=()=>{},this.updateActions=()=>{this.setActionDefinitions((0,d.default)(this))},this.updateFeedbacks=()=>{this.setFeedbackDefinitions((0,c.default)(this))},this.client=new m.StreamStudioClient("companion-module")}async init(e){this.config=e,this.client.on("gateway-connection",this.onConnection),this.client.onws("closed",this.startReconnecting),this.client.onws("error",(e=>{this.log("error",JSON.stringify(e))}));try{this.apiDefinition=y.default}catch(e){return void this.updateStatus(a.InstanceStatus.ConnectionFailure)}try{await this.connectToWsServer()}catch(e){this.updateStatus(a.InstanceStatus.ConnectionFailure)}}async configUpdated(e){this.config=e,this.client.disconnect(),this.stopReconnecting(),e.ip&&e.port?this.connectToWsServer():this.updateStatus(a.InstanceStatus.BadConfig,"Missing Studio Controller IP and/or port.")}getConfigFields(){return(0,p.getConfigFields)()}async destroy(){this.log("debug","Destroying..."),this.stopReconnecting(),this.removeAllUpdateListeners(),this.client.disconnect(),this.options={},this.activeRequests=0,this.actionsState={},this.feedbacksState={}}}(0,a.runEntrypoint)(f,[]),e.exports=f},9671:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generatePresets=void 0;const s=r(1658);var n;!function(e){e.VIDEO_MIXER="Video Mixer",e.REPLAYS="Replays"}(n||(n={})),t.generatePresets=()=>{const e={};return Array.from(Array(8)).forEach(((t,r)=>{const o=r+1;e[`preview-scene-${o}`]={type:"button",category:n.VIDEO_MIXER,name:`Preview Scene ${o}`,style:{text:`PRV ${o}`,size:"auto",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"SetPreviewSceneByIndex",options:{sceneIndex:r}}],up:[]}],feedbacks:[{feedbackId:s.Feedback.PREVIEW_SCENE_INDEX,options:{"scene-index":r},style:{color:s.Color.BLACK,bgcolor:s.Color.GREEN}}]}})),Array.from(Array(8)).forEach(((t,r)=>{const o=r+1;e[`ProgramScene${o}`]={type:"button",category:n.VIDEO_MIXER,name:`Program Scene ${o}`,style:{text:`PGM ${o}`,size:"auto",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"SetCurrentSceneByIndex",options:{sceneIndex:r}}],up:[]}],feedbacks:[{feedbackId:s.Feedback.PROGRAM_SCENE_INDEX,options:{"scene-index":r},style:{color:s.Color.BLACK,bgcolor:s.Color.RED}}]}})),e.Cut={type:"button",category:n.VIDEO_MIXER,name:"Cut",style:{text:"Cut",size:"24",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"Cut",options:{}}],up:[]}],feedbacks:[]},e.Fade={type:"button",category:n.VIDEO_MIXER,name:"Fade",style:{text:"Fade",size:"24",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"TransitionToProgramCustom",options:{"with-transition.duration":500,"with-transition.name":"Fade"}}],up:[]}],feedbacks:[]},Array.from(Array(4)).forEach(((t,r)=>{const o=r+1;e[`SelectReplaysSlot${o}`]={type:"button",category:n.REPLAYS,name:`Replays Slot ${o}`,style:{text:`REPLAY ${o}`,size:"auto",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"replays.slot.select",options:{slot:r}}],up:[]}],feedbacks:[{feedbackId:s.Feedback.REPLAYS_SELECTED_SLOT,options:{slot:r},style:{color:s.Color.BLACK,bgcolor:s.Color.PURPLE}}]}})),[25,33,50,75,100].forEach((t=>{e[`ReplaysPlaybackSpeed${t}`]={type:"button",category:n.REPLAYS,name:`Replays Playback Speed ${t}%`,style:{text:`${t}%`,size:"auto",color:s.Color.WHITE,bgcolor:s.Color.BLACK},steps:[{down:[{actionId:"replays.slot.playback.speed",options:{speed_percent:t,slot:"all"}}],up:[]}],feedbacks:[{feedbackId:s.Feedback.REPLAYS_PLAYBACK_SPEED,options:{speed:t,slot:"all"},style:{color:s.Color.BLACK,bgcolor:s.Color.PURPLE}}]}})),e}},5955:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StreamStudioClient=void 0;const n=s(r(2361)),o=r(4493);function i(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}t.StreamStudioClient=class{constructor(e){this.clientName=e,this.events=new n.default,this.wsClient=new o.WsClient,this.connect=e=>this.wsClient.connect(e),this.disconnect=()=>this.wsClient.disconnect(),this.onws=(e,t)=>this.wsClient.on(e,t),this.offws=(e,t)=>this.wsClient.off(e,t),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.on(e,t)},this.send=async e=>{return this.wsClient.send({...e,"message-id":(t=this.clientName,`${t}_${i()}${i()}-${i()}-${i()}-${i()}-${i()}${i()}${i()}`)});var t},this.wsClient.on("message",(e=>{const t=e["update-type"];t&&this.events.emit(t,e)}))}get isConnected(){return this.wsClient.isConnected}get url(){return this.wsClient.url}}},4339:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.RequestMethod=t.GROUPS_TO_SKIP=void 0,t.GROUPS_TO_SKIP=["frontend"],function(e){e.GET="get",e.SET="set"}(r||(t.RequestMethod=r={}))},8621:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMAND_PARMS_TYPES_WITHOUT_OPTIONS_TO_GET=void 0,t.COMMAND_PARMS_TYPES_WITHOUT_OPTIONS_TO_GET=["boolean","string","number","select"]},6807:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.CompanionControlType=void 0,function(e){e.ACTION="ACTION",e.FEEDBACK="FEEDBACK"}(r||(t.CompanionControlType=r={}))},6787:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestMethod=t.getValueAtPath=t.setValueAtPath=t.trimText=t.generateMessageId=t.commandParameterTypeToInputType=t.transformDotCaseToTitleCase=void 0;const s=r(2600);t.transformDotCaseToTitleCase=e=>e.split(".").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" "),t.commandParameterTypeToInputType=e=>{switch(e){case"number":return"number";case"boolean":return"checkbox";case"string":return"textinput";default:return"dropdown"}},t.generateMessageId=()=>`COMPANION_MODULE_TELLYO_STREAMSTUDIO_${(0,s.v4)()}`,t.trimText=(e,t)=>e,t.setValueAtPath=(e,t,r)=>{const s=r.split(".");let n=e;for(let e=0;e{const r=t.split(".");let s=e;for(let e=0;e{const t=e.split(".");return t[t.length-1]}},4493:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WsClient=void 0;const n=r(2361),o=s(r(8777));t.WsClient=class{constructor(){this.connected=!1,this.idName="message-id",this.eventEmitter=new n.EventEmitter,this.eventEmitter.on("warning",(e=>this.emit("warning",e))),this.eventEmitter.setMaxListeners(200)}connect(e){return new Promise(((t,r)=>{this.wsUrl=e,this.ws=new o.default(this.wsUrl),this.ws.onopen=()=>{this.emit("connected",e),this.connected=!0,t()},this.ws.onerror=e=>{this.emit("error",e),r(e)},this.ws.onclose=e=>{this.emit("closed",e),this.connected=!1},this.ws.onmessage=e=>{const t=JSON.parse(e.data.toString());this.emit("message",t)}}))}disconnect(){return new Promise(((e,t)=>{this.ws&&(this.ws.onerror=e=>{t(e)},this.ws.onclose=t=>{e()},this.connected=!1,this.ws.close())}))}async send(e){return new Promise(((t,r)=>{if(this.ws||r(new Error("No ws client")),e[this.idName]){const s=n=>{n[this.idName]==e[this.idName]&&(this.off("message",s),"ok"==n.status?t(n):r(n))};this.on("message",s)}this.ws.send(JSON.stringify(e)),e[this.idName]||t(e)}))}get url(){return this.wsUrl}get isConnected(){return this.connected}emit(e,t){this.eventEmitter.emit(e,t)}on(e,t){this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}}},7056:(e,t,r)=>{"use strict";const s=r(4063);s.code='require("ajv/dist/runtime/equal").default',t.Z=s},6872:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r={grad:.9,turn:360,rad:360/(2*Math.PI)},s=function(e){return"string"==typeof e?e.length>0:"number"==typeof e},n=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=Math.pow(10,t)),Math.round(r*e)/r+0},o=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=1),e>r?r:e>t?e:t},i=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},a=function(e){return{r:o(e.r,0,255),g:o(e.g,0,255),b:o(e.b,0,255),a:o(e.a)}},p=function(e){return{r:n(e.r),g:n(e.g),b:n(e.b),a:n(e.a,3)}},d=/^#([0-9a-f]{3,8})$/i,c=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},u=function(e){var t=e.r,r=e.g,s=e.b,n=e.a,o=Math.max(t,r,s),i=o-Math.min(t,r,s),a=i?o===t?(r-s)/i:o===r?2+(s-t)/i:4+(t-r)/i:0;return{h:60*(a<0?a+6:a),s:o?i/o*100:0,v:o/255*100,a:n}},l=function(e){var t=e.h,r=e.s,s=e.v,n=e.a;t=t/360*6,r/=100,s/=100;var o=Math.floor(t),i=s*(1-r),a=s*(1-(t-o)*r),p=s*(1-(1-t+o)*r),d=o%6;return{r:255*[s,a,i,i,p,s][d],g:255*[p,s,s,a,i,i][d],b:255*[i,i,p,s,s,a][d],a:n}},m=function(e){return{h:i(e.h),s:o(e.s,0,100),l:o(e.l,0,100),a:o(e.a)}},y=function(e){return{h:n(e.h),s:n(e.s),l:n(e.l),a:n(e.a,3)}},f=function(e){return l((r=(t=e).s,{h:t.h,s:(r*=((s=t.l)<50?s:100-s)/100)>0?2*r/(s+r)*100:0,v:s+r,a:t.a}));var t,r,s},h=function(e){return{h:(t=u(e)).h,s:(n=(200-(r=t.s))*(s=t.v)/100)>0&&n<200?r*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,r,s,n},_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,b=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,g=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,q={string:[[function(e){var t=d.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?n(parseInt(e[3]+e[3],16)/255,2):1}:6===e.length||8===e.length?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:8===e.length?n(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=g.exec(e)||v.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=_.exec(e)||b.exec(e);if(!t)return null;var s,n,o=m({h:(s=t[1],n=t[2],void 0===n&&(n="deg"),Number(s)*(r[n]||1)),s:Number(t[3]),l:Number(t[4]),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return f(o)},"hsl"]],object:[[function(e){var t=e.r,r=e.g,n=e.b,o=e.a,i=void 0===o?1:o;return s(t)&&s(r)&&s(n)?a({r:Number(t),g:Number(r),b:Number(n),a:Number(i)}):null},"rgb"],[function(e){var t=e.h,r=e.s,n=e.l,o=e.a,i=void 0===o?1:o;if(!s(t)||!s(r)||!s(n))return null;var a=m({h:Number(t),s:Number(r),l:Number(n),a:Number(i)});return f(a)},"hsl"],[function(e){var t=e.h,r=e.s,n=e.v,a=e.a,p=void 0===a?1:a;if(!s(t)||!s(r)||!s(n))return null;var d=function(e){return{h:i(e.h),s:o(e.s,0,100),v:o(e.v,0,100),a:o(e.a)}}({h:Number(t),s:Number(r),v:Number(n),a:Number(p)});return l(d)},"hsv"]]},N=function(e,t){for(var r=0;r=.5},e.prototype.toHex=function(){return t=(e=p(this.rgba)).r,r=e.g,s=e.b,i=(o=e.a)<1?c(n(255*o)):"","#"+c(t)+c(r)+c(s)+i;var e,t,r,s,o,i},e.prototype.toRgb=function(){return p(this.rgba)},e.prototype.toRgbString=function(){return t=(e=p(this.rgba)).r,r=e.g,s=e.b,(n=e.a)<1?"rgba("+t+", "+r+", "+s+", "+n+")":"rgb("+t+", "+r+", "+s+")";var e,t,r,s,n},e.prototype.toHsl=function(){return y(h(this.rgba))},e.prototype.toHslString=function(){return t=(e=y(h(this.rgba))).h,r=e.s,s=e.l,(n=e.a)<1?"hsla("+t+", "+r+"%, "+s+"%, "+n+")":"hsl("+t+", "+r+"%, "+s+"%)";var e,t,r,s,n},e.prototype.toHsv=function(){return e=u(this.rgba),{h:n(e.h),s:n(e.s),v:n(e.v),a:n(e.a,3)};var e},e.prototype.invert=function(){return I({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return void 0===e&&(e=.1),I(S(this.rgba,e))},e.prototype.desaturate=function(e){return void 0===e&&(e=.1),I(S(this.rgba,-e))},e.prototype.grayscale=function(){return I(S(this.rgba,-1))},e.prototype.lighten=function(e){return void 0===e&&(e=.1),I(w(this.rgba,e))},e.prototype.darken=function(e){return void 0===e&&(e=.1),I(w(this.rgba,-e))},e.prototype.rotate=function(e){return void 0===e&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return"number"==typeof e?I({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):n(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=h(this.rgba);return"number"==typeof e?I({h:e,s:t.s,l:t.l,a:t.a}):n(t.h)},e.prototype.isEqual=function(e){return this.toHex()===I(e).toHex()},e}(),I=function(e){return e instanceof k?e:new k(e)},T=[];t.Colord=k,t.colord=I,t.extend=function(e){e.forEach((function(e){T.indexOf(e)<0&&(e(k,q),T.push(e))}))},t.getFormat=function(e){return x(e)[1]},t.random=function(){return new k({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}},2559:e=>{!function(){"use strict";var t=[,function(e,t){function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r255)throw new Error("Not ascii. Base64.encode can only take ascii strings.");e[r]=n}}for(var i=[],a=null,p=null,d=null,c=null,u=0;u>2&63,p=(3&e[u])<<4;break;case 1:p|=e[u]>>4&15,d=(15&e[u])<<2;break;case 2:d|=e[u]>>6&3,c=63&e[u],i.push(s(a)),i.push(s(p)),i.push(s(d)),i.push(s(c)),a=null,p=null,d=null,c=null}return null!=a&&(i.push(s(a)),i.push(s(p)),null==d?i.push("="):i.push(s(d)),null==c&&i.push("=")),i.join("")},decode:function(e){var t=Math.floor(3*e.length/4);"="==e.charAt(e.length-1)&&(t--,"="==e.charAt(e.length-2)&&t--);for(var s,n=o(t),i=null,a=null,p=null,d=0,c=0;c>4,n[d++]=i,a=(15&u)<<4;break;case 2:u>=0&&(a|=u>>2,n[d++]=a,p=(3&u)<<6);break;case 3:u>=0&&(n[d++]=p|u)}}return n},newBinary:o};t.Base64=i},function(e){e.exports={_noYieldsAllowed:function(e){return e()}}},function(e,t){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function s(e){return JSON.stringify(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function e(t,n,o,i,a){var p=n[t];switch(r(p)){case"string":return s(p);case"number":return isFinite(p)?String(p):"null";case"boolean":return String(p);case"object":if(!p)return"null";var d,c=i+o,u=[];if(Array.isArray(p)||{}.hasOwnProperty.call(p,"callee")){for(var l=p.length,m=0;m0&&void 0!==arguments[0]&&arguments[0]?a:(0,o.convertMapToObject)(a)},i._getConverters=function(){return p};var d=function(e){for(var t=0;t=u.length||n!==u[s]||!i.equals(e[n],t[u[s]],r)||(s++,0))}))):(s=0,a=c.every((function(n){return!!(0,o.hasOwn)(t,n)&&!!i.equals(e[n],t[n],r)&&(s++,!0)}))),a&&s===u.length},i.clone=function(e){var t;if(!(0,o.isObject)(e))return e;if(null===e)return null;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return e;if(i.isBinary(e)){t=i.newBinary(e.length);for(var r=0;r{"use strict";var t=Object.prototype.hasOwnProperty,r="~";function s(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,s,o,i){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new n(s,o||e,i),p=r?r+t:t;return e._events[p]?e._events[p].fn?e._events[p]=[e._events[p],a]:e._events[p].push(a):(e._events[p]=a,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,s,n=[];if(0===this._eventsCount)return n;for(s in e=this._events)t.call(e,s)&&n.push(r?s.slice(1):s);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},a.prototype.listeners=function(e){var t=r?r+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var n=0,o=s.length,i=new Array(o);n{"use strict";e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var s,n,o;if(Array.isArray(t)){if((s=t.length)!=r.length)return!1;for(n=s;0!=n--;)if(!e(t[n],r[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((s=(o=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(n=s;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,o[n]))return!1;for(n=s;0!=n--;){var i=o[n];if(!e(t[i],r[i]))return!1}return!0}return t!=t&&r!=r}},4341:e=>{"use strict";const t=(e,t,s,n)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const o=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);!r(o,i)&&n||Object.defineProperty(e,s,i)},r=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},s=(e,t)=>`/* Wrapped ${e}*/\n${t}`,n=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),o=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name");e.exports=(e,r,{ignoreNonConfigurable:i=!1}={})=>{const{name:a}=e;for(const s of Reflect.ownKeys(r))t(e,r,s,i);return((e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)})(e,r),((e,t,r)=>{const i=""===r?"":`with ${r.trim()}() `,a=s.bind(null,i,t.toString());Object.defineProperty(a,"name",o),Object.defineProperty(e,"toString",{...n,value:a})})(e,r,a),e}},7345:e=>{"use strict";e.exports=(e,t)=>(t=t||(()=>{}),e.then((e=>new Promise((e=>{e(t())})).then((()=>e))),(e=>new Promise((e=>{e(t())})).then((()=>{throw e})))))},5860:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(6729),n=r(6512),o=r(6506),i=()=>{},a=new n.TimeoutError;t.default=class extends s{constructor(e){var t,r,s,n;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=i,this._resolveIdle=i,!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:o.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(n=null===(s=e.interval)||void 0===s?void 0:s.toString())&&void 0!==n?n:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount{this._onResumeInterval()}),t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const t=this._queue.dequeue();return!!t&&(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0)}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((()=>{this._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,t={}){return new Promise(((r,s)=>{this._queue.enqueue((async()=>{this._pendingCount++,this._intervalCount++;try{const o=void 0===this._timeout&&void 0===t.timeout?e():n.default(Promise.resolve(e()),void 0===t.timeout?this._timeout:t.timeout,(()=>{(void 0===t.throwOnTimeout?this._throwOnTimeout:t.throwOnTimeout)&&s(a)}));r(await o)}catch(e){s(e)}this._next()}),t),this._tryToStartAnother(),this.emit("add")}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise((e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}}))}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise((e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}}))}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}}},7489:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let s=0,n=e.length;for(;n>0;){const o=n/2|0;let i=s+o;r(e[i],t)<=0?(s=++i,n-=o+1):n=o}return s}},6506:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(7489);t.default=class{constructor(){this._queue=[]}enqueue(e,t){const r={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(r);const n=s.default(this._queue,r,((e,t)=>t.priority-e.priority));this._queue.splice(n,0,r)}dequeue(){const e=this._queue.shift();return null==e?void 0:e.run}filter(e){return this._queue.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this._queue.length}}},6512:(e,t,r)=>{"use strict";const s=r(7345);class n extends Error{constructor(e){super(e),this.name="TimeoutError"}}const o=(e,t,r)=>new Promise(((o,i)=>{if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0)return void o(e);const a=setTimeout((()=>{if("function"==typeof r){try{o(r())}catch(e){i(e)}return}const s=r instanceof Error?r:new n("string"==typeof r?r:`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),i(s)}),t);s(e.then(o,i),(()=>{clearTimeout(a)}))}));e.exports=o,e.exports.default=o,e.exports.TimeoutError=n},2600:(e,t,r)=>{"use strict";r.r(t),r.d(t,{NIL:()=>S,parse:()=>b,stringify:()=>l,v1:()=>_,v3:()=>v,v4:()=>N,v5:()=>x,validate:()=>d,version:()=>P});var s=r(6113),n=r.n(s);const o=new Uint8Array(256);let i=o.length;function a(){return i>o.length-16&&(n().randomFillSync(o),i=0),o.slice(i,i+=16)}const p=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,d=function(e){return"string"==typeof e&&p.test(e)},c=[];for(let e=0;e<256;++e)c.push((e+256).toString(16).slice(1));function u(e,t=0){return(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase()}const l=function(e,t=0){const r=u(e,t);if(!d(r))throw TypeError("Stringified UUID is invalid");return r};let m,y,f=0,h=0;const _=function(e,t,r){let s=t&&r||0;const n=t||new Array(16);let o=(e=e||{}).node||m,i=void 0!==e.clockseq?e.clockseq:y;if(null==o||null==i){const t=e.random||(e.rng||a)();null==o&&(o=m=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==i&&(i=y=16383&(t[6]<<8|t[7]))}let p=void 0!==e.msecs?e.msecs:Date.now(),d=void 0!==e.nsecs?e.nsecs:h+1;const c=p-f+(d-h)/1e4;if(c<0&&void 0===e.clockseq&&(i=i+1&16383),(c<0||p>f)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");f=p,h=d,y=i,p+=122192928e5;const l=(1e4*(268435455&p)+d)%4294967296;n[s++]=l>>>24&255,n[s++]=l>>>16&255,n[s++]=l>>>8&255,n[s++]=255&l;const _=p/4294967296*1e4&268435455;n[s++]=_>>>8&255,n[s++]=255&_,n[s++]=_>>>24&15|16,n[s++]=_>>>16&255,n[s++]=i>>>8|128,n[s++]=255&i;for(let e=0;e<6;++e)n[s+e]=o[e];return t||u(n)},b=function(e){if(!d(e))throw TypeError("Invalid UUID");let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r};function g(e,t,r){function s(e,s,n,o){var i;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r{"use strict";const s=r(8762);s.createWebSocketStream=r(404),s.Server=r(9284),s.Receiver=r(2957),s.Sender=r(7330),s.WebSocket=s,s.WebSocketServer=s.Server,e.exports=s},977:(e,t,r)=>{"use strict";const{EMPTY_BUFFER:s}=r(1872),n=Buffer[Symbol.species];function o(e,t,r,s,n){for(let o=0;o{"use strict";e.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},62:(e,t,r)=>{"use strict";const{kForOnEventAttribute:s,kListener:n}=r(1872),o=Symbol("kCode"),i=Symbol("kData"),a=Symbol("kError"),p=Symbol("kMessage"),d=Symbol("kReason"),c=Symbol("kTarget"),u=Symbol("kType"),l=Symbol("kWasClean");class m{constructor(e){this[c]=null,this[u]=e}get target(){return this[c]}get type(){return this[u]}}Object.defineProperty(m.prototype,"target",{enumerable:!0}),Object.defineProperty(m.prototype,"type",{enumerable:!0});class y extends m{constructor(e,t={}){super(e),this[o]=void 0===t.code?0:t.code,this[d]=void 0===t.reason?"":t.reason,this[l]=void 0!==t.wasClean&&t.wasClean}get code(){return this[o]}get reason(){return this[d]}get wasClean(){return this[l]}}Object.defineProperty(y.prototype,"code",{enumerable:!0}),Object.defineProperty(y.prototype,"reason",{enumerable:!0}),Object.defineProperty(y.prototype,"wasClean",{enumerable:!0});class f extends m{constructor(e,t={}){super(e),this[a]=void 0===t.error?null:t.error,this[p]=void 0===t.message?"":t.message}get error(){return this[a]}get message(){return this[p]}}Object.defineProperty(f.prototype,"error",{enumerable:!0}),Object.defineProperty(f.prototype,"message",{enumerable:!0});class h extends m{constructor(e,t={}){super(e),this[i]=void 0===t.data?null:t.data}get data(){return this[i]}}Object.defineProperty(h.prototype,"data",{enumerable:!0});const _={addEventListener(e,t,r={}){for(const o of this.listeners(e))if(!r[s]&&o[n]===t&&!o[s])return;let o;if("message"===e)o=function(e,r){const s=new h("message",{data:r?e:e.toString()});s[c]=this,b(t,this,s)};else if("close"===e)o=function(e,r){const s=new y("close",{code:e,reason:r.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[c]=this,b(t,this,s)};else if("error"===e)o=function(e){const r=new f("error",{error:e,message:e.message});r[c]=this,b(t,this,r)};else{if("open"!==e)return;o=function(){const e=new m("open");e[c]=this,b(t,this,e)}}o[s]=!!r[s],o[n]=t,r.once?this.once(e,o):this.on(e,o)},removeEventListener(e,t){for(const r of this.listeners(e))if(r[n]===t&&!r[s]){this.removeListener(e,r);break}}};function b(e,t,r){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}e.exports={CloseEvent:y,ErrorEvent:f,Event:m,EventTarget:_,MessageEvent:h}},1503:(e,t,r)=>{"use strict";const{tokenChars:s}=r(6746);function n(e,t,r){void 0===e[t]?e[t]=[r]:e[t].push(r)}e.exports={format:function(e){return Object.keys(e).map((t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map((e=>[t].concat(Object.keys(e).map((t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let r,o,i=Object.create(null),a=!1,p=!1,d=!1,c=-1,u=-1,l=-1,m=0;for(;m{"use strict";const t=Symbol("kDone"),r=Symbol("kRun");e.exports=class{constructor(e){this[t]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[t])}}}},5196:(e,t,r)=>{"use strict";const s=r(9796),n=r(977),o=r(305),{kStatusCode:i}=r(1872),a=Buffer[Symbol.species],p=Buffer.from([0,0,255,255]),d=Symbol("permessage-deflate"),c=Symbol("total-length"),u=Symbol("callback"),l=Symbol("buffers"),m=Symbol("error");let y;function f(e){this[l].push(e),this[c]+=e.length}function h(e){this[c]+=e.length,this[d]._maxPayload<1||this[c]<=this[d]._maxPayload?this[l].push(e):(this[m]=new RangeError("Max payload size exceeded"),this[m].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[m][i]=1009,this.removeListener("data",h),this.reset())}function _(e){this[d]._inflate=null,e[i]=1007,this[u](e)}e.exports=class{constructor(e,t,r){if(this._maxPayload=0|r,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!y){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;y=new o(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,r=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(r.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?r.client_max_window_bits=t.clientMaxWindowBits:!0!==r.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete r.client_max_window_bits,r}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let r=e[t];if(r.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(r=r[0],"client_max_window_bits"===t){if(!0!==r){const e=+r;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${r}`)}else if("server_max_window_bits"===t){const e=+r;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==r)throw new TypeError(`Invalid value for parameter "${t}": ${r}`)}e[t]=r}))})),e}decompress(e,t,r){y.add((s=>{this._decompress(e,t,((e,t)=>{s(),r(e,t)}))}))}compress(e,t,r){y.add((s=>{this._compress(e,t,((e,t)=>{s(),r(e,t)}))}))}_decompress(e,t,r){const o=this._isServer?"client":"server";if(!this._inflate){const e=`${o}_max_window_bits`,t="number"!=typeof this.params[e]?s.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=s.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[d]=this,this._inflate[c]=0,this._inflate[l]=[],this._inflate.on("error",_),this._inflate.on("data",h)}this._inflate[u]=r,this._inflate.write(e),t&&this._inflate.write(p),this._inflate.flush((()=>{const e=this._inflate[m];if(e)return this._inflate.close(),this._inflate=null,void r(e);const s=n.concat(this._inflate[l],this._inflate[c]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[c]=0,this._inflate[l]=[],t&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,s)}))}_compress(e,t,r){const o=this._isServer?"server":"client";if(!this._deflate){const e=`${o}_max_window_bits`,t="number"!=typeof this.params[e]?s.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=s.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[c]=0,this._deflate[l]=[],this._deflate.on("data",f)}this._deflate[u]=r,this._deflate.write(e),this._deflate.flush(s.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=n.concat(this._deflate[l],this._deflate[c]);t&&(e=new a(e.buffer,e.byteOffset,e.length-4)),this._deflate[u]=null,this._deflate[c]=0,this._deflate[l]=[],t&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),r(null,e)}))}}},2957:(e,t,r)=>{"use strict";const{Writable:s}=r(2781),n=r(5196),{BINARY_TYPES:o,EMPTY_BUFFER:i,kStatusCode:a,kWebSocket:p}=r(1872),{concat:d,toArrayBuffer:c,unmask:u}=r(977),{isValidStatusCode:l,isValidUTF8:m}=r(6746),y=Buffer[Symbol.species];e.exports=class extends s{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[p]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,r){if(8===this._opcode&&0==this._state)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=r.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),s),this._buffers[0]=new y(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(0!=(48&t[0]))return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"));const r=64==(64&t[0]);if(!r||this._extensions[n.extensionName]){if(this._fin=128==(128&t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(r)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(!this._fragmented)return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"));this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));this._compressed=r}else{if(!(this._opcode>7&&this._opcode<11))return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));if(!this._fin)return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"));if(r)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&t[1]),this._isServer){if(!this._masked)return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}else if(this._masked)return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"));126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}else e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),r=t.readUInt32BE(0);r>Math.pow(2,21)-1?e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e))}haveLength(e){this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)?e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")):this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=i;if(this._payloadLength){if(this._bufferedBytes7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[n.extensionName].decompress(e,this._fin,((e,r)=>{if(e)return t(e);if(r.length){if(this._messageLength+=r.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(r)}this.dataMessage(t),0===this._state&&this.startLoop(t)}))}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let s;s="nodebuffer"===this._binaryType?d(r,t):"arraybuffer"===this._binaryType?c(d(r,t)):r,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",s,!0),this._state=0,this.startLoop(e)})))}else{const s=d(r,t);if(!this._skipUTF8Validation&&!m(s)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=0):(this._state=6,setImmediate((()=>{this.emit("message",s,!1),this._state=0,this.startLoop(e)})))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate((()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)})));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,i),this.end();else{const r=e.readUInt16BE(0);if(!l(r)){const e=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const s=new y(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!m(s)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",r,s),this.end()}this._state=0}}createError(e,t,r,s,n){this._loop=!1,this._errored=!0;const o=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=n,o[a]=s,o}}},7330:(e,t,r)=>{"use strict";const{Duplex:s}=r(2781),{randomFillSync:n}=r(6113),o=r(5196),{EMPTY_BUFFER:i}=r(1872),{isValidStatusCode:a}=r(6746),{mask:p,toBuffer:d}=r(977),c=Symbol("kByteLength"),u=Buffer.alloc(4),l=8192;let m,y=l;class f{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let r,s,o=!1,i=2,a=!1;t.mask&&(r=t.maskBuffer||u,t.generateMask?t.generateMask(r):(y===l&&(void 0===m&&(m=Buffer.alloc(l)),n(m,0,l),y=0),r[0]=m[y++],r[1]=m[y++],r[2]=m[y++],r[3]=m[y++]),a=0==(r[0]|r[1]|r[2]|r[3]),i=6),"string"==typeof e?s=t.mask&&!a||void 0===t[c]?(e=Buffer.from(e)).length:t[c]:(s=e.length,o=t.mask&&t.readOnly&&!a);let d=s;s>=65536?(i+=8,d=127):s>125&&(i+=2,d=126);const f=Buffer.allocUnsafe(o?s+i:i);return f[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(f[0]|=64),f[1]=d,126===d?f.writeUInt16BE(s,2):127===d&&(f[2]=f[3]=0,f.writeUIntBE(s,4,6)),t.mask?(f[1]|=128,f[i-4]=r[0],f[i-3]=r[1],f[i-2]=r[2],f[i-1]=r[3],a?[f,e]:o?(p(e,r,f,i,s),[f]):(p(e,r,e,0,s),[f,e])):[f,e]}close(e,t,r,s){let n;if(void 0===e)n=i;else{if("number"!=typeof e||!a(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const r=Buffer.byteLength(t);if(r>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+r),n.writeUInt16BE(e,0),"string"==typeof t?n.write(t,2):n.set(t,2)}else n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0)}const o={[c]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,n,!1,o,s]):this.sendFrame(f.frame(n,o),s)}ping(e,t,r){let s,n;if("string"==typeof e?(s=Buffer.byteLength(e),n=!1):(s=(e=d(e)).length,n=d.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[c]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(f.frame(e,o),r)}pong(e,t,r){let s,n;if("string"==typeof e?(s=Buffer.byteLength(e),n=!1):(s=(e=d(e)).length,n=d.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[c]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(f.frame(e,o),r)}send(e,t,r){const s=this._extensions[o.extensionName];let n,i,a=t.binary?2:1,p=t.compress;if("string"==typeof e?(n=Buffer.byteLength(e),i=!1):(n=(e=d(e)).length,i=d.readOnly),this._firstFragment?(this._firstFragment=!1,p&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(p=n>=s._threshold),this._compress=p):(p=!1,a=0),t.fin&&(this._firstFragment=!0),s){const s={[c]:n,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:i,rsv1:p};this._deflating?this.enqueue([this.dispatch,e,this._compress,s,r]):this.dispatch(e,this._compress,s,r)}else this.sendFrame(f.frame(e,{[c]:n,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:i,rsv1:!1}),r)}dispatch(e,t,r,s){if(!t)return void this.sendFrame(f.frame(e,r),s);const n=this._extensions[o.extensionName];this._bufferedBytes+=r[c],this._deflating=!0,n.compress(e,r.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof s&&s(e);for(let t=0;t{"use strict";const{Duplex:s}=r(2781);function n(e){e.emit("close")}function o(){!this.destroyed&&this._writableState.finished&&this.destroy()}function i(e){this.removeListener("error",i),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}e.exports=function(e,t){let r=!0;const a=new s({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,r){const s=!r&&a._readableState.objectMode?t.toString():t;a.push(s)||e.pause()})),e.once("error",(function(e){a.destroyed||(r=!1,a.destroy(e))})),e.once("close",(function(){a.destroyed||a.push(null)})),a._destroy=function(t,s){if(e.readyState===e.CLOSED)return s(t),void process.nextTick(n,a);let o=!1;e.once("error",(function(e){o=!0,s(e)})),e.once("close",(function(){o||s(t),process.nextTick(n,a)})),r&&e.terminate()},a._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),a._readableState.endEmitted&&a.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){a._final(t)}))},a._read=function(){e.isPaused&&e.resume()},a._write=function(t,r,s){e.readyState!==e.CONNECTING?e.send(t,s):e.once("open",(function(){a._write(t,r,s)}))},a.on("end",o),a.on("error",i),a}},640:(e,t,r)=>{"use strict";const{tokenChars:s}=r(6746);e.exports={parse:function(e){const t=new Set;let r=-1,n=-1,o=0;for(;o{"use strict";const{isUtf8:s}=r(4300);function n(e){const t=e.length;let r=0;for(;r=t||128!=(192&e[r+1])||128!=(192&e[r+2])||224===e[r]&&128==(224&e[r+1])||237===e[r]&&160==(224&e[r+1]))return!1;r+=3}else{if(240!=(248&e[r]))return!1;if(r+3>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||128!=(192&e[r+3])||240===e[r]&&128==(240&e[r+1])||244===e[r]&&e[r+1]>143||e[r]>244)return!1;r+=4}return!0}if(e.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:n,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},s)e.exports.isValidUTF8=function(e){return e.length<24?n(e):s(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=r(Object(function(){var e=new Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.isValidUTF8=function(e){return e.length<32?n(e):t(e)}}catch(e){}},9284:(e,t,r)=>{"use strict";const s=r(2361),n=r(3685),{Duplex:o}=r(2781),{createHash:i}=r(6113),a=r(1503),p=r(5196),d=r(640),c=r(8762),{GUID:u,kWebSocket:l}=r(1872),m=/^[+/0-9A-Za-z]{22}==$/;function y(e){e._state=2,e.emit("close")}function f(){this.destroy()}function h(e,t,r,s){r=r||n.STATUS_CODES[t],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${n.STATUS_CODES[t]}\r\n`+Object.keys(s).map((e=>`${e}: ${s[e]}`)).join("\r\n")+"\r\n\r\n"+r)}function _(e,t,r,s,n){if(e.listenerCount("wsClientError")){const s=new Error(n);Error.captureStackTrace(s,_),e.emit("wsClientError",s,r,t)}else h(r,s,n)}e.exports=class extends s{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=n.createServer(((e,t)=>{const r=n.STATUS_CODES[426];t.writeHead(426,{"Content-Length":r.length,"Content-Type":"text/plain"}),t.end(r)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const r of Object.keys(t))e.on(r,t[r]);return function(){for(const r of Object.keys(t))e.removeListener(r,t[r])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,r,s)=>{this.handleUpgrade(t,r,s,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(y,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(y,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{y(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,s){t.on("error",f);const n=e.headers["sec-websocket-key"],o=e.headers.upgrade,i=+e.headers["sec-websocket-version"];if("GET"!==e.method)return void _(this,e,t,405,"Invalid HTTP method");if(void 0===o||"websocket"!==o.toLowerCase())return void _(this,e,t,400,"Invalid Upgrade header");if(void 0===n||!m.test(n))return void _(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");if(8!==i&&13!==i)return void _(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");if(!this.shouldHandle(e))return void h(t,400);const c=e.headers["sec-websocket-protocol"];let u=new Set;if(void 0!==c)try{u=d.parse(c)}catch(r){return void _(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const l=e.headers["sec-websocket-extensions"],y={};if(this.options.perMessageDeflate&&void 0!==l){const r=new p(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=a.parse(l);e[p.extensionName]&&(r.accept(e[p.extensionName]),y[p.extensionName]=r)}catch(r){return void _(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const o={origin:e.headers[8===i?"sec-websocket-origin":"origin"],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,((o,i,a,p)=>{if(!o)return h(t,i||401,a,p);this.completeUpgrade(y,n,u,e,t,r,s)}));if(!this.options.verifyClient(o))return h(t,401)}this.completeUpgrade(y,n,u,e,t,r,s)}completeUpgrade(e,t,r,s,n,o,d){if(!n.readable||!n.writable)return n.destroy();if(n[l])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return h(n,503);const c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${i("sha1").update(t+u).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(r.size){const e=this.options.handleProtocols?this.options.handleProtocols(r,s):r.values().next().value;e&&(c.push(`Sec-WebSocket-Protocol: ${e}`),m._protocol=e)}if(e[p.extensionName]){const t=e[p.extensionName].params,r=a.format({[p.extensionName]:[t]});c.push(`Sec-WebSocket-Extensions: ${r}`),m._extensions=e}this.emit("headers",c,s),n.write(c.concat("\r\n").join("\r\n")),n.removeListener("error",f),m.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",(()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(y,this)}))),d(m,s)}}},8762:(e,t,r)=>{"use strict";const s=r(2361),n=r(5687),o=r(3685),i=r(1808),a=r(4404),{randomBytes:p,createHash:d}=r(6113),{Duplex:c,Readable:u}=r(2781),{URL:l}=r(7310),m=r(5196),y=r(2957),f=r(7330),{BINARY_TYPES:h,EMPTY_BUFFER:_,GUID:b,kForOnEventAttribute:g,kListener:v,kStatusCode:q,kWebSocket:N,NOOP:x}=r(1872),{EventTarget:{addEventListener:S,removeEventListener:P}}=r(62),{format:w,parse:k}=r(1503),{toBuffer:I}=r(977),T=Symbol("kAborted"),E=[8,13],O=["CONNECTING","OPEN","CLOSING","CLOSED"],C=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class A extends s{constructor(e,t,r){super(),this._binaryType=h[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=_,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=A.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(r=t,t=[]):t=[t]),j(this,e,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){h.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){const s=new y({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new f(e,this._extensions,r.generateMask),this._receiver=s,this._socket=e,s[N]=this,e[N]=this,s.on("conclude",V),s.on("drain",F),s.on("error",$),s.on("message",W),s.on("ping",G),s.on("pong",H),e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",J),e.on("data",Y),e.on("end",Q),e.on("error",K),this._readyState=A.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=A.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[m.extensionName]&&this._extensions[m.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=A.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==A.CLOSED)if(this.readyState!==A.CONNECTING)this.readyState!==A.CLOSING?(this._readyState=A.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";L(this,this._req,e)}}pause(){this.readyState!==A.CONNECTING&&this.readyState!==A.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===A.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===A.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||_,t,r)):U(this,e,r)}pong(e,t,r){if(this.readyState===A.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===A.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||_,t,r)):U(this,e,r)}resume(){this.readyState!==A.CONNECTING&&this.readyState!==A.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===A.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(r=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==A.OPEN)return void U(this,e,r);const s={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[m.extensionName]||(s.compress=!1),this._sender.send(e||_,s,r)}terminate(){if(this.readyState!==A.CLOSED)if(this.readyState!==A.CONNECTING)this._socket&&(this._readyState=A.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";L(this,this._req,e)}}}function j(e,t,r,s){const i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:E[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!E.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${E.join(", ")})`);let a;if(t instanceof l)a=t;else try{a=new l(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===a.protocol?a.protocol="ws:":"https:"===a.protocol&&(a.protocol="wss:"),e._url=a.href;const c="wss:"===a.protocol,u="ws+unix:"===a.protocol;let y;if("ws:"===a.protocol||c||u?u&&!a.pathname?y="The URL's pathname is empty":a.hash&&(y="The URL contains a fragment identifier"):y='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"',y){const t=new SyntaxError(y);if(0===e._redirects)throw t;return void M(e,t)}const f=c?443:80,h=p(16).toString("base64"),_=c?n.request:o.request,g=new Set;let v,q;if(i.createConnection=i.createConnection||(c?D:R),i.defaultPort=i.defaultPort||f,i.port=a.port||f,i.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=a.pathname+a.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(v=new m(!0!==i.perMessageDeflate?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=w({[m.extensionName]:v.offer()})),r.length){for(const e of r){if("string"!=typeof e||!C.test(e)||g.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");g.add(e)}i.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(a.username||a.password)&&(i.auth=`${a.username}:${a.password}`),u){const e=i.path.split(":");i.socketPath=e[0],i.path=e[1]}if(i.followRedirects){if(0===e._redirects){e._originalIpc=u,e._originalSecure=c,e._originalHostOrSocketPath=u?i.socketPath:a.host;const t=s&&s.headers;if(s={...s,headers:{}},t)for(const[e,r]of Object.entries(t))s.headers[e.toLowerCase()]=r}else if(0===e.listenerCount("redirect")){const t=u?!!e._originalIpc&&i.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&a.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!c)&&(delete i.headers.authorization,delete i.headers.cookie,t||delete i.headers.host,i.auth=void 0)}i.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),q=e._req=_(i),e._redirects&&e.emit("redirect",e.url,q)}else q=e._req=_(i);i.timeout&&q.on("timeout",(()=>{L(e,q,"Opening handshake has timed out")})),q.on("error",(t=>{null===q||q[T]||(q=e._req=null,M(e,t))})),q.on("response",(n=>{const o=n.headers.location,a=n.statusCode;if(o&&i.followRedirects&&a>=300&&a<400){if(++e._redirects>i.maxRedirects)return void L(e,q,"Maximum redirects exceeded");let n;q.abort();try{n=new l(o,t)}catch(t){const r=new SyntaxError(`Invalid URL: ${o}`);return void M(e,r)}j(e,n,r,s)}else e.emit("unexpected-response",q,n)||L(e,q,`Unexpected server response: ${n.statusCode}`)})),q.on("upgrade",((t,r,s)=>{if(e.emit("upgrade",t),e.readyState!==A.CONNECTING)return;q=e._req=null;const n=t.headers.upgrade;if(void 0===n||"websocket"!==n.toLowerCase())return void L(e,r,"Invalid Upgrade header");const o=d("sha1").update(h+b).digest("base64");if(t.headers["sec-websocket-accept"]!==o)return void L(e,r,"Invalid Sec-WebSocket-Accept header");const a=t.headers["sec-websocket-protocol"];let p;if(void 0!==a?g.size?g.has(a)||(p="Server sent an invalid subprotocol"):p="Server sent a subprotocol but none was requested":g.size&&(p="Server sent no subprotocol"),p)return void L(e,r,p);a&&(e._protocol=a);const c=t.headers["sec-websocket-extensions"];if(void 0!==c){if(!v)return void L(e,r,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");let t;try{t=k(c)}catch(t){return void L(e,r,"Invalid Sec-WebSocket-Extensions header")}const s=Object.keys(t);if(1!==s.length||s[0]!==m.extensionName)return void L(e,r,"Server indicated an extension that was not requested");try{v.accept(t[m.extensionName])}catch(t){return void L(e,r,"Invalid Sec-WebSocket-Extensions header")}e._extensions[m.extensionName]=v}e.setSocket(r,s,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})})),i.finishRequest?i.finishRequest(q,e):q.end()}function M(e,t){e._readyState=A.CLOSING,e.emit("error",t),e.emitClose()}function R(e){return e.path=e.socketPath,i.connect(e)}function D(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=i.isIP(e.host)?"":e.host),a.connect(e)}function L(e,t,r){e._readyState=A.CLOSING;const s=new Error(r);Error.captureStackTrace(s,L),t.setHeader?(t[T]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(M,e,s)):(t.destroy(s),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function U(e,t,r){if(t){const r=I(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(r){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${O[e.readyState]})`);process.nextTick(r,t)}}function V(e,t){const r=this[N];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,void 0!==r._socket[N]&&(r._socket.removeListener("data",Y),process.nextTick(z,r._socket),1005===e?r.close():r.close(e,t))}function F(){const e=this[N];e.isPaused||e._socket.resume()}function $(e){const t=this[N];void 0!==t._socket[N]&&(t._socket.removeListener("data",Y),process.nextTick(z,t._socket),t.close(e[q])),t.emit("error",e)}function B(){this[N].emitClose()}function W(e,t){this[N].emit("message",e,t)}function G(e){const t=this[N];t._autoPong&&t.pong(e,!this._isServer,x),t.emit("ping",e)}function H(e){this[N].emit("pong",e)}function z(e){e.resume()}function J(){const e=this[N];let t;this.removeListener("close",J),this.removeListener("data",Y),this.removeListener("end",Q),e._readyState=A.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[N]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",B),e._receiver.on("finish",B))}function Y(e){this[N]._receiver.write(e)||this.pause()}function Q(){const e=this[N];e._readyState=A.CLOSING,e._receiver.end(),this.end()}function K(){const e=this[N];this.removeListener("error",K),this.on("error",x),e&&(e._readyState=A.CLOSING,this.destroy())}Object.defineProperty(A,"CONNECTING",{enumerable:!0,value:O.indexOf("CONNECTING")}),Object.defineProperty(A.prototype,"CONNECTING",{enumerable:!0,value:O.indexOf("CONNECTING")}),Object.defineProperty(A,"OPEN",{enumerable:!0,value:O.indexOf("OPEN")}),Object.defineProperty(A.prototype,"OPEN",{enumerable:!0,value:O.indexOf("OPEN")}),Object.defineProperty(A,"CLOSING",{enumerable:!0,value:O.indexOf("CLOSING")}),Object.defineProperty(A.prototype,"CLOSING",{enumerable:!0,value:O.indexOf("CLOSING")}),Object.defineProperty(A,"CLOSED",{enumerable:!0,value:O.indexOf("CLOSED")}),Object.defineProperty(A.prototype,"CLOSED",{enumerable:!0,value:O.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(A.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(A.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[g])return t[v];return null},set(t){for(const t of this.listeners(e))if(t[g]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[g]:!0})}})})),A.prototype.addEventListener=S,A.prototype.removeEventListener=P,e.exports=A},4300:e=>{"use strict";e.exports=require("buffer")},6113:e=>{"use strict";e.exports=require("crypto")},1891:e=>{"use strict";e.exports=require("dgram")},2361:e=>{"use strict";e.exports=require("events")},3292:e=>{"use strict";e.exports=require("fs/promises")},3685:e=>{"use strict";e.exports=require("http")},5687:e=>{"use strict";e.exports=require("https")},1808:e=>{"use strict";e.exports=require("net")},1017:e=>{"use strict";e.exports=require("path")},2781:e=>{"use strict";e.exports=require("stream")},4404:e=>{"use strict";e.exports=require("tls")},7310:e=>{"use strict";e.exports=require("url")},9796:e=>{"use strict";e.exports=require("zlib")},2764:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},7359:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runEntrypoint=void 0;const s=r(7582),n=r(9913),o=s.__importDefault(r(3292)),i=r(2068),a=r(8221),p=s.__importDefault(r(1017));let d,c=!1;t.runEntrypoint=function(e,t){Promise.resolve().then((async()=>{if(c)throw new Error("runEntrypoint can only be called once");c=!0;const r=process.env.MODULE_MANIFEST;if(!r)throw new Error("Module initialise is missing MODULE_MANIFEST");const s=await o.default.readFile(r),u=JSON.parse(s.toString());if(u.runtime?.api!==n.HostApiNodeJsIpc)throw new Error("Module manifest 'api' mismatch");if(!u.runtime.apiVersion)throw new Error("Module manifest 'apiVersion' missing");let l=u.runtime.apiVersion;if("0.0.0"===l)try{const e=await o.default.readFile(p.default.join(__dirname,"../package.json")),t=JSON.parse(e.toString());"@companion-module/base"===t.name&&(l=t.version)}catch(e){throw new Error("Failed to determine module api version")}if(!process.send)throw new Error("Module is not being run with ipc");console.log(`Starting up module class: ${e.name}`);const m=process.env.CONNECTION_ID;if("string"!=typeof m||!m)throw new Error("Module initialise is missing CONNECTION_ID");const y=process.env.VERIFICATION_TOKEN;if("string"!=typeof y||!y)throw new Error("Module initialise is missing VERIFICATION_TOKEN");const f=new a.IpcWrapper({},(e=>{process.send(e)}),5e3);process.once("message",(e=>{f.receivedMessage(e)})),d=new e((0,i.literal)({id:m,upgradeScripts:t,_isInstanceBaseProps:!0})),f.sendWithCb("register",{apiVersion:l,connectionId:m,verificationToken:y}).then((()=>{console.log("Module-host accepted registration")}),(e=>{console.error("Module registration failed",e),process.exit(11)}))})).catch((e=>{console.error("Failed to startup module:"),console.error(e.stack||e.message),process.exit(1)}))}},1972:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UDPHelper=t.TelnetHelper=t.TCPHelper=void 0;var s=r(9159);Object.defineProperty(t,"TCPHelper",{enumerable:!0,get:function(){return s.TCPHelper}});var n=r(6226);Object.defineProperty(t,"TelnetHelper",{enumerable:!0,get:function(){return n.TelnetHelper}});var o=r(8473);Object.defineProperty(t,"UDPHelper",{enumerable:!0,get:function(){return o.UDPHelper}})},9159:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TCPHelper=void 0;const s=r(7582).__importDefault(r(1808)),n=r(6729),o=r(609);class i extends n.EventEmitter{#e;#t;_socket;#r;#s=!1;#n=!1;#o=!1;#i;#a;#p;get isConnected(){return this.#s}get isConnecting(){return this.#n}get isDestroyed(){return this.#o}constructor(e,t,r){super(),this.#e=e,this.#t=t,this.#r={reconnect_interval:2e3,reconnect:!0,...r},this._socket=new s.default.Socket,this._socket.setKeepAlive(!0),this._socket.setNoDelay(!0),this._socket.on("error",(e=>{this.#n=!1,this.#s=!1,this.#r.reconnect&&this.#d(),this.#c(o.InstanceStatus.UnknownError,e.message),this.emit("error",e)})),this._socket.on("ready",(()=>{this.#s=!0,this.#n=!1,this.#c(o.InstanceStatus.Ok),this.emit("connect")})),this._socket.on("end",(()=>{this.#s=!1,this.#c(o.InstanceStatus.Disconnected),!this.#n&&this.#r.reconnect&&this.#d(),this.emit("end")})),this._socket.on("data",(e=>this.emit("data",e))),this._socket.on("drain",(()=>this.emit("drain"))),setImmediate((()=>{this.#o||this.connect()})),this.#p=setTimeout((()=>{this.#p=void 0,this.#o||this.listenerCount("error")||console.error(`Danger: TCP client for ${this.#e}:${this.#t} is missing an error handler!`)}),5e3)}connect(){if(this.#o)throw new Error("Cannot connect destroyed socket");return!this.#n&&(this.#n=!0,this._socket.connect(this.#t,this.#e),!0)}async send(e){if(this.#o||this._socket.destroyed)throw new Error("Cannot write to destroyed socket");if(!e||!e.length)throw new Error("No message to send");if(!this.#s)return!1;try{return new Promise(((t,r)=>{this._socket.write(e,(e=>{e?r(e):t(!0)}))}))}catch(e){this.#s=!1;const t=e instanceof Error?e:new Error(`${e}`);throw this.#c(o.InstanceStatus.UnknownError,t.message),this.emit("error",t),t}}destroy(){this.#o=!0,void 0!==this.#a&&(clearTimeout(this.#a),this.#a=void 0),void 0!==this.#p&&(clearTimeout(this.#p),this.#p=void 0),this._socket.removeAllListeners(),this.removeAllListeners(),this._socket.destroy()}#d(){void 0!==this.#a&&clearTimeout(this.#a),this.#a=setTimeout((()=>{this.#a=void 0,this.#c(o.InstanceStatus.Connecting),this.connect()}),this.#r.reconnect_interval)}#c(e,t){this.#i!=e&&(this.#i=e,this.emit("status_change",e,t))}}t.TCPHelper=i},6226:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TelnetHelper=void 0;const s=r(7582).__importDefault(r(6729)),n=r(2781),o=r(9159);class i extends s.default{#u;#l;#p;get isConnected(){return this.#u.isConnected}get isConnecting(){return this.#u.isConnecting}get isDestroyed(){return this.#u.isDestroyed}constructor(e,t,r){super(),this.#u=new o.TCPHelper(e,t,r),this.#l=new a,this.#u._socket.pipe(this.#l),this.#u.on("connect",(()=>this.emit("connect"))),this.#u.on("end",(()=>this.emit("end"))),this.#u.on("error",(e=>this.emit("error",e))),this.#u.on("status_change",((e,t)=>this.emit("status_change",e,t))),this.#l.on("iac",((e,t)=>this.emit("iac",e,t))),this.#l.on("sb",(e=>this.emit("sb",e))),this.#l.on("data",(e=>this.emit("data",e))),this.#l.on("drain",(()=>this.emit("drain"))),this.#p=setTimeout((()=>{this.#p=void 0,this.isDestroyed||this.listenerCount("error")||console.error(`Danger: Telnet client for ${e}:${t} is missing an error handler!`)}),5e3)}connect(){return this.#u.connect()}async send(e){return this.#u.send(e)}destroy(){this.#u.destroy(),void 0!==this.#p&&(clearTimeout(this.#p),this.#p=void 0),this.#l.removeAllListeners(),this.#l.destroy()}}t.TelnetHelper=i;class a extends n.Transform{#m;#y;#f;constructor(e){super(e),this.#m=Buffer.alloc(0),this.#y=Buffer.alloc(0),this.#f=0}_transform(e,t,r){for(let t=0;t=251&&this.#f<=254){let t;switch(this.#f){case 251:t="WILL";break;case 252:t="WONT";break;case 253:t="DO";break;case 254:t="DONT";break;default:return}return this.emit("iac",t,e),void(this.#f=0)}if(250===this.#f){if(240===e)return this.emit("sb",this.#y),this.#f=0,void(this.#y=Buffer.alloc(0));this.#y=Buffer.concat([this.#y,Buffer.from([e])])}}}#_(){const e=this.#m;return this.#m=Buffer.alloc(0),e}}},8473:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UDPHelper=void 0;const s=r(7582).__importDefault(r(1891)),n=r(6729),o=r(609);class i extends n.EventEmitter{#e;#t;#b;#r;#o=!1;#i;#p;get isDestroyed(){return this.#o}constructor(e,t,r){super(),this.#e=e,this.#t=t,this.#r={...r},this.#b=s.default.createSocket("udp4");try{this.#b.bind(this.#r.bind_port||0,this.#r.bind_ip)}catch(e){throw new Error(`Unable to bind to ip/port: ${this.#r.bind_ip||"0.0.0.0"}:${this.#r.bind_port||0}`)}this.#r.broadcast&&this.#b.setBroadcast(!0),void 0!==this.#r.ttl&&this.#b.setTTL(this.#r.ttl),void 0!==this.#r.multicast_ttl&&this.#b.setMulticastTTL(this.#r.multicast_ttl),this.#b.on("error",(e=>{this.#c(o.InstanceStatus.UnknownError,e.message),this.emit("error",e)})),this.#b.on("listening",(()=>{this.#r.multicast_interface&&this.#b.setMulticastInterface(this.#r.multicast_interface),this.#c(o.InstanceStatus.Ok),this.emit("listening")})),this.#b.on("message",(e=>this.emit("data",e))),this.#p=setTimeout((()=>{this.#o||this.listenerCount("error")||console.error(`Danger: UDP socket for ${this.#e}:${this.#t} is missing an error handler!`)}),5e3)}async send(e){if(this.#o)throw new Error("Cannot write to destroyed socket");if(!e||!e.length)throw new Error("No message to send");return new Promise(((t,r)=>{this.#b.send(e,this.#t,this.#e,(e=>{e?r(e):t()}))}))}destroy(){this.#o=!0,void 0!==this.#p&&(clearTimeout(this.#p),this.#p=void 0),this.#b.removeAllListeners(),this.#b.close(),this.removeAllListeners()}#c(e,t){this.#i!=e&&(this.#i=e,this.emit("status_change",e,t))}}t.UDPHelper=i},8221:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IpcWrapper=void 0;const s=r(7582),n=r(2068),o=s.__importDefault(r(2559));t.IpcWrapper=class{#g;#v;#q;#N=1;#x=new Map;constructor(e,t,r){this.#g=e,this.#v=t,this.#q=r}async sendWithCb(e,t,r,s=0){s<=0&&(s=this.#q);const n={timeout:void 0,resolve:()=>null,reject:()=>null},i=new Promise(((e,t)=>{n.resolve=e,n.reject=t}));this.#N>268435456&&(this.#N=1);const a=this.#N++;this.#x.set(a,n),this.#v({direction:"call",name:String(e),payload:o.default.stringify(t),callbackId:a});const p=new Error("Call timed out");return n.timeout=setTimeout((()=>{n.reject(r?r():p),this.#x.delete(a)}),s),i}sendWithNoCb(e,t){this.#v({direction:"call",name:String(e),payload:o.default.stringify(t),callbackId:void 0})}receivedMessage(e){const t=e;switch(e.direction){case"call":{const t=this.#g[e.name];if(!t)return void(e.callbackId&&this.#v({direction:"response",callbackId:e.callbackId,success:!1,payload:o.default.stringify({message:`Unknown command "${e.name}"`})}));t(e.payload?o.default.parse(e.payload):void 0).then((t=>{e.callbackId&&this.#v({direction:"response",callbackId:e.callbackId,success:!0,payload:o.default.stringify(t)})}),(t=>{e.callbackId&&this.#v({direction:"response",callbackId:e.callbackId,success:!1,payload:t instanceof Error?JSON.stringify(t,Object.getOwnPropertyNames(t)):o.default.stringify(t)})}));break}case"response":{if(!e.callbackId)return void console.error("Ipc: Response message has no callbackId");const t=this.#x.get(e.callbackId);if(this.#x.delete(e.callbackId),!t)return;clearTimeout(t.timeout);const r=e.payload?o.default.parse(e.payload):void 0;if(e.success)t.resolve(r);else{let e=r;r&&"object"==typeof r&&"message"in r&&(e=new Error(r.message),r.stack&&(e.stack=r.stack)),t.reject(e)}break}default:(0,n.assertNever)(e),console.error(`Ipc: Message of unknown direction "${t.direction}"`)}}}},9913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HostApiNodeJsIpc=void 0,t.HostApiNodeJsIpc="nodejs-ipc"},8049:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runEntrypoint=t.assertNever=t.splitHex=t.splitHsv=t.splitHsl=t.splitRgb=t.combineRgb=t.literal=void 0;const s=r(7582);s.__exportStar(r(7517),t),s.__exportStar(r(4911),t),s.__exportStar(r(2764),t);var n=r(2068);Object.defineProperty(t,"literal",{enumerable:!0,get:function(){return n.literal}}),Object.defineProperty(t,"combineRgb",{enumerable:!0,get:function(){return n.combineRgb}}),Object.defineProperty(t,"splitRgb",{enumerable:!0,get:function(){return n.splitRgb}}),Object.defineProperty(t,"splitHsl",{enumerable:!0,get:function(){return n.splitHsl}}),Object.defineProperty(t,"splitHsv",{enumerable:!0,get:function(){return n.splitHsv}}),Object.defineProperty(t,"splitHex",{enumerable:!0,get:function(){return n.splitHex}}),Object.defineProperty(t,"assertNever",{enumerable:!0,get:function(){return n.assertNever}}),s.__exportStar(r(1972),t);var o=r(7359);Object.defineProperty(t,"runEntrypoint",{enumerable:!0,get:function(){return o.runEntrypoint}})},4391:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionManager=void 0;const s=r(2557);function n(e){return{id:e.id,actionId:e.actionId,controlId:e.controlId,options:e.options}}t.ActionManager=class{#S;#P;#w;#k=new Map;#I=new Map;constructor(e,t,r){this.#S=e,this.#P=t,this.#w=r}async handleExecuteAction(e){const t=this.#k.get(e.action.actionId);if(!t)throw new Error(`Unknown action: ${e.action.actionId}`);const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.action.controlId,actionInstanceId:e.action.id,feedbackInstanceId:void 0})).text};await t.callback({id:e.action.id,actionId:e.action.actionId,controlId:e.action.controlId,options:e.action.options,surfaceId:e.surfaceId},r)}handleUpdateActions(e){for(const[t,r]of Object.entries(e)){const e=this.#I.get(t);if(e){const t=this.#k.get(e.actionId);if(t?.unsubscribe){const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.unsubscribe(n(e),r)).catch((t=>{this.#w("error",`Action unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}if(!r||r.disabled)this.#I.delete(t);else{this.#I.set(t,r);const e=this.#k.get(r.actionId);if(e?.subscribe){const t={parseVariablesInString:async e=>(await this.#S({text:e,controlId:r.controlId,actionInstanceId:r.id,feedbackInstanceId:void 0})).text};Promise.resolve(e.subscribe(n(r),t)).catch((e=>{this.#w("error",`Action subscribe failed: ${JSON.stringify(r)} - ${e?.message??e} ${e?.stack}`)}))}}}}async handleLearnAction(e){const t=this.#k.get(e.action.actionId);if(t&&t.learn){const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.action.controlId,actionInstanceId:e.action.id,feedbackInstanceId:void 0})).text};return{options:await t.learn({id:e.action.id,actionId:e.action.actionId,controlId:e.action.controlId,options:e.action.options,surfaceId:void 0},r)}}return{options:void 0}}setActionDefinitions(e){const t=[];this.#k.clear();for(const[r,n]of Object.entries(e))n&&(t.push({id:r,name:n.name,description:n.description,options:(0,s.serializeIsVisibleFn)(n.options),hasLearn:!!n.learn,learnTimeout:n.learnTimeout}),this.#k.set(r,n));this.#P({actions:t})}_getAllActions(){return Array.from(this.#I.values()).map((e=>({id:e.id,actionId:e.actionId,controlId:e.controlId,options:e.options})))}subscribeActions(e){let t=Array.from(this.#I.values());const r=new Set(e);r.size&&(t=t.filter((e=>r.has(e.actionId))));for(const e of t){const t=this.#k.get(e.actionId);if(t?.subscribe){const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.subscribe(n(e),r)).catch((t=>{this.#w("error",`Action subscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}unsubscribeActions(e){let t=Array.from(this.#I.values());const r=new Set(e);r.size&&(t=t.filter((e=>r.has(e.actionId))));for(const e of t){const t=this.#k.get(e.actionId);if(t&&t.unsubscribe){const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.unsubscribe(n(e),r)).catch((t=>{this.#w("error",`Action unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}}},2557:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInstanceBaseProps=t.serializeIsVisibleFn=void 0,t.serializeIsVisibleFn=function(e){return(e??[]).map((e=>"isVisible"in e&&"function"==typeof e.isVisible?{...e,isVisibleFn:e.isVisible.toString(),isVisible:void 0}:{...e,isVisibleFn:void 0}))},t.isInstanceBaseProps=function(e){const t=e;return"object"==typeof t&&"string"==typeof t.id&&!0===t._isInstanceBaseProps}},7550:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeedbackManager=void 0;const s=r(7582),n=r(2557),o=s.__importDefault(r(3453));function i(e,t){return{type:e,id:t.id,feedbackId:t.feedbackId,controlId:t.controlId,options:t.options}}t.FeedbackManager=class{#S;#T;#E;#w;#O=new Map;#C=new Map;#A=new Map;#j=new Map;#M;get parseVariablesContext(){return this.#M}constructor(e,t,r,s){this.#S=e,this.#T=t,this.#E=r,this.#w=s}getDefinitionIds(){return Array.from(this.#O.keys())}getInstanceIds(){return Array.from(this.#C.keys())}handleUpdateFeedbacks(e){for(const[t,r]of Object.entries(e)){const e=this.#C.get(t);if(e){const t=this.#O.get(e.feedbackId);if(t?.unsubscribe){const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.unsubscribe(i(t.type,e),r)).catch((t=>{this.#w("error",`Feedback unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}if(!r||r.disabled)this.#C.delete(t);else{this.#C.set(t,{...r,referencedVariables:null});const e=this.#O.get(r.feedbackId);if(e?.subscribe){const t={parseVariablesInString:async e=>(await this.#S({text:e,controlId:r.controlId,actionInstanceId:void 0,feedbackInstanceId:r.id})).text};Promise.resolve(e.subscribe(i(e.type,r),t)).catch((e=>{this.#w("error",`Feedback subscribe failed: ${JSON.stringify(r)} - ${e?.message??e} ${e?.stack}`)}))}this.#R(t)}}}async handleLearnFeedback(e){const t=this.#O.get(e.feedback.feedbackId);if(t&&t.learn){const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.feedback.controlId,actionInstanceId:void 0,feedbackInstanceId:e.feedback.id})).text};return{options:await t.learn({id:e.feedback.id,feedbackId:e.feedback.feedbackId,controlId:e.feedback.controlId,options:e.feedback.options,type:t.type},r)}}return{options:void 0}}handleVariablesChanged(e){if(!e.variablesIds.length)return;const t=new Set(e.variablesIds);for(const t of this.#j.values())for(const r of e.variablesIds)t.changedVariables.add(r);const r=new Set;for(const e of this.#C.values())if(!this.#j.has(e.id)&&e.referencedVariables)for(const s of e.referencedVariables)if(t.has(s)){r.add(e.id);break}for(const e of r)setImmediate((()=>{this.#R(e)}))}#R(e){const t=this.#j.get(e);if(t)return void(t.needsRecheck=!0);const r=this.#C.get(e);if(!r)return;const s=r,n={needsRecheck:!1,changedVariables:new Set};this.#j.set(e,n),Promise.resolve().then((async()=>{const t=this.#O.get(s.feedbackId);let r;const n=new Set;if(t){this.#M=`Feedback ${s.feedbackId} (${e})`;const o={parseVariablesInString:async t=>{const r=await this.#S({text:t,controlId:s.controlId,actionInstanceId:void 0,feedbackInstanceId:e});if(r.variableIds&&r.variableIds.length)for(const e of r.variableIds)n.add(e);return r.text}};r="boolean"===t.type?t.callback({...i("boolean",s),type:"boolean"},o):t.callback({...i("advanced",s),type:"advanced",image:s.image},o),this.#M=void 0}const o=await r;this.#A.set(e,{id:e,controlId:s.controlId,value:o}),this.#D(),s.referencedVariables=n.size>0?Array.from(n):null})).catch((e=>{console.error(`Feedback check failed: ${JSON.stringify(s)} - ${e?.message??e} ${e?.stack}`)})).finally((()=>{this.#M=void 0,this.#j.delete(e);let t=!1;if(s.referencedVariables)for(const e of s.referencedVariables)if(n.changedVariables.has(e)){t=!0;break}(t||n.needsRecheck)&&setImmediate((()=>{this.#R(e)}))}))}#D=(0,o.default)((()=>{const e=this.#A;this.#A=new Map,e.size>0&&this.#T({values:Array.from(e.values())})}),{wait:5,maxWait:25});setFeedbackDefinitions(e){const t=[];this.#O.clear();for(const[r,s]of Object.entries(e))s&&(t.push({id:r,name:s.name,description:s.description,options:(0,n.serializeIsVisibleFn)(s.options),type:s.type,defaultStyle:"boolean"===s.type?s.defaultStyle:void 0,hasLearn:!!s.learn,learnTimeout:s.learnTimeout,showInvert:"boolean"===s.type&&s.showInvert}),this.#O.set(r,s));this.#E({feedbacks:t})}checkFeedbacks(e){const t=new Set(e);for(const[e,r]of this.#C.entries())this.#O.get(r.feedbackId)&&(0===t.size||t.has(r.feedbackId))&&this.#R(e)}checkFeedbacksById(e){for(const t of e)this.#R(t)}_getAllFeedbacks(){return Array.from(this.#C.values()).map((e=>({id:e.id,feedbackId:e.feedbackId,controlId:e.controlId,options:e.options})))}subscribeFeedbacks(e){let t=Array.from(this.#C.values());const r=new Set(e);r.size&&(t=t.filter((e=>r.has(e.feedbackId))));for(const e of t){const t=this.#O.get(e.feedbackId);if(t?.subscribe){const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.subscribe(i(t.type,e),r)).catch((t=>{this.#w("error",`Feedback subscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}unsubscribeFeedbacks(e){let t=Array.from(this.#C.values());const r=new Set(e);r.size&&(t=t.filter((e=>r.has(e.feedbackId))));for(const e of t){const t=this.#O.get(e.feedbackId);if(t&&t.unsubscribe){const r={parseVariablesInString:async t=>(await this.#S({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.unsubscribe(i(t.type,e),r)).catch((t=>{this.#w("error",`Feedback unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}}},1806:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runThroughUpgradeScripts=void 0;const s=r(2068);function n(e){return JSON.parse(JSON.stringify(e))}t.runThroughUpgradeScripts=function(e,t,r,o,i,a){const p=new Map,d=e=>{let t=p.get(e);return t||(t={actions:[],feedbacks:[],config:!1},p.set(e,t)),t};for(const t of Object.values(e)){const e=t?.upgradeIndex??r;t&&"number"==typeof e&&d(e).actions.push(t.id)}for(const e of Object.values(t)){const t=e?.upgradeIndex??r;e&&"number"==typeof t&&d(t).feedbacks.push(e.id)}if(!a)for(let e=r??-1;e0){const a=Array.from(p.keys()).sort(),d=Math.min(...a,r??-1)+1,m=[],y=[],f=o.length;for(let r=d;r{const r=e[t];if(r)return(0,s.literal)({id:r.id,controlId:r.controlId,actionId:r.actionId,options:void 0!==r.options?n(r.options):{}})})).filter((e=>!!e)),feedbacks:y.map((e=>{const r=t[e];if(r)return(0,s.literal)({id:r.id,controlId:r.controlId,feedbackId:r.feedbackId,options:void 0!==r.options?n(r.options):{},isInverted:r.isInverted})})).filter((e=>!!e))});d&&h.updatedConfig&&(l=h.updatedConfig);for(const t of h.updatedActions)if(t){const r=e[t.id];r&&(r.actionId=t.actionId,r.options=t.options,u[t.id]=r)}for(const e of h.updatedFeedbacks)if(e){const r=t[e.id];r&&(r.feedbackId=e.feedbackId,r.options=e.options,c[e.id]={...r,style:c[e.id]?.style??e.style,isInverted:e.isInverted??!1})}}for(const[t,r]of Object.entries(e))u[t]||"number"!=typeof r?.upgradeIndex||(u[t]=r);for(const[e,r]of Object.entries(t))c[e]||"number"!=typeof r?.upgradeIndex||(c[e]=r)}return{updatedActions:u,updatedFeedbacks:c,updatedConfig:l}}},7517:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateManifest=void 0;const s=r(7582).__importDefault(r(4618));t.validateManifest=function(e){const t=JSON.stringify(e);if(t.includes("companion-module-your-module-name"))throw new Error("Manifest incorrectly references template module 'companion-module-your-module-name'");if(t.includes("module-shortname"))throw new Error("Manifest incorrectly references template module 'module-shortname'");if(t.includes("A short one line description of your module"))throw new Error("Manifest incorrectly references template module 'A short one line description of your module'");if(t.includes("Your name"))throw new Error("Manifest incorrectly references template module 'Your name'");if(t.includes("Your email"))throw new Error("Manifest incorrectly references template module 'Your email'");if(t.includes("Your company"))throw new Error("Manifest incorrectly references template module 'Your company'");if(t.includes("Your product"))throw new Error("Manifest incorrectly references template module 'Your product'");if(!(0,s.default)(e)){const e=s.default.errors;if(!e)throw new Error("Manifest failed validation with unknown reason");throw new Error(`Manifest validation failed: ${JSON.stringify(e)}`)}}},8322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5203:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceBase=void 0;const s=r(7582),n=r(2068),o=s.__importDefault(r(5860)),i=r(2557),a=r(1806),p=r(7550),d=r(8221),c=r(4391),u=r(9509);t.InstanceBase=class{#L;#U;id;#V=new o.default({concurrency:1});#F=!1;#$=!1;#B={};#W;#G;#H=new Map;#z=new Map;#J=new Map;#r;#Y;get instanceOptions(){return this.#r}get label(){return this.#Y}constructor(e){if(!(0,i.isInstanceBaseProps)(e)||!e._isInstanceBaseProps)throw new Error("Module instance is being constructed incorrectly. Make sure you aren't trying to do this manually");this.createSharedUdpSocket=this.createSharedUdpSocket.bind(this),this.#r={disableVariableValidation:!1},this.#L=new d.IpcWrapper({init:this._handleInit.bind(this),destroy:this._handleDestroy.bind(this),updateConfigAndLabel:this._handleConfigUpdateAndLabel.bind(this),updateConfig:async()=>{},executeAction:this._handleExecuteAction.bind(this),updateFeedbacks:this._handleUpdateFeedbacks.bind(this),updateActions:this._handleUpdateActions.bind(this),getConfigFields:this._handleGetConfigFields.bind(this),handleHttpRequest:this._handleHttpRequest.bind(this),learnAction:this._handleLearnAction.bind(this),learnFeedback:this._handleLearnFeedback.bind(this),startStopRecordActions:this._handleStartStopRecordActions.bind(this),variablesChanged:this._handleVariablesChanged.bind(this),sharedUdpSocketMessage:this._handleSharedUdpSocketMessage.bind(this),sharedUdpSocketError:this._handleSharedUdpSocketError.bind(this)},(e=>{process.send(e)}),5e3),process.on("message",(e=>{this.#L.receivedMessage(e)})),this.#W=new c.ActionManager((async e=>this.#L.sendWithCb("parseVariablesInString",e)),(e=>this.#L.sendWithNoCb("setActionDefinitions",e)),this.log.bind(this)),this.#G=new p.FeedbackManager((async e=>this.#L.sendWithCb("parseVariablesInString",e)),(e=>this.#L.sendWithNoCb("updateFeedbackValues",e)),(e=>this.#L.sendWithNoCb("setFeedbackDefinitions",e)),this.log.bind(this)),this.#U=e.upgradeScripts,this.id=e.id,this.#Y=e.id,this.log("debug","Initializing")}async _handleInit(e){return this.#V.add((async()=>{if(this.#F)throw new Error("Already initialized");const t=e.actions,r=e.feedbacks;if(this.#B=e.config,this.#Y=e.label,e.isFirstInit){const t={},r=this.getConfigFields();for(const e of r)"default"in e&&(t[e.id]=e.default);this.#B=t,this.saveConfig(this.#B),e.lastUpgradeIndex=this.#U.length-1}const{updatedActions:s,updatedFeedbacks:n,updatedConfig:o}=(0,a.runThroughUpgradeScripts)(t,r,e.lastUpgradeIndex,this.#U,this.#B,!1);this.#B=o??this.#B;const i=this.#L.sendWithCb("upgradedItems",{updatedActions:s,updatedFeedbacks:n});try{await this.init(this.#B,!!e.isFirstInit),this.#F=!0}catch(e){throw console.trace(`Init failed: ${e}`),e}finally{await i}return setImmediate((()=>{this._handleUpdateActions({actions:t},!0).catch((e=>{this.log("error",`Receive actions failed: ${e}`)})),this._handleUpdateFeedbacks({feedbacks:r},!0).catch((e=>{this.log("error",`Receive feedbacks failed: ${e}`)}))})),{hasHttpHandler:"function"==typeof this.handleHttpRequest,hasRecordActionsHandler:"function"==typeof this.handleStartStopRecordActions,newUpgradeIndex:this.#U.length-1,updatedConfig:this.#B}}))}async _handleDestroy(){await this.#V.add((async()=>{if(!this.#F)throw new Error("Not initialized");await this.destroy(),this.#F=!1}))}async _handleConfigUpdateAndLabel(e){await this.#V.add((async()=>{if(!this.#F)throw new Error("Not initialized");this.#Y=e.label,this.#B=e.config,await this.configUpdated(this.#B)}))}async _handleExecuteAction(e){return this.#W.handleExecuteAction(e)}async _handleUpdateFeedbacks(e,t){if(!t){const t=(0,a.runThroughUpgradeScripts)({},e.feedbacks,null,this.#U,this.#B,!0);this.#L.sendWithCb("upgradedItems",{updatedActions:t.updatedActions,updatedFeedbacks:t.updatedFeedbacks}).catch((e=>{this.log("error",`Failed to save upgraded feedbacks: ${e}`)}))}this.#G.handleUpdateFeedbacks(e.feedbacks)}async _handleUpdateActions(e,t){if(!t){const t=(0,a.runThroughUpgradeScripts)(e.actions,{},null,this.#U,this.#B,!0);this.#L.sendWithCb("upgradedItems",{updatedActions:t.updatedActions,updatedFeedbacks:t.updatedFeedbacks}).catch((e=>{this.log("error",`Failed to save upgraded actions: ${e}`)}))}this.#W.handleUpdateActions(e.actions)}async _handleGetConfigFields(e){return{fields:(0,i.serializeIsVisibleFn)(this.getConfigFields())}}async _handleHttpRequest(e){if(!this.handleHttpRequest)throw new Error("handleHttpRequest is not supported!");return{response:await this.handleHttpRequest(e.request)}}async _handleLearnAction(e){return this.#W.handleLearnAction(e)}async _handleLearnFeedback(e){return this.#G.handleLearnFeedback(e)}async _handleStartStopRecordActions(e){if(e.recording){if(this.#$)return}else if(!this.#$)return;if(!this.handleStartStopRecordActions)throw this.#$=!1,new Error("Recording actions is not supported by this module!");this.#$=e.recording,this.handleStartStopRecordActions(this.#$)}async _handleVariablesChanged(e){this.#G.handleVariablesChanged(e)}async _handleSharedUdpSocketMessage(e){for(const t of this.#H.values())t.handleId===e.handleId&&t.receiveSocketMessage(e)}async _handleSharedUdpSocketError(e){for(const t of this.#H.values())t.handleId===e.handleId&&t.receiveSocketError(e.error)}saveConfig(e){this.#B=e,this.#L.sendWithNoCb("saveConfig",{config:e})}setActionDefinitions(e){this.#W.setActionDefinitions(e)}setFeedbackDefinitions(e){this.#G.setFeedbackDefinitions(e)}setPresetDefinitions(e){const t=[];for(const[r,s]of Object.entries(e))s&&t.push({...s,id:r});this.#L.sendWithNoCb("setPresetDefinitions",{presets:t})}setVariableDefinitions(e){const t=[],r=[];this.#z.clear();for(const s of e)t.push({id:s.variableId,name:s.name}),this.#z.set(s.variableId,s),this.#J.has(s.variableId)||(this.#J.set(s.variableId,""),r.push({id:s.variableId,value:""}));if(!this.#r.disableVariableValidation){const e=new Set(this.#z.keys());for(const t of this.#J.keys())e.has(t)||(this.#J.delete(t),r.push({id:t,value:void 0}))}this.#L.sendWithNoCb("setVariableDefinitions",{variables:t,newValues:r})}setVariableValues(e){const t=[];for(const[r,s]of Object.entries(e))this.#r.disableVariableValidation?(void 0===s?this.#J.delete(r):this.#J.set(r,s),t.push({id:r,value:s})):this.#z.has(r)?(this.#J.set(r,s??""),t.push({id:r,value:s??""})):t.push({id:r,value:void 0});this.#L.sendWithNoCb("setVariableValues",{newValues:t})}getVariableValue(e){return this.#J.get(e)}async parseVariablesInString(e){const t=this.#G.parseVariablesContext;return t&&this.log("debug",`parseVariablesInString called while in: ${t}. You should use the parseVariablesInString provided to the callback instead`),(await this.#L.sendWithCb("parseVariablesInString",{text:e,controlId:void 0,actionInstanceId:void 0,feedbackInstanceId:void 0})).text}checkFeedbacks(...e){this.#G.checkFeedbacks(e)}checkFeedbacksById(...e){this.#G.checkFeedbacksById(e)}_getAllActions(){return this.#W._getAllActions()}subscribeActions(...e){this.#W.subscribeActions(e)}unsubscribeActions(...e){this.#W.unsubscribeActions(e)}_getAllFeedbacks(){return this.#G._getAllFeedbacks()}subscribeFeedbacks(...e){this.#G.subscribeFeedbacks(e)}unsubscribeFeedbacks(...e){this.#G.unsubscribeFeedbacks(e)}recordAction(e,t){if(!this.#$)throw new Error("Not currently recording actions");this.#L.sendWithNoCb("recordAction",{uniquenessId:t??null,actionId:e.actionId,options:e.options,delay:e.delay})}setCustomVariableValue(e,t){this.#L.sendWithNoCb("setCustomVariable",{customVariableId:e,value:t})}oscSend(e,t,r,s){this.#L.sendWithNoCb("send-osc",(0,n.literal)({host:e,port:t,path:r,args:s}))}updateStatus(e,t){this.#L.sendWithNoCb("set-status",(0,n.literal)({status:e,message:t??null}))}log(e,t){this.#L.sendWithNoCb("log-message",(0,n.literal)({level:e,message:t}))}createSharedUdpSocket(e,t){const r="string"==typeof e?{type:e}:e,s=new u.SharedUdpSocketImpl(this.#L,this.#H,r);return t&&s.on("message",t),s}}},9051:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},609:(e,t)=>{"use strict";var r,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Regex=t.InstanceStatus=void 0,function(e){e.Ok="ok",e.Connecting="connecting",e.Disconnected="disconnected",e.ConnectionFailure="connection_failure",e.BadConfig="bad_config",e.UnknownError="unknown_error",e.UnknownWarning="unknown_warning",e.AuthenticationFailure="authentication_failure"}(r||(t.InstanceStatus=r={})),function(e){e.IP="/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/",e.HOSTNAME="/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/",e.BOOLEAN="/^(true|false|0|1)$/i",e.PORT="/^([1-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-4])$/",e.MAC_ADDRESS="/^(?:[a-fA-F0-9]{2}:){5}([a-fA-F0-9]{2})$/",e.PERCENT="/^(100|[0-9]|[0-9][0-9])$/",e.FLOAT="/^([0-9]*\\.)?[0-9]+$/",e.SIGNED_FLOAT="/^[+-]?([0-9]*\\.)?[0-9]+$/",e.FLOAT_OR_INT="/^([0-9]+)(\\.[0-9]+)?$/",e.NUMBER="/^\\d+$/",e.SIGNED_NUMBER="/^[+-]?\\d+$/",e.SOMETHING="/^.+$/",e.TIMECODE="/^(0*[0-9]|1[0-9]|2[0-4]):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[12][0-9]|30)$/"}(s||(t.Regex=s={}))},4334:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2490:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4911:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(7582);s.__exportStar(r(8322),t),s.__exportStar(r(5203),t),s.__exportStar(r(9051),t),s.__exportStar(r(609),t),s.__exportStar(r(4334),t),s.__exportStar(r(2490),t),s.__exportStar(r(3646),t),s.__exportStar(r(3558),t),s.__exportStar(r(4788),t),s.__exportStar(r(521),t),s.__exportStar(r(6870),t)},3646:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},9509:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharedUdpSocketImpl=void 0;const s=r(7582).__importDefault(r(6729)),n=r(2068);class o extends s.default{#L;#Q;#r;get handleId(){return this.boundState?.handleId}get portNumber(){return this.boundState?.portNumber}get boundState(){return this.#f&&"object"==typeof this.#f?this.#f:void 0}#f="pending";constructor(e,t,r){super(),this.#L=e,this.#Q=t,this.#r={...r}}bind(e,t,r){if(this.#f&&"object"==typeof this.#f)throw new Error("Socket is already bound");switch(this.#f){case"fatalError":throw new Error("Socket has encountered fatal error");case"binding":throw new Error("Socket is already bound");case"closed":throw new Error("Socket is closing");case"pending":break;default:throw(0,n.assertNever)(this.#f),new Error("Invalid socket state")}this.#f="binding",r&&this.on("listening",r),this.#L.sendWithCb("sharedUdpSocketJoin",{family:this.#r.type,portNumber:e}).then((t=>{this.#f={portNumber:e,handleId:t},this.#Q.set(t,this),this.emit("listening")}),(e=>{this.#f="closed",this.emit("error",e instanceof Error?e:new Error(e))})).catch((()=>null))}close(e){if(this.#f&&"object"==typeof this.#f);else switch(this.#f){case"fatalError":throw new Error("Socket has encountered fatal error");case"pending":case"closed":case"binding":throw new Error("Socket is not open");default:throw(0,n.assertNever)(this.#f),new Error("Invalid socket state")}const t=this.#f.handleId;this.#f="closed",e&&this.on("close",e),this.#L.sendWithCb("sharedUdpSocketLeave",{handleId:t}).then((()=>{this.#Q.delete(t),this.emit("close")}),(e=>{this.#Q.delete(t),this.emit("error",e instanceof Error?e:new Error(e))})).catch((()=>null))}send(e,t,r,s,n,o){if("number"!=typeof t)throw new Error("Invalid arguments");if("number"==typeof r){if("number"!=typeof s||"string"!=typeof n)throw new Error("Invalid arguments");if(void 0!==o&&"number"!=typeof o)throw new Error("Invalid arguments");const i=this.#K(e,t,r);this.#X(i,s,n,o)}else{if("string"!=typeof r)throw new Error("Invalid arguments");{if(void 0!==s&&"function"!=typeof s)throw new Error("Invalid arguments");const n=this.#K(e,0,void 0);this.#X(n,t,r,s)}}}#K(e,t,r){let s;if("string"==typeof e)s=Buffer.from(e,"utf-8");else if(Buffer.isBuffer(e))s=e;else{if(Array.isArray(e))return Buffer.from(e);s=Buffer.from(e.buffer,e.byteOffset,e.byteLength)}return s.subarray(t,void 0!==r?r+t:void 0)}#X(e,t,r,s){if(!this.#f||"object"!=typeof this.#f)throw new Error("Socket is not open");this.#L.sendWithCb("sharedUdpSocketSend",{handleId:this.#f.handleId,message:e,address:r,port:t}).then((()=>{s?.()}),(e=>{this.emit("error",e instanceof Error?e:new Error(e))})).catch((()=>null))}receiveSocketMessage(e){try{this.emit("message",e.message,e.source)}catch(e){}}receiveSocketError(e){this.#f="fatalError";const t=this.boundState;t&&this.#Q.delete(t.handleId);try{this.emit("error",e)}catch(e){}}}t.SharedUdpSocketImpl=o},4788:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},521:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateUseBuiltinInvertForFeedbacksUpgradeScript=t.CreateConvertToBooleanFeedbackUpgradeScript=t.EmptyUpgradeScript=void 0,t.EmptyUpgradeScript=()=>({updatedConfig:null,updatedActions:[],updatedFeedbacks:[]}),t.CreateConvertToBooleanFeedbackUpgradeScript=function(e){return(t,r)=>{const s=[];for(const t of r.feedbacks){let r=e[t.feedbackId];if(!0===r&&(r={bg:"bgcolor",bgcolor:"bgcolor",fg:"color",color:"color",png64:"png64",png:"png64"}),r){t.style||(t.style={});for(const[e,n]of Object.entries(r))void 0!==t.options[e]&&(t.style[n]=t.options[e],delete t.options[e],s.push(t))}}return{updatedConfig:null,updatedActions:[],updatedFeedbacks:s}}},t.CreateUseBuiltinInvertForFeedbacksUpgradeScript=function(e){return(t,r)=>{const s=[];for(const t of r.feedbacks){const r=e[t.feedbackId];if("string"!=typeof r)continue;const n=t.options[r];void 0!==n&&(delete t.options[r],t.isInverted="true"===n||!0===n||Number(n)>0,s.push(t))}return{updatedConfig:null,updatedActions:[],updatedFeedbacks:s}}}},6870:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2068:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitHex=t.splitHsv=t.splitHsl=t.splitRgb=t.combineRgb=t.assertNever=t.literal=void 0;const s=r(6872);function n(e){if("number"==typeof e)return e>16777215?{r:e>>16&255,g:e>>8&255,b:255&e,a:(255-(e>>24&255))/255}:{r:e>>16&255,g:e>>8&255,b:255&e,a:1};if("string"==typeof e&&(0,s.colord)(e).isValid()){const t=(0,s.colord)(e).toRgb();return{r:t.r,g:t.g,b:t.b,a:t.a}}return{r:0,g:0,b:0,a:1}}t.literal=function(e){return e},t.assertNever=function(e){},t.combineRgb=function(e,t,r,s){let n=(255&e)<<16|(255&t)<<8|255&r;return s&&s>=0&&s<1&&(n+=16777216*Math.round(255*(1-s))),n},t.splitRgb=n,t.splitHsl=function(e){const t=n(e);return(0,s.colord)(`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a})`).toHsl()},t.splitHsv=function(e){const t=n(e);return(0,s.colord)(`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a})`).toHsv()},t.splitHex=function(e){const t=n(e);return(0,s.colord)(`rgba(${t.r}, ${t.g}, ${t.b}, ${t.a})`).toHex()}},4618:(e,t,r)=>{"use strict";e.exports=p,e.exports.default=p;const s={$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"ModuleManifest",properties:{$schema:{type:"string"},id:{type:"string",description:"Unique identifier for the module"},name:{type:"string",description:"Name of the module"},shortname:{type:"string"},description:{type:"string",description:"Description of the module "},version:{type:"string",description:"Current version of the module"},license:{type:"string",description:"SPDX identifier for license of the module"},repository:{type:"string",description:"URL to the source repository"},bugs:{type:"string",description:"URL to bug tracker"},maintainers:{type:"array",description:"List of active maintiners",uniqueItems:!0,items:{type:"object",title:"ModuleManifestMaintainer",properties:{name:{type:"string"},email:{type:"string"},github:{type:"string"}},required:["name"]}},legacyIds:{type:"array",description:"If the module had a different unique identifier previously, then specify it here",uniqueItems:!0,items:{type:"string"}},runtime:{type:"object",title:"ModuleManifestRuntime",description:"Information on how to execute the module",properties:{type:{type:"string",description:"Type of the module. Must be: node18"},api:{type:"string",description:"Which host-api does it use. In the future alternate options will be allowed",enum:["nodejs-ipc"]},apiVersion:{type:"string",description:"The version of the host-api used"},entrypoint:{type:"string",description:"Entrypoint to pass to the runtime. eg index.js"}},required:["type","api","apiVersion","entrypoint"]},manufacturer:{type:"string"},products:{type:"array",uniqueItems:!0,items:{type:"string"},minItems:1},keywords:{type:"array",uniqueItems:!0,items:{type:"string"}},bonjourQueries:{type:"object",description:"If the device or software for your module supports bonjour announcements, Companion will offer an easy way to watch for these announcements.\nEach query you define must have a matching config field of type 'bonjour-device' with the same name",patternProperties:{"":{oneOf:[{$ref:"#/definitions/bonjourQuery"},{type:"array",items:{$ref:"#/definitions/bonjourQuery"}}]}},additionalProperties:!1}},additionalProperties:!1,required:["id","name","shortname","description","version","license","repository","bugs","maintainers","legacyIds","runtime","manufacturer","products","keywords"],definitions:{bonjourQuery:{type:"object",title:"ModuleBonjourQuery",description:"",properties:{type:{type:"string"},protocol:{type:"string",enum:["tcp","udp"]},txt:{type:"object",description:"Match on any txt values returned in the query. This is useful to filter out devices of the same 'type' that are not supported",patternProperties:{"":{type:"string"}},additionalProperties:!1}},required:["type","protocol"],additionalProperties:!1}}},n={type:"object",title:"ModuleBonjourQuery",description:"",properties:{type:{type:"string"},protocol:{type:"string",enum:["tcp","udp"]},txt:{type:"object",description:"Match on any txt values returned in the query. This is useful to filter out devices of the same 'type' that are not supported",patternProperties:{"":{type:"string"}},additionalProperties:!1}},required:["type","protocol"],additionalProperties:!1},o=Object.prototype.hasOwnProperty,i=r(7056).Z,a=new RegExp("","u");function p(e,{instancePath:t="",parentData:r,parentDataProperty:d,rootData:c=e}={}){let u=null,l=0;if(0===l){if(!e||"object"!=typeof e||Array.isArray(e))return p.errors=[{instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let r;if(void 0===e.id&&(r="id")||void 0===e.name&&(r="name")||void 0===e.shortname&&(r="shortname")||void 0===e.description&&(r="description")||void 0===e.version&&(r="version")||void 0===e.license&&(r="license")||void 0===e.repository&&(r="repository")||void 0===e.bugs&&(r="bugs")||void 0===e.maintainers&&(r="maintainers")||void 0===e.legacyIds&&(r="legacyIds")||void 0===e.runtime&&(r="runtime")||void 0===e.manufacturer&&(r="manufacturer")||void 0===e.products&&(r="products")||void 0===e.keywords&&(r="keywords"))return p.errors=[{instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:r},message:"must have required property '"+r+"'"}],!1;{const r=l;for(const r in e)if(!o.call(s.properties,r))return p.errors=[{instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:r},message:"must NOT have additional properties"}],!1;if(r===l){if(void 0!==e.$schema){const r=l;if("string"!=typeof e.$schema)return p.errors=[{instancePath:t+"/$schema",schemaPath:"#/properties/%24schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var m=r===l}else m=!0;if(m){if(void 0!==e.id){const r=l;if("string"!=typeof e.id)return p.errors=[{instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.name){const r=l;if("string"!=typeof e.name)return p.errors=[{instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.shortname){const r=l;if("string"!=typeof e.shortname)return p.errors=[{instancePath:t+"/shortname",schemaPath:"#/properties/shortname/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.description){const r=l;if("string"!=typeof e.description)return p.errors=[{instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.version){const r=l;if("string"!=typeof e.version)return p.errors=[{instancePath:t+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.license){const r=l;if("string"!=typeof e.license)return p.errors=[{instancePath:t+"/license",schemaPath:"#/properties/license/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.repository){const r=l;if("string"!=typeof e.repository)return p.errors=[{instancePath:t+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.bugs){const r=l;if("string"!=typeof e.bugs)return p.errors=[{instancePath:t+"/bugs",schemaPath:"#/properties/bugs/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.maintainers){let r=e.maintainers;const s=l;if(l===s){if(!Array.isArray(r))return p.errors=[{instancePath:t+"/maintainers",schemaPath:"#/properties/maintainers/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var y=!0;const e=r.length;for(let s=0;s1)for(;s--;)for(e=s;e--;)if(i(r[s],r[e]))return p.errors=[{instancePath:t+"/maintainers",schemaPath:"#/properties/maintainers/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1}}}m=s===l}else m=!0;if(m){if(void 0!==e.legacyIds){let r=e.legacyIds;const s=l;if(l===s){if(!Array.isArray(r))return p.errors=[{instancePath:t+"/legacyIds",schemaPath:"#/properties/legacyIds/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var h=!0;const e=r.length;for(let s=0;s1){const n={};for(;s--;){let o=r[s];if("string"==typeof o){if("number"==typeof n[o])return e=n[o],p.errors=[{instancePath:t+"/legacyIds",schemaPath:"#/properties/legacyIds/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;n[o]=s}}}}}}m=s===l}else m=!0;if(m){if(void 0!==e.runtime){let r=e.runtime;const n=l;if(l===n){if(!r||"object"!=typeof r||Array.isArray(r))return p.errors=[{instancePath:t+"/runtime",schemaPath:"#/properties/runtime/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let e;if(void 0===r.type&&(e="type")||void 0===r.api&&(e="api")||void 0===r.apiVersion&&(e="apiVersion")||void 0===r.entrypoint&&(e="entrypoint"))return p.errors=[{instancePath:t+"/runtime",schemaPath:"#/properties/runtime/required",keyword:"required",params:{missingProperty:e},message:"must have required property '"+e+"'"}],!1;if(void 0!==r.type){const e=l;if("string"!=typeof r.type)return p.errors=[{instancePath:t+"/runtime/type",schemaPath:"#/properties/runtime/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var _=e===l}else _=!0;if(_){if(void 0!==r.api){let e=r.api;const n=l;if("string"!=typeof e)return p.errors=[{instancePath:t+"/runtime/api",schemaPath:"#/properties/runtime/properties/api/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if("nodejs-ipc"!==e)return p.errors=[{instancePath:t+"/runtime/api",schemaPath:"#/properties/runtime/properties/api/enum",keyword:"enum",params:{allowedValues:s.properties.runtime.properties.api.enum},message:"must be equal to one of the allowed values"}],!1;_=n===l}else _=!0;if(_){if(void 0!==r.apiVersion){const e=l;if("string"!=typeof r.apiVersion)return p.errors=[{instancePath:t+"/runtime/apiVersion",schemaPath:"#/properties/runtime/properties/apiVersion/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;_=e===l}else _=!0;if(_)if(void 0!==r.entrypoint){const e=l;if("string"!=typeof r.entrypoint)return p.errors=[{instancePath:t+"/runtime/entrypoint",schemaPath:"#/properties/runtime/properties/entrypoint/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;_=e===l}else _=!0}}}}m=n===l}else m=!0;if(m){if(void 0!==e.manufacturer){const r=l;if("string"!=typeof e.manufacturer)return p.errors=[{instancePath:t+"/manufacturer",schemaPath:"#/properties/manufacturer/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;m=r===l}else m=!0;if(m){if(void 0!==e.products){let r=e.products;const s=l;if(l===s){if(!Array.isArray(r))return p.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;if(r.length<1)return p.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var b=!0;const e=r.length;for(let s=0;s1){const n={};for(;s--;){let o=r[s];if("string"==typeof o){if("number"==typeof n[o])return e=n[o],p.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;n[o]=s}}}}}}m=s===l}else m=!0;if(m){if(void 0!==e.keywords){let r=e.keywords;const s=l;if(l===s){if(!Array.isArray(r))return p.errors=[{instancePath:t+"/keywords",schemaPath:"#/properties/keywords/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var g=!0;const e=r.length;for(let s=0;s1){const n={};for(;s--;){let o=r[s];if("string"==typeof o){if("number"==typeof n[o])return e=n[o],p.errors=[{instancePath:t+"/keywords",schemaPath:"#/properties/keywords/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;n[o]=s}}}}}}m=s===l}else m=!0;if(m)if(void 0!==e.bonjourQueries){let r=e.bonjourQueries;const s=l;if(l===s){if(!r||"object"!=typeof r||Array.isArray(r))return p.errors=[{instancePath:t+"/bonjourQueries",schemaPath:"#/properties/bonjourQueries/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{const e=l;for(const e in r)if(!a.test(e))return p.errors=[{instancePath:t+"/bonjourQueries",schemaPath:"#/properties/bonjourQueries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:e},message:"must NOT have additional properties"}],!1;if(e===l)for(const e in r)if(a.test(e)){let s=r[e];const o=l,i=l;let d=!1,c=null;const m=l;if(l==l)if(s&&"object"==typeof s&&!Array.isArray(s)){let r;if(void 0===s.type&&(r="type")||void 0===s.protocol&&(r="protocol")){const s={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/definitions/bonjourQuery/required",keyword:"required",params:{missingProperty:r},message:"must have required property '"+r+"'"};null===u?u=[s]:u.push(s),l++}else{const r=l;for(const r in s)if("type"!==r&&"protocol"!==r&&"txt"!==r){const s={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/definitions/bonjourQuery/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:r},message:"must NOT have additional properties"};null===u?u=[s]:u.push(s),l++;break}if(r===l){if(void 0!==s.type){const r=l;if("string"!=typeof s.type){const r={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/type",schemaPath:"#/definitions/bonjourQuery/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};null===u?u=[r]:u.push(r),l++}var v=r===l}else v=!0;if(v){if(void 0!==s.protocol){let r=s.protocol;const o=l;if("string"!=typeof r){const r={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/protocol",schemaPath:"#/definitions/bonjourQuery/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};null===u?u=[r]:u.push(r),l++}if("tcp"!==r&&"udp"!==r){const r={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/protocol",schemaPath:"#/definitions/bonjourQuery/properties/protocol/enum",keyword:"enum",params:{allowedValues:n.properties.protocol.enum},message:"must be equal to one of the allowed values"};null===u?u=[r]:u.push(r),l++}v=o===l}else v=!0;if(v)if(void 0!==s.txt){let r=s.txt;const n=l;if(l===n)if(r&&"object"==typeof r&&!Array.isArray(r)){const s=l;for(const s in r)if(!a.test(s)){const r={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/txt",schemaPath:"#/definitions/bonjourQuery/properties/txt/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:s},message:"must NOT have additional properties"};null===u?u=[r]:u.push(r),l++;break}if(s===l)for(const s in r)if(a.test(s)){const n=l;if("string"!=typeof r[s]){const r={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/txt/"+s.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/definitions/bonjourQuery/properties/txt/patternProperties//type",keyword:"type",params:{type:"string"},message:"must be string"};null===u?u=[r]:u.push(r),l++}if(n!==l)break}}else{const r={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1")+"/txt",schemaPath:"#/definitions/bonjourQuery/properties/txt/type",keyword:"type",params:{type:"object"},message:"must be object"};null===u?u=[r]:u.push(r),l++}v=n===l}else v=!0}}}}else{const r={instancePath:t+"/bonjourQueries/"+e.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/definitions/bonjourQuery/type",keyword:"type",params:{type:"object"},message:"must be object"};null===u?u=[r]:u.push(r),l++}m===l&&(d=!0,c=0);const y=l;if(l===y)if(Array.isArray(s)){const r=s.length;for(let o=0;o{"use strict";const s=r(4341);e.exports=(e,t={})=>{if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:r=0,maxWait:n=0,before:o=!1,after:i=!0}=t;if(!o&&!i)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,p,d;const c=function(...t){const s=this,c=o&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,p&&(clearTimeout(p),p=void 0),i&&(d=e.apply(s,t))}),r),n>0&&!p&&i&&(p=setTimeout((()=>{p=void 0,a&&(clearTimeout(a),a=void 0),d=e.apply(s,t)}),n)),c&&(d=e.apply(s,t)),d};return s(c,e),c.cancel=()=>{a&&(clearTimeout(a),a=void 0),p&&(clearTimeout(p),p=void 0)},c}},7582:(e,t,r)=>{"use strict";r.r(t),r.d(t,{__addDisposableResource:()=>j,__assign:()=>o,__asyncDelegator:()=>P,__asyncGenerator:()=>S,__asyncValues:()=>w,__await:()=>x,__awaiter:()=>y,__classPrivateFieldGet:()=>O,__classPrivateFieldIn:()=>A,__classPrivateFieldSet:()=>C,__createBinding:()=>h,__decorate:()=>a,__disposeResources:()=>R,__esDecorate:()=>d,__exportStar:()=>_,__extends:()=>n,__generator:()=>f,__importDefault:()=>E,__importStar:()=>T,__makeTemplateObject:()=>k,__metadata:()=>m,__param:()=>p,__propKey:()=>u,__read:()=>g,__rest:()=>i,__runInitializers:()=>c,__setFunctionName:()=>l,__spread:()=>v,__spreadArray:()=>N,__spreadArrays:()=>q,__values:()=>b,default:()=>D});var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},s(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return o=Object.assign||function(e){for(var t,r=1,s=arguments.length;r=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}function p(e,t){return function(r,s){t(r,s,e)}}function d(e,t,r,s,n,o){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,p=s.kind,d="getter"===p?"get":"setter"===p?"set":"value",c=!t&&e?s.static?e:e.prototype:null,u=t||(c?Object.getOwnPropertyDescriptor(c,s.name):{}),l=!1,m=r.length-1;m>=0;m--){var y={};for(var f in s)y[f]="access"===f?{}:s[f];for(var f in s.access)y.access[f]=s.access[f];y.addInitializer=function(e){if(l)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(e||null))};var h=(0,r[m])("accessor"===p?{get:u.get,set:u.set}:u[d],y);if("accessor"===p){if(void 0===h)continue;if(null===h||"object"!=typeof h)throw new TypeError("Object expected");(a=i(h.get))&&(u.get=a),(a=i(h.set))&&(u.set=a),(a=i(h.init))&&n.unshift(a)}else(a=i(h))&&("field"===p?n.unshift(a):u[d]=a)}c&&Object.defineProperty(c,s.name,u),l=!0}function c(e,t,r){for(var s=arguments.length>2,n=0;n0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var s,n,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(s=o.next()).done;)i.push(s.value)}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}function v(){for(var e=[],t=0;t1||a(e,t)}))},t&&(s[e]=t(s[e])))}function a(e,t){try{(r=n[e](t)).value instanceof x?Promise.resolve(r.value.v).then(p,d):c(o[0][2],r)}catch(e){c(o[0][3],e)}var r}function p(e){a("next",e)}function d(e){a("throw",e)}function c(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function P(e){var t,r;return t={},s("next"),s("throw",(function(e){throw e})),s("return"),t[Symbol.iterator]=function(){return this},t;function s(s,n){t[s]=e[s]?function(t){return(r=!r)?{value:x(e[s](t)),done:!1}:n?n(t):t}:n}}function w(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=b(e),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(r){t[r]=e[r]&&function(t){return new Promise((function(s,n){!function(e,t,r,s){Promise.resolve(s).then((function(t){e({value:t,done:r})}),t)}(s,n,(t=e[r](t)).done,t.value)}))}}}function k(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var I=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function T(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&h(t,e,r);return I(t,e),t}function E(e){return e&&e.__esModule?e:{default:e}}function O(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)}function C(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r}function A(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function j(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(void 0===s){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(n=s)}if("function"!=typeof s)throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}var M="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s};function R(e){function t(t){e.error=e.hasError?new M(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,s=0;return function n(){for(;r=e.stack.pop();)try{if(!r.async&&1===s)return s=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(o).then(n,(function(e){return t(e),n()}))}else s|=1}catch(e){t(e)}if(1===s)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}const D={__extends:n,__assign:o,__rest:i,__decorate:a,__param:p,__metadata:m,__awaiter:y,__generator:f,__createBinding:h,__exportStar:_,__values:b,__read:g,__spread:v,__spreadArrays:q,__spreadArray:N,__await:x,__asyncGenerator:S,__asyncDelegator:P,__asyncValues:w,__makeTemplateObject:k,__importStar:T,__importDefault:E,__classPrivateFieldGet:O,__classPrivateFieldSet:C,__classPrivateFieldIn:A,__addDisposableResource:j,__disposeResources:R}},5721:e=>{"use strict";e.exports=JSON.parse('{"audiomixer.channel":[{"pretty_name":"Add empty audio channel","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.add","requestParams":[],"responseParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}]},{"pretty_name":"Delete audio channel","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.delete","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[]},{"pretty_name":"Duplicate audio channel","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.duplicate","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}]},{"pretty_name":"Get channel gain","doc_request_description":"","doc_response_description":"","requestType":"audiomixer.channel.gain.get","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"gain","property":"optional","range":{"min":0,"max":40},"prettyName":"Linear gain","type":"number"},{"id":"db","property":"optional","range":{"min":-60,"max":32},"prettyName":"Gain [dB]","type":"number"}]},{"pretty_name":"Set channel gain","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.gain.set","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"gain","property":"optional hidden","range":{"min":0,"max":40},"prettyName":"Linear gain","type":"number"},{"id":"db","property":"controllable","range":{"min":-60,"max":32},"prettyName":"Gain [dB]","type":"number"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":-60,"max":32},"prettyName":"Controller value","type":"number"}],"responseParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"gain","property":"optional hidden","range":{"min":0,"max":40},"prettyName":"Linear gain","type":"number"},{"id":"db","property":"optional","range":{"min":-60,"max":32},"prettyName":"Gain [dB]","type":"number"}]},{"pretty_name":"Get channel layout","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.layout.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"layout","property":"required","values":["L/R","L","R","R/L"],"prettyName":"Channel layout: \'L/R\', \'L\', \'R\', \'R/L\'","type":"select"}]},{"pretty_name":"Set channel layout","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.layout.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"layout","property":"required","values":["L/R","L","R","R/L"],"prettyName":"Channel layout: \'L/R\', \'L\', \'R\', \'R/L\'","type":"select"}],"responseParams":[]},{"pretty_name":"Channel move","doc_request_description":"Sets the channel positions on the UI","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.move","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"dstOrderPosition","property":"required","range":{"min":0,"max":256},"prettyName":"Destination order position","type":"number"}],"responseParams":[]},{"pretty_name":"Get channel panning","doc_request_description":"","doc_response_description":"","requestType":"audiomixer.channel.pan.get","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"pan","property":"required","range":{"min":-1,"max":1},"prettyName":"Panorama","type":"number"}]},{"pretty_name":"Set channel panning","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.pan.set","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"pan","property":"controllable","range":{"min":-1,"max":1},"prettyName":"Panorama","type":"number"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":-1,"max":1},"prettyName":"Controller value","type":"number"}],"responseParams":[]},{"pretty_name":"Route PFL","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.channel.pfl.get\\",\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.pfl.get","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[]},{"pretty_name":"Route PFL","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.channel.get.set\\",\\n \\"on\\":false\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.pfl.set","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"on","property":"controllable","prettyName":"PFL","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}],"responseParams":[]},{"pretty_name":"Get channel source","doc_request_description":"","doc_response_description":"","requestType":"audiomixer.channel.source.get","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"source","property":"optional","prettyName":"Source name","type":"SourceName"}]},{"pretty_name":"Set channel source","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.source.set","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"source","property":"optional","prettyName":"Source name","type":"SourceName"}],"responseParams":[]},{"pretty_name":"Channel visibility","doc_request_description":"Get the channel visibility on the UI","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.visibility.get","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[]},{"pretty_name":"Channel visibility","doc_request_description":"Sets the channel visibility on the UI","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.channel.visibility.set","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"visibility","property":"required","prettyName":"Boolean value","type":"boolean"}],"responseParams":[]},{"pretty_name":"Get channel volume","doc_request_description":"","doc_response_description":"","requestType":"audiomixer.channel.volume.get","requestParams":[{"id":"output","property":"optional","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"volume","property":"optional","range":{"min":0,"max":3.2},"prettyName":"Volume","type":"number"},{"id":"db","property":"controllable","range":{"min":-60,"max":10},"prettyName":"Volume [dB]","type":"number"}]},{"pretty_name":"Set channel volume","doc_request_description":"If no `output` parameter is provided sets global input source volume.\\n Otherwise sets volume of route from input channel to specified `output`.\\n ","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.channel.volume.set\\",\\n \\"source\\":\\"1\\",\\n \\"volume\\":0.5\\n }","doc_response_description":"\\n - Full output configuration if `output` param provided.\\n - Otherwise?\\n ","doc_response_example":"","requestType":"audiomixer.channel.volume.set","requestParams":[{"id":"output","property":"optional","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"volume","property":"optional hidden","range":{"min":0,"max":3.2},"prettyName":"Volume","type":"number"},{"id":"db","property":"controllable","range":{"min":-60,"max":10},"prettyName":"Volume [dB]","type":"number"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":-60,"max":10},"prettyName":"Controller value","type":"number"}],"responseParams":[]}],"audiomixer.outputs":[{"pretty_name":"Copy audio output settings","doc_request_description":"Copies all settings from `srcOutput` to `dstAudioOutput`","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.outputs.copy\\",\\n \\"srcOutput\\":\\"AUX 1\\",\\n \\"dstOutput\\":\\"AUX 2\\"\\n }","doc_response_description":"All audio outputs state","doc_response_example":"","requestType":"audiomixer.outputs.copy","requestParams":[{"id":"srcOutput","property":"required","prettyName":"Source audio output","type":"AudioOutputName"},{"id":"dstOutput","property":"required","prettyName":"Destination audio output","type":"AudioOutputName"}]},{"pretty_name":"Get output","doc_request_description":"Returns current state of provided audio output","doc_request_example":"{\\"message-id\\":\\"d\\",\\"request-type\\":\\"audiomixer.outputs.get\\", \\"output\\":\\"AUX 4\\"}","doc_response_description":"Audio output state","doc_response_example":"","requestType":"audiomixer.outputs.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"}]},{"pretty_name":"Get all outputs","doc_request_description":"Returns all audio outputs state","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.outputs.list\\"\\n }","doc_response_description":"All audio output state","doc_response_example":"","requestType":"audiomixer.outputs.list","requestParams":[]},{"pretty_name":"Get output mute state","doc_request_description":"Mutes audio output","doc_response_description":"Modified audio output state","requestType":"audiomixer.outputs.muted.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"}],"responseParams":[{"id":"muted","property":"controllable","prettyName":"Muted","type":"boolean"}]},{"pretty_name":"Set output mute state","doc_request_description":"Mutes audio output","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.outputs.muted.set\\",\\n \\"output\\":\\"PROGRAM\\",\\n \\"muted\\":false\\n }","doc_response_description":"Modified audio output state","doc_response_example":"","requestType":"audiomixer.outputs.muted.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"id":"muted","property":"controllable","prettyName":"Muted","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}],"responseParams":[]},{"pretty_name":"Get output panning","doc_request_description":"Gets audio output panorama","doc_response_description":"Modified audio output state","requestType":"audiomixer.outputs.panning.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"}],"responseParams":[{"id":"panning","property":"controllable","range":{"min":-1,"max":1},"prettyName":"Panning","type":"number"}]},{"pretty_name":"Set output panning","doc_request_description":"Sets audio output panorama","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.outputs.panning.set\\",\\n \\"output\\":\\"Master\\",\\n \\"panning\\":-0.5\\n }","doc_response_description":"Modified audio output state","doc_response_example":"","requestType":"audiomixer.outputs.panning.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"id":"panning","property":"controllable","range":{"min":-1,"max":1},"prettyName":"Panning","type":"number"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":-1,"max":1},"prettyName":"Controller value","type":"number"}],"responseParams":[]},{"pretty_name":"Get route PFL","doc_request_description":"","doc_response_description":"","requestType":"audiomixer.outputs.pfl.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"}],"responseParams":[{"id":"on","property":"controllable","prettyName":"PFL","type":"boolean"}]},{"pretty_name":"Route PFL","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.outputs.pfl.set\\",\\n \\"output\\":\\"Master\\",\\n \\"on\\":false\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.outputs.pfl.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"id":"on","property":"controllable","prettyName":"PFL","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}],"responseParams":[]},{"pretty_name":"Reset audio output settings","doc_request_description":"Resets all audio output settings to its default state. For example ON and AFV flags.","doc_request_example":"{\\"message-id\\":\\"d\\",\\"request-type\\":\\"audiomixer.outputs.reset\\",\\"output\\":\\"AUX 1\\"}","doc_response_description":"All audio outputs state","doc_response_example":"","requestType":"audiomixer.outputs.reset","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"}]},{"pretty_name":"Get output volume","doc_request_description":"Gets volume of audio output channel","doc_response_description":"Modified audio output state","requestType":"audiomixer.outputs.volume.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"}],"responseParams":[{"id":"volume","property":"optional","range":{"min":0,"max":3.2},"prettyName":"Volume","type":"number"},{"id":"db","property":"controllable","range":{"min":-60,"max":10},"prettyName":"Volume [dB]","type":"number"}]},{"pretty_name":"Set output volume","doc_request_description":"Sets volume of audio output channel","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.outputs.volume.set\\",\\n \\"output\\":\\"AUX 1\\",\\n \\"volume\\":0.5\\n }","doc_response_description":"Modified audio output state","doc_response_example":"","requestType":"audiomixer.outputs.volume.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"id":"volume","property":"optional hidden","range":{"min":0,"max":3.2},"prettyName":"Volume","type":"number"},{"id":"db","property":"controllable","range":{"min":-60,"max":10},"prettyName":"Volume [dB]","type":"number"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":-60,"max":10},"prettyName":"Controller value","type":"number"}],"responseParams":[]},{"pretty_name":"Route - audio follow video [AFV]","doc_request_description":"Gets AFV flag for audio route from `source` to `output`.","doc_response_description":"Modified output state","requestType":"audiomixer.routes.afv.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"afv","property":"controllable","prettyName":"AFV","type":"boolean"}]},{"pretty_name":"Route - audio follow video [AFV]","doc_request_description":"Sets AFV flag for audio route from `source` to `output`.","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.routes.afv.set\\",\\n \\"output\\":\\"auxowe e\\",\\n \\"source\\":\\"id-62b79a46-6f25-012f-b152-0b8aa98f3c97\\",\\n \\"afv\\":false\\n }","doc_response_description":"Modified output state","doc_response_example":"","requestType":"audiomixer.routes.afv.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"afv","property":"controllable","prettyName":"AFV","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}],"responseParams":[]},{"pretty_name":"Gets route mode [OFF, ON, AFV]","doc_request_description":"","doc_response_description":"","requestType":"audiomixer.routes.mode.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"mode","property":"required","values":["OFF","ON","AFV"],"prettyName":"mode [OFF, ON, AFV]","type":"select"},{"id":"on","property":"required","prettyName":"ON","type":"boolean"},{"id":"afv","property":"required","prettyName":"AFV","type":"boolean"}]},{"pretty_name":"Sets route mode [OFF, ON, AFV]","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.routes.mode.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"mode","property":"required","values":["OFF","ON","AFV"],"prettyName":"mode [OFF, ON, AFV]","type":"select"}]},{"pretty_name":"Route active [ON]","doc_request_description":"Gets ON flag for audio route from `source` to `output`.","doc_response_description":"Modified output state","requestType":"audiomixer.routes.on.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"on","property":"controllable","prettyName":"ON","type":"boolean"}]},{"pretty_name":"Route active [ON]","doc_request_description":"Sets ON flag for audio route from `source` to `output`.","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.routes.on.set\\",\\n \\"output\\":\\"auxowe e\\",\\n \\"source\\":\\"id-62b79a46-6f25-012f-b152-0b8aa98f3c97\\",\\n \\"on\\":false\\n }","doc_response_description":"Modified output state","doc_response_example":"","requestType":"audiomixer.routes.on.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"on","property":"controllable","prettyName":"ON","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}],"responseParams":[]},{"pretty_name":"Route pre/post fader","doc_request_description":"Gets audio route from `source` to `output` to be post or pre fader","doc_response_description":"Modified output state","requestType":"audiomixer.routes.post.get","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"}],"responseParams":[{"id":"post","property":"controllable","prettyName":"Is POST","type":"boolean"}]},{"pretty_name":"Route pre/post fader","doc_request_description":"Sets audio route from `source` to `output` to be post or pre fader","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.routes.post.set\\",\\n \\"output\\":\\"auxowe e\\",\\n \\"source\\":\\"id-62b79a46-6f25-012f-b152-0b8aa98f3c97\\",\\n \\"post\\":false\\n }","doc_response_description":"Modified output state","doc_response_example":"","requestType":"audiomixer.routes.post.set","requestParams":[{"id":"output","property":"required","prettyName":"Audio output","type":"AudioOutputName"},{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"post","property":"controllable","prettyName":"Is POST","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}],"responseParams":[]}],"audiomixer.plugins":[{"pretty_name":"","doc_request_description":"","doc_response_description":"","requestType":"audiomixer.plugins.enabled.get","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"pluginName","property":"required","prettyName":"Plugin name","type":"string"}],"responseParams":[{"id":"enable","property":"required","prettyName":"Is enabled flag","type":"boolean"}]},{"pretty_name":"Enable plugin parameter","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.plugins.enabled.set","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"pluginName","property":"required","values":["compressor","delay","pan"],"prettyName":"Plugin name","type":"select"},{"id":"enable","property":"controllable","prettyName":"Is enabled flag","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}]},{"pretty_name":"","doc_request_description":"","doc_response_description":"","requestType":"audiomixer.plugins.parameter.get","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"pluginName","property":"required","values":["compressor","delay","pan"],"prettyName":"Plugin name","type":"select"},{"id":"paramName","property":"required","values":["attack","release","knee","ratio","threshold","makeup","sidechain","enable","sidechainChannel","delay","mix","pan"],"prettyName":"Parameter name","type":"select"}],"responseParams":[{"id":"value","property":"required","range":{"min":-1.7976931348623157e+308,"max":1.7976931348623157e+308},"prettyName":"Parameter value","type":"number"}]},{"pretty_name":"Set plugin parameter value","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.plugins.parameter.set","requestParams":[{"property":"required","prettyName":"Audio channel id","type":"ExistingChannelIdParameter","id":"audioChannel"},{"id":"pluginName","property":"required","values":["compressor","delay","pan"],"prettyName":"Plugin name","type":"select"},{"id":"paramName","property":"required","values":["attack","release","knee","ratio","threshold","makeup","sidechain","enable","sidechainChannel","delay","mix","pan"],"prettyName":"Parameter name","type":"select"},{"id":"value","property":"controllable","range":{"min":-1.7976931348623157e+308,"max":1.7976931348623157e+308},"prettyName":"Parameter value","type":"number"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":-1.7976931348623157e+308,"max":1.7976931348623157e+308},"prettyName":"Controller value","type":"number"}]}],"audiomixer":[{"pretty_name":"Connect audio source to group","doc_request_description":"Connect audio source to group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.connect\\",\\n \\"outputName\\": \\"audio-group-id\\",\\n \\"inputsChannelIds\\": [\\"audioId\\", \\"Audio 2\\"]\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.connect","requestParams":[{"id":"inputsChannelIds","property":"required","prettyName":"Array of audio inputs","type":"array of strings"},{"id":"subgroupName","property":"required","prettyName":"Audio subgroup","type":"AudioSubgroupName"}]},{"pretty_name":"Disconnect audio source from group","doc_request_description":"Disconnect audio source from group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.disconnect\\",\\n \\"outputName\\": \\"audio-group-id\\",\\n \\"inputsChannelIds\\": [\\"audioId\\", \\"Audio 2\\"]\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.disconnect","requestParams":[{"id":"inputsChannelIds","property":"required","prettyName":"Array of input names","type":"array of strings"},{"id":"subgroupName","property":"required","prettyName":"Audio subgroup","type":"AudioSubgroupName"}]},{"pretty_name":"Add audio group","doc_request_description":"adds an audio group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.subgroups.add\\",\\n \\"subgroupName\\": \\"audio-group-id\\",\\n \\"displayName\\": \\"My Super Group\\",\\n \\"selectedColor\\": \\"violet\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.subgroups.add","requestParams":[{"id":"subgroupName","property":"required","prettyName":"Subgroup id","type":"string"},{"id":"displayName","property":"required","prettyName":"Subgroup visible name","type":"string"},{"id":"selectedColor","property":"optional","prettyName":"Subgroup color","type":"string"}]},{"pretty_name":"Get audio subgroups","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.subgroups.get\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.subgroups.get","requestParams":[]},{"pretty_name":"Remove audio group","doc_request_description":"Remove an audio group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.subgroups.remove\\",\\n \\"subgroupName\\": \\"audio-group-id\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.subgroups.remove","requestParams":[{"id":"subgroupName","property":"required","prettyName":"Audio subgroup","type":"AudioSubgroupName"}]},{"pretty_name":"Udpate audio group","doc_request_description":"Update an audio group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"audiomixer.update.subgroup\\",\\n \\"subgroupName\\": \\"audio-group-id\\",\\n \\"displayName\\": \\"My Super Group\\",\\n \\"selectedColor\\": \\"violet\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"audiomixer.update.subgroup","requestParams":[{"id":"subgroupName","property":"required","prettyName":"Audio subgroup","type":"AudioSubgroupName"},{"id":"displayName","property":"required","prettyName":"Subgroup visible name","type":"string"},{"id":"selectedColor","property":"required","prettyName":"Subgroup color","type":"string"}]}],"commands":[{"pretty_name":"Get commands","doc_request_description":"","doc_response_description":"","requestType":"commands.get","requestParams":[]},{"pretty_name":"Get commands groups","doc_request_description":"","doc_response_description":"","requestType":"commands.groups.get","requestParams":[]},{"pretty_name":"Get command parameter options","doc_request_description":"Return possible options for parameter type","doc_request_example":"{\\n \\"message-id\\": \\"LACTOAC-getOptions\\",\\n \\"request-type\\": \\"commands.parameter.options.get\\",\\n \\"parameterType\\": \\"parameter.type\\"\\n }","doc_response_description":"\\n Array of options.\\n [\\n {id: 1, value: \\"One\\"}\\n ]","doc_response_example":"","requestType":"commands.parameter.options.get","requestParams":[{"id":"requestType","property":"required","prettyName":"Request type","type":"string"},{"id":"parameterName","property":"required","prettyName":"Parameter name","type":"string"}]}],"general":[{"pretty_name":"","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"config.get\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"config.get","requestParams":[],"responseParams":[{"id":"producer","property":"required","prettyName":"Producer state","type":"object"},{"id":"features","property":"required","prettyName":"Features state","type":"object"}]},{"pretty_name":"Get producer webrtc protocol","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"config.webrtc.protocol.get\\",\\n \\"protocol\\":\\"UDP\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"config.webrtc.protocol.get","requestParams":[],"responseParams":[{"id":"protocol","property":"required","prettyName":"Selected Webrtc protocol","type":"select"}]},{"pretty_name":"Set producer webrtc protocol","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"config.webrtc.protocol.set\\",\\n \\"protocol\\":\\"UDP\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"config.webrtc.protocol.set","requestParams":[{"id":"protocol","property":"required","values":["UDP","TCP"],"prettyName":"Selected Webrtc protocol","type":"select"}]},{"pretty_name":"","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"config.webrtc.protocols.get\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"config.webrtc.protocols.get","requestParams":[]},{"pretty_name":"Reload Live Production","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"reload.set\\",\\n }","doc_response_description":"","doc_response_example":"","requestType":"reload.set","requestParams":[{"id":"force","property":"optional","prettyName":"force","type":"boolean"},{"id":"waitForIt","property":"optional","prettyName":"waitForIt","type":"boolean"}]}],"guests":[{"pretty_name":"Restart jitsi return","doc_request_description":"","doc_request_example":"{\\"request-type\\":\\"RestartJitsiReturn\\", \\"message-id\\":\\"msgid\\", \\"ConferenceName\\":\\"t1-d43vf2nz15rk\\" }","doc_response_description":"","doc_response_example":"{\\"status\\":\\"ok\\",\\"message-id\\":\\"msgid\\"}","requestType":"RestartJitsiReturn","requestParams":[{"property":"required","prettyName":"Conference name","description":"Conference name","type":"ConferenceNameParameter","id":"ConferenceName"}]}],"multiviewer":[{"pretty_name":"Available sources","doc_request_description":"Returns a list of sources that can be added to multiview","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"multiviewer.available.sources.get\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"multiviewer.available.sources.get","requestParams":[],"responseParams":[{"id":"sources","property":"required","prettyName":"Object of available sources grouped by type","type":"object"},{"id":"types","property":"required","prettyName":"Available sources types","type":"array of strings"}]},{"pretty_name":"Get multiview state","doc_request_description":"Returns a list of assets added to multiview","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"multiviewer.get\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"multiviewer.get","requestParams":[],"responseParams":[{"id":"multiviewApp","property":"required","prettyName":"Object describing multiviewr configuration","type":"object"}]},{"pretty_name":"Set the current layout","doc_request_description":"Sets the preview layout to multiview","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"multiviewer.layout.set\\",\\n \\"layout\\":\\"generic\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"multiviewer.layout.set","requestParams":[{"id":"configId","property":"required","prettyName":"","type":"string"},{"id":"layout","property":"required","prettyName":"","type":"string"}],"responseParams":[]},{"pretty_name":"Add slot","doc_request_description":"Adds asset preview to multivew","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"multiviewer.slot.add\\",\\n \\"index\\":0,\\n \\"sourceName\\":\\"Scene 1\\",\\n \\"additionalData\\":{}\\n }","doc_response_description":"","doc_response_example":"","requestType":"multiviewer.slot.add","requestParams":[{"id":"configId","property":"required","prettyName":"Id of multiview.","type":"string"},{"id":"index","property":"required","prettyName":"Slot index","type":"string"},{"id":"sourceName","property":"required","prettyName":"Asset source name","type":"string"},{"id":"displayName","property":"required","prettyName":"Readable name of asset","type":"string"},{"id":"type","property":"optional","prettyName":"Source type","type":"string"},{"id":"url","property":"optional","prettyName":"Asset url","type":"string"},{"id":"additionalData","property":"optional","prettyName":"Additional data about used asset","type":"object"}],"responseParams":[]},{"pretty_name":"Set slot audiometer","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"multiviewer.slot.audiometer.set\\",\\n \\"index\\":3,\\n \\"value\\":true\\n }","doc_response_description":"","doc_response_example":"","requestType":"multiviewer.slot.audiometer.set","requestParams":[{"id":"index","property":"required","range":{"min":0,"max":64},"prettyName":"","type":"number"},{"id":"configId","property":"required","prettyName":"","type":"string"},{"id":"value","property":"required","prettyName":"","type":"boolean"}],"responseParams":[]},{"pretty_name":"","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"multiviewer.slot.fullscreen.set\\",\\n \\"index\\":3,\\n \\"value\\":true\\n }","doc_response_description":"","doc_response_example":"","requestType":"multiviewer.slot.fullscreen.set","requestParams":[{"id":"index","property":"required","range":{"min":0,"max":64},"prettyName":"","type":"number"},{"id":"configId","property":"required","prettyName":"","type":"string"},{"id":"value","property":"required","prettyName":"","type":"boolean"}],"responseParams":[]},{"pretty_name":"Move slot","doc_request_description":"Move slot from one position to another","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"multiviewer.slot.move\\",\\n \\"from\\":1,\\n \\"to\\":2\\n }","doc_response_description":"","doc_response_example":"","requestType":"multiviewer.slot.move","requestParams":[{"id":"configId","property":"required","prettyName":"Id of multiview.","type":"string"},{"id":"from","property":"required","range":{"min":0,"max":32},"prettyName":"Moved slot index","type":"number"},{"id":"to","property":"required","range":{"min":0,"max":32},"prettyName":"Destination slot index","type":"number"}]},{"pretty_name":"Remove slot","doc_request_description":"Removes a source from the view","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"multiviewer.slot.remove\\",\\n \\"index\\":1\\n }","doc_response_description":"","doc_response_example":"","requestType":"multiviewer.slot.remove","requestParams":[{"id":"configId","property":"required","prettyName":"Id of multiview.","type":"string"},{"id":"index","property":"required","range":{"min":0,"max":32},"prettyName":"Slot index","type":"number"}],"responseParams":[]}],"playouts":[{"pretty_name":"Set autoplay to playout.","doc_request_description":"Set whenever slayout should be autoplayed when enter the program.","doc_request_example":"{\\n message-id: \\"id-a0b89575-b223-6ea2-46aa-15cdbe48bf41\\",\\n autoplay: true,\\n playout: 0,\\n request-type: \\"playouts.autoplay.set\\",\\n trackingData: {\\n applicationId: \\"id-e21c0f07-c3d7-8944-516e-057b354bedff\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702983361062,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-a0b89575-b223-6ea2-46aa-15cdbe48bf41\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.autoplay.set","requestParams":[{"id":"autoplay","property":"required","prettyName":"Is the autoplay of playout set?","type":"boolean"},{"id":"playout","property":"required","prettyName":"Playout\'s index.","type":"PlayoutIndex"}],"responseParams":[{"id":"playouts","property":"required","prettyName":"Array of playouts state","type":"array"}]},{"pretty_name":"Switch play/pause playlist source.","doc_request_description":"Playout index and boolean value of play/pause has to be given.","doc_request_example":"{\\n message-id: \\"id-3a057cd8-74db-dc90-154f-551d8b94fffd\\",\\n playout: 0,\\n request-type: \\"playouts.playPause\\",\\n playPause: true,\\n trackingData: {\\n applicationId: \\"id-16604aac-91f4-1c89-cf45-f760336a7019\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702995321349,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"","doc_response_example":"","requestType":"playouts.playPause","requestParams":[{"id":"playout","property":"required","prettyName":"Playout index","type":"PlayoutIndex"},{"id":"playPause","property":"optional","prettyName":"Force action. If true play if false pause.","type":"boolean"}],"responseParams":[]},{"pretty_name":"Add playlist to playout.","doc_request_description":"Playlist name and playout index have to be given.","doc_request_example":"{\\n message-id: \\"id-8500659c-1a2f-5434-c8b9-4e9a97e8f10c\\",\\n playlistName: \\"playlist-e7c84ff2-53e9-6b4c-53ad-84b1c3948c83\\",\\n playout: 0,\\n request-type: \\"playouts.playlists.add\\",\\n trackingData: {\\n applicationId: \\"id-e21c0f07-c3d7-8944-516e-057b354bedff\\",\\n ts: 1702902800700,\\n uiElement: \\"unkown\\",\\n applicationName: \\"PLAYOUTS\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-8500659c-1a2f-5434-c8b9-4e9a97e8f10c\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.add","requestParams":[{"id":"playlistName","property":"required","prettyName":"New playlist\'s name.","type":"string"},{"id":"playout","property":"required","prettyName":"Playout\'s index.","type":"PlayoutIndex"}],"responseParams":[{"id":"playouts","property":"required","prettyName":"","type":"array"}]},{"pretty_name":"Set playlist\'s displayName.","doc_request_description":"Playlist name and display name have to be given.","doc_request_example":"{\\n message-id: \\"id-a0b89575-b223-6ea2-46aa-15cdbe48bf41\\",\\n playlistName: \\"playlist-e7c84ff2-53e9-6b4c-53ad-84b1c3948c83\\",\\n playlistDisplayName: \\"Playlist_3\\",\\n request-type: \\"playouts.playlists.displayName.set\\",\\n trackingData: {\\n applicationId: \\"id-e21c0f07-c3d7-8944-516e-057b354bedff\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702983361062,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-a0b89575-b223-6ea2-46aa-15cdbe48bf41\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.displayName.set","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"playlistDisplayName","property":"required","prettyName":"Playlist\'s display name.","type":"string"}]},{"pretty_name":"Change mode of playing in the playlist.","doc_request_description":"Playlist name and mode have to be given.","doc_request_example":"{\\n message-id: \\"id-95699bad-b20e-1a71-cf03-0405f169d90d\\",\\n mode: \\"LoopAll\\",\\n playlistName: \\"playlist-e7c84ff2-53e9-6b4c-53ad-84b1c3948c83\\",\\n request-type: \\"playouts.playlists.mode.set\\",\\n trackingData: {\\n applicationId: \\"id-e21c0f07-c3d7-8944-516e-057b354bedff\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702983005668,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-95699bad-b20e-1a71-cf03-0405f169d90d\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.mode.set","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"mode","property":"required","prettyName":"Playlist\'s playing mode.","type":"string"}]},{"pretty_name":"Remove playout\'s playlist.","doc_request_description":"Playlist name and playout index have to be given.","doc_request_example":"{\\n message-id: \\"id-a0b89575-b223-6ea2-46aa-15cdbe48bf41\\",\\n playlistName: \\"playlist-e7c84ff2-53e9-6b4c-53ad-84b1c3948c83\\",\\n playout: 0,\\n request-type: \\"playouts.playlists.remove\\",\\n trackingData: {\\n applicationId: \\"id-e21c0f07-c3d7-8944-516e-057b354bedff\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702983361062,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-a0b89575-b223-6ea2-46aa-15cdbe48bf41\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.remove","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"playout","property":"required","prettyName":"Playout\'s index.","type":"PlayoutIndex"}]},{"pretty_name":"Add source to playlist.","doc_request_description":"Source name and its props have to be given.","doc_request_example":"{\\n message-id: \\"id-0fe0a98a-ab07-9aa2-7dd4-a11a99784a80\\",\\n request-type: \\"playouts.playlists.sources.add\\",\\n source: {\\n name: \\"a test fps pull_dropbox_1699536389670\\",\\n sourceName: \\"id-a60578dd-0fbb-584e-5fb5-5e73657a3845\\",\\n sourceSettings: {\\n file: \\"https://d2ndi552mc32nx.cloudfront.net/s/b20ca851f63dd9672abb945ba73d90c9/atestfpspull_dropbox_1699536389670.jpg\\"\\n }\\n },\\n sourceType: \\"image_source\\",\\n type: \\"image\\",\\n playlistName: \\"playlist-e7c84ff2-53e9-6b4c-53ad-84b1c3948c83\\",\\n sourceName: \\"playlist-source-0fc73eca-2098-fca6-b964-0b0c98809414\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702984741465,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-0fe0a98a-ab07-9aa2-7dd4-a11a99784a80\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.add","requestParams":[{"id":"sourceName","property":"required","prettyName":"New source\'s name.","type":"string"},{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"source","property":"required","prettyName":"Source.","type":"PlaylistSource"}]},{"pretty_name":"Set source\'s cue.","doc_request_description":"Source name, cueIn, cueOut have to be given.","doc_request_example":"{\\n cueIn: 1000,\\n cueOut: 7000,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"playouts.playlists.sources.cue.set\\",\\n playlistName: \\"playlist-d2bc486e-1150-6dba-79fe-e2ca40e59a08\\",\\n sourceName: \\"playlist-source-0fc73eca-2098-fca6-b964-0b0c98809414\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.cue.set","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"sourceName","property":"required","prettyName":"Source\'s name.","type":"PlayoutSourceName"},{"id":"cueIn","property":"required","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"CueIn of the source.","type":"number"},{"id":"cueOut","property":"required","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"CueOut of the source.","type":"number"}]},{"pretty_name":"Set disable source.","doc_request_description":"Playlist name, source name and disabled have to be given.","doc_request_example":"{\\n disabled: true,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n playlistName: \\"playlist-d2bc486e-1150-6dba-79fe-e2ca40e59a08\\",\\n request-type: \\"playouts.playlists.sources.disable.set\\",\\n sourceName: \\"playlist-source-0fc73eca-2098-fca6-b964-0b0c98809414\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.disable.set","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"sourceName","property":"required","prettyName":"Source\'s name.","type":"PlayoutSourceName"},{"id":"disabled","property":"required","prettyName":"Disabled","description":"Is the source disabled?","type":"boolean"}]},{"pretty_name":"Set source\'s duration.","doc_request_description":"Playlist name, source name, duation and hasDuration have to be given.","doc_request_example":"{\\n duration: 60000,\\n hasDuration: true,\\n message-id: \\"id-f5dd5b9d-55c9-6729-78e4-edc40886f59d\\",\\n playlistName: \\"playlist-d2bc486e-1150-6dba-79fe-e2ca40e59a08\\"\\n request-type: \\"playouts.playlists.sources.duration.set\\",\\n sourceName: \\"playlist-source-0fc73eca-2098-fca6-b964-0b0c98809414\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702985920794,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-f5dd5b9d-55c9-6729-78e4-edc40886f59d\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.duration.set","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"sourceName","property":"required","prettyName":"Source\'s name.","type":"PlayoutSourceName"},{"id":"duration","property":"required","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Source\'s duration.","type":"number"},{"id":"hasDuration","property":"required","prettyName":"Does the source have duration?","type":"boolean"}]},{"pretty_name":"Play playlist source.","doc_request_description":"Playlist name, source name and playout index have to be given.","doc_request_example":"{\\n message-id: \\"id-4fe183cf-3de1-1c16-960f-2bf21c56a513\\",\\n playlistName: \\"playlist-d2bc486e-1150-6dba-79fe-e2ca40e59a08\\",\\n playout: 0,\\n request-type: \\"playouts.playlists.sources.play\\",\\n sourceName: \\"playlist-source-1fcac9f6-4c53-0136-eff8-5e521ab33f1d\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702987231507,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-4fe183cf-3de1-1c16-960f-2bf21c56a513\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.play","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"sourceName","property":"required","prettyName":"Source\'s name.","type":"PlayoutSourceName"},{"id":"playout","property":"required","prettyName":"Playout\'s index.","type":"PlayoutIndex"}]},{"pretty_name":"Set playlist\'s next source.","doc_request_description":"Playlist name has to be given.","doc_request_example":"{\\n message-id: \\"id-3c8821b1-6cd5-366b-99cc-5d4a98177063\\",\\n playlistName: \\"playlist-d2bc486e-1150-6dba-79fe-e2ca40e59a08\\",\\n request-type: \\"playouts.playlists.sources.play.next\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702986723484,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-3c8821b1-6cd5-366b-99cc-5d4a98177063\\",\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.play.next","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"}]},{"pretty_name":"Set playlist\'s previous source.","doc_request_description":"Playlist name has to be given.","doc_request_example":"{\\n message-id: \\"id-3c8821b1-6cd5-366b-99cc-5d4a98177063\\",\\n playlistName: \\"playlist-d2bc486e-1150-6dba-79fe-e2ca40e59a08\\",\\n request-type: \\"playouts.playlists.sources.play.prev\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702986723484,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-3c8821b1-6cd5-366b-99cc-5d4a98177063\\",\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.play.prev","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"}]},{"pretty_name":"Remove playlist\'s source.","doc_request_description":"Playlist name, source name and source index have to be given.","doc_request_example":"{\\n message-id: \\"id-2d852c0c-22c0-32c6-b6b8-5d379a89fa84\\",\\n playlistName: \\"playlist-c664ebb8-be88-b447-e7ff-46ac9336bc19\\",\\n request-type: \\"playouts.playlists.sources.remove\\",\\n sourceIndex: 0,\\n sourceName: \\"playlist-source-28383191-33e4-50f2-fba2-1df12aea551f\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702992995152,\\n uiElement: \\"unkown\\",\\n userId: 100000629\\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-2d852c0c-22c0-32c6-b6b8-5d379a89fa84\\",\\n editSource: false,\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n selected: {\\n playoutIndex: 0, playlistIndex: 0, sourceIndex: null\\n },\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.remove","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"sourceName","property":"required","prettyName":"Source\'s name.","type":"PlayoutSourceName"},{"id":"sourceIndex","property":"required","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Source\'s index.","type":"number"}]},{"pretty_name":"Reorder playlist\'s sources.","doc_request_description":"Playlist name, source name and sources order have to be given.","doc_request_example":"{\\n message-id: \\"id-3a057cd8-74db-dc90-154f-551d8b94fffd\\",\\n playlistName: \\"playlist-05be8183-5fa3-f383-0c4f-5582b44f77c4\\",\\n request-type: \\"playouts.playlists.sources.reorder\\",\\n sourcesOrder: [\\n \\"playlist-source-8219ddf9-70d7-56e1-78ce-d83ed62dc443\\",\\n \\"playlist-source-d5e9cc25-9b4a-23f6-307b-8ef3e6f6cf85\\"\\n ],\\n trackingData: {\\n applicationId: \\"id-16604aac-91f4-1c89-cf45-f760336a7019\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702995321349,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-3a057cd8-74db-dc90-154f-551d8b94fffd\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.sources.reorder","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"sourcesOrder","property":"required","prettyName":"Source\'s order.","type":"array of strings"}]},{"pretty_name":"Set playlist\'s transition duration.","doc_request_description":"Playlist name and transition duration have to be given.","doc_request_example":"{\\n message-id: \\"id-ba44a4ed-bd30-30fe-0b25-c57343f81eea\\",\\n playlistName: \\"playlist-05be8183-5fa3-f383-0c4f-5582b44f77c4\\",\\n request-type: \\"playouts.playlists.transition.duration.set\\",\\n transitionDuration: 1000,\\n trackingData: {\\n applicationId: \\"id-16604aac-91f4-1c89-cf45-f760336a7019\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702996287567,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-ba44a4ed-bd30-30fe-0b25-c57343f81eea\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.transition.duration.set","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"transitionDuration","property":"required","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Transition\'s duration.","type":"number"}]},{"pretty_name":"Set playlist\'s transition.","doc_request_description":"Playlist name and transition have to be given.","doc_request_example":"{\\n message-id: \\"id-ba44a4ed-bd30-30fe-0b25-c57343f81eea\\",\\n playlistName: \\"playlist-05be8183-5fa3-f383-0c4f-5582b44f77c4\\",\\n request-type: \\"playouts.playlists.transition.set\\",\\n transition: \\"Dip to Black\\",\\n trackingData: {\\n applicationId: \\"id-16604aac-91f4-1c89-cf45-f760336a7019\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702996287567,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n\\n }","doc_response_description":"Current state of playouts and the status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-ba44a4ed-bd30-30fe-0b25-c57343f81eea\\",\\n playouts: [{id: 0, label: \\"Playout 1\\",…},…],\\n status: \\"ok\\"\\n }","requestType":"playouts.playlists.transition.set","requestParams":[{"id":"playlistName","property":"required","prettyName":"Playlist\'s name.","type":"PlaylistName"},{"id":"transition","property":"required","prettyName":"Playlist\'s transition.","type":"string"}]},{"pretty_name":"Stop playout.","doc_request_description":"Playout index has to be given.","doc_request_example":"{\\n message-id: \\"id-3a057cd8-74db-dc90-154f-551d8b94fffd\\",\\n playout: 0,\\n request-type: \\"playouts.stop\\",\\n trackingData: {\\n applicationId: \\"id-16604aac-91f4-1c89-cf45-f760336a7019\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702995321349,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"","doc_response_example":"","requestType":"playouts.stop","requestParams":[{"id":"playout","property":"required","prettyName":"Playout index","type":"PlayoutIndex"}],"responseParams":[]}],"producer":[{"pretty_name":"Get audio monitor channel","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.audiomonitor.get","requestParams":[],"responseParams":[{"id":"channel","property":"required","values":["preview","program"],"prettyName":"Monitoring channel","type":"select"}]},{"pretty_name":"Set audio monitor channel","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.audiomonitor.set","requestParams":[{"id":"channel","property":"controllable","values":["preview","program"],"prettyName":"Monitoring channel","type":"select"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","values":["preview","program"],"prettyName":"Controller value","type":"select"}],"responseParams":[]},{"pretty_name":"Get direct edit state","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.directEditMode.get\\",\\n \\"message-id\\": \\"id-3c503fd3-ee6a\\"\\n }","doc_response_description":"Possible values: NONE,SCENE,LAYER","doc_response_example":"{ \\"directEdit\\": \\"NONE\\", \\"status\\": \\"ok\\", \\"message-id\\": \\"id-3c503fd3-ee6a\\" }","requestType":"producer.directEditMode.get","requestParams":[],"responseParams":[{"id":"directEdit","property":"required","prettyName":"Direct edit mode","type":"string"},{"id":"previewScene","property":"required","range":{"min":0,"max":20},"prettyName":"Preview scene index","type":"number"},{"id":"currentScene","property":"required","range":{"min":0,"max":20},"prettyName":"Progeam scene index","type":"number"},{"id":"editingScene","property":"required","range":{"min":0,"max":20},"prettyName":"Editing scene index","type":"number"}]},{"pretty_name":"Set direct edit layers mode","doc_request_description":"This request only turns on or off layer mode.","doc_request_example":"{\\n \\"active\\": true,\\n \\"message-id\\": \\"gateway_9e7eab9e-de32-c2eb-3b8b-4fa619e5ef0f\\",\\n \\"request-type\\": \\"producer.directEditMode.layer.set\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"message-id\\": \\"id-b70cb024-760f-3e13-217e-659af3ddb25c\\",\\n \\"status\\": \\"ok\\",\\n \\"previewScene\\": 0,\\n \\"currentScene\\": 0,\\n \\"editingScene\\": 0\\n }","requestType":"producer.directEditMode.layer.set","requestParams":[{"id":"active","property":"controllable","prettyName":"Is DE Layers mode active","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}],"responseParams":[{"id":"previewScene","property":"required","range":{"min":0,"max":20},"prettyName":"Preview scene index","type":"number"},{"id":"currentScene","property":"required","range":{"min":0,"max":20},"prettyName":"Progeam scene index","type":"number"},{"id":"editingScene","property":"required","range":{"min":0,"max":20},"prettyName":"Editing scene index","type":"number"}]},{"pretty_name":"Set direct edit scene mode","doc_request_description":"This request only turns on or off scenes mode.","doc_request_example":"{\\n \\"active\\": true,\\n \\"message-id\\": \\"gateway_9e7eab9e-de32-c2eb-3b8b-4fa619e5ef0f\\",\\n \\"request-type\\": \\"producer.directEditMode.scene.set\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"message-id\\": \\"id-b70cb024-760f-3e13-217e-659af3ddb25c\\",\\n \\"status\\": \\"ok\\",\\n \\"previewScene\\": 0,\\n \\"currentScene\\": 0,\\n \\"editingScene\\": 0\\n }","requestType":"producer.directEditMode.scene.set","requestParams":[{"id":"active","property":"controllable","prettyName":"Is DE Scene mode active","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}],"responseParams":[{"id":"previewScene","property":"required","range":{"min":0,"max":20},"prettyName":"Preview scene index","type":"number"},{"id":"currentScene","property":"required","range":{"min":0,"max":20},"prettyName":"Progeam scene index","type":"number"},{"id":"editingScene","property":"required","range":{"min":0,"max":20},"prettyName":"Editing scene index","type":"number"}]},{"pretty_name":"Set direct edit mode","doc_request_description":"This request sets one of three possible values.","doc_request_example":"{\\n \\"directEdit\\": \\"NONE\\",\\n \\"message-id\\": \\"gateway_9e7eab9e-de32-c2eb-3b8b-4fa619e5ef0f\\",\\n \\"request-type\\": \\"producer.directEditMode.set\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"message-id\\": \\"id-b70cb024-760f-3e13-217e-659af3ddb25c\\",\\n \\"status\\": \\"ok\\",\\n \\"previewScene\\": 0,\\n \\"currentScene\\": 0,\\n \\"editingScene\\": 0\\n }","requestType":"producer.directEditMode.set","requestParams":[{"id":"directEdit","property":"required","prettyName":"Possible values: NONE,SCENE,LAYER","type":"string"}],"responseParams":[{"id":"previewScene","property":"required","range":{"min":0,"max":20},"prettyName":"Preview scene index","type":"number"},{"id":"currentScene","property":"required","range":{"min":0,"max":20},"prettyName":"Progeam scene index","type":"number"},{"id":"editingScene","property":"required","range":{"min":0,"max":20},"prettyName":"Editing scene index","type":"number"}]},{"pretty_name":"Returns preview scene","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.preview.get","requestParams":[],"responseParams":[]},{"pretty_name":"Get current program scene","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\": \\"gateway_f9fffc0b-6567-ee26-9a9e-434c7c0cfaf0\\",\\n \\"request-type\\": \\"producer.program.set\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"producer.program.get","requestParams":[],"responseParams":[{"id":"scene","property":"optional","prettyName":"Scene data","type":"object"}]},{"pretty_name":"Select scene","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.selectedScene.set\\",\\n \\"message-id\\": \\"id-4c71d2dc-6a19-18f3-af21-86f220a85dc8:77dfb7ff-87bb\\",\\n \\"sceneName\\": \\"Scene 1\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"previewScene\\": 0,\\n \\"currentScene\\": 0,\\n \\"editingScene\\": 0,\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"id-4c71d2dc-6a19-18f3-af21-86f220a85dc8\\"\\n }","requestType":"producer.selectedScene.set","requestParams":[{"id":"sceneName","property":"optional","prettyName":"Scene name","type":"SceneName"},{"id":"sceneIndex","property":"optional","range":{"min":0,"max":20},"prettyName":"Scene index","type":"number"}],"responseParams":[{"id":"previewScene","property":"required","range":{"min":0,"max":20},"prettyName":"Preview scene index","type":"number"},{"id":"currentScene","property":"required","range":{"min":0,"max":20},"prettyName":"Progeam scene index","type":"number"},{"id":"editingScene","property":"required","range":{"min":0,"max":20},"prettyName":"Editing scene index","type":"number"}]},{"pretty_name":"Get source display name","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.inputs.displayName.get","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"}],"responseParams":[{"id":"displayName","property":"required","prettyName":"Display name","type":"string"}]},{"pretty_name":"Set source display name","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.inputs.displayName.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"},{"id":"displayName","property":"required","prettyName":"Display name","type":"string"}],"responseParams":[]},{"pretty_name":"Move input source to other layer","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.inputs.move\\",\\n \\"message-id\\": \\"id-03b8845c-ac5f-3392-e3f4-1abb3b968cb6:0e95e909-6563\\",\\n \\"sceneName\\": \\"Scene 1\\",\\n \\"srcLayer\\": \\"layer-86257da8-032c-321b-f8b1-6ef200fa2aa2\\",\\n \\"srcLayerItemId\\": 1,\\n \\"dstLayer\\": \\"layer-b5c90a2f-3d4b-18bc-9ade-e38c704ed8a0\\",\\n \\"dstOrderPosition\\": 0\\n }","doc_response_description":"","doc_response_example":"{\\n \\"sourceName\\": \\"id-2817d277-d348-b5ea-6c75-a4d43e4ee4a2\\",\\n \\"inputName\\": \\"Input 2\\",\\n \\"layerName\\": \\"layer-b5c90a2f-3d4b-18bc-9ade-e38c704ed8a0\\",\\n \\"layerItemId\\": 1,\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"id-03b8845c-ac5f-3392-e3f4-1abb3b968cb6\\"\\n }","requestType":"producer.inputs.move","requestParams":[{"id":"sceneName","property":"required","prettyName":"Source scene name","type":"SceneName"},{"id":"srcLayer","property":"required","prettyName":"Source layer name","type":"LayerName"},{"id":"srcLayerItemId","property":"required","range":{"min":0,"max":100},"prettyName":"Source layer item id","type":"number"},{"id":"dstLayer","property":"required","prettyName":"Destination layer name","type":"LayerName"},{"id":"dstOrderPosition","property":"required","range":{"min":0,"max":100},"prettyName":"Destination order position","type":"number"}]},{"pretty_name":"Replace source","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.inputs.source.replace","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"},{"id":"syncGroup","property":"required","prettyName":"Sync group","type":"string"}],"responseParams":[]},{"pretty_name":"Get scene layers data","doc_request_description":"","doc_response_description":"","requestType":"producer.layers.get","requestParams":[{"id":"sceneName","property":"optional","prettyName":"Scene name","type":"SceneName"},{"id":"sceneIndex","property":"optional","range":{"min":0,"max":8},"prettyName":"Scene index","type":"number"},{"id":"layerName","property":"optional","prettyName":"Layer name","type":"LayerName"},{"id":"sceneItemId","property":"optional","range":{"min":0,"max":100},"prettyName":"Scene item id","type":"number"},{"id":"visible","property":"optional","prettyName":"Visible","type":"boolean"}],"responseParams":[{"id":"found","property":"required","prettyName":"Found","type":"boolean"},{"id":"references","property":"required","prettyName":"References","type":"array"},{"id":"data","property":"optional","prettyName":"Data","type":"array"}]},{"pretty_name":"Add input with source onto a layer","doc_request_description":"","doc_request_example":"{\\n \\"sourceName\\": \\"id-a5cbd5ae-b0dc-27b4-76cf-555fe47067c9\\",\\n \\"layerName\\": \\"layer-d32efa82-94a1-3d24-4c8c-b3cbc979a57b\\",\\n \\"sceneName\\": \\"Scene 2\\",\\n \\"orderPosition\\": 0,\\n \\"type\\": \\"liveStream\\",\\n \\"displayName\\": \\"lambo\\",\\n \\"additionalData\\": {},\\n \\"sourceSettings\\": {\\n \\"clear_on_media_end\\": true,\\n \\"hwDecode\\": true,\\n \\"input\\": \\"rtmp://test-streamer-s3dev.aws-dev.intranet/stream_test/lambo\\",\\n \\"is_local_file\\": false,\\n \\"looping\\": false,\\n \\"restart_on_activate\\": false,\\n \\"deinterlacing\\": \\"disable\\",\\n \\"audioTrackIndex\\": 0\\n },\\n \\"item\\": {\\n \\"visible\\": true\\n },\\n \\"request-type\\": \\"producer.layers.inputs.add\\",\\n \\"message-id\\": \\"id-8c793004-ce13-3705-9556-0eb30501c117\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"sourceName\\": \\"id-a5cbd5ae-b0dc-27b4-76cf-555fe47067c9\\",\\n \\"inputName\\": \\"Input12\\",\\n \\"layerName\\": \\"layer-d32efa82-94a1-3d24-4c8c-b3cbc979a57b\\",\\n \\"layerItemId\\": 3,\\n \\"width\\": 1920,\\n \\"height\\": 1080,\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"id-8c793004-ce13-3705-9556-0eb30501c117\\"\\n }\\n ","requestType":"producer.layers.inputs.add","requestParams":[{"id":"sourceName","property":"required","prettyName":"New source identificator","type":"string"},{"id":"layerName","property":"required","prettyName":"Layer which source will be added on","type":"LayerName"},{"id":"sceneName","property":"required","prettyName":"Scene contining layerName.","type":"SceneName"},{"id":"orderPosition","property":"required","range":{"min":0,"max":100},"prettyName":"Order position","defaultValue":0,"description":"Index on a layer to place new input source","type":"number"},{"id":"inputName","property":"optional","prettyName":"For future use","type":"string"},{"id":"type","property":"required","prettyName":"Source type","type":"SourceType"},{"id":"displayName","property":"required","prettyName":"Name visible to users","type":"string"},{"id":"sourceSettings","property":"optional","prettyName":"Source settings specific for this source type","type":"object"},{"id":"item","property":"optional","prettyName":"Transformations description object","type":"object"},{"id":"properties","property":"optional","prettyName":"TODO: Refactor to use item only.","type":"object"},{"id":"sourceType","property":"optional","prettyName":"Deprecated, but used :(","type":"string"},{"id":"guest","property":"optional","prettyName":"Deprecated, but used :(","type":"object"},{"id":"sourceId","property":"optional","prettyName":"Some internal staff [magic]","type":"hidden"},{"id":"thumbnailUrl","property":"optional","prettyName":"Default asset thumbnail","type":"string"},{"id":"additionalData","property":"optional","prettyName":"Additional data about used asset","type":"object"}],"responseParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"string"},{"id":"layerName","property":"required","prettyName":"Layer name","type":"string"},{"id":"inputName","property":"required","prettyName":"Input name","type":"string"},{"id":"layerItemId","property":"required","range":{"min":0,"max":100},"prettyName":"Layer item id","type":"number"},{"id":"width","property":"required","range":{"min":0,"max":100000},"prettyName":"Width","type":"number"},{"id":"height","property":"required","range":{"min":0,"max":100000},"prettyName":"Height","type":"number"}]},{"pretty_name":"Duplicate source on the same layer","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.layers.inputs.duplicate\\",\\n \\"message-id\\": \\"id-2f7baeba-bef5-57fd-90e0-5a70bbed8876:8bbdf923-7acf\\",\\n \\"sceneName\\": \\"Scene 1\\",\\n \\"layerName\\": \\"layer-ce6e40ba-9eb2-e7b6-379b-fca4e538ee71\\",\\n \\"layerItemId\\": 3\\n }","doc_response_description":"","doc_response_example":"{\\n \\"sourceName\\": \\"id_ad423058-57bd-22fc-ba78-e12f4054231e\\",\\n \\"inputName\\": \\"Input 8\\",\\n \\"layerName\\": \\"layer-ce6e40ba-9eb2-e7b6-379b-fca4e538ee71\\",\\n \\"layerItemId\\": 4,\\n \\"width\\": 1920,\\n \\"height\\": 1080,\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"id-2f7baeba-bef5-57fd-90e0-5a70bbed8876\\"\\n }","requestType":"producer.layers.inputs.duplicate","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"},{"id":"layerName","property":"required","prettyName":"Layer name","type":"LayerName"},{"id":"layerItemId","property":"required","range":{"min":0,"max":100},"prettyName":"layer item id","type":"number"}],"responseParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"string"},{"id":"layerName","property":"required","prettyName":"Layer name","type":"string"},{"id":"inputName","property":"required","prettyName":"Input name","type":"string"},{"id":"layerItemId","property":"required","range":{"min":0,"max":100},"prettyName":"Layer item id","type":"number"},{"id":"width","property":"required","range":{"min":0,"max":100000},"prettyName":"Width","type":"number"},{"id":"height","property":"required","range":{"min":0,"max":100000},"prettyName":"Height","type":"number"}]},{"pretty_name":"Set order of all layer items","doc_request_description":"producer.layers.inputs.order.set","doc_request_example":"{\\n \\"request-type\\": \\"\\",\\n \\"message-id\\": \\"id-9d2900a2-cb34-d32c-a0cc-c9af9d91f481:29d38fdd-91f2\\",\\n \\"sceneName\\": \\"Scene 2\\",\\n \\"layerName\\": \\"layer-15cc5743-0dcf-852c-eddd-14d446a48db7\\",\\n \\"layerItems\\": [\\n {\\n \\"name\\": \\"id-a70fa548-5f76-7fba-9a29-109503ef5cb4\\",\\n \\"id\\": 4,\\n \\"displayName\\": \\"Eleven Sports HLS\\"\\n },\\n {\\n \\"name\\": \\"id-b42c8f65-aaef-e656-3373-60e2e582f236\\",\\n \\"id\\": 5,\\n \\"displayName\\": \\"Eleven Sports HLS\\"\\n },\\n {\\n \\"name\\": \\"id-4f67c5c2-f067-82d3-2ef7-fb5f6a0503b9\\",\\n \\"id\\": 1,\\n \\"displayName\\": \\"1 <80><94> kopia\\"\\n },\\n {\\n \\"name\\": \\"id-7f05335b-6623-a8da-16ed-da329ece4f20\\",\\n \\"id\\": 2,\\n \\"displayName\\": \\"1920px-Flag_of_Iran_with_standardized_lion_and_sun.svg.png\\"\\n },\\n {\\n \\"name\\": \\"id-76879773-4e64-c513-f86c-5e5e8f4f2014\\",\\n \\"id\\": 3,\\n \\"displayName\\": \\"09fa82a0-cc81-11e8-a02e-592e7b2bf1e7.jpeg\\"\\n }\\n ]\\n }","doc_response_description":"","doc_response_example":"{\\"message-id\\":\\"id-9d2900a2-cb34-d32c-a0cc-c9af9d91f481\\",\\"status\\":\\"ok\\"}","requestType":"producer.layers.inputs.order.set","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"},{"id":"layerName","property":"required","prettyName":"Layer name","type":"LayerName"},{"id":"layerItems","property":"required","prettyName":"Layer items","type":"array"}]},{"pretty_name":"Remove layer item","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.layers.inputs.remove\\",\\n \\"message-id\\": \\"id-bc361a11-ddf=1-1b02-46e6-98af16732328:9b812bfc-c7fb\\",\\n \\"layerName\\": \\"layer-86257da8-032c-321b-f8b1-6ef200fa2aa2\\",\\n \\"layerItemId\\": 1\\n }","doc_response_description":"","doc_response_example":"{\\"status\\":\\"ok\\",\\"message-id\\":\\"id-bc361a11-ddf1-1b02-46e6-98af16732328\\"}","requestType":"producer.layers.inputs.remove","requestParams":[{"id":"layerName","property":"required","prettyName":"Layer name","type":"LayerName"},{"id":"layerItemId","property":"optional","range":{"min":0,"max":100},"prettyName":"Layer item id if source was added correctly.","type":"number"}]},{"pretty_name":"Select source","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.layers.inputs.select\\",\\n \\"message-id\\": \\"id-d757b5cb-83b1-2773-d99e-15ae1dd8fbd9:8bbdf923-7acf\\",\\n \\"hideLayerItemId\\": 2,\\n \\"showLayerItemId\\": 1,\\n \\"layerName\\": \\"layer-19caeb78-a03f-09bb-9e36-d35129bfd099\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"HideSceneItemId\\": 2,\\n \\"ShowSceneItemId\\": 1,\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"id-d757b5cb-83b1-2773-d99e-15ae1dd8fbd9\\"\\n }","requestType":"producer.layers.inputs.select","requestParams":[{"id":"layerName","property":"optional","prettyName":"Layer name","type":"LayerName"},{"id":"hideLayerItemId","property":"optional","range":{"min":0,"max":100},"prettyName":"Hide layer item id","type":"number"},{"id":"showLayerItemId","property":"optional","range":{"min":0,"max":100},"prettyName":"Show layer item id","type":"number"},{"id":"sceneIndex","property":"optional","range":{"min":0,"max":20},"prettyName":"Scene index","type":"number"},{"id":"layerIndex","property":"optional","range":{"min":0,"max":100},"prettyName":"layer index","type":"number"},{"id":"sourceIndex","property":"optional","range":{"min":0,"max":100},"prettyName":"Source index","type":"number"}]},{"pretty_name":"Set layer item transformations data","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.layers.items.properties.set\\",\\n \\"message-id\\": \\"id-840c3f60-30d4-b0ad-1332-0af2b6ccba7a:b797264f-f8c1\\",\\n \\"layerName\\": \\"layer-d32efa82-94a1-3d24-4c8c-b3cbc979a57b\\",\\n \\"properties\\": {\\n \\"locked\\": false,\\n \\"lockAspectRatio\\": true,\\n \\"flipVertical\\": false,\\n \\"flipHorizontal\\": false,\\n \\"crop\\": {\\n \\"bottom\\": 0,\\n \\"left\\": 0,\\n \\"right\\": 0,\\n \\"top\\": 0,\\n \\"prevTop\\": 0,\\n \\"prevLeft\\": 0,\\n \\"prevBottom\\": 0,\\n \\"prevRight\\": 0\\n },\\n \\"position\\": { \\"x\\": 0, \\"y\\": 0 },\\n \\"dimensions\\": { \\"width\\": 1314.174745703766, \\"height\\": 739.2232944583684 },\\n \\"scale\\": { \\"x\\": 0.6844660133873782, \\"y\\": 0.6844660133873782 },\\n \\"rotation\\": 0,\\n \\"visible\\": true,\\n \\"size\\": { \\"width\\": 1314.1747457037661, \\"height\\": 739.2232944583685 }\\n },\\n \\"item\\": {\\n \\"id\\": 2,\\n \\"locked\\": false,\\n \\"lockAspectRatio\\": true,\\n \\"flipVertical\\": false,\\n \\"flipHorizontal\\": false,\\n \\"crop\\": {\\n \\"bottom\\": 0,\\n \\"left\\": 0,\\n \\"right\\": 0,\\n \\"top\\": 0,\\n \\"prevTop\\": 0,\\n \\"prevLeft\\": 0,\\n \\"prevBottom\\": 0,\\n \\"prevRight\\": 0\\n },\\n \\"position\\": { \\"x\\": 0, \\"y\\": 0 },\\n \\"dimensions\\": { \\"width\\": 1314.174745703766, \\"height\\": 739.2232944583684 },\\n \\"scale\\": { \\"x\\": 1, \\"y\\": 1 },\\n \\"rotation\\": 0,\\n \\"visible\\": true,\\n \\"size\\": { \\"width\\": 1314.1747457037661, \\"height\\": 739.2232944583685 }\\n }\\n }","doc_response_description":"","doc_response_example":"{\\"message-id\\":\\"id-840c3f60-30d4-b0ad-1332-0af2b6ccba7a\\",\\"status\\":\\"ok\\"}","requestType":"producer.layers.items.properties.set","requestParams":[{"id":"layerName","property":"required","prettyName":"Layer name","type":"LayerName"},{"id":"item","property":"required","prettyName":"Transformations info","type":"object"},{"id":"properties","property":"required","prettyName":"Deprecated but used. This duplicates item object","type":"object"}]},{"pretty_name":"Set layer visibility","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.layers.visibility.set\\",\\n \\"message-id\\": \\"id-25cd8b5f-6e4b-4d27-dbe3-1955792b8548:b797264f-f8c1\\",\\n \\"sceneName\\": \\"Scene 1\\",\\n \\"sceneItem\\": { \\"name\\": \\"layer-8bc0a487-5525-7e14-0bb9-f7accef6a045\\" },\\n \\"visible\\": true\\n }","doc_response_description":"","doc_response_example":"{\\"message-id\\":\\"id-25cd8b5f-6e4b-4d27-dbe3-1955792b8548\\",\\"status\\":\\"ok\\"}","requestType":"producer.layers.visibility.set","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"},{"id":"sceneItem","property":"required","prettyName":"Scene item","type":"object"},{"id":"visible","property":"controllable","prettyName":"Visible","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","prettyName":"Controller value","type":"boolean"}]},{"pretty_name":"Add scene","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.scenes.add\\",\\n \\"message-id\\": \\"id-c7098f14-0148-b53c-c216-f4838dda3145\\",\\n \\"sceneType\\": \\"Scene\\",\\n \\"sceneName\\": \\"Scene 3\\",\\n \\"displayName\\": \\"Scene 3\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"name\\": \\"Scene 3\\",\\n \\"inputWidth\\": 1920,\\n \\"inputHeight\\": 1080,\\n \\"refCount\\": 0,\\n \\"displayName\\": \\"Scene 3\\",\\n \\"type\\": \\"scene\\",\\n \\"layoutItems\\": [],\\n \\"layout\\": {},\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"id-c7098f14-0148-b53c-c216-f4838dda3145\\"\\n }","requestType":"producer.scenes.add","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene Name","description":"New scene name","type":"string"},{"id":"sceneType","property":"optional","prettyName":"Scene type","type":"SceneType"},{"id":"displayName","property":"optional","prettyName":"Scene visible name","type":"string"}],"responseParams":[]},{"pretty_name":"Get scene display name","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.scenes.displayName.get","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"}],"responseParams":[{"id":"displayName","property":"required","prettyName":"Display name","type":"string"}]},{"pretty_name":"Set scene display name","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.scenes.displayName.set","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"},{"id":"displayName","property":"required","prettyName":"Display name","type":"string"}],"responseParams":[]},{"pretty_name":"Duplicate scene","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.scenes.duplicate\\",\\n \\"message-id\\": \\"id-b46f0d2d-0a23-f92c-c0cd-303687756f5c:d63c425d-1509\\",\\n \\"sceneName\\": \\"Scene 2\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"sceneName\\": \\"Scene 3\\",\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"id-b46f0d2d-0a23-f92c-c0cd-303687756f5c\\"\\n }","requestType":"producer.scenes.duplicate","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"}],"responseParams":[{"id":"sceneName","property":"required","prettyName":"Name of new scene","type":"string"}]},{"pretty_name":"Get all scenes data","doc_request_description":"","doc_response_description":"","requestType":"producer.scenes.get","requestParams":[{"id":"sceneIndex","property":"optional","range":{"min":0,"max":8},"prettyName":"Scene index","type":"number"},{"id":"sceneName","property":"optional","prettyName":"Scene name","type":"SceneName"},{"id":"sceneType","property":"optional","prettyName":"Scene type","type":"SceneType"}],"responseParams":[{"id":"found","property":"required","prettyName":"Found","type":"boolean"},{"id":"references","property":"required","prettyName":"references","type":"array"},{"id":"data","property":"optional","prettyName":"Data","type":"array"}]},{"pretty_name":"Add layer to scene","doc_request_description":"","doc_request_example":"\\n {\\n \\"layerName\\": \\"layer-9e1f58dc-24b1-44aa-1896-f777725eda0d\\",\\n \\"sceneName\\": \\"Scene2\\",\\n \\"orderPosition\\": 2,\\n \\"displayName\\": \\"Layer 3\\",\\n \\"message-id\\": \\"gateway_c67e4416-cb37-7578-481c-2301bbd65eb6\\",\\n \\"request-type\\": \\"producer.scenes.layers.add\\"\\n }\\n ","doc_response_description":"","doc_response_example":"\\n {\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"gateway_c67e4416-cb37-7578-481c-2301bbd65eb6\\",\\n \\"layerName\\": \\"layer-9e1f58dc-24b1-44aa-1896-f777725eda0d\\",\\n \\"sceneName\\": \\"Scene2\\",\\n \\"sceneItemId\\": 2\\n }\\n ","requestType":"producer.scenes.layers.add","requestParams":[{"id":"layerName","property":"required","prettyName":"New layer id","type":"string"},{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"},{"id":"orderPosition","property":"optional","range":{"min":0,"max":100},"prettyName":"Order position","defaultValue":0,"type":"number"},{"id":"displayName","property":"optional","prettyName":"Display name","type":"string"},{"id":"visible","property":"optional","prettyName":"Visible","type":"boolean"}],"responseParams":[{"id":"layerName","property":"required","prettyName":"Layer name","type":"LayerName"},{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"},{"id":"sceneItemId","property":"required","range":{"min":0,"max":100},"prettyName":"Scene item id","type":"number"}]},{"pretty_name":"Reorder layers on scene","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.scenes.layers.order.set\\",\\n \\"message-id\\": \\"id-64580fe5-56b0-e221-c071-ee4a61a6566e:29d38fdd-91f2\\",\\n \\"sceneName\\": \\"Scene 1\\",\\n \\"sceneItems\\": [\\n { \\"name\\": \\"layer-d32efa82-94a1-3d24-4c8c-b3cbc979a57b\\", \\"id\\": 9 },\\n { \\"name\\": \\"layer-8bc0a487-5525-7e14-0bb9-f7accef6a045\\", \\"id\\": 8 }\\n ]\\n }","doc_response_description":"","doc_response_example":"{\\"message-id\\":\\"id-64580fe5-56b0-e221-c071-ee4a61a6566e\\",\\"status\\":\\"ok\\"}","requestType":"producer.scenes.layers.order.set","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"},{"id":"sceneItems","property":"required","prettyName":"Scene items","type":"array"}]},{"pretty_name":"Remove layer from scene","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.scenes.layers.remove\\",\\n \\"message-id\\": \\"id-5ebc1a99-a525-4d87-d9bd-598bda3f449d:6ada89eb-b648\\",\\n \\"layerName\\": \\"layer-0d3e8f60-0377-da6f-5f12-26e91355576d\\",\\n \\"sceneName\\": \\"mdsk:1\\",\\n \\"sceneItemId\\": 1\\n }","doc_response_description":"","doc_response_example":"{\\"status\\":\\"ok\\",\\"message-id\\":\\"id-5ebc1a99-a525-4d87-d9bd-598bda3f449d\\"}","requestType":"producer.scenes.layers.remove","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"},{"id":"sceneItemId","property":"required","range":{"min":0,"max":100},"prettyName":"Scene item id","type":"number"}]},{"pretty_name":"Lock editing on selected scene","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.scenes.lock\\",\\n \\"message-id\\": \\"id-5ebc1a99-a525-4d87-d9bd-598bda3f449d:6ada89eb-b648\\",\\n \\"sceneName\\": \\"Scene 1\\",\\n }","doc_response_description":"","doc_response_example":"{\\"status\\":\\"ok\\",\\"message-id\\":\\"id-5ebc1a99-a525-4d87-d9bd-598bda3f449d\\"}","requestType":"producer.scenes.lock","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"}]},{"pretty_name":"Set scenes order","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.scenes.order.set\\",\\n \\"message-id\\": \\"id-5ebc1a99-a525-4d87-d9bd-598bda3f449d:6ada89eb-b648\\",\\n \\"scenesOrder\\": [\\"Scene 1\\", \\"Scene 2\\"],\\n }","doc_response_description":"","doc_response_example":"{\\"status\\":\\"ok\\",\\"message-id\\":\\"id-5ebc1a99-a525-4d87-d9bd-598bda3f449d\\"}","requestType":"producer.scenes.order.set","requestParams":[{"id":"scenesOrder","property":"required","prettyName":"Scene names","type":"array"}]},{"pretty_name":"Delete scene","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.scenes.remove\\",\\n \\"message-id\\": \\"id-d91b3528-d40b-6086-fee3-b833e08413e5:d63c425d-1509\\",\\n \\"sceneName\\": \\"Scene 3\\",\\n \\"sceneType\\": \\"Scene\\"\\n }","doc_response_description":"","doc_response_example":"{ \\"status\\": \\"ok\\", \\"message-id\\": \\"id-d91b3528-d40b-6086-fee3-b833e08413e5\\" }","requestType":"producer.scenes.remove","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"}],"responseParams":[]},{"pretty_name":"Unlock editing on selected scene","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.scenes.unlock\\",\\n \\"message-id\\": \\"id-5ebc1a99-a525-4d87-d9bd-598bda3f449d:6ada89eb-b648\\",\\n \\"sceneName\\": \\"Scene 1\\",\\n }","doc_response_description":"","doc_response_example":"{\\"status\\":\\"ok\\",\\"message-id\\":\\"id-5ebc1a99-a525-4d87-d9bd-598bda3f449d\\"}","requestType":"producer.scenes.unlock","requestParams":[{"id":"sceneName","property":"required","prettyName":"Scene name","type":"SceneName"}]},{"pretty_name":"Set source asset url","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.source.asset.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source Name","type":"SourceName"},{"id":"assetUrl","property":"required","prettyName":"Asset url","type":"string"},{"id":"additionalData","property":"optional","prettyName":"","type":"object"}],"responseParams":[]},{"pretty_name":"Set source audio track index","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.source.audioTrackIndex.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source Name","type":"SourceName"},{"id":"audioTrackIndex","property":"required","range":{"min":0,"max":999999999},"prettyName":"Audio track index","type":"number"}],"responseParams":[]},{"pretty_name":"Set source hwDecode","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.source.hwDecode.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source Name","type":"SourceName"},{"id":"hwDecode","property":"required","prettyName":"hwDecode","type":"boolean"}],"responseParams":[]},{"pretty_name":"Set source offset","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.source.offset.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source Name","type":"SourceName"},{"id":"offset","property":"required","range":{"min":0,"max":999999999},"prettyName":"Offset value","type":"number"}],"responseParams":[]},{"pretty_name":"Set text source settings","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.source.text.settings.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source Name","type":"SourceName"},{"id":"url","property":"required","prettyName":"Overlay url","type":"string"},{"id":"textSettings","property":"required","prettyName":"Overlay settings object","type":"object"}],"responseParams":[]},{"pretty_name":"Set source cue in and out","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.cue.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"},{"id":"cueIn","property":"optional","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Cue in","type":"number"},{"id":"cueOut","property":"optional","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Cue out","type":"number"}],"responseParams":[]},{"pretty_name":"Set media time","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.currentTime.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"},{"id":"timestamp","property":"controllable","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Timestamp [ms]","type":"number"},{"id":"ignoreInNotifications","property":"optional","prettyName":"ignoreInNotifications","type":"boolean"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Controller value","type":"number"}]},{"pretty_name":"Set source deinterlace mode","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.deinterlace.set","requestParams":[{"id":"source","property":"required","prettyName":"Source name","type":"SourceName"},{"id":"mode","property":"controllable","values":["disable","yadif","yadif_2x"],"prettyName":"Mode","type":"select"},{"id":"fieldOrder","property":"required","values":["top"],"prettyName":"Field order","type":"select"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","values":["disable","yadif","yadif_2x"],"prettyName":"Controller value","type":"select"}],"responseParams":[]},{"pretty_name":"Get all sources","doc_request_description":"returns a list of sources used in the project along with their settings","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.get","requestParams":[{"id":"type","property":"optional","prettyName":"Source type","type":"SourceType"},{"id":"scope","property":"optional","prettyName":"Source Scope","type":"string"},{"id":"whereUsed","property":"optional","prettyName":"Information where the source was used","type":"boolean"}],"responseParams":[]},{"pretty_name":"Lis tproducer sources","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.list","requestParams":[],"responseParams":[]},{"pretty_name":"Change looping flag","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.looping.set","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"},{"id":"looping","property":"required","prettyName":"Is looping flag","type":"boolean"}],"responseParams":[]},{"pretty_name":"Switch play/pause","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.playPause","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"},{"id":"playPause","property":"optional","prettyName":"Force action. If true play if false pause.","type":"boolean"}],"responseParams":[]},{"pretty_name":"Reinit source","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.reload","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"}],"responseParams":[]},{"pretty_name":"Scrub source","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.scrub","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"},{"id":"timeOffset","property":"optional","range":{"min":-1.7976931348623157e+308,"max":1.7976931348623157e+308},"prettyName":"timeOffset","type":"number"},{"id":"frameOffset","property":"optional","range":{"min":-1.7976931348623157e+308,"max":1.7976931348623157e+308},"prettyName":"frameOffset","type":"number"}],"responseParams":[]},{"pretty_name":"Stop source","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.stop","requestParams":[{"id":"sourceName","property":"required","prettyName":"Source name","type":"SourceName"}],"responseParams":[]},{"pretty_name":"Update source url","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.sources.url.update","requestParams":[],"responseParams":[]},{"pretty_name":"Add wipe transition","doc_request_description":"","doc_request_example":"{\\n \\"displayName\\": \\"1\\",\\n \\"transitionName\\": \\"135\\",\\n \\"mediaUrl\\": \\"https://d3p5rv6a2z7gyu.cloudfront.net/c/68/w/8de7fb0ac73618b1e4213945987e7c1d/wipe.mov\\",\\n \\"message-id\\": \\"gateway_eaeceeb5-ed07-f0a1-88fd-2d88a516c7d7\\",\\n \\"request-type\\": \\"producer.transitions.add\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"status\\": \\"ok\\",\\n \\"message-id\\": \\"gateway_eaeceeb5-ed07-f0a1-88fd-2d88a516c7d7\\"\\n }","requestType":"producer.transitions.add","requestParams":[{"id":"transitionName","property":"required","prettyName":"Transition name","type":"string"},{"id":"displayName","property":"optional","prettyName":"Display name","type":"string"},{"id":"mediaUrl","property":"required","prettyName":"Media url","type":"string"},{"id":"thumbnail","property":"optional","prettyName":"Thumbnail url","type":"string"},{"id":"duration","property":"optional","range":{"min":0,"max":99999},"prettyName":"Duration","type":"number"}],"responseParams":[]},{"pretty_name":"Set current transition duration","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.transitions.duration.set\\",\\n \\"message-id\\": \\"id-4baf0866-7f7e-c633-0391-845d23fa96f5:7f113c48-f556\\",\\n \\"duration\\": 3000\\n }","doc_response_description":"","doc_response_example":"{\\n \\"message-id\\": \\"id-4baf0866-7f7e-c633-0391-845d23fa96f5:7f113c48-f556\\",\\n \\"status\\": \\"ok\\"\\n }","requestType":"producer.transitions.duration.set","requestParams":[{"id":"duration","property":"required","range":{"min":0,"max":99999},"prettyName":"Duration","defaultValue":500,"description":"[ms]","type":"number"}],"responseParams":[]},{"pretty_name":"Get transitions","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.transitions.get","requestParams":[],"responseParams":[{"id":"current-transition","property":"required","prettyName":"Current transtion name","type":"string"},{"id":"transitions","property":"required","prettyName":"Array of objects { name: string }","type":"array"}]},{"pretty_name":"Get all transitions","doc_request_description":"","doc_response_description":"","requestType":"producer.transitions.get2","requestParams":[],"responseParams":[]},{"pretty_name":"Take transition","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"producer.transitions.make\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"producer.transitions.make","requestParams":[],"responseParams":[{"id":"previewScene","property":"required","range":{"min":0,"max":20},"prettyName":"Preview scene index","type":"number"},{"id":"currentScene","property":"required","range":{"min":0,"max":20},"prettyName":"Program scene index","type":"number"},{"id":"editingScene","property":"required","range":{"min":0,"max":20},"prettyName":"Editing scene index","type":"number"}]},{"pretty_name":"","doc_request_description":"","doc_request_example":"","doc_response_description":"","doc_response_example":"","requestType":"producer.transitions.position.get","requestParams":[],"responseParams":[{"id":"position","property":"required","range":{"min":0,"max":1},"prettyName":"Normalized transition position","type":"number"}]},{"pretty_name":"Get TBar position","doc_request_description":"","doc_response_description":"","requestType":"producer.transitions.tbar.get","requestParams":[],"responseParams":[{"id":"position","property":"required","range":{"min":0,"max":1},"prettyName":"TBar position [0.0; 1.0]","type":"number"},{"id":"direction","property":"required","prettyName":"TBar direction","type":"string"}]},{"pretty_name":"Reset TBar","doc_request_description":"","doc_response_description":"","requestType":"producer.transitions.tbar.reset","requestParams":[],"responseParams":[]},{"pretty_name":"Set TBar position","doc_request_description":"","doc_response_description":"","requestType":"producer.transitions.tbar.set","requestParams":[{"id":"position","property":"controllable","range":{"min":0,"max":1},"prettyName":"TBar position [0.0; 1.0]","type":"number"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":0,"max":1},"prettyName":"Controller value","type":"number"}],"responseParams":[]},{"pretty_name":"Select transition","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\": \\"producer.transitions.transition.set\\",\\n \\"transition-name\\": \\"135\\",\\n \\"message-id\\": \\"gateway_gateway_a50e9ac1-4385-dd35-01d6-52a2a5bebf97\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"message-id\\": \\"gateway_gateway_a50e9ac1-4385-dd35-01d6-52a2a5bebf97\\",\\n \\"status\\": \\"ok\\"\\n }","requestType":"producer.transitions.transition.set","requestParams":[{"id":"transition-name","property":"required","prettyName":"Transition name","type":"TransitionName"}],"responseParams":[]},{"pretty_name":"Get tally (SourcesStatus)","doc_request_description":"Get tally (SourcesStatus)","doc_response_description":"","requestType":"producer.tally.get","requestParams":[]}],"project":[{"pretty_name":"Get project","doc_request_description":"Return latest version of project","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"project.get\\",\\n }","doc_response_description":"","doc_response_example":"","requestType":"project.get","requestParams":[{"id":"path","property":"optional","prettyName":"","type":"string"}],"responseParams":[{"id":"data","property":"required","prettyName":"State","type":"object"}]}],"replays":[{"pretty_name":"Available sources","doc_request_description":"Returns a list of sources that can be added to replay","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.available.sources.get\\",\\n }","doc_response_description":"","doc_response_example":"","requestType":"replays.available.sources.get","requestParams":[],"responseParams":[{"id":"sources","property":"required","prettyName":"Object where properties names are ources types and values are arrays od sources objects","type":"object"},{"id":"types","property":"required","prettyName":"Sources types","description":"Array of sources types names","type":"array of strings"}]},{"pretty_name":"","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.get\\",\\n }","doc_response_description":"","doc_response_example":"","requestType":"replays.get","requestParams":[],"responseParams":[{"id":"replay","property":"required","prettyName":"Replay state","type":"object"}]},{"pretty_name":"Show original source on the output","doc_request_description":"Currently when switching output mode also all slots will be switched.","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.output.original\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.output.original","requestParams":[]},{"pretty_name":"Show replay video on output","doc_request_description":"Currently when switching output mode also all slots will be switched.","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.output.replay\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.output.replay","requestParams":[]},{"pretty_name":"Setup connected slot control","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.control.connected.set\\",\\n \\"linked\\":true\\n }","doc_response_description":"","doc_response_example":"","requestType":"replays.slot.control.connected.set","requestParams":[{"id":"connected","property":"required","prettyName":"Is slot control connected?","type":"boolean"}]},{"pretty_name":"Grab replay(s)","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.grab\\",\\n \\"slot\\":0,\\n \\"source\\":\\"id-121221-121212-121212\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.grab","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"},{"id":"seek_to_end","property":"optional","prettyName":"Seek to end","type":"boolean"}]},{"pretty_name":"Reset cue","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.cue.reset\\",\\n \\"slot\\":\\"all\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.playback.cue.reset","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Set cue in","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.cue_in.set\\",\\n \\"slot\\":\\"all\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.playback.cue_in.set","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Set cue out","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.cue_out.set\\",\\n \\"slot\\":\\"all\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.playback.cue_out.set","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Play/pause slot","doc_request_description":"Please read https://tellyo.atlassian.net/browse/TRD-5252 for information how this button should work.","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.playPause\\",\\n \\"slot\\":\\"all\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.playback.playPause","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Restart slot playback","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.restart\\",\\n \\"slot\\":\\"all\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.playback.restart","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Seek to begin","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.seek.begin\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"replays.slot.playback.seek.begin","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Seek to end","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.seek.end\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"replays.slot.playback.seek.end","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Seek by frames num","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.seek.frames\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"replays.slot.playback.seek.frames","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"},{"id":"num_frames","property":"required","range":{"min":-10000,"max":10000},"prettyName":"Number of frames","type":"number"}]},{"pretty_name":"Seek second backward","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.seek.secondBackward\\",\\n \\"slot\\":\\"all\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"replays.slot.playback.seek.secondBackward","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Seek second forward","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.seek.secondForward\\",\\n \\"slot\\":\\"all\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"replays.slot.playback.seek.secondForward","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Set playback speed","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.speed\\",\\n \\"slot\\":\\"all\\",\\n \\"speed_percent\\":75\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.playback.speed","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"},{"id":"speed_percent","property":"controllable","range":{"min":10,"max":200},"prettyName":"Speed percent","type":"number"},{"id":"controllerMode","property":"optional","values":["default","fixed","relative"],"prettyName":"Controller mode","type":"select"},{"id":"controllerValue","property":"optional","range":{"min":10,"max":200},"prettyName":"Controller value","type":"number"}]},{"pretty_name":"Stop slot playback","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.playback.stop\\",\\n \\"slot\\":\\"all\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.playback.stop","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Select slot (Camera selection / Switch)","doc_request_description":"This changes visible slot on output. In this case \'all\' value for slot param does not make sense. So use only 0, 1, 2 or 3.","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.select\\",\\n \\"slot\\":0\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.select","requestParams":[{"id":"slot","property":"required","range":{"min":0,"max":3},"prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Remove source from slot","doc_request_description":"","doc_request_example":"\\n {\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"replays.slot.source.remove\\",\\n \\"slot\\":0\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.source.remove","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"}]},{"pretty_name":"Set source to replay slot","doc_request_description":"If there is already a source, it is automatically cleaned up. So remove source is not needed.","doc_request_example":"\\n {\\n \\"message-id\\": \\"replays.slot.source.set_gwint\\",\\n \\"request-type\\": \\"replays.slot.source.set\\",\\n \\"slot\\": \\"0\\",\\n \\"source\\": \\"id-296cf369-8e6a-b1f0-b740-362fb14a6912\\"\\n }","doc_response_description":"Currently selected slot index","doc_response_example":"","requestType":"replays.slot.source.set","requestParams":[{"id":"slot","property":"optional","prettyName":"Replays slot","type":"number"},{"id":"source","property":"required","prettyName":"Source name","type":"SourceName"}]}],"scte":[{"pretty_name":"Set ad cue out marker\'s infinity parameter.","doc_request_description":"AutoCueIn paramater have to be given.","doc_request_example":"{\\n autoCueIn: true,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"scte.ad.marker.cueOut.autoCueIn.set\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"SCTE35\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Status of the request with autoCueIn parameter is returned.","doc_response_example":"{\\n autoCueIn: true,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n status: \\"ok\\"\\n }","requestType":"scte.ad.marker.cueOut.autoCueIn.set","requestParams":[{"id":"autoCueIn","property":"required","prettyName":"AutoCueIn parameter of the cueOut scte marker.","type":"boolean"}]},{"pretty_name":"Set ad cue out marker\'s duration.","doc_request_description":"Scte duration have to be given.","doc_request_example":"{\\n duration: 70,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"scte.ad.marker.cueOut.duration.set\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"SCTE35\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Status of the request with duration is returned.","doc_response_example":"{\\n duration: 7000,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n status: \\"ok\\"\\n }","requestType":"scte.ad.marker.cueOut.duration.set","requestParams":[{"id":"duration","property":"required","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Duratiion of the cueOut scte marker.","type":"number"}]},{"pretty_name":"Set ad cue out marker\'s infinity parameter.","doc_request_description":"Inifinity paramater have to be given.","doc_request_example":"{\\n infinite: true,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"scte.ad.marker.cueOut.infinite.set\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"SCTE35\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Status of the request with infinity parameter is returned.","doc_response_example":"{\\n infinite: true,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n status: \\"ok\\"\\n }","requestType":"scte.ad.marker.cueOut.infinite.set","requestParams":[{"id":"infinite","property":"required","prettyName":"Infinite parameter of the cueOut scte marker.","type":"boolean"}]},{"pretty_name":"End ad marker.","doc_request_description":"Scte duration, timestampMode, and autoInMarker have to be given.","doc_request_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"scte.ad.marker.end\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"SCTE35\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n status: \\"ok\\"\\n }","requestType":"scte.ad.marker.end","requestParams":[]},{"pretty_name":"Get ad markers.","doc_request_description":"","doc_request_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"scte.ad.marker.get\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"SCTE35\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"","doc_response_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n status: \\"ok\\"\\n }","requestType":"scte.ad.marker.get","requestParams":[]},{"pretty_name":"Set ad marker.","doc_request_description":"Scte duration, timestampMode, and autoInMarker have to be given.","doc_request_example":"{\\n durationMillis: 7000,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"scte.ad.marker.set\\",\\n timestampMode: \\"Cue In\\",\\n autoInMarker: true,\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"SCTE35\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n status: \\"ok\\"\\n }","requestType":"scte.ad.marker.set","requestParams":[{"id":"timestampMode","property":"required","prettyName":"Scte\'s timestamp mode.","type":"string"},{"id":"durationMillis","property":"optional","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Duratiion of the scte cueOut marker.","type":"number"},{"id":"autoInMarker","property":"optional","prettyName":"Should the marker be auto?","type":"boolean"}]},{"pretty_name":"Clear source\'s scte marker.","doc_request_description":"Source name, and scte markerTrigger have to be given.","doc_request_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"scte.source.marker.clear\\",\\n markerTrigger: \\"onStart\\",\\n sourceName: \\"playlist-source-0fc73eca-2098-fca6-b964-0b0c98809414\\",\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n status: \\"ok\\"\\n }","requestType":"scte.source.marker.clear","requestParams":[{"id":"markerTrigger","property":"required","prettyName":"Scte\'s marker type.","type":"string"},{"id":"sourceName","property":"required","prettyName":"Source\'s name.","type":"string"}]},{"pretty_name":"Set source\'s scte marker.","doc_request_description":"Source name, scte duration, offset, markerTrigger, and autoInMarker have to be given.","doc_request_example":"{\\n offset: 1000,\\n durationMillis: 7000,\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n request-type: \\"scte.source.marker.set\\",\\n markerTrigger: \\"onStart\\",\\n sourceName: \\"playlist-source-0fc73eca-2098-fca6-b964-0b0c98809414\\",\\n autoInMarker: true,\\n trackingData: {\\n applicationId: \\"id-0b750bfc-a748-06ec-5dc2-18ca904c87db\\",\\n applicationName: \\"PLAYOUTS\\",\\n ts: 1702985390434,\\n uiElement: \\"unkown\\",\\n userId: 100000629 \\n }\\n }","doc_response_description":"Status of the request is returned.","doc_response_example":"{\\n message-id: \\"id-69c1c856-9fc0-ae2d-ff1d-a85d6478f990\\",\\n status: \\"ok\\"\\n }","requestType":"scte.source.marker.set","requestParams":[{"id":"markerTrigger","property":"required","prettyName":"Scte\'s marker type.","type":"string"},{"id":"sourceName","property":"required","prettyName":"Source\'s name.","type":"string"},{"id":"durationMillis","property":"optional","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Duratiion of the source\'s scte marker.","type":"number"},{"id":"offset","property":"optional","range":{"min":0,"max":1.7976931348623157e+308},"prettyName":"Offset of the source\'s scte marker.","type":"number"},{"id":"autoInMarker","property":"optional","prettyName":"Should the marker be auto?","type":"boolean"}]}],"SIP":[{"pretty_name":"Clear all","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"sip.clear\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"sip.clear","requestParams":[]},{"pretty_name":"Display name set","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"sip.displayName.set\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"sip.displayName.set","requestParams":[{"id":"id","property":"required","prettyName":"Account id","type":"string"},{"id":"displayName","property":"required","prettyName":"Human readable name","type":"string"}]},{"pretty_name":"Get state of sip","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"sip.get\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"sip.get","requestParams":[]},{"pretty_name":"Discard source","doc_request_description":"Disconnect audio source","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"sip.mixer.discard\\",\\n \\"input\\":\\"id-1\\",\\n \\"output\\":\\"id-2\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"sip.mixer.discard","requestParams":[{"id":"input","property":"required","prettyName":"","type":"string"},{"id":"output","property":"required","prettyName":"","type":"string"}]},{"pretty_name":"Set the volume","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"sip.mixer.level.set\\",\\n \\"input\\":\\"id-1\\",\\n \\"output\\":\\"id-2\\",\\n \\"level\\":0\\n }","doc_response_description":"","doc_response_example":"","requestType":"sip.mixer.level.set","requestParams":[{"id":"input","property":"required","prettyName":"","type":"string"},{"id":"output","property":"required","prettyName":"","type":"string"},{"id":"level","property":"required","range":{"min":0,"max":999999},"prettyName":"","type":"number"}]},{"pretty_name":"Mute","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"sip.mixer.mute.set\\",\\n \\"input\\":\\"id-1\\",\\n \\"output\\":\\"id-2\\",\\n \\"mute\\": true\\n }","doc_response_description":"","doc_response_example":"","requestType":"sip.mixer.mute.set","requestParams":[{"id":"input","property":"required","prettyName":"","type":"string"},{"id":"output","property":"required","prettyName":"","type":"string"},{"id":"mute","property":"required","prettyName":"","type":"boolean"}]},{"pretty_name":"Sip register","doc_request_description":"Registers a sip account","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"sip.register\\",\\n \\"id\\":\\"1\\",\\n \\"server\\":\\"127.0.0.1\\",\\n \\"user_name\\":\\"demo\\",\\n \\"password\\":\\"123456\\",\\n \\"displayName\\":\\"Example account\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"sip.register","requestParams":[{"id":"id","property":"required","prettyName":"Account unique id","type":"string"},{"id":"server","property":"required","prettyName":"Server address","type":"string"},{"id":"user_name","property":"required","prettyName":"User name","type":"string"},{"id":"password","property":"required","prettyName":"Password","type":"string"},{"id":"displayName","property":"required","prettyName":"Human readable name of sip account","type":"string"}]},{"pretty_name":"Sip unregister","doc_request_description":"Unregister a sip account","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"sip.unregister\\",\\n \\"id\\":\\"1\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"sip.unregister","requestParams":[{"id":"id","property":"required","prettyName":"Account id","type":"string"}]}],"recording":[{"pretty_name":"Create channel","doc_request_description":"Creates a dedicated channel for recording a program","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.recording.channel.create\\",\\n \\"channelName\\": \\"Sample Channel name\\",\\n \\"profileId\\": 23\\n }","doc_response_example":"{\\n \\"message-id\\": \\"d\\",\\n \\"socials\\": {\\"items\\": []}\\n }","doc_response_description":"Returns the modified profile list","requestType":"producer.recording.channel.create","requestParams":[{"id":"authKey","property":"optional","prettyName":"authKey","type":"string"},{"id":"channelName","property":"required","prettyName":"channelName","type":"string"},{"id":"profileId","property":"required","range":{"min":0,"max":999999},"prettyName":"Profile ID","type":"number"}]},{"pretty_name":"Get recording service status","doc_request_description":"Returns information about currently ongoing recordings.","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.recording.get\\"\\n }","doc_response_example":"{\\n \\"producer\\":\\n {\\"streams\\":[\\n {\\"streamId\\":4769,\\"credentialsId\\":384,\\"type\\":\\"tellyoRecording\\"},\\n {\\"streamId\\":586,\\"credentialsId\\":303,\\"type\\":\\"tellyoRecording\\"}\\n ],\\n \\"isLive\\":true},\\n \\"status\\":\\"ok\\",\\n \\"message-id\\":\\"d\\"\\n }","doc_response_description":"","requestType":"producer.recording.get","requestParams":[],"responseParams":[]},{"pretty_name":"Start recording","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.recording.start\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"producer.recording.start","requestParams":[{"id":"userId","property":"required","range":{"min":0,"max":9999999999},"prettyName":"User ID","type":"number"}],"responseParams":[]},{"pretty_name":"Stop recording","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.recording.stop\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"producer.recording.stop","requestParams":[{"id":"userId","property":"required","range":{"min":0,"max":9999999999},"prettyName":"User ID","type":"number"},{"id":"credentialsId","property":"optional","range":{"min":0,"max":999999},"prettyName":"Credentials ID","type":"number"}],"responseParams":[]}],"streaming":[{"pretty_name":"Get streaming service status","doc_request_description":"Returns information about currently ongoing transmissions.","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.streaming.get\\"\\n }","doc_response_example":"{\\n \\"producer\\":\\n {\\"streams\\":[\\n {\\"streamId\\":4769,\\"credentialsId\\":384,\\"type\\":\\"custom\\"},\\n {\\"streamId\\":586,\\"credentialsId\\":303,\\"type\\":\\"twitter\\"}\\n ],\\n \\"isLive\\":true},\\n \\"status\\":\\"ok\\",\\n \\"message-id\\":\\"d\\"\\n }","doc_response_description":"","requestType":"producer.streaming.get","requestParams":[],"responseParams":[{"id":"producer","property":"required","prettyName":"Producer data","type":"object"}]},{"pretty_name":"Sets additional options for profiles","doc_request_description":"","doc_request_example":"{\\n \\"request-type\\":\\"producer.streaming.profile.settings.set\\",\\n \\"message-id\\":\\"d\\",\\n \\"name\\":\\"facebook\\",\\n \\"settings\\":[{\\"profileId\\":\\"ALL\\",\\"title\\":\\"y\\",\\"description\\":\\"x\\",\\"saveVod\\":true}]\\n }","doc_response_description":"Returns an object with additional settings for profiles","doc_response_example":"\\n {\\n \\"message-id\\" : \\"id-fc3b8eba-6c23-9bd4-3a2d-cb11bbcfbf6e\\",\\n \\"status\\":\\"ok\\",\\n \\"socials\\":{\\"profileSettings\\": {}}\\n }\\n ","requestType":"producer.streaming.profile.settings.set","requestParams":[{"id":"name","property":"required","prettyName":"name","type":"string"},{"id":"settings","property":"required","prettyName":"Settings","type":"object"}],"responseParams":[{"id":"socials","property":"required","prettyName":"Socials","type":"object"}]},{"pretty_name":"get streaming profiles","doc_request_description":"Give a list of available streaming profiles","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"producer.streaming.profile.state.get\\"\\n }","doc_response_example":"{\\n \\"message-id\\": \\"d\\",\\n \\"socials\\": {\\"items\\": []},\\n \\"status\\": \\"ok\\"\\n }","doc_response_description":"Returns the state of the profile tree","requestType":"producer.streaming.profile.state.get","requestParams":[],"responseParams":[{"id":"socials","property":"required","prettyName":"Socials","type":"object"}]},{"pretty_name":"Sets the data of streaming profiles","doc_request_description":"Allows you to modify profile parameters. We can set data such as: profile is selected, profile output, audio tracks","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.streaming.profile.state.set\\",\\n \\"id\\":274,\\n \\"name\\":\\"facebook\\",\\n \\"state\\": {\\"selected\\": true, \\"audioTracks\\": [\\"main\\"]}\\n }","doc_response_example":"{\\n \\"message-id\\": \\"d\\",\\n \\"socials\\": {\\"items\\": []},\\n \\"status\\": \\"ok\\"\\n }","doc_response_description":"Returns the modified state of the profile tree","requestType":"producer.streaming.profile.state.set","requestParams":[{"id":"name","property":"required","prettyName":"name","type":"string"},{"id":"id","property":"required","range":{"min":0,"max":100000},"prettyName":"ID","type":"number"},{"id":"state","property":"required","prettyName":"State","type":"object"}],"responseParams":[{"id":"socials","property":"required","prettyName":"Socials","type":"object"}]},{"pretty_name":"Refresh streaming profiles","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.streaming.profiles.refresh\\",\\n }","doc_response_example":"{\\n \\n }","doc_response_description":"","requestType":"producer.streaming.profiles.refresh","requestParams":[],"responseParams":[]},{"pretty_name":"Get streaming settings","doc_request_description":"Returns the title and description of the published video","doc_request_example":"{\\n \\"request-type\\":\\"producer.streaming.settings.get\\",\\n \\"message-id\\":\\"d\\"\\n }","doc_response_description":"","doc_response_example":"{\\n \\"producer\\":{\\"streamTitle\\":\\"Sample title\\",\\"streamDescription\\":\\"Sample description\\"},\\n \\"status\\":\\"ok\\",\\n \\"message-id\\":\\"d\\"\\n }","requestType":"producer.streaming.settings.get","requestParams":[],"responseParams":[{"id":"producer","property":"required","prettyName":"Producer data","type":"object"}]},{"pretty_name":"set streaming settings","doc_request_description":"Here you can set the title and description of the published stream","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.streaming.settings.set\\",\\n \\"values\\": {\\"streamTitle\\": \\"Sample title\\", \\"streamDescription\\": \\"Sample description\\" }\\n }","doc_response_example":"{\\n \\"producer\\":{\\"streamTitle\\":\\"Sample title\\",\\"streamDescription\\":\\"Sample description\\"},\\n \\"status\\":\\"ok\\",\\n \\"message-id\\":\\"d\\"\\n }","doc_response_description":"Modified data","requestType":"producer.streaming.settings.set","requestParams":[{"id":"values","property":"required","prettyName":"values","type":"object"}],"responseParams":[{"id":"producer","property":"required","prettyName":"Producer data","type":"object"}]},{"pretty_name":"Start streaming","doc_request_description":"Go live with your chosen social media.","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"producer.streaming.start\\"\\n }","doc_response_example":"\\n {\\n \\"producer\\":{\\"isLive\\":true,\\"credentialsSettingUp\\":[396]},\\n \\"status\\":\\"ok\\",\\n \\"message-id\\":\\"d\\"\\n }\\n ","doc_response_description":"Returns the state of the producer and a collection of currently initiated streams","requestType":"producer.streaming.start","requestParams":[{"id":"userId","property":"required","range":{"min":0,"max":9999999999},"prettyName":"User ID","type":"number"}],"responseParams":[{"id":"producer","property":"required","prettyName":"Producer data","type":"object"}]},{"pretty_name":"Get streaming status","doc_request_description":"Gives basic information about the streaming status.","doc_request_example":"{\\"request-type\\":\\"producer.streaming.status.get\\",\\"message-id\\":\\"gwint_a90981dd-2425-21f2-ccef-bd5e0b1cbdad\\"}","doc_response_example":"{\\"streamingStatus\\":{\\"isLive\\":false,\\"canStart\\":true,\\"canStop\\":false,\\"streamingStartedISO\\":null,\\"streamingTime\\":\\"\\"},\\"status\\":\\"ok\\",\\"message-id\\":\\"gwint_a90981dd-2425-21f2-ccef-bd5e0b1cbdad\\"}","doc_response_description":"The information returned is: it is active, can be start or stop streaming, start time and duration","requestType":"producer.streaming.status.get","requestParams":[],"responseParams":[]},{"pretty_name":"Stop streaming","doc_request_description":"Stops the active or selected broadcast video stream","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"producer.streaming.stop\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"producer.streaming.stop","requestParams":[{"id":"userId","property":"required","range":{"min":0,"max":9999999999},"prettyName":"User ID","type":"number"},{"id":"groupName","property":"optional","prettyName":"Group name","type":"string"},{"id":"credentialsId","property":"optional","range":{"min":0,"max":1000000},"prettyName":"Credentials ID","type":"number"}],"responseParams":[{"id":"producer","property":"required","prettyName":"Producer data","type":"object"}]}],"SyncGroup":[{"pretty_name":"Add group","doc_request_description":"Add sync group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"syncgroup.add\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"syncgroup.add","requestParams":[{"id":"groupName","property":"required","prettyName":"Display name of sync group","type":"string"},{"id":"groupId","property":"required","prettyName":"Group Id","type":"string"},{"id":"groupSettings","property":"required","prettyName":"Settings of gorup","type":"object"}]},{"pretty_name":"Get sync group state","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"syncgroup.get\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"syncgroup.get","requestParams":[]},{"pretty_name":"Remove","doc_request_description":"Remove sync group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"syncgroup.remove\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"syncgroup.remove","requestParams":[{"id":"groupId","property":"required","prettyName":"Group Id","type":"string"}]},{"pretty_name":"Add source","doc_request_description":"Add source to sync group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"syncgroup.source.add\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"syncgroup.source.add","requestParams":[{"id":"groupId","property":"required","prettyName":"Group Id","type":"string"},{"id":"channelId","property":"required","prettyName":"Channel Id","type":"string"},{"id":"channelName","property":"required","prettyName":"Channel name","type":"string"},{"id":"groupName","property":"required","prettyName":"Group name","type":"string"}]},{"pretty_name":"Remove source","doc_request_description":"Remove source from sync group","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\":\\"syncgroup.source.remove\\"\\n }","doc_response_description":"","doc_response_example":"","requestType":"syncgroup.source.remove","requestParams":[{"id":"channelId","property":"required","prettyName":"Channel Id","type":"string"}]}],"timer":[{"pretty_name":"Get timer state","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"timer.get\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"timer.get","requestParams":[],"responseParams":[]},{"pretty_name":"Pause timer","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"timer.pause\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"timer.pause","requestParams":[{"id":"timerId","property":"required","prettyName":"Timer ID","type":"string"}],"responseParams":[]},{"pretty_name":"Reset timer","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"timer.reset\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"timer.reset","requestParams":[{"id":"timerId","property":"required","prettyName":"Timer ID","type":"string"}],"responseParams":[]},{"pretty_name":"Create new timer","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"timer.set\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"timer.set","requestParams":[{"id":"displayName","property":"optional","prettyName":"Human readable name","type":"string"},{"id":"mode","property":"required","prettyName":"CLOCK, UP, DOWN","type":"string"},{"id":"hours","property":"required","range":{"min":0,"max":23},"prettyName":"","type":"number"},{"id":"minutes","property":"required","range":{"min":0,"max":59},"prettyName":"","type":"number"},{"id":"seconds","property":"required","range":{"min":0,"max":59},"prettyName":"","type":"number"}],"responseParams":[]},{"pretty_name":"Start timer","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"timer.start\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"timer.start","requestParams":[{"id":"timerId","property":"required","prettyName":"Timer ID","type":"string"}],"responseParams":[]},{"pretty_name":"Stop timer","doc_request_description":"","doc_request_example":"{\\n \\"message-id\\":\\"d\\",\\n \\"request-type\\": \\"timer.stop\\"\\n }","doc_response_example":"","doc_response_description":"","requestType":"timer.stop","requestParams":[{"id":"timerId","property":"required","prettyName":"Timer ID","type":"string"}],"responseParams":[]}]}')}},t={};function r(s){var n=t[s];if(void 0!==n)return n.exports;var o=t[s]={exports:{}};return e[s].call(o.exports,o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(5590)})(); \ No newline at end of file diff --git a/tellyo-streamstudio/package.json b/tellyo-streamstudio/package.json index b47ad211..cb0b1bdb 100644 --- a/tellyo-streamstudio/package.json +++ b/tellyo-streamstudio/package.json @@ -1 +1 @@ -{"name":"tellyo-streamstudio","version":"1.1.4","license":"MIT","type":"commonjs","dependencies":{}} \ No newline at end of file +{"name":"tellyo-streamstudio","version":"2.0.1","license":"MIT","type":"commonjs","dependencies":{}} \ No newline at end of file