6 lines
114 KiB
JavaScript
6 lines
114 KiB
JavaScript
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("audio[data-v-d09db2c2]{border-radius:100px}audio.shadowed[data-v-d09db2c2]{border:2px solid var(--color-primary-element)}.image-display{display:flex}.image-display img{width:auto;height:200px}.image-display img.clickable{cursor:pointer!important}.file-display{display:flex}.file-display .preview{display:flex;flex-direction:column;align-items:center;justify-content:center}.file-display .preview img{width:100px}.file-display .preview img.clickable{cursor:pointer!important}.file-display .preview .file-name{max-width:100px;max-height:100px;overflow:hidden;text-overflow:ellipsis}.assistant-audio-recorder-wrapper[data-v-e7522bfa]{display:flex;align-items:center;gap:10px}.assistant-audio-recorder-wrapper .recording[data-v-e7522bfa]{display:flex;align-items:center;gap:8px}.assistant-audio-recorder-wrapper .recording--indicator[data-v-e7522bfa]{width:16px;height:16px;flex:0 0 16px;border-radius:8px;background-color:var(--color-error)}@keyframes fadeOutIn-e7522bfa{0%{opacity:1}50%{opacity:.3}to{opacity:1}}.assistant-audio-recorder-wrapper .recording .fadeOutIn[data-v-e7522bfa]{animation:fadeOutIn-e7522bfa 3s infinite}.media-field{display:flex;flex-direction:column;align-items:start;gap:12px}.media-field .label-row{width:100%;display:flex;align-items:center;justify-content:start}.media-field .label-row .field-label{font-weight:700}.media-field .select-media{width:100%;display:flex;align-items:start;gap:8px}.media-field .media-value{display:flex;flex-direction:column;align-items:center;gap:4px;padding:12px;border-radius:var(--border-radius-large)}.media-field .media-value.row{flex-direction:row}.media-field .media-value:hover{background-color:var(--color-primary-element-light-hover)}.media-field .media-value .buttons{display:flex;gap:2px;justify-content:center}")),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
|
|
import{_ as ee}from"./_plugin-vue_export-helper-RS-qxU5_.chunk.mjs";import{a as V,o as B,h as X,k as K,b as te,m as ue,n as et,T as Ir,r as Z,f as ge,I as Er,w as oe,j as Mt,g as Q,i as Tr,y as kr}from"./runtime-dom.esm-bundler-Dyqpejx9.chunk.mjs";import{b as tt,C as Mr}from"./index-Dk4MzVw6.chunk.mjs";import{g as re,a as mt}from"./index-D953jVe0.chunk.mjs";import Oe from"./index-Ds-TrDn_.chunk.mjs";import{s as he,k as Ar,b as Yt}from"./index-DhgIrZpo.chunk.mjs";import{S as we,b as Or,a as xr,c as Sr}from"./constants-HI3vTFfS.chunk.mjs";const Ur={name:"CloseIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},Rr=["aria-hidden","aria-label"],Br=["fill","width","height"],Lr={d:"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"},Nr={key:0};function Vr(e,r,n,o,i,s){return B(),V("span",ue(e.$attrs,{"aria-hidden":n.title?null:"true","aria-label":n.title,class:"material-design-icon close-icon",role:"img",onClick:r[0]||(r[0]=a=>e.$emit("click",a))}),[(B(),V("svg",{fill:n.fillColor,class:"material-design-icon__svg",width:n.size,height:n.size,viewBox:"0 0 24 24"},[X("path",Lr,[n.title?(B(),V("title",Nr,te(n.title),1)):K("",!0)])],8,Br))],16,Rr)}const bn=ee(Ur,[["render",Vr]]),Pr={name:"TrayArrowDownIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},Dr=["aria-hidden","aria-label"],Fr=["fill","width","height"],Wr={d:"M2 12H4V17H20V12H22V17C22 18.11 21.11 19 20 19H4C2.9 19 2 18.11 2 17V12M12 15L17.55 9.54L16.13 8.13L13 11.25V2H11V11.25L7.88 8.13L6.46 9.55L12 15Z"},jr={key:0};function $r(e,r,n,o,i,s){return B(),V("span",ue(e.$attrs,{"aria-hidden":n.title?null:"true","aria-label":n.title,class:"material-design-icon tray-arrow-down-icon",role:"img",onClick:r[0]||(r[0]=a=>e.$emit("click",a))}),[(B(),V("svg",{fill:n.fillColor,class:"material-design-icon__svg",width:n.size,height:n.size,viewBox:"0 0 24 24"},[X("path",Wr,[n.title?(B(),V("title",jr,te(n.title),1)):K("",!0)])],8,Fr))],16,Dr)}const zr=ee(Pr,[["render",$r]]),Hr={name:"ShareVariantIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},qr=["aria-hidden","aria-label"],Gr=["fill","width","height"],Yr={d:"M18,16.08C17.24,16.08 16.56,16.38 16.04,16.85L8.91,12.7C8.96,12.47 9,12.24 9,12C9,11.76 8.96,11.53 8.91,11.3L15.96,7.19C16.5,7.69 17.21,8 18,8A3,3 0 0,0 21,5A3,3 0 0,0 18,2A3,3 0 0,0 15,5C15,5.24 15.04,5.47 15.09,5.7L8.04,9.81C7.5,9.31 6.79,9 6,9A3,3 0 0,0 3,12A3,3 0 0,0 6,15C6.79,15 7.5,14.69 8.04,14.19L15.16,18.34C15.11,18.55 15.08,18.77 15.08,19C15.08,20.61 16.39,21.91 18,21.91C19.61,21.91 20.92,20.61 20.92,19A2.92,2.92 0 0,0 18,16.08Z"},Zr={key:0};function Xr(e,r,n,o,i,s){return B(),V("span",ue(e.$attrs,{"aria-hidden":n.title?null:"true","aria-label":n.title,class:"material-design-icon share-variant-icon",role:"img",onClick:r[0]||(r[0]=a=>e.$emit("click",a))}),[(B(),V("svg",{fill:n.fillColor,class:"material-design-icon__svg",width:n.size,height:n.size,viewBox:"0 0 24 24"},[X("path",Yr,[n.title?(B(),V("title",Zr,te(n.title),1)):K("",!0)])],8,Gr))],16,qr)}const Kr=ee(Hr,[["render",Xr]]),Qr={name:"ContentSaveOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},Jr=["aria-hidden","aria-label"],eo=["fill","width","height"],to={d:"M17 3H5C3.89 3 3 3.9 3 5V19C3 20.1 3.89 21 5 21H19C20.1 21 21 20.1 21 19V7L17 3M19 19H5V5H16.17L19 7.83V19M12 12C10.34 12 9 13.34 9 15S10.34 18 12 18 15 16.66 15 15 13.66 12 12 12M6 6H15V10H6V6Z"},no={key:0};function ro(e,r,n,o,i,s){return B(),V("span",ue(e.$attrs,{"aria-hidden":n.title?null:"true","aria-label":n.title,class:"material-design-icon content-save-outline-icon",role:"img",onClick:r[0]||(r[0]=a=>e.$emit("click",a))}),[(B(),V("svg",{fill:n.fillColor,class:"material-design-icon__svg",width:n.size,height:n.size,viewBox:"0 0 24 24"},[X("path",to,[n.title?(B(),V("title",no,te(n.title),1)):K("",!0)])],8,eo))],16,Jr)}const oo=ee(Qr,[["render",ro]]),so={name:"AudioDisplay",components:{},props:{fileId:{type:Number,required:!0},taskId:{type:[Number,null],default:null},isOutput:{type:Boolean,default:!1},autoplay:{type:Boolean,default:!1}},emits:[],data(){return{}},computed:{audioUrl(){return this.isOutput?re("apps/assistant/api/v1/task/{taskId}/output-file/{fileId}/download",{taskId:this.taskId,fileId:this.fileId}):re("apps/assistant/api/v1/file/{fileId}/display",{fileId:this.fileId})}},watch:{},mounted(){console.debug("CURRENT TASK",this.taskId)},methods:{}},io=["src","autoplay"];function ao(e,r,n,o,i,s){return B(),V("audio",{src:s.audioUrl,controls:"",autoplay:n.autoplay,class:et({shadowed:n.isOutput})},null,10,io)}const lo=ee(so,[["render",ao],["__scopeId","data-v-d09db2c2"]]),co={name:"ImageDisplay",components:{},inject:["providedCurrentTaskId"],props:{taskId:{type:[Number,null],default:null},fileId:{type:Number,required:!0},isOutput:{type:Boolean,default:!1},borderRadius:{type:[Number,null],default:null},clickable:{type:Boolean,default:!1}},emits:[],data(){return{}},computed:{myCurrentTaskId(){return this.taskId??this.providedCurrentTaskId()},imageUrl(){return this.isOutput?re("apps/assistant/api/v1/task/{taskId}/output-file/{fileId}/preview?x=300&y=300",{taskId:this.myCurrentTaskId,fileId:this.fileId}):re("apps/assistant/api/v1/file/{fileId}/display",{fileId:this.fileId})},style(){return{"border-radius":this.borderRadius?this.borderRadius+"px":"var(--border-radius-large)"}}},watch:{},mounted(){console.debug("CURRENT TASK",this.myCurrentTaskId)},methods:{}},uo={class:"image-display"},ho=["src"];function po(e,r,n,o,i,s){return B(),V("div",uo,[X("img",{src:s.imageUrl,style:Ir(s.style),class:et({clickable:n.clickable})},null,14,ho)])}const fo=ee(co,[["render",po]]),mo={name:"FileDisplay",components:{},inject:["providedCurrentTaskId"],props:{taskId:{type:[Number,null],default:null},fileId:{type:Number,required:!0},isOutput:{type:Boolean,default:!1},clickable:{type:Boolean,default:!1}},emits:[],data(){return{fileInfo:{}}},computed:{myCurrentTaskId(){return this.taskId??this.providedCurrentTaskId()},imageUrl(){return this.isOutput?re("apps/assistant/api/v1/task/{taskId}/output-file/{fileId}/preview",{taskId:this.myCurrentTaskId,fileId:this.fileId}):mt("core/preview?fileId={fileId}&x=100&y=100&mimeFallback=true&a=0",{fileId:this.fileId})},fileName(){return this.fileInfo?.name}},watch:{},mounted(){console.debug("CURRENT TASK",this.myCurrentTaskId),this.getFileInfo()},methods:{getFileInfo(){const e=re("apps/assistant/api/v1/file/{fileId}/info",{fileId:this.fileId});Oe.get(e).then(r=>{this.fileInfo=r.data.ocs.data})}}},vo={class:"file-display"},go={class:"preview"},yo=["src"],wo=["title"];function bo(e,r,n,o,i,s){return B(),V("div",vo,[X("div",go,[X("img",{src:s.imageUrl,class:et({clickable:n.clickable})},null,10,yo),s.fileName?(B(),V("span",{key:0,class:"file-name",title:s.fileName},te(s.fileName),9,wo)):K("",!0)])])}const Co=ee(mo,[["render",bo]]),_o={name:"CheckIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},Io=["aria-hidden","aria-label"],Eo=["fill","width","height"],To={d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"},ko={key:0};function Mo(e,r,n,o,i,s){return B(),V("span",ue(e.$attrs,{"aria-hidden":n.title?null:"true","aria-label":n.title,class:"material-design-icon check-icon",role:"img",onClick:r[0]||(r[0]=a=>e.$emit("click",a))}),[(B(),V("svg",{fill:n.fillColor,class:"material-design-icon__svg",width:n.size,height:n.size,viewBox:"0 0 24 24"},[X("path",To,[n.title?(B(),V("title",ko,te(n.title),1)):K("",!0)])],8,Eo))],16,Io)}const Ao=ee(_o,[["render",Mo]]),Oo={name:"MicrophoneOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},xo=["aria-hidden","aria-label"],So=["fill","width","height"],Uo={d:"M17.3,11C17.3,14 14.76,16.1 12,16.1C9.24,16.1 6.7,14 6.7,11H5C5,14.41 7.72,17.23 11,17.72V21H13V17.72C16.28,17.23 19,14.41 19,11M10.8,4.9C10.8,4.24 11.34,3.7 12,3.7C12.66,3.7 13.2,4.24 13.2,4.9L13.19,11.1C13.19,11.76 12.66,12.3 12,12.3C11.34,12.3 10.8,11.76 10.8,11.1M12,14A3,3 0 0,0 15,11V5A3,3 0 0,0 12,2A3,3 0 0,0 9,5V11A3,3 0 0,0 12,14Z"},Ro={key:0};function Bo(e,r,n,o,i,s){return B(),V("span",ue(e.$attrs,{"aria-hidden":n.title?null:"true","aria-label":n.title,class:"material-design-icon microphone-outline-icon",role:"img",onClick:r[0]||(r[0]=a=>e.$emit("click",a))}),[(B(),V("svg",{fill:n.fillColor,class:"material-design-icon__svg",width:n.size,height:n.size,viewBox:"0 0 24 24"},[X("path",Uo,[n.title?(B(),V("title",Ro,te(n.title),1)):K("",!0)])],8,So))],16,xo)}const Lo=ee(Oo,[["render",Bo]]),No=e=>r=>{const n=e(r);return r.add(n),n},Vo=e=>(r,n)=>(e.set(r,n),n),Zt=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,Cn=536870912,Xt=Cn*2,Po=(e,r)=>n=>{const o=r.get(n);let i=o===void 0?n.size:o<Xt?o+1:0;if(!n.has(i))return e(n,i);if(n.size<Cn){for(;n.has(i);)i=Math.floor(Math.random()*Xt);return e(n,i)}if(n.size>Zt)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(i);)i=Math.floor(Math.random()*Zt);return e(n,i)},_n=new WeakMap,Do=Vo(_n),At=Po(Do,_n),Kt=No(At),Fo=e=>typeof e.start=="function",Qt=new WeakMap,Wo=e=>({...e,connect:({call:r})=>async()=>{const{port1:n,port2:o}=new MessageChannel,i=await r("connect",{port:n},[n]);return Qt.set(o,i),o},disconnect:({call:r})=>async n=>{const o=Qt.get(n);if(o===void 0)throw new Error("The given port is not connected.");await r("disconnect",{portId:o})},isSupported:({call:r})=>()=>r("isSupported")}),dt=new WeakMap,jo=e=>{if(dt.has(e))return dt.get(e);const r=new Map;return dt.set(e,r),r},In=e=>{const r=Wo(e);return n=>{const o=jo(n);n.addEventListener("message",(({data:c})=>{const{id:l}=c;if(l!==null&&o.has(l)){const{reject:u,resolve:h}=o.get(l);o.delete(l),c.error===void 0?h(c.result):u(new Error(c.error.message))}})),Fo(n)&&n.start();const i=(c,l=null,u=[])=>new Promise((h,d)=>{const v=At(o);o.set(v,{reject:d,resolve:h}),l===null?n.postMessage({id:v,method:c},u):n.postMessage({id:v,method:c,params:l},u)}),s=(c,l,u=[])=>{n.postMessage({id:null,method:c,params:l},u)};let a={};for(const[c,l]of Object.entries(r))a={...a,[c]:l({call:i,notify:s})};return{...a}}},ht=new Set,Jt=new Set,Be=new WeakMap,$o=In({deregister:({call:e})=>async r=>{const n=Be.get(r);if(n===void 0)throw new Error("There is no encoder registered with the given port.");const o=await e("deregister",{encoderId:n});return ht.delete(n),Be.delete(r),o},encode:({call:e})=>async(r,n)=>{const o=await e("encode",{encoderInstanceId:r,timeslice:n});return Jt.delete(r),o},instantiate:({call:e})=>async(r,n)=>{const o=Kt(Jt),i=await e("instantiate",{encoderInstanceId:o,mimeType:r,sampleRate:n});return{encoderInstanceId:o,port:i}},register:({call:e})=>async r=>{if(Be.has(r))throw new Error("");const n=Kt(ht);Be.set(r,n);try{return await e("register",{encoderId:n,port:r},[r])}catch(o){throw ht.delete(n),Be.delete(r),o}}}),zo=e=>{const r=new Worker(e);return $o(r)},Ho=`(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),c=void 0===a?r.size:a<s?a+1:0;if(!r.has(c))return e(r,c);if(r.size<o){for(;r.has(c);)c=Math.floor(Math.random()*s);return e(r,c)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(c);)c=Math.floor(Math.random()*n);return e(r,c)}},c=new WeakMap,i=r(c),d=a(i,c),l=t(d);e.addUniqueNumber=l,e.generateUniqueNumber=d}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";var e=r(455);const t=new WeakMap,n=new WeakMap,o=(r=>{const o=(s=r,{...s,connect:({call:e})=>async()=>{const{port1:r,port2:n}=new MessageChannel,o=await e("connect",{port:r},[r]);return t.set(n,o),n},disconnect:({call:e})=>async r=>{const n=t.get(r);if(void 0===n)throw new Error("The given port is not connected.");await e("disconnect",{portId:n})},isSupported:({call:e})=>()=>e("isSupported")});var s;return t=>{const r=(e=>{if(n.has(e))return n.get(e);const t=new Map;return n.set(e,t),t})(t);t.addEventListener("message",({data:e})=>{const{id:t}=e;if(null!==t&&r.has(t)){const{reject:n,resolve:o}=r.get(t);r.delete(t),void 0===e.error?o(e.result):n(new Error(e.error.message))}}),(e=>"function"==typeof e.start)(t)&&t.start();const s=(n,o=null,s=[])=>new Promise((a,c)=>{const i=(0,e.generateUniqueNumber)(r);r.set(i,{reject:c,resolve:a}),null===o?t.postMessage({id:i,method:n},s):t.postMessage({id:i,method:n,params:o},s)}),a=(e,r,n=[])=>{t.postMessage({id:null,method:e,params:r},n)};let c={};for(const[e,t]of Object.entries(o))c={...c,[e]:t({call:s,notify:a})};return{...c}}})({characterize:({call:e})=>()=>e("characterize"),encode:({call:e})=>(t,r)=>e("encode",{recordingId:t,timeslice:r}),record:({call:e})=>async(t,r,n)=>{await e("record",{recordingId:t,sampleRate:r,typedArrays:n},n.map(({buffer:e})=>e).filter(e=>e instanceof ArrayBuffer))}}),s=-32603,a=-32602,c=-32601,i=(e,t)=>Object.assign(new Error(e),{status:t}),d=e=>i('The handler of the method called "'.concat(e,'" returned an unexpected result.'),s),l=(e,t)=>async({data:{id:r,method:n,params:o}})=>{const a=t[n];try{if(void 0===a)throw(e=>i('The requested method called "'.concat(e,'" is not supported.'),c))(n);const t=void 0===o?a():a(o);if(void 0===t)throw(e=>i('The handler of the method called "'.concat(e,'" returned no required result.'),s))(n);const l=t instanceof Promise?await t:t;if(null===r){if(void 0!==l.result)throw d(n)}else{if(void 0===l.result)throw d(n);const{result:t,transferables:o=[]}=l;e.postMessage({id:r,result:t},o)}}catch(t){const{message:n,status:o=-32603}=t;e.postMessage({error:{code:o,message:n},id:r})}},u=new Map,h=(t,r,n)=>({...r,connect:({port:n})=>{n.start();const o=t(n,r),s=(0,e.generateUniqueNumber)(u);return u.set(s,()=>{o(),n.close(),u.delete(s)}),{result:s}},disconnect:({portId:e})=>{const t=u.get(e);if(void 0===t)throw(e=>i('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),a))(e);return t(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),f=(e,t,r=()=>!0)=>{const n=h(f,t,r),o=l(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},w=e=>{e.onmessage=null,e.close()},p=new Map,m=new Map,g=((e,t)=>r=>{const n=t.get(r);if(void 0===n)throw new Error("There was no encoder stored with the given id.");e.delete(n),t.delete(r)})(p,m),v=new Map,y=(e=>t=>{const r=e.get(t);if(void 0===r)throw new Error("There was no instance of an encoder stored with the given id.");return r})(v),M=((e,t)=>r=>{const n=t(r);return e.delete(r),n})(v,y),E=((e,t)=>r=>{const[n,o,s,a]=t(r);return s?new Promise(t=>{o.onmessage=({data:s})=>{0===s.length?(e(o),t(n.encode(r,null))):n.record(r,a,s)}}):n.encode(r,null)})(w,M),b=(e=>t=>{for(const[r,n]of Array.from(e.values()))if(r.test(t))return n;throw new Error("There is no encoder registered which could handle the given mimeType.")})(p),T=((e,t,r)=>(n,o,s)=>{if(t.has(n))throw new Error('There is already an encoder instance registered with an id called "'.concat(n,'".'));const a=r(o),{port1:c,port2:i}=new MessageChannel,d=[a,c,!0,s];return t.set(n,d),c.onmessage=({data:t})=>{0===t.length?(e(c),d[2]=!1):a.record(n,s,t.map(e=>"number"==typeof e?new Float32Array(e):e))},i})(w,v,b),I=((e,t,r)=>async(n,o)=>{const s=r(o),a=await s.characterize(),c=a.toString();if(e.has(c))throw new Error("There is already an encoder stored which handles exactly the same mime types.");if(t.has(n))throw new Error('There is already an encoder registered with an id called "'.concat(n,'".'));return e.set(c,[a,s]),t.set(n,c),a})(p,m,o),A=(e=>(t,r)=>{const[n]=e(t);return n.encode(t,r)})(y);f(self,{deregister:async({encoderId:e})=>(g(e),{result:null}),encode:async({encoderInstanceId:e,timeslice:t})=>{const r=null===t?await E(e):await A(e,t);return{result:r,transferables:r}},instantiate:({encoderInstanceId:e,mimeType:t,sampleRate:r})=>{const n=T(e,t,r);return{result:n,transferables:[n]}},register:async({encoderId:e,port:t})=>({result:await I(e,t)})})})()})();`,qo=new Blob([Ho],{type:"application/javascript; charset=utf-8"}),En=URL.createObjectURL(qo),Ot=zo(En),qe=Ot.encode,Tn=Ot.instantiate,Go=Ot.register;URL.revokeObjectURL(En);const Yo=e=>(r,n)=>{if(e===null)throw new Error("A native BlobEvent could not be created.");return new e(r,n)},Zo=(e,r)=>(n,o,i)=>{const s=[];let a=o,c=0;for(;c<n.byteLength;)if(a===null){const l=r(n,c);if(l===null)break;const{length:u,type:h}=l;a=h,c+=u}else{const l=e(n,c,a,i);if(l===null)break;const{content:u,length:h}=l;a=null,c+=h,u!==null&&s.push(u)}return{contents:s,currentElementType:a,offset:c}},Xo=(e,r)=>class{constructor(n=null){this._listeners=new WeakMap,this._nativeEventTarget=n===null?e():n}addEventListener(n,o,i){if(o!==null){let s=this._listeners.get(o);s===void 0&&(s=r(this,o),typeof o=="function"&&this._listeners.set(o,s)),this._nativeEventTarget.addEventListener(n,s,i)}}dispatchEvent(n){return this._nativeEventTarget.dispatchEvent(n)}removeEventListener(n,o,i){const s=o===null?void 0:this._listeners.get(o);this._nativeEventTarget.removeEventListener(n,s===void 0?null:s,i)}},Ko=e=>()=>{if(e===null)throw new Error("A native EventTarget could not be created.");return e.document.createElement("p")},Qo=(e="")=>{try{return new DOMException(e,"InvalidModificationError")}catch(r){return r.code=13,r.message=e,r.name="InvalidModificationError",r}},Jo=()=>{try{return new DOMException("","InvalidStateError")}catch(e){return e.code=11,e.name="InvalidStateError",e}},es=(e,r,n,o,i,s,a)=>class extends s{constructor(c,l={}){const{mimeType:u}=l;if(a!==null&&(u===void 0||a.isTypeSupported!==void 0&&a.isTypeSupported(u))){const h=e(a,c,l);super(h),this._internalMediaRecorder=h}else if(u!==void 0&&i.some(h=>h.test(u)))super(),a!==null&&a.isTypeSupported!==void 0&&a.isTypeSupported("audio/webm; codecs=pcm")?this._internalMediaRecorder=o(this,a,c,u):this._internalMediaRecorder=n(this,c,u);else throw a!==null&&e(a,c,l),r();this._ondataavailable=null,this._onerror=null,this._onpause=null,this._onresume=null,this._onstart=null,this._onstop=null}get mimeType(){return this._internalMediaRecorder.mimeType}get ondataavailable(){return this._ondataavailable===null?this._ondataavailable:this._ondataavailable[0]}set ondataavailable(c){if(this._ondataavailable!==null&&this.removeEventListener("dataavailable",this._ondataavailable[1]),typeof c=="function"){const l=c.bind(this);this.addEventListener("dataavailable",l),this._ondataavailable=[c,l]}else this._ondataavailable=null}get onerror(){return this._onerror===null?this._onerror:this._onerror[0]}set onerror(c){if(this._onerror!==null&&this.removeEventListener("error",this._onerror[1]),typeof c=="function"){const l=c.bind(this);this.addEventListener("error",l),this._onerror=[c,l]}else this._onerror=null}get onpause(){return this._onpause===null?this._onpause:this._onpause[0]}set onpause(c){if(this._onpause!==null&&this.removeEventListener("pause",this._onpause[1]),typeof c=="function"){const l=c.bind(this);this.addEventListener("pause",l),this._onpause=[c,l]}else this._onpause=null}get onresume(){return this._onresume===null?this._onresume:this._onresume[0]}set onresume(c){if(this._onresume!==null&&this.removeEventListener("resume",this._onresume[1]),typeof c=="function"){const l=c.bind(this);this.addEventListener("resume",l),this._onresume=[c,l]}else this._onresume=null}get onstart(){return this._onstart===null?this._onstart:this._onstart[0]}set onstart(c){if(this._onstart!==null&&this.removeEventListener("start",this._onstart[1]),typeof c=="function"){const l=c.bind(this);this.addEventListener("start",l),this._onstart=[c,l]}else this._onstart=null}get onstop(){return this._onstop===null?this._onstop:this._onstop[0]}set onstop(c){if(this._onstop!==null&&this.removeEventListener("stop",this._onstop[1]),typeof c=="function"){const l=c.bind(this);this.addEventListener("stop",l),this._onstop=[c,l]}else this._onstop=null}get state(){return this._internalMediaRecorder.state}pause(){return this._internalMediaRecorder.pause()}resume(){return this._internalMediaRecorder.resume()}start(c){return this._internalMediaRecorder.start(c)}stop(){return this._internalMediaRecorder.stop()}static isTypeSupported(c){return a!==null&&a.isTypeSupported!==void 0&&a.isTypeSupported(c)||i.some(l=>l.test(c))}},ts=e=>e!==null&&e.BlobEvent!==void 0?e.BlobEvent:null,ns=e=>e===null||e.MediaRecorder===void 0?null:e.MediaRecorder,rs=e=>(r,n,o)=>{const i=new Map,s=new WeakMap,a=new WeakMap,c=[],l=new r(n,o),u=new WeakMap;return l.addEventListener("stop",({isTrusted:h})=>{h&&setTimeout(()=>c.shift())}),l.addEventListener=(h=>(d,v,g)=>{let m=v;if(typeof v=="function")if(d==="dataavailable"){const p=[];m=f=>{const[[y,_]=[!1,!1]]=c;y&&!_?p.push(f):v.call(l,f)},i.set(v,p),s.set(v,m)}else d==="error"?(m=p=>{p instanceof ErrorEvent?v.call(l,p):v.call(l,new ErrorEvent("error",{error:p.error}))},a.set(v,m)):d==="stop"&&(m=p=>{for(const[f,y]of i.entries())if(y.length>0){const[_]=y;y.length>1&&Object.defineProperty(_,"data",{value:new Blob(y.map(({data:b})=>b),{type:_.data.type})}),y.length=0,f.call(l,_)}v.call(l,p)},u.set(v,m));return h.call(l,d,m,g)})(l.addEventListener),l.removeEventListener=(h=>(d,v,g)=>{let m=v;if(typeof v=="function"){if(d==="dataavailable"){i.delete(v);const p=s.get(v);p!==void 0&&(m=p)}else if(d==="error"){const p=a.get(v);p!==void 0&&(m=p)}else if(d==="stop"){const p=u.get(v);p!==void 0&&(m=p)}}return h.call(l,d,m,g)})(l.removeEventListener),l.start=(h=>d=>{if(o.mimeType!==void 0&&o.mimeType.startsWith("audio/")&&n.getVideoTracks().length>0)throw e();return l.state==="inactive"&&c.push([d!==void 0,!0]),d===void 0?h.call(l):h.call(l,d)})(l.start),l.stop=(h=>()=>{l.state!=="inactive"&&(c[0][1]=!1),h.call(l)})(l.stop),l},vt=()=>{try{return new DOMException("","NotSupportedError")}catch(e){return e.code=9,e.name="NotSupportedError",e}},os=e=>(r,n,o,i=2)=>{const s=e(r,n);if(s===null)return s;const{length:a,value:c}=s;if(o==="master")return{content:null,length:a};if(n+a+c>r.byteLength)return null;if(o==="binary"){const l=(c/Float32Array.BYTES_PER_ELEMENT-1)/i,u=Array.from({length:i},()=>new Float32Array(l));for(let h=0;h<l;h+=1){const d=h*i+1;for(let v=0;v<i;v+=1)u[v][h]=r.getFloat32(n+a+(d+v)*Float32Array.BYTES_PER_ELEMENT,!0)}return{content:u,length:a+c}}return{content:null,length:a+c}},ss=e=>(r,n)=>{const o=e(r,n);if(o===null)return o;const{length:i,value:s}=o;return s===35?{length:i,type:"binary"}:s===46||s===97||s===88713574||s===106212971||s===139690087||s===172351395||s===256095861?{length:i,type:"master"}:{length:i,type:"unknown"}},is=e=>(r,n)=>{const o=e(r,n);if(o===null)return o;const i=n+Math.floor((o-1)/8);if(i+o>r.byteLength)return null;let s=r.getUint8(i)&(1<<8-o%8)-1;for(let a=1;a<o;a+=1)s=(s<<8)+r.getUint8(i+a);return{length:o,value:s}},en=Symbol.observable||"@@observable";function as(e){return Symbol.observable||(typeof e=="function"&&e.prototype&&e.prototype[Symbol.observable]?(e.prototype[en]=e.prototype[Symbol.observable],delete e.prototype[Symbol.observable]):(e[en]=e[Symbol.observable],delete e[Symbol.observable])),e}const je=()=>{},tn=e=>{throw e};function ls(e){return e?e.next&&e.error&&e.complete?e:{complete:(e.complete??je).bind(e),error:(e.error??tn).bind(e),next:(e.next??je).bind(e)}:{complete:je,error:tn,next:je}}const cs=e=>(r,n,o)=>e(i=>{const s=a=>i.next(a);return r.addEventListener(n,s,o),()=>r.removeEventListener(n,s,o)}),us=(e,r)=>{const n=()=>{},o=i=>typeof i[0]=="function";return i=>{const s=((...a)=>{const c=i(o(a)?r({next:a[0]}):r(...a));return c!==void 0?c:n});return s[Symbol.observable]=()=>({subscribe:(...a)=>({unsubscribe:s(...a)})}),e(s)}},ds=us(as,ls),kn=cs(ds),hs=(e,r,n)=>async o=>{const i=new e([n],{type:"application/javascript; charset=utf-8"}),s=r.createObjectURL(i);try{await o(s)}finally{r.revokeObjectURL(s)}},ps=e=>({data:r})=>{const{id:n}=r;if(n!==null){const o=e.get(n);if(o!==void 0){const{reject:i,resolve:s}=o;e.delete(n),r.error===void 0?s(r.result):i(new Error(r.error.message))}}},fs=e=>(r,n)=>(o,i=[])=>new Promise((s,a)=>{const c=e(r);r.set(c,{reject:a,resolve:s}),n.postMessage({id:c,...o},i)}),ms=(e,r,n,o)=>(i,s,a={})=>{const c=new i(s,"recorder-audio-worklet-processor",{...a,channelCountMode:"explicit",numberOfInputs:1,numberOfOutputs:0}),l=new Map,u=r(l,c.port),h=n(c.port,"message")(e(l));c.port.start();let d="inactive";return Object.defineProperties(c,{pause:{get(){return async()=>(o(["recording"],d),d="paused",u({method:"pause"}))}},port:{get(){throw new Error("The port of a RecorderAudioWorkletNode can't be accessed.")}},record:{get(){return async v=>(o(["inactive"],d),d="recording",u({method:"record",params:{encoderPort:v}},[v]))}},resume:{get(){return async()=>(o(["paused"],d),d="recording",u({method:"resume"}))}},stop:{get(){return async()=>{o(["paused","recording"],d),d="stopped";try{await u({method:"stop"})}finally{h()}}}}}),c},vs=(e,r)=>{if(!e.includes(r))throw new Error(`Expected the state to be ${e.map(n=>`"${n}"`).join(" or ")} but it was "${r}".`)},gs='(()=>{"use strict";class e extends AudioWorkletProcessor{constructor(){super(),this._encoderPort=null,this._numberOfChannels=0,this._state="inactive",this.port.onmessage=({data:e})=>{"pause"===e.method?"active"===this._state||"recording"===this._state?(this._state="paused",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"record"===e.method?"inactive"===this._state?(this._encoderPort=e.params.encoderPort,this._state="active",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"resume"===e.method?"paused"===this._state?(this._state="active",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"stop"===e.method?"active"!==this._state&&"paused"!==this._state&&"recording"!==this._state||null===this._encoderPort?this._sendUnexpectedStateError(e.id):(this._stop(this._encoderPort),this._sendAcknowledgement(e.id)):"number"==typeof e.id&&this.port.postMessage({error:{code:-32601,message:"The requested method is not supported."},id:e.id})}}process([e]){if("inactive"===this._state||"paused"===this._state)return!0;if("active"===this._state){if(void 0===e)throw new Error("No channelData was received for the first input.");if(0===e.length)return!0;this._state="recording"}if("recording"===this._state&&null!==this._encoderPort){if(void 0===e)throw new Error("No channelData was received for the first input.");return 0===e.length?this._encoderPort.postMessage(Array.from({length:this._numberOfChannels},()=>128)):(this._encoderPort.postMessage(e,e.map(({buffer:e})=>e)),this._numberOfChannels=e.length),!0}return!1}_sendAcknowledgement(e){this.port.postMessage({id:e,result:null})}_sendUnexpectedStateError(e){this.port.postMessage({error:{code:-32603,message:"The internal state does not allow to process the given message."},id:e})}_stop(e){e.postMessage([]),e.close(),this._encoderPort=null,this._state="stopped"}}e.parameterDescriptors=[],registerProcessor("recorder-audio-worklet-processor",e)})();',ys=hs(Blob,URL,gs),ws=ms(ps,fs(At),kn,vs),nn=(e,r,n)=>({endTime:r,insertTime:n,type:"exponentialRampToValue",value:e}),rn=(e,r,n)=>({endTime:r,insertTime:n,type:"linearRampToValue",value:e}),gt=(e,r)=>({startTime:r,type:"setValue",value:e}),Mn=(e,r,n)=>({duration:n,startTime:r,type:"setValueCurve",values:e}),An=(e,r,{startTime:n,target:o,timeConstant:i})=>o+(r-o)*Math.exp((n-e)/i),xe=e=>e.type==="exponentialRampToValue",Ge=e=>e.type==="linearRampToValue",ve=e=>xe(e)||Ge(e),xt=e=>e.type==="setValue",de=e=>e.type==="setValueCurve",Ye=(e,r,n,o)=>{const i=e[r];return i===void 0?o:ve(i)||xt(i)?i.value:de(i)?i.values[i.values.length-1]:An(n,Ye(e,r-1,i.startTime,o),i)},on=(e,r,n,o,i)=>n===void 0?[o.insertTime,i]:ve(n)?[n.endTime,n.value]:xt(n)?[n.startTime,n.value]:de(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,Ye(e,r-1,n.startTime,i)],yt=e=>e.type==="cancelAndHold",wt=e=>e.type==="cancelScheduledValues",me=e=>yt(e)||wt(e)?e.cancelTime:xe(e)||Ge(e)?e.endTime:e.startTime,sn=(e,r,n,{endTime:o,value:i})=>n===i?i:0<n&&0<i||n<0&&i<0?n*(i/n)**((e-r)/(o-r)):0,an=(e,r,n,{endTime:o,value:i})=>n+(e-r)/(o-r)*(i-n),bs=(e,r)=>{const n=Math.floor(r),o=Math.ceil(r);return n===o?e[n]:(1-(r-n))*e[n]+(1-(o-r))*e[o]},Cs=(e,{duration:r,startTime:n,values:o})=>{const i=(e-n)/r*(o.length-1);return bs(o,i)},$e=e=>e.type==="setTarget";class _s{constructor(r){this._automationEvents=[],this._currenTime=0,this._defaultValue=r}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(r){const n=me(r);if(yt(r)||wt(r)){const o=this._automationEvents.findIndex(s=>wt(r)&&de(s)?s.startTime+s.duration>=n:me(s)>=n),i=this._automationEvents[o];if(o!==-1&&(this._automationEvents=this._automationEvents.slice(0,o)),yt(r)){const s=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&ve(i)){if(s!==void 0&&$e(s))throw new Error("The internal list is malformed.");const a=s===void 0?i.insertTime:de(s)?s.startTime+s.duration:me(s),c=s===void 0?this._defaultValue:de(s)?s.values[s.values.length-1]:s.value,l=xe(i)?sn(n,a,c,i):an(n,a,c,i),u=xe(i)?nn(l,n,this._currenTime):rn(l,n,this._currenTime);this._automationEvents.push(u)}if(s!==void 0&&$e(s)&&this._automationEvents.push(gt(this.getValue(n),n)),s!==void 0&&de(s)&&s.startTime+s.duration>n){const a=n-s.startTime,c=(s.values.length-1)/s.duration,l=Math.max(2,1+Math.ceil(a*c)),u=a/(l-1)*c,h=s.values.slice(0,l);if(u<1)for(let d=1;d<l;d+=1){const v=u*d%1;h[d]=s.values[d-1]*(1-v)+s.values[d]*v}this._automationEvents[this._automationEvents.length-1]=Mn(h,s.startTime,a)}}}else{const o=this._automationEvents.findIndex(a=>me(a)>n),i=o===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[o-1];if(i!==void 0&&de(i)&&me(i)+i.duration>n)return!1;const s=xe(r)?nn(r.value,r.endTime,this._currenTime):Ge(r)?rn(r.value,n,this._currenTime):r;if(o===-1)this._automationEvents.push(s);else{if(de(r)&&n+r.duration>me(this._automationEvents[o]))return!1;this._automationEvents.splice(o,0,s)}}return!0}flush(r){const n=this._automationEvents.findIndex(o=>me(o)>r);if(n>1){const o=this._automationEvents.slice(n-1),i=o[0];$e(i)&&o.unshift(gt(Ye(this._automationEvents,n-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=o}}getValue(r){if(this._automationEvents.length===0)return this._defaultValue;const n=this._automationEvents.findIndex(a=>me(a)>r),o=this._automationEvents[n],i=(n===-1?this._automationEvents.length:n)-1,s=this._automationEvents[i];if(s!==void 0&&$e(s)&&(o===void 0||!ve(o)||o.insertTime>r))return An(r,Ye(this._automationEvents,i-1,s.startTime,this._defaultValue),s);if(s!==void 0&&xt(s)&&(o===void 0||!ve(o)))return s.value;if(s!==void 0&&de(s)&&(o===void 0||!ve(o)||s.startTime+s.duration>r))return r<s.startTime+s.duration?Cs(r,s):s.values[s.values.length-1];if(s!==void 0&&ve(s)&&(o===void 0||!ve(o)))return s.value;if(o!==void 0&&xe(o)){const[a,c]=on(this._automationEvents,i,s,o,this._defaultValue);return sn(r,a,c,o)}if(o!==void 0&&Ge(o)){const[a,c]=on(this._automationEvents,i,s,o,this._defaultValue);return an(r,a,c,o)}return this._defaultValue}}const Is=e=>({cancelTime:e,type:"cancelAndHold"}),Es=e=>({cancelTime:e,type:"cancelScheduledValues"}),Ts=(e,r)=>({endTime:r,type:"exponentialRampToValue",value:e}),ks=(e,r)=>({endTime:r,type:"linearRampToValue",value:e}),Ms=(e,r,n)=>({startTime:r,target:e,timeConstant:n,type:"setTarget"}),As=()=>new DOMException("","AbortError"),Os=e=>(r,n,[o,i,s],a)=>{e(r[i],[n,o,s],c=>c[0]===n&&c[1]===o,a)},xs=e=>(r,n,o)=>{const i=[];for(let s=0;s<o.numberOfInputs;s+=1)i.push(new Set);e.set(r,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:n})},Ss=e=>(r,n)=>{e.set(r,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:n})},Se=new WeakSet,On=new WeakMap,xn=new WeakMap,Sn=new WeakMap,Un=new WeakMap,Rn=new WeakMap,Bn=new WeakMap,bt=new WeakMap,Ct=new WeakMap,_t=new WeakMap,Ln={construct(){return Ln}},Us=e=>{try{const r=new Proxy(e,Ln);new r}catch{return!1}return!0},ln=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,cn=(e,r)=>{const n=[];let o=e.replace(/^[\s]+/,""),i=o.match(ln);for(;i!==null;){const s=i[1].slice(1,-1),a=i[0].replace(/([\s]+)?;?$/,"").replace(s,new URL(s,r).toString());n.push(a),o=o.slice(i[0].length).replace(/^[\s]+/,""),i=o.match(ln)}return[n.join(";"),o]},un=e=>{if(e!==void 0&&!Array.isArray(e))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},dn=e=>{if(!Us(e))throw new TypeError("The given value for processorCtor should be a constructor.");if(e.prototype===null||typeof e.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},Rs=(e,r,n,o,i,s,a,c,l,u,h,d,v)=>{let g=0;return(m,p,f={credentials:"omit"})=>{const y=h.get(m);if(y!==void 0&&y.has(p))return Promise.resolve();const _=u.get(m);if(_!==void 0){const E=_.get(p);if(E!==void 0)return E}const b=s(m),k=b.audioWorklet===void 0?i(p).then(([E,I])=>{const[w,C]=cn(E,I),A=`${w};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${C}
|
|
})})(window,'_AWGS')`;return n(A)}).then(()=>{const E=v._AWGS.pop();if(E===void 0)throw new SyntaxError;o(b.currentTime,b.sampleRate,()=>E(class{},void 0,(I,w)=>{if(I.trim()==="")throw r();const C=Ct.get(b);if(C!==void 0){if(C.has(I))throw r();dn(w),un(w.parameterDescriptors),C.set(I,w)}else dn(w),un(w.parameterDescriptors),Ct.set(b,new Map([[I,w]]))},b.sampleRate,void 0,void 0))}):Promise.all([i(p),Promise.resolve(e(d,d))]).then(([[E,I],w])=>{const C=g+1;g=C;const[A,P]=cn(E,I),x=`${A};((AudioWorkletProcessor,registerProcessor)=>{${P}
|
|
})(${w?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${w?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${w?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${C}',class extends AudioWorkletProcessor{process(){return !1}})`,S=new Blob([x],{type:"application/javascript; charset=utf-8"}),N=URL.createObjectURL(S);return b.audioWorklet.addModule(N,f).then(()=>{if(c(b))return b;const L=a(b);return L.audioWorklet.addModule(N,f).then(()=>L)}).then(L=>{if(l===null)throw new SyntaxError;try{new l(L,`__sac${C}`)}catch{throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(N))});return _===void 0?u.set(m,new Map([[p,k]])):_.set(p,k),k.then(()=>{const E=h.get(m);E===void 0?h.set(m,new Set([p])):E.add(p)}).finally(()=>{const E=u.get(m);E!==void 0&&E.delete(p)}),k}},le=(e,r)=>{const n=e.get(r);if(n===void 0)throw new Error("A value with the given key could not be found.");return n},nt=(e,r)=>{const n=Array.from(e).filter(r);if(n.length>1)throw Error("More than one element was found.");if(n.length===0)throw Error("No element was found.");const[o]=n;return e.delete(o),o},Nn=(e,r,n,o)=>{const i=le(e,r),s=nt(i,a=>a[0]===n&&a[1]===o);return i.size===0&&e.delete(r),s},Ve=e=>le(Bn,e),Ze=e=>{if(Se.has(e))throw new Error("The AudioNode is already stored.");Se.add(e),Ve(e).forEach(r=>r(!0))},Vn=e=>"port"in e,St=e=>{if(!Se.has(e))throw new Error("The AudioNode is not stored.");Se.delete(e),Ve(e).forEach(r=>r(!1))},It=(e,r)=>{!Vn(e)&&r.every(n=>n.size===0)&&St(e)},Bs=(e,r,n,o,i,s,a,c,l,u,h,d,v)=>{const g=new WeakMap;return(m,p,f,y,_)=>{const{activeInputs:b,passiveInputs:k}=s(p),{outputs:E}=s(m),I=c(m),w=C=>{const A=l(p),P=l(m);if(C){const x=Nn(k,m,f,y);e(b,m,x,!1),!_&&!d(m)&&n(P,A,f,y),v(p)&&Ze(p)}else{const x=o(b,m,f,y);r(k,y,x,!1),!_&&!d(m)&&i(P,A,f,y);const S=a(p);if(S===0)h(p)&&It(p,b);else{const N=g.get(p);N!==void 0&&clearTimeout(N),g.set(p,setTimeout(()=>{h(p)&&It(p,b)},S*1e3))}}};return u(E,[p,f,y],C=>C[0]===p&&C[1]===f&&C[2]===y,!0)?(I.add(w),h(m)?e(b,m,[f,y,w],!0):r(k,y,[m,f,w],!0),!0):!1}},Ls=e=>(r,n,[o,i,s],a)=>{const c=r.get(o);c===void 0?r.set(o,new Set([[i,n,s]])):e(c,[i,n,s],l=>l[0]===i&&l[1]===n,a)},Ns=e=>(r,n)=>{const o=e(r,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.connect(o).connect(r.destination);const i=()=>{n.removeEventListener("ended",i),n.disconnect(o),o.disconnect()};n.addEventListener("ended",i)},Vs=e=>(r,n)=>{e(r).add(n)},Pn=(e,r)=>e.context===r,hn=e=>{try{e.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},Ee=()=>new DOMException("","IndexSizeError"),Ps=e=>{e.getChannelData=(r=>n=>{try{return r.call(e,n)}catch(o){throw o.code===12?Ee():o}})(e.getChannelData)},Ds={numberOfChannels:1},Fs=(e,r,n,o,i,s,a,c)=>{let l=null;return class Dn{constructor(h){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:d,numberOfChannels:v,sampleRate:g}={...Ds,...h};l===null&&(l=new i(1,1,44100));const m=o!==null&&r(s,s)?new o({length:d,numberOfChannels:v,sampleRate:g}):l.createBuffer(v,d,g);if(m.numberOfChannels===0)throw n();return typeof m.copyFromChannel!="function"?(a(m),Ps(m)):r(hn,()=>hn(m))||c(m),e.add(m),m}static[Symbol.hasInstance](h){return h!==null&&typeof h=="object"&&Object.getPrototypeOf(h)===Dn.prototype||e.has(h)}}},rt=-34028234663852886e22,Ut=-rt,Ce=e=>Se.has(e),Ws={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},js=(e,r,n,o,i,s,a,c)=>class extends e{constructor(l,u){const h=s(l),d={...Ws,...u},v=i(h,d),g=a(h),m=g?r():null;super(l,!1,v,m),this._audioBufferSourceNodeRenderer=m,this._isBufferNullified=!1,this._isBufferSet=d.buffer!==null,this._nativeAudioBufferSourceNode=v,this._onended=null,this._playbackRate=n(this,g,v.playbackRate,Ut,rt)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(l){if(this._nativeAudioBufferSourceNode.buffer=l,l!==null){if(this._isBufferSet)throw o();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(l){this._nativeAudioBufferSourceNode.loop=l}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(l){this._nativeAudioBufferSourceNode.loopEnd=l}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(l){this._nativeAudioBufferSourceNode.loopStart=l}get onended(){return this._onended}set onended(l){const u=typeof l=="function"?c(this,l):null;this._nativeAudioBufferSourceNode.onended=u;const h=this._nativeAudioBufferSourceNode.onended;this._onended=h!==null&&h===u?l:h}get playbackRate(){return this._playbackRate}start(l=0,u=0,h){if(this._nativeAudioBufferSourceNode.start(l,u,h),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=h===void 0?[l,u]:[l,u,h]),this.context.state!=="closed"){Ze(this);const d=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",d),Ce(this)&&St(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",d)}}stop(l=0){this._nativeAudioBufferSourceNode.stop(l),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=l)}},$s=(e,r,n,o,i)=>()=>{const s=new WeakMap;let a=null,c=null;const l=async(u,h)=>{let d=n(u);const v=Pn(d,h);if(!v){const g={buffer:d.buffer,channelCount:d.channelCount,channelCountMode:d.channelCountMode,channelInterpretation:d.channelInterpretation,loop:d.loop,loopEnd:d.loopEnd,loopStart:d.loopStart,playbackRate:d.playbackRate.value};d=r(h,g),a!==null&&d.start(...a),c!==null&&d.stop(c)}return s.set(h,d),v?await e(h,u.playbackRate,d.playbackRate):await o(h,u.playbackRate,d.playbackRate),await i(u,h,d),d};return{set start(u){a=u},set stop(u){c=u},render(u,h){const d=s.get(h);return d!==void 0?Promise.resolve(d):l(u,h)}}},zs=e=>"playbackRate"in e,Hs=e=>"frequency"in e&&"gain"in e,qs=e=>"offset"in e,Gs=e=>!("frequency"in e)&&"gain"in e,Ys=e=>"detune"in e&&"frequency"in e&&!("gain"in e),Zs=e=>"pan"in e,J=e=>le(On,e),Pe=e=>le(Sn,e),Et=(e,r)=>{const{activeInputs:n}=J(e);n.forEach(i=>i.forEach(([s])=>{r.includes(e)||Et(s,[...r,e])}));const o=zs(e)?[e.playbackRate]:Vn(e)?Array.from(e.parameters.values()):Hs(e)?[e.Q,e.detune,e.frequency,e.gain]:qs(e)?[e.offset]:Gs(e)?[e.gain]:Ys(e)?[e.detune,e.frequency]:Zs(e)?[e.pan]:[];for(const i of o){const s=Pe(i);s!==void 0&&s.activeInputs.forEach(([a])=>Et(a,r))}Ce(e)&&St(e)},Xs=e=>{Et(e.destination,[])},Ks=e=>e===void 0||typeof e=="number"||typeof e=="string"&&(e==="balanced"||e==="interactive"||e==="playback"),Qs=(e,r,n,o,i,s,a,c)=>class extends e{constructor(l,u){const h=s(l),d=a(h),v=i(h,u,d),g=d?r(c):null;super(l,!1,v,g),this._isNodeOfNativeOfflineAudioContext=d,this._nativeAudioDestinationNode=v}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(l){if(this._isNodeOfNativeOfflineAudioContext)throw o();if(l>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=l}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(l){if(this._isNodeOfNativeOfflineAudioContext)throw o();this._nativeAudioDestinationNode.channelCountMode=l}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}},Js=e=>{const r=new WeakMap,n=async(o,i)=>{const s=i.destination;return r.set(i,s),await e(o,i,s),s};return{render(o,i){const s=r.get(i);return s!==void 0?Promise.resolve(s):n(o,i)}}},ei=(e,r,n,o,i,s,a,c)=>(l,u)=>{const h=u.listener,d=()=>{const E=new Float32Array(1),I=r(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),w=a(u);let C=!1,A=[0,0,-1,0,1,0],P=[0,0,0];const x=()=>{if(C)return;C=!0;const W=o(u,256,9,0);W.onaudioprocess=({inputBuffer:R})=>{const j=[s(R,E,0),s(R,E,1),s(R,E,2),s(R,E,3),s(R,E,4),s(R,E,5)];j.some((M,O)=>M!==A[O])&&(h.setOrientation(...j),A=j);const $=[s(R,E,6),s(R,E,7),s(R,E,8)];$.some((M,O)=>M!==P[O])&&(h.setPosition(...$),P=$)},I.connect(W)},S=W=>R=>{R!==A[W]&&(A[W]=R,h.setOrientation(...A))},N=W=>R=>{R!==P[W]&&(P[W]=R,h.setPosition(...P))},L=(W,R,j)=>{const $=n(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:R});$.connect(I,0,W),$.start(),Object.defineProperty($.offset,"defaultValue",{get(){return R}});const M=e({context:l},w,$.offset,Ut,rt);return c(M,"value",O=>()=>O.call(M),O=>z=>{try{O.call(M,z)}catch(H){if(H.code!==9)throw H}x(),w&&j(z)}),M.cancelAndHoldAtTime=(O=>w?()=>{throw i()}:(...z)=>{const H=O.apply(M,z);return x(),H})(M.cancelAndHoldAtTime),M.cancelScheduledValues=(O=>w?()=>{throw i()}:(...z)=>{const H=O.apply(M,z);return x(),H})(M.cancelScheduledValues),M.exponentialRampToValueAtTime=(O=>w?()=>{throw i()}:(...z)=>{const H=O.apply(M,z);return x(),H})(M.exponentialRampToValueAtTime),M.linearRampToValueAtTime=(O=>w?()=>{throw i()}:(...z)=>{const H=O.apply(M,z);return x(),H})(M.linearRampToValueAtTime),M.setTargetAtTime=(O=>w?()=>{throw i()}:(...z)=>{const H=O.apply(M,z);return x(),H})(M.setTargetAtTime),M.setValueAtTime=(O=>w?()=>{throw i()}:(...z)=>{const H=O.apply(M,z);return x(),H})(M.setValueAtTime),M.setValueCurveAtTime=(O=>w?()=>{throw i()}:(...z)=>{const H=O.apply(M,z);return x(),H})(M.setValueCurveAtTime),M};return{forwardX:L(0,0,S(0)),forwardY:L(1,0,S(1)),forwardZ:L(2,-1,S(2)),positionX:L(6,0,N(0)),positionY:L(7,0,N(1)),positionZ:L(8,0,N(2)),upX:L(3,0,S(3)),upY:L(4,1,S(4)),upZ:L(5,0,S(5))}},{forwardX:v,forwardY:g,forwardZ:m,positionX:p,positionY:f,positionZ:y,upX:_,upY:b,upZ:k}=h.forwardX===void 0?d():h;return{get forwardX(){return v},get forwardY(){return g},get forwardZ(){return m},get positionX(){return p},get positionY(){return f},get positionZ(){return y},get upX(){return _},get upY(){return b},get upZ(){return k}}},Xe=e=>"context"in e,De=e=>Xe(e[0]),Te=(e,r,n,o)=>{for(const i of e)if(n(i)){if(o)return!1;throw Error("The set contains at least one similar element.")}return e.add(r),!0},pn=(e,r,[n,o],i)=>{Te(e,[r,n,o],s=>s[0]===r&&s[1]===n,i)},fn=(e,[r,n,o],i)=>{const s=e.get(r);s===void 0?e.set(r,new Set([[n,o]])):Te(s,[n,o],a=>a[0]===n,i)},Fn=e=>"inputs"in e,Tt=(e,r,n,o)=>{if(Fn(r)){const i=r.inputs[o];return e.connect(i,n,0),[i,n,0]}return e.connect(r,n,o),[r,n,o]},Wn=(e,r,n)=>{for(const o of e)if(o[0]===r&&o[1]===n)return e.delete(o),o;return null},ti=(e,r,n)=>nt(e,o=>o[0]===r&&o[1]===n),jn=(e,r)=>{if(!Ve(e).delete(r))throw new Error("Missing the expected event listener.")},$n=(e,r,n)=>{const o=le(e,r),i=nt(o,s=>s[0]===n);return o.size===0&&e.delete(r),i},kt=(e,r,n,o)=>{Fn(r)?e.disconnect(r.inputs[o],n,0):e.disconnect(r,n,o)},ie=e=>le(xn,e),Le=e=>le(Un,e),_e=e=>bt.has(e),He=e=>!Se.has(e),mn=(e,r)=>new Promise(n=>{if(r!==null)n(!0);else{const o=e.createScriptProcessor(256,1,1),i=e.createGain(),s=e.createBuffer(1,2,44100),a=s.getChannelData(0);a[0]=1,a[1]=1;const c=e.createBufferSource();c.buffer=s,c.loop=!0,c.connect(o).connect(e.destination),c.connect(i),c.disconnect(i),o.onaudioprocess=l=>{const u=l.inputBuffer.getChannelData(0);Array.prototype.some.call(u,h=>h===1)?n(!0):n(!1),c.stop(),o.onaudioprocess=null,c.disconnect(o),o.disconnect(e.destination)},c.start()}}),pt=(e,r)=>{const n=new Map;for(const o of e)for(const i of o){const s=n.get(i);n.set(i,s===void 0?1:s+1)}n.forEach((o,i)=>r(i,o))},Ke=e=>"context"in e,ni=e=>{const r=new Map;e.connect=(n=>(o,i=0,s=0)=>{const a=Ke(o)?n(o,i,s):n(o,i),c=r.get(o);return c===void 0?r.set(o,[{input:s,output:i}]):c.every(l=>l.input!==s||l.output!==i)&&c.push({input:s,output:i}),a})(e.connect.bind(e)),e.disconnect=(n=>(o,i,s)=>{if(n.apply(e),o===void 0)r.clear();else if(typeof o=="number")for(const[a,c]of r){const l=c.filter(u=>u.output!==o);l.length===0?r.delete(a):r.set(a,l)}else if(r.has(o))if(i===void 0)r.delete(o);else{const a=r.get(o);if(a!==void 0){const c=a.filter(l=>l.output!==i&&(l.input!==s||s===void 0));c.length===0?r.delete(o):r.set(o,c)}}for(const[a,c]of r)c.forEach(l=>{Ke(a)?e.connect(a,l.output,l.input):e.connect(a,l.output)})})(e.disconnect)},ri=(e,r,n,o)=>{const{activeInputs:i,passiveInputs:s}=Pe(r),{outputs:a}=J(e),c=Ve(e),l=u=>{const h=ie(e),d=Le(r);if(u){const v=$n(s,e,n);pn(i,e,v,!1),!o&&!_e(e)&&h.connect(d,n)}else{const v=ti(i,e,n);fn(s,v,!1),!o&&!_e(e)&&h.disconnect(d,n)}};return Te(a,[r,n],u=>u[0]===r&&u[1]===n,!0)?(c.add(l),Ce(e)?pn(i,e,[n,l],!0):fn(s,[e,n,l],!0),!0):!1},oi=(e,r,n,o)=>{const{activeInputs:i,passiveInputs:s}=J(r),a=Wn(i[o],e,n);return a===null?[Nn(s,e,n,o)[2],!1]:[a[2],!0]},si=(e,r,n)=>{const{activeInputs:o,passiveInputs:i}=Pe(r),s=Wn(o,e,n);return s===null?[$n(i,e,n)[1],!1]:[s[2],!0]},Rt=(e,r,n,o,i)=>{const[s,a]=oi(e,n,o,i);if(s!==null&&(jn(e,s),a&&!r&&!_e(e)&&kt(ie(e),ie(n),o,i)),Ce(n)){const{activeInputs:c}=J(n);It(n,c)}},Bt=(e,r,n,o)=>{const[i,s]=si(e,n,o);i!==null&&(jn(e,i),s&&!r&&!_e(e)&&ie(e).disconnect(Le(n),o))},ii=(e,r)=>{const n=J(e),o=[];for(const i of n.outputs)De(i)?Rt(e,r,...i):Bt(e,r,...i),o.push(i[0]);return n.outputs.clear(),o},ai=(e,r,n)=>{const o=J(e),i=[];for(const s of o.outputs)s[1]===n&&(De(s)?Rt(e,r,...s):Bt(e,r,...s),i.push(s[0]),o.outputs.delete(s));return i},li=(e,r,n,o,i)=>{const s=J(e);return Array.from(s.outputs).filter(a=>a[0]===n&&(o===void 0||a[1]===o)&&(i===void 0||a[2]===i)).map(a=>(De(a)?Rt(e,r,...a):Bt(e,r,...a),s.outputs.delete(a),a[0]))},ci=(e,r,n,o,i,s,a,c,l,u,h,d,v,g,m,p)=>class extends u{constructor(f,y,_,b){super(_),this._context=f,this._nativeAudioNode=_;const k=h(f);d(k)&&n(mn,()=>mn(k,p))!==!0&&ni(_),xn.set(this,_),Bn.set(this,new Set),f.state!=="closed"&&y&&Ze(this),e(this,b,_)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(f){this._nativeAudioNode.channelCount=f}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(f){this._nativeAudioNode.channelCountMode=f}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(f){this._nativeAudioNode.channelInterpretation=f}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(f,y=0,_=0){if(y<0||y>=this._nativeAudioNode.numberOfOutputs)throw i();const b=h(this._context),k=m(b);if(v(f)||g(f))throw s();if(Xe(f)){const I=ie(f);try{const w=Tt(this._nativeAudioNode,I,y,_),C=He(this);(k||C)&&this._nativeAudioNode.disconnect(...w),this.context.state!=="closed"&&!C&&He(f)&&Ze(f)}catch(w){throw w.code===12?s():w}if(r(this,f,y,_,k)){const w=l([this],f);pt(w,o(k))}return f}const E=Le(f);if(E.name==="playbackRate"&&E.maxValue===1024)throw a();try{this._nativeAudioNode.connect(E,y),(k||He(this))&&this._nativeAudioNode.disconnect(E,y)}catch(I){throw I.code===12?s():I}if(ri(this,f,y,k)){const I=l([this],f);pt(I,o(k))}}disconnect(f,y,_){let b;const k=h(this._context),E=m(k);if(f===void 0)b=ii(this,E);else if(typeof f=="number"){if(f<0||f>=this.numberOfOutputs)throw i();b=ai(this,E,f)}else{if(y!==void 0&&(y<0||y>=this.numberOfOutputs)||Xe(f)&&_!==void 0&&(_<0||_>=f.numberOfInputs))throw i();if(b=li(this,E,f,y,_),b.length===0)throw s()}for(const I of b){const w=l([this],I);pt(w,c)}}},ui=(e,r,n,o,i,s,a,c,l,u,h,d,v)=>(g,m,p,f=null,y=null)=>{const _=p.value,b=new _s(_),k=m?o(b):null,E={get defaultValue(){return _},get maxValue(){return f===null?p.maxValue:f},get minValue(){return y===null?p.minValue:y},get value(){return p.value},set value(I){p.value=I,E.setValueAtTime(I,g.context.currentTime)},cancelAndHoldAtTime(I){if(typeof p.cancelAndHoldAtTime=="function")k===null&&b.flush(g.context.currentTime),b.add(i(I)),p.cancelAndHoldAtTime(I);else{const w=Array.from(b).pop();k===null&&b.flush(g.context.currentTime),b.add(i(I));const C=Array.from(b).pop();p.cancelScheduledValues(I),w!==C&&C!==void 0&&(C.type==="exponentialRampToValue"?p.exponentialRampToValueAtTime(C.value,C.endTime):C.type==="linearRampToValue"?p.linearRampToValueAtTime(C.value,C.endTime):C.type==="setValue"?p.setValueAtTime(C.value,C.startTime):C.type==="setValueCurve"&&p.setValueCurveAtTime(C.values,C.startTime,C.duration))}return E},cancelScheduledValues(I){return k===null&&b.flush(g.context.currentTime),b.add(s(I)),p.cancelScheduledValues(I),E},exponentialRampToValueAtTime(I,w){if(I===0)throw new RangeError;if(!Number.isFinite(w)||w<0)throw new RangeError;const C=g.context.currentTime;return k===null&&b.flush(C),Array.from(b).length===0&&(b.add(u(_,C)),p.setValueAtTime(_,C)),b.add(a(I,w)),p.exponentialRampToValueAtTime(I,w),E},linearRampToValueAtTime(I,w){const C=g.context.currentTime;return k===null&&b.flush(C),Array.from(b).length===0&&(b.add(u(_,C)),p.setValueAtTime(_,C)),b.add(c(I,w)),p.linearRampToValueAtTime(I,w),E},setTargetAtTime(I,w,C){return k===null&&b.flush(g.context.currentTime),b.add(l(I,w,C)),p.setTargetAtTime(I,w,C),E},setValueAtTime(I,w){return k===null&&b.flush(g.context.currentTime),b.add(u(I,w)),p.setValueAtTime(I,w),E},setValueCurveAtTime(I,w,C){const A=I instanceof Float32Array?I:new Float32Array(I);if(d!==null&&d.name==="webkitAudioContext"){const P=w+C,x=g.context.sampleRate,S=Math.ceil(w*x),N=Math.floor(P*x),L=N-S,W=new Float32Array(L);for(let j=0;j<L;j+=1){const $=(A.length-1)/C*((S+j)/x-w),M=Math.floor($),O=Math.ceil($);W[j]=M===O?A[M]:(1-($-M))*A[M]+(1-(O-$))*A[O]}k===null&&b.flush(g.context.currentTime),b.add(h(W,w,C)),p.setValueCurveAtTime(W,w,C);const R=N/x;R<P&&v(E,W[W.length-1],R),v(E,A[A.length-1],P)}else k===null&&b.flush(g.context.currentTime),b.add(h(A,w,C)),p.setValueCurveAtTime(A,w,C);return E}};return n.set(E,p),r.set(E,g),e(E,k),E},di=e=>({replay(r){for(const n of e)if(n.type==="exponentialRampToValue"){const{endTime:o,value:i}=n;r.exponentialRampToValueAtTime(i,o)}else if(n.type==="linearRampToValue"){const{endTime:o,value:i}=n;r.linearRampToValueAtTime(i,o)}else if(n.type==="setTarget"){const{startTime:o,target:i,timeConstant:s}=n;r.setTargetAtTime(i,o,s)}else if(n.type==="setValue"){const{startTime:o,value:i}=n;r.setValueAtTime(i,o)}else if(n.type==="setValueCurve"){const{duration:o,startTime:i,values:s}=n;r.setValueCurveAtTime(s,i,o)}else throw new Error("Can't apply an unknown automation.")}});class zn{constructor(r){this._map=new Map(r)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(r,n=null){return this._map.forEach((o,i)=>r.call(n,o,i,this))}get(r){return this._map.get(r)}has(r){return this._map.has(r)}keys(){return this._map.keys()}values(){return this._map.values()}}const hi={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},pi=(e,r,n,o,i,s,a,c,l,u,h,d,v,g)=>class extends r{constructor(m,p,f){var y;const _=c(m),b=l(_),k=h({...hi,...f});v(k);const E=Ct.get(_),I=E?.get(p),w=b||_.state!=="closed"?_:(y=a(_))!==null&&y!==void 0?y:_,C=i(w,b?null:m.baseLatency,u,p,I,k),A=b?o(p,k,I):null;super(m,!0,C,A);const P=[];C.parameters.forEach((S,N)=>{const L=n(this,b,S);P.push([N,L])}),this._nativeAudioWorkletNode=C,this._onprocessorerror=null,this._parameters=new zn(P),b&&e(_,this);const{activeInputs:x}=s(this);d(C,x)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(m){const p=typeof m=="function"?g(this,m):null;this._nativeAudioWorkletNode.onprocessorerror=p;const f=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=f!==null&&f===p?m:f}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Qe(e,r,n,o,i){if(typeof e.copyFromChannel=="function")r[n].byteLength===0&&(r[n]=new Float32Array(128)),e.copyFromChannel(r[n],o,i);else{const s=e.getChannelData(o);if(r[n].byteLength===0)r[n]=s.slice(i,i+128);else{const a=new Float32Array(s.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);r[n].set(a)}}}const Hn=(e,r,n,o,i)=>{typeof e.copyToChannel=="function"?r[n].byteLength!==0&&e.copyToChannel(r[n],o,i):r[n].byteLength!==0&&e.getChannelData(o).set(r[n],i)},Je=(e,r)=>{const n=[];for(let o=0;o<e;o+=1){const i=[],s=typeof r=="number"?r:r[o];for(let a=0;a<s;a+=1)i.push(new Float32Array(128));n.push(i)}return n},fi=(e,r)=>{const n=le(_t,e),o=ie(r);return le(n,o)},mi=async(e,r,n,o,i,s,a)=>{const c=r===null?Math.ceil(e.context.length/128)*128:r.length,l=o.channelCount*o.numberOfInputs,u=i.reduce((f,y)=>f+y,0),h=u===0?null:n.createBuffer(u,c,n.sampleRate);if(s===void 0)throw new Error("Missing the processor constructor.");const d=J(e),v=await fi(n,e),g=Je(o.numberOfInputs,o.channelCount),m=Je(o.numberOfOutputs,i),p=Array.from(e.parameters.keys()).reduce((f,y)=>({...f,[y]:new Float32Array(128)}),{});for(let f=0;f<c;f+=128){if(o.numberOfInputs>0&&r!==null)for(let y=0;y<o.numberOfInputs;y+=1)for(let _=0;_<o.channelCount;_+=1)Qe(r,g[y],_,_,f);s.parameterDescriptors!==void 0&&r!==null&&s.parameterDescriptors.forEach(({name:y},_)=>{Qe(r,p,y,l+_,f)});for(let y=0;y<o.numberOfInputs;y+=1)for(let _=0;_<i[y];_+=1)m[y][_].byteLength===0&&(m[y][_]=new Float32Array(128));try{const y=g.map((b,k)=>d.activeInputs[k].size===0?[]:b),_=a(f/n.sampleRate,n.sampleRate,()=>v.process(y,m,p));if(h!==null)for(let b=0,k=0;b<o.numberOfOutputs;b+=1){for(let E=0;E<i[b];E+=1)Hn(h,m[b],E,k+E,f);k+=i[b]}if(!_)break}catch(y){e.dispatchEvent(new ErrorEvent("processorerror",{colno:y.colno,filename:y.filename,lineno:y.lineno,message:y.message}));break}}return h},vi=(e,r,n,o,i,s,a,c,l,u,h,d,v,g,m,p)=>(f,y,_)=>{const b=new WeakMap;let k=null;const E=async(I,w)=>{let C=h(I),A=null;const P=Pn(C,w),x=Array.isArray(y.outputChannelCount)?y.outputChannelCount:Array.from(y.outputChannelCount);if(d===null){const S=x.reduce((R,j)=>R+j,0),N=i(w,{channelCount:Math.max(1,S),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,S)}),L=[];for(let R=0;R<I.numberOfOutputs;R+=1)L.push(o(w,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:x[R]}));const W=a(w,{channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation,gain:1});W.connect=r.bind(null,L),W.disconnect=l.bind(null,L),A=[N,L,W]}else P||(C=new d(w,f));if(b.set(w,A===null?C:A[2]),A!==null){if(k===null){if(_===void 0)throw new Error("Missing the processor constructor.");if(v===null)throw new Error("Missing the native OfflineAudioContext constructor.");const j=I.channelCount*I.numberOfInputs,$=_.parameterDescriptors===void 0?0:_.parameterDescriptors.length,M=j+$;k=mi(I,M===0?null:await(async()=>{const O=new v(M,Math.ceil(I.context.length/128)*128,w.sampleRate),z=[],H=[];for(let G=0;G<y.numberOfInputs;G+=1)z.push(a(O,{channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation,gain:1})),H.push(i(O,{channelCount:y.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:y.channelCount}));const Me=await Promise.all(Array.from(I.parameters.values()).map(async G=>{const ne=s(O,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:G.value});return await g(O,G,ne.offset),ne})),Ae=o(O,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,j+$)});for(let G=0;G<y.numberOfInputs;G+=1){z[G].connect(H[G]);for(let ne=0;ne<y.channelCount;ne+=1)H[G].connect(Ae,ne,G*y.channelCount+ne)}for(const[G,ne]of Me.entries())ne.connect(Ae,0,j+G),ne.start(0);return Ae.connect(O.destination),await Promise.all(z.map(G=>m(I,O,G))),p(O)})(),w,y,x,_,u)}const S=await k,N=n(w,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[L,W,R]=A;S!==null&&(N.buffer=S,N.start(0)),N.connect(L);for(let j=0,$=0;j<I.numberOfOutputs;j+=1){const M=W[j];for(let O=0;O<x[j];O+=1)L.connect(M,$+O,O);$+=x[j]}return R}if(P)for(const[S,N]of I.parameters.entries())await e(w,N,C.parameters.get(S));else for(const[S,N]of I.parameters.entries())await g(w,N,C.parameters.get(S));return await m(I,w,C),C};return{render(I,w){c(w,I);const C=b.get(w);return C!==void 0?Promise.resolve(C):E(I,w)}}},gi=(e,r)=>(n,o)=>{const i=r.get(n);if(i!==void 0)return i;const s=e.get(n);if(s!==void 0)return s;try{const a=o();return a instanceof Promise?(e.set(n,a),a.catch(()=>!1).then(c=>(e.delete(n),r.set(n,c),c))):(r.set(n,a),a)}catch{return r.set(n,!1),!1}},yi=e=>(r,n,o)=>e(n,r,o),wi=e=>(r,n,o=0,i=0)=>{const s=r[o];if(s===void 0)throw e();return Ke(n)?s.connect(n,0,i):s.connect(n,0)},bi=e=>r=>(e[0]=r,e[0]),Ci=(e,r,n,o,i,s,a,c)=>(l,u)=>{const h=r.get(l);if(h===void 0)throw new Error("Missing the expected cycle count.");const d=s(l.context),v=c(d);if(h===u){if(r.delete(l),!v&&a(l)){const g=o(l),{outputs:m}=n(l);for(const p of m)if(De(p)){const f=o(p[0]);e(g,f,p[1],p[2])}else{const f=i(p[0]);g.connect(f,p[1])}}}else r.set(l,h-u)},_i=e=>(r,n,o,i)=>e(r[i],s=>s[0]===n&&s[1]===o),Ii=e=>(r,n)=>{e(r).delete(n)},Ei=e=>"delayTime"in e,Ti=(e,r,n)=>function o(i,s){const a=Xe(s)?s:n(e,s);if(Ei(a))return[];if(i[0]===a)return[i];if(i.includes(a))return[];const{outputs:c}=r(a);return Array.from(c).map(l=>o([...i,a],l[0])).reduce((l,u)=>l.concat(u),[])},ze=(e,r,n)=>{const o=r[n];if(o===void 0)throw e();return o},ki=e=>(r,n=void 0,o=void 0,i=0)=>n===void 0?r.forEach(s=>s.disconnect()):typeof n=="number"?ze(e,r,n).disconnect():Ke(n)?o===void 0?r.forEach(s=>s.disconnect(n)):i===void 0?ze(e,r,o).disconnect(n,0):ze(e,r,o).disconnect(n,0,i):o===void 0?r.forEach(s=>s.disconnect(n)):ze(e,r,o).disconnect(n,0),Mi=e=>r=>new Promise((n,o)=>{if(e===null){o(new SyntaxError);return}const i=e.document.head;if(i===null)o(new SyntaxError);else{const s=e.document.createElement("script"),a=new Blob([r],{type:"application/javascript"}),c=URL.createObjectURL(a),l=e.onerror,u=()=>{e.onerror=l,URL.revokeObjectURL(c)};e.onerror=(h,d,v,g,m)=>{if(d===c||d===e.location.href&&v===1&&g===1)return u(),o(m),!1;if(l!==null)return l(h,d,v,g,m)},s.onerror=()=>{u(),o(new SyntaxError)},s.onload=()=>{u(),n()},s.src=c,s.type="module",i.appendChild(s)}}),Ai=e=>class{constructor(r){this._nativeEventTarget=r,this._listeners=new WeakMap}addEventListener(r,n,o){if(n!==null){let i=this._listeners.get(n);i===void 0&&(i=e(this,n),typeof n=="function"&&this._listeners.set(n,i)),this._nativeEventTarget.addEventListener(r,i,o)}}dispatchEvent(r){return this._nativeEventTarget.dispatchEvent(r)}removeEventListener(r,n,o){const i=n===null?void 0:this._listeners.get(n);this._nativeEventTarget.removeEventListener(r,i===void 0?null:i,o)}},Oi=e=>(r,n,o)=>{Object.defineProperties(e,{currentFrame:{configurable:!0,get(){return Math.round(r*n)}},currentTime:{configurable:!0,get(){return r}}});try{return o()}finally{e!==null&&(delete e.currentFrame,delete e.currentTime)}},xi=e=>async r=>{try{const n=await fetch(r);if(n.ok)return[await n.text(),n.url]}catch{}throw e()},Si=(e,r)=>n=>r(e,n),Ui=e=>r=>{const n=e(r);if(n.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return n.renderer},Ri=e=>r=>{var n;return(n=e.get(r))!==null&&n!==void 0?n:0},Bi=e=>r=>{const n=e(r);if(n.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer},Li=e=>r=>e.get(r),ae=()=>new DOMException("","InvalidStateError"),Ni=e=>r=>{const n=e.get(r);if(n===void 0)throw ae();return n},Vi=(e,r)=>n=>{let o=e.get(n);if(o!==void 0)return o;if(r===null)throw new Error("Missing the native OfflineAudioContext constructor.");return o=new r(1,1,44100),e.set(n,o),o},Pi=e=>r=>{const n=e.get(r);if(n===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return n},Di=()=>new DOMException("","InvalidAccessError"),Fi=(e,r,n,o,i,s)=>a=>(c,l)=>{const u=e.get(c);if(u===void 0){if(!a&&s(c)){const h=o(c),{outputs:d}=n(c);for(const v of d)if(De(v)){const g=o(v[0]);r(h,g,v[1],v[2])}else{const g=i(v[0]);h.disconnect(g,v[1])}}e.set(c,l)}else e.set(c,u+l)},Wi=e=>r=>e!==null&&r instanceof e,ji=e=>r=>e!==null&&typeof e.AudioNode=="function"&&r instanceof e.AudioNode,$i=e=>r=>e!==null&&typeof e.AudioParam=="function"&&r instanceof e.AudioParam,zi=e=>r=>e!==null&&r instanceof e,Hi=e=>e!==null&&e.isSecureContext,qi=(e,r,n,o)=>class extends e{constructor(i,s){const a=n(i),c=r(a,s);if(o(a))throw new TypeError;super(i,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}},Gi=(e,r,n,o,i)=>class extends o{constructor(s={}){if(i===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new i(s)}catch(u){throw u.code===12&&u.message==="sampleRate is not in range"?r():u}if(a===null)throw n();if(!Ks(s.latencyHint))throw new TypeError(`The provided value '${s.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(s.sampleRate!==void 0&&a.sampleRate!==s.sampleRate)throw r();super(a,2);const{latencyHint:c}=s,{sampleRate:l}=a;if(this._baseLatency=typeof a.baseLatency=="number"?a.baseLatency:c==="balanced"?512/l:c==="interactive"||c===void 0?256/l:c==="playback"?1024/l:Math.max(2,Math.min(128,Math.round(c*l/128)))*128/l,this._nativeAudioContext=a,i.name==="webkitAudioContext"?(this._nativeGainNode=a.createGain(),this._nativeOscillatorNode=a.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(a.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,a.state==="running"){this._state="suspended";const u=()=>{this._state==="suspended"&&(this._state=null),a.removeEventListener("statechange",u)};a.addEventListener("statechange",u)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw e()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),Xs(this)}))}resume(){return this._state==="suspended"?new Promise((s,a)=>{const c=()=>{this._nativeAudioContext.removeEventListener("statechange",c),this._nativeAudioContext.state==="running"?s():this.resume().then(s,a)};this._nativeAudioContext.addEventListener("statechange",c)}):this._nativeAudioContext.resume().catch(s=>{throw s===void 0||s.code===15?e():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?e():s})}},Yi=(e,r,n,o,i,s)=>class extends n{constructor(a,c){super(a),this._nativeContext=a,Rn.set(this,a),o(a)&&i.set(a,new Set),this._destination=new e(this,c),this._listener=r(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){const c=typeof a=="function"?s(this,a):null;this._nativeContext.onstatechange=c;const l=this._nativeContext.onstatechange;this._onstatechange=l!==null&&l===c?a:l}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}},vn=e=>{const r=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=e.decodeAudioData(r.buffer,()=>{});return n===void 0?!1:(n.catch(()=>{}),!0)}catch{}return!1},Zi=(e,r)=>(n,o,i)=>{const s=new Set;return n.connect=(a=>(c,l=0,u=0)=>{const h=s.size===0;if(r(c))return a.call(n,c,l,u),e(s,[c,l,u],d=>d[0]===c&&d[1]===l&&d[2]===u,!0),h&&o(),c;a.call(n,c,l),e(s,[c,l],d=>d[0]===c&&d[1]===l,!0),h&&o()})(n.connect),n.disconnect=(a=>(c,l,u)=>{const h=s.size>0;if(c===void 0)a.apply(n),s.clear();else if(typeof c=="number"){a.call(n,c);for(const v of s)v[1]===c&&s.delete(v)}else{r(c)?a.call(n,c,l,u):a.call(n,c,l);for(const v of s)v[0]===c&&(l===void 0||v[1]===l)&&(u===void 0||v[2]===u)&&s.delete(v)}const d=s.size===0;h&&d&&i()})(n.disconnect),n},be=(e,r,n)=>{const o=r[n];o!==void 0&&o!==e[n]&&(e[n]=o)},Fe=(e,r)=>{be(e,r,"channelCount"),be(e,r,"channelCountMode"),be(e,r,"channelInterpretation")},Xi=e=>e===null?null:e.hasOwnProperty("AudioBuffer")?e.AudioBuffer:null,Lt=(e,r,n)=>{const o=r[n];o!==void 0&&o!==e[n].value&&(e[n].value=o)},Ki=e=>{e.start=(r=>{let n=!1;return(o=0,i=0,s)=>{if(n)throw ae();r.call(e,o,i,s),n=!0}})(e.start)},qn=e=>{e.start=(r=>(n=0,o=0,i)=>{if(typeof i=="number"&&i<0||o<0||n<0)throw new RangeError("The parameters can't be negative.");r.call(e,n,o,i)})(e.start)},Gn=e=>{e.stop=(r=>(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");r.call(e,n)})(e.stop)},Qi=(e,r,n,o,i,s,a,c,l,u,h)=>(d,v)=>{const g=d.createBufferSource();return Fe(g,v),Lt(g,v,"playbackRate"),be(g,v,"buffer"),be(g,v,"loop"),be(g,v,"loopEnd"),be(g,v,"loopStart"),r(n,()=>n(d))||Ki(g),r(o,()=>o(d))||l(g),r(i,()=>i(d))||u(g,d),r(s,()=>s(d))||qn(g),r(a,()=>a(d))||h(g,d),r(c,()=>c(d))||Gn(g),e(d,g),g},Ji=e=>e===null?null:e.hasOwnProperty("AudioContext")?e.AudioContext:e.hasOwnProperty("webkitAudioContext")?e.webkitAudioContext:null,ea=(e,r)=>(n,o,i)=>{const s=n.destination;if(s.channelCount!==o)try{s.channelCount=o}catch{}i&&s.channelCountMode!=="explicit"&&(s.channelCountMode="explicit"),s.maxChannelCount===0&&Object.defineProperty(s,"maxChannelCount",{value:o});const a=e(n,{channelCount:o,channelCountMode:s.channelCountMode,channelInterpretation:s.channelInterpretation,gain:1});return r(a,"channelCount",c=>()=>c.call(a),c=>l=>{c.call(a,l);try{s.channelCount=l}catch(u){if(l>s.maxChannelCount)throw u}}),r(a,"channelCountMode",c=>()=>c.call(a),c=>l=>{c.call(a,l),s.channelCountMode=l}),r(a,"channelInterpretation",c=>()=>c.call(a),c=>l=>{c.call(a,l),s.channelInterpretation=l}),Object.defineProperty(a,"maxChannelCount",{get:()=>s.maxChannelCount}),a.connect(s),a},ta=e=>e===null?null:e.hasOwnProperty("AudioWorkletNode")?e.AudioWorkletNode:null,na=e=>{const{port1:r}=new MessageChannel;try{r.postMessage(e)}finally{r.close()}},ra=(e,r,n,o,i)=>(s,a,c,l,u,h)=>{if(c!==null)try{const d=new c(s,l,h),v=new Map;let g=null;if(Object.defineProperties(d,{channelCount:{get:()=>h.channelCount,set:()=>{throw e()}},channelCountMode:{get:()=>"explicit",set:()=>{throw e()}},onprocessorerror:{get:()=>g,set:m=>{typeof g=="function"&&d.removeEventListener("processorerror",g),g=typeof m=="function"?m:null,typeof g=="function"&&d.addEventListener("processorerror",g)}}}),d.addEventListener=(m=>(...p)=>{if(p[0]==="processorerror"){const f=typeof p[1]=="function"?p[1]:typeof p[1]=="object"&&p[1]!==null&&typeof p[1].handleEvent=="function"?p[1].handleEvent:null;if(f!==null){const y=v.get(p[1]);y!==void 0?p[1]=y:(p[1]=_=>{_.type==="error"?(Object.defineProperties(_,{type:{value:"processorerror"}}),f(_)):f(new ErrorEvent(p[0],{..._}))},v.set(f,p[1]))}}return m.call(d,"error",p[1],p[2]),m.call(d,...p)})(d.addEventListener),d.removeEventListener=(m=>(...p)=>{if(p[0]==="processorerror"){const f=v.get(p[1]);f!==void 0&&(v.delete(p[1]),p[1]=f)}return m.call(d,"error",p[1],p[2]),m.call(d,p[0],p[1],p[2])})(d.removeEventListener),h.numberOfOutputs!==0){const m=n(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return d.connect(m).connect(s.destination),i(d,()=>m.disconnect(),()=>m.connect(s.destination))}return d}catch(d){throw d.code===11?o():d}if(u===void 0)throw o();return na(h),r(s,a,u,h)},oa=(e,r)=>e===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(e*r))))),sa=e=>new Promise((r,n)=>{const{port1:o,port2:i}=new MessageChannel;o.onmessage=({data:s})=>{o.close(),i.close(),r(s)},o.onmessageerror=({data:s})=>{o.close(),i.close(),n(s)},i.postMessage(e)}),ia=async(e,r)=>{const n=await sa(r);return new e(n)},aa=(e,r,n,o)=>{let i=_t.get(e);i===void 0&&(i=new WeakMap,_t.set(e,i));const s=ia(n,o);return i.set(r,s),s},la=(e,r,n,o,i,s,a,c,l,u,h,d,v)=>(g,m,p,f)=>{if(f.numberOfInputs===0&&f.numberOfOutputs===0)throw l();const y=Array.isArray(f.outputChannelCount)?f.outputChannelCount:Array.from(f.outputChannelCount);if(y.some(T=>T<1))throw l();if(y.length!==f.numberOfOutputs)throw r();if(f.channelCountMode!=="explicit")throw l();const _=f.channelCount*f.numberOfInputs,b=y.reduce((T,U)=>T+U,0),k=p.parameterDescriptors===void 0?0:p.parameterDescriptors.length;if(_+k>6||b>6)throw l();const E=new MessageChannel,I=[],w=[];for(let T=0;T<f.numberOfInputs;T+=1)I.push(a(g,{channelCount:f.channelCount,channelCountMode:f.channelCountMode,channelInterpretation:f.channelInterpretation,gain:1})),w.push(i(g,{channelCount:f.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:f.channelCount}));const C=[];if(p.parameterDescriptors!==void 0)for(const{defaultValue:T,maxValue:U,minValue:Y,name:q}of p.parameterDescriptors){const D=s(g,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:f.parameterData[q]!==void 0?f.parameterData[q]:T===void 0?0:T});Object.defineProperties(D.offset,{defaultValue:{get:()=>T===void 0?0:T},maxValue:{get:()=>U===void 0?Ut:U},minValue:{get:()=>Y===void 0?rt:Y}}),C.push(D)}const A=o(g,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,_+k)}),P=oa(m,g.sampleRate),x=c(g,P,_+k,Math.max(1,b)),S=i(g,{channelCount:Math.max(1,b),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,b)}),N=[];for(let T=0;T<f.numberOfOutputs;T+=1)N.push(o(g,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:y[T]}));for(let T=0;T<f.numberOfInputs;T+=1){I[T].connect(w[T]);for(let U=0;U<f.channelCount;U+=1)w[T].connect(A,U,T*f.channelCount+U)}const L=new zn(p.parameterDescriptors===void 0?[]:p.parameterDescriptors.map(({name:T},U)=>{const Y=C[U];return Y.connect(A,0,_+U),Y.start(0),[T,Y.offset]}));A.connect(x);let W=f.channelInterpretation,R=null;const j=f.numberOfOutputs===0?[x]:N,$={get bufferSize(){return P},get channelCount(){return f.channelCount},set channelCount(T){throw n()},get channelCountMode(){return f.channelCountMode},set channelCountMode(T){throw n()},get channelInterpretation(){return W},set channelInterpretation(T){for(const U of I)U.channelInterpretation=T;W=T},get context(){return x.context},get inputs(){return I},get numberOfInputs(){return f.numberOfInputs},get numberOfOutputs(){return f.numberOfOutputs},get onprocessorerror(){return R},set onprocessorerror(T){typeof R=="function"&&$.removeEventListener("processorerror",R),R=typeof T=="function"?T:null,typeof R=="function"&&$.addEventListener("processorerror",R)},get parameters(){return L},get port(){return E.port2},addEventListener(...T){return x.addEventListener(T[0],T[1],T[2])},connect:e.bind(null,j),disconnect:u.bind(null,j),dispatchEvent(...T){return x.dispatchEvent(T[0])},removeEventListener(...T){return x.removeEventListener(T[0],T[1],T[2])}},M=new Map;E.port1.addEventListener=(T=>(...U)=>{if(U[0]==="message"){const Y=typeof U[1]=="function"?U[1]:typeof U[1]=="object"&&U[1]!==null&&typeof U[1].handleEvent=="function"?U[1].handleEvent:null;if(Y!==null){const q=M.get(U[1]);q!==void 0?U[1]=q:(U[1]=D=>{h(g.currentTime,g.sampleRate,()=>Y(D))},M.set(Y,U[1]))}}return T.call(E.port1,U[0],U[1],U[2])})(E.port1.addEventListener),E.port1.removeEventListener=(T=>(...U)=>{if(U[0]==="message"){const Y=M.get(U[1]);Y!==void 0&&(M.delete(U[1]),U[1]=Y)}return T.call(E.port1,U[0],U[1],U[2])})(E.port1.removeEventListener);let O=null;Object.defineProperty(E.port1,"onmessage",{get:()=>O,set:T=>{typeof O=="function"&&E.port1.removeEventListener("message",O),O=typeof T=="function"?T:null,typeof O=="function"&&(E.port1.addEventListener("message",O),E.port1.start())}}),p.prototype.port=E.port1;let z=null;aa(g,$,p,f).then(T=>z=T);const H=Je(f.numberOfInputs,f.channelCount),Me=Je(f.numberOfOutputs,y),Ae=p.parameterDescriptors===void 0?[]:p.parameterDescriptors.reduce((T,{name:U})=>({...T,[U]:new Float32Array(128)}),{});let G=!0;const ne=()=>{f.numberOfOutputs>0&&x.disconnect(S);for(let T=0,U=0;T<f.numberOfOutputs;T+=1){const Y=N[T];for(let q=0;q<y[T];q+=1)S.disconnect(Y,U+q,q);U+=y[T]}},We=new Map;x.onaudioprocess=({inputBuffer:T,outputBuffer:U})=>{if(z!==null){const Y=d($);for(let q=0;q<P;q+=128){for(let D=0;D<f.numberOfInputs;D+=1)for(let F=0;F<f.channelCount;F+=1)Qe(T,H[D],F,F,q);p.parameterDescriptors!==void 0&&p.parameterDescriptors.forEach(({name:D},F)=>{Qe(T,Ae,D,_+F,q)});for(let D=0;D<f.numberOfInputs;D+=1)for(let F=0;F<y[D];F+=1)Me[D][F].byteLength===0&&(Me[D][F]=new Float32Array(128));try{const D=H.map((F,se)=>{if(Y[se].size>0)return We.set(se,P/128),F;const fe=We.get(se);return fe===void 0?[]:(F.every(Cr=>Cr.every(_r=>_r===0))&&(fe===1?We.delete(se):We.set(se,fe-1)),F)});G=h(g.currentTime+q/g.sampleRate,g.sampleRate,()=>z.process(D,Me,Ae));for(let F=0,se=0;F<f.numberOfOutputs;F+=1){for(let fe=0;fe<y[F];fe+=1)Hn(U,Me[F],fe,se+fe,q);se+=y[F]}}catch(D){G=!1,$.dispatchEvent(new ErrorEvent("processorerror",{colno:D.colno,filename:D.filename,lineno:D.lineno,message:D.message}))}if(!G){for(let D=0;D<f.numberOfInputs;D+=1){I[D].disconnect(w[D]);for(let F=0;F<f.channelCount;F+=1)w[q].disconnect(A,F,D*f.channelCount+F)}if(p.parameterDescriptors!==void 0){const D=p.parameterDescriptors.length;for(let F=0;F<D;F+=1){const se=C[F];se.disconnect(A,0,_+F),se.stop()}}A.disconnect(x),x.onaudioprocess=null,ct?ne():Gt();break}}}};let ct=!1;const ut=a(g,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),qt=()=>x.connect(ut).connect(g.destination),Gt=()=>{x.disconnect(ut),ut.disconnect()},wr=()=>{if(G){Gt(),f.numberOfOutputs>0&&x.connect(S);for(let T=0,U=0;T<f.numberOfOutputs;T+=1){const Y=N[T];for(let q=0;q<y[T];q+=1)S.connect(Y,U+q,q);U+=y[T]}}ct=!0},br=()=>{G&&(qt(),ne()),ct=!1};return qt(),v($,wr,br)},ca=(e,r)=>(n,o)=>{const i=n.createChannelMerger(o.numberOfInputs);return e!==null&&e.name==="webkitAudioContext"&&r(n,i),Fe(i,o),i},ua=e=>{const r=e.numberOfOutputs;Object.defineProperty(e,"channelCount",{get:()=>r,set:n=>{if(n!==r)throw ae()}}),Object.defineProperty(e,"channelCountMode",{get:()=>"explicit",set:n=>{if(n!=="explicit")throw ae()}}),Object.defineProperty(e,"channelInterpretation",{get:()=>"discrete",set:n=>{if(n!=="discrete")throw ae()}})},Yn=(e,r)=>{const n=e.createChannelSplitter(r.numberOfOutputs);return Fe(n,r),ua(n),n},da=(e,r,n,o,i)=>(s,a)=>{if(s.createConstantSource===void 0)return n(s,a);const c=s.createConstantSource();return Fe(c,a),Lt(c,a,"offset"),r(o,()=>o(s))||qn(c),r(i,()=>i(s))||Gn(c),e(s,c),c},Zn=(e,r)=>(e.connect=r.connect.bind(r),e.disconnect=r.disconnect.bind(r),e),ha=(e,r,n,o)=>(i,{offset:s,...a})=>{const c=i.createBuffer(1,2,44100),l=r(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),u=n(i,{...a,gain:s}),h=c.getChannelData(0);h[0]=1,h[1]=1,l.buffer=c,l.loop=!0;const d={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(m){u.channelCount=m},get channelCountMode(){return u.channelCountMode},set channelCountMode(m){u.channelCountMode=m},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(m){u.channelInterpretation=m},get context(){return u.context},get inputs(){return[]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get offset(){return u.gain},get onended(){return l.onended},set onended(m){l.onended=m},addEventListener(...m){return l.addEventListener(m[0],m[1],m[2])},dispatchEvent(...m){return l.dispatchEvent(m[0])},removeEventListener(...m){return l.removeEventListener(m[0],m[1],m[2])},start(m=0){l.start.call(l,m)},stop(m=0){l.stop.call(l,m)}},v=()=>l.connect(u),g=()=>l.disconnect(u);return e(i,l),o(Zn(d,u),v,g)},ye=(e,r)=>{const n=e.createGain();return Fe(n,r),Lt(n,r,"gain"),n},pa=(e,{mediaStream:r})=>{const n=r.getAudioTracks();n.sort((s,a)=>s.id<a.id?-1:s.id>a.id?1:0);const o=n.slice(0,1),i=e.createMediaStreamSource(new MediaStream(o));return Object.defineProperty(i,"mediaStream",{value:r}),i},fa=e=>e===null?null:e.hasOwnProperty("OfflineAudioContext")?e.OfflineAudioContext:e.hasOwnProperty("webkitOfflineAudioContext")?e.webkitOfflineAudioContext:null,Nt=(e,r,n,o)=>e.createScriptProcessor(r,n,o),ke=()=>new DOMException("","NotSupportedError"),ma=(e,r)=>(n,o,i)=>(e(o).replay(i),r(o,n,i)),va=(e,r,n)=>async(o,i,s)=>{const a=e(o);await Promise.all(a.activeInputs.map((c,l)=>Array.from(c).map(async([u,h])=>{const d=await r(u).render(u,i),v=o.context.destination;!n(u)&&(o!==v||!n(o))&&d.connect(s,h,l)})).reduce((c,l)=>[...c,...l],[]))},ga=(e,r,n)=>async(o,i,s)=>{const a=r(o);await Promise.all(Array.from(a.activeInputs).map(async([c,l])=>{const u=await e(c).render(c,i);n(c)||u.connect(s,l)}))},ya=(e,r,n,o)=>i=>e(vn,()=>vn(i))?Promise.resolve(e(o,o)).then(s=>{if(!s){const a=n(i,512,0,1);i.oncomplete=()=>{a.onaudioprocess=null,a.disconnect()},a.onaudioprocess=()=>i.currentTime,a.connect(i.destination)}return i.startRendering()}):new Promise(s=>{const a=r(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=c=>{a.disconnect(),s(c.renderedBuffer)},a.connect(i.destination),i.startRendering()}),wa=e=>(r,n)=>{e.set(r,n)},ba=e=>()=>{if(e===null)return!1;try{new e({length:1,sampleRate:44100})}catch{return!1}return!0},Ca=(e,r)=>async()=>{if(e===null)return!0;if(r===null)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),o=new r(1,128,44100),i=URL.createObjectURL(n);let s=!1,a=!1;try{await o.audioWorklet.addModule(i);const c=new e(o,"a",{numberOfOutputs:0}),l=o.createOscillator();c.port.onmessage=()=>s=!0,c.onprocessorerror=()=>a=!0,l.connect(c),l.start(0),await o.startRendering(),await new Promise(u=>setTimeout(u))}catch{}finally{URL.revokeObjectURL(i)}return s&&!a},_a=(e,r)=>()=>{if(r===null)return Promise.resolve(!1);const n=new r(1,1,44100),o=e(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{n.oncomplete=()=>{o.disconnect(),i(n.currentTime!==0)},n.startRendering()})},Ia=()=>new DOMException("","UnknownError"),Ea=()=>typeof window>"u"?null:window,Ta=(e,r)=>n=>{n.copyFromChannel=(o,i,s=0)=>{const a=e(s),c=e(i);if(c>=n.numberOfChannels)throw r();const l=n.length,u=n.getChannelData(c),h=o.length;for(let d=a<0?-a:0;d+a<l&&d<h;d+=1)o[d]=u[d+a]},n.copyToChannel=(o,i,s=0)=>{const a=e(s),c=e(i);if(c>=n.numberOfChannels)throw r();const l=n.length,u=n.getChannelData(c),h=o.length;for(let d=a<0?-a:0;d+a<l&&d<h;d+=1)u[d+a]=o[d]}},ka=e=>r=>{r.copyFromChannel=(n=>(o,i,s=0)=>{const a=e(s),c=e(i);if(a<r.length)return n.call(r,o,c,a)})(r.copyFromChannel),r.copyToChannel=(n=>(o,i,s=0)=>{const a=e(s),c=e(i);if(a<r.length)return n.call(r,o,c,a)})(r.copyToChannel)},Ma=e=>(r,n)=>{const o=n.createBuffer(1,1,44100);r.buffer===null&&(r.buffer=o),e(r,"buffer",i=>()=>{const s=i.call(r);return s===o?null:s},i=>s=>i.call(r,s===null?o:s))},Aa=(e,r)=>(n,o)=>{o.channelCount=1,o.channelCountMode="explicit",Object.defineProperty(o,"channelCount",{get:()=>1,set:()=>{throw e()}}),Object.defineProperty(o,"channelCountMode",{get:()=>"explicit",set:()=>{throw e()}});const i=n.createBufferSource();r(o,()=>{const s=o.numberOfInputs;for(let a=0;a<s;a+=1)i.connect(o,0,a)},()=>i.disconnect(o))},Oa=(e,r,n)=>e.copyFromChannel===void 0?e.getChannelData(n)[0]:(e.copyFromChannel(r,n),r[0]),Vt=(e,r,n,o)=>{let i=e;for(;!i.hasOwnProperty(r);)i=Object.getPrototypeOf(i);const{get:s,set:a}=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,{get:n(s),set:o(a)})},xa=e=>({...e,outputChannelCount:e.outputChannelCount!==void 0?e.outputChannelCount:e.numberOfInputs===1&&e.numberOfOutputs===1?[e.channelCount]:Array.from({length:e.numberOfOutputs},()=>1)}),Xn=(e,r,n)=>{try{e.setValueAtTime(r,n)}catch(o){if(o.code!==9)throw o;Xn(e,r,n+1e-7)}},Sa=e=>{const r=e.createBufferSource();r.start();try{r.start()}catch{return!0}return!1},Ua=e=>{const r=e.createBufferSource(),n=e.createBuffer(1,1,44100);r.buffer=n;try{r.start(0,1)}catch{return!1}return!0},Ra=e=>{const r=e.createBufferSource();r.start();try{r.stop()}catch{return!1}return!0},Kn=e=>{const r=e.createOscillator();try{r.start(-1)}catch(n){return n instanceof RangeError}return!1},Ba=e=>{const r=e.createBuffer(1,1,44100),n=e.createBufferSource();n.buffer=r,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}},Qn=e=>{const r=e.createOscillator();try{r.stop(-1)}catch(n){return n instanceof RangeError}return!1},La=e=>{const{port1:r,port2:n}=new MessageChannel;try{r.postMessage(e)}finally{r.close(),n.close()}},Na=e=>{e.start=(r=>(n=0,o=0,i)=>{const s=e.buffer,a=s===null?o:Math.min(s.duration,o);s!==null&&a>s.duration-.5/e.context.sampleRate?r.call(e,n,0,0):r.call(e,n,a,i)})(e.start)},Va=(e,r)=>{const n=r.createGain();e.connect(n);const o=(i=>()=>{i.call(e,n),e.removeEventListener("ended",o)})(e.disconnect);e.addEventListener("ended",o),Zn(e,n),e.stop=(i=>{let s=!1;return(a=0)=>{if(s)try{i.call(e,a)}catch{n.gain.setValueAtTime(0,a)}else i.call(e,a),s=!0}})(e.stop)},ot=(e,r)=>n=>{const o={value:e};return Object.defineProperties(n,{currentTarget:o,target:o}),typeof r=="function"?r.call(e,n):r.handleEvent.call(e,n)},Pa=Os(Te),Da=Ls(Te),Fa=_i(nt),Wa=new WeakMap,ja=Ri(Wa),Ue=gi(new Map,new WeakMap),ce=Ea(),Jn=Ui(J),Pt=va(J,Jn,_e),Ie=Ni(Rn),Re=fa(ce),pe=zi(Re),er=new WeakMap,tr=Ai(ot),st=Ji(ce),$a=Wi(st),nr=ji(ce),za=$i(ce),Ne=ta(ce),it=ci(xs(On),Bs(Pa,Da,Tt,Fa,kt,J,ja,Ve,ie,Te,Ce,_e,He),Ue,Fi(bt,kt,J,ie,Le,Ce),Ee,Di,ke,Ci(Tt,bt,J,ie,Le,Ie,Ce,pe),Ti(er,J,le),tr,Ie,$a,nr,za,pe,Ne),Ha=new WeakSet,gn=Xi(ce),rr=bi(new Uint32Array(1)),qa=Ta(rr,Ee),Ga=ka(rr),Ya=Fs(Ha,Ue,ke,gn,Re,ba(gn),qa,Ga),Dt=Ns(ye),or=ga(Jn,Pe,_e),sr=yi(or),at=Qi(Dt,Ue,Sa,Ua,Ra,Kn,Ba,Qn,Na,Ma(Vt),Va),ir=ma(Bi(Pe),or),Za=$s(sr,at,ie,ir,Pt),Ft=ui(Ss(Sn),er,Un,di,Is,Es,Ts,ks,Ms,gt,Mn,st,Xn),Xa=js(it,Za,Ft,ae,at,Ie,pe,ot),Ka=Qs(it,Js,Ee,ae,ea(ye,Vt),Ie,pe,Pt),lt=Zi(Te,nr),Qa=Aa(ae,lt),Wt=ca(st,Qa),Ja=ha(Dt,at,ye,lt),jt=da(Dt,Ue,Ja,Kn,Qn),el=ya(Ue,ye,Nt,_a(ye,Re)),tl=ei(Ft,Wt,jt,Nt,ke,Oa,pe,Vt),ar=new WeakMap,nl=Yi(Ka,tl,tr,pe,ar,ot),lr=Hi(ce),$t=Oi(ce),cr=new WeakMap,rl=Vi(cr,Re),yn=lr?Rs(Ue,ke,Mi(ce),$t,xi(As),Ie,rl,pe,Ne,new WeakMap,new WeakMap,Ca(Ne,Re),ce):void 0,ol=qi(it,pa,Ie,pe),ur=Pi(ar),sl=Vs(ur),dr=wi(Ee),il=Ii(ur),hr=ki(Ee),pr=new WeakMap,al=Si(pr,le),ll=la(dr,Ee,ae,Wt,Yn,jt,ye,Nt,ke,hr,$t,al,lt),cl=ra(ae,ll,ye,ke,lt),ul=vi(sr,dr,at,Wt,Yn,jt,ye,il,hr,$t,ie,Ne,Re,ir,Pt,el),dl=Li(cr),hl=wa(pr),wn=lr?pi(sl,it,Ft,ul,cl,J,dl,Ie,pe,Ne,xa,hl,La,ot):void 0,pl=Gi(ae,ke,Ia,nl,st),fr="Missing AudioWorklet support. Maybe this is not running in a secure context.",fl=async(e,r,n,o,i)=>{const{encoderInstanceId:s,port:a}=await Tn(i,r.sampleRate);if(wn===void 0)throw new Error(fr);const c=e===null?null:new Xa(r,{buffer:e}),l=new ol(r,{mediaStream:o}),u=ws(wn,r,{channelCount:n});return{audioBufferSourceNode:c,encoderInstanceId:s,mediaStreamAudioSourceNode:l,port:a,recorderAudioWorkletNode:u}},ml=(e,r,n,o)=>(i,s,a)=>{var c;const l=(c=s.getAudioTracks()[0])===null||c===void 0?void 0:c.getSettings().sampleRate,u=new pl({latencyHint:"playback",sampleRate:l}),h=MediaRecorder.isTypeSupported("audio/mp4")?new Ya({length:2688,sampleRate:u.sampleRate}):null,d=[],v=ys(w=>{if(yn===void 0)throw new Error(fr);return yn(u,w)});let g=null,m=null,p=null,f=null,y=!0;const _=w=>{i.dispatchEvent(e("dataavailable",{data:new Blob(w,{type:a})}))},b=async(w,C)=>{const A=await qe(w,C);p===null?d.push(...A):(_(A),f=b(w,C))},k=()=>(y=!0,u.resume()),E=()=>{p!==null&&(g!==null&&(s.removeEventListener("addtrack",g),s.removeEventListener("removetrack",g)),m!==null&&clearTimeout(m),p.then(async({encoderInstanceId:w,mediaStreamAudioSourceNode:C,recorderAudioWorkletNode:A})=>{f!==null&&(f.catch(()=>{}),f=null),await A.stop(),C.disconnect(A);const P=await qe(w,null);p===null&&await I(),_([...d,...P]),d.length=0,i.dispatchEvent(new Event("stop"))}),p=null)},I=()=>(y=!1,u.suspend());return I(),{get mimeType(){return a},get state(){return p===null?"inactive":y?"recording":"paused"},pause(){if(p===null)throw n();y&&(I(),i.dispatchEvent(new Event("pause")))},resume(){if(p===null)throw n();y||(k(),i.dispatchEvent(new Event("resume")))},start(w){var C;if(p!==null)throw n();if(s.getVideoTracks().length>0)throw o();i.dispatchEvent(new Event("start"));const A=s.getAudioTracks(),P=A.length===0?2:(C=A[0].getSettings().channelCount)!==null&&C!==void 0?C:2;p=Promise.all([k(),v.then(()=>fl(h,u,P,s,a))]).then(async([,{audioBufferSourceNode:S,encoderInstanceId:N,mediaStreamAudioSourceNode:L,port:W,recorderAudioWorkletNode:R}])=>(L.connect(R),S!==null&&(await new Promise(j=>{S.onended=j,S.connect(R),S.start()}),S.disconnect(R)),await R.record(W),w!==void 0&&(f=b(N,w)),{encoderInstanceId:N,mediaStreamAudioSourceNode:L,recorderAudioWorkletNode:R}));const x=s.getTracks();g=()=>{E(),i.dispatchEvent(new ErrorEvent("error",{error:r()}))},s.addEventListener("addtrack",g),s.addEventListener("removetrack",g),m=setInterval(()=>{const S=s.getTracks();(S.length!==x.length||S.some((N,L)=>N!==x[L]))&&g!==null&&g()},1e3)},stop:E}};class ft{constructor(r,n=0,o){if(n<0||o!==void 0&&o<0)throw new RangeError;const i=r.reduce((h,d)=>h+d.byteLength,0);if(n>i||o!==void 0&&n+o>i)throw new RangeError;const s=[],a=o===void 0?i-n:o,c=[];let l=0,u=n;for(const h of r)if(c.length===0)if(h.byteLength>u){l=h.byteLength-u;const d=l>a?a:l;s.push(new DataView(h,u,d)),c.push(h)}else u-=h.byteLength;else if(l<a){l+=h.byteLength;const d=l>a?h.byteLength-l+a:h.byteLength;s.push(new DataView(h,0,d)),c.push(h)}this._buffers=c,this._byteLength=a,this._byteOffset=u,this._dataViews=s,this._internalBuffer=new DataView(new ArrayBuffer(8))}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get byteOffset(){return this._byteOffset}getFloat32(r,n){return this._internalBuffer.setUint8(0,this.getUint8(r+0)),this._internalBuffer.setUint8(1,this.getUint8(r+1)),this._internalBuffer.setUint8(2,this.getUint8(r+2)),this._internalBuffer.setUint8(3,this.getUint8(r+3)),this._internalBuffer.getFloat32(0,n)}getFloat64(r,n){return this._internalBuffer.setUint8(0,this.getUint8(r+0)),this._internalBuffer.setUint8(1,this.getUint8(r+1)),this._internalBuffer.setUint8(2,this.getUint8(r+2)),this._internalBuffer.setUint8(3,this.getUint8(r+3)),this._internalBuffer.setUint8(4,this.getUint8(r+4)),this._internalBuffer.setUint8(5,this.getUint8(r+5)),this._internalBuffer.setUint8(6,this.getUint8(r+6)),this._internalBuffer.setUint8(7,this.getUint8(r+7)),this._internalBuffer.getFloat64(0,n)}getInt16(r,n){return this._internalBuffer.setUint8(0,this.getUint8(r+0)),this._internalBuffer.setUint8(1,this.getUint8(r+1)),this._internalBuffer.getInt16(0,n)}getInt32(r,n){return this._internalBuffer.setUint8(0,this.getUint8(r+0)),this._internalBuffer.setUint8(1,this.getUint8(r+1)),this._internalBuffer.setUint8(2,this.getUint8(r+2)),this._internalBuffer.setUint8(3,this.getUint8(r+3)),this._internalBuffer.getInt32(0,n)}getInt8(r){const[n,o]=this._findDataViewWithOffset(r);return n.getInt8(r-o)}getUint16(r,n){return this._internalBuffer.setUint8(0,this.getUint8(r+0)),this._internalBuffer.setUint8(1,this.getUint8(r+1)),this._internalBuffer.getUint16(0,n)}getUint32(r,n){return this._internalBuffer.setUint8(0,this.getUint8(r+0)),this._internalBuffer.setUint8(1,this.getUint8(r+1)),this._internalBuffer.setUint8(2,this.getUint8(r+2)),this._internalBuffer.setUint8(3,this.getUint8(r+3)),this._internalBuffer.getUint32(0,n)}getUint8(r){const[n,o]=this._findDataViewWithOffset(r);return n.getUint8(r-o)}setFloat32(r,n,o){this._internalBuffer.setFloat32(0,n,o),this.setUint8(r,this._internalBuffer.getUint8(0)),this.setUint8(r+1,this._internalBuffer.getUint8(1)),this.setUint8(r+2,this._internalBuffer.getUint8(2)),this.setUint8(r+3,this._internalBuffer.getUint8(3))}setFloat64(r,n,o){this._internalBuffer.setFloat64(0,n,o),this.setUint8(r,this._internalBuffer.getUint8(0)),this.setUint8(r+1,this._internalBuffer.getUint8(1)),this.setUint8(r+2,this._internalBuffer.getUint8(2)),this.setUint8(r+3,this._internalBuffer.getUint8(3)),this.setUint8(r+4,this._internalBuffer.getUint8(4)),this.setUint8(r+5,this._internalBuffer.getUint8(5)),this.setUint8(r+6,this._internalBuffer.getUint8(6)),this.setUint8(r+7,this._internalBuffer.getUint8(7))}setInt16(r,n,o){this._internalBuffer.setInt16(0,n,o),this.setUint8(r,this._internalBuffer.getUint8(0)),this.setUint8(r+1,this._internalBuffer.getUint8(1))}setInt32(r,n,o){this._internalBuffer.setInt32(0,n,o),this.setUint8(r,this._internalBuffer.getUint8(0)),this.setUint8(r+1,this._internalBuffer.getUint8(1)),this.setUint8(r+2,this._internalBuffer.getUint8(2)),this.setUint8(r+3,this._internalBuffer.getUint8(3))}setInt8(r,n){const[o,i]=this._findDataViewWithOffset(r);o.setInt8(r-i,n)}setUint16(r,n,o){this._internalBuffer.setUint16(0,n,o),this.setUint8(r,this._internalBuffer.getUint8(0)),this.setUint8(r+1,this._internalBuffer.getUint8(1))}setUint32(r,n,o){this._internalBuffer.setUint32(0,n,o),this.setUint8(r,this._internalBuffer.getUint8(0)),this.setUint8(r+1,this._internalBuffer.getUint8(1)),this.setUint8(r+2,this._internalBuffer.getUint8(2)),this.setUint8(r+3,this._internalBuffer.getUint8(3))}setUint8(r,n){const[o,i]=this._findDataViewWithOffset(r);o.setUint8(r-i,n)}_findDataViewWithOffset(r){let n=0;for(const o of this._dataViews){const i=n+o.byteLength;if(r>=n&&r<i)return[o,n];n=i}throw new RangeError}}const vl=(e,r,n)=>(o,i,s,a)=>{const c=[],l=new i(s,{mimeType:"audio/webm; codecs=pcm"});let u=null,h=()=>{};const d=m=>{o.dispatchEvent(e("dataavailable",{data:new Blob(m,{type:a})}))},v=async(m,p)=>{const f=await qe(m,p);l.state==="inactive"?c.push(...f):(d(f),u=v(m,p))},g=()=>{l.state!=="inactive"&&(u!==null&&(u.catch(()=>{}),u=null),h(),h=()=>{},l.stop())};return l.addEventListener("error",m=>{g(),o.dispatchEvent(new ErrorEvent("error",{error:m.error}))}),l.addEventListener("pause",()=>o.dispatchEvent(new Event("pause"))),l.addEventListener("resume",()=>o.dispatchEvent(new Event("resume"))),l.addEventListener("start",()=>o.dispatchEvent(new Event("start"))),{get mimeType(){return a},get state(){return l.state},pause(){return l.pause()},resume(){return l.resume()},start(m){const[p]=s.getAudioTracks();if(p!==void 0&&l.state==="inactive"){const{channelCount:f,sampleRate:y}=p.getSettings();if(f===void 0)throw new Error("The channelCount is not defined.");if(y===void 0)throw new Error("The sampleRate is not defined.");let _=!1,b=!1,k=0,E=Tn(a,y);h=()=>{b=!0};const I=kn(l,"dataavailable")(({data:w})=>{k+=1;const C=w.arrayBuffer();E=E.then(async({dataView:A=null,elementType:P=null,encoderInstanceId:x,port:S})=>{const N=await C;k-=1;const L=A===null?new ft([N]):new ft([...A.buffers,N],A.byteOffset);if(!_&&l.state==="recording"&&!b){const M=n(L,0);if(M===null)return{dataView:L,elementType:P,encoderInstanceId:x,port:S};const{value:O}=M;if(O!==172351395)return{dataView:A,elementType:P,encoderInstanceId:x,port:S};_=!0}const{currentElementType:W,offset:R,contents:j}=r(L,P,f),$=R<L.byteLength?new ft(L.buffers,L.byteOffset+R):null;return j.forEach(M=>S.postMessage(M,M.map(({buffer:O})=>O))),k===0&&(l.state==="inactive"||b)&&(qe(x,null).then(M=>{d([...c,...M]),c.length=0,o.dispatchEvent(new Event("stop"))}),S.postMessage([]),S.close(),I()),{dataView:$,elementType:W,encoderInstanceId:x,port:S}})});m!==void 0&&E.then(({encoderInstanceId:w})=>{b||(u=v(w,m))})}l.start(100)},stop:g}},gl=()=>typeof window>"u"?null:window,mr=(e,r)=>{if(r>=e.byteLength)return null;const n=e.getUint8(r);if(n>127)return 1;if(n>63)return 2;if(n>31)return 3;if(n>15)return 4;if(n>7)return 5;if(n>3)return 6;if(n>1)return 7;if(n>0)return 8;const o=mr(e,r+1);return o===null?null:o+8},yl=(e,r)=>n=>{const o={value:e};return Object.defineProperties(n,{currentTarget:o,target:o}),typeof r=="function"?r.call(e,n):r.handleEvent.call(e,n)},vr=[],zt=gl(),wl=ts(zt),gr=Yo(wl),bl=ml(gr,Qo,Jo,vt),Ht=is(mr),Cl=os(Ht),_l=ss(Ht),Il=Zo(Cl,_l),El=vl(gr,Il,Ht),Tl=Ko(zt),kl=ns(zt),Ml=es(rs(vt),vt,bl,El,vr,Xo(Tl,yl),kl),Al=new WeakMap,Ol=async e=>{const r=await Go(e);vr.push(r),Al.set(e,r)},xl=In({characterize:({call:e})=>()=>e("characterize"),encode:({call:e})=>(r,n)=>e("encode",{recordingId:r,timeslice:n}),record:({call:e})=>async(r,n,o)=>{await e("record",{recordingId:r,sampleRate:n,typedArrays:o},o.map(({buffer:i})=>i).filter(i=>i instanceof ArrayBuffer))}}),Sl=e=>{const r=new Worker(e);return xl(r)},Ul=`(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,s=536870912,a=2*s,o=function(e,t){return function(r){var o=t.get(r),i=void 0===o?r.size:o<a?o+1:0;if(!r.has(i))return e(r,i);if(r.size<s){for(;r.has(i);)i=Math.floor(Math.random()*a);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,c=r(i),l=o(c,i),u=t(l);e.addUniqueNumber=u,e.generateUniqueNumber=l}(t)}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,s=(e,t)=>Object.assign(new Error(e),{status:t}),a=t=>s('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),o=(t,r)=>async({data:{id:o,method:i,params:c}})=>{const l=r[i];try{if(void 0===l)throw(e=>s('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===c?l():l(c);if(void 0===r)throw(t=>s('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const u=r instanceof Promise?await r:r;if(null===o){if(void 0!==u.result)throw a(i)}else{if(void 0===u.result)throw a(i);const{result:e,transferables:r=[]}=u;t.postMessage({id:o,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:o})}};var i=r(455);const c=new Map,l=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),s=(0,i.generateUniqueNumber)(c);return c.set(s,()=>{n(),t.close(),c.delete(s)}),{result:s}},disconnect:({portId:e})=>{const r=c.get(e);if(void 0===r)throw(e=>s('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),u=(e,t,r=()=>!0)=>{const n=l(u,t,r),s=o(e,n);return e.addEventListener("message",s),()=>e.removeEventListener("message",s)},d=e=>e.reduce((e,t)=>e+t.length,0),h=(e,t)=>{const r=[];let n=0;e:for(;n<t;){const t=e.length;for(let s=0;s<t;s+=1){const t=e[s];void 0===r[s]&&(r[s]=[]);const a=t.shift();if(void 0===a)break e;r[s].push(a),0===s&&(n+=a.length)}}if(n>t){const s=n-t;r.forEach((t,r)=>{const n=t.pop(),a=n.length-s;t.push(n.subarray(0,a)),e[r].unshift(n.subarray(a))})}return r},f=new Map,m=(e=>(t,r,n)=>{const s=e.get(t);if(void 0===s){const s={channelDataArrays:n.map(e=>[e]),isComplete:!0,sampleRate:r};return e.set(t,s),s}return s.channelDataArrays.forEach((e,t)=>e.push(n[t])),s})(f),p=((e,t)=>(r,n,s,a)=>{const o=s>>3,i="subsequent"===n?0:44,c=r.length,l=e(r[0]),u=new ArrayBuffer(l*c*o+i),d=new DataView(u);return"subsequent"!==n&&t(d,s,c,"complete"===n?l:Number.POSITIVE_INFINITY,a),r.forEach((e,t)=>{let r=i+t*o;e.forEach(e=>{const t=e.length;for(let n=0;n<t;n+=1){const t=e[n];d.setInt16(r,t<0?32768*Math.max(-1,t):32767*Math.min(1,t),!0),r+=c*o}})}),[u]})(d,(e,t,r,n,s)=>{const a=t>>3,o=Math.min(n*r*a,4294967251);e.setUint32(0,1380533830),e.setUint32(4,o+36,!0),e.setUint32(8,1463899717),e.setUint32(12,1718449184),e.setUint32(16,16,!0),e.setUint16(20,1,!0),e.setUint16(22,r,!0),e.setUint32(24,s,!0),e.setUint32(28,s*r*a,!0),e.setUint16(32,r*a,!0),e.setUint16(34,t,!0),e.setUint32(36,1684108385),e.setUint32(40,o,!0)}),v=new Map;u(self,{characterize:()=>({result:/^audio\\/wav$/}),encode:({recordingId:e,timeslice:t})=>{const r=v.get(e);void 0!==r&&(v.delete(e),r.reject(new Error("Another request was made to initiate an encoding.")));const n=f.get(e);if(null!==t){if(void 0===n||d(n.channelDataArrays[0])*(1e3/n.sampleRate)<t)return new Promise((r,n)=>{v.set(e,{reject:n,resolve:r,timeslice:t})});const r=h(n.channelDataArrays,Math.ceil(t*(n.sampleRate/1e3))),s=p(r,n.isComplete?"initial":"subsequent",16,n.sampleRate);return n.isComplete=!1,{result:s,transferables:s}}if(void 0!==n){const t=p(n.channelDataArrays,n.isComplete?"complete":"subsequent",16,n.sampleRate);return f.delete(e),{result:t,transferables:t}}return{result:[],transferables:[]}},record:({recordingId:e,sampleRate:t,typedArrays:r})=>{const n=m(e,t,r),s=v.get(e);if(void 0!==s&&d(n.channelDataArrays[0])*(1e3/t)>=s.timeslice){const r=h(n.channelDataArrays,Math.ceil(s.timeslice*(t/1e3))),a=p(r,n.isComplete?"initial":"subsequent",16,t);n.isComplete=!1,v.delete(e),s.resolve({result:a,transferables:a})}return{result:null}}})})()})();`,Rl=new Blob([Ul],{type:"application/javascript; charset=utf-8"}),yr=URL.createObjectURL(Rl),Bl=Sl(yr),Ll=Bl.connect;URL.revokeObjectURL(yr);const Nl={name:"AudioRecorderWrapper",components:{NcButton:tt,MicrophoneOutlineIcon:Lo,CheckIcon:Ao,CloseIcon:bn},props:{disabled:{type:Boolean,default:!1},isRecording:{type:Boolean,default:!1},compact:{type:Boolean,default:!1}},emits:["new-recording","update:is-recording"],data(){return{audioStream:null,mediaRecorder:null,chunks:[],aborted:!1,recordTimer:null,recordTime:{minutes:0,seconds:0}}},computed:{parsedRecordTime(){const e=this.recordTime.seconds.toString().length===2?this.recordTime.seconds:`0${this.recordTime.seconds}`;return`${this.recordTime.minutes.toString().length===2?this.recordTime.minutes:`0${this.recordTime.minutes}`}:${e}`}},watch:{isRecording(e){console.debug("isRecording",e)}},mounted(){},beforeUnmount(){this.killStreams()},methods:{async start(){OCA.Assistant.encoderRegistered||(await Ol(await Ll()),OCA.Assistant.encoderRegistered=!0);try{this.audioStream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1})}catch(e){console.debug(e),this.killStreams(),e.name==="NotAllowedError"?he(t("assistant","Access to the microphone was denied. Please check you allowed this page to access the microphone.")):he(t("assistant","Microphone either not available or disabled in settings. Check you are accessing this page with HTTPS or adjust your browser settings."));return}try{this.mediaRecorder=new Ml(this.audioStream,{mimeType:"audio/wav"})}catch(e){console.debug(e),this.killStreams(),this.audioStream=null,he(t("assistant","Error while recording audio")+". "+t("assistant","Please try again and inform the server administrators if this issue persists."));return}this.mediaRecorder.onstop=this.generateFile,this.mediaRecorder.ondataavailable=e=>{this.chunks.push(e.data)};try{this.mediaRecorder.start()}catch(e){console.debug(e),this.aborted=!0,this.stop(),this.killStreams(),this.resetComponentData(),he(t("assistant","Error while recording audio"));return}console.debug(this.mediaRecorder.state),this.recordTimer=setInterval(()=>{this.recordTime.seconds===59&&(this.recordTime.minutes++,this.recordTime.seconds=0),this.recordTime.seconds++},1e3),this.$emit("update:is-recording",!0)},stop(){this.mediaRecorder.stop(),clearInterval(this.recordTimer),this.$emit("update:is-recording",!1)},async generateFile(){if(this.killStreams(),!this.aborted){const e=new Blob(this.chunks,{type:this.mediaRecorder.mimeType});this.$emit("new-recording",e),this.$emit("update:is-recording",!1)}this.resetComponentData()},abortRecording(){this.aborted=!0,this.stop()},resetComponentData(){this.audioStream=null,this.mediaRecorder=null,this.chunks=[],this.aborted=!1,this.recordTime={minutes:0,seconds:0}},killStreams(){this.audioStream?.getTracks().forEach(e=>e.stop())}}},Vl={class:"assistant-audio-recorder-wrapper"},Pl={key:2,class:"recording"},Dl={class:"time"};function Fl(e,r,n,o,i,s){const a=Z("MicrophoneOutlineIcon"),c=Z("NcButton"),l=Z("CloseIcon"),u=Z("CheckIcon");return B(),V("div",Vl,[n.isRecording?K("",!0):(B(),ge(c,{key:0,disabled:n.disabled,title:n.compact?e.t("assistant","Start recording"):void 0,onClick:s.start},Er({icon:oe(()=>[Q(a)]),_:2},[n.compact?void 0:{name:"default",fn:oe(()=>[Mt(te(e.t("assistant","Start recording")),1)]),key:"0"}]),1032,["disabled","title","onClick"])),n.isRecording?(B(),ge(c,{key:1,variant:"error",title:e.t("assistant","Dismiss recording"),onClick:s.abortRecording},{icon:oe(()=>[Q(l)]),_:1},8,["title","onClick"])):K("",!0),n.isRecording?(B(),V("div",Pl,[r[0]||(r[0]=X("div",{class:"recording--indicator fadeOutIn"},null,-1)),X("span",Dl,te(s.parsedRecordTime),1)])):K("",!0),n.isRecording?(B(),ge(c,{key:3,variant:"success",title:e.t("assistant","End recording and send"),onClick:s.stop},{icon:oe(()=>[Q(u)]),_:1},8,["title","onClick"])):K("",!0)])}const Wl=ee(Nl,[["render",Fl],["__scopeId","data-v-e7522bfa"]]),jl={name:"UploadOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},$l=["aria-hidden","aria-label"],zl=["fill","width","height"],Hl={d:"M9,10V16H15V10H19L12,3L5,10H9M12,5.8L14.2,8H13V14H11V8H9.8L12,5.8M19,18H5V20H19V18Z"},ql={key:0};function Gl(e,r,n,o,i,s){return B(),V("span",ue(e.$attrs,{"aria-hidden":n.title?null:"true","aria-label":n.title,class:"material-design-icon upload-outline-icon",role:"img",onClick:r[0]||(r[0]=a=>e.$emit("click",a))}),[(B(),V("svg",{fill:n.fillColor,class:"material-design-icon__svg",width:n.size,height:n.size,viewBox:"0 0 24 24"},[X("path",Hl,[n.title?(B(),V("title",ql,te(n.title),1)):K("",!0)])],8,zl))],16,$l)}const Yl=ee(jl,[["render",Gl]]),Zl=re("/apps/assistant/api/v1/input-file"),Xl={name:"UploadInputFileButton",components:{NcButton:tt,UploadOutlineIcon:Yl,NcLoadingIcon:Mr},props:{label:{type:String,default:t("assistant","Upload file")},accept:{type:Array,default:()=>[]},multiple:{type:Boolean,default:!1},isUploading:{type:Boolean,default:!1}},emits:["files-uploaded","update:is-uploading"],data(){return{}},computed:{fileInputAccept(){return this.accept.length>0?this.accept.join(","):void 0}},watch:{},mounted(){},methods:{onCancel(){console.debug("[assistant] file upload cancel")},onUploadFile(){this.$refs.fileInput.click()},onUploadFileSelected(e){if(this.$refs.fileInput.files.length===0)return;const r=this.$refs.fileInput.files;if(console.debug("FILES",this.$refs.fileInput.files),this.multiple)this.$emit("update:is-uploading",!0),Promise.all(Array.from(r).map(n=>this.uploadFile(n))).then(n=>{if(n.some(o=>o.code==="ERR_CANCELED")){console.debug("At least one request has been canceled, do nothing");return}this.$emit("files-uploaded",n.map(o=>o.data.ocs.data))}).catch(n=>{he(t("assistant","Could not upload the files")),console.error(n)}).then(()=>{this.$emit("update:is-uploading",!1)});else{this.$emit("update:is-uploading",!0);const n=r[0];this.uploadFile(n).then(o=>{this.$emit("files-uploaded",o.data.ocs.data)}).catch(o=>{he(t("assistant","Could not upload the file")),console.error(o)}).then(()=>{this.$emit("update:is-uploading",!1)})}},uploadFile(e){const r=new FormData;return r.append("data",e),r.append("filename",e.name),Oe.post(Zl,r)}}},Kl=["accept","multiple"];function Ql(e,r,n,o,i,s){const a=Z("NcLoadingIcon"),c=Z("UploadOutlineIcon"),l=Z("NcButton");return B(),V("div",null,[X("input",{ref:"fileInput",type:"file",accept:s.fileInputAccept,multiple:n.multiple,style:{display:"none"},onCancel:r[0]||(r[0]=Tr((...u)=>s.onCancel&&s.onCancel(...u),["stop"])),onChange:r[1]||(r[1]=(...u)=>s.onUploadFileSelected&&s.onUploadFileSelected(...u))},null,40,Kl),Q(l,ue(e.$attrs,{variant:"secondary",onClick:s.onUploadFile}),{icon:oe(()=>[n.isUploading?(B(),ge(a,{key:0})):(B(),ge(c,{key:1}))]),default:oe(()=>[Mt(" "+te(n.label),1)]),_:1},16,["onClick"])])}const Jl=ee(Xl,[["render",Ql]]),ec={name:"FolderPlusOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},tc=["aria-hidden","aria-label"],nc=["fill","width","height"],rc={d:"M13 19C13 19.34 13.04 19.67 13.09 20H4C2.9 20 2 19.11 2 18V6C2 4.89 2.89 4 4 4H10L12 6H20C21.1 6 22 6.89 22 8V13.81C21.39 13.46 20.72 13.22 20 13.09V8H4V18H13.09C13.04 18.33 13 18.66 13 19M20 18V15H18V18H15V20H18V23H20V20H23V18H20Z"},oc={key:0};function sc(e,r,n,o,i,s){return B(),V("span",ue(e.$attrs,{"aria-hidden":n.title?null:"true","aria-label":n.title,class:"material-design-icon folder-plus-outline-icon",role:"img",onClick:r[0]||(r[0]=a=>e.$emit("click",a))}),[(B(),V("svg",{fill:n.fillColor,class:"material-design-icon__svg",width:n.size,height:n.size,viewBox:"0 0 24 24"},[X("path",rc,[n.title?(B(),V("title",oc,te(n.title),1)):K("",!0)])],8,nc))],16,tc)}const ic=ee(ec,[["render",sc]]),ac={name:"ChooseInputFileButton",components:{NcButton:tt,FolderPlusOutlineIcon:ic},props:{label:{type:String,default:t("assistant","Choose file")},pickerTitle:{type:String,default:t("assistant","Choose a file")},accept:{type:Array,default:()=>[]},multiple:{type:Boolean,default:!1}},emits:["files-chosen"],data(){return{picker:e=>Ar(this.pickerTitle).setMimeTypeFilter(this.accept).setMultiSelect(this.multiple).allowDirectories(!1).addButton({id:"choose-input-file",label:t("assistant","Choose"),variant:"primary",callback:e()}).build()}},computed:{},watch:{},mounted(){},methods:{async onButtonClick(){await this.picker(this.pickerSubmitted).pick()},pickerSubmitted(){return e=>{if(!e||e.length===0||!e[0].path){he(t("assistant","No file selected"));return}console.debug("[assistant] nodes",e),this.$emit("files-chosen",this.multiple?e:e[0])}}}};function lc(e,r,n,o,i,s){const a=Z("FolderPlusOutlineIcon"),c=Z("NcButton");return B(),ge(c,ue(e.$attrs,{variant:"secondary",onClick:s.onButtonClick}),{icon:oe(()=>[Q(a)]),default:oe(()=>[Mt(" "+te(n.label),1)]),_:1},16,["onClick"])}const cc=ee(ac,[["render",lc]]),uc={name:"MediaField",components:{AudioRecorderWrapper:Wl,ChooseInputFileButton:cc,UploadInputFileButton:Jl,TrayArrowDownIcon:zr,ShareVariantIcon:Kr,CloseIcon:bn,ContentSaveOutlineIcon:oo,NcButton:tt},inject:["providedCurrentTaskId"],props:{fieldKey:{type:String,required:!0},value:{type:[Number,null],default:null},field:{type:Object,required:!0},isOutput:{type:Boolean,default:!1}},emits:["update:value"],data(){return{filePath:null,isUploading:!1,isRecording:!1}},computed:{isAudio(){return this.field.type===we.Audio},displayComponent(){return this.field.type===we.Image?fo:this.field.type===we.Audio?lo:this.field.type===we.File?Co:null},acceptedMimeTypes(){if(this.field.type===we.Image)return Or;if(this.field.type===we.Audio)return xr;if(this.field.type===we.Video)return Sr}},watch:{},mounted(){},methods:{onNewRecording(e){const r=re("/apps/assistant/api/v1/input-file"),n=new FormData;n.append("data",e),n.append("filename","recording.wav"),Oe.post(r,n).then(o=>{this.$emit("update:value",o.data.ocs.data.fileId),this.filePath=o.data.ocs.data.filePath}).catch(o=>{he(t("assistant","Could not upload the recorded file")),console.error(o)})},onFileUploaded(e){this.$emit("update:value",e.fileId),this.filePath=e.filePath},onFileChosen(e){this.filePath=e.path,this.$emit("update:value",e.fileid)},onClear(){this.$emit("update:value",null)},getDownloadUrl(){return re("apps/assistant/api/v1/task/{taskId}/output-file/{fileId}/download",{taskId:this.providedCurrentTaskId(),fileId:this.value})},onShare(){if(this.value===null)return;const e=re("/apps/assistant/api/v1/task/{taskId}/file/{fileId}/share",{taskId:this.providedCurrentTaskId(),fileId:this.value});Oe.post(e).then(r=>{const n=r.data.ocs.data.shareToken,o=window.location.protocol+"//"+window.location.host+mt("/s/{shareToken}",{shareToken:n});console.debug("[assistant] generated share link",o);const i=t("assistant","Output file share link copied to clipboard");this.copyString(o,i)}).catch(r=>{console.error(r)})},onSave(){if(this.value===null)return;const e=re("/apps/assistant/api/v1/task/{taskId}/file/{fileId}/save",{taskId:this.providedCurrentTaskId(),fileId:this.value});return Oe.post(e).then(r=>{const n=r.data.ocs.data.path,o=r.data.ocs.data.fileId;console.debug("[assistant] save output file",n);const i=window.location.protocol+"//"+window.location.host+mt("/f/{savedFileId}",{savedFileId:o}),s=`<a href="${i}" target="_blank">${t("assistant","Click this to open the file")}</a>`;Yt(s,{isHTML:!0});const a=t("assistant","This output file has been saved in {path}",{path:n});this.copyString(i,a)}).catch(r=>{console.error(r)})},async copyString(e,r){try{await navigator.clipboard.writeText(e),Yt(r)}catch(n){console.error(n),he(t("assistant","Could not copy to clipboard"))}},onPreviewClick(){if(this.value===null)return;const e=re("/apps/assistant/api/v1/task/{taskId}/file/{fileId}/save",{taskId:this.providedCurrentTaskId(),fileId:this.value});return Oe.post(e).then(r=>{const n=r.data.ocs.data.path;console.debug("[assistant] view output file",n),OCA.Viewer.open({path:n})}).catch(r=>{console.error(r)})}}},dc={class:"media-field"},hc={class:"label-row"},pc=["title"],fc={key:0,class:"select-media"},mc={key:0,class:"buttons"},vc=["href"],gc={key:1,class:"buttons"};function yc(e,r,n,o,i,s){const a=Z("UploadInputFileButton"),c=Z("ChooseInputFileButton"),l=Z("AudioRecorderWrapper"),u=Z("TrayArrowDownIcon"),h=Z("NcButton"),d=Z("ContentSaveOutlineIcon"),v=Z("ShareVariantIcon"),g=Z("CloseIcon");return B(),V("div",dc,[X("div",hc,[X("label",{class:"field-label",title:n.field.description},te(n.field.name),9,pc)]),n.isOutput?K("",!0):(B(),V("div",fc,[Q(a,{"is-uploading":i.isUploading,"onUpdate:isUploading":r[0]||(r[0]=m=>i.isUploading=m),accept:s.acceptedMimeTypes,label:e.t("assistant","Upload from device"),disabled:n.value!==null||i.isRecording||i.isUploading,onFilesUploaded:s.onFileUploaded},null,8,["is-uploading","accept","label","disabled","onFilesUploaded"]),Q(c,{label:e.t("assistant","Select from storage"),"picker-title":e.t("assistant","Pick a file"),accept:s.acceptedMimeTypes,disabled:n.value!==null||i.isRecording||i.isUploading,onFilesChosen:s.onFileChosen},null,8,["label","picker-title","accept","disabled","onFilesChosen"]),s.isAudio?(B(),ge(l,{key:0,"is-recording":i.isRecording,"onUpdate:isRecording":r[1]||(r[1]=m=>i.isRecording=m),disabled:n.value!==null||i.isUploading,onNewRecording:s.onNewRecording},null,8,["is-recording","disabled","onNewRecording"])):K("",!0)])),n.value!==null?(B(),V("div",{key:1,class:et(["media-value",{row:s.isAudio}])},[(B(),ge(kr(s.displayComponent),{"file-id":n.value,"task-id":s.providedCurrentTaskId(),"show-delete":!1,"is-output":n.isOutput,clickable:!0,onClick:s.onPreviewClick},null,8,["file-id","task-id","is-output","onClick"])),n.isOutput?(B(),V("div",mc,[X("a",{href:s.getDownloadUrl(),target:"_blank"},[Q(h,{title:e.t("assistant","Download this media")},{icon:oe(()=>[Q(u)]),_:1},8,["title"])],8,vc),Q(h,{title:e.t("assistant","Save this media"),onClick:s.onSave},{icon:oe(()=>[Q(d)]),_:1},8,["title","onClick"]),Q(h,{title:e.t("assistant","Share this media"),onClick:s.onShare},{icon:oe(()=>[Q(v)]),_:1},8,["title","onClick"])])):(B(),V("div",gc,[Q(h,{variant:"tertiary",title:e.t("assistant","Clear value"),onClick:s.onClear},{icon:oe(()=>[Q(g)]),_:1},8,["title","onClick"])]))],2)):K("",!0)])}const kc=ee(uc,[["render",yc]]);export{Wl as A,bn as C,Co as F,fo as I,kc as M,Kr as S,zr as T,Jl as U,oo as a,cc as b,lo as c,Ao as d};
|
|
//# sourceMappingURL=MediaField-DHoRej3P.chunk.mjs.map
|