@loadmap/cli 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,22 +13,22 @@ import{r as e,t}from"./rolldown-runtime-pP25SEvz.js";(function(){let e=document.
|
|
|
13
13
|
`,t:` `,"\\":`\\`,'"':`"`,"'":`'`,"`":"`",$:`$`};function rn(e,t,n,r){let i=``;for(;t<n&&e[t]!==r&&e[t]!==`
|
|
14
14
|
`;)e[t]===`\\`&&t+1<n?(i+=nn[e[t+1]]??e[t+1],t+=2):i+=e[t++];let a=e[t]===r;return{value:i,end:a?t+1:t,closed:a}}var an=16;function on(e,t,n,r,i=0){let a=[],o=[],s=``;for(;t<n&&e[t]!=="`";)if(e[t]===`\\`&&t+1<n)s+=nn[e[t+1]]??e[t+1],t+=2;else if(e[t]===`$`&&e[t+1]===`{`){a.push(s),s=``;let c=t+2,l=sn(e,c,n,r,i);o.push({from:c,to:l}),e[l]===`}`?t=l+1:(r.error({from:t,to:l},'this "${" has no closing "}"'),t=l)}else s+=e[t++];a.push(s);let c=e[t]==="`";return{quasis:a,parts:o,end:c?t+1:t,closed:c}}function sn(e,t,n,r,i){let a=0;for(;t<n;){let o=e[t];if(o===`}`&&a===0)return t;if(o===`{`)a++;else if(o===`}`)a--;else if(o===`"`||o===`'`){t=rn(e,t+1,n,o).end;continue}else if(o==="`"){if(i+1>=an)return r.error({from:t,to:t+1},`templates are nested more than ${an} deep`),n;t=on(e,t+1,n,r,i+1).end;continue}else if(o===`
|
|
15
15
|
`)return t;t++}return t}var cn=2e5,ln={"||":1,"&&":2,"==":3,"!=":3,"===":3,"!==":3,"<":4,"<=":4,">":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6},un=class{};function dn(e,t=new gt(e)){return e.length>2e5?(t.error({from:0,to:0},`the definition is ${e.length} characters long; at most ${cn}`),{doc:{body:[]},report:t}):{doc:{body:new pn(Qt(e,t),e,t).block(!1)},report:t}}function fn(e,t,n,r,i=0){let a=new pn(Qt(e,r,t,n),e,r);a.depth=i;try{let e=a.expr();return a.peek().kind!==`eof`&&a.fail(a.peek(),`unexpected ${mn(a.peek())} in the formula`),e}catch(e){if(e instanceof un)return{t:`error`,from:t,to:n};throw e}}var pn=class{toks;source;report;i=0;depth=0;blocks=0;constructor(e,t,n){this.toks=e,this.source=t,this.report=n}peek(e=0){return this.toks[Math.min(this.i+e,this.toks.length-1)]}next(){let e=this.peek();return e.kind!==`eof`&&this.i++,e}is(e,t=0){let n=this.peek(t);return n.kind===`punct`&&n.text===e}eat(e){return this.is(e)?(this.i++,!0):!1}expect(e,t){return this.is(e)||this.fail(this.peek(),`expected ${t}, found ${mn(this.peek())}`),this.next()}fail(e,t,n){throw this.report.error(e,t,n),new un}block(e){let t=[];for(;;){for(;this.peek().kind===`newline`||this.is(`;`);)this.next();let n=this.peek();if(n.kind===`eof`)break;if(this.is(`}`)){if(e)break;this.report.error(n,`this "}" closes no block`),this.next()}else try{t.push(this.statement());let e=this.peek();e.kind===`newline`||e.kind===`eof`||this.is(`;`)||this.is(`}`)||this.fail(e,`expected the end of the line, found ${mn(e)}`)}catch(e){if(!(e instanceof un))throw e;this.recover()}}return t}recover(){let e=0;for(;;){let t=this.peek();if(t.kind===`eof`||e===0&&(t.kind===`newline`||this.is(`;`)||this.is(`}`)))return;this.is(`{`)?e++:this.is(`}`)&&e--,this.next()}}statement(){let e=this.peek();return e.kind===`number`||this.is(`-`)&&this.peek(1).kind===`number`?this.row():(e.kind!==`ident`&&this.fail(e,`expected a statement, found ${mn(e)}`),this.is(`:`,1)?this.property():this.is(`->`,1)?this.edge():this.decl())}ident(e=`a name`){let t=this.peek();return t.kind!==`ident`&&this.fail(t,`expected ${e}, found ${mn(t)}`),this.next(),{name:t.text,from:t.from,to:t.to}}property(){let e=this.ident();this.expect(`:`,`":"`),this.endsStatement()&&this.fail(this.peek(),`"${e.name}" has no value`);let t=this.expr();if(this.is(`->`)){t.t!==`id`&&this.fail(t,`a route is a list of names joined by "->"`);let n=[{name:t.name,from:t.from,to:t.to}];for(;this.eat(`->`);)n.push(this.ident(`a stage`));return{kind:`prop`,key:e,value:t,chain:n,from:e.from,to:n.at(-1).to}}return{kind:`prop`,key:e,value:t,from:e.from,to:t.to}}edge(){let e=[this.ident()];for(;this.eat(`->`);)e.push(this.ident(`a name after "->"`));let t={kind:`edge`,chain:e,from:e[0].from,to:e.at(-1).to};if(this.is(`:`)&&this.is(`{`,1)){let e=this.next();t.colon={from:e.from,to:e.to}}else this.eat(`:`)&&(this.endsStatement()&&this.fail(this.peek(),`expected a value after ":"`),t.value=this.expr(),t.to=t.value.to);return this.is(`{`)&&this.body(t),t}decl(){let e=this.next(),t={kind:`decl`,keyword:{name:e.text,from:e.from,to:e.to},args:[],from:e.from,to:e.to};for(;;){let e=this.peek();if(e.kind===`ident`||e.kind===`string`||e.kind===`template`||e.kind===`number`)t.args.push(this.primary());else if(this.is(`-`)&&this.peek(1).kind===`number`)t.args.push(this.unary());else break;t.to=t.args.at(-1).to}return this.eat(`=`)&&(this.endsStatement()&&this.fail(this.peek(),`expected a formula after "="`),t.init=this.expr(),t.to=t.init.to),this.is(`{`)?this.body(t):this.endsStatement()||this.fail(this.peek(),`expected "{" or the end of the line, found ${mn(this.peek())}`),t}body(e){if(this.blocks>=64){let t=this.next();this.report.error(t,`blocks are nested more than 64 deep`);for(let e=1;e>0&&this.peek().kind!==`eof`;){let t=this.next();t.kind===`punct`&&t.text===`{`?e++:t.kind===`punct`&&t.text===`}`&&e--}e.to=this.peek().from}else{this.blocks++;try{this.bodyInside(e)}finally{this.blocks--}}}bodyInside(e){let t=this.next();e.body=this.block(!0);let n=this.peek();this.is(`}`)?(this.next(),e.bodySpan={from:t.from,to:n.to},e.to=n.to):(this.report.error(t,`this "{" of "${`keyword`in e?e.keyword.name:`edge`}" is never closed`),e.bodySpan={from:t.from,to:n.from+1},e.to=n.from)}row(){let e=[];for(;this.peek().kind===`number`||this.is(`-`)&&this.peek(1).kind===`number`;)e.push(this.unary()),this.eat(`,`);return{kind:`row`,values:e,from:e[0].from,to:e.at(-1).to}}endsStatement(){let e=this.peek();return e.kind===`newline`||e.kind===`eof`||this.is(`;`)||this.is(`}`)}expr(){++this.depth>64&&this.fail(this.peek(),`the formula is nested more than 64 deep`);try{let e=this.binary(1);if(this.is(`±`)||this.is(`+/-`))return this.pm(e);if(!this.eat(`?`))return e;let t=this.expr();this.expect(`:`,`":" of the "?"`);let n=this.expr();return{t:`cond`,test:e,then:t,else:n,from:e.from,to:n.to}}finally{this.depth--}}pm(e){this.next();let t=this.unary(),n=this.is(`%`)?this.next():null;return{t:`pm`,value:e,within:t,percent:!!n,from:e.from,to:n?.to??t.to}}binary(e){let t=this.unary();for(;;){let n=this.peek(),r=n.kind===`punct`?ln[n.text]:void 0;if(r==null||r<e)return t;this.next();let i=this.binary(r+1);t={t:`bin`,op:n.text===`===`?`==`:n.text===`!==`?`!=`:n.text,left:t,right:i,from:t.from,to:i.to}}}unary(){let e=this.peek();if(this.is(`-`)||this.is(`+`)||this.is(`!`)){this.next(),++this.depth>64&&this.fail(e,`the formula is nested more than 64 deep`);try{let t=this.unary();return{t:`unary`,op:e.text,arg:t,from:e.from,to:t.to}}finally{this.depth--}}return this.primary()}primary(){let e=this.peek();switch((e.kind===`punct`?e.text===`(`||e.text===`[`:e.kind!==`newline`&&e.kind!==`eof`)||this.fail(e,`expected a value, found ${mn(e)}`),this.next(),e.kind){case`number`:return{t:`num`,value:e.value,from:e.from,to:e.to};case`string`:return{t:`str`,value:e.value,from:e.from,to:e.to};case`template`:return{t:`tpl`,quasis:e.quasis,parts:e.parts.map(e=>this.part(e)),from:e.from,to:e.to};case`ident`:{if(e.text===`true`||e.text===`false`)return{t:`bool`,value:e.text===`true`,from:e.from,to:e.to};let t={name:e.text,from:e.from,to:e.to};if(this.is(`.`)){this.next();let n=this.ident(`a name after "."`);if(!this.is(`(`)){if(t.name===`at`&&this.is(`.`)){this.next();let r=this.ident(`a flow after "at.<stage>."`);return this.is(`.`)&&this.fail(this.peek(),`at takes two names: at.db.orders`),{t:`member`,object:t,prop:n,flow:r,from:e.from,to:r.to}}return this.is(`.`)&&this.fail(this.peek(),`only one "." is allowed: flows.orders, util.db`),{t:`member`,object:t,prop:n,from:e.from,to:n.to}}t.name!==`Math`&&this.fail(t,`"${t.name}.${n.name}(…)" is not a function`),t=n}if(this.is(`(`)){this.next();let n=[];for(;!this.is(`)`)&&(n.push(this.expr()),this.eat(`,`)););let r=this.expect(`)`,`")" or ","`);return{t:`call`,callee:t,args:n,from:e.from,to:r.to}}return{t:`id`,name:e.text,from:e.from,to:e.to}}case`punct`:if(e.text===`(`){let t=this.expr(),n=this.expect(`)`,`")"`);return{...t,from:e.from,to:n.to}}if(e.text===`[`){let t=[];for(;!this.is(`]`)&&(t.push(this.expr()),this.eat(`,`)););let n=this.expect(`]`,`"]" or ","`);return{t:`array`,items:t,from:e.from,to:n.to}}}this.fail(e,`expected a value, found ${mn(e)}`)}part(e){return e.to>e.from?fn(this.source,e.from,e.to,this.report,this.depth):(this.report.error({from:e.from-2,to:e.to+1},`an empty part in a template`),{t:`error`,from:e.from,to:e.to})}};function mn(e){switch(e.kind){case`eof`:return`the end of the file`;case`newline`:return`the end of the line`;case`string`:case`template`:return`a text`;case`number`:return`the number ${e.text}`;default:return`"${e.text}"`}}var hn=5,gn={members:64,pods:256,perPod:256,partitions:1024};function _n(e){return{...e.speed==null?{}:{speed:e.speed},...e.transition==null?{}:{transition:e.transition},...e.direction?{direction:e.direction}:{},...e.assumptions.length?{assumptions:e.assumptions}:{},...e.fullScreen?{fullScreen:e.fullScreen}:{},...e.fullScreenMode?{fullScreenMode:e.fullScreenMode}:{}}}function vn(e,t={}){let n=new gt(e),r=new bn(e,n,t.functions??{}),i={body:[]},a,o=[];try{i=dn(e,n).doc,a=r.run(i),a&&(o=be(a.model).map((e,t)=>{let i=r.expectSpans[t];return{at:i,...n.position(i.from),result:e}}))}catch(e){e instanceof Lt||w(e)||e instanceof Error&&e.message.startsWith(`loadmap: `)?r.runError(e,{from:0,to:0}):e instanceof yn||n.error({from:0,to:0},`internal error: ${e?.message??e}`)}let s=[...n.list].sort((e,t)=>e.from-t.from);return{ok:!n.failed&&!!a,diagnostics:s,definition:a,expectations:o,symbols:r.symbols,doc:i}}var yn=class{},bn=class{source;report;functions;symbols=[];expectSpans=[];names;fits=new Map;lets=new Map;constructor(e,t,n){this.source=e,this.report=t,this.functions=n}run(e){let t=this.shape(``,Nt[``],e.body,{from:0,to:0});this.header(e.body);let n=e=>t.children.filter(t=>t.keyword===e),r=n(`load`);r.length||this.report.error({from:0,to:0},`a definition needs a load line`,`load { max: 100 }`);for(let e of r.slice(1))this.report.error(e.at,`only one load line is allowed`);let i=n(`param`),a=n(`let`),o=n(`fit`),s=n(`flow`),c=t.children.filter(e=>Ft.includes(e.keyword)&&e.args.id).map(e=>this.box(e)),l=n(`component`),u=new Map,d=(e,t,n)=>{let r=t.args.id;r&&this.declare(e,r.name,r,t,n)};for(let e of[...i,...a,...o])d(e.keyword===`param`?`param`:e.keyword===`let`?`let`:`fit`,e,u),e.args.id&&Wt.has(e.args.id.name)&&this.report.error(e.args.id,`"${e.args.id.name}" is a reserved name; pick another`);let f=new Map;for(let e of s)d(`flow`,e,f);let p=new Map,m=new Map,h=new Map;for(let e of c){this.declare(`node`,e.id,e.block.args.id,e.block,p,e.block.keyword);for(let t of e.stages)this.declare(`stage`,t.id,t.block.args.id??t.block.at,t.block,m,e.id);if(e.component){let t=e.component;this.declare(`component`,t.id,t.own?e.block.args.id:t.block.args.id??t.block.at,t.block,h)}}for(let e of l)e.args.id?d(`component`,e,h):this.report.error(e.at,`a component outside a box needs an id: component cache "Cache"`);let g=new Map([[`load`,`number`]]);for(let e of i)e.args.id&&g.set(e.args.id.name,this.paramType(e));for(let e of o)this.fit(e);this.names={params:g,lets:this.lets,flows:new Set(f.keys()),stages:new Set(m.keys()),components:new Set(h.keys()),fits:this.fits,functions:this.functions};for(let e of a)e.args.id&&this.lets.set(e.args.id.name,`any`);for(let e=!0,t=0;e&&t<=a.length;t++){e=!1;for(let t of a){if(!t.args.id||!t.decl?.init)continue;let n=qt(t.decl.init,this.names,`ctx`,new gt(this.source)).type;n!==this.lets.get(t.args.id.name)&&(e=!0),this.lets.set(t.args.id.name,n)}}let _=new Map;for(let e of c)for(let t of e.stages)_.set(t.id,{block:t.block,box:e});let v=new Map(c.map(e=>[e.id,e])),y=r[0]&&this.load(r[0]),b={};for(let e of i)e.args.id&&(b[e.args.id.name]=this.param(e));let x={};for(let e of n(`preset`)){let t=this.text(e.args.label);t!=null&&(x[t]=this.preset(e,i))}let S={};for(let e of n(`scenario`)){let t=this.text(e.args.label);t!=null&&(Object.hasOwn(S,t)?this.report.error(e.args.label,`scenario "${t}" is declared twice`):S[t]=this.preset(e,i,`scenario`),this.symbols.push({kind:`scenario`,id:t,span:e.args.label,decl:e.decl??e.at}))}let C=[];for(let e of n(`expect`)){let t=this.expectation(e,S,h);t&&(C.push(t),this.expectSpans.push({from:e.at.from,to:e.args.label?.to??e.at.to}))}let w=[];for(let e of n(`step`)){let t=this.step(e,S,h,i,y);t&&w.push(t)}let T=n(`growth`);for(let e of T.slice(1))this.report.error(e.at,`only one growth line is allowed`);let E=T[0]&&this.growth(T[0]),D={};for(let e of a)e.args.id&&e.decl?.init&&(D[e.args.id.name]=Yt(e.decl.init,this.formula(e.decl.init,`ctx`).run));let O=(e,t)=>{if(_.has(e.name))return e.name;let n=v.get(e.name);if(n?.stages.length===1)return n.stages[0].id;n?this.report.error(e,n.stages.length?`"${e.name}" holds ${n.stages.length} stages; name one: ${n.stages.map(e=>e.id).join(`, `)}`:`the box "${e.name}" runs no stage`):this.report.error(e,`unknown ${t} "${e.name}"`,bt(e.name,[..._.keys(),...v.keys()]))},ee={},k={},A={},te=new Set;for(let e of s){let t=e.args.id;if(!t)continue;this.flowAt.set(t.name,t);let n=this.text(e.args.label),r={};n!=null&&(r.label=n);let i=this.constProp(e,`unit`);i!=null&&(r.unit=i),r.rate=this.dynProp(e,`rate`,`number`);let a=this.constProp(e,`priority`);a!=null&&(r.priority=a);let o=this.overload(e);o&&(r.overload=o);let s=this.retry(e);s&&(r.retry=s),ee[t.name]=r;let c=this.prop(e,`route`),l=[];for(let[e,t]of(c?.chain??(c?.value.t===`id`?[c.value]:[])).entries()){let n=O(t,`stage`);n&&(_.get(n).block.keyword===`fanout`&&e<(c?.chain?.length??1)-1&&this.report.error(t,`the fan-out "${n}" must be the last stage of the route`),l.push(n),te.add(n))}c&&c.value.t!==`id`&&this.report.error(c.value,`a route is a list of stages: a -> b -> c`),A[t.name]=l;let u=this.prop(e,`from`),d={from:``,color:`accent`};u&&(u.value.t===`id`&&v.has(u.value.name)?d.from=u.value.name:this.report.error(u.value,`unknown node "${this.slice(u.value)}"`,bt(this.slice(u.value),v.keys())));let f=this.prop(e,`color`);f&&(d.color=this.color(f.value)),n!=null&&(d.label=n),k[t.name]=d}let ne={};for(let e of c)e.component&&(ne[e.component.id]=this.component(e.component.block,e.block));for(let e of l)e.args.id&&(ne[e.args.id.name]=this.component(e));let re={};for(let e of c)for(let t of e.stages){let n=this.stage(t.block,e,h,O,f,te);n&&(re[t.id]=n)}for(let[e,t]of _)!te.has(e)&&t.block.keyword!==`fanout`&&this.report.warning(t.block.args.id??t.block.at,`no flow passes the stage "${e}"`);let ie=new Set(Object.values(re).map(e=>e.component));for(let[e,t]of Object.entries(ne))t.demand||ie.has(e)||this.plainBoxes.has(e)||this.report.error(h.get(e),`the component "${e}" needs "demand: …": no stage uses it`,Et.demand.doc);let ae={};for(let e of o){let t=e.args.id&&this.fits.get(e.args.id.name);t&&(ae[this.text(e.args.label)??e.args.id.name]=t)}let j={load:y,params:b,flows:ee,components:ne,stages:re,routes:A},oe=this.constProp(t,`title`);oe!=null&&(j.title=oe),Object.keys(x).length&&(j.presets=x),Object.keys(S).length&&(j.scenarios=S),E&&(j.growth=E),C.length&&(j.expect=C),w.length&&(j.story=w),Object.keys(D).length&&(j.derived=D),Object.keys(ae).length&&(j.calibration=ae);let se=n(`thresholds`)[0];if(se){let e={};for(let t of[`target`,`full`]){let n=this.constProp(se,t);n!=null&&(e[t]=n)}j.thresholds=e}let ce=this.constProp(t,`searchMax`);ce!=null&&(j.searchMax=ce);let le={};for(let e of c)le[e.id]=this.node(e);let ue=[];for(let e of t.edges)ue.push(...this.edges(e,v));s.length||this.report.error({from:0,to:0},`a definition needs at least one flow`);let de={assumptions:[]},fe=this.constProp(t,`speed`);fe!=null&&(de.speed=fe);let pe=this.constProp(t,`transition`);pe!=null&&(pe<0||pe>hn)?this.report.error(this.prop(t,`transition`).value,`transition is ${pe} seconds; 0 to ${hn}`):pe!=null&&(de.transition=pe);let me=this.prop(t,`layout`);me&&(de.direction=this.enumValue(me,Nt[``].props.layout)===`down`?`DOWN`:`RIGHT`);let he=this.prop(t,`fullScreen`);he&&(de.fullScreen=this.words(he,Nt[``].props.fullScreen));let M=this.prop(t,`fullScreenMode`);M&&(de.fullScreenMode=this.enumValue(M,Nt[``].props.fullScreenMode));for(let e of t.props.get(`assume`)??[]){let t=this.constant(e.value,`string`);typeof t==`string`&&de.assumptions.push(t)}if(!this.report.failed)return this.build(j,{nodes:le,edges:ue,flows:k},de,n(`preset`),n(`scenario`))}build(e,t,n,r,i){let a={from:0,to:0},o,s;try{o=de(e),s=ht(o,t)}catch(e){this.runError(e,a);return}let c=[{values:{},at:a}];for(let t of r){let n=this.text(t.args.label),r=n!=null&&e.presets?.[n];r&&c.push({values:r,at:t.at})}for(let e of i){let t=this.text(e.args.label),n=t!=null&&o.scenarios.find(e=>e.label===t)?.values;n&&c.push({values:n,at:e.at})}for(let[n,{values:r,at:i}]of c.entries())try{let n=o.evaluate(r);et(s,n);for(let t of Object.keys(e.derived??{}))n.ctx.derived[t];for(let e of Object.values(t.nodes)){if(e.kind===`cluster`){let t=typeof e.members==`function`?e.members(n.ctx):e.members;e.memberLabel?.(Math.max(0,t-1))}e.kind===`pool`&&e.podLabel?.(0)}for(let e of t.edges)e.when?.(n.ctx);for(let e of o.flowIds)Number.isFinite(n.flows[e])||this.report.warning(this.flowRate.get(e)??i,`the rate of "${e}" is ${n.flows[e]} here`)}catch(e){this.runError(e,i,n===0)}if(!this.report.failed)return{model:o,view:s,options:n}}runError(e,t,n=!0){if(e instanceof Lt)return this.report.error(e.span,e.message,e.hint);let r=w(e),{message:i,hint:a}=zt(e,r?`the flow "${r}"`:`the model`);this.report.error(n&&r&&this.flowAt.get(r)||t,i,a)}flowRate=new Map;flowAt=new Map;plainBoxes=new Set;shape(e,t,n,r,i){let a={keyword:e,spec:t,at:r,decl:i,args:{},props:new Map,children:[],edges:[],rows:[]};i&&this.args(a,i);let o=e?`in ${e}`:`at the top`;for(let e of n)if(e.kind===`prop`){let n=e.key.name;if(!t.open&&!St(t.props,n)){let r=t.children.includes(n)?`write it as a block: ${n} { … }`:bt(n,[...Object.keys(t.props),...t.children]);this.report.error(e.key,`unknown property "${n}" ${o}`,r);continue}let r=a.props.get(n)??[];r.length&&!(St(t.props,n)?.repeat??!1)&&this.report.error(e.key,`"${n}" is set twice ${o}`,`remove one of them`),r.push(e),a.props.set(n,r)}else if(e.kind===`decl`){let n=e.keyword.name,r=St(Nt,n);if(!t.children.includes(n)||!r||n===``){St(t.props,n)?this.report.error(e.keyword,`"${n}" is a property: write "${n}: …"`):r?this.report.error(e.keyword,`"${n}" cannot go ${o}`,wn(n)):this.report.error(e.keyword,`unknown statement "${n}" ${o}`,bt(n,[...t.children,...Object.keys(t.props)]));continue}a.children.push(this.shape(n,r,e.body??[],e.keyword,e))}else e.kind===`edge`?t.edges?a.edges.push(e):this.report.error(e.chain[0],`an "a -> b" line cannot go ${o}`):t.rows?a.rows.push(e):this.report.error(e,`a row of numbers can only go in "points"`);if(i)for(let[n,i]of Object.entries(t.props))i.required&&!a.props.has(n)&&this.report.error(r,`"${e}" needs "${n}: …"`,i.doc);return a}args(e,t){let{filled:n,bad:r,missing:i}=Ct(e.spec.args,t.args);for(let t of r)this.report.error(t,`unexpected ${this.slice(t)} after "${e.keyword}"`,Cn(e.keyword));for(let[t,r]of n)r.t===`tpl`&&!t.dynamic&&!r.parts.length?e.args[t.name]={t:`str`,value:r.quasis[0],from:r.from,to:r.to}:(r.t===`tpl`&&!t.dynamic&&this.report.error(r,`the ${t.name} of "${e.keyword}" must be a plain text`),r.t===`id`?e.args[t.name]={name:r.name,from:r.from,to:r.to}:e.args[t.name]=r);i&&this.report.error(e.at,`"${e.keyword}" needs its ${i.name}`,Cn(e.keyword)),e.spec.init&&!t.init&&this.report.error(e.at,`"${e.keyword}" needs "= formula"`,Cn(e.keyword)),!e.spec.init&&t.init&&this.report.error(t.init,`"${e.keyword}" takes no "="`)}header(e){let t=e[0],n=e=>e?.kind===`decl`&&e.keyword.name===`loadmap`;if(!n(t))throw this.report.error(t??{from:0,to:0},`a definition starts with "loadmap 1"`,`add "loadmap 1" as the first line`),new yn;for(let t of e.slice(1))n(t)&&this.report.error(t.keyword,`the "loadmap" line must be the first and only one`);let r=t.args[0];if(r?.t===`num`&&r.value!==1)throw this.report.error(r,r.value>1?`this definition is written in language version ${r.value}; this loadmap reads version 1`:`there is no language version ${r.value}; the first is 1`,r.value>1?`update @loadmap/dsl`:void 0),new yn}declare(e,t,n,r,i,a){xn.has(t)&&this.report.error(n,`"${t}" cannot be used as a name`),i.has(t)?this.report.error(n,`"${t}" is declared twice`,`rename one of them`):i.set(t,n),this.symbols.push({kind:e,id:t,span:n,decl:r.decl??r.at,detail:a})}box(e){let t=e.args.id.name,n=e.children.filter(e=>It.includes(e.keyword)),r=n.map(e=>({block:e,id:e.args.id?.name??t})),i=Object.keys(Et).some(t=>e.props.has(t)),a=e.children.filter(e=>e.keyword===`component`),o;i&&(o={block:e,id:t,own:!0});for(let e of a)o?this.report.error(e.at,`"${t}" already has a component`,`one component per box; put others at the top`):o={block:e,id:e.args.id?.name??t,own:!1};e.keyword===`node`&&r.length>1&&this.report.error(n[1].at,`a node runs at most one stage; a cluster can hold several queues`),e.keyword===`cluster`&&!r.length&&this.report.error(e.at,`a cluster needs a queue`,`queue topic { partitions { orders: 12 } }`),e.keyword===`pool`&&r.length!==1&&this.report.error(e.at,`a pool needs exactly one workers stage`,`workers { pods: 3; perPod: 8 }`);let s=new Set;for(let e of r)s.has(e.id)&&this.report.error(e.block.at,`"${t}" has two stages called "${e.id}"`,`give each an id`),s.add(e.id);return{block:e,id:t,stages:r,component:o}}plainBox(e){let[t,n]=Object.keys(Et).flatMap(t=>e.props.has(t)?[[t,this.prop(e,t)]]:[]).sort((e,t)=>e[1].key.from-t[1].key.from)[0],r=`give the box capacity and over lines, or drop it`,i=e.args.sub,a=(!i||i.t===`str`&&i.value===``)&&!e.props.has(`sub`);t===`describe`&&n.value.t===`str`&&a&&(r=e.args.label?`for a line under a plain box, put it on the first line: ${e.keyword} ${e.args.id.name} ${this.slice(e.args.label)} ${this.slice(n.value)}`:`for a line under a plain box, write sub: ${this.slice(n.value)}`),this.report.error(n.key,`"${t}" belongs to a component, and this box has no capacity`,r)}slice(e){return this.source.slice(e.from,e.to)}prop(e,t){return e.props.get(t)?.[0]}formula(e,t,n){let r=qt(e,this.names,t,this.report);if(n&&n!==`any`&&r.type!==n&&r.type!==`any`){if(n===`string`&&r.type===`number`){let e=r.run;return{...r,type:`string`,run:(t,n)=>String(e(t,n))}}n===`capacity`&&r.type===`number`?this.report.error(e,`a capacity says where it came from`,`write measured(${this.slice(e)}, "unit", "source") or estimated(…)`):this.report.error(e,`expected ${Kt(n)}, this is ${Kt(r.type)}`)}return r}constant(e,t){let n=this.formula(e,`const`,t);try{return n.run(void 0)}catch(t){let{message:n,hint:r}=zt(t);this.report.error(e,n,r);return}}constProp(e,t){let n=this.prop(e,t);if(!n)return;let r=e.spec.props[t];return r.value===`enum`?this.enumValue(n,r):this.constant(n.value,r.value)}dyn(e,t,n=`ctx`,r){let i=this.formula(e,n,t);if(i.constant){let n=this.constant(e,t);try{n!==void 0&&r?.(n)}catch(t){this.report.error(e,t.message)}return n}let a=i.run;return r?Yt(e,(e,t)=>{let n=a(e,t);return r(n),n}):Yt(e,a)}dynProp(e,t,n,r){let i=this.prop(e,t);if(i)return t===`rate`&&e.args.id&&this.flowRate.set(e.args.id.name,i.value),this.dyn(i.value,n,St(e.spec.props,t)?.scope??`ctx`,r)}text(e){if(!e)return;let t=this.constant(e,`string`);return typeof t==`string`?t:void 0}label(e){if(e)return this.dyn(e,`string`)}enumValue(e,t){let n=e.value.t===`str`?e.value.value:this.slice(e.value).replace(/\s+/g,``);if(t.values?.includes(n))return n;this.report.error(e.value,`"${n}" is not one of ${t.values.join(`, `)}`,bt(n,t.values??[]))}words(e,t){let n=t.values??[];if(e.value.t!==`array`){this.report.error(e.value,`a list: [${n.slice(0,2).join(`, `)}]`);return}let r=[];for(let t of e.value.items){let e=t.t===`str`?t.value:t.t===`id`?t.name:this.slice(t);n.includes(e)?r.push(e):this.report.error(t,`"${e}" is not one of ${n.join(`, `)}`,bt(e,n))}return r}color(e){if(e.t===`id`){if(Mt.includes(e.name))return e.name;this.report.error(e,`"${e.name}" is not a theme colour`,bt(e.name,Mt)??`or quote a CSS colour`)}else if(e.t===`str`){if(Sn.test(e.value.trim()))return e.value.trim();this.report.error(e,`"${e.value}" is not a colour`,`use #rrggbb, rgb(…), hsl(…) or a theme colour`)}else this.report.error(e,`a colour is a theme colour or a CSS colour in quotes`);return`accent`}count(e){let t=gn[e];return n=>{if(typeof n!=`number`||!Number.isInteger(n)||n<0)throw Error(`${e} must be a whole number of at least 0, not ${String(n)}`);if(n>t)throw Error(`${e} is ${n}; at most ${t}`)}}load(e){let t={},n=this.text(e.args.label);n!=null&&(t.label=n);for(let n of[`min`,`max`,`step`,`default`]){let r=this.constProp(e,n);r!=null&&(t[n]=r)}return typeof t.max!=`number`&&(t.max=1),E.load(t)}paramType(e){let t=this.prop(e,`options`);if(t?.value.t===`array`)return t.value.items[0]?.t===`str`?`string`:`number`;if(e.props.has(`min`)||e.props.has(`max`))return`number`;let n=this.prop(e,`default`)?.value;return n?.t===`bool`?`boolean`:n?.t===`str`?`string`:n?.t===`num`?`number`:`any`}param(e){let t={label:this.text(e.args.label)??e.args.id.name};for(let n of[`hint`,`tag`]){let r=this.constProp(e,n);r!=null&&(t[n]=r)}let n=this.prop(e,`enabled`);n&&(t.enabled=Yt(n.value,this.formula(n.value,`values`).run));let r=this.prop(e,`format`);if(r){let e=Yt(r.value,this.formula(r.value,`value`,`string`).run);t.format=t=>e(void 0,t)}let i=this.prop(e,`default`);if(!i)return;let a=this.constant(i.value,`any`),o=this.prop(e,`options`);if(o){for(let t of[`min`,`max`,`step`])e.props.has(t)&&this.report.error(this.prop(e,t).key,`"${t}" is for a slider; this param has options`);let n=this.options(o);if(!n)return;if(!n.includes(a)){this.report.error(i.value,`the default ${this.slice(i.value)} is not one of the options`,n.join(`, `));return}return E.select({...t,options:n,default:a})}if(e.props.has(`min`)||e.props.has(`max`)){for(let t of[`min`,`max`])e.props.has(t)||this.report.error(e.at,`a slider needs "${t}: …"`);let n={...t};for(let t of[`min`,`max`,`step`]){let r=this.constProp(e,t);r!=null&&(n[t]=r)}return typeof a!=`number`&&this.report.error(i.value,`the default of a slider is a number`),E.range({...n,default:a})}if(typeof a==`boolean`)return E.switch({...t,default:a});this.report.error(e.at,`"${e.args.id.name}" is neither a select, a slider nor a switch`,`give it options: [...], min and max, or a default of true or false`)}options(e){if(e.value.t!==`array`||!e.value.items.length){this.report.error(e.value,`options are a list: [2, 3, 4] or ["a", "b"]`);return}let t=e.value.items.map(e=>this.constant(e,`any`)),n=typeof t[0];if(!t.every(e=>(typeof e==`number`||typeof e==`string`)&&typeof e===n))this.report.error(e.value,`options are all numbers or all texts`);else return t}preset(e,t,n=`preset`){let r={},i=new Map(t.filter(e=>e.args.id).map(e=>[e.args.id.name,e]));for(let[t,a]of e.props){if(St(e.spec.props,t))continue;let o=a[0],s=this.constant(o.value,`any`);if(t===`load`&&n===`scenario`){this.report.error(o.key,`a scenario leaves the load to the slider`,`use a preset for a load`);continue}if(t!==`load`&&!i.has(t)){let e=[...n===`preset`?[`load`]:[],...i.keys()];this.report.error(o.key,`unknown parameter "${t}"`,bt(t,e));continue}let c=this.names.params.get(t);if(c&&c!==`any`&&typeof s!==c){this.report.error(o.value,`"${t}" takes ${Kt(c)}`);continue}let l=i.get(t)&&this.prop(i.get(t),`options`);if(l?.value.t===`array`){let e=l.value.items.map(e=>e.t===`num`||e.t===`str`?e.value:void 0);e.includes(s)||this.report.error(o.value,`${String(s)} is not an option of "${t}"`,e.join(`, `))}r[t]=s}return r}expectation(e,t,n){let r={},i=this.text(e.args.label);i!=null&&(r.label=i);let a=this.named(e,`scenario`,Object.keys(t),`scenario`),o=this.named(e,`component`,[...n.keys()],`component`);if(a!==null&&o!==null){a!=null&&(r.scenario=a),o!=null&&(r.component=o);for(let t of[`target`,`full`]){let n=this.constProp(e,t);n!=null&&(n>0&&Number.isFinite(n)?r[t]=n:this.report.error(this.prop(e,t).value,`${t} is a load multiple above 0`))}if(!e.props.has(`target`)&&!e.props.has(`full`))this.report.error(e.at,`an expect needs a target or a full multiple`,`expect { target: 8 }`);else return r.target!=null||r.full!=null?r:void 0}}named(e,t,n,r){let i=this.prop(e,t);if(!i)return;let a=i.value.t===`id`?i.value.name:i.value.t===`str`?i.value.value:void 0;if(a==null)this.report.error(i.value,`${t} is the name of a ${r}`);else if(!n.includes(a))this.report.error(i.value,`unknown ${r} "${a}"`,bt(a,n));else return a;return null}step(e,t,n,r,i){let a=this.text(e.args.label);for(let t of Object.keys(e.spec.props)){let n=e.props.get(t)?.[0];n&&r.some(e=>e.args.id?.name===t)&&this.report.error(n.key,`"${t}" in a step is the step's own ${t}, not the parameter "${t}"`,`rename the parameter to set it in a step`)}let o=this.named(e,`scenario`,Object.keys(t),`scenario`),s=this.named(e,`focus`,[...n.keys()],`component`),c=this.constProp(e,`title`);c!=null&&!c.trim()&&this.report.error(this.prop(e,`title`).value,`a title needs a few words`);let l=this.constProp(e,`seconds`);l!=null&&!(l>0&&Number.isFinite(l))&&this.report.error(this.prop(e,`seconds`).value,`seconds is a duration above 0`);let u=this.preset(e,r),d=this.prop(e,`load`);if(d&&i&&typeof u.load==`number`&&!(u.load>=i.min&&u.load<=i.max)&&this.report.error(d.value,`the load goes from ${i.min} to ${i.max}`),a!=null&&o!==null&&s!==null)return{text:a,...c?.trim()?{title:c}:{},...o==null?{}:{scenario:o},...s==null?{}:{focus:s},...l!=null&&l>0?{seconds:l}:{},...Object.keys(u).length?{set:u}:{}}}growth(e){let t=this.constProp(e,`rate`),n=this.constProp(e,`per`),r=this.constProp(e,`asOf`);if(t!=null&&!(t>0)&&this.report.error(this.prop(e,`rate`).value,`growth needs a rate above 0`),r!=null&&!b(r)&&this.report.error(this.prop(e,`asOf`).value,`"${r}" is not a date`,`a day like "2026-11-01"`),t!=null&&n!=null&&r!=null)return{rate:t,per:n,asOf:r}}fit(e){let t=e.args.id;if(!t)return;this.fits.set(t.name,null);let n=e.children.filter(e=>e.keyword===`points`);if(n.length!==1){this.report.error(e.at,n.length?`a fit has one points block`:`a fit needs its points`,Cn(`points`));return}let r=n[0],{x:i,y:a}=r.args;if(!i||!a)return;i.name===a.name&&this.report.error(a,`x and y need different names`);let o=[];for(let e of r.rows){if(e.values.length!==2){this.report.error(e,`a row is two numbers: ${i.name} and ${a.name}`);continue}let[t,n]=e.values.map(e=>this.constant(e,`number`));o.push({[i.name]:t,[a.name]:n})}let s=this.constProp(e,`source`),c=this.constProp(e,`through`);try{let e={x:i.name,y:a.name};s!=null&&(e.source=s),c&&(e.through=c),this.fits.set(t.name,we(o,e))}catch(e){this.report.error(r.at,e.message.replace(/^loadmap: /,``))}}overload(e){let t=e.children.filter(e=>e.keyword===`drop`||e.keyword===`merge`);if(!t.length)return;let n=new Set,r=[],i={drop:[`olderThan`,`reason`],merge:[`share`,`reason`]};for(let e of t){let t=e.keyword;n.has(t)&&this.report.error(e.at,`"${t}" is set twice in this flow`),n.add(t);let a=[];for(let n of i[t]){let t=this.dynProp(e,n,n===`reason`?`string`:`number`);t!==void 0&&a.push([n,t])}let o=this.prop(e,`when`);r.push({key:t,fields:a,when:o&&Yt(o.value,this.formula(o.value,`ctx`).run)})}let a=r.every(e=>!e.when&&e.fields.every(([,e])=>typeof e!=`function`)),o=e=>{let t={};for(let n of r){if(n.when&&!n.when(e))continue;let r={};for(let[t,i]of n.fields)r[t]=typeof i==`function`?i(e):i;t[n.key]=r}return t};return a?o(void 0):o}retry(e){let t=e.children.filter(e=>e.keyword===`retry`);if(!t.length)return;t.length>1&&this.report.error(t[1].at,`"retry" is set twice in this flow`);let n=t[0],r=this.dynProp(n,`times`,`number`),i=this.dynProp(n,`budget`,`number`),a=this.prop(n,`when`),o=a&&Yt(a.value,this.formula(a.value,`values`).run),s=e=>{if(o&&!o(e))return;let t={times:(typeof r==`function`?r(e):r)??0};return i!==void 0&&(t.budget=typeof i==`function`?i(e):i),t};return!o&&typeof r!=`function`&&typeof i!=`function`?s(void 0):s}component(e,t){let n={},r=this.constProp(e,`name`)??this.text(e.args.label)??this.text(t?.args.label);if(r==null){let n=t?.args.label??e.args.label;n&&this.report.error(n,`a computed label cannot name the component`,`add name: "…"`)}n.name=r??(e.args.id??t?.args.id)?.name;for(let t of[`short`,`plural`]){let r=this.constProp(e,t);r!=null&&(n[t]=r)}for(let[t,r]of[[`demand`,`number`],[`capacity`,`capacity`],[`when`,`any`],[`over`,`string`],[`describe`,`string`]]){let i=this.prop(e,t);if(!i)continue;let a=t===`capacity`?e=>{if(!Xt(e))throw Error(`a capacity comes from measured(…), estimated(…) or configured(…)`)}:void 0;n[t]=this.dyn(i.value,r,`ctx`,a)}let i=t?t.args.id??t.at:e.at,a=[`capacity`,`over`].filter(e=>!(e in n)),o=e.children.some(e=>e.keyword===`component`);if(e===t&&!o&&a.length===2&&!(`demand`in n))return this.plainBoxes.add(e.args.id.name),this.plainBox(e),n;for(let e of a)this.report.error(i,`the component needs "${e}: …"`,Et[e].doc);return n}stage(e,t,n,r,i,a){let o=this.text(e.args.label),s=o==null?{}:{label:o},c=t.component?.id,l=this.prop(e,`component`);if(l){let e=l.value;e.t===`id`&&n.has(e.name)?c=e.name:this.report.error(e,`unknown component "${this.slice(e)}"`,bt(this.slice(e),n.keys()))}let u=()=>{this.report.error(e.at,`a ${e.keyword} stage needs a component`,`give the box demand and capacity lines, or name one: component: db`)};switch(e.keyword){case`pass`:return c?O(c,s):u();case`limit`:return c?te(c,s):u();case`cache`:{let t=this.dynProp(e,`hit`,`number`);return A({...s,hit:t??0,...c?{component:c}:{}})}case`store`:return c?ne(c,s):u();case`sink`:return re(s);case`workers`:{if(!c)return u();let t=this.dynProp(e,`perPod`,`number`,this.count(`perPod`)),n=this.constProp(e,`fill`),r={...s,perPod:t??0,...n?{fill:n}:{}},i=e.children.find(e=>e.keyword===`autoscale`);if(i){this.prop(e,`pods`)&&this.report.error(this.prop(e,`pods`).key,`an autoscaled pool has no fixed pods`,`leave out pods`);let t=this.dynProp(i,`min`,`number`)??1,n=this.dynProp(i,`max`,`number`,this.count(`pods`))??1,a=this.dynProp(i,`target`,`number`)??1;return k(c,{...r,autoscale:{min:t,max:n,target:a}})}let a=this.dynProp(e,`pods`,`number`,this.count(`pods`));return this.prop(e,`pods`)||this.report.error(e.at,`a workers stage needs pods, or autoscale`,`pods: 3, or autoscale { min: 2; max: 10; target: 0.7 }`),k(c,{...r,pods:a??0})}case`queue`:{let t=e.children.find(e=>e.keyword===`partitions`);if(!t){this.report.error(e.at,`a queue needs its partitions`,`partitions { orders: 12 }`);return}let n=[];for(let[e,r]of t.props){let t=r[0];i.has(e)?n.push([e,this.dyn(t.value,`number`,`ctx`,this.count(`partitions`))]):this.report.error(t.key,`unknown flow "${e}"`,bt(e,i.keys()))}let r=n.every(([,e])=>typeof e==`number`),a=e=>Object.fromEntries(n.map(([t,n])=>[t,typeof n==`function`?n(e):n])),o=r?a(void 0):a;return ee({...s,partitions:o,...c?{component:c}:{}})}case`fanout`:{let t=[];for(let n of e.edges){if(n.chain.length!==2){this.report.error(n,`a branch is one "flow -> stage: copies" line`);continue}let[e,o]=n.chain;i.has(e.name)||this.report.error(e,`unknown flow "${e.name}"`,bt(e.name,i.keys()));let s=r(o,`stage`);s&&a.add(s),n.colon?this.report.error(n.colon,`a branch takes its copies after ":", not a block`,`${e.name} -> ${o.name}: 1`):(n.value||this.report.error(n,`how many copies per unit?`,`${e.name} -> ${o.name}: 1`),n.body&&this.report.error(n.bodySpan??n,`a branch has no block`),s&&n.value&&i.has(e.name)&&t.push([e.name,s,this.dyn(n.value,`number`)]))}let n=e=>{let n={};for(let[r,i,a]of t){let t=n[r]??[];t.push({stage:i,share:typeof a==`function`?a(e):a}),n[r]=t}return n},o=t.every(([,,e])=>typeof e==`number`);return ie({...s,to:o?n(void 0):n,...c?{component:c}:{}})}}}node(e){let t=e.block,n=this.label(t.args.label)??e.id,r=this.prop(t,`sub`);r&&t.args.sub&&this.report.error(r.key,`the sub-line is set twice: on the first line and here`);let i=this.label(t.args.sub??r?.value),a={label:n};i!=null&&(a.sub=i);let o=e=>{let n=this.prop(t,e);if(!n)return;let r=Yt(n.value,this.formula(n.value,`i`,`string`).run);return e=>r(void 0,e)},s=e.stages.map(e=>e.id);if(t.keyword===`cluster`){a.stage=s.length===1?s[0]:s;let e=this.prop(t,`members`);a.members=e?this.dyn(e.value,`number`,`ctx`,this.count(`members`)):1;let n=o(`memberLabel`);return n&&(a.memberLabel=n),{kind:`cluster`,...a}}if(t.keyword===`pool`){a.stage=s[0];let e=o(`podLabel`);return e&&(a.podLabel=e),{kind:`pool`,...a}}return s.length?a.stage=s[0]:e.component&&(a.component=e.component.id),{kind:`node`,shape:this.constProp(t,`shape`)??`box`,...a}}edges(e,t){e.colon&&this.report.error(e.colon,`drop the ":" before a { … } block`,`${e.chain.map(e=>e.name).join(` -> `)} { ${e.chain.length>2?``:`label: …; `}when: … }`);for(let n of e.chain)t.has(n.name)||this.report.error(n,`unknown node "${n.name}"`,bt(n.name,t.keys()));let n=new Map;for(let t of e.body??[])if(t.kind!==`prop`||!St(Pt,t.key.name)){let e=t.kind===`prop`?t.key:t.kind===`decl`?t.keyword:t;this.report.error(e,`an edge holds only label and when`,bt(this.slice(e),Object.keys(Pt)))}else n.has(t.key.name)&&this.report.error(t.key,`"${t.key.name}" is set twice on this edge`),n.set(t.key.name,t);let r=e.value??n.get(`label`)?.value;e.value&&n.has(`label`)&&this.report.error(n.get(`label`).key,`the label is set twice`),r&&e.chain.length>2&&this.report.error(r,`a label goes on a single edge: a -> b: "…"`);let i=this.label(r),a=n.get(`when`),o=[];for(let t=0;t+1<e.chain.length;t++){let n={from:e.chain[t].name,to:e.chain[t+1].name};i!=null&&(n.label=i),a&&(n.when=Yt(a.value,this.formula(a.value,`ctx`).run)),o.push(n)}return o}},xn=new Set([...Object.getOwnPropertyNames(Object.prototype),`prototype`]),Sn=/^(#[0-9a-f]{3,8}|(rgb|hsl)a?\([\d\s.,%/+-]+\))$/i;function Cn(e){let t=St(Nt,e)?.example;return t?`e.g. ${t.split(`
|
|
16
|
-
`)[0]}`:void 0}function wn(e){let t=Object.entries(Nt).filter(([,t])=>t.children.includes(e)).map(([e])=>e===``?`the top level`:e);return t.length?`it goes in ${t.join(` or `)}`:void 0}var Tn=t((e=>{var t=Object.defineProperty;(e=>t(e,`__esModule`,{value:!0}))(e),((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(e,{GIFEncoder:()=>k,applyPalette:()=>S,default:()=>ce,nearestColor:()=>ee,nearestColorIndex:()=>D,nearestColorIndexWithDistance:()=>O,prequantize:()=>x,quantize:()=>_,snapColorsToPalette:()=>T});var n={signature:`GIF`,version:`89a`,trailer:59,extensionIntroducer:33,applicationExtensionLabel:255,graphicControlExtensionLabel:249,imageSeparator:44,signatureSize:3,versionSize:3,globalColorTableFlagMask:128,colorResolutionMask:112,sortFlagMask:8,globalColorTableSizeMask:7,applicationIdentifierSize:8,applicationAuthCodeSize:3,disposalMethodMask:28,userInputFlagMask:2,transparentColorFlagMask:1,localColorTableFlagMask:128,interlaceFlagMask:64,idSortFlagMask:32,localColorTableSizeMask:7};function r(e=256){let t=0,n=new Uint8Array(e);return{get buffer(){return n.buffer},reset(){t=0},bytesView(){return n.subarray(0,t)},bytes(){return n.slice(0,t)},writeByte(e){r(t+1),n[t]=e,t++},writeBytes(e,i=0,a=e.length){r(t+a);for(let r=0;r<a;r++)n[t++]=e[r+i]},writeBytesView(e,i=0,a=e.byteLength){r(t+a),n.set(e.subarray(i,i+a),t),t+=a}};function r(e){var r=n.length;if(r>=e)return;e=Math.max(e,r*(r<1048576?2:1.125)>>>0),r!=0&&(e=Math.max(e,256));let i=n;n=new Uint8Array(e),t>0&&n.set(i.subarray(0,t),0)}}var i=12,a=5003,o=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function s(e,t,n,s,c=r(512),l=new Uint8Array(256),u=new Int32Array(a),d=new Int32Array(a)){let f=u.length,p=Math.max(2,s);l.fill(0),d.fill(0),u.fill(-1);let m=0,h=0,g=p+1,_=g,v=!1,y=_,b=(1<<y)-1,x=1<<g-1,S=x+1,C=x+2,w=0,T=n[0],E=0;for(let e=f;e<65536;e*=2)++E;E=8-E,c.writeByte(p),O(x);let D=n.length;for(let e=1;e<D;e++)next_block:{let t=n[e],r=(t<<i)+T,a=t<<E^T;if(u[a]===r){T=d[a];break next_block}let o=a===0?1:f-a;for(;u[a]>=0;)if(a-=o,a<0&&(a+=f),u[a]===r){T=d[a];break next_block}O(T),T=t,C<1<<i?(d[a]=C++,u[a]=r):(u.fill(-1),C=x+2,v=!0,O(x))}return O(T),O(S),c.writeByte(0),c.bytesView();function O(e){for(m&=o[h],h>0?m|=e<<h:m=e,h+=y;h>=8;)l[w++]=m&255,w>=254&&(c.writeByte(w),c.writeBytesView(l,0,w),w=0),m>>=8,h-=8;if((C>b||v)&&(v?(y=_,b=(1<<y)-1,v=!1):(++y,b=y===i?1<<y:(1<<y)-1)),e==S){for(;h>0;)l[w++]=m&255,w>=254&&(c.writeByte(w),c.writeBytesView(l,0,w),w=0),m>>=8,h-=8;w>0&&(c.writeByte(w),c.writeBytesView(l,0,w),w=0)}}}var c=s;function l(e,t,n){return e<<8&63488|t<<2&992|n>>3}function u(e,t,n,r){return e>>4|t&240|(n&240)<<4|(r&240)<<8}function d(e,t,n){return e>>4<<8|t&240|n>>4}function f(e,t,n){return e<t?t:e>n?n:e}function p(e){return e*e}function m(e,t,n){var r=0,i=1e100;let a=e[t],o=a.cnt,s=a.ac,c=a.rc,l=a.gc,u=a.bc;for(var d=a.fw;d!=0;d=e[d].fw){let t=e[d],a=t.cnt,m=o*a/(o+a);if(!(m>=i)){var f=0;n&&(f+=m*p(t.ac-s),f>=i)||(f+=m*p(t.rc-c),f>=i||(f+=m*p(t.gc-l),f>=i||(f+=m*p(t.bc-u),f>=i||(i=f,r=d))))}}a.err=i,a.nn=r}function h(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}function g(e,t){let n=Array(t===`rgb444`?4096:65536),r=e.length;if(t===`rgba4444`)for(let t=0;t<r;++t){let r=e[t],i=r>>24&255,a=r>>16&255,o=r>>8&255,s=r&255,c=u(s,o,a,i),l=c in n?n[c]:n[c]=h();l.rc+=s,l.gc+=o,l.bc+=a,l.ac+=i,l.cnt++}else if(t===`rgb444`)for(let t=0;t<r;++t){let r=e[t],i=r>>16&255,a=r>>8&255,o=r&255,s=d(o,a,i),c=s in n?n[s]:n[s]=h();c.rc+=o,c.gc+=a,c.bc+=i,c.cnt++}else for(let t=0;t<r;++t){let r=e[t],i=r>>16&255,a=r>>8&255,o=r&255,s=l(o,a,i),c=s in n?n[s]:n[s]=h();c.rc+=o,c.gc+=a,c.bc+=i,c.cnt++}return n}function _(e,t,n={}){let{format:r=`rgb565`,clearAlpha:i=!0,clearAlphaColor:a=0,clearAlphaThreshold:o=0,oneBitAlpha:s=!1}=n;if(!e||!e.buffer||!(e instanceof Uint8Array)&&!(e instanceof Uint8ClampedArray))throw Error(`quantize() expected RGBA Uint8Array data`);let c=new Uint32Array(e.buffer),l=n.useSqrt!==!1,u=r===`rgba4444`,d=g(c,r),h=d.length,_=h-1,y=new Uint32Array(h+1);for(var b=0,x=0;x<h;++x){let e=d[x];if(e!=null){var S=1/e.cnt;u&&(e.ac*=S),e.rc*=S,e.gc*=S,e.bc*=S,d[b++]=e}}p(t)/b<.022&&(l=!1);for(var x=0;x<b-1;++x)d[x].fw=x+1,d[x+1].bk=x,l&&(d[x].cnt=Math.sqrt(d[x].cnt));l&&(d[x].cnt=Math.sqrt(d[x].cnt));var C,w,T;for(x=0;x<b;++x){m(d,x,!1);var E=d[x].err;for(w=++y[0];w>1&&(T=w>>1,!(d[C=y[T]].err<=E));w=T)y[w]=C;y[w]=x}var D=b-t;for(x=0;x<D;){for(var O;;){var ee=y[1];if(O=d[ee],O.tm>=O.mtm&&d[O.nn].mtm<=O.tm)break;O.mtm==_?ee=y[1]=y[y[0]--]:(m(d,ee,!1),O.tm=x);var E=d[ee].err;for(w=1;(T=w+w)<=y[0]&&(T<y[0]&&d[y[T]].err>d[y[T+1]].err&&T++,!(E<=d[C=y[T]].err));w=T)y[w]=C;y[w]=ee}var k=d[O.nn],A=O.cnt,te=k.cnt,S=1/(A+te);u&&(O.ac=S*(A*O.ac+te*k.ac)),O.rc=S*(A*O.rc+te*k.rc),O.gc=S*(A*O.gc+te*k.gc),O.bc=S*(A*O.bc+te*k.bc),O.cnt+=k.cnt,O.mtm=++x,d[k.bk].fw=k.fw,d[k.fw].bk=k.bk,k.mtm=_}let ne=[];var re=0;for(x=0;;++re){let e=f(Math.round(d[x].rc),0,255),t=f(Math.round(d[x].gc),0,255),n=f(Math.round(d[x].bc),0,255),r=255;u&&(r=f(Math.round(d[x].ac),0,255),s&&(r=r<=(typeof s==`number`?s:127)?0:255),i&&r<=o&&(e=t=n=a,r=0));let c=u?[e,t,n,r]:[e,t,n];if(v(ne,c)||ne.push(c),(x=d[x].fw)==0)break}return ne}function v(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2],a=r.length>=4&&t.length>=4?r[3]===t[3]:!0;if(i&&a)return!0}return!1}function y(e,t){for(var n=0,r=0;r<e.length;r++){let i=e[r]-t[r];n+=i*i}return n}function b(e,t){return t>1?Math.round(e/t)*t:e}function x(e,{roundRGB:t=5,roundAlpha:n=10,oneBitAlpha:r=null}={}){let i=new Uint32Array(e.buffer);for(let e=0;e<i.length;e++){let a=i[e],o=a>>24&255,s=a>>16&255,c=a>>8&255,l=a&255;o=b(o,n),r&&(o=o<=(typeof r==`number`?r:127)?0:255),l=b(l,t),c=b(c,t),s=b(s,t),i[e]=o<<24|s<<16|c<<8|l}}function S(e,t,n=`rgb565`){if(!e||!e.buffer||!(e instanceof Uint8Array)&&!(e instanceof Uint8ClampedArray))throw Error(`quantize() expected RGBA Uint8Array data`);if(t.length>256)throw Error(`applyPalette() only works with 256 colors or less`);let r=new Uint32Array(e.buffer),i=r.length,a=n===`rgb444`?4096:65536,o=new Uint8Array(i),s=Array(a);if(n===`rgba4444`)for(let e=0;e<i;e++){let n=r[e],i=n>>24&255,a=n>>16&255,c=n>>8&255,l=n&255,d=u(l,c,a,i),f=d in s?s[d]:s[d]=C(l,c,a,i,t);o[e]=f}else{let e=n===`rgb444`?d:l;for(let n=0;n<i;n++){let i=r[n],a=i>>16&255,c=i>>8&255,l=i&255,u=e(l,c,a),d=u in s?s[u]:s[u]=w(l,c,a,t);o[n]=d}}return o}function C(e,t,n,r,i){let a=0,o=1e100;for(let s=0;s<i.length;s++){let c=i[s],l=c[3],u=E(l-r);if(u>o)continue;let d=c[0];if(u+=E(d-e),u>o)continue;let f=c[1];if(u+=E(f-t),u>o)continue;let p=c[2];u+=E(p-n),u>o||(o=u,a=s)}return a}function w(e,t,n,r){let i=0,a=1e100;for(let o=0;o<r.length;o++){let s=r[o],c=s[0],l=E(c-e);if(l>a)continue;let u=s[1];if(l+=E(u-t),l>a)continue;let d=s[2];l+=E(d-n),l>a||(a=l,i=o)}return i}function T(e,t,n=5){if(!e.length||!t.length)return;let r=e.map(e=>e.slice(0,3)),i=n*n,a=e[0].length;for(let n=0;n<t.length;n++){let o=t[n];o=o.length<a?[o[0],o[1],o[2],255]:o.length>a?o.slice(0,3):o.slice();let s=O(r,o.slice(0,3),y),c=s[0],l=s[1];l>0&&l<=i&&(e[c]=o)}}function E(e){return e*e}function D(e,t,n=y){let r=1/0,i=-1;for(let a=0;a<e.length;a++){let o=e[a],s=n(t,o);s<r&&(r=s,i=a)}return i}function O(e,t,n=y){let r=1/0,i=-1;for(let a=0;a<e.length;a++){let o=e[a],s=n(t,o);s<r&&(r=s,i=a)}return[i,r]}function ee(e,t,n=y){return e[D(e,t,n)]}function k(e={}){let{initialCapacity:t=4096,auto:i=!0}=e,a=r(t),o=5003,s=new Uint8Array(256),c=new Int32Array(o),l=new Int32Array(o),u=!1;return{reset(){a.reset(),u=!1},finish(){a.writeByte(n.trailer)},bytes(){return a.bytes()},bytesView(){return a.bytesView()},get buffer(){return a.buffer},get stream(){return a},writeHeader:d,writeFrame(e,t,n,r={}){let{transparent:o=!1,transparentIndex:f=0,delay:p=0,palette:m=null,repeat:h=0,colorDepth:g=8,dispose:_=-1}=r,v=!1;if(i?u||=(v=!0,d(),!0):v=!!r.first,t=Math.max(0,Math.floor(t)),n=Math.max(0,Math.floor(n)),v){if(!m)throw Error(`First frame must include a { palette } option`);te(a,t,n,m,g),re(a,m),h>=0&&ne(a,h)}let y=Math.round(p/10);A(a,_,y,o,f);let b=!!m&&!v;ie(a,t,n,b?m:null),b&&re(a,m),ae(a,e,t,n,g,s,c,l)}};function d(){oe(a,`GIF89a`)}}function A(e,t,n,r,i){e.writeByte(33),e.writeByte(249),e.writeByte(4),i<0&&(i=0,r=!1);var a,o;r?(a=1,o=2):(a=0,o=0),t>=0&&(o=t&7),o<<=2,e.writeByte(o|0|a),j(e,n),e.writeByte(i||0),e.writeByte(0)}function te(e,t,n,r,i=8){let a=se(r.length)-1,o=i-1<<4|128|a;j(e,t),j(e,n),e.writeBytes([o,0,0])}function ne(e,t){e.writeByte(33),e.writeByte(255),e.writeByte(11),oe(e,`NETSCAPE2.0`),e.writeByte(3),e.writeByte(1),j(e,t),e.writeByte(0)}function re(e,t){let n=1<<se(t.length);for(let r=0;r<n;r++){let n=[0,0,0];r<t.length&&(n=t[r]),e.writeByte(n[0]),e.writeByte(n[1]),e.writeByte(n[2])}}function ie(e,t,n,r){if(e.writeByte(44),j(e,0),j(e,0),j(e,t),j(e,n),r){let t=se(r.length)-1;e.writeByte(128|t)}else e.writeByte(0)}function ae(e,t,n,r,i=8,a,o,s){c(n,r,t,i,e,a,o,s)}function j(e,t){e.writeByte(t&255),e.writeByte(t>>8&255)}function oe(e,t){for(var n=0;n<t.length;n++)e.writeByte(t.charCodeAt(n))}function se(e){return Math.max(Math.ceil(Math.log2(e)),1)}var ce=k}));function F(e){if(!e)throw Error(`Assertion failed.`)}var En=Math.PI/180,Dn=180/Math.PI,On=e=>{let t=(e%360+360)%360;if(t===0||t===90||t===180||t===270)return t;throw Error(`Invalid rotation ${e}.`)},kn=[1,0,0,0,1,0,0,0,1],An=(e,t,n)=>{let[r,i,,a,o]=e,s=Math.abs(r)*t+Math.abs(a)*n,c=Math.abs(i)*t+Math.abs(o)*n;return In(In(Pn(-t/2,-n/2),e),Pn(s/2,c/2))},jn=e=>{let[t,n]=e;return On(cr(Math.atan2(n,Mn(e)?-t:t)*Dn,90))},Mn=e=>{let[t,n,,r,i]=e;return t*i-n*r<0},Nn=e=>{let t=e*En,n=Math.round(Math.cos(t)),r=Math.round(Math.sin(t));return[n,r,0,-r,n,0,0,0,1]},Pn=(e,t)=>[1,0,0,0,1,0,e,t,1],Fn=(e,t)=>[e,0,0,0,t,0,0,0,1],In=(e,t)=>{let n=Array(9);for(let r=0;r<3;r++)for(let i=0;i<3;i++)n[3*r+i]=e[3*r]*t[i]+e[3*r+1]*t[3+i]+e[3*r+2]*t[6+i];return n},Ln=(e,t,n,r)=>({rotation:On(e+(t?-n:n)),flip:t!==r}),Rn=e=>e&&e[e.length-1],zn=e=>e>=0&&e<2**32,Bn=e=>e>=-(2**31)&&e<2**31,I=e=>{let t=0;for(;e.readBits(1)===0&&t<32;)t++;if(t>=32)throw Error(`Invalid exponential-Golomb code.`);return 2**t-1+e.readBits(t)},Vn=e=>{let t=I(e);return t%2==0?-(t/2):(t+1)/2},Hn=(e,t,n,r)=>{for(let i=t;i<n;i++){let t=Math.floor(i/8),a=e[t],o=7-(i&7);a&=~(1<<o),a|=(r&1<<n-i-1)>>n-i-1<<o,e[t]=a}},Un=e=>e.constructor===Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),Wn=e=>e.constructor===DataView?e:ArrayBuffer.isView(e)?new DataView(e.buffer,e.byteOffset,e.byteLength):new DataView(e),Gn=globalThis.TextEncoder===void 0?class{constructor(){this.encoding=`utf-8`}encode(e=``){let t=new Uint8Array(3*e.length),n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i<128)t[n++]=i;else if(i<2048)t[n++]=192|i>>6,t[n++]=128|i&63;else if(i<55296||i>57343)t[n++]=224|i>>12,t[n++]=128|i>>6&63,t[n++]=128|i&63;else{let a=r+1<e.length?e.charCodeAt(r+1):0;i<56320&&a>=56320&&a<=57343?(i=65536+(i-55296<<10)+(a-56320),r++,t[n++]=240|i>>18,t[n++]=128|i>>12&63,t[n++]=128|i>>6&63,t[n++]=128|i&63):(t[n++]=239,t[n++]=191,t[n++]=189)}}return t.slice(0,n)}}:globalThis.TextEncoder;globalThis.TextDecoder===void 0||globalThis.TextDecoder;var Kn=new Gn,qn={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},Jn={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},Yn={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},Xn=e=>!e||e.primaries==null&&e.transfer==null&&e.matrix==null&&e.fullRange==null,Zn=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e),Qn=class{constructor(){this.currentPromise=Promise.resolve(),this.pending=0}async acquire(){let e,t=new Promise(t=>{let n=!1;e=()=>{n||=(t(),this.pending--,!0)}}),n=this.currentPromise;return this.currentPromise=t,this.pending++,await n,e}},$n=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``),er=e=>(e=e>>1&1431655765|(e&1431655765)<<1,e=e>>2&858993459|(e&858993459)<<2,e=e>>4&252645135|(e&252645135)<<4,e=e>>8&16711935|(e&16711935)<<8,e=e>>16&65535|(e&65535)<<16,e>>>0),tr=(e,t,n)=>{let r=0,i=e.length-1,a=-1;for(;r<=i;){let o=r+(i-r+1)/2|0;n(e[o])<=t?(a=o,r=o+1):i=o-1}return a},nr=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},rr=e=>{throw Error(`Unexpected value: ${e}`)},ir=(e,t,n)=>{let r=e.getUint8(t),i=e.getUint8(t+1),a=e.getUint8(t+2);return n?r|i<<8|a<<16:r<<16|i<<8|a},ar=(e,t,n,r)=>{n>>>=0,n&=16777215,r?(e.setUint8(t,n&255),e.setUint8(t+1,n>>>8&255),e.setUint8(t+2,n>>>16&255)):(e.setUint8(t,n>>>16&255),e.setUint8(t+1,n>>>8&255),e.setUint8(t+2,n&255))},or=(e,t,n)=>Math.max(t,Math.min(n,e)),sr=(e,t,n)=>e+(t-e)*n,cr=(e,t)=>Math.round(e/t)*t,lr=(e,t)=>Math.round(e*t)/t,ur=(e,t)=>Math.floor(e*t)/t,dr=e=>{let t=0;for(;e!==0;)e&=e-1,t++;return t},fr=/^[a-z]{3}$/,pr=e=>fr.test(e),mr=1e6*(1+2**-52),hr=(e,t)=>{let n=e<0?-1:1;e=Math.abs(e);let r=0,i=1,a=1,o=0,s=e;for(;;){let e=Math.floor(s),c=e*a+r,l=e*o+i;if(l>t)return{num:n*a,den:o};if(r=a,i=o,a=c,o=l,s=1/(s-e),!isFinite(s))break}return{num:n*a,den:o}},gr=class{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}},_r=null,vr=()=>_r===null?_r=!!(typeof navigator<`u`&&(navigator.vendor?.match(/apple/i)||/AppleWebKit/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent))):_r,yr=null,br=()=>yr===null?yr=typeof navigator<`u`&&navigator.userAgent?.includes(`Firefox`):yr,xr=null,Sr=()=>xr===null?xr=!(typeof navigator>`u`||!navigator.vendor?.includes(`Google Inc`)&&!/Chrome/.test(navigator.userAgent)):xr,Cr=null,wr=()=>{if(Cr!==null)return Cr;if(typeof navigator>`u`)return null;let e=/\bChrome\/(\d+)/.exec(navigator.userAgent);return e?Cr=Number(e[1]):null},Tr=e=>globalThis.isSecureContext!==void 0&&!globalThis.isSecureContext?`${e} is not available in this environment; this may be because this page is running in an insecure context. Try serving your page over HTTPS or use localhost.`:`${e} is not available in this environment.`,Er=e=>e instanceof DOMException&&e.name===`QuotaExceededError`&&/reclaimed/i.test(e.message),Dr=(async()=>{})().constructor,Or=e=>e instanceof Dr||e instanceof Promise||typeof e?.then==`function`,kr=function*(e){for(let t in e){let n=e[t];n!==void 0&&(yield{key:t,value:n})}},Ar=e=>{switch(e.toLowerCase()){case`image/jpeg`:case`image/jpg`:return`.jpg`;case`image/png`:return`.png`;case`image/gif`:return`.gif`;case`image/webp`:return`.webp`;case`image/bmp`:return`.bmp`;case`image/svg+xml`:return`.svg`;case`image/tiff`:return`.tiff`;case`image/avif`:return`.avif`;case`image/x-icon`:case`image/vnd.microsoft.icon`:return`.ico`;default:return null}},jr=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Mr=()=>{Symbol.dispose??=Symbol(`Symbol.dispose`)},Nr=e=>typeof e==`number`&&!Number.isNaN(e),Pr=(e,t)=>{let n=-1,r=1/0;for(let i=0;i<e.length;i++){let a=t(e[i]);(n===-1||a<r)&&(r=a,n=i)}return n},Fr=e=>{F(Number.isInteger(e.num)),F(Number.isInteger(e.den)),F(e.den!==0);let t=Math.abs(e.num),n=Math.abs(e.den);for(;n!==0;){let e=t%n;t=n,n=e}let r=t||1;return{num:e.num/r,den:e.den/r}},Ir=(e,t)=>{if(typeof e!=`object`||!e)throw TypeError(`${t} must be an object.`);if(!Number.isInteger(e.left)||e.left<0)throw TypeError(`${t}.left must be a non-negative integer.`);if(!Number.isInteger(e.top)||e.top<0)throw TypeError(`${t}.top must be a non-negative integer.`);if(!Number.isInteger(e.width)||e.width<0)throw TypeError(`${t}.width must be a non-negative integer.`);if(!Number.isInteger(e.height)||e.height<0)throw TypeError(`${t}.height must be a non-negative integer.`)},Lr=e=>new Promise(t=>setTimeout(t,e)),Rr=e=>Array.isArray(e)?e:[e],zr=class{constructor(){this._listeners=new Map}on(e,t,n){this._listeners.has(e)||this._listeners.set(e,new Set);let r={fn:t,once:n?.once??!1};return this._listeners.get(e).add(r),()=>{this._listeners.get(e)?.delete(r)}}_emit(...e){let[t,n]=e,r=this._listeners.get(t);if(r)for(let e of r){try{e.fn(n)}catch(e){console.error(e)}e.once&&r.delete(e)}}},Br=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(e=>typeof e==`string`),Vr;(function(e){e[e.Silent=0]=`Silent`,e[e.Errors=1]=`Errors`,e[e.Warnings=2]=`Warnings`,e[e.Info=3]=`Info`})(Vr||={});var Hr=class e{constructor(){}static get level(){return e._level}static set level(t){if(t!==Vr.Silent&&t!==Vr.Errors&&t!==Vr.Warnings&&t!==Vr.Info)throw TypeError(`Invalid log level. Use one of the values of the LogLevel enum.`);e._level=t}static get _emitter(){return e._emitterInstance??=new zr}static on(t,n,r){return e._emitter.on(t,n,r)}static _error(...t){e._emitter._emit(`error`,t),e._level>=Vr.Errors&&console.error(...t)}static _warn(...t){e._emitter._emit(`warn`,t),e._level>=Vr.Warnings&&console.warn(...t)}static _info(...t){e._emitter._emit(`info`,t),e._level>=Vr.Info&&console.info(...t)}};Hr._level=Vr.Info,Hr._emitterInstance=null;var Ur=class{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(typeof t!=`string`)throw TypeError(`mimeType must be a string.`)}},Wr=class{constructor(e,t,n,r){if(this.data=e,this.mimeType=t,this.name=n,this.description=r,!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(t!==void 0&&typeof t!=`string`)throw TypeError(`mimeType, when provided, must be a string.`);if(n!==void 0&&typeof n!=`string`)throw TypeError(`name, when provided, must be a string.`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`description, when provided, must be a string.`)}},Gr=e=>{if(!e||typeof e!=`object`)throw TypeError(`tags must be an object.`);if(e.title!==void 0&&typeof e.title!=`string`)throw TypeError(`tags.title, when provided, must be a string.`);if(e.description!==void 0&&typeof e.description!=`string`)throw TypeError(`tags.description, when provided, must be a string.`);if(e.artist!==void 0&&typeof e.artist!=`string`)throw TypeError(`tags.artist, when provided, must be a string.`);if(e.album!==void 0&&typeof e.album!=`string`)throw TypeError(`tags.album, when provided, must be a string.`);if(e.albumArtist!==void 0&&typeof e.albumArtist!=`string`)throw TypeError(`tags.albumArtist, when provided, must be a string.`);if(e.trackNumber!==void 0&&(!Number.isInteger(e.trackNumber)||e.trackNumber<=0))throw TypeError(`tags.trackNumber, when provided, must be a positive integer.`);if(e.tracksTotal!==void 0&&(!Number.isInteger(e.tracksTotal)||e.tracksTotal<=0))throw TypeError(`tags.tracksTotal, when provided, must be a positive integer.`);if(e.discNumber!==void 0&&(!Number.isInteger(e.discNumber)||e.discNumber<=0))throw TypeError(`tags.discNumber, when provided, must be a positive integer.`);if(e.discsTotal!==void 0&&(!Number.isInteger(e.discsTotal)||e.discsTotal<=0))throw TypeError(`tags.discsTotal, when provided, must be a positive integer.`);if(e.genre!==void 0&&typeof e.genre!=`string`)throw TypeError(`tags.genre, when provided, must be a string.`);if(e.date!==void 0&&(!(e.date instanceof Date)||Number.isNaN(e.date.getTime())))throw TypeError(`tags.date, when provided, must be a valid Date.`);if(e.creationTime!==void 0&&e.creationTime!==null&&(!(e.creationTime instanceof Date)||Number.isNaN(e.creationTime.getTime())))throw TypeError(`tags.creationTime, when provided, must be a valid Date or null.`);if(e.beatsPerMinute!==void 0&&(!Number.isInteger(e.beatsPerMinute)||e.beatsPerMinute<=0))throw TypeError(`tags.beatsPerMinute, when provided, must be a positive integer.`);if(e.lyrics!==void 0&&typeof e.lyrics!=`string`)throw TypeError(`tags.lyrics, when provided, must be a string.`);if(e.images!==void 0){if(!Array.isArray(e.images))throw TypeError(`tags.images, when provided, must be an array.`);for(let t of e.images){if(!t||typeof t!=`object`)throw TypeError(`Each image in tags.images must be an object.`);if(!(t.data instanceof Uint8Array))throw TypeError(`Each image.data must be a Uint8Array.`);if(typeof t.mimeType!=`string`)throw TypeError(`Each image.mimeType must be a string.`);if(![`coverFront`,`coverBack`,`unknown`].includes(t.kind))throw TypeError(`Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.`)}}if(e.comment!==void 0&&typeof e.comment!=`string`)throw TypeError(`tags.comment, when provided, must be a string.`);if(e.raw!==void 0){if(!e.raw||typeof e.raw!=`object`)throw TypeError(`tags.raw, when provided, must be an object.`);for(let t of Object.values(e.raw))if(t!==null&&typeof t!=`string`&&!(Array.isArray(t)&&t.every(e=>typeof e==`string`))&&!(t instanceof Uint8Array)&&!(Array.isArray(t)&&t.every(e=>e instanceof Uint8Array))&&!(t instanceof Ur)&&!(t instanceof Wr)&&!Br(t))throw TypeError(`Each value in tags.raw must be a string, string array, Uint8Array, Uint8Array array, RichImageData, AttachedFile, Record<string, string>, or null.`)}},Kr=e=>{if(!e||typeof e!=`object`)throw TypeError(`disposition must be an object.`);if(e.default!==void 0&&typeof e.default!=`boolean`)throw TypeError(`disposition.default must be a boolean.`);if(e.primary!==void 0&&typeof e.primary!=`boolean`)throw TypeError(`disposition.primary must be a boolean.`);if(e.forced!==void 0&&typeof e.forced!=`boolean`)throw TypeError(`disposition.forced must be a boolean.`);if(e.original!==void 0&&typeof e.original!=`boolean`)throw TypeError(`disposition.original must be a boolean.`);if(e.commentary!==void 0&&typeof e.commentary!=`boolean`)throw TypeError(`disposition.commentary must be a boolean.`);if(e.hearingImpaired!==void 0&&typeof e.hearingImpaired!=`boolean`)throw TypeError(`disposition.hearingImpaired must be a boolean.`);if(e.visuallyImpaired!==void 0&&typeof e.visuallyImpaired!=`boolean`)throw TypeError(`disposition.visuallyImpaired must be a boolean.`)},qr=class e{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){let e=Math.floor(this.pos/8),t=this.bytes[e]??0,n=7-(this.pos&7),r=(t&1<<n)>>n;return this.pos++,r}readBits(e){if(e===1)return this.readBit();let t=0;for(let n=0;n<e;n++)t<<=1,t|=this.readBit();return t}writeBits(e,t){let n=this.pos+e;for(let e=this.pos;e<n;e++){let r=Math.floor(e/8),i=this.bytes[r],a=7-(e&7);i&=~(1<<a),i|=(t&1<<n-e-1)>>n-e-1<<a,this.bytes[r]=i}this.pos=n}copyBits(e,t){let n=0;for(;n<e-7;n+=8)this.writeBits(8,t.readBits(8));let r=e-n;r>0&&this.writeBits(r,t.readBits(r))}readAlignedByte(){if(this.pos%8!=0)throw Error(`Bitstream is not byte-aligned.`);let e=this.pos/8,t=this.bytes[e]??0;return this.pos+=8,t}skipBits(e){this.pos+=e}getBitsLeft(){return this.bytes.length*8-this.pos}clone(){let t=new e(this.bytes);return t.pos=this.pos,t}},Jr=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Yr=[-1,1,2,3,4,5,6,8],Xr=[1,2,3,4,6,7,17,19,20,21,22],Zr=e=>{if(!e||e.byteLength<2)throw TypeError(`AAC description must be at least 2 bytes long.`);let t=new qr(e),n=Qr(t),{frequencyIndex:r,sampleRate:i}=$r(t),a=t.readBits(4),o=null;a>=1&&a<=7&&(o=Yr[a]);let s=n,c=!1,l=i;(n===5||n===29)&&(c=n===29,l=$r(t).sampleRate,s=Qr(t),s===22&&t.skipBits(4));let u=1024;if(Xr.includes(s)&&(u=t.readBits(1)?960:1024),n!==5&&n!==29)for(;t.getBitsLeft()>15;){let e=t.pos;if(t.readBits(11)!==695)t.pos=e+1;else{Qr(t)===5&&t.readBits(1)&&(l=$r(t).sampleRate,t.getBitsLeft()>11&&t.readBits(11)===1352&&(c=!!t.readBits(1)));break}}return o!==null&&o>1&&(c=!1),{objectType:n,coreObjectType:s,frequencyIndex:r,channelConfiguration:a,coreSampleRate:i,outputSampleRate:l,outputNumberOfChannels:c&&o===1?2:o,frameLength:u}},Qr=e=>{let t=e.readBits(5);return t===31?32+e.readBits(6):t},$r=e=>{let t=e.readBits(4);return t===15?{frequencyIndex:t,sampleRate:e.readBits(24)}:{frequencyIndex:t,sampleRate:t<Jr.length?Jr[t]:null}},ei=e=>{let t=e.objectType===5||e.objectType===29,n=e.objectType===29,r=t?e.outputSampleRate/2:e.outputSampleRate,i=n?1:e.outputNumberOfChannels,a=Yr.indexOf(i);if(a===-1)throw TypeError(`Unsupported number of channels: ${e.outputNumberOfChannels}`);let o=16;e.objectType>=32&&(o+=6),ri(r)===15&&(o+=24),t&&(o+=9,ri(e.outputSampleRate)===15&&(o+=24));let s=Math.ceil(o/8),c=new Uint8Array(s),l=new qr(c);return ti(l,e.objectType),ni(l,r),l.writeBits(4,a),t&&(ni(l,e.outputSampleRate),ti(l,2)),l.writeBits(3,0),c},ti=(e,t)=>{t<32?e.writeBits(5,t):(e.writeBits(5,31),e.writeBits(6,t-32))},ni=(e,t)=>{let n=ri(t);e.writeBits(4,n),n===15&&e.writeBits(24,t)},ri=e=>{let t=Jr.indexOf(e);return t===-1?15:t},ii=[48e3,44100,32e3],ai=[24e3,22050,16e3],oi=`Mediabunny v1.65.0`,si;(function(e){e[e.NON_IDR_SLICE=1]=`NON_IDR_SLICE`,e[e.SLICE_DPA=2]=`SLICE_DPA`,e[e.SLICE_DPB=3]=`SLICE_DPB`,e[e.SLICE_DPC=4]=`SLICE_DPC`,e[e.IDR=5]=`IDR`,e[e.SEI=6]=`SEI`,e[e.SPS=7]=`SPS`,e[e.PPS=8]=`PPS`,e[e.AUD=9]=`AUD`,e[e.SPS_EXT=13]=`SPS_EXT`})(si||={});var ci;(function(e){e[e.RASL_N=8]=`RASL_N`,e[e.RASL_R=9]=`RASL_R`,e[e.BLA_W_LP=16]=`BLA_W_LP`,e[e.RSV_IRAP_VCL23=23]=`RSV_IRAP_VCL23`,e[e.VPS_NUT=32]=`VPS_NUT`,e[e.SPS_NUT=33]=`SPS_NUT`,e[e.PPS_NUT=34]=`PPS_NUT`,e[e.AUD_NUT=35]=`AUD_NUT`,e[e.PREFIX_SEI_NUT=39]=`PREFIX_SEI_NUT`,e[e.SUFFIX_SEI_NUT=40]=`SUFFIX_SEI_NUT`})(ci||={});var li=function*(e){let t=0,n=-1;for(;t<e.length-2;){let r=e.indexOf(0,t);if(r===-1||r>=e.length-2)break;t=r;let i=0;t+3<e.length&&e[t+1]===0&&e[t+2]===0&&e[t+3]===1?i=4:e[t+1]===0&&e[t+2]===1&&(i=3),i===0?t++:(n!==-1&&t>n&&(yield{offset:n,length:t-n}),n=t+i,t=n)}n!==-1&&n<e.length&&(yield{offset:n,length:e.length-n})},ui=function*(e,t){let n=0,r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;n+t<=e.length;){let e;t===1?e=r.getUint8(n):t===2?e=r.getUint16(n,!1):t===3?e=ir(r,n,!1):(F(t===4),e=r.getUint32(n,!1)),n+=t,yield{offset:n,length:e},n+=e}},di=(e,t)=>t.description?ui(e,(Un(t.description)[4]&3)+1):li(e),fi=e=>e&31,pi=e=>{let t=new Uint8Array(e.length),n=e.length,r=0;for(let i=0;i<n;i++)i+2<n&&e[i]===0&&e[i+1]===0&&e[i+2]===3?(t[r++]=0,t[r++]=0,i+=2):t[r++]=e[i];return t.subarray(0,r)};new Uint8Array([0,0,0,1]);var mi=(e,t)=>{let n=e.reduce((e,n)=>e+t+n.byteLength,0),r=new Uint8Array(n),i=0;for(let n of e){let e=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(t){case 1:e.setUint8(i,n.byteLength);break;case 2:e.setUint16(i,n.byteLength,!1);break;case 3:ar(e,i,n.byteLength,!1);break;case 4:e.setUint32(i,n.byteLength,!1)}i+=t,r.set(n,i),i+=n.byteLength}return r},hi=e=>{try{let t=[],n=[],r=[];for(let i of li(e)){let a=e.subarray(i.offset,i.offset+i.length),o=fi(a[0]);o===si.SPS&&t.length<31?t.push(a):o===si.PPS&&n.length<255?n.push(a):o===si.SPS_EXT&&r.length<255&&r.push(a)}if(t.length===0||n.length===0)return null;let i=t[0],a=yi(i);if(!a)return null;let o=a.profileIdc===100||a.profileIdc===110||a.profileIdc===122||a.profileIdc===144;return{configurationVersion:1,avcProfileIndication:a.profileIdc,profileCompatibility:a.constraintFlags,avcLevelIndication:a.levelIdc,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:n,chromaFormat:o?a.chromaFormatIdc:null,bitDepthLumaMinus8:o?a.bitDepthLumaMinus8:null,bitDepthChromaMinus8:o?a.bitDepthChromaMinus8:null,sequenceParameterSetExt:o?r:null}}catch(e){return Hr._error(`Error building AVC Decoder Configuration Record:`,e),null}},gi=e=>{let t=[];t.push(e.configurationVersion),t.push(e.avcProfileIndication),t.push(e.profileCompatibility),t.push(e.avcLevelIndication),t.push(252|e.lengthSizeMinusOne&3),t.push(224|e.sequenceParameterSets.length&31);for(let n of e.sequenceParameterSets){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}t.push(e.pictureParameterSets.length);for(let n of e.pictureParameterSets){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}if((e.avcProfileIndication===100||e.avcProfileIndication===110||e.avcProfileIndication===122||e.avcProfileIndication===144)&&e.chromaFormat!==null){F(e.bitDepthLumaMinus8!==null),F(e.bitDepthChromaMinus8!==null),F(e.sequenceParameterSetExt!==null),t.push(252|e.chromaFormat&3),t.push(248|e.bitDepthLumaMinus8&7),t.push(248|e.bitDepthChromaMinus8&7),t.push(e.sequenceParameterSetExt.length);for(let n of e.sequenceParameterSetExt){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}}return new Uint8Array(t)},_i=e=>{try{let t=Wn(e),n=0,r=t.getUint8(n++),i=t.getUint8(n++),a=t.getUint8(n++),o=t.getUint8(n++),s=t.getUint8(n++)&3,c=t.getUint8(n++)&31,l=[];for(let r=0;r<c;r++){let r=t.getUint16(n,!1);n+=2,l.push(e.subarray(n,n+r)),n+=r}let u=t.getUint8(n++),d=[];for(let r=0;r<u;r++){let r=t.getUint16(n,!1);n+=2,d.push(e.subarray(n,n+r)),n+=r}let f={configurationVersion:r,avcProfileIndication:i,profileCompatibility:a,avcLevelIndication:o,lengthSizeMinusOne:s,sequenceParameterSets:l,pictureParameterSets:d,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if((i===100||i===110||i===122||i===144)&&n+4<=e.length){let r=t.getUint8(n++)&3,i=t.getUint8(n++)&7,a=t.getUint8(n++)&7,o=t.getUint8(n++);f.chromaFormat=r,f.bitDepthLumaMinus8=i,f.bitDepthChromaMinus8=a;let s=[];for(let r=0;r<o;r++){let r=t.getUint16(n,!1);n+=2,s.push(e.subarray(n,n+r)),n+=r}f.sequenceParameterSetExt=s}return f}catch(e){return Hr._error(`Error deserializing AVC Decoder Configuration Record:`,e),null}},vi={1:{num:1,den:1},2:{num:12,den:11},3:{num:10,den:11},4:{num:16,den:11},5:{num:40,den:33},6:{num:24,den:11},7:{num:20,den:11},8:{num:32,den:11},9:{num:80,den:33},10:{num:18,den:11},11:{num:15,den:11},12:{num:64,den:33},13:{num:160,den:99},14:{num:4,den:3},15:{num:3,den:2},16:{num:2,den:1}},yi=e=>{try{let t=pi(e),n=new qr(t);if(n.skipBits(1),n.skipBits(2),n.readBits(5)!==7)return null;let r=n.readAlignedByte(),i=n.readAlignedByte(),a=n.readAlignedByte();I(n);let o=1,s=0,c=0,l=0;if((r===100||r===110||r===122||r===244||r===44||r===83||r===86||r===118||r===128)&&(o=I(n),o===3&&(l=n.readBits(1)),s=I(n),c=I(n),n.skipBits(1),n.readBits(1))){for(let e=0;e<(o===3?12:8);e++)if(n.readBits(1)){let t=e<6?16:64,r=8,i=8;for(let e=0;e<t;e++){if(i!==0){let e=Vn(n);i=(r+e+256)%256}r=i===0?r:i}}}I(n);let u=I(n);if(u===0)I(n);else if(u===1){n.skipBits(1),Vn(n),Vn(n);let e=I(n);for(let t=0;t<e;t++)Vn(n)}I(n),n.skipBits(1);let d=I(n),f=I(n),p=16*(d+1),m=16*(f+1),h=p,g=m,_=n.readBits(1);if(_||n.skipBits(1),n.skipBits(1),n.readBits(1)){let e=I(n),t=I(n),r=I(n),i=I(n),a,s;if((l===0?o:0)===0)a=1,s=2-_;else{let e=o===3?1:2,t=o===1?2:1;a=e,s=t*(2-_)}h-=a*(e+t),g-=s*(r+i)}if(h<=0||g<=0)return null;let v=2,y=2,b=2,x=0,S={num:1,den:1},C=null,w=null,T=null,E=null,D=n.pos;if(n.readBits(1)){if(n.readBits(1)){let e=n.readBits(8);if(e===255)S={num:n.readBits(16),den:n.readBits(16)};else{let t=vi[e];t&&(S=t)}}n.readBits(1)&&n.skipBits(1),n.readBits(1)&&(n.skipBits(3),x=n.readBits(1),n.readBits(1)&&(v=n.readBits(8),y=n.readBits(8),b=n.readBits(8))),n.readBits(1)&&(I(n),I(n)),n.readBits(1)&&(n.skipBits(32),n.skipBits(32),n.skipBits(1));let e=n.readBits(1);e&&bi(n);let t=n.readBits(1);t&&bi(n),(e||t)&&n.skipBits(1),n.skipBits(1),T=n.pos,E=n.readBits(1),E&&(n.skipBits(1),I(n),I(n),I(n),I(n),C=Math.min(I(n),16),w=Math.min(I(n),16))}if(C===null){F(w===null);let e=i&16;if((r===44||r===86||r===100||r===110||r===122||r===244)&&e)C=0,w=0;else{let e=d+1,t=f+1,n=(2-_)*t,r=Bo.find(e=>e.level>=a)??Rn(Bo),i=Math.min(Math.floor(r.maxDpbMbs/(e*n)),16);C=i,w=i}}return F(w!==null),{emulationUnpreventedBytes:t,profileIdc:r,constraintFlags:i,levelIdc:a,frameMbsOnlyFlag:_,chromaFormatIdc:o,bitDepthLumaMinus8:s,bitDepthChromaMinus8:c,codedWidth:p,codedHeight:m,displayWidth:h,displayHeight:g,pixelAspectRatio:S,colourPrimaries:v,matrixCoefficients:b,transferCharacteristics:y,fullRangeFlag:x,numReorderFrames:C,maxDecFrameBuffering:w,vuiParametersFlagBitOffset:D,bitstreamRestrictionFlagBitOffset:T,bitstreamRestrictionFlag:E}}catch(e){return Hr._error(`Error parsing AVC SPS:`,e),null}},bi=e=>{let t=I(e);e.skipBits(4),e.skipBits(4);for(let n=0;n<=t;n++)I(e),I(e),e.skipBits(1);e.skipBits(5),e.skipBits(5),e.skipBits(5),e.skipBits(5)},xi=(e,t)=>t.description?ui(e,(Un(t.description)[21]&3)+1):li(e),Si=e=>e>>1&63,Ci=e=>{try{let t=new qr(pi(e));t.skipBits(16),t.readBits(4);let n=t.readBits(3),r=t.readBits(1),{general_profile_space:i,general_tier_flag:a,general_profile_idc:o,general_profile_compatibility_flags:s,general_constraint_indicator_flags:c,general_level_idc:l}=Ti(t,n);I(t);let u=I(t),d=0;u===3&&(d=t.readBits(1));let f=I(t),p=I(t),m=f,h=p;if(t.readBits(1)){let e=I(t),n=I(t),r=I(t),i=I(t),a=1,o=1,s=d===0?u:0;s===1?(a=2,o=2):s===2&&(a=2,o=1),m-=(e+n)*a,h-=(r+i)*o}if(m<=0||h<=0)return null;let g=I(t),_=I(t);I(t);let v=t.readBits(1)?0:n,y=0;for(let e=v;e<=n;e++)I(t),y=I(t),I(t);if(I(t),I(t),I(t),I(t),I(t),I(t),t.readBits(1)&&t.readBits(1)&&Ei(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&(t.skipBits(4),t.skipBits(4),I(t),I(t),t.skipBits(1)),Di(t,I(t)),t.readBits(1)){let e=I(t);for(let n=0;n<e;n++)I(t),t.skipBits(1)}t.skipBits(1),t.skipBits(1);let b=2,x=2,S=2,C=0,w=0,T={num:1,den:1};if(t.readBits(1)){let e=ki(t,n);T=e.pixelAspectRatio,b=e.colourPrimaries,x=e.transferCharacteristics,S=e.matrixCoefficients,C=e.fullRangeFlag,w=e.minSpatialSegmentationIdc}return{displayWidth:m,displayHeight:h,pixelAspectRatio:T,colourPrimaries:b,transferCharacteristics:x,matrixCoefficients:S,fullRangeFlag:C,maxDecFrameBuffering:Math.min(y+1,16),spsMaxSubLayersMinus1:n,spsTemporalIdNestingFlag:r,generalProfileSpace:i,generalTierFlag:a,generalProfileIdc:o,generalProfileCompatibilityFlags:s,generalConstraintIndicatorFlags:c,generalLevelIdc:l,chromaFormatIdc:u,bitDepthLumaMinus8:g,bitDepthChromaMinus8:_,minSpatialSegmentationIdc:w}}catch(e){return Hr._error(`Error parsing HEVC SPS:`,e),null}},wi=e=>{try{let t=[],n=[],r=[],i=[],a=65535;for(let o of li(e)){let s=e.subarray(o.offset,o.offset+o.length),c=Si(s[0]);c===ci.VPS_NUT&&t.length<a?t.push(s):c===ci.SPS_NUT&&n.length<a?n.push(s):c===ci.PPS_NUT&&r.length<a?r.push(s):(c===ci.PREFIX_SEI_NUT||c===ci.SUFFIX_SEI_NUT)&&i.length<a&&i.push(s)}if(n.length===0||r.length===0)return null;let o=Ci(n[0]);if(!o)return null;let s=0;if(r.length>0){let e=r[0],t=new qr(pi(e));t.skipBits(16),I(t),I(t),t.skipBits(1),t.skipBits(1),t.skipBits(3),t.skipBits(1),t.skipBits(1),I(t),I(t),Vn(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&I(t),Vn(t),Vn(t),t.skipBits(1),t.skipBits(1),t.skipBits(1),t.skipBits(1);let n=t.readBits(1),i=t.readBits(1);s=!n&&!i?0:n&&!i?2:!n&&i?3:0}let c=[...t.length?[{arrayCompleteness:1,nalUnitType:ci.VPS_NUT,nalUnits:t}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:ci.SPS_NUT,nalUnits:n}]:[],...r.length?[{arrayCompleteness:1,nalUnitType:ci.PPS_NUT,nalUnits:r}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:Si(i[0][0]),nalUnits:i}]:[]];return{configurationVersion:1,generalProfileSpace:o.generalProfileSpace,generalTierFlag:o.generalTierFlag,generalProfileIdc:o.generalProfileIdc,generalProfileCompatibilityFlags:o.generalProfileCompatibilityFlags,generalConstraintIndicatorFlags:o.generalConstraintIndicatorFlags,generalLevelIdc:o.generalLevelIdc,minSpatialSegmentationIdc:o.minSpatialSegmentationIdc,parallelismType:s,chromaFormatIdc:o.chromaFormatIdc,bitDepthLumaMinus8:o.bitDepthLumaMinus8,bitDepthChromaMinus8:o.bitDepthChromaMinus8,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:o.spsMaxSubLayersMinus1+1,temporalIdNested:o.spsTemporalIdNestingFlag,lengthSizeMinusOne:3,arrays:c}}catch(e){return Hr._error(`Error building HEVC Decoder Configuration Record:`,e),null}},Ti=(e,t)=>{let n=e.readBits(2),r=e.readBits(1),i=e.readBits(5),a=0;for(let t=0;t<32;t++)a=a<<1|e.readBits(1);let o=new Uint8Array(6);for(let t=0;t<6;t++)o[t]=e.readBits(8);let s=e.readBits(8),c=[],l=[];for(let n=0;n<t;n++)c.push(e.readBits(1)),l.push(e.readBits(1));if(t>0)for(let n=t;n<8;n++)e.skipBits(2);for(let n=0;n<t;n++)c[n]&&e.skipBits(88),l[n]&&e.skipBits(8);return{general_profile_space:n,general_tier_flag:r,general_profile_idc:i,general_profile_compatibility_flags:a,general_constraint_indicator_flags:o,general_level_idc:s}},Ei=e=>{for(let t=0;t<4;t++)for(let n=0;n<(t===3?2:6);n++)if(!e.readBits(1))I(e);else{let n=Math.min(64,1<<4+(t<<1));t>1&&Vn(e);for(let t=0;t<n;t++)Vn(e)}},Di=(e,t)=>{let n=[];for(let r=0;r<t;r++)n[r]=Oi(e,r,t,n)},Oi=(e,t,n,r)=>{let i=0,a=0,o=0;if(t!==0&&(a=e.readBits(1)),a){o=t===n?t-(I(e)+1):t-1,e.readBits(1),I(e);let a=r[o]??0;for(let t=0;t<=a;t++)e.readBits(1)||e.readBits(1);i=r[o]}else{let t=I(e),n=I(e);for(let n=0;n<t;n++)I(e),e.readBits(1);for(let t=0;t<n;t++)I(e),e.readBits(1);i=t+n}return i},ki=(e,t)=>{let n=2,r=2,i=2,a=0,o=0,s={num:1,den:1};if(e.readBits(1)){let t=e.readBits(8);if(t===255)s={num:e.readBits(16),den:e.readBits(16)};else{let e=vi[t];e&&(s=e)}}return e.readBits(1)&&e.readBits(1),e.readBits(1)&&(e.readBits(3),a=e.readBits(1),e.readBits(1)&&(n=e.readBits(8),r=e.readBits(8),i=e.readBits(8))),e.readBits(1)&&(I(e),I(e)),e.readBits(1),e.readBits(1),e.readBits(1),e.readBits(1)&&(I(e),I(e),I(e),I(e)),e.readBits(1)&&(e.readBits(32),e.readBits(32),e.readBits(1)&&I(e),e.readBits(1)&&Ai(e,!0,t)),e.readBits(1)&&(e.readBits(1),e.readBits(1),e.readBits(1),o=I(e),I(e),I(e),I(e),I(e)),{pixelAspectRatio:s,colourPrimaries:n,transferCharacteristics:r,matrixCoefficients:i,fullRangeFlag:a,minSpatialSegmentationIdc:o}},Ai=(e,t,n)=>{let r=!1,i=!1,a=!1;t&&(r=e.readBits(1)===1,i=e.readBits(1)===1,(r||i)&&(a=e.readBits(1)===1,a&&(e.readBits(8),e.readBits(5),e.readBits(1),e.readBits(5)),e.readBits(4),e.readBits(4),a&&e.readBits(4),e.readBits(5),e.readBits(5),e.readBits(5)));for(let t=0;t<=n;t++){let t=e.readBits(1)===1,n=!0;t||(n=e.readBits(1)===1);let o=!1;n?I(e):o=e.readBits(1)===1;let s=1;o||(s=I(e)+1),r&&ji(e,s,a),i&&ji(e,s,a)}},ji=(e,t,n)=>{for(let r=0;r<t;r++)I(e),I(e),n&&(I(e),I(e)),e.readBits(1)},Mi=e=>{let t=[];t.push(e.configurationVersion),t.push((e.generalProfileSpace&3)<<6|(e.generalTierFlag&1)<<5|e.generalProfileIdc&31),t.push(e.generalProfileCompatibilityFlags>>>24&255),t.push(e.generalProfileCompatibilityFlags>>>16&255),t.push(e.generalProfileCompatibilityFlags>>>8&255),t.push(e.generalProfileCompatibilityFlags&255),t.push(...e.generalConstraintIndicatorFlags),t.push(e.generalLevelIdc&255),t.push(240|e.minSpatialSegmentationIdc>>8&15),t.push(e.minSpatialSegmentationIdc&255),t.push(252|e.parallelismType&3),t.push(252|e.chromaFormatIdc&3),t.push(248|e.bitDepthLumaMinus8&7),t.push(248|e.bitDepthChromaMinus8&7),t.push(e.avgFrameRate>>8&255),t.push(e.avgFrameRate&255),t.push((e.constantFrameRate&3)<<6|(e.numTemporalLayers&7)<<3|(e.temporalIdNested&1)<<2|e.lengthSizeMinusOne&3),t.push(e.arrays.length&255);for(let n of e.arrays){t.push((n.arrayCompleteness&1)<<7|n.nalUnitType&63),t.push(n.nalUnits.length>>8&255),t.push(n.nalUnits.length&255);for(let e of n.nalUnits){t.push(e.length>>8&255),t.push(e.length&255);for(let n=0;n<e.length;n++)t.push(e[n])}}return new Uint8Array(t)},Ni;(function(e){e[e.audAllowed=0]=`audAllowed`,e[e.beforeFirstVcl=1]=`beforeFirstVcl`,e[e.afterFirstVcl=2]=`afterFirstVcl`,e[e.eoBitstreamAllowed=3]=`eoBitstreamAllowed`,e[e.noMoreDataAllowed=4]=`noMoreDataAllowed`})(Ni||={});var Pi={1:{colourPrimaries:5,transferCharacteristics:6,matrixCoefficients:5},2:{colourPrimaries:1,transferCharacteristics:1,matrixCoefficients:1},3:{colourPrimaries:6,transferCharacteristics:6,matrixCoefficients:6},4:{colourPrimaries:7,transferCharacteristics:7,matrixCoefficients:7},5:{colourPrimaries:9,transferCharacteristics:14,matrixCoefficients:9},7:{colourPrimaries:1,transferCharacteristics:13,matrixCoefficients:0}},Fi=e=>{let t=new qr(e);if(t.readBits(2)!==2)return null;let n=t.readBits(1),r=(t.readBits(1)<<1)+n;if(r===3&&t.skipBits(1),t.readBits(1)===1||t.readBits(1)!==0||(t.skipBits(2),t.readBits(24)!==4817730))return null;let i=8;r>=2&&(i=t.readBits(1)?12:10);let a=t.readBits(3),o=0,s=0;if(a!==7){if(s=t.readBits(1),r===1||r===3){let e=t.readBits(1),n=t.readBits(1);o=!e&&!n?3:e&&!n?2:1,t.skipBits(1)}else o=1}else o=3,s=1;let c=t.readBits(16),l=t.readBits(16),u=(c+1)*(l+1),d=Rn(z).level;for(let e of z)if(u<=e.maxPictureSize){d=e.level;break}let f=Pi[a],p=f?.colourPrimaries??2,m=f?.transferCharacteristics??2,h=f?.matrixCoefficients??2;return{profile:r,level:d,bitDepth:i,chromaSubsampling:o,videoFullRangeFlag:s,colourPrimaries:p,transferCharacteristics:m,matrixCoefficients:h}},Ii=function*(e){let t=new qr(e),n=()=>{let e=0;for(let n=0;n<8;n++){let r=t.readAlignedByte();if(e+=(r&127)*2**(n*7),!(r&128))break;if(n===7&&r&128)return null}return e>2**32-1?null:e};for(;t.getBitsLeft()>=8;){t.skipBits(1);let r=t.readBits(4),i=t.readBits(1),a=t.readBits(1);t.skipBits(1),i&&t.skipBits(8);let o;if(a){let e=n();if(e===null)return;o=e}else o=Math.floor(t.getBitsLeft()/8);F(t.pos%8==0),yield{type:r,data:e.subarray(t.pos/8,t.pos/8+o)},t.skipBits(o*8)}},Li=e=>{for(let{type:t,data:n}of Ii(e)){if(t!==1)continue;let e=new qr(n),r=e.readBits(3);e.readBits(1);let i=e.readBits(1),a=0,o=0,s=0;if(i)a=e.readBits(5);else{let t=e.readBits(1),n=0;if(t){if(e.skipBits(32),e.skipBits(32),e.readBits(1)){let t=0;for(;t<32&&!e.readBits(1);)t++;t<32&&e.skipBits(t)}n=e.readBits(1),n&&(s=e.readBits(5),e.skipBits(32),e.skipBits(5),e.skipBits(5))}let r=e.readBits(1),i=e.readBits(5);for(let t=0;t<=i;t++){e.skipBits(12);let i=e.readBits(5);if(t===0&&(a=i),i>7){let n=e.readBits(1);t===0&&(o=n)}if(n&&e.readBits(1)){let t=s+1;e.skipBits(t),e.skipBits(t),e.skipBits(1)}r&&e.readBits(1)&&e.skipBits(4)}}let c=e.readBits(4),l=e.readBits(4),u=c+1;e.skipBits(u);let d=l+1;e.skipBits(d);let f=0;if(f=i?0:e.readBits(1),f&&(e.skipBits(4),e.skipBits(3)),e.skipBits(1),e.skipBits(1),e.skipBits(1),!i){e.skipBits(1),e.skipBits(1),e.skipBits(1),e.skipBits(1);let t=e.readBits(1);t&&(e.skipBits(1),e.skipBits(1));let n=e.readBits(1),r=0;r=n?2:e.readBits(1),r>0&&(e.readBits(1)||e.skipBits(1)),t&&e.skipBits(3)}e.skipBits(1),e.skipBits(1),e.skipBits(1);let p=e.readBits(1),m=8;r===2&&p?m=e.readBits(1)?12:10:r<=2&&(m=p?10:8);let h=0;r!==1&&(h=e.readBits(1));let g=2,_=2,v=2;e.readBits(1)&&(g=e.readBits(8),_=e.readBits(8),v=e.readBits(8));let y=0,b=1,x=1,S=0;return h?y=e.readBits(1):g===1&&_===13&&v===0?(y=1,b=0,x=0):(y=e.readBits(1),r===0?(b=1,x=1):r===1?(b=0,x=0):m===12?(b=e.readBits(1),x=b?e.readBits(1):0):(b=1,x=0),b&&x&&(S=e.readBits(2))),{profile:r,level:a,tier:o,bitDepth:m,monochrome:h,chromaSubsamplingX:b,chromaSubsamplingY:x,chromaSamplePosition:S,videoFullRangeFlag:y,colourPrimaries:g,transferCharacteristics:_,matrixCoefficients:v}}return null},Ri=e=>e.colourPrimaries!==2||e.transferCharacteristics!==2||e.matrixCoefficients!==2,zi=e=>{if(e.byteLength<19)throw Error(`Invalid Opus identification header: too short.`);let t=Wn(e),n=t.getUint8(9),r=t.getUint16(10,!0),i=t.getUint32(12,!0),a=t.getInt16(16,!0),o=t.getUint8(18),s=null;return o&&(s=e.subarray(19,21+n)),{outputChannelCount:n,preSkip:r,inputSampleRate:i,outputGain:a,channelMappingFamily:o,channelMappingTable:s}},Bi=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960],Vi=e=>{let t=e[0]>>3,n=e[0]&3,r;return r=n===0?1:n===1||n===2?2:e[1]&63,{durationInSamples:Bi[t]*r}},Hi=(e,t,n)=>{switch(e){case`avc`:for(let e of di(n,t)){let t=n[e.offset],r=fi(t);if(r>=si.NON_IDR_SLICE&&r<=si.SLICE_DPC)return`delta`;if(r===si.IDR)return`key`;if(r===si.SEI&&!Sr()){let t=pi(n.subarray(e.offset,e.offset+e.length)),r=1;do{let e=0;for(;;){let n=t[r++];if(n===void 0||(e+=n,n<255))break}let n=0;for(;;){let e=t[r++];if(e===void 0||(n+=e,e<255))break}if(e===6){let e=new qr(t);e.pos=8*r;let n=-1;try{n=I(e)}catch{}let i=e.readBits(1);if(n===0&&i===1)return`key`}r+=n}while(r<t.length-1)}}return`delta`;case`hevc`:for(let e of xi(n,t)){let t=Si(n[e.offset]);if(t<ci.BLA_W_LP)return`delta`;if(t<=ci.RSV_IRAP_VCL23)return`key`}return`delta`;case`vp8`:return n[0]&1?`delta`:`key`;case`vp9`:{let e=new qr(n);if(e.readBits(2)!==2)return null;let t=e.readBits(1);return(e.readBits(1)<<1)+t===3&&e.skipBits(1),e.readBits(1)?null:e.readBits(1)===0?`key`:`delta`}case`av1`:{let e=!1;for(let{type:t,data:r}of Ii(n))if(t===1){let t=new qr(r);t.skipBits(4),e=!!t.readBits(1)}else if(t===3||t===6||t===7){if(e)return`key`;let t=new qr(r);return t.readBits(1)?null:t.readBits(2)===0?`key`:`delta`}return null}case`prores`:return`key`;default:rr(e),F(!1)}},Ui=(e,t)=>e===`truehd`?(t.byteLength>=8?Wn(t).getUint32(4):null)===4168249274?`key`:`delta`:`key`,Wi;(function(e){e[e.STREAMINFO=0]=`STREAMINFO`,e[e.VORBIS_COMMENT=4]=`VORBIS_COMMENT`,e[e.PICTURE=6]=`PICTURE`})(Wi||={});var Gi=e=>{if(e.length<7||e[0]!==11||e[1]!==119)return null;let t=new qr(e);t.skipBits(16),t.skipBits(16);let n=t.readBits(2);if(n===3)return null;let r=t.readBits(6),i=t.readBits(5);if(i>8)return null;let a=t.readBits(3),o=t.readBits(3);return o&1&&o!==1&&t.skipBits(2),o&4&&t.skipBits(2),o===2&&t.skipBits(2),{fscod:n,bsid:i,bsmod:a,acmod:o,lfeon:t.readBits(1),bitRateCode:Math.floor(r/2)}};new Uint8Array([5,4,65,67,45,51]),new Uint8Array([5,4,69,65,67,51]);var Ki=[1,2,3,6],qi=e=>{if(e.length<6||e[0]!==11||e[1]!==119)return null;let t=new qr(e);t.skipBits(16);let n=t.readBits(2);if(t.skipBits(3),n!==0&&n!==2)return null;let r=t.readBits(11),i=t.readBits(2),a=0,o;i===3?(a=t.readBits(2),o=3):o=t.readBits(2);let s=t.readBits(3),c=t.readBits(1),l=t.readBits(5);if(l<11||l>16)return null;let u=Ki[o],d;return d=i<3?ii[i]/1e3:ai[a]/1e3,{dataRate:Math.round((r+1)*d/(u*16)),substreams:[{fscod:i,fscod2:a,bsid:l,bsmod:0,acmod:s,lfeon:c,numDepSub:0,chanLoc:0}]}},Ji=8,Yi=[0,8e3,16e3,32e3,0,0,11025,22050,44100,0,0,12e3,24e3,48e3,96e3,192e3],Xi=[32e3,56e3,64e3,96e3,112e3,128e3,192e3,224e3,256e3,32e4,384e3,448e3,512e3,576e3,64e4,768e3,96e4,1024e3,1152e3,128e4,1344e3,1408e3,1411200,1472e3,1536e3,192e4,2048e3,3072e3,384e4,0,0,0],Zi=[16,16,20,20,0,24,24,0],Qi=[1,2,2,2,2,3,3,4,4,5,6,6,6,7,8,8],$i=[1,2,2,2,2,3,18,19,6,7,518,323,83,519,582,535],ea=8,ta=[32e3,44100,48e3,0],na=[8e3,16e3,32e3,64e3,128e3,22050,44100,88200,176400,352800,12e3,24e3,48e3,96e3,192e3,384e3],ra=[512,1024,2048,4096],ia=e=>{let t=L(e),n=Wn(e),r=t?Math.ceil(t.frameSize/4)*4:0,i=null;for(;r+4<=e.length&&n.getUint32(r)===1683496997;){let t=aa(e.subarray(r));if(!t)break;i??=t,r+=t.frameSize}if(t)return{frameSize:i?r:t.frameSize,sampleRate:t.sampleRate,numberOfChannels:t.numberOfChannels,sampleCount:t.sampleCount,channelLayout:t.channelLayout,pcmResolution:t.pcmResolution,bitRate:t.bitRate,core:t,hasExtensions:i!==null};if(!i?.asset)return null;let{asset:a}=i;return{frameSize:r,sampleRate:a.sampleRate,numberOfChannels:a.numberOfChannels,sampleCount:a.sampleCount,channelLayout:a.channelLayout,pcmResolution:a.pcmResolution,bitRate:0,core:null,hasExtensions:!0}},L=e=>{if(e.length<18||e[0]!==127||e[1]!==254||e[2]!==128||e[3]!==1)return null;let t=new qr(e);if(t.skipBits(32),t.skipBits(1),t.readBits(5)!==31)return null;let n=t.readBits(1),r=t.readBits(7)+1;if(r%Ji!==0)return null;let i=t.readBits(14)+1;if(i<96)return null;let a=t.readBits(6);if(a>=Qi.length)return null;let o=Yi[t.readBits(4)];if(o===0)return null;let s=Xi[t.readBits(5)];if(t.readBits(1)!==0)return null;t.skipBits(4),t.skipBits(5);let c=t.readBits(2);if(c===3)return null;t.skipBits(1),n&&t.skipBits(16),t.skipBits(7);let l=Zi[t.readBits(3)];if(l===0)return null;let u=c!==0;return{frameSize:i,sampleRate:o,numberOfChannels:Qi[a]+ +!!u,sampleCount:r*32,channelLayout:$i[a]|(u?ea:0),amode:a,lfePresent:u,bitRate:s,pcmResolution:l}},aa=e=>{if(e.length<10||e[0]!==100||e[1]!==88||e[2]!==32||e[3]!==37)return null;let t=new qr(e);t.skipBits(32),t.skipBits(8);let n=t.readBits(2),r=t.readBits(1),i=8+4*r,a=16+4*r;t.skipBits(i);let o=t.readBits(a)+1,s={frameSize:o,asset:null};if(!t.readBits(1))return s;let c=ta[t.readBits(2)],l=512*(t.readBits(3)+1);t.readBits(1)&&t.skipBits(36);let u=t.readBits(3)+1,d=t.readBits(3)+1,f=[];for(let e=0;e<u;e++)f.push(t.readBits(n+1));for(let e of f)t.skipBits(8*dr(e));if(t.readBits(1)){t.skipBits(2);let e=t.readBits(2)+1<<2,n=t.readBits(2)+1;t.skipBits(n*e)}for(let e=0;e<d;e++)t.skipBits(a);t.skipBits(9),t.skipBits(3),t.readBits(1)&&t.skipBits(4),t.readBits(1)&&t.skipBits(24),t.readBits(1)&&t.skipBits(8*(t.readBits(10)+1));let p=t.readBits(5)+1,m=na[t.readBits(4)],h=t.readBits(8)+1,g=0;if(t.readBits(1)&&(h>2&&t.skipBits(1),h>6&&t.skipBits(1),t.readBits(1))){let e=t.readBits(2)+1<<2;g=t.readBits(e)}return c===0||t.getBitsLeft()<0?s:{frameSize:o,asset:{sampleRate:m,numberOfChannels:h,sampleCount:Math.round(l*m/c),channelLayout:g,pcmResolution:p}}},oa=e=>{let t=new Uint8Array(20),n=Wn(t);n.setUint32(0,e.sampleRate),n.setUint32(4,e.bitRate),n.setUint32(8,e.bitRate),t[12]=e.pcmResolution;let r=e.core&&!e.hasExtensions?1:0,i=new qr(t);return i.seekToByte(13),i.writeBits(2,Math.max(ra.indexOf(e.sampleCount),0)),i.writeBits(5,r),i.writeBits(1,+!!e.core?.lfePresent),i.writeBits(6,e.core?.amode??0),i.writeBits(14,e.core?e.core.frameSize-1:0),i.writeBits(1,0),i.writeBits(3,0),i.writeBits(16,e.channelLayout),i.writeBits(1,0),i.writeBits(1,0),i.writeBits(1,0),i.writeBits(5,0),t},sa=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,ca=/(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})/,la=e=>{let t=ca.exec(e);if(!t)throw Error(`Expected match.`);return 36e5*Number(t[1]||`0`)+6e4*Number(t[2])+1e3*Number(t[3])+Number(t[4])},ua=e=>{let t=Math.floor(e/36e5),n=Math.floor(e%36e5/6e4),r=Math.floor(e%6e4/1e3),i=e%1e3;return t.toString().padStart(2,`0`)+`:`+n.toString().padStart(2,`0`)+`:`+r.toString().padStart(2,`0`)+`.`+i.toString().padStart(3,`0`)},da=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},fa=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});Mr();var pa=-1/0,ma=-1/0,ha=null;typeof FinalizationRegistry<`u`&&(ha=new FinalizationRegistry(e=>{let t=performance.now();e.type===`video`?(t-pa>=1e3&&(Hr._error(`A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them.`),pa=t),typeof VideoFrame<`u`&&e.data instanceof VideoFrame&&e.data.close()):(t-ma>=1e3&&(Hr._error(`An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them.`),ma=t),typeof AudioData<`u`&&e.data instanceof AudioData&&e.data.close())}));var ga=class{constructor(){this._referenceCount=0,this._lastAllocationBuffer=null}},_a=[`I420`,`I420P10`,`I420P12`,`I420A`,`I420AP10`,`I420AP12`,`I422`,`I422P10`,`I422P12`,`I422A`,`I422AP10`,`I422AP12`,`I444`,`I444P10`,`I444P12`,`I444A`,`I444AP10`,`I444AP12`,`NV12`,`RGBA`,`RGBX`,`BGRA`,`BGRX`],va=new Set(_a),ya=class e{get codedWidth(){return this.visibleRect.width}get codedHeight(){return this.visibleRect.height}get displayWidth(){return this.rotation%180==0?this.squarePixelWidth:this.squarePixelHeight}get displayHeight(){return this.rotation%180==0?this.squarePixelHeight:this.squarePixelWidth}get microsecondTimestamp(){return Math.trunc(mr*this.timestamp)}get microsecondDuration(){return Math.trunc(mr*this.duration)}get hasAlpha(){return this.format&&this.format.includes(`A`)}constructor(t,n){if(this._closed=!1,t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer||ArrayBuffer.isView(t)){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.format===void 0||!va.has(n.format))throw TypeError(`init.format must be one of: `+_a.join(`, `));if(!Number.isInteger(n.codedWidth)||n.codedWidth<=0)throw TypeError(`init.codedWidth must be a positive integer.`);if(!Number.isInteger(n.codedHeight)||n.codedHeight<=0)throw TypeError(`init.codedHeight must be a positive integer.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n.flip!==void 0&&typeof n.flip!=`boolean`)throw TypeError(`init.flip, when provided, must be a boolean.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(n.layout!==void 0){if(!Array.isArray(n.layout))throw TypeError(`init.layout, when provided, must be an array.`);for(let e of n.layout){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`Each entry in init.layout must be an object.`);if(!Number.isInteger(e.offset)||e.offset<0)throw TypeError(`plane.offset must be a non-negative integer.`);if(!Number.isInteger(e.stride)||e.stride<0)throw TypeError(`plane.stride must be a non-negative integer.`)}}if(n.visibleRect!==void 0&&Ir(n.visibleRect,`init.visibleRect`),n.displayWidth!==void 0&&(!Number.isInteger(n.displayWidth)||n.displayWidth<=0))throw TypeError(`init.displayWidth, when provided, must be a positive integer.`);if(n.displayHeight!==void 0&&(!Number.isInteger(n.displayHeight)||n.displayHeight<=0))throw TypeError(`init.displayHeight, when provided, must be a positive integer.`);if(n.displayWidth!==void 0!=(n.displayHeight!==void 0))throw TypeError(`init.displayWidth and init.displayHeight must be either both provided or both omitted.`);this.format=n.format,this.rotation=n.rotation??0,this.flip=n.flip??!1,this.timestamp=n.timestamp,this.duration=n.duration??0;let e=n.layout??Aa(n.format,n.codedWidth,n.codedHeight),r=n.colorSpace??null;r===null&&(r=this.format===`RGBA`||this.format===`RGBX`||this.format===`BGRA`||this.format===`BGRX`?{primaries:`bt709`,transfer:`iec61966-2-1`,matrix:`rgb`,fullRange:!0}:{primaries:`bt709`,transfer:`bt709`,matrix:`bt709`,fullRange:!1}),this.visibleRect={left:n.visibleRect?.left??0,top:n.visibleRect?.top??0,width:n.visibleRect?.width??n.codedWidth,height:n.visibleRect?.height??n.codedHeight},n.displayWidth===void 0?(this.squarePixelWidth=this.visibleRect.width,this.squarePixelHeight=this.visibleRect.height):(this.squarePixelWidth=this.rotation%180==0?n.displayWidth:n.displayHeight,this.squarePixelHeight=this.rotation%180==0?n.displayHeight:n.displayWidth),this._data=n._doNotCopy?Un(t):Un(t).slice(),this._layout=e,this.colorSpace=new Ta(r)}else if(typeof VideoFrame<`u`&&t instanceof VideoFrame){if(n?.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n?.flip!==void 0&&typeof n.flip!=`boolean`)throw TypeError(`init.flip, when provided, must be a boolean.`);if(n?.timestamp!==void 0&&!Number.isFinite(n?.timestamp))throw TypeError(`init.timestamp, when provided, must be a number.`);if(n?.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);n?.visibleRect!==void 0&&Ir(n.visibleRect,`init.visibleRect`),this._data=t,this._layout=null,this.format=t.format,this.visibleRect={left:t.visibleRect?.x??0,top:t.visibleRect?.y??0,width:t.visibleRect?.width??t.codedWidth,height:t.visibleRect?.height??t.codedHeight},this.rotation=n?.rotation??0,this.flip=n?.flip??!1,this.squarePixelWidth=t.displayWidth,this.squarePixelHeight=t.displayHeight,this.timestamp=n?.timestamp??t.timestamp/1e6,this.duration=n?.duration??(t.duration??0)/1e6;let{primaries:e,transfer:r,matrix:i,fullRange:a}=t.colorSpace;this.colorSpace=new Ta({primaries:e!==null&&e in qn?e:null,transfer:r!==null&&r in Jn?r:null,matrix:i!==null&&i in Yn?i:null,fullRange:a})}else if(typeof HTMLImageElement<`u`&&t instanceof HTMLImageElement||typeof SVGImageElement<`u`&&t instanceof SVGImageElement||typeof ImageBitmap<`u`&&t instanceof ImageBitmap||typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement||typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n.flip!==void 0&&typeof n.flip!=`boolean`)throw TypeError(`init.flip, when provided, must be a boolean.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(n.visibleRect!==void 0&&Ir(n.visibleRect,`init.visibleRect`),typeof VideoFrame<`u`)return new e(new VideoFrame(t,{timestamp:Math.trunc(n.timestamp*mr),duration:Math.trunc((n.duration??0)*mr)||void 0,visibleRect:n.visibleRect&&{x:n.visibleRect.left,y:n.visibleRect.top,width:n.visibleRect.width,height:n.visibleRect.height}}),n);let r=0,i=0;if(`naturalWidth`in t?(r=t.naturalWidth,i=t.naturalHeight):`videoWidth`in t?(r=t.videoWidth,i=t.videoHeight):`width`in t&&(r=Number(t.width),i=Number(t.height)),!r||!i)throw TypeError(`Could not determine dimensions.`);let a=n.visibleRect??{left:0,top:0,width:r,height:i},o=new OffscreenCanvas(a.width,a.height),s=o.getContext(`2d`,{alpha:br(),willReadFrequently:!0});if(!s)throw Error(`OffscreenCanvas must have support for the '2d' context in order to create a VideoSample from this data.`);s.drawImage(t,-a.left,-a.top),this._data=o,this._layout=null,this.format=`RGBX`,this.visibleRect={left:0,top:0,width:a.width,height:a.height},this.squarePixelWidth=a.width,this.squarePixelHeight=a.height,this.rotation=n.rotation??0,this.flip=n.flip??!1,this.timestamp=n.timestamp,this.duration=n.duration??0,this.colorSpace=new Ta({matrix:`rgb`,primaries:`bt709`,transfer:`iec61966-2-1`,fullRange:!0})}else if(t instanceof ga){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n.flip!==void 0&&typeof n.flip!=`boolean`)throw TypeError(`init.flip, when provided, must be a boolean.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(this._data=t,t._referenceCount++,this.format=t.getFormat(),this.format!==null&&!_a.includes(this.format))throw TypeError(`getFormat() must return a VideoSamplePixelFormat or null.`);if(this.visibleRect={left:0,top:0,width:t.getCodedWidth(),height:t.getCodedHeight()},!Number.isInteger(this.visibleRect.width)||this.visibleRect.width<=0)throw TypeError(`getCodedWidth() must return a positive integer.`);if(!Number.isInteger(this.visibleRect.height)||this.visibleRect.height<=0)throw TypeError(`getCodedHeight() must return a positive integer.`);if(this.squarePixelWidth=t.getSquarePixelWidth(),!Number.isInteger(this.squarePixelWidth)||this.squarePixelWidth<=0)throw TypeError(`getSquarePixelWidth() must return a positive integer.`);if(this.squarePixelHeight=t.getSquarePixelHeight(),!Number.isInteger(this.squarePixelHeight)||this.squarePixelHeight<=0)throw TypeError(`getSquarePixelHeight() must return a positive integer.`);this.rotation=n.rotation??0,this.flip=n.flip??!1,this.timestamp=n.timestamp,this.duration=n.duration??0,this.colorSpace=t.getColorSpace()}else throw TypeError(`Invalid data type: Must be a BufferSource, CanvasImageSource, or VideoSampleResource.`);this.encodeOptions=n?.encodeOptions??{},this.pixelAspectRatio=Fr({num:this.squarePixelWidth*this.codedHeight,den:this.squarePixelHeight*this.codedWidth}),ha?.register(this,{type:`video`,data:this._data},this)}clone(){if(this._closed)throw Error(`VideoSample is closed.`);return F(this._data!==null),this._data instanceof ga?new e(this._data,{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,flip:this.flip,encodeOptions:this.encodeOptions}):Ea(this._data)?new e(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,flip:this.flip,encodeOptions:this.encodeOptions}):this._data instanceof Uint8Array?(F(this._layout),new e(this._data,{format:this.format,layout:this._layout,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation,flip:this.flip,visibleRect:this.visibleRect,displayWidth:this.displayWidth,displayHeight:this.displayHeight,encodeOptions:this.encodeOptions,_doNotCopy:!0})):new e(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation,flip:this.flip,visibleRect:this.visibleRect,displayWidth:this.displayWidth,displayHeight:this.displayHeight,encodeOptions:this.encodeOptions})}close(){this._closed||=(ha?.unregister(this),this._data instanceof ga?(this._data._referenceCount--,this._data._referenceCount===0&&this._data.close()):Ea(this._data)?this._data.close():this._data=null,!0)}allocationSize(e={}){if(ka(e),this._closed)throw Error(`VideoSample is closed.`);if((e.format??this.format)==null)throw Error(`Cannot get allocation size when format is null.`);return Ea(this._data)?this._data.allocationSize(e):Ma(this,e).allocationSize}async copyTo(t,n={}){if(!Zn(t))throw TypeError(`destination must be an ArrayBuffer or an ArrayBuffer view.`);if(ka(n),this._closed)throw Error(`VideoSample is closed.`);if((n.format??this.format)==null)throw Error(`Cannot copy video sample data when format is null.`);if(F(this._data!==null),Ea(this._data))return this._data.copyTo(t,n);if(n.format&&![`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(this.format)&&[`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(n.format)){if(this._data instanceof ga){let r={stack:[],error:void 0,hasError:!1};try{let i=da(r,await this._data.toRgbSample({timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,flip:this.flip},n.colorSpace??`srgb`),!1);if(!(i instanceof e))throw TypeError(`toRgbSample() must return a VideoSample.`);if(![`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(i.format))throw Error(`Sample returned by toRgbSample was expected to have an RGB format, got '${i.format}' instead.`);return await i.copyTo(t,n)}catch(e){r.error=e,r.hasError=!0}finally{fa(r)}}else{if(typeof VideoFrame>`u`)throw Error(`For this sample, converting from a non-RGB to an RGB format requires VideoFrame to be defined.`);let e=this.toVideoFrame(),r=await e.copyTo(t,n);return e.close(),r}}let r=Ma(this,n);F(this.format);let i=Un(t);if(i.byteLength<r.allocationSize)throw TypeError(`Destination buffer too small. Required: ${r.allocationSize}, Available: ${i.byteLength}`);let a=ja(this.format),o;if(this._data instanceof ga){let e=this._data.getDataPlanes();if(Or(e)&&(e=await e),!Array.isArray(e)||e.some(e=>!(e.data instanceof Uint8Array)||!Number.isInteger(e.stride)||e.stride<0))throw TypeError(`getDataPlanes() must return an array of objects with a Uint8Array "data" property and a non-negative integer "stride" property.`);o=e}else if(this._data instanceof Uint8Array)F(this._layout),F(this._layout.length===a.length),o=this._layout.map((e,t)=>{let n=Math.ceil(this.codedHeight/a[t].heightDivisor);return{data:this._data.subarray(e.offset,e.offset+e.stride*n),stride:e.stride}});else{let e=this._data.getContext(`2d`);F(e),o=[{data:Un(e.getImageData(0,0,this.codedWidth,this.codedHeight).data),stride:4*this.codedWidth}]}let s=[],c=a.length;for(let e=0;e<c;e++){let t=r.computedLayouts[e],n=o[e].stride,a=o[e].data,c=t.sourceTop*n;c+=t.sourceLeftBytes;let l=t.destinationOffset,u=t.sourceWidthBytes,d={offset:l,stride:t.destinationStride};for(let e=0;e<t.sourceHeight;e++){if(c+u>a.byteLength)throw Error(`Source buffer OOB read.`);if(l+u>i.byteLength)throw Error(`Destination buffer OOB write.`);let e=a.subarray(c,c+u);i.set(e,l),c+=n,l+=t.destinationStride}s.push(d)}if(n.format!==void 0){let e=this.format.startsWith(`RGB`)!==n.format.startsWith(`RGB`),t=this.format.includes(`X`)&&n.format.includes(`A`);if(e||t)for(let n=0;n<r.allocationSize;n+=4){if(e){let e=i[n],t=i[n+2];i[n]=t,i[n+2]=e}t&&(i[n+3]=255)}}return s}toVideoFrame(){if(this._closed)throw Error(`VideoSample is closed.`);if(F(this._data!==null),this._data instanceof ga){if(this.format===null)throw Error(`Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if format is null.`);let e=this._data.getDataPlanes();if(Or(e))throw Error(`Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if getDataPlanes() returns a promise.`);let t=e.reduce((e,t)=>e+t.data.byteLength,0),n=new Uint8Array(t),r=0,i=[];for(let t of e)n.set(t.data,r),i.push(r),r+=t.data.byteLength;return new VideoFrame(n,{format:this.format,layout:e.map((e,t)=>({offset:i[t],stride:e.stride})),codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration,colorSpace:this.colorSpace,visibleRect:this.visibleRect,displayWidth:this.squarePixelWidth,displayHeight:this.squarePixelHeight})}return Ea(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?(F(this._layout),new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,layout:this._layout,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace,visibleRect:this.visibleRect,displayWidth:this.squarePixelWidth,displayHeight:this.squarePixelHeight})):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,n,r,i,a,o,s,c){let l=0,u=0,d=this.displayWidth,f=this.displayHeight,p=0,m=0,h=this.displayWidth,g=this.displayHeight;if(a===void 0?(p=t,m=n,r!==void 0&&(h=r,g=i)):(l=t,u=n,d=r,f=i,p=a,m=o,s===void 0?(h=d,g=f):(h=s,g=c)),!(typeof CanvasRenderingContext2D<`u`&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<`u`&&e instanceof OffscreenCanvasRenderingContext2D))throw TypeError(`context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.`);if(!Number.isFinite(l))throw TypeError(`sx must be a number.`);if(!Number.isFinite(u))throw TypeError(`sy must be a number.`);if(!Number.isFinite(d)||d<0)throw TypeError(`sWidth must be a non-negative number.`);if(!Number.isFinite(f)||f<0)throw TypeError(`sHeight must be a non-negative number.`);if(!Number.isFinite(p))throw TypeError(`dx must be a number.`);if(!Number.isFinite(m))throw TypeError(`dy must be a number.`);if(!Number.isFinite(h)||h<0)throw TypeError(`dWidth must be a non-negative number.`);if(!Number.isFinite(g)||g<0)throw TypeError(`dHeight must be a non-negative number.`);if(this._closed)throw Error(`VideoSample is closed.`);({sx:l,sy:u,sWidth:d,sHeight:f}=this._unmapSourceRegion(l,u,d,f,this.rotation,this.flip));let _=this.toCanvasImageSource();e.save();let v=p+h/2,y=m+g/2;e.translate(v,y),this.flip&&e.scale(-1,1),e.rotate(this.rotation*Math.PI/180);let b=this.rotation%180==0?1:h/g;e.scale(1/b,b),e.drawImage(_,l,u,d,f,-h/2,-g/2,h,g),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<`u`&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<`u`&&e instanceof OffscreenCanvasRenderingContext2D))throw TypeError(`context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.`);if(!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(![`fill`,`contain`,`cover`].includes(t.fit))throw TypeError(`options.fit must be 'fill', 'contain', or 'cover'.`);if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw TypeError(`options.rotation, when provided, must be 0, 90, 180, or 270.`);if(t.flip!==void 0&&typeof t.flip!=`boolean`)throw TypeError(`options.flip, when provided, must be a boolean.`);t.crop!==void 0&&Oa(t.crop,`options.`);let n=e.canvas.width,r=e.canvas.height,i=t.rotation??this.rotation,a=t.flip??this.flip,[o,s]=i%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth],c=t.crop;c&&=Da(c,o,s);let l,u,d,f,{sx:p,sy:m,sWidth:h,sHeight:g}=this._unmapSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??o,t.crop?.height??s,i,a);if(t.fit===`fill`)l=0,u=0,d=n,f=r;else{let[e,i]=t.crop?[t.crop.width,t.crop.height]:[o,s],a=t.fit===`contain`?Math.min(n/e,r/i):Math.max(n/e,r/i);d=e*a,f=i*a,l=(n-d)/2,u=(r-f)/2}e.save();let _=i%180==0?1:d/f;e.translate(n/2,r/2),a&&e.scale(-1,1),e.rotate(i*Math.PI/180),e.scale(1/_,_),e.translate(-n/2,-r/2),e.drawImage(this.toCanvasImageSource(),p,m,h,g,l,u,d,f),e.restore()}_unmapSourceRegion(e,t,n,r,i,a){return a&&(e=(i%180==0?this.squarePixelWidth:this.squarePixelHeight)-e-n),i===90?[e,t,n,r]=[t,this.squarePixelHeight-e-n,r,n]:i===180?[e,t]=[this.squarePixelWidth-e-n,this.squarePixelHeight-t-r]:i===270&&([e,t,n,r]=[this.squarePixelWidth-t-r,e,r,n]),{sx:e,sy:t,sWidth:n,sHeight:r}}_drawWithFitAndMipmapping(e,t,n){let r=e.width,i=e.height,[a,o]=n.rotation%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth],s=n.crop?n.crop.width:a,c=n.crop?n.crop.height:o,l=0;2*r<s&&2*i<c&&(l=Math.floor(Math.log2(Math.min(s/r,c/i))));let u=r*2**l,d=i*2**l,{canvas:f,context:p,isNew:m}=l>0?wa(u,d):{canvas:e,context:t,isNew:n.targetIsFresh};p.imageSmoothingQuality=`high`,n.fillBlack?(p.fillStyle=`black`,p.fillRect(0,0,u,d)):m||p.clearRect(0,0,u,d),this.drawWithFit(p,{fit:n.fit,rotation:n.rotation,flip:n.flip,crop:n.crop}),p.globalCompositeOperation=`copy`;for(let e=l;e>1;e--){let t=r*2**e,n=i*2**e;p.drawImage(f,0,0,t,n,0,0,t/2,n/2)}p.globalCompositeOperation=`source-over`,l>0&&(t.imageSmoothingQuality=`high`,t.globalCompositeOperation=`copy`,t.drawImage(f,0,0,2*r,2*i,0,0,r,i),t.globalCompositeOperation=`source-over`)}toCanvasImageSource(){if(this._closed)throw Error(`VideoSample is closed.`);if(F(this._data!==null),this._data instanceof ga||this._data instanceof Uint8Array){let e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}return this._data}async transform(t){if(!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(t.width!==void 0&&(!Number.isInteger(t.width)||t.width<=0))throw TypeError(`options.width, when provided, must be a positive integer.`);if(t.height!==void 0&&(!Number.isInteger(t.height)||t.height<=0))throw TypeError(`options.height, when provided, must be a positive integer.`);if(t.roundDimensionsTo!==void 0&&(!Number.isInteger(t.roundDimensionsTo)||t.roundDimensionsTo<=0))throw TypeError(`options.roundDimensionsTo, when provided, must be a positive integer.`);if(t.fit!==void 0&&![`fill`,`contain`,`cover`].includes(t.fit))throw TypeError(`options.fit, when provided, must be one of "fill", "contain", or "cover".`);if(t.width!==void 0&&t.height!==void 0&&t.fit===void 0)throw TypeError(`When both options.width and options.height are provided, options.fit must also be provided.`);if(t.rotate!==void 0&&![0,90,180,270].includes(t.rotate))throw TypeError(`options.rotate, when provided, must be 0, 90, 180 or 270.`);if(t.flip!==void 0&&typeof t.flip!=`boolean`)throw TypeError(`options.flip, when provided, must be a boolean.`);if(t.crop!==void 0&&Oa(t.crop,`options.`),t.alpha!==void 0&&![`keep`,`discard`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'keep' or 'discard'.`);let{rotation:n,flip:r}=Ln(this.rotation,this.flip,t.rotate??0,t.flip??!1),[i,a]=n%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth],o=t.crop;o&&=Da(o,i,a);let s=o?o.width:i,c=o?o.height:a,l=s/c,u,d;t.width!==void 0&&t.height===void 0?(u=t.width,d=u/l):t.width===void 0&&t.height!==void 0?(d=t.height,u=d*l):t.width!==void 0&&t.height!==void 0?(u=t.width,d=t.height):(u=s,d=c),u=cr(u,t.roundDimensionsTo??1),d=cr(d,t.roundDimensionsTo??1);let f={width:u,height:d,fit:t.fit??`fill`,rotation:n,flip:r,crop:o??{left:0,top:0,width:i,height:a},alpha:t.alpha??`keep`};for(let e of ba){let t=e(this,f);if(Or(t)&&(t=await t),t!==null)return t}let{canvas:p,context:m,isNew:h}=wa(f.width,f.height);return this._drawWithFitAndMipmapping(p,m,{fit:f.fit,rotation:f.rotation,flip:f.flip,crop:f.crop,targetIsFresh:h,fillBlack:f.alpha===`discard`}),new e(p,{timestamp:this.timestamp,duration:this.duration,rotation:0,flip:!1})}setRotation(e){if(![0,90,180,270].includes(e))throw TypeError(`newRotation must be 0, 90, 180, or 270.`);this.rotation=e}setFlip(e){if(typeof e!=`boolean`)throw TypeError(`newFlip must be a boolean.`);this.flip=e}setTimestamp(e){if(!Number.isFinite(e))throw TypeError(`newTimestamp must be a number.`);this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw TypeError(`newDuration must be a non-negative number.`);this.duration=e}setEncodeOptions(e){if(!e||typeof e!=`object`)throw TypeError(`newEncodeOptions must be an object.`);this.encodeOptions=e}[Symbol.dispose](){this.close()}},ba=[],xa=3,Sa=[],Ca=0,wa=(e,t)=>{for(let n of Sa)if(n.canvas.width===e&&n.canvas.height===t)return n.age=Ca++,{canvas:n.canvas,context:n.context,isNew:!1};let n;if(typeof OffscreenCanvas<`u`)n=new OffscreenCanvas(e,t);else{if(typeof window>`u`||typeof document>`u`)throw Error(`Cannot transform VideoSamples in this environment. Either run in an environment with OffscreenCanvas or HTMLCanvasElement, or supply a custom VideoSample transformer using registerVideoSampleTransformer().`);n=document.createElement(`canvas`),n.width=e,n.height=t}let r=n.getContext(`2d`,{alpha:!0,willReadFrequently:!1});if(!r)throw Error(`The '2d' canvas context is required to transform VideoSamples. Register a custom transformer using registerVideoSampleTransformer to work around this limitation.`);return Sa.length>=xa&&Sa.splice(Pr(Sa,e=>e.age),1),Sa.push({canvas:n,context:r,age:Ca++}),{canvas:n,context:r,isNew:!0}},Ta=class{constructor(e){if(e!==void 0){if(!e||typeof e!=`object`)throw TypeError(`init.colorSpace, when provided, must be an object.`);let t=Object.keys(qn);if(e.primaries!=null&&!t.includes(e.primaries))throw TypeError(`init.colorSpace.primaries, when provided, must be one of ${t.join(`, `)}.`);let n=Object.keys(Jn);if(e.transfer!=null&&!n.includes(e.transfer))throw TypeError(`init.colorSpace.transfer, when provided, must be one of ${n.join(`, `)}.`);let r=Object.keys(Yn);if(e.matrix!=null&&!r.includes(e.matrix))throw TypeError(`init.colorSpace.matrix, when provided, must be one of ${r.join(`, `)}.`);if(e.fullRange!=null&&typeof e.fullRange!=`boolean`)throw TypeError(`init.colorSpace.fullRange, when provided, must be a boolean.`)}this.primaries=e?.primaries??null,this.transfer=e?.transfer??null,this.matrix=e?.matrix??null,this.fullRange=e?.fullRange??null}toJSON(){return{primaries:this.primaries,transfer:this.transfer,matrix:this.matrix,fullRange:this.fullRange}}},Ea=e=>typeof VideoFrame<`u`&&e instanceof VideoFrame,Da=(e,t,n)=>{let r=Math.min(e.left,t),i=Math.min(e.top,n),a=Math.min(e.width,t-r),o=Math.min(e.height,n-i);return F(a>=0),F(o>=0),{left:r,top:i,width:a,height:o}},Oa=(e,t)=>{if(!e||typeof e!=`object`)throw TypeError(t+`crop, when provided, must be an object.`);if(!Number.isInteger(e.left)||e.left<0)throw TypeError(t+`crop.left must be a non-negative integer.`);if(!Number.isInteger(e.top)||e.top<0)throw TypeError(t+`crop.top must be a non-negative integer.`);if(!Number.isInteger(e.width)||e.width<0)throw TypeError(t+`crop.width must be a non-negative integer.`);if(!Number.isInteger(e.height)||e.height<0)throw TypeError(t+`crop.height must be a non-negative integer.`)},ka=e=>{if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.colorSpace!==void 0&&![`display-p3`,`srgb`].includes(e.colorSpace))throw TypeError(`options.colorSpace, when provided, must be 'display-p3' or 'srgb'.`);if(e.format!==void 0&&typeof e.format!=`string`)throw TypeError(`options.format, when provided, must be a string.`);if(e.layout!==void 0){if(!Array.isArray(e.layout))throw TypeError(`options.layout, when provided, must be an array.`);for(let t of e.layout){if(!t||typeof t!=`object`)throw TypeError(`Each entry in options.layout must be an object.`);if(!Number.isInteger(t.offset)||t.offset<0)throw TypeError(`plane.offset must be a non-negative integer.`);if(!Number.isInteger(t.stride)||t.stride<0)throw TypeError(`plane.stride must be a non-negative integer.`)}}if(e.rect!==void 0){if(!e.rect||typeof e.rect!=`object`)throw TypeError(`options.rect, when provided, must be an object.`);if(e.rect.x!==void 0&&(!Number.isInteger(e.rect.x)||e.rect.x<0))throw TypeError(`options.rect.x, when provided, must be a non-negative integer.`);if(e.rect.y!==void 0&&(!Number.isInteger(e.rect.y)||e.rect.y<0))throw TypeError(`options.rect.y, when provided, must be a non-negative integer.`);if(e.rect.width!==void 0&&(!Number.isInteger(e.rect.width)||e.rect.width<0))throw TypeError(`options.rect.width, when provided, must be a non-negative integer.`);if(e.rect.height!==void 0&&(!Number.isInteger(e.rect.height)||e.rect.height<0))throw TypeError(`options.rect.height, when provided, must be a non-negative integer.`)}},Aa=(e,t,n)=>{let r=ja(e),i=[],a=0;for(let e of r){let r=Math.ceil(t/e.widthDivisor),o=Math.ceil(n/e.heightDivisor),s=r*e.sampleBytes,c=s*o;i.push({offset:a,stride:s}),a+=c}return i},ja=e=>{let t=(e,t,n,r,i)=>{let a=[{sampleBytes:e,widthDivisor:1,heightDivisor:1},{sampleBytes:t,widthDivisor:n,heightDivisor:r},{sampleBytes:t,widthDivisor:n,heightDivisor:r}];return i&&a.push({sampleBytes:e,widthDivisor:1,heightDivisor:1}),a};switch(e){case`I420`:return t(1,1,2,2,!1);case`I420P10`:case`I420P12`:return t(2,2,2,2,!1);case`I420A`:return t(1,1,2,2,!0);case`I420AP10`:case`I420AP12`:return t(2,2,2,2,!0);case`I422`:return t(1,1,2,1,!1);case`I422P10`:case`I422P12`:return t(2,2,2,1,!1);case`I422A`:return t(1,1,2,1,!0);case`I422AP10`:case`I422AP12`:return t(2,2,2,1,!0);case`I444`:return t(1,1,1,1,!1);case`I444P10`:case`I444P12`:return t(2,2,1,1,!1);case`I444A`:return t(1,1,1,1,!0);case`I444AP10`:case`I444AP12`:return t(2,2,1,1,!0);case`NV12`:return[{sampleBytes:1,widthDivisor:1,heightDivisor:1},{sampleBytes:2,widthDivisor:2,heightDivisor:2}];case`RGBA`:case`RGBX`:case`BGRA`:case`BGRX`:return[{sampleBytes:4,widthDivisor:1,heightDivisor:1}];default:rr(e),F(!1)}},Ma=(e,t)=>{let n={left:0,top:0,width:e.codedWidth,height:e.codedHeight},r=t.rect,i=Na(n,r,e.codedWidth,e.codedHeight,e.format),a=t.layout,o;if(!t.format||t.format===e.format)o=e.format;else if([`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(t.format))o=t.format;else throw Error(`NotSupportedError: Invalid destination format.`);return Fa(i,o,a)},Na=(e,t,n,r,i)=>{let a={...e};if(t!==void 0){if(t.width===0||t.height===0)throw TypeError(`visibleRect dimensions cannot be zero.`);if((t.x||0)+(t.width||0)>n)throw TypeError(`visibleRect exceeds codedWidth.`);if((t.y||0)+(t.height||0)>r)throw TypeError(`visibleRect exceeds codedHeight.`);a.x=t.x||0,a.y=t.y||0,a.width=t.width||0,a.height=t.height||0}if(!Pa(i,a))throw TypeError(`visibleRect alignment is invalid for the format.`);return a},Pa=(e,t)=>{if(e===null)return!0;let n=ja(e);for(let e=0;e<n.length;e++){let r=n[e],i=r.widthDivisor,a=r.heightDivisor;if((t.x||0)%i!==0||(t.y||0)%a!==0)return!1}return!0},Fa=(e,t,n)=>{let r=ja(t),i=r.length;if(n!==void 0&&n.length!==i)throw TypeError(`Layout must have ${i} planes.`);let a=0,o=[],s=[];for(let t=0;t<i;t++){let i=r[t],c=i.sampleBytes,l=i.widthDivisor,u=i.heightDivisor,d={destinationOffset:0,destinationStride:0,sourceTop:0,sourceHeight:0,sourceLeftBytes:0,sourceWidthBytes:0};if(d.sourceTop=Math.ceil(Math.trunc(e.y||0)/u),d.sourceHeight=Math.ceil(Math.trunc(e.height||0)/u),d.sourceLeftBytes=Math.floor(Math.trunc(e.x||0)/l)*c,d.sourceWidthBytes=Math.floor(Math.trunc(e.width||0)/l)*c,n!==void 0){let e=n[t];if(e.stride<d.sourceWidthBytes)throw TypeError(`Stride for plane ${t} is too small.`);d.destinationOffset=e.offset,d.destinationStride=e.stride}else d.destinationOffset=a,d.destinationStride=d.sourceWidthBytes;let f=d.destinationStride*d.sourceHeight+d.destinationOffset;if(f>4294967295)throw TypeError(`Allocation size exceeds limit.`);s.push(f),a=Math.max(a,f);for(let e=0;e<t;e++){let n=o[e];if(!(s[t]<=n.destinationOffset||s[e]<=d.destinationOffset))throw TypeError(`Planes overlap.`)}o.push(d)}return{allocationSize:a,computedLayouts:o}},Ia=new Map,La=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!Fo.includes(e.codec))throw TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${Fo.join(`, `)}.`);let t=e.bitrate;if(e.quality===void 0&&t===void 0)throw TypeError(`config.quality must be provided.`);if(e.quality!==void 0&&t!==void 0)throw TypeError(`config.quality and config.bitrate cannot both be provided.`);if(e.quality!==void 0&&!(e.quality instanceof Ba))throw TypeError(`config.quality, when provided, must be a Quality.`);if(t!==void 0&&!(t instanceof Ba)&&(!Number.isInteger(t)||t<=0))throw TypeError(`config.bitrate, when provided, must be a positive integer or a quality.`);if(e.keyFrameInterval!==void 0&&(!Number.isFinite(e.keyFrameInterval)||e.keyFrameInterval<0))throw TypeError(`config.keyFrameInterval, when provided, must be a non-negative number.`);if(e.sizeChangeBehavior!==void 0&&![`deny`,`passThrough`,`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.`);if(e.transform!==void 0){if(typeof e.transform!=`object`||!e.transform)throw TypeError(`config.transform, when provided, must be an object.`);if(e.transform.width!==void 0&&(!Number.isInteger(e.transform.width)||e.transform.width<=0))throw TypeError(`config.transform.width, when provided, must be a positive integer.`);if(e.transform.height!==void 0&&(!Number.isInteger(e.transform.height)||e.transform.height<=0))throw TypeError(`config.transform.height, when provided, must be a positive integer.`);if(e.transform.fit!==void 0&&![`fill`,`contain`,`cover`].includes(e.transform.fit))throw TypeError(`config.transform.fit, when provided, must be one of "fill", "contain", or "cover".`);if(e.transform.width!==void 0&&e.transform.height!==void 0&&e.transform.fit===void 0&&![`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`When both config.transform.width and config.transform.height are provided, config.transform.fit must also be provided.`);if(e.transform.fit!==void 0&&[`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior)&&e.transform.fit!==e.sizeChangeBehavior)throw TypeError(`config.transform.fit, when provided, cannot differ from config.sizeChangeBehavior when config.sizeChangeBehavior is 'fill', 'contain' or 'cover', as sizeChangeBehavior already determines the fitting algorithm.`);if(e.transform.rotate!==void 0&&![0,90,180,270].includes(e.transform.rotate))throw TypeError(`config.transform.rotate, when provided, must be 0, 90, 180 or 270.`);if(e.transform.flip!==void 0&&typeof e.transform.flip!=`boolean`)throw TypeError(`config.transform.flip, when provided, must be a boolean.`);if(e.transform.crop!==void 0&&Oa(e.transform.crop,`config.transform.`),e.transform.process!==void 0&&typeof e.transform.process!=`function`)throw TypeError(`config.transform.process, when provided, must be a function.`);if(e.transform.frameRate!==void 0&&(!Number.isFinite(e.transform.frameRate)||e.transform.frameRate<=0))throw TypeError(`config.transform.frameRate, when provided, must be a finite positive number.`);if(e.transform.force!==void 0&&typeof e.transform.force!=`boolean`)throw TypeError(`config.transform.force, when provided, must be a boolean.`)}if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedPacket, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);if(e.onEncodedSample!==void 0&&typeof e.onEncodedSample!=`function`)throw TypeError(`config.onEncodedSample, when provided, must be a function.`);Ra(e.codec,e)},Ra=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.alpha!==void 0&&![`discard`,`keep`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'discard' or 'keep'.`);let n=t.bitrateMode;if(n!==void 0&&![`constant`,`variable`].includes(n))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.latencyMode!==void 0&&![`quality`,`realtime`].includes(t.latencyMode))throw TypeError(`latencyMode, when provided, must be 'quality' or 'realtime'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&rs(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);if(t.hardwareAcceleration!==void 0&&![`no-preference`,`prefer-hardware`,`prefer-software`].includes(t.hardwareAcceleration))throw TypeError(`hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.`);if(t.scalabilityMode!==void 0&&typeof t.scalabilityMode!=`string`)throw TypeError(`scalabilityMode, when provided, must be a string.`);if(t.contentHint!==void 0&&typeof t.contentHint!=`string`)throw TypeError(`contentHint, when provided, must be a string.`)},za=e=>{let t=e.bitrateMode,n=e.quality._toVideoRateControl(e.codec,e.width,e.height,t),r=(t,n,r)=>({codec:e.fullCodecString??Jo(e.codec,e.width,e.height,r,e.alpha===`keep`),width:e.width,height:e.height,displayWidth:e.squarePixelWidth,displayHeight:e.squarePixelHeight,bitrate:t,bitrateMode:n,alpha:e.alpha??`discard`,framerate:e.framerate,latencyMode:e.latencyMode,hardwareAcceleration:e.hardwareAcceleration,scalabilityMode:e.scalabilityMode,contentHint:e.contentHint,...is(e.codec)}),i=[];return n.quantizer!==null&&i.push({config:r(void 0,`quantizer`,n.bitrate),quantizer:n.quantizer}),n.bitrateMode!==`quantizer`&&i.push({config:r(n.bitrate,n.bitrateMode,n.bitrate),quantizer:null}),F(i.length>0),i},Ba=class{constructor(e){if((typeof e==`number`||typeof e==`string`)&&(e={quality:e}),!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.bitrateMode!==void 0&&![`constant`,`variable`].includes(e.bitrateMode))throw TypeError(`options.bitrateMode, when provided, must be 'constant' or 'variable'.`);if(`quality`in e){if(typeof e.quality==`string`?!(e.quality in Va):typeof e.quality!=`number`||Number.isNaN(e.quality))throw TypeError(`options.quality must be a number, or one of 'very-low', 'low', 'medium', 'high' or 'very-high'.`);if(e.preferBitrate!==void 0&&typeof e.preferBitrate!=`boolean`)throw TypeError(`options.preferBitrate, when provided, must be a boolean.`);if(`bitrate`in e||`quantizer`in e)throw TypeError(`options.quality cannot be combined with options.bitrate or options.quantizer.`);this._quality=typeof e.quality==`string`?Va[e.quality]:e.quality,this._preferBitrate=e.preferBitrate??!1,this._bitrate=void 0,this._quantizer=void 0}else{if(e.bitrate!==void 0&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`options.bitrate, when provided, must be a positive integer.`);if(e.quantizer!==void 0&&(!Number.isInteger(e.quantizer)||e.quantizer<0))throw TypeError(`options.quantizer, when provided, must be a non-negative integer.`);if(e.bitrate===void 0&&e.quantizer===void 0)throw TypeError(`At least one of options.bitrate or options.quantizer must be set.`);if(`preferBitrate`in e)throw TypeError(`options.preferBitrate can only be combined with options.quality.`);this._quality=void 0,this._preferBitrate=!1,this._bitrate=e.bitrate,this._quantizer=e.quantizer}this._bitrateMode=e.bitrateMode}_toVideoRateControl(e,t,n,r){let i=Ha[e],a=null,o=this._bitrateMode??r??`variable`;if(this._quantizer!==void 0){if(!i){if(this._bitrate===void 0)throw Error(`Codec '${e}' does not support quantizer-based encoding. Provide a bitrate in the Quality to define a fallback.`)}else if(this._quantizer<i.min||this._quantizer>i.max){if(this._bitrate===void 0)throw Error(`Quantizer ${this._quantizer} is out of range for codec '${e}'; must be between ${i.min} and ${i.max}.`)}else a=this._quantizer,this._bitrate===void 0&&(o=`quantizer`)}else this._bitrate===void 0&&i&&!this._preferBitrate&&(F(this._quality!==void 0),a=or(Math.round(sr(i.worst,i.best,this._quality)),i.min,i.max));let s;if(this._bitrate!==void 0)s=this._bitrate;else{let r=this._quality;r===void 0&&(F(a!==null&&i),r=or((a-i.worst)/(i.best-i.worst),0,1)),s=Wa(e,t,n,Ua(r))}return{quantizer:a,bitrate:s,bitrateMode:o}}_toVideoBitrate(e,t,n){return this._bitrate===void 0?(F(this._quality!==void 0),Wa(e,t,n,Ua(this._quality))):this._bitrate}_toAudioBitrate(e){if(Io.includes(e)||e===`flac`||e===`truehd`)return;if(this._bitrate!==void 0)return this._bitrate;if(this._quality===void 0)throw Error(`This Quality defines neither a quality level nor a bitrate and therefore cannot be used for audio encoding.`);let t=Ua(this._quality),n={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3,ac3:384e3,eac3:192e3,dts:768e3}[e];if(!n)throw Error(`Unhandled codec: ${e}`);let r=n*t;return e===`aac`?r=[96e3,128e3,16e4,192e3].reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e):e===`opus`||e===`vorbis`?r=Math.max(6e3,r):e===`mp3`&&(r=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e)),Math.round(r/1e3)*1e3}},Va={"very-low":0,low:.25,medium:.5,high:.75,"very-high":1},Ha={avc:{min:0,max:51,worst:41,best:16},hevc:{min:0,max:51,worst:41,best:16},vp9:(wr()??1/0)<145?{min:0,max:63,worst:52,best:20}:{min:0,max:255,worst:208,best:80},av1:{min:0,max:255,worst:208,best:80}},Ua=e=>.3*Math.exp(2.5538*e),Wa=(e,t,n,r)=>{let i=t*n,a=3e6,o=a*(i/2073600)**.95*{avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2,prores:22e7/a}[e]*r;return Math.ceil(o/1e3)*1e3},Ga=(e,t)=>{if(e===`avc`)return{avc:{quantizer:t}};if(e===`hevc`)return{hevc:{quantizer:t}};if(e===`vp9`)return{vp9:{quantizer:t}};if(e===`av1`)return{av1:{quantizer:t}};F(!1)},Ka=new Ba(`high`),qa=async(e,t={})=>{let{width:n=1280,height:r=720,quality:i,bitrate:a,frameRate:o,...s}=t;if(!Fo.includes(e))return!1;if(!Number.isInteger(n)||n<=0)throw TypeError(`width must be a positive integer.`);if(!Number.isInteger(r)||r<=0)throw TypeError(`height must be a positive integer.`);if(i!==void 0&&!(i instanceof Ba))throw TypeError(`quality, when provided, must be a Quality.`);if(i!==void 0&&a!==void 0)throw TypeError(`quality and bitrate cannot both be provided.`);if(a!==void 0&&!(a instanceof Ba)&&(!Number.isInteger(a)||a<=0))throw TypeError(`bitrate must be a positive integer or a quality.`);if(o!==void 0&&(!Number.isFinite(o)||o<=0))throw TypeError(`frameRate, when provided, must be a finite positive number.`);Ra(e,s);let c=Ja(i,a)??new Ba(`medium`),l;try{l=za({codec:e,width:n,height:r,quality:c,framerate:o,...s,alpha:`discard`})}catch{return!1}let u=JSON.stringify(l),d=Ia.get(u);if(d)return d;let f=(async()=>{for(let{config:t}of l)if(Ya.some(n=>n.supports(e,t)))return!0;if(typeof VideoEncoder>`u`||(n%2==1||r%2==1)&&(e===`avc`||e===`hevc`))return!1;for(let{config:t,quantizer:i}of l){try{if(!(await VideoEncoder.isConfigSupported(t)).supported)continue}catch{continue}if(!br()||await new Promise(async a=>{try{let o=new VideoEncoder({output:()=>{},error:()=>a(!1)});o.configure(t);let s=new Uint8Array(n*r*4),c=new VideoFrame(s,{format:`RGBA`,codedWidth:n,codedHeight:r,timestamp:0});o.encode(c,i===null?void 0:Ga(e,i)),c.close(),await o.flush(),a(!0)}catch{a(!1)}}))return!0}return!1})();return Ia.set(u,f),f},Ja=(e,t)=>{if(e!==void 0)return e;if(t!==void 0)return t instanceof Ba?t:new Ba({bitrate:t})},Ya=[],Xa=new Uint8Array,Za=class e{constructor(e,t,n,r,i=-1,a,o){if(this.data=e,this.type=t,this.timestamp=n,this.duration=r,this.sequenceNumber=i,e===Xa&&a===void 0)throw Error(`Internal error: byteLength must be explicitly provided when constructing metadata-only packets.`);if(a===void 0&&(a=e.byteLength),!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(t!==`key`&&t!==`delta`)throw TypeError(`type must be either "key" or "delta".`);if(!Number.isFinite(n))throw TypeError(`timestamp must be a number.`);if(!Number.isFinite(r)||r<0)throw TypeError(`duration must be a non-negative number.`);if(!Number.isFinite(i))throw TypeError(`sequenceNumber must be a number.`);if(!Number.isInteger(a)||a<0)throw TypeError(`byteLength must be a non-negative integer.`);if(o!==void 0&&(typeof o!=`object`||!o))throw TypeError(`sideData, when provided, must be an object.`);if(o?.alpha!==void 0&&!(o.alpha instanceof Uint8Array))throw TypeError(`sideData.alpha, when provided, must be a Uint8Array.`);if(o?.alphaByteLength!==void 0&&(!Number.isInteger(o.alphaByteLength)||o.alphaByteLength<0))throw TypeError(`sideData.alphaByteLength, when provided, must be a non-negative integer.`);this.byteLength=a,this.sideData=o??{},this.sideData.alpha&&this.sideData.alphaByteLength===void 0&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===Xa}get microsecondTimestamp(){return Math.trunc(mr*this.timestamp)}get microsecondDuration(){return Math.trunc(mr*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to a video chunk.`);if(typeof EncodedVideoChunk>`u`)throw Error(`EncodedVideoChunk is not available in this environment.`);return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw TypeError(`This packet does not contain alpha side data.`);if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to a video chunk.`);if(typeof EncodedVideoChunk>`u`)throw Error(`EncodedVideoChunk is not available in this environment.`);return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to an audio chunk.`);if(typeof EncodedAudioChunk>`u`)throw Error(`EncodedAudioChunk is not available in this environment.`);return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(t,n){if(!(t instanceof EncodedVideoChunk||t instanceof EncodedAudioChunk))throw TypeError(`chunk must be an EncodedVideoChunk or EncodedAudioChunk.`);let r=new Uint8Array(t.byteLength);return t.copyTo(r),new e(r,t.type,t.timestamp/1e6,(t.duration??0)/1e6,void 0,void 0,n)}clone(t){if(t!==void 0&&(typeof t!=`object`||!t))throw TypeError(`options, when provided, must be an object.`);if(t?.data!==void 0&&!(t.data instanceof Uint8Array))throw TypeError(`options.data, when provided, must be a Uint8Array.`);if(t?.type!==void 0&&t.type!==`key`&&t.type!==`delta`)throw TypeError(`options.type, when provided, must be either "key" or "delta".`);if(t?.timestamp!==void 0&&!Number.isFinite(t.timestamp))throw TypeError(`options.timestamp, when provided, must be a number.`);if(t?.duration!==void 0&&!Number.isFinite(t.duration))throw TypeError(`options.duration, when provided, must be a number.`);if(t?.sequenceNumber!==void 0&&!Number.isFinite(t.sequenceNumber))throw TypeError(`options.sequenceNumber, when provided, must be a number.`);if(t?.sideData!==void 0&&(typeof t.sideData!=`object`||t.sideData===null))throw TypeError(`options.sideData, when provided, must be an object.`);return new e(t?.data??this.data,t?.type??this.type,t?.timestamp??this.timestamp,t?.duration??this.duration,t?.sequenceNumber??this.sequenceNumber,this.byteLength,t?.sideData??this.sideData)}},Qa=2082844800,$a=e=>{let t=(e.hasVideo?`video/`:e.hasAudio?`audio/`:`application/`)+(e.isQuickTime?`quicktime`:`mp4`);if(e.codecStrings.length>0){let n=[...new Set(e.codecStrings)];t+=`; codecs="${n.join(`, `)}"`}return t},eo=class{constructor(e){this.value=e}},to=class{constructor(e){this.value=e}},no=class{constructor(e){this.value=e}},ro=class{constructor(e){this.value=e}},R;(function(e){e[e.EBML=440786851]=`EBML`,e[e.EBMLVersion=17030]=`EBMLVersion`,e[e.EBMLReadVersion=17143]=`EBMLReadVersion`,e[e.EBMLMaxIDLength=17138]=`EBMLMaxIDLength`,e[e.EBMLMaxSizeLength=17139]=`EBMLMaxSizeLength`,e[e.DocType=17026]=`DocType`,e[e.DocTypeVersion=17031]=`DocTypeVersion`,e[e.DocTypeReadVersion=17029]=`DocTypeReadVersion`,e[e.Void=236]=`Void`,e[e.Segment=408125543]=`Segment`,e[e.SeekHead=290298740]=`SeekHead`,e[e.Seek=19899]=`Seek`,e[e.SeekID=21419]=`SeekID`,e[e.SeekPosition=21420]=`SeekPosition`,e[e.Duration=17545]=`Duration`,e[e.Info=357149030]=`Info`,e[e.TimestampScale=2807729]=`TimestampScale`,e[e.DateUTC=17505]=`DateUTC`,e[e.MuxingApp=19840]=`MuxingApp`,e[e.WritingApp=22337]=`WritingApp`,e[e.Tracks=374648427]=`Tracks`,e[e.TrackEntry=174]=`TrackEntry`,e[e.TrackNumber=215]=`TrackNumber`,e[e.TrackUID=29637]=`TrackUID`,e[e.TrackType=131]=`TrackType`,e[e.FlagEnabled=185]=`FlagEnabled`,e[e.FlagDefault=136]=`FlagDefault`,e[e.FlagForced=21930]=`FlagForced`,e[e.FlagOriginal=21934]=`FlagOriginal`,e[e.FlagHearingImpaired=21931]=`FlagHearingImpaired`,e[e.FlagVisualImpaired=21932]=`FlagVisualImpaired`,e[e.FlagCommentary=21935]=`FlagCommentary`,e[e.FlagLacing=156]=`FlagLacing`,e[e.Name=21358]=`Name`,e[e.Language=2274716]=`Language`,e[e.LanguageBCP47=2274717]=`LanguageBCP47`,e[e.CodecID=134]=`CodecID`,e[e.CodecPrivate=25506]=`CodecPrivate`,e[e.CodecDelay=22186]=`CodecDelay`,e[e.SeekPreRoll=22203]=`SeekPreRoll`,e[e.DefaultDuration=2352003]=`DefaultDuration`,e[e.Video=224]=`Video`,e[e.PixelWidth=176]=`PixelWidth`,e[e.PixelHeight=186]=`PixelHeight`,e[e.DisplayWidth=21680]=`DisplayWidth`,e[e.DisplayHeight=21690]=`DisplayHeight`,e[e.DisplayUnit=21682]=`DisplayUnit`,e[e.AlphaMode=21440]=`AlphaMode`,e[e.Audio=225]=`Audio`,e[e.SamplingFrequency=181]=`SamplingFrequency`,e[e.Channels=159]=`Channels`,e[e.BitDepth=25188]=`BitDepth`,e[e.SimpleBlock=163]=`SimpleBlock`,e[e.BlockGroup=160]=`BlockGroup`,e[e.Block=161]=`Block`,e[e.BlockAdditions=30113]=`BlockAdditions`,e[e.BlockMore=166]=`BlockMore`,e[e.BlockAdditional=165]=`BlockAdditional`,e[e.BlockAddID=238]=`BlockAddID`,e[e.BlockDuration=155]=`BlockDuration`,e[e.ReferenceBlock=251]=`ReferenceBlock`,e[e.Cluster=524531317]=`Cluster`,e[e.Timestamp=231]=`Timestamp`,e[e.Cues=475249515]=`Cues`,e[e.CuePoint=187]=`CuePoint`,e[e.CueTime=179]=`CueTime`,e[e.CueTrackPositions=183]=`CueTrackPositions`,e[e.CueTrack=247]=`CueTrack`,e[e.CueClusterPosition=241]=`CueClusterPosition`,e[e.CueRelativePosition=240]=`CueRelativePosition`,e[e.Colour=21936]=`Colour`,e[e.MatrixCoefficients=21937]=`MatrixCoefficients`,e[e.TransferCharacteristics=21946]=`TransferCharacteristics`,e[e.Primaries=21947]=`Primaries`,e[e.Range=21945]=`Range`,e[e.Projection=30320]=`Projection`,e[e.ProjectionType=30321]=`ProjectionType`,e[e.ProjectionPoseYaw=30323]=`ProjectionPoseYaw`,e[e.ProjectionPosePitch=30324]=`ProjectionPosePitch`,e[e.ProjectionPoseRoll=30325]=`ProjectionPoseRoll`,e[e.Attachments=423732329]=`Attachments`,e[e.AttachedFile=24999]=`AttachedFile`,e[e.FileDescription=18046]=`FileDescription`,e[e.FileName=18030]=`FileName`,e[e.FileMediaType=18016]=`FileMediaType`,e[e.FileData=18012]=`FileData`,e[e.FileUID=18094]=`FileUID`,e[e.Chapters=272869232]=`Chapters`,e[e.Tags=307544935]=`Tags`,e[e.Tag=29555]=`Tag`,e[e.Targets=25536]=`Targets`,e[e.TargetTypeValue=26826]=`TargetTypeValue`,e[e.TargetType=25546]=`TargetType`,e[e.TagTrackUID=25541]=`TagTrackUID`,e[e.TagEditionUID=25545]=`TagEditionUID`,e[e.TagChapterUID=25540]=`TagChapterUID`,e[e.TagAttachmentUID=25542]=`TagAttachmentUID`,e[e.SimpleTag=26568]=`SimpleTag`,e[e.TagName=17827]=`TagName`,e[e.TagLanguage=17530]=`TagLanguage`,e[e.TagString=17543]=`TagString`,e[e.TagBinary=17541]=`TagBinary`,e[e.ContentEncodings=28032]=`ContentEncodings`,e[e.ContentEncoding=25152]=`ContentEncoding`,e[e.ContentEncodingOrder=20529]=`ContentEncodingOrder`,e[e.ContentEncodingScope=20530]=`ContentEncodingScope`,e[e.ContentCompression=20532]=`ContentCompression`,e[e.ContentCompAlgo=16980]=`ContentCompAlgo`,e[e.ContentCompSettings=16981]=`ContentCompSettings`,e[e.ContentEncryption=20533]=`ContentEncryption`})(R||={});var io=[R.EBML,R.Segment],ao=[R.SeekHead,R.Info,R.Cluster,R.Tracks,R.Cues,R.Attachments,R.Chapters,R.Tags];[...io,...ao];var oo=e=>e<256?1:e<65536?2:e<1<<24?3:e<2**32?4:e<2**40?5:6,so=e=>e<1n<<8n?1:e<1n<<16n?2:e<1n<<24n?3:e<1n<<32n?4:e<1n<<40n?5:e<1n<<48n?6:e<1n<<56n?7:8,co=e=>e>=-64&&e<64?1:e>=-8192&&e<8192?2:e>=-1048576&&e<1<<20?3:e>=-134217728&&e<1<<27?4:e>=-(2**34)&&e<2**34?5:6,lo=e=>{if(e<127)return 1;if(e<16383)return 2;if(e<(1<<21)-1)return 3;if(e<(1<<28)-1)return 4;if(e<2**35-1)return 5;if(e<2**42-1)return 6;throw Error(`EBML varint size not supported `+e)},uo=class{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap,this.dataOffsets=new WeakMap}writeByte(e){this.helperView.setUint8(0,e),this.writer.write(this.helper.subarray(0,1))}writeFloat32(e){this.helperView.setFloat32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeFloat64(e){this.helperView.setFloat64(0,e,!1),this.writer.write(this.helper)}writeUnsignedInt(e,t=oo(e)){let n=0;switch(t){case 6:this.helperView.setUint8(n++,e/2**40|0);case 5:this.helperView.setUint8(n++,e/2**32|0);case 4:this.helperView.setUint8(n++,e>>24);case 3:this.helperView.setUint8(n++,e>>16);case 2:this.helperView.setUint8(n++,e>>8);case 1:this.helperView.setUint8(n++,e);break;default:throw Error(`Bad unsigned int size `+t)}this.writer.write(this.helper.subarray(0,n))}writeUnsignedBigInt(e,t=so(e)){let n=0;for(let r=t-1;r>=0;r--)this.helperView.setUint8(n++,Number(e>>BigInt(r*8)&255n));this.writer.write(this.helper.subarray(0,n))}writeSignedInt(e,t=co(e)){e<0&&(e+=2**(t*8)),this.writeUnsignedInt(e,t)}writeVarInt(e,t=lo(e)){let n=0;switch(t){case 1:this.helperView.setUint8(n++,128|e);break;case 2:this.helperView.setUint8(n++,64|e>>8),this.helperView.setUint8(n++,e);break;case 3:this.helperView.setUint8(n++,32|e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 4:this.helperView.setUint8(n++,16|e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 5:this.helperView.setUint8(n++,8|e/2**32&7),this.helperView.setUint8(n++,e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 6:this.helperView.setUint8(n++,4|e/2**40&3),this.helperView.setUint8(n++,e/2**32|0),this.helperView.setUint8(n++,e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;default:throw Error(`Bad EBML varint size `+t)}this.writer.write(this.helper.subarray(0,n))}writeAsciiString(e){this.writer.write(new Uint8Array(e.split(``).map(e=>e.charCodeAt(0))))}writeEBML(e){if(e!==null){if(e instanceof Uint8Array)this.writer.write(e);else if(Array.isArray(e))for(let t of e)this.writeEBML(t);else if(this.offsets.set(e,this.writer.getPos()),this.writeUnsignedInt(e.id),Array.isArray(e.data)){let t=this.writer.getPos(),n=e.size===-1?1:e.size??4;e.size===-1?this.writeByte(255):this.writer.seek(this.writer.getPos()+n);let r=this.writer.getPos();if(this.dataOffsets.set(e,r),this.writeEBML(e.data),e.size!==-1){let e=this.writer.getPos()-r,i=this.writer.getPos();this.writer.seek(t),this.writeVarInt(e,n),this.writer.seek(i)}}else if(typeof e.data==`number`){let t=e.size??oo(e.data);this.writeVarInt(t),this.writeUnsignedInt(e.data,t)}else if(typeof e.data==`bigint`){let t=e.size??so(e.data);this.writeVarInt(t),this.writeUnsignedBigInt(e.data,t)}else if(typeof e.data==`string`)this.writeVarInt(e.data.length),this.writeAsciiString(e.data);else if(e.data instanceof Uint8Array)this.writeVarInt(e.data.byteLength,e.size),this.writer.write(e.data);else if(e.data instanceof eo)this.writeVarInt(4),this.writeFloat32(e.data.value);else if(e.data instanceof to)this.writeVarInt(8),this.writeFloat64(e.data.value);else if(e.data instanceof no){let t=e.size??co(e.data.value);this.writeVarInt(t),this.writeSignedInt(e.data.value,t)}else if(e.data instanceof ro){let t=Kn.encode(e.data.value);this.writeVarInt(t.length),this.writer.write(t)}else rr(e.data)}}},fo=Date.UTC(2001,0,1),po={avc:`V_MPEG4/ISO/AVC`,hevc:`V_MPEGH/ISO/HEVC`,vp8:`V_VP8`,vp9:`V_VP9`,av1:`V_AV1`,prores:`V_PRORES`,aac:`A_AAC`,mp3:`A_MPEG/L3`,opus:`A_OPUS`,vorbis:`A_VORBIS`,flac:`A_FLAC`,ac3:`A_AC3`,eac3:`A_EAC3`,dts:`A_DTS`,truehd:`A_TRUEHD`,"pcm-u8":`A_PCM/INT/LIT`,"pcm-s16":`A_PCM/INT/LIT`,"pcm-s16be":`A_PCM/INT/BIG`,"pcm-s24":`A_PCM/INT/LIT`,"pcm-s24be":`A_PCM/INT/BIG`,"pcm-s32":`A_PCM/INT/LIT`,"pcm-s32be":`A_PCM/INT/BIG`,"pcm-f32":`A_PCM/FLOAT/IEEE`,"pcm-f64":`A_PCM/FLOAT/IEEE`,webvtt:`S_TEXT/WEBVTT`},mo=e=>{let t=(e.hasVideo?`video/`:e.hasAudio?`audio/`:`application/`)+(e.isWebM?`webm`:`x-matroska`);if(e.codecStrings.length>0){let n=[...new Set(e.codecStrings.filter(Boolean))];t+=`; codecs="${n.join(`, `)}"`}return t},ho=e=>{let t=e.filePos;if(e.remainingLength<7)return null;let n=new qr(yo(e,7));if(n.readBits(12)!==4095||(n.skipBits(1),n.readBits(2)!==0))return null;let r=n.readBits(1),i=n.readBits(2)+1,a=n.readBits(4);if(a>=Jr.length)return null;n.skipBits(1);let o=n.readBits(3);if(o===0)throw Error(`ADTS frames with channel configuration 0 are not supported.`);n.skipBits(1),n.skipBits(1),n.skipBits(1),n.skipBits(1);let s=n.readBits(13);n.skipBits(11);let c=n.readBits(2)+1;if(c!==1)throw Error(`ADTS frames with more than one AAC frame are not supported.`);let l=null;if(r===0){if(e.remainingLength<2)return null;l=bo(e)}return s<e.filePos-t?null:{objectType:i,samplingFrequencyIndex:a,channelConfiguration:o,frameLength:s,numberOfAacFrames:c,crcCheck:l,startPos:t}},go=t(((e,t)=>{t.exports={}})),_o=class e{constructor(e,t,n,r,i){this.bytes=e,this.view=t,this.offset=n,this.start=r,this.end=i,this.bufferPos=r-n}static tempFromBytes(t){return new e(t,Wn(t),0,0,t.length)}get length(){return this.end-this.start}get filePos(){return this.offset+this.bufferPos}set filePos(e){this.bufferPos=e-this.offset}get remainingLength(){return Math.max(this.end-this.filePos,0)}skip(e){this.bufferPos+=e}slice(t,n=this.end-t){if(t<this.start||t+n>this.end)throw RangeError(`Slicing outside of original slice.`);return new e(this.bytes,this.view,this.offset,t,t+n)}},vo=(e,t)=>{if(t<0||e.filePos<e.start||e.filePos+t>e.end)throw RangeError(`Tried reading [${e.filePos}, ${e.filePos+t}), but slice is [${e.start}, ${e.end}). This is likely an internal error, please report it alongside the file that caused it.`)},yo=(e,t)=>{vo(e,t);let n=e.bytes.subarray(e.bufferPos,e.bufferPos+t);return e.bufferPos+=t,n},bo=e=>{vo(e,2);let t=e.view.getUint16(e.bufferPos,!1);return e.bufferPos+=2,t},xo=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},So=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Co=class{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._nominalBitrate=null}_ensureValidAdd(){if(!this._connectedTrack)throw Error(`Source is not connected to an output track.`);if(this._connectedTrack.output.state===`canceled`)throw Error(`Output has been canceled.`);if(this._connectedTrack.output.state===`finalizing`||this._connectedTrack.output.state===`finalized`)throw Error(`Output has been finalized.`);if(this._connectedTrack.output.state===`pending`)throw Error(`Output has not started.`);if(this._closed)throw Error(`Source is closed.`)}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;let e=this._connectedTrack;if(!e)throw Error(`Cannot call close without connecting the source to an output track.`);if(e.output.state===`pending`)throw Error(`Cannot call close before output has been started.`);this._closingPromise=(async()=>{await this._flushAndClose(!1),this._closed=!0,e.output.state!==`finalizing`&&e.output.state!==`finalized`&&e.output._muxer.onTrackClose(e)})()}async _flushOrWaitForOngoingClose(e){return this._closingPromise??=(async()=>{await this._flushAndClose(e),this._closed=!0})()}},wo=class extends Co{constructor(e){if(super(),!Fo.includes(e))throw TypeError(`Invalid video codec '${e}'. Must be one of: ${Fo.join(`, `)}.`);this._codec=e}},To=(e,t)=>{if(e.metadata.hasOnlyKeyPackets&&t.type!==`key`)throw Error(`Cannot add non-key packets to a hasOnlyKeyPackets video track.`)},Eo=class{setError(e){this.errorSet||=(this.error=e,!0)}constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.encoderConfig=null,this.encodersReclaimed=!1,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.emittedEncoderPackets=0,this.chunkTimestampsAreShiftedByDuration=!1,this.codedWidth=null,this.codedHeight=null,this.outputWidth=null,this.outputHeight=null,this.frameRateLastSample=null,this.frameRateLastTimestamp=null,this.frameRateLastEndTimestamp=null,this.preciseTimings=[],this.customEncoder=null,this.customEncoderCallSerializer=new gr,this.customEncoderQueueSize=0,this.defaultEncodeOptions={},this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null,this.errorSet=!1,this.lastMuxerPromise=Promise.resolve(),this.closed=!1}async add(e,t,n){let r=e;try{this.checkForEncoderError(),this.source._ensureValidAdd();let i=this.encodingConfig,a=i.sizeChangeBehavior??`deny`,o=!1;if(this.codedWidth!==null&&this.codedHeight!==null){if((e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight)&&(o=!0,a===`deny`))throw Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${e.codedWidth}x${e.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'deny' in the encoding options.`)}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;if(i.transform?.width!==void 0||i.transform?.height!==void 0||i.transform?.rotate!==void 0||i.transform?.flip!==void 0||i.transform?.crop!==void 0||i.transform?.force===!0||o&&a!==`passThrough`){let n=i.transform?.width,r=i.transform?.height,s=i.transform?.fit??`fill`;o&&a!==`passThrough`&&(F(this.outputWidth),F(this.outputHeight),F(a!==`deny`),n=this.outputWidth,r=this.outputHeight,s=a);let c=await e.transform({width:n,height:r,roundDimensionsTo:2,crop:i.transform?.crop,rotate:i.transform?.rotate,flip:i.transform?.flip,fit:s,alpha:i.alpha});(this.outputWidth===null||this.outputHeight===null)&&(this.outputWidth=c.displayWidth,this.outputHeight=c.displayHeight),t&&e.close(),e=c,t=!0}else(this.outputWidth===null||this.outputHeight===null)&&(this.outputWidth=e.codedWidth,this.outputHeight=e.codedHeight);let s=i.transform?.frameRate;if(s!==void 0){let i=e.timestamp+e.duration,a=ur(e.timestamp,s);if(this.frameRateLastSample!==null){if(a<=this.frameRateLastTimestamp){this.frameRateLastSample.close(),this.frameRateLastSample=e.clone(),this.frameRateLastEndTimestamp=i;return}await this.padFrameRate(a,n)}e===r&&(e=e.clone(),t=!0),e.setTimestamp(a),e.setDuration(1/s),this.frameRateLastSample?.close(),this.frameRateLastSample=e.clone(),this.frameRateLastTimestamp=a,this.frameRateLastEndTimestamp=i}await this.processAndEncode(e,n)}finally{t&&e.close()}}async processAndEncode(e,t){let n=this.encodingConfig,r;if(n.transform?.process){let t=n.transform.process(e);if(Or(t)&&(t=await t),t===null)return;Array.isArray(t)||(t=[t]);let i=[];try{for(let n of t)n instanceof ya?i.push(n):typeof VideoFrame<`u`&&n instanceof VideoFrame?i.push(new ya(n)):i.push(new ya(n,{timestamp:e.timestamp,duration:e.duration}))}catch(n){for(let t of i)t!==e&&t.close();for(let n of t)(n instanceof ya&&n!==e||typeof VideoFrame<`u`&&n instanceof VideoFrame)&&n.close();throw n}r=i}else r=[e];try{for(let e of r){if(this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),F(this.encoderInitialized),this.closed)break;this.encodersReclaimed&&this.recreateWebCodecsEncoders();let n=this.encodingConfig.keyFrameInterval??2,r=Math.floor(e.timestamp/n),i={...this.defaultEncodeOptions,...e.encodeOptions,...t},a={...i,keyFrame:i.keyFrame===void 0?n===0||r!==this.lastMultipleOfKeyFrameInterval:i.keyFrame};if(this.lastMultipleOfKeyFrameInterval=r,this.encodingConfig.onEncodedSample?.(e),this.customEncoder){this.customEncoderQueueSize++;let t=e.clone(),n=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(t,a)).catch(e=>this.setError(e)).finally(()=>{this.customEncoderQueueSize--,t.close()});this.customEncoderQueueSize>=4&&await n}else{F(this.encoder);let t=e.toVideoFrame(),n=tr(this.preciseTimings,t.timestamp,e=>e.microsecondTimestamp),r=n===-1?null:this.preciseTimings[n];if(r&&r.microsecondTimestamp===t.timestamp?(r.timestamp!==e.timestamp&&(r.timestampIsValid=!1),r.duration!==e.duration&&(r.durationIsValid=!1)):(this.preciseTimings.splice(n+1,0,{microsecondTimestamp:t.timestamp,timestamp:e.timestamp,duration:e.duration,timestampIsValid:!0,durationIsValid:!0}),this.preciseTimings.length>128&&this.preciseTimings.shift()),!this.alphaEncoder)try{this.encoder.encode(t,a)}finally{t.close()}else if(t.format&&!t.format.includes(`A`)||this.splitterCreationFailed){this.alphaFrameQueue.push(null);try{this.encoder.encode(t,a)}finally{t.close()}}else{this.splitter||=new Ao;let{colorFrame:e,alphaFrame:n}=await this.splitter.split(t);this.alphaFrameQueue.push(n);try{this.encoder.encode(e,a)}finally{e.close()}}this.encoder.encodeQueueSize>=4&&await new Promise(e=>this.encoder.addEventListener(`dequeue`,e,{once:!0}))}await this.lastMuxerPromise}}finally{for(let t of r)t!==e&&t.close()}}async padFrameRate(e,t){let n=this.encodingConfig.transform.frameRate;F(this.frameRateLastSample);let r=Math.round((e-this.frameRateLastTimestamp)*n);for(let e=1;e<r;e++){let r={stack:[],error:void 0,hasError:!1};try{let i=xo(r,this.frameRateLastSample.clone(),!1);i.setTimestamp(this.frameRateLastTimestamp+e/n),i.setDuration(1/n),await this.processAndEncode(i,t)}catch(e){r.error=e,r.hasError=!0}finally{So(r)}}}ensureEncoder(e){this.ensureEncoderPromise=(async()=>{let t=Ja(this.encodingConfig.quality,this.encodingConfig.bitrate);F(t!==void 0);let n=za({...this.encodingConfig,quality:t,width:e.codedWidth,height:e.codedHeight,squarePixelWidth:e.squarePixelWidth,squarePixelHeight:e.squarePixelHeight,framerate:this.source._connectedTrack?.metadata.frameRate}),r=null,i;for(let e of n){let t=e.config;if(this.encodingConfig.onEncoderConfig?.(t),i=Ya.find(e=>e.supports(this.encodingConfig.codec,t)),i){r=e;break}if(typeof VideoEncoder<`u`){if(t.alpha=`discard`,this.encodingConfig.alpha===`keep`&&(t.latencyMode=`quality`),(t.width%2==1||t.height%2==1)&&(this.encodingConfig.codec===`avc`||this.encodingConfig.codec===`hevc`))throw Error(`The dimensions ${t.width}x${t.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);try{if((await VideoEncoder.isConfigSupported(t)).supported){r=e;break}}catch{}}}if(!r){if(typeof VideoEncoder>`u`)throw Error(Tr(`VideoEncoder`));let e=n[0].config,t=n.map(({config:e,quantizer:t})=>t===null?`${e.bitrate} bps`:`quantizer ${t}`);throw Error(`This specific encoder configuration (${e.codec}, ${t.join(` / `)}, ${e.width}x${e.height}, hardware acceleration: ${e.hardwareAcceleration??`no-preference`}) is not supported in this environment. Consider using another codec or changing your video parameters.`)}let a=r.config;r.quantizer===null?this.source._nominalBitrate=a.bitrate??null:this.defaultEncodeOptions=Ga(this.encodingConfig.codec,r.quantizer),i?(this.customEncoder=new i,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=a,this.customEncoder.onPacket=(e,t)=>{if(!(e instanceof Za))throw TypeError(`The first argument passed to onPacket must be an EncodedPacket.`);if(t!==void 0&&(!t||typeof t!=`object`))throw TypeError(`The second argument passed to onPacket must be an object or undefined.`);To(this.source._connectedTrack,e),this.encodingConfig.onEncodedPacket?.(e,t),this.lastMuxerPromise=this.muxer.addEncodedVideoPacket(this.source._connectedTrack,e,t).catch(e=>{this.setError(e)})},this.customEncoder.onError=e=>{this.setError(e)},await this.customEncoder.init()):(this.encoderConfig=a,this.encodingConfig.codec===`avc`&&br()&&(this.chunkTimestampsAreShiftedByDuration=await Oo()),this.createWebCodecsEncoders()),F(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}createWebCodecsEncoders(){let e=this.encoderConfig;F(e);let t=[],n=[],r=0,i=0,a=(e,t)=>{Er(e)?this.encodersReclaimed=!0:(e.stack=t,this.setError(e))},o=Error(`Encoding error`).stack;if(this.encoder=new VideoEncoder({output:(e,a)=>{if(!this.alphaEncoder){this.addPacket(e,null,a);return}let o=this.alphaFrameQueue.shift();F(o!==void 0),o?(this.alphaEncoder.encode(o,{...this.defaultEncodeOptions,keyFrame:e.type===`key`}),i++,o.close(),t.push({chunk:e,meta:a})):i===0?this.addPacket(e,null,a):(n.push(r+i),t.push({chunk:e,meta:a}))},error:e=>a(e,o)}),this.encoder.configure(e),this.encodingConfig.alpha===`keep`){let o=Error(`Encoding error`).stack;this.alphaEncoder=new VideoEncoder({output:(e,a)=>{i--;let o=t.shift();for(F(o!==void 0),this.addPacket(o.chunk,e,o.meta),r++;n.length>0&&n[0]===r;){n.shift();let e=t.shift();F(e!==void 0),this.addPacket(e.chunk,null,e.meta)}},error:e=>a(e,o)}),this.alphaEncoder.configure(e)}}addPacket(e,t,n){let r={};if(t){let e=new Uint8Array(t.byteLength);t.copyTo(e),r.alpha=e}let i=Za.fromEncodedChunk(e,r),a=this.encoderConfig;if(F(a),n?.decoderConfig&&(n.decoderConfig.codec=Zo({width:a.width,height:a.height,codec:this.encodingConfig.codec,codecDescription:n.decoderConfig.description?Un(n.decoderConfig.description):null,colorSpace:n.decoderConfig.colorSpace??null,avcType:a.codec.includes(`avc1.`)?1:a.codec.includes(`avc3.`)?3:null,avcCodecInfo:this.encodingConfig.codec===`avc`&&!n.decoderConfig.description?hi(i.data):null,hevcCodecInfo:this.encodingConfig.codec===`hevc`&&!n.decoderConfig.description?wi(i.data):null,vp9CodecInfo:this.encodingConfig.codec===`vp9`?Fi(i.data):null,av1CodecInfo:this.encodingConfig.codec===`av1`?Li(i.data):null,proresFormat:null}),this.encodingConfig.codec===`avc`&&n.decoderConfig.description&&br())){let e=_i(Un(n.decoderConfig.description)),t=e?.sequenceParameterSets[0];if(t&&t[0]===t[1]){F(e),t=t.subarray(1);let r=e.pictureParameterSets[0];r&&=r.subarray(1);let i=gi({...e,sequenceParameterSets:[t],pictureParameterSets:r?[r]:[]});n.decoderConfig.description=i}}let o=e.timestamp;this.chunkTimestampsAreShiftedByDuration&&(o-=e.duration??0,i=i.clone({timestamp:o/1e6}));let s=tr(this.preciseTimings,o,e=>e.microsecondTimestamp),c=s===-1?null:this.preciseTimings[s],l=null;this.emittedEncoderPackets===0&&i.type===`delta`&&n?.decoderConfig&&(l=Hi(this.encodingConfig.codec,n.decoderConfig,i.data)),(c&&c.microsecondTimestamp===o||l!==null)&&(i=i.clone({timestamp:c?.timestampIsValid?c.timestamp:void 0,duration:c?.durationIsValid?c.duration:void 0,type:l??void 0})),To(this.source._connectedTrack,i),this.encodingConfig.onEncodedPacket?.(i,n),this.lastMuxerPromise=this.muxer.addEncodedVideoPacket(this.source._connectedTrack,i,n).catch(e=>{this.setError(e)}),this.emittedEncoderPackets++}recreateWebCodecsEncoders(){F(this.encoder),this.encoder.state!==`closed`&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!==`closed`&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(e=>e?.close()),this.alphaFrameQueue.length=0,this.encodersReclaimed=!1,this.lastMultipleOfKeyFrameInterval=-1,this.createWebCodecsEncoders()}async flushAndClose(e){try{if(!e&&(this.checkForEncoderError(),this.frameRateLastSample)){let e=this.encodingConfig.transform.frameRate,t=ur(this.frameRateLastEndTimestamp,e);await this.padFrameRate(t)}this.closed=!0,e||(this.customEncoder?this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()):this.encoder&&!this.encodersReclaimed&&(await this.encoder.flush(),await this.alphaEncoder?.flush(),await Lr(25)))}finally{this.closed=!0,this.frameRateLastSample?.close(),this.frameRateLastSample=null,this.customEncoder?await this.customEncoderCallSerializer.call(()=>this.customEncoder.close()).catch(e=>this.setError(e)):this.encoder&&(this.encoder.state!==`closed`&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!==`closed`&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(e=>e?.close()),this.alphaFrameQueue.length=0,this.splitter?.close())}e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.errorSet)throw this.error}},Do=null,Oo=()=>Do??=(async()=>{let e=null,t=new VideoEncoder({output:t=>{e??=t.timestamp},error:()=>{}});try{t.configure({codec:`avc1.64001f`,width:1280,height:720});let e=new VideoFrame(new Uint8Array(1382400),{format:`I420`,codedWidth:1280,codedHeight:720,timestamp:0,duration:500});t.encode(e,{keyFrame:!0}),e.close(),await t.flush()}catch{return!1}finally{t.state!==`closed`&&t.close()}return e===500})(),ko=null,Ao=class{constructor(){this.worker=null,this.pendingRequests=new Map,this.nextRequestId=0}split(e){if(!this.worker){if(!ko){let e=new Blob([`(${jo.toString()})()`],{type:`application/javascript`});ko=URL.createObjectURL(e)}this.worker=new Worker(ko),this.worker.addEventListener(`message`,e=>{let t=e.data,n=this.pendingRequests.get(t.id);n&&(this.pendingRequests.delete(t.id),`error`in t?n.reject(Error(t.error)):n.resolve({colorFrame:t.colorFrame,alphaFrame:t.alphaFrame}))}),this.worker.addEventListener(`error`,e=>{let t=Error(e.message||`Color/alpha splitter worker error.`);for(let e of this.pendingRequests.values())e.reject(t);this.pendingRequests.clear()})}let t=this.nextRequestId++,n=nr();return this.pendingRequests.set(t,n),this.worker.postMessage({id:t,sourceFrame:e},{transfer:[e]}),n.promise}close(){this.worker?.terminate(),this.worker=null;let e=Error(`Color/alpha splitter closed.`);for(let t of this.pendingRequests.values())t.reject(e);this.pendingRequests.clear()}},jo=()=>{let e=null,t=Promise.resolve();self.addEventListener(`message`,e=>{let{id:r,sourceFrame:i}=e.data;t=t.then(async()=>{try{let{colorFrame:e,alphaFrame:t}=await n(i);self.postMessage({id:r,colorFrame:e,alphaFrame:t},{transfer:[e,t]})}catch(e){self.postMessage({id:r,error:e.message})}finally{i.close()}})});let n=async t=>{let n=t.format;if(!n)throw Error(`CPU color/alpha splitting requires a known VideoFrame format.`);let a=t.allocationSize();if(e&&e.byteLength===a||(e=new Uint8Array(a)),await t.copyTo(e),n===`RGBA`||n===`BGRA`)return r(e,n,t);if(n===`I420A`||n===`I420AP10`||n===`I420AP12`||n===`I422A`||n===`I422AP10`||n===`I422AP12`||n===`I444A`||n===`I444AP10`||n===`I444AP12`)return i(e,n,t);throw Error(`CPU color/alpha splitting does not support format '${n}'.`)},r=(e,t,n)=>{let r=n.visibleRect?.width??n.codedWidth,i=n.visibleRect?.height??n.codedHeight,a=r*i,o=a+Math.ceil(r/2)*Math.ceil(i/2)*2,s=new Uint8Array(o);for(let t=0,n=3;t<a;t++,n+=4)s[t]=e[n];s.fill(128,a);let c=new VideoFrame(e,{format:t===`RGBA`?`RGBX`:`BGRX`,codedWidth:r,codedHeight:i,timestamp:n.timestamp,duration:n.duration??void 0}),l={format:`I420`,codedWidth:r,codedHeight:i,timestamp:n.timestamp,duration:n.duration??void 0,colorSpace:{fullRange:!0,matrix:`bt709`,primaries:`bt709`,transfer:`bt709`},transfer:[s.buffer]};return{colorFrame:c,alphaFrame:new VideoFrame(s,l)}},i=(e,t,n)=>{let r=n.visibleRect?.width??n.codedWidth,i=n.visibleRect?.height??n.codedHeight,a=t.includes(`P10`),o=t.includes(`P12`),s=a||o?2:1,c,l;t.startsWith(`I420`)?(c=Math.ceil(r/2),l=Math.ceil(i/2)):t.startsWith(`I422`)?(c=Math.ceil(r/2),l=i):(c=r,l=i);let u=r*i,d=c*l,f=u*s,p=d*s,m=u*s,h=f+p*2,g=t.replace(`A`,``),_=Math.ceil(r/2)*Math.ceil(i/2),v=m+_*s*2,y=new Uint8Array(v),b=h;y.set(e.subarray(b,b+m),0);let x=m,S=a?512:o?2048:128;s===1?y.fill(S,x):new Uint16Array(y.buffer,x,2*_).fill(S);let C=a?`I420P10`:o?`I420P12`:`I420`,w=new VideoFrame(e.subarray(0,h),{format:g,codedWidth:r,codedHeight:i,timestamp:n.timestamp,duration:n.duration??void 0}),T={format:C,codedWidth:r,codedHeight:i,timestamp:n.timestamp,duration:n.duration??void 0,colorSpace:{fullRange:!0,matrix:`bt709`,primaries:`bt709`,transfer:`bt709`},transfer:[y.buffer]};return{colorFrame:w,alphaFrame:new VideoFrame(y,T)}}},Mo=class extends wo{constructor(e,t){if(!(typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas))throw TypeError(`canvas must be an HTMLCanvasElement or OffscreenCanvas.`);La(t),super(t.codec),this._encoder=new Eo(this,t),this._canvas=e}add(e,t=0,n){if(!Number.isFinite(e))throw TypeError(`timestamp must be a finite number.`);if(!Number.isFinite(t)||t<0)throw TypeError(`duration must be a non-negative number.`);let r=new ya(this._canvas,{timestamp:e,duration:t});return this._encoder.add(r,!0,n)}_flushAndClose(e){return this._encoder.flushAndClose(e)}},No=class extends Co{constructor(e){if(super(),!Ro.includes(e))throw TypeError(`Invalid audio codec '${e}'. Must be one of: ${Ro.join(`, `)}.`);this._codec=e}},Po=class extends Co{constructor(e){if(super(),!zo.includes(e))throw TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${zo.join(`, `)}.`);this._codec=e}},Fo=[`avc`,`hevc`,`vp9`,`av1`,`vp8`,`prores`],Io=[`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,`pcm-u8`,`pcm-s8`,`ulaw`,`alaw`],Lo=[`aac`,`opus`,`mp3`,`vorbis`,`flac`,`ac3`,`eac3`,`dts`,`truehd`],Ro=[...Lo,...Io],zo=[`webvtt`],Bo=[{maxMacroblocks:99,maxBitrate:64e3,maxDpbMbs:396,level:10},{maxMacroblocks:396,maxBitrate:192e3,maxDpbMbs:900,level:11},{maxMacroblocks:396,maxBitrate:384e3,maxDpbMbs:2376,level:12},{maxMacroblocks:396,maxBitrate:768e3,maxDpbMbs:2376,level:13},{maxMacroblocks:396,maxBitrate:2e6,maxDpbMbs:2376,level:20},{maxMacroblocks:792,maxBitrate:4e6,maxDpbMbs:4752,level:21},{maxMacroblocks:1620,maxBitrate:4e6,maxDpbMbs:8100,level:22},{maxMacroblocks:1620,maxBitrate:1e7,maxDpbMbs:8100,level:30},{maxMacroblocks:3600,maxBitrate:14e6,maxDpbMbs:18e3,level:31},{maxMacroblocks:5120,maxBitrate:2e7,maxDpbMbs:20480,level:32},{maxMacroblocks:8192,maxBitrate:2e7,maxDpbMbs:32768,level:40},{maxMacroblocks:8192,maxBitrate:5e7,maxDpbMbs:32768,level:41},{maxMacroblocks:8704,maxBitrate:5e7,maxDpbMbs:34816,level:42},{maxMacroblocks:22080,maxBitrate:135e6,maxDpbMbs:110400,level:50},{maxMacroblocks:36864,maxBitrate:24e7,maxDpbMbs:184320,level:51},{maxMacroblocks:36864,maxBitrate:24e7,maxDpbMbs:184320,level:52},{maxMacroblocks:139264,maxBitrate:24e7,maxDpbMbs:696320,level:60},{maxMacroblocks:139264,maxBitrate:48e7,maxDpbMbs:696320,level:61},{maxMacroblocks:139264,maxBitrate:8e8,maxDpbMbs:696320,level:62}],Vo=[{maxPictureSize:36864,maxBitrate:128e3,tier:`L`,level:30},{maxPictureSize:122880,maxBitrate:15e5,tier:`L`,level:60},{maxPictureSize:245760,maxBitrate:3e6,tier:`L`,level:63},{maxPictureSize:552960,maxBitrate:6e6,tier:`L`,level:90},{maxPictureSize:983040,maxBitrate:1e7,tier:`L`,level:93},{maxPictureSize:2228224,maxBitrate:12e6,tier:`L`,level:120},{maxPictureSize:2228224,maxBitrate:3e7,tier:`H`,level:120},{maxPictureSize:2228224,maxBitrate:2e7,tier:`L`,level:123},{maxPictureSize:2228224,maxBitrate:5e7,tier:`H`,level:123},{maxPictureSize:8912896,maxBitrate:25e6,tier:`L`,level:150},{maxPictureSize:8912896,maxBitrate:1e8,tier:`H`,level:150},{maxPictureSize:8912896,maxBitrate:4e7,tier:`L`,level:153},{maxPictureSize:8912896,maxBitrate:16e7,tier:`H`,level:153},{maxPictureSize:8912896,maxBitrate:6e7,tier:`L`,level:156},{maxPictureSize:8912896,maxBitrate:24e7,tier:`H`,level:156},{maxPictureSize:35651584,maxBitrate:6e7,tier:`L`,level:180},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:180},{maxPictureSize:35651584,maxBitrate:12e7,tier:`L`,level:183},{maxPictureSize:35651584,maxBitrate:48e7,tier:`H`,level:183},{maxPictureSize:35651584,maxBitrate:24e7,tier:`L`,level:186},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:186}],z=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}],Ho=[{maxPictureSize:147456,maxBitrate:15e5,tier:`M`,level:0},{maxPictureSize:278784,maxBitrate:3e6,tier:`M`,level:1},{maxPictureSize:665856,maxBitrate:6e6,tier:`M`,level:4},{maxPictureSize:1065024,maxBitrate:1e7,tier:`M`,level:5},{maxPictureSize:2359296,maxBitrate:12e6,tier:`M`,level:8},{maxPictureSize:2359296,maxBitrate:3e7,tier:`H`,level:8},{maxPictureSize:2359296,maxBitrate:2e7,tier:`M`,level:9},{maxPictureSize:2359296,maxBitrate:5e7,tier:`H`,level:9},{maxPictureSize:8912896,maxBitrate:3e7,tier:`M`,level:12},{maxPictureSize:8912896,maxBitrate:1e8,tier:`H`,level:12},{maxPictureSize:8912896,maxBitrate:4e7,tier:`M`,level:13},{maxPictureSize:8912896,maxBitrate:16e7,tier:`H`,level:13},{maxPictureSize:8912896,maxBitrate:6e7,tier:`M`,level:14},{maxPictureSize:8912896,maxBitrate:24e7,tier:`H`,level:14},{maxPictureSize:35651584,maxBitrate:6e7,tier:`M`,level:15},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:15},{maxPictureSize:35651584,maxBitrate:6e7,tier:`M`,level:16},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:16},{maxPictureSize:35651584,maxBitrate:1e8,tier:`M`,level:17},{maxPictureSize:35651584,maxBitrate:48e7,tier:`H`,level:17},{maxPictureSize:35651584,maxBitrate:16e7,tier:`M`,level:18},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:18},{maxPictureSize:35651584,maxBitrate:16e7,tier:`M`,level:19},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:19}],Uo=`.01.01.01.01.00`,Wo=`.0.110.01.01.01.0`,Go=[`ap4x`,`ap4h`,`apch`,`apcn`,`apcs`,`apco`],Ko=[`dtsc`,`dtsh`,`dtsl`,`dtse`],qo=[{fourCc:`apco`,bitrate:45e6,alpha:!1},{fourCc:`apcs`,bitrate:102e6,alpha:!1},{fourCc:`apcn`,bitrate:147e6,alpha:!1},{fourCc:`apch`,bitrate:22e7,alpha:!1},{fourCc:`ap4h`,bitrate:33e7,alpha:!0},{fourCc:`ap4x`,bitrate:5e8,alpha:!0}],Jo=(e,t,n,r,i)=>{if(e===`avc`){let e=vr(),i=e?66:100,a=Math.ceil(t/16)*Math.ceil(n/16),o=Bo.find(e=>a<=e.maxMacroblocks&&r<=e.maxBitrate)??Rn(Bo),s=o?o.level:0;return`avc1.${i.toString(16).padStart(2,`0`)}${e?`40`:`00`}${s.toString(16).padStart(2,`0`)}`}if(e===`hevc`){let e=t*n,i=Vo.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??Rn(Vo);return`hev1.1.6.${i.tier}${i.level}.B0`}if(e===`vp8`)return`vp8`;if(e===`vp9`){let e=t*n;return`vp09.00.${(z.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??Rn(z)).level.toString().padStart(2,`0`)}.08`}if(e===`av1`){let e=t*n,i=Ho.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??Rn(Ho);return`av01.0.${i.level.toString().padStart(2,`0`)}${i.tier}.08`}if(e===`prores`){let e=(t*n/2073600)**.95,a=qo.filter(e=>e.alpha===i),o=a[0].fourCc,s=1/0;for(let{fourCc:t,bitrate:n}of a){let i=Math.abs(n*e-r);i<s&&(s=i,o=t)}return o}throw rr(e),TypeError(`Unhandled codec '${String(e)}'.`)},Yo=e=>{let t=e.split(`.`);return[1,1,Number(t[1]),2,1,Number(t[2]),3,1,Number(t[3]),4,1,t[4]?Number(t[4]):1]},Xo=e=>{let t=e.split(`.`),n=Number(t[1]),r=t[2],i=Number(r.slice(0,-1)),a=(n<<5)+i,o=+(r.slice(-1)===`H`),s=Number(t[3]),c=s===8?0:1,l=+(s===12),u=t[4]?Number(t[4]):0,d=t[5]?Number(t[5][0]):1,f=t[5]?Number(t[5][1]):1,p=t[5]?Number(t[5][2]):0;return[129,a,(o<<7)+(c<<6)+(l<<5)+(u<<4)+(d<<3)+(f<<2)+p,0]},Zo=e=>{let{codec:t,codecDescription:n,colorSpace:r,avcCodecInfo:i,hevcCodecInfo:a,vp9CodecInfo:o,av1CodecInfo:s,proresFormat:c}=e;if(t===`avc`){if(F(e.avcType!==null),i){let t=new Uint8Array([i.avcProfileIndication,i.profileCompatibility,i.avcLevelIndication]);return`avc${e.avcType}.${$n(t)}`}if(!n||n.byteLength<4)throw TypeError(`AVC decoder description is not provided or is not at least 4 bytes long.`);return`avc${e.avcType}.${$n(n.subarray(1,4))}`}if(t===`hevc`){let e,t,r,i,o,s;if(a)e=a.generalProfileSpace,t=a.generalProfileIdc,r=er(a.generalProfileCompatibilityFlags),i=a.generalTierFlag,o=a.generalLevelIdc,s=[...a.generalConstraintIndicatorFlags];else{if(!n||n.byteLength<23)throw TypeError(`HEVC decoder description is not provided or is not at least 23 bytes long.`);let a=Wn(n),c=a.getUint8(1);e=c>>6&3,t=c&31,r=er(a.getUint32(2)),i=c>>5&1,o=a.getUint8(12),s=[];for(let e=0;e<6;e++)s.push(a.getUint8(6+e))}let c=`hev1.`;for(c+=[``,`A`,`B`,`C`][e]+t,c+=`.`,c+=r.toString(16).toUpperCase(),c+=`.`,c+=i===0?`L`:`H`,c+=o;s.length>0&&s[s.length-1]===0;)s.pop();return s.length>0&&(c+=`.`,c+=s.map(e=>e.toString(16).toUpperCase()).join(`.`)),c}if(t===`vp8`)return`vp8`;if(t===`vp9`){if(!o){let t=e.width*e.height,n=Rn(z).level;for(let e of z)if(t<=e.maxPictureSize){n=e.level;break}return`vp09.00.${n.toString().padStart(2,`0`)}.08`}let t=o.profile.toString().padStart(2,`0`),n=o.level.toString().padStart(2,`0`),r=o.bitDepth.toString().padStart(2,`0`),i=o.chromaSubsampling.toString().padStart(2,`0`),a=o.colourPrimaries.toString().padStart(2,`0`),s=o.transferCharacteristics.toString().padStart(2,`0`),c=o.matrixCoefficients.toString().padStart(2,`0`),l=o.videoFullRangeFlag.toString().padStart(2,`0`),u=`vp09.${t}.${n}.${r}.${i}`;return u+=`.${a}.${s}.${c}.${l}`,u.endsWith(Uo)&&(u=u.slice(0,-15)),u}if(t===`av1`){if(!s){let t=e.width*e.height,n=Rn(z).level;for(let e of z)if(t<=e.maxPictureSize){n=e.level;break}return`av01.0.${n.toString().padStart(2,`0`)}M.08`}let t=s.profile,n=s.level.toString().padStart(2,`0`),i=s.tier?`H`:`M`,a=s.bitDepth.toString().padStart(2,`0`),o=s.monochrome?`1`:`0`,c=100*s.chromaSubsamplingX+10*s.chromaSubsamplingY+1*(s.chromaSubsamplingX&&s.chromaSubsamplingY?s.chromaSamplePosition:0),l,u,d,f;Ri(s)?(l=s.colourPrimaries,u=s.transferCharacteristics,d=s.matrixCoefficients,f=s.videoFullRangeFlag):(l=r?.primaries?qn[r.primaries]:1,u=r?.transfer?Jn[r.transfer]:1,d=r?.matrix?Yn[r.matrix]:1,f=+!!r?.fullRange);let p=`av01.${t}.${n}${i}.${a}`;return p+=`.${o}.${c.toString().padStart(3,`0`)}`,p+=`.${l.toString().padStart(2,`0`)}`,p+=`.${u.toString().padStart(2,`0`)}`,p+=`.${d.toString().padStart(2,`0`)}`,p+=`.${f}`,p.endsWith(Wo)&&(p=p.slice(0,-17)),p}if(t===`prores`)return c??`apch`;throw t!==null&&rr(t),TypeError(`Unhandled codec '${t}'.`)},Qo=(e,t)=>{switch(e){case`aac`:{if(!t.description)return 1024/t.sampleRate;let e=Zr(Un(t.description));if(e.coreSampleRate===null)throw Error(`Invalid AAC sampling frequency index.`);return e.frameLength/e.coreSampleRate}case`opus`:return es;case`mp3`:{let{sampleRate:e,numberOfChannels:n}=t,r=e>=32e3,i=r?1152:576,a=r?32e3:8e3,o=r?511:255,s=r?n===1?17:32:n===1?9:17,c=Math.floor(i/8*a/e)-4-s;return(1+Math.ceil(o/c))*i/e}case`vorbis`:{F(t.description);let e=Un(t.description),n=1,r=2;for(;r>0;)e[n++]<255&&r--;return(1<<(e[n+28]>>4))/2/t.sampleRate}case`ac3`:case`eac3`:return 256/t.sampleRate;case`dts`:return 512/t.sampleRate;case`flac`:case`truehd`:case`pcm-s16`:case`pcm-s16be`:case`pcm-s24`:case`pcm-s24be`:case`pcm-s32`:case`pcm-s32be`:case`pcm-f32`:case`pcm-f32be`:case`pcm-f64`:case`pcm-f64be`:case`pcm-u8`:case`pcm-s8`:case`ulaw`:case`alaw`:return 0;default:rr(e),F(!1)}},$o=48e3,es=.4,ts=/^pcm-([usf])(\d+)(be)?$/,ns=e=>{if(F(Io.includes(e)),e===`ulaw`)return{dataType:`ulaw`,sampleSize:1,littleEndian:!0,silentValue:255};if(e===`alaw`)return{dataType:`alaw`,sampleSize:1,littleEndian:!0,silentValue:213};let t=ts.exec(e);F(t);let n;n=t[1]===`u`?`unsigned`:t[1]===`s`?`signed`:`float`;let r=Number(t[2])/8,i=t[3]!==`be`;return{dataType:n,sampleSize:r,littleEndian:i,silentValue:e===`pcm-u8`?128:0}},rs=e=>e.startsWith(`avc1`)||e.startsWith(`avc3`)?`avc`:e.startsWith(`hev1`)||e.startsWith(`hvc1`)?`hevc`:e===`vp8`?`vp8`:e.startsWith(`vp09`)?`vp9`:e.startsWith(`av01`)?`av1`:Go.includes(e)?`prores`:e===`mp3`||e===`mp4a.69`||e===`mp4a.6B`||e===`mp4a.6b`||e===`mp4a.40.34`?`mp3`:e.startsWith(`mp4a.40.`)||e===`mp4a.67`?`aac`:e===`opus`||e===`Opus`?`opus`:e===`vorbis`?`vorbis`:e===`flac`?`flac`:e===`ac-3`||e===`ac3`?`ac3`:e===`ec-3`||e===`eac3`?`eac3`:Ko.includes(e)?`dts`:e===`mlpa`?`truehd`:e===`ulaw`?`ulaw`:e===`alaw`?`alaw`:ts.test(e)?e:e===`webvtt`?`webvtt`:null,is=e=>e===`avc`?{avc:{format:`avc`}}:e===`hevc`?{hevc:{format:`hevc`}}:{},as=[`avc1`,`avc3`,`hev1`,`hvc1`,`vp8`,`vp09`,`av01`,...Go],os=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,ss=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,cs=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,ls=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,us=(e,t)=>{if(!e)throw TypeError(`Video chunk metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Video chunk metadata must be an object.`);if(!e.decoderConfig)throw TypeError(`Video chunk metadata must include a decoder configuration.`);if(typeof e.decoderConfig!=`object`)throw TypeError(`Video chunk metadata decoder configuration must be an object.`);if(typeof e.decoderConfig.codec!=`string`)throw TypeError(`Video chunk metadata decoder configuration must specify a codec string.`);if(!as.some(t=>e.decoderConfig.codec.startsWith(t)))throw TypeError(`Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the Mediabunny Codec Registry.`);if(!Number.isInteger(e.decoderConfig.codedWidth)||e.decoderConfig.codedWidth<=0)throw TypeError(`Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).`);if(!Number.isInteger(e.decoderConfig.codedHeight)||e.decoderConfig.codedHeight<=0)throw TypeError(`Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).`);if(e.decoderConfig.displayAspectWidth!==void 0&&(!Number.isInteger(e.decoderConfig.displayAspectWidth)||e.decoderConfig.displayAspectWidth<=0))throw TypeError(`Video chunk metadata decoder configuration displayAspectWidth, when defined, must be a positive integer.`);if(e.decoderConfig.displayAspectHeight!==void 0&&(!Number.isInteger(e.decoderConfig.displayAspectHeight)||e.decoderConfig.displayAspectHeight<=0))throw TypeError(`Video chunk metadata decoder configuration displayAspectHeight, when defined, must be a positive integer.`);if(e.decoderConfig.displayAspectWidth!==void 0!=(e.decoderConfig.displayAspectHeight!==void 0))throw TypeError(`Video chunk metadata decoder configuration must specify both displayAspectWidth and displayAspectHeight, or neither.`);if(e.decoderConfig.description!==void 0&&!Zn(e.decoderConfig.description))throw TypeError(`Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.`);if(e.decoderConfig.colorSpace!==void 0){let{colorSpace:t}=e.decoderConfig;if(typeof t!=`object`)throw TypeError(`Video chunk metadata decoder configuration colorSpace, when provided, must be an object.`);let n=Object.keys(qn);if(t.primaries!=null&&!n.includes(t.primaries))throw TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${n.join(`, `)}.`);let r=Object.keys(Jn);if(t.transfer!=null&&!r.includes(t.transfer))throw TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${r.join(`, `)}.`);let i=Object.keys(Yn);if(t.matrix!=null&&!i.includes(t.matrix))throw TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${i.join(`, `)}.`);if(t.fullRange!=null&&typeof t.fullRange!=`boolean`)throw TypeError(`Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.`)}if(e.decoderConfig.codec.startsWith(`avc1`)||e.decoderConfig.codec.startsWith(`avc3`)){if(!os.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.`)}else if(e.decoderConfig.codec.startsWith(`hev1`)||e.decoderConfig.codec.startsWith(`hvc1`)){if(!ss.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.`)}else if(e.decoderConfig.codec.startsWith(`vp8`)){if(e.decoderConfig.codec!==`vp8`)throw TypeError(`Video chunk metadata decoder configuration codec string for VP8 must be "vp8".`)}else if(e.decoderConfig.codec.startsWith(`vp09`)){if(!cs.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section "Codecs Parameter String" of https://www.webmproject.org/vp9/mp4/.`)}else if(e.decoderConfig.codec.startsWith(`av01`)){if(!ls.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section "Codecs Parameter String" of https://aomediacodec.github.io/av1-isobmff/.`)}else if(Go.some(t=>e.decoderConfig.codec.startsWith(t))&&!Go.some(t=>e.decoderConfig.codec===t))throw TypeError(`Video chunk metadata decoder configuration codec string for ProRes must be one of the valid ProRes four-character codes: ${Go.join(`, `)}.`);if(t!==null&&rs(e.decoderConfig.codec)!==t)throw TypeError(`Video chunk metadata decoder configuration codec string '${e.decoderConfig.codec}' does not fit to the track codec '${t}'.`)},ds=[`mp4a`,`mp3`,`opus`,`vorbis`,`flac`,`ulaw`,`alaw`,`pcm`,`ac-3`,`ec-3`,`dts`,`mlpa`],fs=(e,t)=>{if(!e)throw TypeError(`Audio chunk metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Audio chunk metadata must be an object.`);if(!e.decoderConfig)throw TypeError(`Audio chunk metadata must include a decoder configuration.`);if(typeof e.decoderConfig!=`object`)throw TypeError(`Audio chunk metadata decoder configuration must be an object.`);if(typeof e.decoderConfig.codec!=`string`)throw TypeError(`Audio chunk metadata decoder configuration must specify a codec string.`);if(!ds.some(t=>e.decoderConfig.codec.startsWith(t)))throw TypeError(`Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the Mediabunny Codec Registry.`);if(!Number.isInteger(e.decoderConfig.sampleRate)||e.decoderConfig.sampleRate<=0)throw TypeError(`Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).`);if(!Number.isInteger(e.decoderConfig.numberOfChannels)||e.decoderConfig.numberOfChannels<=0)throw TypeError(`Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).`);if(e.decoderConfig.description!==void 0&&!Zn(e.decoderConfig.description))throw TypeError(`Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.`);if(e.decoderConfig.codec.startsWith(`mp4a`)&&e.decoderConfig.codec!==`mp4a.69`&&e.decoderConfig.codec!==`mp4a.6B`&&e.decoderConfig.codec!==`mp4a.6b`){if(![`mp4a.40.2`,`mp4a.40.02`,`mp4a.40.5`,`mp4a.40.05`,`mp4a.40.29`,`mp4a.67`].includes(e.decoderConfig.codec))throw TypeError(`Audio chunk metadata decoder configuration codec string for AAC must be a valid AAC codec string as specified in https://www.w3.org/TR/webcodecs-aac-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`mp3`)||e.decoderConfig.codec.startsWith(`mp4a`)){if(e.decoderConfig.codec!==`mp3`&&e.decoderConfig.codec!==`mp4a.69`&&e.decoderConfig.codec!==`mp4a.6B`&&e.decoderConfig.codec!==`mp4a.6b`)throw TypeError(`Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".`)}else if(e.decoderConfig.codec.startsWith(`opus`)){if(e.decoderConfig.codec!==`opus`)throw TypeError(`Audio chunk metadata decoder configuration codec string for Opus must be "opus".`);if(e.decoderConfig.description&&e.decoderConfig.description.byteLength<18)throw TypeError(`Audio chunk metadata decoder configuration description, when specified, is expected to be an Identification Header as specified in Section 5.1 of RFC 7845.`)}else if(e.decoderConfig.codec.startsWith(`vorbis`)){if(e.decoderConfig.codec!==`vorbis`)throw TypeError(`Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".`);if(!e.decoderConfig.description)throw TypeError(`Audio chunk metadata decoder configuration for Vorbis must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-vorbis-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`flac`)){if(e.decoderConfig.codec!==`flac`)throw TypeError(`Audio chunk metadata decoder configuration codec string for FLAC must be "flac".`);if(!e.decoderConfig.description||e.decoderConfig.description.byteLength<42)throw TypeError(`Audio chunk metadata decoder configuration for FLAC must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-flac-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`ac-3`)||e.decoderConfig.codec.startsWith(`ac3`)){if(e.decoderConfig.codec!==`ac-3`)throw TypeError(`Audio chunk metadata decoder configuration codec string for AC-3 must be "ac-3".`)}else if(e.decoderConfig.codec.startsWith(`ec-3`)||e.decoderConfig.codec.startsWith(`eac3`)){if(e.decoderConfig.codec!==`ec-3`)throw TypeError(`Audio chunk metadata decoder configuration codec string for EC-3 must be "ec-3".`)}else if(e.decoderConfig.codec.startsWith(`dts`)){if(!Ko.includes(e.decoderConfig.codec))throw TypeError(`Audio chunk metadata decoder configuration codec string for DTS must be one of the following four-character codes: ${Ko.join(`, `)}.`)}else if(e.decoderConfig.codec.startsWith(`mlpa`)){if(e.decoderConfig.codec!==`mlpa`)throw TypeError(`Audio chunk metadata decoder configuration codec string for TrueHD must be "mlpa".`)}else if((e.decoderConfig.codec.startsWith(`pcm`)||e.decoderConfig.codec.startsWith(`ulaw`)||e.decoderConfig.codec.startsWith(`alaw`))&&!Io.includes(e.decoderConfig.codec))throw TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${Io.join(`, `)}).`);if(t!==null&&rs(e.decoderConfig.codec)!==t)throw TypeError(`Audio chunk metadata decoder configuration codec string '${e.decoderConfig.codec}' does not fit to the track codec '${t}'.`)},ps=e=>{if(!e)throw TypeError(`Subtitle metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Subtitle metadata must be an object.`);if(!e.config)throw TypeError(`Subtitle metadata must include a config object.`);if(typeof e.config!=`object`)throw TypeError(`Subtitle metadata config must be an object.`);if(typeof e.config.description!=`string`)throw TypeError(`Subtitle metadata config description must be a string.`)},ms=class{constructor(e){this.mutex=new Qn,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateTimestamp(e,t,n){let r=this.trackTimestampInfo.get(e);if(r){if(n&&(r.maxTimestampBeforeLastKeyPacket=r.maxTimestamp),r.maxTimestampBeforeLastKeyPacket!==null&&t<r.maxTimestampBeforeLastKeyPacket)throw Error(`Timestamps cannot be smaller than the largest timestamp of the previous GOP (a GOP begins with a key packet and ends right before the next key packet). Got ${t}s, but largest timestamp is ${r.maxTimestampBeforeLastKeyPacket}s.`);r.maxTimestamp=Math.max(r.maxTimestamp,t)}else{if(!n)throw Error(`First packet must be a key packet.`);r={maxTimestamp:t,maxTimestampBeforeLastKeyPacket:null},this.trackTimestampInfo.set(e,r)}}},hs=class{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeU64(e){this.helperView.setUint32(0,Math.floor(e/2**32),!1),this.helperView.setUint32(4,e,!1),this.writer.write(this.helper.subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)this.helperView.setUint8(t%8,e.charCodeAt(t)),t%8==7&&this.writer.write(this.helper);e.length%8!=0&&this.writer.write(this.helper.subarray(0,e.length%8))}writeBox(e){if(this.offsets.set(e,this.writer.getPos()),e.contents&&!e.children)this.writeBoxHeader(e,e.size??e.contents.byteLength+8),this.writer.write(e.contents);else{let t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(let t of e.children)t&&this.writeBox(t);let n=this.writer.getPos(),r=e.size??n-t;this.writer.seek(t),this.writeBoxHeader(e,r),this.writer.seek(n)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}measureBoxHeader(e){return 8+(e.largeSize?8:0)}patchBox(e){let t=this.offsets.get(e);F(t!==void 0);let n=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(n)}measureBox(e){if(e.contents&&!e.children)return this.measureBoxHeader(e)+e.contents.byteLength;{let t=this.measureBoxHeader(e);if(e.contents&&(t+=e.contents.byteLength),e.children)for(let n of e.children)n&&(t+=this.measureBox(n));return t}}},B=new Uint8Array(8),gs=new DataView(B.buffer),_s=e=>[(e%256+256)%256],V=e=>(gs.setUint16(0,e,!1),[B[0],B[1]]),vs=e=>(gs.setInt16(0,e,!1),[B[0],B[1]]),ys=e=>(gs.setUint32(0,e,!1),[B[1],B[2],B[3]]),H=e=>(gs.setUint32(0,e,!1),[B[0],B[1],B[2],B[3]]),bs=e=>(gs.setInt32(0,e,!1),[B[0],B[1],B[2],B[3]]),xs=e=>(gs.setUint32(0,Math.floor(e/2**32),!1),gs.setUint32(4,e,!1),[B[0],B[1],B[2],B[3],B[4],B[5],B[6],B[7]]),Ss=e=>(gs.setInt32(0,Math.floor(e/2**32),!1),gs.setUint32(4,e,!1),[B[0],B[1],B[2],B[3],B[4],B[5],B[6],B[7]]),Cs=e=>(gs.setInt16(0,256*e,!1),[B[0],B[1]]),ws=e=>(gs.setInt32(0,2**16*e,!1),[B[0],B[1],B[2],B[3]]),Ts=e=>(gs.setInt32(0,2**30*e,!1),[B[0],B[1],B[2],B[3]]),Es=(e,t)=>{let n=[],r=e;do{let e=r&127;r>>=7,n.length>0&&(e|=128),n.push(e),t!==void 0&&t--}while(r>0||t);return n.reverse()},U=(e,t=!1)=>{let n=Array(e.length).fill(null).map((t,n)=>e.charCodeAt(n));return t&&n.push(0),n},Ds=e=>[ws(e[0]),ws(e[1]),Ts(e[2]),ws(e[3]),ws(e[4]),Ts(e[5]),ws(e[6]),ws(e[7]),Ts(e[8])],W=(e,t,n)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:n}),G=(e,t,n,r,i)=>W(e,[_s(t),ys(n),r??[]],i),Os=e=>e.isQuickTime?W(`ftyp`,[U(`qt `),H(512),U(`qt `)]):e.fragmented?e.cmaf?W(`ftyp`,[U(`iso5`),H(512),U(`iso5`),U(`iso6`),U(`mp41`),U(`cmfc`),U(`dash`)]):W(`ftyp`,[U(`iso5`),H(512),U(`iso5`),U(`iso6`),U(`mp41`)]):W(`ftyp`,[U(`isom`),H(512),U(`isom`),e.holdsAvc?U(`avc1`):[],U(`mp41`)]),ks=()=>W(`styp`,[U(`iso5`),H(0),U(`iso5`),U(`iso6`),U(`mp41`),U(`cmfc`),U(`dash`)]),As=(e,t)=>{let n=Math.max(0,e.minWrittenTimestamp),r=Math.max(0,e.maxWrittenEndTimestamp-n);return Number.isFinite(r)||(r=0),G(`sidx`,1,0,[H(1),H(ul),xs(K(n,ul)),xs(0),V(0),V(1),H(t&2147483647),H(K(r,ul)),H(0)])},js=e=>({type:`mdat`,largeSize:e}),Ms=e=>({type:`free`,size:e}),Ns=e=>W(`moov`,void 0,[Ps(e.creationTime,e.trackDatas),...e.trackDatas.map(t=>Fs(t,e.creationTime)),e.isFragmented?Ec(e.trackDatas):null,Vc(e)]),Ps=(e,t)=>{let n=Math.max(0,...t.map(e=>Math.max(0,K(pl(e),ul)+K(e.startTimestampOffset??0,ul)))),r=Math.max(0,...t.map(e=>e.track.id))+1,i=!zn(e)||!zn(n),a=i?xs:H;return G(`mvhd`,+i,0,[a(e),a(e),H(ul),a(n),ws(1),Cs(1),Array(10).fill(0),Ds(kn),Array(24).fill(0),H(r)])},Fs=(e,t)=>{let n=fl(e),r=e.startTimestampOffset!==null&&e.startTimestampOffset!==0;return W(`trak`,void 0,[Is(e,t),r?Ls(e):null,Rs(e,t),n.name===void 0?null:W(`udta`,void 0,[W(`name`,[...Kn.encode(n.name)])])])},Is=(e,t)=>{let n=Math.max(0,K(pl(e),ul)+K(e.startTimestampOffset??0,ul)),r=!zn(t)||!zn(n),i=r?xs:H,a;if(e.type===`video`&&e.track.metadata.transformationMatrix)a=e.track.metadata.transformationMatrix;else if(e.type===`video`){let{rotation:t,flip:n}=e.track.metadata;a=An(In(Nn(t??0),Fn(n?-1:1,1)),e.info.width,e.info.height)}else a=kn;let o=2;e.track.metadata.disposition?.default!==!1&&(o|=1);let s=e.type===`video`?0:e.type===`audio`?1:e.type===`subtitle`?2:rr(e);return G(`tkhd`,+r,o,[i(t),i(t),H(e.track.id),H(0),i(n),Array(8).fill(0),V(0),V(s),Cs(+(e.type===`audio`)),V(0),Ds(a),ws(e.type===`video`?e.info.width:0),ws(e.type===`video`?e.info.height:0)])},Ls=e=>{let t=e.startTimestampOffset;if(F(t!==null),t>0){let n=K(t,ul),r=K(pl(e),ul),i=!zn(n)||!zn(r),a=i?xs:H,o=i?Ss:bs;return W(`edts`,void 0,[G(`elst`,+!!i,0,[H(2),a(n),o(-1),ws(1),a(r),o(0),ws(1)])])}{let n=K(-t,e.timescale),r=Math.max(0,K(pl(e),ul)+K(t,ul)),i=!Bn(n)||!zn(r),a=i?xs:H,o=i?Ss:bs;return W(`edts`,void 0,[G(`elst`,+!!i,0,[H(1),a(r),o(n),ws(1)])])}},Rs=(e,t)=>W(`mdia`,void 0,[zs(e,t),Hs(!0,Bs[e.type],Vs[e.type]),Us(e)]),zs=(e,t)=>{let n=K(pl(e),e.timescale),r=!zn(t)||!zn(n),i=r?xs:H;return G(`mdhd`,+r,0,[i(t),i(t),H(e.timescale),i(n),V(nl(e.track.metadata.languageCode??`und`)),V(0)])},Bs={video:`vide`,audio:`soun`,subtitle:`text`},Vs={video:`MediabunnyVideoHandler`,audio:`MediabunnySoundHandler`,subtitle:`MediabunnyTextHandler`},Hs=(e,t,n,r=`\0\0\0\0`)=>G(`hdlr`,0,0,[e?U(`mhlr`):H(0),U(t),U(r),H(0),H(0),U(n,!0)]),Us=e=>W(`minf`,void 0,[Ws[e.type](),Gs(),Js(e)]),Ws={video:()=>G(`vmhd`,0,1,[V(0),V(0),V(0),V(0)]),audio:()=>G(`smhd`,0,0,[V(0),V(0)]),subtitle:()=>G(`nmhd`,0,0)},Gs=()=>W(`dinf`,void 0,[Ks()]),Ks=()=>G(`dref`,0,0,[H(1)],[qs()]),qs=()=>G(`url `,0,1),Js=e=>{let t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(e=>e.sampleCompositionTimeOffset!==0);return W(`stbl`,void 0,[Ys(e),vc(e),t?Cc(e):null,t?wc(e):null,bc(e),xc(e),Sc(e),yc(e),...Tc(e.samples,!1)])},Ys=e=>{let t;if(e.type===`video`)t=Xs(Xc(e.track.source._codec,e.info.decoderConfig.codec),e);else if(e.type===`audio`){let n=Qc(e.track.source._codec,e.info.decoderConfig.codec,e.muxer.isQuickTime);F(n),t=ic(n,e)}else e.type===`subtitle`&&(t=gc(el[e.track.source._codec],e));return F(t),G(`stsd`,0,0,[H(1)],[t])},Xs=(e,t)=>W(e,[[,,,,,,].fill(0),V(1),V(0),V(0),Array(12).fill(0),V(t.info.width),V(t.info.height),H(4718592),H(4718592),H(0),V(1),_s(oi.length),U(oi),Array(31-oi.length).fill(0),V(t.info.hasAlphaChannel?32:24),vs(65535)],[Zc[t.track.source._codec]?.(t)??null,Qs(t),Xn(t.info.decoderConfig.colorSpace)?null:$s(t),Zs(t)]),Zs=e=>e.avgBitrate===0&&e.maxBitrate===0?null:W(`btrt`,[H(0),H(e.maxBitrate),H(e.avgBitrate)]),Qs=e=>e.info.pixelAspectRatio.num===e.info.pixelAspectRatio.den?null:W(`pasp`,[H(e.info.pixelAspectRatio.num),H(e.info.pixelAspectRatio.den)]),$s=e=>{let t=e.info.decoderConfig.colorSpace;return W(`colr`,[U(e.muxer.isQuickTime?`nclc`:`nclx`),V(t?.primaries==null?2:qn[t.primaries]),V(t?.transfer==null?2:Jn[t.transfer]),V(t?.matrix==null?2:Yn[t.matrix]),e.muxer.isQuickTime?[]:_s(!!t?.fullRange<<7)])},ec=e=>e.info.decoderConfig&&W(`avcC`,[...Un(e.info.decoderConfig.description)]),tc=e=>e.info.decoderConfig&&W(`hvcC`,[...Un(e.info.decoderConfig.description)]),nc=e=>{if(!e.info.decoderConfig)return null;let t=e.info.decoderConfig,n=t.codec.split(`.`),r=Number(n[1]),i=Number(n[2]),a=Number(n[3]),o=n[4]?Number(n[4]):1,s=n[8]?Number(n[8]):Number(t.colorSpace?.fullRange??0),c=(a<<4)+(o<<1)+s,l=n[5]?Number(n[5]):t.colorSpace?.primaries?qn[t.colorSpace.primaries]:1,u=n[6]?Number(n[6]):t.colorSpace?.transfer?Jn[t.colorSpace.transfer]:1,d=n[7]?Number(n[7]):t.colorSpace?.matrix?Yn[t.colorSpace.matrix]:1;return G(`vpcC`,1,0,[_s(r),_s(i),_s(c),_s(l),_s(u),_s(d),V(0)])},rc=e=>W(`av1C`,Xo(e.info.decoderConfig.codec)),ic=(e,t)=>{let n=0,r,i=16,a=Io.includes(t.track.source._codec);if(a){let e=t.track.source._codec,{sampleSize:r}=ns(e);i=8*r,i>16&&(n=1)}if(t.muxer.isQuickTime&&t.track.source._codec!==`truehd`&&(n=1),n===0)r=[[,,,,,,].fill(0),V(1),V(n),V(0),H(0),V(t.info.numberOfChannels),V(i),V(0),V(0),t.track.source._codec===`truehd`?H(t.info.sampleRate):[V(t.info.sampleRate<2**16?t.info.sampleRate:0),V(0)]];else{let e=a?0:-2;r=[[,,,,,,].fill(0),V(1),V(n),V(0),H(0),V(t.info.numberOfChannels),V(Math.min(i,16)),vs(e),V(0),V(t.info.sampleRate<2**16?t.info.sampleRate:0),V(0),a?[H(1),H(i/8),H(t.info.numberOfChannels*i/8)]:[H(0),H(0),H(0)],H(2)]}return W(e,r,[$c(t.track.source._codec,t.muxer.isQuickTime)?.(t)??null,Zs(t)])},ac=e=>{let t;switch(e.track.source._codec){case`aac`:t=64;break;case`mp3`:t=107;break;case`vorbis`:t=221;break;default:throw Error(`Unhandled audio codec: ${e.track.source._codec}`)}let n=[..._s(t),..._s(21),...ys(0),...H(e.maxBitrate),...H(e.avgBitrate)];if(e.info.decoderConfig.description){let t=Un(e.info.decoderConfig.description);n=[...n,..._s(5),...Es(t.byteLength),...t]}return n=[...V(1),..._s(0),..._s(4),...Es(n.length),...n,..._s(6),..._s(1),..._s(2)],n=[..._s(3),...Es(n.length),...n],G(`esds`,0,0,n)},oc=e=>W(`wave`,void 0,[sc(e),cc(e),W(`\0\0\0\0`)]),sc=e=>W(`frma`,[U(Qc(e.track.source._codec,e.info.decoderConfig.codec,e.muxer.isQuickTime))]),cc=e=>{let{littleEndian:t}=ns(e.track.source._codec);return W(`enda`,[V(+t)])},lc=e=>{let t=e.info.numberOfChannels,n=312,r=e.info.sampleRate,i=0,a=0,o=new Uint8Array,s=e.info.decoderConfig?.description;if(s){F(s.byteLength>=18);let e=zi(Un(s));t=e.outputChannelCount,n=e.preSkip,r=e.inputSampleRate,i=e.outputGain,a=e.channelMappingFamily,e.channelMappingTable&&(o=e.channelMappingTable)}return W(`dOps`,[_s(0),_s(t),V(n),H(r),vs(i),_s(a),...o])},uc=e=>{let t=e.info.decoderConfig?.description;return F(t),G(`dfLa`,0,0,[...Un(t).subarray(4)])},dc=e=>{let{littleEndian:t,sampleSize:n}=ns(e.track.source._codec);return G(`pcmC`,0,0,[_s(+t),_s(8*n)])},fc=e=>{F(e.info.primingPacket);let t=Gi(e.info.primingPacket.data);if(!t)throw Error(`Couldn't extract AC-3 frame info from the audio packet. Ensure the packets contain valid AC-3 sync frames (as specified in ETSI TS 102 366).`);let n=new Uint8Array(3),r=new qr(n);return r.writeBits(2,t.fscod),r.writeBits(5,t.bsid),r.writeBits(3,t.bsmod),r.writeBits(3,t.acmod),r.writeBits(1,t.lfeon),r.writeBits(5,t.bitRateCode),r.writeBits(5,0),W(`dac3`,[...n])},pc=e=>{F(e.info.primingPacket);let t=qi(e.info.primingPacket.data);if(!t)throw Error(`Couldn't extract E-AC-3 frame info from the audio packet. Ensure the packets contain valid E-AC-3 sync frames (as specified in ETSI TS 102 366).`);let n=16;for(let e of t.substreams)n+=23,e.numDepSub>0?n+=9:n+=1;let r=Math.ceil(n/8),i=new Uint8Array(r),a=new qr(i);a.writeBits(13,t.dataRate),a.writeBits(3,t.substreams.length-1);for(let e of t.substreams)a.writeBits(2,e.fscod),a.writeBits(5,e.bsid),a.writeBits(1,0),a.writeBits(1,0),a.writeBits(3,e.bsmod),a.writeBits(3,e.acmod),a.writeBits(1,e.lfeon),a.writeBits(3,0),a.writeBits(4,e.numDepSub),e.numDepSub>0?a.writeBits(9,e.chanLoc):a.writeBits(1,0);return W(`dec3`,[...i])},mc=e=>{F(e.info.primingPacket);let t=ia(e.info.primingPacket.data);if(!t)throw Error(`Couldn't extract DTS frame info from the audio packet. Ensure the packets contain valid DTS frames as specified in ETSI TS 102 114.`);return W(`ddts`,[...oa(t)])},hc=e=>{F(e.info.primingPacket);let t=e.info.primingPacket.data;if(Ui(`truehd`,t)!==`key`)throw Error(`Couldn't extract TrueHD stream info from the audio packet. Ensure the first packet is an access unit carrying a major sync.`);let n=Wn(t),r=n.getUint32(8),i=n.getUint16(18)&32767;return W(`dmlp`,[H(r),V(i<<1),H(0)])},gc=(e,t)=>W(e,[[,,,,,,].fill(0),V(1)],[tl[t.track.source._codec](t),Zs(t)]),_c=e=>W(`vttC`,[...Kn.encode(e.info.config.description)]),vc=e=>G(`stts`,0,0,[H(e.timeToSampleTable.length),e.timeToSampleTable.map(e=>[H(e.sampleCount),H(e.sampleDelta)])]),yc=e=>{if(e.samples.every(e=>e.type===`key`))return null;let t=[...e.samples.entries()].filter(([,e])=>e.type===`key`);return G(`stss`,0,0,[H(t.length),t.map(([e])=>H(e+1))])},bc=e=>G(`stsc`,0,0,[H(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(e=>[H(e.firstChunk),H(e.samplesPerChunk),H(1)])]),xc=e=>{if(e.type===`audio`&&e.info.requiresPcmTransformation){let{sampleSize:t}=ns(e.track.source._codec);return G(`stsz`,0,0,[H(t*e.info.numberOfChannels),H(e.samples.reduce((t,n)=>t+K(n.duration,e.timescale),0))])}return G(`stsz`,0,0,[H(0),H(e.samples.length),e.samples.map(e=>H(e.size))])},Sc=e=>e.finalizedChunks.length>0&&Rn(e.finalizedChunks).offset>=2**32?G(`co64`,0,0,[H(e.finalizedChunks.length),e.finalizedChunks.map(e=>xs(e.offset))]):G(`stco`,0,0,[H(e.finalizedChunks.length),e.finalizedChunks.map(e=>H(e.offset))]),Cc=e=>G(`ctts`,1,0,[H(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(e=>[H(e.sampleCount),bs(e.sampleCompositionTimeOffset)])]),wc=e=>{if(F(e.compositionTimeOffsetTable.length>0),e.samples.length===0)return null;let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let r=0;r<e.compositionTimeOffsetTable.length;r++){let i=e.compositionTimeOffsetTable[r];t=Math.min(t,i.sampleCompositionTimeOffset),n=Math.max(n,i.sampleCompositionTimeOffset)}for(let t=0;t<e.samples.length;t++){let n=e.samples[t];r=Math.min(r,K(n.timestamp,e.timescale)),i=Math.max(i,K(n.timestamp+n.duration,e.timescale))}let a=Math.max(-t,0);return i>=2**31?null:G(`cslg`,0,0,[bs(a),bs(t),bs(n),bs(r),bs(i)])},Tc=(e,t)=>{let n=[];for(let t of e)if(n.length===0)n.push({sampleCount:1,prerollSamples:t.prerollSamples});else{let e=n[n.length-1];e.prerollSamples===t.prerollSamples?e.sampleCount++:n.push({sampleCount:1,prerollSamples:t.prerollSamples})}let r=n.filter(e=>e.prerollSamples!==0);if(r.length===0)return[];let i=t?65537:1;return[G(`sgpd`,1,0,[U(`roll`),H(2),H(r.length),...r.map(e=>vs(e.prerollSamples))]),G(`sbgp`,0,0,[U(`roll`),H(n.length),...n.map(e=>[H(e.sampleCount),H(e.prerollSamples===0?0:i++)])])]},Ec=e=>W(`mvex`,void 0,e.map(Dc)),Dc=e=>G(`trex`,0,0,[H(e.track.id),H(1),H(0),H(0),H(0)]),Oc=(e,t)=>W(`moof`,void 0,[kc(e),...t.map(jc)]),kc=e=>G(`mfhd`,0,0,[H(e)]),Ac=e=>{let t=0,n=0,r=e.type===`delta`;return n|=+r,t|=r?1:2,t<<24|n<<16},jc=e=>W(`traf`,void 0,[Mc(e),Nc(e),Pc(e),...Tc(e.currentChunk.samples,!0)]),Mc=e=>{F(e.currentChunk);let t=0;t|=8,t|=16,t|=32,t|=131072;let n=e.currentChunk.samples[1]??e.currentChunk.samples[0],r={duration:n.timescaleUnitsToNextSample,size:n.size,flags:Ac(n)};return G(`tfhd`,0,t,[H(e.track.id),H(r.duration),H(r.size),H(r.flags)])},Nc=e=>(F(e.currentChunk),G(`tfdt`,1,0,[xs(K(e.currentChunk.startTimestamp,e.timescale))])),Pc=e=>{F(e.currentChunk);let t=e.currentChunk.samples.map(e=>e.timescaleUnitsToNextSample),n=e.currentChunk.samples.map(e=>e.size),r=e.currentChunk.samples.map(Ac),i=e.currentChunk.samples.map(t=>K(t.timestamp-t.decodeTimestamp,e.timescale)),a=new Set(t),o=new Set(n),s=new Set(r),c=new Set(i),l=s.size===2&&r[0]!==r[1],u=a.size>1,d=o.size>1,f=!l&&s.size>1,p=c.size>1||[...c].some(e=>e!==0),m=0;return m|=1,m|=4*l,m|=256*u,m|=512*d,m|=1024*f,m|=2048*p,G(`trun`,1,m,[H(e.currentChunk.samples.length),H(e.currentChunk.offset-e.currentChunk.moofOffset||0),l?H(r[0]):[],e.currentChunk.samples.map((e,a)=>[u?H(t[a]):[],d?H(n[a]):[],f?H(r[a]):[],p?bs(i[a]):[]])])},Fc=e=>W(`mfra`,void 0,[...e.map(Ic),Lc()]),Ic=e=>{let t=[];for(let n of e.finalizedChunks){let r=n.samples.findIndex(e=>e.type===`key`);if(r===-1)continue;let i=n.samples[r];t.push([xs(K(i.timestamp,e.timescale)),xs(n.moofOffset),H(n.trafIndex+1),H(1),H(r+1)])}return G(`tfra`,1,0,[H(e.track.id),H(63),H(t.length),t])},Lc=()=>G(`mfro`,0,0,[H(0)]),Rc=()=>W(`vtte`),zc=(e,t,n,r,i)=>W(`vttc`,void 0,[i===null?null:W(`vsid`,[bs(i)]),n===null?null:W(`iden`,[...Kn.encode(n)]),t===null?null:W(`ctim`,[...Kn.encode(ua(t))]),r===null?null:W(`sttg`,[...Kn.encode(r)]),W(`payl`,[...Kn.encode(e)])]),Bc=e=>W(`vtta`,[...Kn.encode(e)]),Vc=e=>{let t=[],n=e.format._options.metadataFormat??`auto`,r=e.output._metadataTags;if(n===`mdir`||n===`auto`&&!e.isQuickTime){let e=qc(r);e&&t.push(e)}else if(n===`mdta`){let e=Jc(r);e&&t.push(e)}else(n===`udta`||n===`auto`&&e.isQuickTime)&&Hc(t,e.output._metadataTags);return t.length===0?null:W(`udta`,void 0,t)},Hc=(e,t)=>{for(let{key:n,value:r}of kr(t))switch(n){case`title`:e.push(Uc(`©nam`,r));break;case`description`:e.push(Uc(`©des`,r));break;case`artist`:e.push(Uc(`©ART`,r));break;case`album`:e.push(Uc(`©alb`,r));break;case`albumArtist`:e.push(Uc(`albr`,r));break;case`genre`:e.push(Uc(`©gen`,r));break;case`date`:e.push(Uc(`©day`,r.toISOString().slice(0,10)));break;case`comment`:e.push(Uc(`©cmt`,r));break;case`lyrics`:e.push(Uc(`©lyr`,r));break;case`raw`:break;case`creationTime`:break;case`discNumber`:case`discsTotal`:case`trackNumber`:case`tracksTotal`:case`beatsPerMinute`:case`images`:break;default:rr(n)}if(t.raw)for(let n in t.raw){let r=t.raw[n];r==null||n.length!==4||e.some(e=>e.type===n)||(typeof r==`string`?e.push(Uc(n,r)):r instanceof Uint8Array&&e.push(W(n,Array.from(r))))}},Uc=(e,t)=>{let n=Kn.encode(t);return W(e,[V(n.length),V(nl(`und`)),Array.from(n)])},Wc={"image/jpeg":13,"image/png":14,"image/bmp":27},Gc=new Set([`HMMT`,`loci`,`chpl`]),Kc=(e,t)=>{let n=[];for(let{key:r,value:i}of kr(e))switch(r){case`title`:n.push({key:t?`title`:`©nam`,value:Yc(i)});break;case`description`:n.push({key:t?`description`:`©des`,value:Yc(i)});break;case`artist`:n.push({key:t?`artist`:`©ART`,value:Yc(i)});break;case`album`:n.push({key:t?`album`:`©alb`,value:Yc(i)});break;case`albumArtist`:n.push({key:t?`album_artist`:`aART`,value:Yc(i)});break;case`comment`:n.push({key:t?`comment`:`©cmt`,value:Yc(i)});break;case`genre`:n.push({key:t?`genre`:`©gen`,value:Yc(i)});break;case`beatsPerMinute`:t||n.push({key:`tmpo`,value:W(`data`,[H(21),H(0),V(i)])});break;case`lyrics`:n.push({key:t?`lyrics`:`©lyr`,value:Yc(i)});break;case`date`:n.push({key:t?`date`:`©day`,value:Yc(i.toISOString().slice(0,10))});break;case`images`:for(let e of i)e.kind===`coverFront`&&n.push({key:`covr`,value:W(`data`,[H(Wc[e.mimeType]??0),H(0),Array.from(e.data)])});break;case`trackNumber`:if(t){let t=e.tracksTotal===void 0?i.toString():`${i}/${e.tracksTotal}`;n.push({key:`track`,value:Yc(t)})}else n.push({key:`trkn`,value:W(`data`,[H(0),H(0),V(0),V(i),V(e.tracksTotal??0),V(0)])});break;case`discNumber`:t||n.push({key:`disc`,value:W(`data`,[H(0),H(0),V(0),V(i),V(e.discsTotal??0),V(0)])});break;case`tracksTotal`:case`discsTotal`:break;case`raw`:break;case`creationTime`:break;default:rr(r)}if(e.raw)for(let r in e.raw){let i=e.raw[r];i==null||!t&&(r.length!==4||Gc.has(r))||n.some(e=>e.key===r)||(typeof i==`string`?n.push({key:r,value:Yc(i)}):i instanceof Uint8Array?n.push({key:r,value:W(`data`,[H(0),H(0),Array.from(i)])}):i instanceof Ur&&n.push({key:r,value:W(`data`,[H(Wc[i.mimeType]??0),H(0),Array.from(i.data)])}))}return n},qc=e=>{let t=Kc(e,!1);return t.length===0?null:G(`meta`,0,0,void 0,[Hs(!1,`mdir`,``,`appl`),W(`ilst`,void 0,t.map(e=>W(e.key,void 0,[e.value])))])},Jc=e=>{let t=Kc(e,!0);return t.length===0?null:W(`meta`,void 0,[Hs(!1,`mdta`,``),G(`keys`,0,0,[H(t.length)],t.map(e=>W(`mdta`,[...Kn.encode(e.key)]))),W(`ilst`,void 0,t.map((e,t)=>W(String.fromCharCode(...H(t+1)),void 0,[e.value])))])},Yc=e=>W(`data`,[H(1),H(0),...Kn.encode(e)]),Xc=(e,t)=>{switch(e){case`avc`:return t.startsWith(`avc3`)?`avc3`:`avc1`;case`hevc`:return`hvc1`;case`vp8`:return`vp08`;case`vp9`:return`vp09`;case`av1`:return`av01`;case`prores`:return t}},Zc={avc:ec,hevc:tc,vp8:nc,vp9:nc,av1:rc,prores:null},Qc=(e,t,n)=>{switch(e){case`aac`:return`mp4a`;case`mp3`:return`mp4a`;case`opus`:return`Opus`;case`vorbis`:return`mp4a`;case`flac`:return`fLaC`;case`ulaw`:return`ulaw`;case`alaw`:return`alaw`;case`pcm-u8`:return`raw `;case`pcm-s8`:return`sowt`;case`ac3`:return`ac-3`;case`eac3`:return`ec-3`;case`dts`:return t;case`truehd`:return`mlpa`}if(n)switch(e){case`pcm-s16`:return`sowt`;case`pcm-s16be`:return`twos`;case`pcm-s24`:return`in24`;case`pcm-s24be`:return`in24`;case`pcm-s32`:return`in32`;case`pcm-s32be`:return`in32`;case`pcm-f32`:return`fl32`;case`pcm-f32be`:return`fl32`;case`pcm-f64`:return`fl64`;case`pcm-f64be`:return`fl64`}else switch(e){case`pcm-s16`:return`ipcm`;case`pcm-s16be`:return`ipcm`;case`pcm-s24`:return`ipcm`;case`pcm-s24be`:return`ipcm`;case`pcm-s32`:return`ipcm`;case`pcm-s32be`:return`ipcm`;case`pcm-f32`:return`fpcm`;case`pcm-f32be`:return`fpcm`;case`pcm-f64`:return`fpcm`;case`pcm-f64be`:return`fpcm`}},$c=(e,t)=>{switch(e){case`aac`:return ac;case`mp3`:return ac;case`opus`:return lc;case`vorbis`:return ac;case`flac`:return uc;case`ac3`:return fc;case`eac3`:return pc;case`dts`:return mc;case`truehd`:return hc}if(t)switch(e){case`pcm-s24`:return oc;case`pcm-s24be`:return oc;case`pcm-s32`:return oc;case`pcm-s32be`:return oc;case`pcm-f32`:return oc;case`pcm-f32be`:return oc;case`pcm-f64`:return oc;case`pcm-f64be`:return oc}else switch(e){case`pcm-s16`:return dc;case`pcm-s16be`:return dc;case`pcm-s24`:return dc;case`pcm-s24be`:return dc;case`pcm-s32`:return dc;case`pcm-s32be`:return dc;case`pcm-f32`:return dc;case`pcm-f32be`:return dc;case`pcm-f64`:return dc;case`pcm-f64be`:return dc}return null},el={webvtt:`wvtt`},tl={webvtt:_c},nl=e=>{F(e.length===3);let t=0;for(let n=0;n<3;n++)t<<=5,t+=e.charCodeAt(n)-96;return t},rl=class{constructor(e,t){if(this.finalized=!1,this.started=!1,this.pos=0,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1,e._writerAcquired)throw Error(`Can't have multiple Writers for the same Target.`);this.target=e,e._setMonotonicity(t),e._writerAcquired=!0}start(){F(!this.started),this.target._start(),this.started=!0}write(e){F(this.started&&!this.finalized),this.maybeTrackWrites(e),this.target._write(e,this.pos),this.pos+=e.byteLength}seek(e){this.pos=e}getPos(){return this.pos}async flush(){return F(this.started&&!this.finalized),this.target._flush()}async finalize(){F(this.started&&!this.finalized),await this.target._finalize(),this.finalized=!0}maybeTrackWrites(e){if(!this.trackedWrites)return;let t=this.getPos();if(t<this.trackedStart){if(t+e.byteLength<=this.trackedStart)return;e=e.subarray(this.trackedStart-t),t=0}let n=t+e.byteLength-this.trackedStart,r=this.trackedWrites.byteLength;for(;r<n;)r*=2;if(r!==this.trackedWrites.byteLength){let e=new Uint8Array(r);e.set(this.trackedWrites,0),this.trackedWrites=e}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(1024),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw Error(`Internal error: Can't get tracked writes since nothing was tracked.`);let e={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,e}};go();var il=class extends zr{constructor(){super(...arguments),this._writerAcquired=!1,this._monotonicity=null,this.onwrite=null}_setMonotonicity(e){this._monotonicity!==!1&&(this._monotonicity=e)}_dispatchWrite(e,t){this.onwrite?.(e,t),this._emit(`write`,{start:e,end:t})}slice(e){if(!Number.isInteger(e)||e<0)throw TypeError(`offset must be a non-negative integer.`);return new cl(this,e)}},al=2**16,ol=2**32,sl=class extends il{constructor(e={}){if(super(),this.buffer=null,this._maxPos=0,!e||typeof e!=`object`)throw TypeError(`BufferTarget options, when provided, must be an object.`);if(e.onFinalize!==void 0&&typeof e.onFinalize!=`function`)throw TypeError(`options.onFinalize, when provided, must be a function.`);if(this._options=e,this._supportsResize=`resize`in new ArrayBuffer(0),this._supportsResize)try{this._buffer=new ArrayBuffer(al,{maxByteLength:ol})}catch{this._buffer=new ArrayBuffer(al),this._supportsResize=!1}else this._buffer=new ArrayBuffer(al);this._bytes=new Uint8Array(this._buffer)}_ensureSize(e){F(this._buffer),F(this._bytes);let t=this._buffer.byteLength;for(;t<e;)t*=2;if(t!==this._buffer.byteLength){if(t>ol)throw Error(`ArrayBuffer exceeded maximum size of ${ol} bytes. Please consider using another target.`);if(this._supportsResize)this._buffer.resize(t);else{let e=new ArrayBuffer(t),n=new Uint8Array(e);n.set(this._bytes,0),this._buffer=e,this._bytes=n}}}_start(){}_write(e,t){F(this._bytes),this._ensureSize(t+e.byteLength),this._bytes.set(e,t),this._maxPos=Math.max(this._maxPos,t+e.byteLength),this._dispatchWrite(t,t+e.byteLength)}async _flush(){}async _finalize(){F(this._buffer),this.buffer=`transferToFixedLength`in this._buffer?this._buffer.transferToFixedLength(this._maxPos):this._buffer.slice(0,this._maxPos),this._buffer=null,this._bytes=null,this._options.onFinalize&&await this._options.onFinalize(this.buffer),this._emit(`finalized`)}async _close(){}_getSlice(e,t){return F(this._bytes),this._bytes.slice(e,t)}},cl=class extends il{constructor(e,t){super(),this._baseTarget=e,this._offset=t}_start(){}_write(e,t){this._baseTarget._write(e,this._offset+t),this._dispatchWrite(t,t+e.byteLength)}_flush(){return this._baseTarget._flush()}async _finalize(){this._emit(`finalized`)}async _close(){}_setMonotonicity(e){super._setMonotonicity(e),this._baseTarget._setMonotonicity(e)}},ll=class{constructor(e,t){if(this.rootPath=e,this.getTarget=t,typeof e!=`string`)throw TypeError(`rootPath must be a string.`);if(typeof t!=`function`)throw TypeError(`getTarget must be a function.`)}},ul=57600,dl=.5,fl=e=>{let t={},n=e.track;return n.metadata.name!==void 0&&(t.name=n.metadata.name),t},K=(e,t,n=!0)=>{let r=e*t;return n?Math.round(r):r},pl=e=>{if(e.samples.length===0)return 0;let t=1/0,n=-1/0;for(let r=0;r<e.samples.length;r++){let i=e.samples[r];i.timestamp<t&&(t=i.timestamp),i.timestamp+i.duration>n&&(n=i.timestamp+i.duration)}return t===1/0?0:n-t},ml=class extends ms{constructor(e,t){super(e),this.writer=null,this.boxWriter=null,this.initWriter=null,this.initBoxWriter=null,this.auxTarget=new sl,this.auxWriter=new rl(this.auxTarget,!1),this.auxBoxWriter=new hs(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=nr(),this.finalizedChunks=[],this.wroteFragmentedHeader=!1,this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.minWrittenTimestamp=1/0,this.maxWrittenEndTimestamp=-1/0,this.segmentHeaderSize=null,this.format=t,this.formatOptions={...t._options},this.isQuickTime=t instanceof Tl,this.isCmaf=t instanceof wl,this.minimumFragmentDuration=this.formatOptions.minimumFragmentDuration??(t instanceof wl?1/0:1),this.auxWriter.start()}async start(){let e=await this.mutex.acquire(),t=this.output._metadataTags.creationTime===void 0?new Date:this.output._metadataTags.creationTime;if(this.creationTime=t?Math.floor(t.getTime()/1e3)+Qa:0,t&&this.creationTime<=0)throw Error(`creationTime must be after 1904-01-01T00:00:00Z for MP4/QuickTime files.`);if(this.isCmaf?(this.fastStart=`fragmented`,this.isFragmented=!0):(this.writer=await this.output._getRootWriter(e=>this.formatOptions.fastStart===void 0?e instanceof sl:this.formatOptions.fastStart===`fragmented`),this.boxWriter=new hs(this.writer),this.fastStart=this.formatOptions.fastStart??(this.writer.target instanceof sl&&`in-memory`),this.isFragmented=this.fastStart===`fragmented`),this.isCmaf){if(!this.output._hasInitTarget())throw Error(`CMAF outputs require the initTarget field in OutputOptions to be set; the init segment will be written to it.`);let e=new rl(await this.output._getInitTarget(),!0);e.start(),this.initWriter=e,this.initBoxWriter=new hs(e)}let n=this.output.tracks.some(e=>e.isVideoTrack()&&e.source._codec===`avc`);{let e=this.initBoxWriter??this.boxWriter;if(F(e),this.formatOptions.onFtyp&&e.writer.startTrackingWrites(),e.writeBox(Os({isQuickTime:this.isQuickTime,holdsAvc:n,fragmented:this.isFragmented,cmaf:this.isCmaf})),this.formatOptions.onFtyp){let{data:t,start:n}=e.writer.stopTrackingWrites();this.formatOptions.onFtyp(t,n)}this.ftypSize=e.writer.getPos(),this.isCmaf&&await this.initWriter.flush()}if(this.fastStart!==`in-memory`){if(this.fastStart===`reserve`)for(let e of this.output.tracks){if(e.metadata.maximumPacketCount===void 0)throw Error(`All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.`);if(e.metadata.maximumPacketCount>2**32-1)throw Error(`Track #${e.id} has a maximumPacketCount of ${e.metadata.maximumPacketCount}, which exceeds the maximum of ${2**32-1} packets per track that a non-fragmented file can hold.`)}else this.isFragmented||(F(this.writer),F(this.boxWriter),this.formatOptions.onMdat&&this.writer.startTrackingWrites(),this.mdat=js(!0),this.boxWriter.writeBox(this.mdat))}await this.writer?.flush();for(let e of this.output.tracks)e.isVideoTrack()&&e.metadata.decoderConfig?this.getVideoTrackData(e,e.metadata.primingPacket??null,{decoderConfig:e.metadata.decoderConfig}):e.isAudioTrack()&&e.metadata.decoderConfig&&this.getAudioTrackData(e,e.metadata.primingPacket??null,{decoderConfig:e.metadata.decoderConfig});e()}allTracksAreKnown(){for(let e of this.output.tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;let e=this.trackDatas.map(e=>e.type===`video`||e.type===`audio`?e.info.decoderConfig.codec:{webvtt:`wvtt`}[e.track.source._codec]);return $a({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(e=>e.type===`video`),hasAudio:this.trackDatas.some(e=>e.type===`audio`),codecStrings:e})}getVideoTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;us(n,e.source._codec),F(n),F(n.decoderConfig);let i={...n.decoderConfig};F(i.codedWidth!==void 0),F(i.codedHeight!==void 0);let a=!1;if(e.source._codec===`avc`&&!i.description){if(!t)throw Error(`No AVC description provided; you must therefore provide a priming packet.`);let e=hi(t.data);if(!e)throw Error(`Couldn't extract an AVCDecoderConfigurationRecord from the AVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.264) when not providing a description, or provide a description (must be an AVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in AVCC format.`);i.description=gi(e),a=!0}else if(e.source._codec===`hevc`&&!i.description){if(!t)throw Error(`No HEVC description provided; you must therefore provide a priming packet.`);let e=wi(t.data);if(!e)throw Error(`Couldn't extract an HEVCDecoderConfigurationRecord from the HEVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.265) when not providing a description, or provide a description (must be an HEVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in HEVC format.`);i.description=Mi(e),a=!0}let o=hr(1/(e.metadata.frameRate??57600),1e6).den,s=i.displayAspectWidth,c=i.displayAspectHeight,l=s===void 0||c===void 0?{num:1,den:1}:Fr({num:s*i.codedHeight,den:c*i.codedWidth}),u=i.codec===`ap4h`||i.codec===`ap4x`,d={muxer:this,track:e,type:`video`,info:{width:i.codedWidth,height:i.codedHeight,pixelAspectRatio:l,decoderConfig:i,requiresAnnexBTransformation:a,hasAlphaChannel:u},timescale:o,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1,avgBitrate:e.source._nominalBitrate??e.metadata.averageBitrate??0,maxBitrate:e.source._nominalBitrate??e.metadata.bitrate??0};return this.trackDatas.push(d),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),d}getAudioTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;fs(n,e.source._codec),F(n),F(n.decoderConfig);let i={...n.decoderConfig},a=!1;if(e.source._codec===`aac`&&!i.description){if(!t)throw Error(`No AAC description provided; you must therefore provide a priming packet.`);let e=ho(_o.tempFromBytes(t.data));if(!e)throw Error(`Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.`);let n=Jr[e.samplingFrequencyIndex],r=Yr[e.channelConfiguration];if(n===void 0||r===void 0)throw Error(`Invalid ADTS frame header.`);i.description=ei({objectType:e.objectType,outputSampleRate:n,outputNumberOfChannels:r}),a=!0}if(!t){if(e.source._codec===`ac3`||e.source._codec===`eac3`)throw Error(`AC-3/E-AC-3 require a priming packet.`);if(e.source._codec===`dts`)throw Error(`DTS requires a priming packet.`);if(e.source._codec===`truehd`)throw Error(`TrueHD requires a priming packet.`)}let o={muxer:this,track:e,type:`audio`,info:{numberOfChannels:n.decoderConfig.numberOfChannels,sampleRate:n.decoderConfig.sampleRate,decoderConfig:i,requiresPcmTransformation:!this.isFragmented&&Io.includes(e.source._codec),expectedNextPcmPacketTimestamp:null,requiresAdtsStripping:a,primingPacket:t,preroll:{packetCount:0,accumulatedAudioSamples:0,audioSampleDurationHistory:[]}},timescale:i.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1,avgBitrate:e.source._nominalBitrate??e.metadata.averageBitrate??0,maxBitrate:e.source._nominalBitrate??e.metadata.bitrate??0};return this.trackDatas.push(o),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),o}getSubtitleTrackData(e,t){let n=this.trackDatas.find(t=>t.track===e);if(n)return n;ps(t),F(t),F(t.config);let r={muxer:this,track:e,type:`subtitle`,info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1,avgBitrate:e.source._nominalBitrate??e.metadata.averageBitrate??0,maxBitrate:e.source._nominalBitrate??e.metadata.bitrate??0,lastCueEndTimestamp:null,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(r),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getVideoTrackData(e,t,n),i=t.data;if(r.info.requiresAnnexBTransformation){let e=[...li(i)].map(e=>i.subarray(e.offset,e.offset+e.length));if(e.length===0)throw Error(`Failed to transform packet data. Make sure all packets are provided in Annex B format, as specified in ITU-T-REC-H.264 and ITU-T-REC-H.265.`);i=mi(e,4)}this.validateTimestamp(r.track,t.timestamp,t.type===`key`);let a=this.createSampleForTrack(r,i,t.timestamp,t.duration,t.type,0);await this.registerSample(r,a)}finally{r()}}async addEncodedAudioPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getAudioTrackData(e,t,n),i=t.data;if(r.info.requiresAdtsStripping){let e=ho(_o.tempFromBytes(i));if(!e)throw Error(`Expected ADTS frame, didn't get one.`);let t=e.crcCheck===null?7:9;i=i.subarray(t)}this.validateTimestamp(r.track,t.timestamp,t.type===`key`);let a=t.timestamp,o=t.duration;if(r.info.requiresPcmTransformation){let e=ns(r.info.decoderConfig.codec).sampleSize*r.info.numberOfChannels;if(o=i.byteLength/e/r.info.sampleRate,r.info.expectedNextPcmPacketTimestamp!==null){let e=a-r.info.expectedNextPcmPacketTimestamp;if(e<.01)a=r.info.expectedNextPcmPacketTimestamp;else{let t=await this.padWithSilence(r,r.info.expectedNextPcmPacketTimestamp,e);a=r.info.expectedNextPcmPacketTimestamp+t}}r.info.expectedNextPcmPacketTimestamp=a+o}let{preroll:s}=r.info,c=0;if(e.source._codec===`aac`||e.source._codec===`vorbis`)c=-Math.min(1,s.packetCount);else if(e.source._codec===`mp3`)c=-Math.min(2,s.packetCount);else if(e.source._codec===`opus`){let e=Math.round(es*$o);c=-s.audioSampleDurationHistory.length;let t=Vi(i);for(s.accumulatedAudioSamples+=t.durationInSamples,s.audioSampleDurationHistory.push(t.durationInSamples);s.accumulatedAudioSamples-s.audioSampleDurationHistory[0]>=e;)s.accumulatedAudioSamples-=s.audioSampleDurationHistory.shift(),F(s.audioSampleDurationHistory.length>0)}s.packetCount++;let l=this.createSampleForTrack(r,i,a,o,t.type,c);await this.registerSample(r,l)}finally{r()}}async padWithSilence(e,t,n){let r=K(n,e.timescale);if(n=r/e.timescale,r>0){let{sampleSize:i,silentValue:a}=ns(e.info.decoderConfig.codec),o=r*e.info.numberOfChannels,s=new Uint8Array(i*o).fill(a),c=this.createSampleForTrack(e,new Uint8Array(s.buffer),t,n,`key`,0);await this.registerSample(e,c)}return n}async addSubtitleCue(e,t,n){let r=await this.mutex.acquire();try{let r=this.getSubtitleTrackData(e,n);this.validateTimestamp(r.track,t.timestamp,!0),e.source._codec===`webvtt`&&(r.cueQueue.push(t),await this.processWebVTTCues(r,t.timestamp))}finally{r()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){e.lastCueEndTimestamp??=Math.min(0,e.cueQueue[0].timestamp);let n=new Set([]);for(let r of e.cueQueue)F(r.timestamp<=t),F(e.lastCueEndTimestamp<=r.timestamp+r.duration),n.add(Math.max(r.timestamp,e.lastCueEndTimestamp)),n.add(r.timestamp+r.duration);let r=[...n].sort((e,t)=>e-t),i=r[0],a=r[1]??i;if(t<a)break;if(e.lastCueEndTimestamp<i){this.auxWriter.seek(0);let t=Rc();this.auxBoxWriter.writeBox(t);let n=this.auxTarget._getSlice(0,this.auxWriter.getPos()),r=this.createSampleForTrack(e,n,e.lastCueEndTimestamp,i-e.lastCueEndTimestamp,`key`,0);await this.registerSample(e,r),e.lastCueEndTimestamp=i}this.auxWriter.seek(0);for(let t=0;t<e.cueQueue.length;t++){let n=e.cueQueue[t];if(n.timestamp>=a)break;sa.lastIndex=0;let r=sa.test(n.text),o=n.timestamp+n.duration,s=e.cueToSourceId.get(n);if(s===void 0&&a<o&&(s=e.nextSourceId++,e.cueToSourceId.set(n,s)),n.notes){let e=Bc(n.notes);this.auxBoxWriter.writeBox(e)}let c=zc(n.text,r?i:null,n.identifier??null,n.settings??null,s??null);this.auxBoxWriter.writeBox(c),o===a&&e.cueQueue.splice(t--,1)}let o=this.auxTarget._getSlice(0,this.auxWriter.getPos()),s=this.createSampleForTrack(e,o,i,a-i,`key`,0);await this.registerSample(e,s),e.lastCueEndTimestamp=a}}createSampleForTrack(e,t,n,r,i,a){return{timestamp:n,decodeTimestamp:n,duration:r,data:t,size:t.byteLength,type:i,timescaleUnitsToNextSample:K(r,e.timescale),prerollSamples:a}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type===`audio`&&e.info.requiresPcmTransformation){F(!this.isFragmented),e.startTimestampOffset??=e.timestampProcessingQueue[0].timestamp;let t=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){let r=e.timestampProcessingQueue[n],i=K(r.duration,e.timescale);t+=i}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:t,sampleDelta:1});else{let n=Rn(e.timeToSampleTable);n.sampleCount+=t}e.timestampProcessingQueue.length=0;return}let n=e.timestampProcessingQueue.map(e=>e.timestamp).sort((e,t)=>e-t);this.isFragmented?e.startTimestampOffset??=Math.min(n[0],0):e.startTimestampOffset??=n[0];for(let t=0;t<e.timestampProcessingQueue.length;t++){let r=e.timestampProcessingQueue[t];r.decodeTimestamp=n[t];let i=K(r.timestamp-r.decodeTimestamp,e.timescale),a=K(r.duration,e.timescale);if(e.lastTimescaleUnits!==null){F(e.lastSample);let t=K(r.decodeTimestamp,e.timescale,!1),n=Math.round(t-e.lastTimescaleUnits);if(F(n>=0),e.lastTimescaleUnits+=n,e.lastSample.timescaleUnitsToNextSample=n,!this.isFragmented){let t=Rn(e.timeToSampleTable);if(F(t),t.sampleCount===1){t.sampleDelta=n;let r=e.timeToSampleTable[e.timeToSampleTable.length-2];r&&r.sampleDelta===n&&(r.sampleCount++,e.timeToSampleTable.pop(),t=r)}else t.sampleDelta!==n&&(t.sampleCount--,e.timeToSampleTable.push(t={sampleCount:1,sampleDelta:n}));t.sampleDelta===a?t.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:a});let r=Rn(e.compositionTimeOffsetTable);F(r),r.sampleCompositionTimeOffset===i?r.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i})}}else e.lastTimescaleUnits=K(r.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:a}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i}));e.lastSample=r}if(e.timestampProcessingQueue.length=0,F(e.lastSample),F(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){F(t.type===`key`);let n=K(t.timestamp,e.timescale,!1),r=Math.round(n-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=r}}async registerSample(e,t){t.type===`key`&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),e.sampleQueue.push(t),await this.interleaveSamples()}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart===`reserve`)){let t=e.track.metadata.maximumPacketCount;if(F(t!==void 0),e.samples.length>t)throw Error(`Track #${e.track.id} has already reached the maximum packet count (${t}). Either add less packets or increase the maximum packet count.`)}let n=!1;if(!e.currentChunk)n=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);let r=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){let i=this.trackDatas.every(n=>{if(e===n)return t.type===`key`;let r=n.sampleQueue[0];return r?r.type===`key`:n.closed});r>=this.minimumFragmentDuration&&i&&t.timestamp>this.maxWrittenTimestamp&&(n=!0,await this.finalizeFragment())}else n=r>=dl}if(n){if(!this.isFragmented){let e=this.trackDatas.filter(e=>e.currentChunk&&t.timestamp-e.currentChunk.startTimestamp>=dl).sort((e,t)=>e.currentChunk.startTimestamp-t.currentChunk.startTimestamp);for(let t of e)await this.finalizeCurrentChunk(t)}e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null,trafIndex:null}}F(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp),this.maxWrittenEndTimestamp=Math.max(this.maxWrittenEndTimestamp,t.timestamp+t.duration),this.minWrittenTimestamp=Math.min(this.minWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){F(!this.isFragmented),F(this.writer);let t=e.currentChunk;F(t),e.currentChunk=null,e.finalizedChunks.push(t),this.finalizedChunks.push(t);let n=t.samples.length;if(e.type===`audio`&&e.info.requiresPcmTransformation&&(n=t.samples.reduce((t,n)=>t+K(n.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||Rn(e.compactlyCodedChunkTable).samplesPerChunk!==n)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:n}),this.fastStart===`in-memory`)t.offset=0;else{t.offset=this.writer.getPos();for(let e of t.samples)F(e.data),this.writer.write(e.data),e.data=null;await this.writer.flush()}}async interleaveSamples(e=!1){if(e||this.allTracksAreKnown()){this.fastStart===`reserve`&&!this.mdat&&await this.createFastStartReserveMdat();outer:for(;;){let t=null,n=1/0;for(let r of this.trackDatas){if(!e&&r.sampleQueue.length===0&&!r.closed)break outer;r.sampleQueue.length>0&&r.sampleQueue[0].timestamp<n&&(t=r,n=r.sampleQueue[0].timestamp)}if(!t)break;let r=t.sampleQueue.shift();await this.addSampleToTrack(t,r)}}}async finalizeFragment(e=!this.isCmaf){if(F(this.isFragmented),!this.wroteFragmentedHeader){this.wroteFragmentedHeader=!0;let e=this.initBoxWriter??this.boxWriter;F(e),this.formatOptions.onMoov&&e.writer.startTrackingWrites(),this.ensureOneEnabledTrack();let t=Ns(this);if(e.writeBox(t),this.formatOptions.onMoov){let{data:t,start:n}=e.writer.stopTrackingWrites();this.formatOptions.onMoov(t,n)}if(this.isCmaf){F(this.initWriter),await this.initWriter.flush(),await this.initWriter.finalize(),this.writer=await this.output._getRootWriter(!0),this.boxWriter=new hs(this.writer);let e=this.boxWriter.measureBox(ks()),t=this.boxWriter.measureBox(As(this,0));this.segmentHeaderSize=e+t,this.writer.seek(this.segmentHeaderSize)}}F(this.writer),F(this.boxWriter);let t=this.trackDatas.filter(e=>e.currentChunk);if(t.length===0){e&&await this.writer.flush();return}let n=this.nextFragmentNumber++,r=Oc(n,t),i=this.writer.getPos(),a=i+this.boxWriter.measureBox(r),o=a+8,s=1/0;for(let e=0;e<t.length;e++){let n=t[e];F(n.currentChunk),F(n.startTimestampOffset!==null),n.currentChunk.offset=o,n.currentChunk.moofOffset=i,n.currentChunk.trafIndex=e,n.currentChunk.startTimestamp-=n.startTimestampOffset;for(let e of n.currentChunk.samples)o+=e.size,e.timestamp-=n.startTimestampOffset,e.decodeTimestamp-=n.startTimestampOffset;s=Math.min(s,n.currentChunk.startTimestamp)}let c=o-a,l=c>=2**32;if(l)for(let e of t)e.currentChunk.offset+=8;this.formatOptions.onMoof&&this.writer.startTrackingWrites();let u=Oc(n,t);if(this.boxWriter.writeBox(u),this.formatOptions.onMoof){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMoof(e,t,s)}F(this.writer.getPos()===a),this.formatOptions.onMdat&&this.writer.startTrackingWrites();let d=js(l);d.size=c,this.boxWriter.writeBox(d),this.writer.seek(a+(l?16:8));for(let e of t)for(let t of e.currentChunk.samples)this.writer.write(t.data),t.data=null;if(this.formatOptions.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMdat(e,t)}for(let e of t)e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk),e.currentChunk=null;e&&await this.writer.flush()}async createFastStartReserveMdat(){F(this.writer),F(this.boxWriter),this.ensureOneEnabledTrack();let e=Ns(this),t=this.boxWriter.measureBox(e)+this.computeSampleTableSizeUpperBound()+4096;F(this.ftypSize!==null),this.writer.seek(this.ftypSize+t),this.formatOptions.onMdat&&this.writer.startTrackingWrites(),this.mdat=js(!0),this.boxWriter.writeBox(this.mdat)}computeSampleTableSizeUpperBound(){F(this.fastStart===`reserve`);let e=0;for(let t of this.trackDatas){let n=t.track.metadata.maximumPacketCount;F(n!==void 0),e+=8*Math.ceil(2/3*n),e+=4*n,e+=8*Math.ceil(2/3*n),e+=12*Math.ceil(2/3*n),e+=4*n,e+=8*n,t.type===`audio`&&(e+=2*n,e+=8*n)}return e}async onTrackClose(e){let t=await this.mutex.acquire(),n=this.trackDatas.find(t=>t.track===e);n&&(n.closed=!0,n.type===`subtitle`&&e.source._codec===`webvtt`&&await this.processWebVTTCues(n,1/0),this.processTimestamps(n)),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),await this.interleaveSamples(),t()}ensureOneEnabledTrack(){for(let e of[`video`,`audio`,`subtitle`]){let t=this.trackDatas.filter(t=>t.type===e);if(t.length!==0&&!t.some(e=>e.track.metadata.disposition?.default!==!1)){let e=t[0];e.track.metadata.disposition={...e.track.metadata.disposition,default:!0}}}}async forceFragmentFinalization(){F(this.isFragmented);let e=await this.mutex.acquire();try{for(let e of this.trackDatas)e.type===`subtitle`&&e.track.source._codec===`webvtt`&&await this.processWebVTTCues(e,1/0),this.processTimestamps(e);await this.interleaveSamples(!0),await this.finalizeFragment()}finally{e()}}async finalize(){let e=await this.mutex.acquire();this.allTracksKnown.resolve(),this.ensureOneEnabledTrack();for(let e of this.trackDatas)e.closed=!0,e.type===`subtitle`&&e.track.source._codec===`webvtt`&&await this.processWebVTTCues(e,1/0),this.processTimestamps(e);if(await this.interleaveSamples(!0),this.isFragmented)await this.finalizeFragment(!1);else{let e=this.trackDatas.filter(e=>e.currentChunk).sort((e,t)=>e.currentChunk.startTimestamp-t.currentChunk.startTimestamp);for(let t of e)await this.finalizeCurrentChunk(t);for(let e of this.trackDatas){let t=pl(e);if(t>0){let n=0;for(let t of e.samples)n+=t.size;e.avgBitrate=Math.round(8*n/t)}else e.avgBitrate=0;let n=0,r=0,i=0;for(let t=0;t<e.samples.length;t++){let a=e.samples[t];for(r+=a.size;a.decodeTimestamp-e.samples[n].decodeTimestamp>=1;)r-=e.samples[n].size,n++;i=Math.max(i,r)}if(e.maxBitrate=8*i,e.startTimestampOffset!==null)for(let t=0;t<e.samples.length;t++){let n=e.samples[t];n.timestamp-=e.startTimestampOffset,n.decodeTimestamp-=e.startTimestampOffset}}}if(F(this.writer),F(this.boxWriter),this.fastStart===`in-memory`){this.mdat=js(!1);let e;for(let t=0;t<2;t++){let t=Ns(this),n=this.boxWriter.measureBox(t);e=this.boxWriter.measureBox(this.mdat);let r=this.writer.getPos()+n+e;for(let t of this.finalizedChunks){t.offset=r;for(let{data:n}of t.samples)F(n),r+=n.byteLength,e+=n.byteLength}if(r<2**32)break;e>=2**32&&(this.mdat.largeSize=!0)}this.formatOptions.onMoov&&this.writer.startTrackingWrites();let t=Ns(this);if(this.boxWriter.writeBox(t),this.formatOptions.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMoov(e,t)}this.formatOptions.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=e,this.boxWriter.writeBox(this.mdat);for(let e of this.finalizedChunks)for(let t of e.samples)F(t.data),this.writer.write(t.data),t.data=null;if(this.formatOptions.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMdat(e,t)}}else if(this.isFragmented){if(this.isCmaf){let e=this.segmentHeaderSize===null?0:this.writer.getPos()-this.segmentHeaderSize;this.writer.seek(0),this.boxWriter.writeBox(ks()),this.boxWriter.writeBox(As(this,e))}else{let e=this.writer.getPos(),t=Fc(this.trackDatas);this.boxWriter.writeBox(t);let n=this.writer.getPos()-e;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(n)}}else{F(this.mdat);let e=this.boxWriter.offsets.get(this.mdat);F(e!==void 0);let t=this.writer.getPos()-e;if(this.mdat.size=t,this.mdat.largeSize=t>=2**32,this.boxWriter.patchBox(this.mdat),this.formatOptions.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMdat(e,t)}let n=Ns(this);if(this.fastStart===`reserve`){F(this.ftypSize!==null);let e=this.boxWriter.offsets.get(this.mdat)-this.ftypSize,t=this.boxWriter.measureBox(n);if(t+8>e)throw Error(`The moov box (${t} bytes) plus a free box (8 bytes) exceed the space reserved for them (${e} bytes) with fastStart: 'reserve'. This is a bug; please report it.`);this.writer.seek(this.ftypSize),this.formatOptions.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n),this.boxWriter.writeBox(Ms(e-t))}else this.formatOptions.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n);if(this.formatOptions.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMoov(e,t)}}e()}},hl=-(2**15),gl=2**15-1,_l=6,vl=5,yl={video:1,audio:2,subtitle:17},bl=class extends ms{constructor(e,t){super(e),this.trackDatas=[],this.allTracksKnown=nr(),this.segment=null,this.segmentInfo=null,this.seekHead=null,this.tracksElement=null,this.tagsElement=null,this.attachmentsElement=null,this.segmentDuration=null,this.cues=null,this.currentClusterBlocks=[],this.currentClusterStartMsTimestamp=null,this.currentClusterMaxMsTimestamp=null,this.startTimestamp=1/0,this.endTimestamp=-1/0,this.warnedAboutTooNegativeTimestamp=!1,this.format=t}async start(){let e=await this.mutex.acquire();this.writer=await this.output._getRootWriter(!!this.format._options.appendOnly),this.ebmlWriter=new uo(this.writer),this.writeEBMLHeader(),this.createSegmentInfo(),this.createCues(),await this.writer.flush();for(let e of this.output.tracks)e.isVideoTrack()&&e.metadata.decoderConfig?this.getVideoTrackData(e,e.metadata.primingPacket??null,{decoderConfig:e.metadata.decoderConfig}):e.isAudioTrack()&&e.metadata.decoderConfig&&this.getAudioTrackData(e,e.metadata.primingPacket??null,{decoderConfig:e.metadata.decoderConfig});e()}writeEBMLHeader(){this.format._options.onEbmlHeader&&this.writer.startTrackingWrites();let e={id:R.EBML,data:[{id:R.EBMLVersion,data:1},{id:R.EBMLReadVersion,data:1},{id:R.EBMLMaxIDLength,data:4},{id:R.EBMLMaxSizeLength,data:8},{id:R.DocType,data:this.format instanceof Dl?`webm`:`matroska`},{id:R.DocTypeVersion,data:4},{id:R.DocTypeReadVersion,data:2}]};if(this.ebmlWriter.writeEBML(e),this.format._options.onEbmlHeader){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onEbmlHeader(e,t)}}maybeCreateSeekHead(e){if(this.format._options.appendOnly)return;let t=new Uint8Array([28,83,187,107]),n=new Uint8Array([21,73,169,102]),r=new Uint8Array([22,84,174,107]),i=new Uint8Array([25,65,164,105]),a=new Uint8Array([18,84,195,103]),o={id:R.SeekHead,data:[{id:R.Seek,data:[{id:R.SeekID,data:n},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.segmentInfo)-this.segmentDataOffset:0}]},{id:R.Seek,data:[{id:R.SeekID,data:r},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.tracksElement)-this.segmentDataOffset:0}]},this.attachmentsElement?{id:R.Seek,data:[{id:R.SeekID,data:i},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.attachmentsElement)-this.segmentDataOffset:0}]}:null,this.tagsElement?{id:R.Seek,data:[{id:R.SeekID,data:a},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.tagsElement)-this.segmentDataOffset:0}]}:null,{id:R.Seek,data:[{id:R.SeekID,data:t},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.cues)-this.segmentDataOffset:0}]}]};this.seekHead=o}createSegmentInfo(){let e={id:R.Duration,data:new to(0)};this.segmentDuration=e;let t=this.output._metadataTags.creationTime===void 0?new Date:this.output._metadataTags.creationTime,n=null;if(t){let e=1000000n*BigInt(t.getTime()-fo);if(BigInt.asIntN(64,e)!==e)throw Error(`creationTime is out of the range representable by Matroska files.`);n={id:R.DateUTC,size:8,data:BigInt.asUintN(64,e)}}let r={id:R.Info,data:[{id:R.TimestampScale,data:1e6},this.format._options.appendOnly?null:e,n,{id:R.MuxingApp,data:oi},{id:R.WritingApp,data:oi}]};this.segmentInfo=r}createTracks(){let e={id:R.Tracks,data:[]};this.tracksElement=e;for(let t of this.trackDatas){let n=po[t.track.source._codec];F(n),t.type===`audio`&&t.track.source._codec===`dts`&&(t.info.decoderConfig.codec===`dtse`?n=`A_DTS/EXPRESS`:t.info.decoderConfig.codec===`dtsl`&&(n=`A_DTS/LOSSLESS`));let r=0;if(t.type===`audio`){let e=Qo(t.track.source._codec,t.info.decoderConfig);r=Math.round(1e9*e)}e.data.push({id:R.TrackEntry,data:[{id:R.TrackNumber,data:t.track.id},{id:R.TrackUID,data:t.track.id},{id:R.TrackType,data:yl[t.type]},t.track.metadata.disposition?.default===!1?{id:R.FlagDefault,data:0}:null,t.track.metadata.disposition?.forced?{id:R.FlagForced,data:1}:null,t.track.metadata.disposition?.hearingImpaired?{id:R.FlagHearingImpaired,data:1}:null,t.track.metadata.disposition?.visuallyImpaired?{id:R.FlagVisualImpaired,data:1}:null,t.track.metadata.disposition?.original?{id:R.FlagOriginal,data:1}:null,t.track.metadata.disposition?.commentary?{id:R.FlagCommentary,data:1}:null,{id:R.FlagLacing,data:0},{id:R.Language,data:t.track.metadata.languageCode??`und`},{id:R.CodecID,data:n},t.codecPrivate?{id:R.CodecPrivate,data:Un(t.codecPrivate)}:null,t.type===`audio`&&t.info.codecDelay?{id:R.CodecDelay,data:Math.round(1e9*t.info.codecDelay)}:null,r>0?{id:R.SeekPreRoll,data:r}:null,t.track.metadata.name===void 0?null:{id:R.Name,data:new ro(t.track.metadata.name)},t.type===`video`?this.videoSpecificTrackInfo(t):null,t.type===`audio`?this.audioSpecificTrackInfo(t):null,t.type===`subtitle`?this.subtitleSpecificTrackInfo(t):null]})}}videoSpecificTrackInfo(e){let{frameRate:t,transformationMatrix:n}=e.track.metadata,r=[t?{id:R.DefaultDuration,data:1e9/t}:null],i,a,o;if(n){i=jn(n);let e=In(Nn(-i),n);a=Math.sign(e[0]),o=Math.sign(e[4]),o===-1&&(o=1,a=-a,i=On(i+180))}else i=e.track.metadata.rotation??0,a=e.track.metadata.flip?-1:1,o=1;let s=i?On(a===-1?i:-i):0,c=Math.round(Math.acos(a)*Dn),l=Math.round(Math.acos(o)*Dn),u=!!e.info.aspectRatio&&e.info.aspectRatio.num*e.info.height!==e.info.aspectRatio.den*e.info.width,d=e.info.decoderConfig.colorSpace,f={id:R.Video,data:[{id:R.PixelWidth,data:e.info.width},{id:R.PixelHeight,data:e.info.height},u?{id:R.DisplayWidth,data:e.info.aspectRatio.num}:null,u?{id:R.DisplayHeight,data:e.info.aspectRatio.den}:null,u?{id:R.DisplayUnit,data:3}:null,e.info.alphaMode?{id:R.AlphaMode,data:1}:null,Xn(d)?null:{id:R.Colour,data:[{id:R.MatrixCoefficients,data:d?.matrix==null?2:Yn[d.matrix]},{id:R.TransferCharacteristics,data:d?.transfer==null?2:Jn[d.transfer]},{id:R.Primaries,data:d?.primaries==null?2:qn[d.primaries]},{id:R.Range,data:d?.fullRange==null?0:d.fullRange?2:1}]},s||c||l?{id:R.Projection,data:[{id:R.ProjectionType,data:0},c?{id:R.ProjectionPoseYaw,data:new eo(c)}:null,l?{id:R.ProjectionPosePitch,data:new eo(l)}:null,s?{id:R.ProjectionPoseRoll,data:new eo((s+180)%360-180)}:null]}:null]};return r.push(f),r}audioSpecificTrackInfo(e){let t=Io.includes(e.track.source._codec)?ns(e.track.source._codec):null;return[{id:R.Audio,data:[{id:R.SamplingFrequency,data:new eo(e.info.sampleRate)},{id:R.Channels,data:e.info.numberOfChannels},t?{id:R.BitDepth,data:8*t.sampleSize}:null]}]}subtitleSpecificTrackInfo(e){return[]}maybeCreateTags(){let e=[],t=(t,n)=>{e.push({id:R.SimpleTag,data:[{id:R.TagName,data:new ro(t)},typeof n==`string`?{id:R.TagString,data:new ro(n)}:{id:R.TagBinary,data:n}]})},n=this.output._metadataTags,r=new Set;for(let{key:e,value:i}of kr(n))switch(e){case`title`:t(`TITLE`,i),r.add(`TITLE`);break;case`description`:t(`DESCRIPTION`,i),r.add(`DESCRIPTION`);break;case`artist`:t(`ARTIST`,i),r.add(`ARTIST`);break;case`album`:t(`ALBUM`,i),r.add(`ALBUM`);break;case`albumArtist`:t(`ALBUM_ARTIST`,i),r.add(`ALBUM_ARTIST`);break;case`genre`:t(`GENRE`,i),r.add(`GENRE`);break;case`beatsPerMinute`:t(`BPM`,i.toString()),r.add(`BPM`);break;case`comment`:t(`COMMENT`,i),r.add(`COMMENT`);break;case`lyrics`:t(`LYRICS`,i),r.add(`LYRICS`);break;case`date`:t(`DATE`,i.toISOString().slice(0,10)),r.add(`DATE`);break;case`trackNumber`:t(`PART_NUMBER`,n.tracksTotal===void 0?i.toString():`${i}/${n.tracksTotal}`),r.add(`PART_NUMBER`);break;case`discNumber`:t(`DISC`,n.discsTotal===void 0?i.toString():`${i}/${n.discsTotal}`),r.add(`DISC`);break;case`tracksTotal`:case`discsTotal`:break;case`images`:case`raw`:case`creationTime`:break;default:rr(e)}if(n.raw)for(let e in n.raw){let i=n.raw[e];i==null||r.has(e)||(typeof i==`string`||i instanceof Uint8Array)&&t(e,i)}e.length!==0&&(this.tagsElement={id:R.Tags,data:[{id:R.Tag,data:[{id:R.Targets,data:[{id:R.TargetTypeValue,data:50},{id:R.TargetType,data:`MOVIE`}]},...e]}]})}maybeCreateAttachments(){let e=this.output._metadataTags,t=[],n=new Set,r=e.images??[];for(let e of r){let r=e.name;r===void 0&&(r=(e.kind===`coverFront`?`cover`:e.kind===`coverBack`?`back`:`image`)+(Ar(e.mimeType)??``));let i;for(;;){i=0n;for(let e=0;e<8;e++)i<<=8n,i|=BigInt(Math.floor(Math.random()*256));if(i!==0n&&!n.has(i))break}n.add(i),t.push({id:R.AttachedFile,data:[e.description===void 0?null:{id:R.FileDescription,data:new ro(e.description)},{id:R.FileName,data:new ro(r)},{id:R.FileMediaType,data:e.mimeType},{id:R.FileData,data:e.data},{id:R.FileUID,data:i}]})}for(let[n,i]of Object.entries(e.raw??{}))i instanceof Wr&&/^\d+$/.test(n)&&(r.find(e=>e.mimeType===i.mimeType&&jr(e.data,i.data))||t.push({id:R.AttachedFile,data:[i.description===void 0?null:{id:R.FileDescription,data:new ro(i.description)},{id:R.FileName,data:new ro(i.name??``)},{id:R.FileMediaType,data:i.mimeType??``},{id:R.FileData,data:i.data},{id:R.FileUID,data:BigInt(n)}]}));t.length!==0&&(this.attachmentsElement={id:R.Attachments,data:t})}createSegment(){this.createTracks(),this.maybeCreateTags(),this.maybeCreateAttachments(),this.maybeCreateSeekHead(!1);let e={id:R.Segment,size:this.format._options.appendOnly?-1:_l,data:[this.seekHead,this.segmentInfo,this.tracksElement,this.attachmentsElement,this.tagsElement]};if(this.segment=e,this.format._options.onSegmentHeader&&this.writer.startTrackingWrites(),this.ebmlWriter.writeEBML(e),this.format._options.onSegmentHeader){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onSegmentHeader(e,t)}}createCues(){this.cues={id:R.Cues,data:[]}}get segmentDataOffset(){return F(this.segment),this.ebmlWriter.dataOffsets.get(this.segment)}allTracksAreKnown(){for(let e of this.output.tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;let e=this.trackDatas.map(e=>e.type===`video`||e.type===`audio`?e.info.decoderConfig.codec:{webvtt:`wvtt`}[e.track.source._codec]);return mo({isWebM:this.format instanceof Dl,hasVideo:this.trackDatas.some(e=>e.type===`video`),hasAudio:this.trackDatas.some(e=>e.type===`audio`),codecStrings:e})}getVideoTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;us(n,e.source._codec),F(n),F(n.decoderConfig),F(n.decoderConfig.codedWidth!==void 0),F(n.decoderConfig.codedHeight!==void 0);let i=n.decoderConfig.displayAspectWidth,a=n.decoderConfig.displayAspectHeight,o=i===void 0||a===void 0?null:Fr({num:i,den:a}),s={track:e,type:`video`,info:{width:n.decoderConfig.codedWidth,height:n.decoderConfig.codedHeight,aspectRatio:o,decoderConfig:n.decoderConfig,alphaMode:e.metadata.canBeTransparent||(t?!!t.sideData.alpha:null)},chunkQueue:[],lastWrittenMsTimestamp:null,codecPrivate:n.decoderConfig.description??null,closed:!1};return e.source._codec===`vp9`?s.codecPrivate=new Uint8Array(Yo(s.info.decoderConfig.codec)):e.source._codec===`av1`?s.codecPrivate=new Uint8Array(Xo(s.info.decoderConfig.codec)):e.source._codec===`prores`&&(s.codecPrivate=Kn.encode(n.decoderConfig.codec)),this.trackDatas.push(s),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),s}getAudioTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;fs(n,e.source._codec),F(n),F(n.decoderConfig);let i={...n.decoderConfig},a=!1;if(e.source._codec===`aac`&&!i.description){if(!t)throw Error(`No AAC description provided; you must therefore provide a priming packet.`);let e=ho(_o.tempFromBytes(t.data));if(!e)throw Error(`Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.`);let n=Jr[e.samplingFrequencyIndex],r=Yr[e.channelConfiguration];if(n===void 0||r===void 0)throw Error(`Invalid ADTS frame header.`);i.description=ei({objectType:e.objectType,outputSampleRate:n,outputNumberOfChannels:r}),a=!0}let o={track:e,type:`audio`,info:{numberOfChannels:n.decoderConfig.numberOfChannels,sampleRate:n.decoderConfig.sampleRate,decoderConfig:i,requiresAdtsStripping:a,codecDelay:null},chunkQueue:[],lastWrittenMsTimestamp:null,codecPrivate:i.description??null,closed:!1};return this.trackDatas.push(o),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),o}getSubtitleTrackData(e,t){let n=this.trackDatas.find(t=>t.track===e);if(n)return n;ps(t),F(t),F(t.config);let r={track:e,type:`subtitle`,info:{config:t.config},chunkQueue:[],lastWrittenMsTimestamp:null,codecPrivate:Kn.encode(t.config.description),closed:!1};return this.trackDatas.push(r),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getVideoTrackData(e,t,n);r.info.alphaMode??=!!t.sideData.alpha;let i=t.data;if(e.source._codec===`prores`){if(i.byteLength<8)throw Error(`ProRes packet too small, expected at least 8 bytes.`);i=i.subarray(8)}let a=t.type===`key`;this.validateTimestamp(r.track,t.timestamp,a);let o=t.timestamp,s=t.duration;e.metadata.frameRate!==void 0&&(o=lr(o,e.metadata.frameRate),s=lr(s,e.metadata.frameRate));let c=r.info.alphaMode?t.sideData.alpha??null:null,l=this.createInternalChunk(i,o,s,t.type,c);e.source._codec===`vp9`&&this.fixVP9ColorSpace(r,l),r.chunkQueue.push(l),await this.interleaveChunks()}finally{r()}}async addEncodedAudioPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getAudioTrackData(e,t,n),i=t.data;if(r.info.requiresAdtsStripping){let e=ho(_o.tempFromBytes(i));if(!e)throw Error(`Expected ADTS frame, didn't get one.`);let t=e.crcCheck===null?7:9;i=i.subarray(t)}let a=t.type===`key`;this.validateTimestamp(r.track,t.timestamp,a),r.info.codecDelay??=Math.max(-t.timestamp,0);let o=this.createInternalChunk(i,t.timestamp+r.info.codecDelay,t.duration,t.type);r.chunkQueue.push(o),await this.interleaveChunks()}finally{r()}}async addSubtitleCue(e,t,n){let r=await this.mutex.acquire();try{let r=this.getSubtitleTrackData(e,n);this.validateTimestamp(r.track,t.timestamp,!0);let i=t.text,a=Math.round(t.timestamp*1e3);sa.lastIndex=0,i=i.replace(sa,e=>`<${ua(la(e.slice(1,-1))-a)}>`);let o=Kn.encode(i),s=`${t.settings??``}\n${t.identifier??``}\n${t.notes??``}`,c=this.createInternalChunk(o,t.timestamp,t.duration,`key`,s.trim()?Kn.encode(s):null);r.chunkQueue.push(c),await this.interleaveChunks()}finally{r()}}async interleaveChunks(e=!1){if(e||this.allTracksAreKnown()){outer:for(;;){let t=null,n=1/0;for(let r of this.trackDatas){if(!e&&r.chunkQueue.length===0&&!r.closed)break outer;r.chunkQueue.length>0&&r.chunkQueue[0].timestamp<n&&(t=r,n=r.chunkQueue[0].timestamp)}if(!t)break;let r=t.chunkQueue.shift();this.addBlock(t,r)}e||await this.writer.flush()}}fixVP9ColorSpace(e,t){if(t.type!==`key`||!e.info.decoderConfig.colorSpace||!e.info.decoderConfig.colorSpace.matrix)return;let n=new qr(t.data);n.skipBits(2);let r=n.readBits(1),i=(n.readBits(1)<<1)+r;if(i===3&&n.skipBits(1),n.readBits(1)||n.readBits(1)!==0||(n.skipBits(2),n.readBits(24)!==4817730))return;i>=2&&n.skipBits(1);let a={rgb:7,bt709:2,bt470bg:1,smpte170m:3}[e.info.decoderConfig.colorSpace.matrix];Hn(t.data,n.pos,n.pos+3,a)}createInternalChunk(e,t,n,r,i=null){return{data:e,type:r,timestamp:t,duration:n,additions:i}}addBlock(e,t){this.segment||this.createSegment();let n=Math.round(1e3*t.timestamp),r=this.trackDatas.every(n=>{if(e===n)return t.type===`key`;let r=n.chunkQueue[0];return r?r.type===`key`:n.closed}),i=!1;if(this.currentClusterStartMsTimestamp===null)i=!0;else{F(this.currentClusterMaxMsTimestamp!==null);let e=n-this.currentClusterStartMsTimestamp;i=r&&n>this.currentClusterMaxMsTimestamp&&e>=1e3*(this.format._options.minimumClusterDuration??1)||e>gl}if(i&&this.startNewCluster(n),n-this.currentClusterStartMsTimestamp<hl){if(!this.warnedAboutTooNegativeTimestamp){let e=this.format instanceof Dl?`WebM`:`Matroska`;Hr._warn(`Packets had to be discarded because their timestamp is too negative to represent in ${e}.`),this.warnedAboutTooNegativeTimestamp=!0}}else this.currentClusterBlocks.push({trackData:e,chunk:t,msTimestamp:n,previousMsTimestamp:e.lastWrittenMsTimestamp}),this.startTimestamp=Math.min(this.startTimestamp,n),this.endTimestamp=Math.max(this.endTimestamp,n+Math.round(1e3*t.duration)),e.lastWrittenMsTimestamp=n,this.currentClusterMaxMsTimestamp=Math.max(this.currentClusterMaxMsTimestamp,n)}startNewCluster(e){this.currentClusterStartMsTimestamp!==null&&this.writeCurrentCluster();let t=Math.max(0,e);this.currentClusterStartMsTimestamp=t,this.currentClusterMaxMsTimestamp=t}writeCurrentCluster(){F(this.currentClusterStartMsTimestamp!==null);let e=this.currentClusterStartMsTimestamp,t=new Map,n=new Map;for(let e of this.currentClusterBlocks)e.chunk.type===`key`&&!t.has(e.trackData)&&t.set(e.trackData,e),n.set(e.trackData,e);let r=new Map;for(let t of this.currentClusterBlocks)r.set(t,this.createBlockElement(t,e,n.get(t.trackData)===t));let i={id:R.Cluster,size:this.format._options.appendOnly?-1:vl,data:[{id:R.Timestamp,data:e},...r.values()]};if(this.format._options.onCluster&&this.writer.startTrackingWrites(),this.ebmlWriter.writeEBML(i),this.currentClusterBlocks=[],this.format._options.onCluster){let{data:t,start:n}=this.writer.stopTrackingWrites();this.format._options.onCluster(t,n,e/1e3)}let a=this.ebmlWriter.offsets.get(i)-this.segmentDataOffset,o=this.ebmlWriter.dataOffsets.get(i),s=new Map;for(let e of t.values())s.has(e.msTimestamp)||s.set(e.msTimestamp,[]),s.get(e.msTimestamp).push(e);let c=[...s.entries()].sort((e,t)=>e[0]-t[0]);for(let[e,t]of c)F(this.cues),this.cues.data.push({id:R.CuePoint,data:[{id:R.CueTime,data:Math.max(0,e)},...t.map(e=>{let t=this.ebmlWriter.offsets.get(r.get(e));return{id:R.CueTrackPositions,data:[{id:R.CueTrack,data:e.trackData.track.id},{id:R.CueClusterPosition,data:a},{id:R.CueRelativePosition,data:t-o}]}})]})}createBlockElement(e,t,n){let{trackData:r,chunk:i,msTimestamp:a}=e,o=new Uint8Array(4),s=new DataView(o.buffer);s.setUint8(0,128|r.track.id),s.setInt16(1,a-t,!1);let c=Math.round(1e3*i.duration);return i.additions||r.type===`subtitle`||n&&c>0?{id:R.BlockGroup,data:[{id:R.Block,data:[o,i.data]},i.type===`delta`?{id:R.ReferenceBlock,data:new no(e.previousMsTimestamp-a)}:null,i.additions?{id:R.BlockAdditions,data:[{id:R.BlockMore,data:[{id:R.BlockAddID,data:1},{id:R.BlockAdditional,data:i.additions}]}]}:null,c>0?{id:R.BlockDuration,data:c}:null]}:(s.setUint8(3,Number(i.type===`key`)<<7),{id:R.SimpleBlock,data:[o,i.data]})}async onTrackClose(e){let t=await this.mutex.acquire(),n=this.trackDatas.find(t=>t.track===e);n&&(n.closed=!0),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),await this.interleaveChunks(),t()}async finalize(){let e=await this.mutex.acquire();this.allTracksKnown.resolve();for(let e of this.trackDatas)e.closed=!0;if(this.segment||this.createSegment(),await this.interleaveChunks(!0),this.currentClusterStartMsTimestamp!==null&&this.writeCurrentCluster(),F(this.cues),this.ebmlWriter.writeEBML(this.cues),!this.format._options.appendOnly){let e=this.writer.getPos()-this.segmentDataOffset;this.writer.seek(this.ebmlWriter.offsets.get(this.segment)+4),this.ebmlWriter.writeVarInt(e,_l);let t=this.startTimestamp===1/0?0:this.endTimestamp;this.segmentDuration.data=new to(t),this.writer.seek(this.ebmlWriter.offsets.get(this.segmentDuration)),this.ebmlWriter.writeEBML(this.segmentDuration),F(this.seekHead),this.writer.seek(this.ebmlWriter.offsets.get(this.seekHead)),this.maybeCreateSeekHead(!0),this.ebmlWriter.writeEBML(this.seekHead)}e()}},xl=class{get supportsVideoRotationMetadata(){return this.supportsVideoTransformationMetadata}get requiresMaximumPacketCount(){return!1}getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>Fo.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>Ro.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>zo.includes(e))}_codecUnsupportedHint(e){return``}_isFragmentedIsobmff(){return!1}},Sl=class extends xl{constructor(e={}){if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.fastStart!==void 0&&![!1,`in-memory`,`reserve`,`fragmented`].includes(e.fastStart))throw TypeError(`options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.`);if(e.minimumFragmentDuration!==void 0&&(!Nr(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw TypeError(`options.minimumFragmentDuration, when provided, must be a non-negative number.`);if(e.onFtyp!==void 0&&typeof e.onFtyp!=`function`)throw TypeError(`options.onFtyp, when provided, must be a function.`);if(e.onMoov!==void 0&&typeof e.onMoov!=`function`)throw TypeError(`options.onMoov, when provided, must be a function.`);if(e.onMdat!==void 0&&typeof e.onMdat!=`function`)throw TypeError(`options.onMdat, when provided, must be a function.`);if(e.onMoof!==void 0&&typeof e.onMoof!=`function`)throw TypeError(`options.onMoof, when provided, must be a function.`);if(e.metadataFormat!==void 0&&![`mdir`,`mdta`,`udta`,`auto`].includes(e.metadataFormat))throw TypeError(`options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.`);super(),this._options=e}getSupportedTrackCounts(){let e=2**32-1;return{video:{min:0,max:e},audio:{min:0,max:e},subtitle:{min:0,max:e},total:{min:0,max:e}}}get supportsVideoTransformationMetadata(){return!0}get supportsTimestampedMediaData(){return!0}get negativeTimestampSupport(){return`full`}get requiresMaximumPacketCount(){return this._options.fastStart===`reserve`}_createMuxer(e){return new ml(e,this)}_isFragmentedIsobmff(){return this._options.fastStart===`fragmented`}},Cl=class extends Sl{constructor(e){super(e)}get _name(){return`MP4`}get fileExtension(){return`.mp4`}get mimeType(){return`video/mp4`}getSupportedCodecs(){return[...Fo,...Lo,`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,...zo]}_codecUnsupportedHint(e){return new Tl().getSupportedCodecs().includes(e)?` Switching to MOV will grant support for this codec.`:``}},wl=class extends Sl{constructor(e){super(e)}get _name(){return`CMAF`}get fileExtension(){return`.m4s`}get mimeType(){return`video/mp4`}getSupportedCodecs(){return[...Fo,...Lo,`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,...zo]}},Tl=class extends Sl{constructor(e){super(e)}get _name(){return`MOV`}get fileExtension(){return`.mov`}get mimeType(){return`video/quicktime`}getSupportedCodecs(){return[...Fo,...Ro]}_codecUnsupportedHint(e){return new Cl().getSupportedCodecs().includes(e)?` Switching to MP4 will grant support for this codec.`:``}},El=class extends xl{constructor(e={}){if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.appendOnly!==void 0&&typeof e.appendOnly!=`boolean`)throw TypeError(`options.appendOnly, when provided, must be a boolean.`);if(e.minimumClusterDuration!==void 0&&(!Nr(e.minimumClusterDuration)||e.minimumClusterDuration<0))throw TypeError(`options.minimumClusterDuration, when provided, must be a non-negative number.`);if(e.onEbmlHeader!==void 0&&typeof e.onEbmlHeader!=`function`)throw TypeError(`options.onEbmlHeader, when provided, must be a function.`);if(e.onSegmentHeader!==void 0&&typeof e.onSegmentHeader!=`function`)throw TypeError(`options.onHeader, when provided, must be a function.`);if(e.onCluster!==void 0&&typeof e.onCluster!=`function`)throw TypeError(`options.onCluster, when provided, must be a function.`);super(),this._options=e}_createMuxer(e){return new bl(e,this)}get _name(){return`Matroska`}getSupportedTrackCounts(){return{video:{min:0,max:127},audio:{min:0,max:127},subtitle:{min:0,max:127},total:{min:0,max:127}}}get fileExtension(){return`.mkv`}get mimeType(){return`video/x-matroska`}getSupportedCodecs(){return[...Fo,...Lo,...Io.filter(e=>![`pcm-s8`,`pcm-f32be`,`pcm-f64be`,`ulaw`,`alaw`].includes(e)),...zo]}get supportsVideoTransformationMetadata(){return!1}get supportsTimestampedMediaData(){return!0}get negativeTimestampSupport(){return`prefer-non-negative`}},Dl=class extends El{constructor(e){super(e)}getSupportedCodecs(){return[...Fo.filter(e=>[`vp8`,`vp9`,`av1`].includes(e)),...Ro.filter(e=>[`opus`,`vorbis`].includes(e)),...zo]}get _name(){return`WebM`}get fileExtension(){return`.webm`}get mimeType(){return`video/webm`}_codecUnsupportedHint(e){return new El().getSupportedCodecs().includes(e)?` Switching to MKV will grant support for this codec.`:``}},Ol=[`video`,`audio`,`subtitle`],kl=class e{constructor(e,t,n,r,i){this.id=e,this.output=t,this.type=n,this.source=r,this.metadata=i}isVideoTrack(){return this.type===`video`}isAudioTrack(){return this.type===`audio`}isSubtitleTrack(){return this.type===`subtitle`}canBePairedWith(t){if(!(t instanceof e))throw TypeError(`other must be an OutputTrack.`);if(this===t)return!1;let n=Rr(this.metadata.group),r=Rr(t.metadata.group);for(let e of n)if(this.type!==t.type&&r.some(t=>e===t)||r.some(t=>e._pairedGroups.has(t)))return!0;return!1}},Al=class extends kl{constructor(e,t,n,r){super(e,t,`video`,n,r)}},jl=class extends kl{constructor(e,t,n,r){super(e,t,`audio`,n,r)}},Ml=class extends kl{constructor(e,t,n,r){super(e,t,`subtitle`,n,r)}},Nl=class e{constructor(){this._pairedGroups=new Set}pairWith(t){if(!(t instanceof e))throw TypeError(`other must be an OutputTrackGroup.`);if(this===t)throw TypeError(`Cannot pair a group with itself.`);this._pairedGroups.add(t),t._pairedGroups.add(this)}},Pl=e=>{if(!e||typeof e!=`object`)throw TypeError(`metadata must be an object.`);if(e.languageCode!==void 0&&!pr(e.languageCode))throw TypeError(`metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.`);if(e.name!==void 0&&typeof e.name!=`string`)throw TypeError(`metadata.name, when provided, must be a string.`);if(e.disposition!==void 0&&Kr(e.disposition),e.maximumPacketCount!==void 0&&(!Number.isInteger(e.maximumPacketCount)||e.maximumPacketCount<0))throw TypeError(`metadata.maximumPacketCount, when provided, must be a non-negative integer.`);if(e.bitrate!==void 0&&(!Number.isFinite(e.bitrate)||e.bitrate<0))throw TypeError(`metadata.bitrate, when provided, must be a non-negative number.`);if(e.averageBitrate!==void 0&&(!Number.isFinite(e.averageBitrate)||e.averageBitrate<0))throw TypeError(`metadata.averageBitrate, when provided, must be a non-negative number.`);if(e.group!==void 0&&!(e.group instanceof Nl)&&(!Array.isArray(e.group)||e.group.some(e=>!(e instanceof Nl))))throw TypeError(`metadata.group, when provided, must be an OutputTrackGroup instance or an array of OutputTrackGroup instances.`)},Fl=class extends zr{get target(){let e=`Output.target cannot be used when using PathedTarget with an async callback. Use the 'target' event instead.`;if(this._rootTargetPromise)throw TypeError(e);let t=this._getRootTarget();if(Or(t))throw TypeError(e);return t}constructor(e){if(super(),this.state=`pending`,this.defaultTrackGroup=new Nl,this.tracks=[],this._onFinalize=null,this._unfinalizedTargets=new Set,this._rootWriterPromise=null,this._startPromise=null,this._cancelPromise=null,this._finalizePromise=null,this._mutex=new Qn,this._metadataTags={},this._rootTarget=null,this._rootTargetPromise=null,this._firstMediaStreamTimestamp=null,!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(!(e.format instanceof xl))throw TypeError(`options.format must be an OutputFormat.`);if(!(e.target instanceof il||e.target instanceof ll))throw TypeError(`options.target must be a Target or a PathedTarget.`);if(e.target instanceof il&&this._rememberTarget(e.target),e.initTarget!==void 0&&!(e.initTarget instanceof il)&&typeof e.initTarget!=`function`)throw Error(`options.initTarget, when provided, must be a Target or a function that returns or resolves to a Target.`);if(e.onFinalize!==void 0&&typeof e.onFinalize!=`function`)throw TypeError(`options.onFinalize, when provided, must be a function.`);this.format=e.format,this._target=e.target,this._onFinalize=e.onFinalize??null,this._initTarget=e.initTarget??null,this._initTarget instanceof il&&this._rememberTarget(this._initTarget),this._muxer=e.format._createMuxer(this)}_getTargetValidated(e){F(this._target instanceof ll);let t=this._target.getTarget(e),n=e=>{if(!(e instanceof il))throw TypeError(`getTarget must return a Target.`);return e};return Or(t)?t.then(n):n(t)}async _getTarget(e){F(this._target instanceof ll);let t=await this._getTargetValidated(e);return this._emit(`target`,{target:t,request:e,isRoot:e.isRoot}),this.state===`canceled`?await t._close():this._rememberTarget(t),t}_rememberTarget(e){this._unfinalizedTargets.add(e),e.on(`finalized`,()=>this._unfinalizedTargets.delete(e),{once:!0})}async _getInitTarget(){if(F(this._initTarget!==null),this._initTarget instanceof il)return this._initTarget;let e=await this._initTarget();return this.state===`canceled`?await e._close():this._rememberTarget(e),e}_hasInitTarget(){return this._initTarget!==null}_getRootTarget(){if(this._rootTarget)return this._rootTarget;if(this._rootTargetPromise)return this._rootTargetPromise;if(this._target instanceof il)return this._emit(`target`,{target:this._target,request:null,isRoot:!0}),this._rootTarget=this._target,this._target;let e={path:this._target.rootPath,isRoot:!0,mimeType:this.format.mimeType},t=this._getTargetValidated(e),n=t=>(this.state===`canceled`?t._close():this._rememberTarget(t),this._emit(`target`,{target:t,request:e,isRoot:!0}),this._rootTarget=t,t);return Or(t)?this._rootTargetPromise=t.then(n):n(t)}_getRootWriter(e){return this._rootWriterPromise??=(async()=>{let t=await this._getRootTarget(),n=new rl(t,typeof e==`boolean`?e:e(t));return n.start(),n})()}addVideoTrack(e,t={}){if(!(e instanceof wo))throw TypeError(`source must be a VideoSource.`);if(Pl(t),t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);if(t.flip!==void 0&&typeof t.flip!=`boolean`)throw TypeError(`metadata.flip, when provided, must be a boolean.`);if(t.transformationMatrix!==void 0&&(!Array.isArray(t.transformationMatrix)||t.transformationMatrix.length!==9||!t.transformationMatrix.every(e=>Number.isFinite(e))))throw TypeError(`metadata.transformationMatrix, when provided, must be an array of 9 finite numbers.`);if(t.frameRate!==void 0&&(!Number.isFinite(t.frameRate)||t.frameRate<=0))throw TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);if(t.hasOnlyKeyPackets!==void 0&&typeof t.hasOnlyKeyPackets!=`boolean`)throw TypeError(`metadata.hasOnlyKeyPackets, when provided, must be a boolean.`);if(t.canBeTransparent!==void 0&&typeof t.canBeTransparent!=`boolean`)throw TypeError(`metadata.canBeTransparent, when provided, must be a boolean.`);if(t.decoderConfig!==void 0&&us({decoderConfig:t.decoderConfig},e._codec),t.primingPacket!==void 0){if(!(t.primingPacket instanceof Za))throw TypeError(`metadata.primingPacket, when provided, must be an EncodedPacket.`);if(t.decoderConfig===void 0)throw TypeError(`metadata.primingPacket can only be provided alongside metadata.decoderConfig.`)}let n={...t};return n.group??=this.defaultTrackGroup,this._addTrack(new Al(this.tracks.length+1,this,e,n))}addAudioTrack(e,t={}){if(!(e instanceof No))throw TypeError(`source must be an AudioSource.`);if(Pl(t),t.decoderConfig!==void 0&&fs({decoderConfig:t.decoderConfig},e._codec),t.primingPacket!==void 0){if(!(t.primingPacket instanceof Za))throw TypeError(`metadata.primingPacket, when provided, must be an EncodedPacket.`);if(t.decoderConfig===void 0)throw TypeError(`metadata.primingPacket can only be provided alongside metadata.decoderConfig.`)}let n={...t};return n.group??=this.defaultTrackGroup,this._addTrack(new jl(this.tracks.length+1,this,e,n))}addSubtitleTrack(e,t={}){if(!(e instanceof Po))throw TypeError(`source must be a SubtitleSource.`);Pl(t);let n={...t};return n.group??=this.defaultTrackGroup,this._addTrack(new Ml(this.tracks.length+1,this,e,n))}setMetadataTags(e){if(Gr(e),this.state!==`pending`)throw Error(`Cannot set metadata tags after output has been started or canceled.`);this._metadataTags=e}_addTrack(e){if(this.state!==`pending`)throw Error(`Cannot add track after output has been started or canceled.`);if(e.source._connectedTrack)throw Error(`Source is already used for a track.`);let t=this.format.getSupportedTrackCounts(),n=this.tracks.reduce((t,n)=>t+ +(n.type===e.type),0),r=t[e.type].max;if(n===r)throw Error(r===0?`${this.format._name} does not support ${e.type} tracks.`:`${this.format._name} does not support more than ${r} ${e.type} track${r===1?``:`s`}.`);let i=t.total.max;if(this.tracks.length===i)throw Error(`${this.format._name} does not support more than ${i} tracks${i===1?``:`s`} in total.`);if(e.isVideoTrack()){let t=this.format.getSupportedVideoCodecs();if(t.length===0)throw Error(`${this.format._name} does not support video tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${t.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(e.source._codec))}else if(e.isAudioTrack()){let t=this.format.getSupportedAudioCodecs();if(t.length===0)throw Error(`${this.format._name} does not support audio tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${t.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(e.source._codec))}else if(e.isSubtitleTrack()){let t=this.format.getSupportedSubtitleCodecs();if(t.length===0)throw Error(`${this.format._name} does not support subtitle tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${t.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(e.source._codec))}return this.tracks.push(e),e.source._connectedTrack=e,e}hasEnoughTracks(){let e=this.format.getSupportedTrackCounts();for(let t of Ol)if(this.tracks.reduce((e,n)=>e+ +(n.type===t),0)<e[t].min)return!1;let t=e.total.min;return!(this.tracks.length<t)}async start(){let e=this.format.getSupportedTrackCounts();for(let t of Ol){let n=this.tracks.reduce((e,n)=>e+ +(n.type===t),0),r=e[t].min;if(n<r)throw Error(r===e[t].max?`${this.format._name} requires exactly ${r} ${t} track${r===1?``:`s`}.`:`${this.format._name} requires at least ${r} ${t} track${r===1?``:`s`}.`)}let t=e.total.min;if(this.tracks.length<t)throw Error(t===e.total.max?`${this.format._name} requires exactly ${t} track${t===1?``:`s`}.`:`${this.format._name} requires at least ${t} track${t===1?``:`s`}.`);if(this.state===`canceled`)throw Error(`Output has been canceled.`);return this._startPromise?(Hr._warn(`Output has already been started.`),this._startPromise):this._startPromise=(async()=>{this.state=`started`;let e=this._mutex.acquire();try{await this._muxer.start();let e=this.tracks.map(e=>e.source._start());await Promise.all(e)}finally{(await e)()}})()}getMimeType(){return this._muxer.getMimeType()}async cancel(){if(this.state===`canceled`)return this._cancelPromise??void 0;if(this.state===`finalizing`||this.state===`finalized`)this.state===`finalized`&&Hr._warn(`Output has already been finalized.`);else return this._cancelPromise=(async()=>{this.state=`canceled`;let e=await this._mutex.acquire();try{let e=this.tracks.map(e=>e.source._flushOrWaitForOngoingClose(!0));await Promise.all(e),await Promise.all([...this._unfinalizedTargets].map(e=>e._close())),this._unfinalizedTargets.clear()}finally{e()}})()}async finalize(){if(this.state===`pending`)throw Error(`Cannot finalize before starting.`);if(this.state===`canceled`)throw Error(`Cannot finalize after canceling.`);return this._finalizePromise?(Hr._warn(`Output has already been finalized.`),this._finalizePromise):this._finalizePromise=(async()=>{this.state=`finalizing`;let e=await this._mutex.acquire();try{let e=this.tracks.map(e=>e.source._flushOrWaitForOngoingClose(!1));if(await Promise.all(e),await this._muxer.finalize(),this._rootWriterPromise){let e=await this._rootWriterPromise;e.finalized||(await e.flush(),await e.finalize())}this._onFinalize&&await this._onFinalize(),this.state=`finalized`}catch(e){throw this.state=`canceled`,e}finally{await Promise.all([...this._unfinalizedTargets].map(e=>e._close().catch(()=>{}))),this._unfinalizedTargets.clear(),e()}})()}},Il=Tn(),Ll=e=>e===!0?{}:e||null;function Rl(e){let t=Math.max(1,e/900);return{u:t,top:Math.round(44*t),bottom:Math.round(84*t)}}function zl(e){let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(`--lm-${e}`).trim()||n;return{font:t.fontFamily||`sans-serif`,mono:n(`mono`,`monospace`),bg:n(`bg`,`#eef2f5`),surface:n(`surface`,`#ffffff`),fg:n(`fg`,`#17212b`),accent:n(`accent`,`#0b6b8f`),muted:n(`muted`,`#5d6d7c`),line:n(`line`,`#c6d0da`),ok:n(`ok`,`#2a7f5a`),warn:n(`warn`,`#b86e00`),drop:n(`drop`,`#b7392e`),series:[1,2,3,4].map(e=>n(`s${e}`,`#5d6d7c`))}}var Bl=(e,t)=>t===`over`?e.drop:t===`warn`?e.warn:e.ok;function Vl(e,t){let{model:n,ev:r}=e.engine,i=n.scenarioOf(r.values);return{title:t.title??n.title??``,where:[t.step,i?.label,`${s(r.values.load)}× today`].filter(Boolean).join(` · `),verdict:t.text??r.verdict.text,tier:r.verdict.tier}}function Hl(e,t,n,r=1/0){let i=[],a=``;for(let r of t.split(/\s+/).filter(Boolean)){let t=a?`${a} ${r}`:r;!a||e(t)<=n?a=t:(i.push(a),a=r)}if(a&&i.push(a),i.length<=r)return i;let o=i.slice(0,r),s=o[r-1];for(;s&&e(`${s}…`)>n;)s=s.slice(0,-1);return o[r-1]=`${s.trimEnd()}…`,o}function Ul(e,t,n,r,i){let a=zl(t.board().svg),{u:o,top:s,bottom:c}=Rl(r),l=Vl(t,n),u=14*o;e.save(),e.setTransform(1,0,0,1,0,0),e.fillStyle=a.line,e.fillRect(0,s-o,r,o),e.fillRect(0,i-c,r,o),e.textBaseline=`middle`,e.font=`500 ${13*o}px ${a.font}`,e.fillStyle=a.muted,e.textAlign=`right`,e.fillText(l.where,r-u,s/2);let d=e.measureText(l.where).width;e.font=`600 ${16*o}px ${a.font}`,e.fillStyle=a.fg,e.textAlign=`left`,e.fillText(l.title,u,s/2,Math.max(0,r-3*u-d)),e.fillStyle=Bl(a,l.tier),e.fillRect(u,i-c+12*o,4*o,c-24*o),e.font=`400 ${14*o}px ${a.font}`,e.fillStyle=a.fg,e.textBaseline=`top`,Hl(t=>e.measureText(t).width,l.verdict,r-2*u-14*o,3).forEach((t,n)=>{e.fillText(t,u+14*o,i-c+(14+n*20)*o)}),e.restore()}function Wl(e,t,n,r,i){let a=t.board(),o=zl(a.svg),s=Math.max(.75,r/a.scene.width),c=r/s<=520,l=12*s;e.save(),e.textBaseline=`top`,e.textAlign=`left`;let u=`600 ${(c?11.5:13.5)*s}px ${o.font}`,d=`500 ${11.5*s}px ${o.mono}`;e.font=u;let f=c?r-16*s:Math.min(476*s,r-2*l)-28*s,p=Hl(t=>e.measureText(t).width,n.title,f,c?1:2);e.font=d;let m=c||!n.detail?[]:Hl(t=>e.measureText(t).width,n.detail,f,1),h=18*s,g=(c?6:15)*s+p.length*h+m.length*16*s;e.font=u;let _=Math.max(...p.map(t=>e.measureText(t).width),...m.map(t=>(e.font=d,e.measureText(t).width))),v=c?r:_+28*s,y=c?0:l,b=c?0:n.top?l:i-l-g;e.globalAlpha=.94,e.fillStyle=o.surface,e.fillRect(y,b,v,g),e.globalAlpha=1,c||(e.fillStyle=o.accent,e.fillRect(y,b,4*s,g));let x=y+(c?8:16)*s,S=b+(c?3:7)*s;e.font=u,e.fillStyle=o.fg;for(let t of p)e.fillText(t,x,S),S+=h;e.font=d,e.fillStyle=o.muted;for(let t of m)e.fillText(t,x,S);e.restore()}var Gl=[`fill`,`stroke`,`color`];function Kl(e,t,n){let r=e.cloneNode(!0),i=[e,...e.querySelectorAll(`*`)],a=[r,...r.querySelectorAll(`*`)];i.forEach((e,t)=>{let n=getComputedStyle(e),r=a[t];for(let e of Gl){let t=r.getAttribute(e);t&&(t.includes(`var(`)||t===`currentColor`)&&r.setAttribute(e,n.getPropertyValue(e))}r.style?.color&&(r.style.color=n.color);for(let e of[`tabindex`,`aria-describedby`,`class`])r.removeAttribute(e)});let o=getComputedStyle(e);return r.setAttribute(`font-family`,o.fontFamily),r.setAttribute(`color`,o.color),r.setAttribute(`width`,String(t)),r.setAttribute(`height`,String(n)),r.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),r}var ql=`http://www.w3.org/2000/svg`;function Jl(e,t,n){let r=document.createElementNS(ql,e);for(let[e,n]of Object.entries(t))r.setAttribute(e,String(n));return n!=null&&(r.textContent=n),r}async function Yl(e,t={}){await e.ready();let n=e.board(),{width:r,height:i}=n.scene,a=Kl(n.svg,r,i),o=Jl(`g`,{});for(let t of e.engine.dots())o.appendChild(Jl(`circle`,t.ring?{cx:t.x.toFixed(2),cy:t.y.toFixed(2),r:t.r-t.ring/2,fill:`none`,stroke:t.color,"stroke-width":t.ring,...t.alpha<1?{"stroke-opacity":t.alpha.toFixed(3)}:{}}:{cx:t.x.toFixed(2),cy:t.y.toFixed(2),r:t.r,fill:t.color,...t.alpha<1?{"fill-opacity":t.alpha.toFixed(3)}:{}}));a.appendChild(o);let s=Ll(t.caption);if(!s)return new XMLSerializer().serializeToString(a);let c=zl(n.svg),{top:l,bottom:u}=Rl(r),d=i+l+u,f=Vl(e,s),p=Jl(`svg`,{xmlns:ql,width:r,height:d,viewBox:`0 0 ${r} ${d}`,"font-family":c.font});p.appendChild(Jl(`rect`,{width:r,height:d,fill:c.surface})),p.appendChild(Jl(`text`,{x:14,y:l/2+5,"font-size":16,"font-weight":600,fill:c.fg},f.title)),p.appendChild(Jl(`text`,{x:r-14,y:l/2+5,"font-size":13,"text-anchor":`end`,fill:c.muted},f.where)),p.appendChild(Jl(`rect`,{x:0,y:l-1,width:r,height:1,fill:c.line})),a.setAttribute(`y`,String(l)),p.appendChild(a),p.appendChild(Jl(`rect`,{x:0,y:l+i,width:r,height:1,fill:c.line})),p.appendChild(Jl(`rect`,{x:14,y:l+i+12,width:4,height:u-24,fill:Bl(c,f.tier)}));let m=document.createElement(`canvas`).getContext(`2d`);return m.font=`400 14px ${c.font}`,Hl(e=>m.measureText(e).width,f.verdict,r-42,3).forEach((e,t)=>{p.appendChild(Jl(`text`,{x:28,y:l+i+28+t*20,"font-size":14,fill:c.fg},e))}),new XMLSerializer().serializeToString(p)}function Xl(e){let t=Math.max(720,Math.min(1400,e.width+48)),n=t-48;return{W:t,pad:24,inner:n,boardH:e.height*n/e.width}}async function Zl(e,t,n=2){let r=e.board(),{model:i,ev:a}=e.engine,o=zl(r.svg),{W:c,pad:d,inner:p,boardH:m}=Xl(r.scene),h=e=>{let t=i.dateAt(e);return t?` (${_(t,!0)})`:``},g=(e,t)=>e?`${u(e,i.searchMax,!0)}${h(e.low)}`:`${l(t,i.searchMax)}${h(t)}`,v=Vl(e,{}),y=i.growth,x=[v.where,y&&`load grows ${s(y.rate*100)} % a ${y.per} from ${_(b(y.asOf))}`].filter(Boolean).join(` · `),S=i.scenarios.length>1?xe(i,a.values.load):null,C=a.assumptions.flatMap(e=>e.kind===`capacity`&&e.capacity.provenance===`estimated`?[e.name]:[]),w=document.createElement(`canvas`).getContext(`2d`),T=(e,t,n=!1)=>`${e} ${t}px ${n?o.mono:o.font}`,E=(e,t,n)=>(w.font=t,Hl(e=>w.measureText(e).width,e,n)),D=E(v.verdict,T(400,15),p-20),O=a.measure?E(a.measure.text,T(400,13),p-20):[],ee=S?E(S.text,T(400,14),p):[],k=[],A=(e,t,n,r,i,a,o=`left`)=>{e.font=i,e.fillStyle=a,e.textAlign=o,e.fillText(t,n,r)},te=e=>k.push([30,(t,n)=>A(t,e.toUpperCase(),d,n+20,T(600,11),o.muted)]);k.push([34,(e,t)=>A(e,v.title,d,t+26,T(600,22),o.fg)]),k.push([26,(e,t)=>A(e,x,d,t+16,T(400,13),o.muted)]),k.push([m+16,(e,n)=>{e.fillStyle=o.line,e.fillRect(d-1,n+7,p+2,m+2),e.drawImage(t,d,n+8,p,m)}]),k.push([D.length*22+20,(e,t)=>{e.fillStyle=Bl(o,v.tier),e.fillRect(d,t+6,4,D.length*22+8),D.forEach((n,r)=>{A(e,n,d+16,t+24+r*22,T(400,15),o.fg)})}]),O.length&&k.push([O.length*18+6,(e,t)=>{O.forEach((n,r)=>{A(e,n,d+16,t+14+r*18,T(400,13),o.muted)})}]),te(`Where it runs out, in order`);let ne=Math.max(1.5,i.thresholds.full*1.5);k.push([16,(e,t)=>{let n=i.thresholds;A(e,`0`,d,t+10,T(400,11,!0),o.muted),A(e,`${f(n.target)} target`,d+p*n.target/ne,t+10,T(400,11,!0),o.muted,`center`),A(e,f(n.full),d+p*n.full/ne,t+10,T(400,11,!0),o.muted,`center`),A(e,f(ne),c-d,t+10,T(400,11,!0),o.muted,`right`)}]);for(let e of a.ranked)k.push([46,(t,n)=>{let r=e===a.firstLimit?` · first limit`:``;A(t,`${e.name}${r}`,d,n+16,T(600,14),o.fg);let s=e.util==null?`switched off`:`${f(e.util)} now · ${f(i.thresholds.target)} at ${g(e.targetRange,e.target)} · ${f(i.thresholds.full)} at ${g(e.fullRange,e.full)}`;A(t,s,c-d,n+16,T(400,12,!0),o.muted,`right`),t.fillStyle=o.bg,t.fillRect(d,n+24,p,10),t.fillStyle=e.state===`over`?o.drop:e.state===`warn`?o.warn:o.ok,t.fillRect(d,n+24,p*Math.min(ne,e.util??0)/ne,10),t.fillStyle=o.fg;for(let e of[i.thresholds.target,i.thresholds.full])t.fillRect(d+p*e/ne,n+22,1,14)}]);S&&(te(`Scenarios compared`),k.push([ee.length*20+6,(e,t)=>{ee.forEach((n,r)=>{A(e,n,d,t+15+r*20,T(400,14),o.fg)})}]),S.rows.forEach((e,t)=>{k.push([26,(n,r)=>{n.fillStyle=o.series[t]??o.muted,n.beginPath(),n.arc(d+5,r+13,5,0,Math.PI*2),n.fill(),A(n,e.label,d+18,r+18,T(600,14),o.fg);let a=`first limit ${e.firstLimit?.name??`—`} · ${f(i.thresholds.target)} at ${g(e.targetRange,e.target)} · runs out at ${g(e.fullRange,e.full)}`;A(n,a,c-d,r+18,T(400,12,!0),o.muted,`right`)}])})),C.length&&k.push([30,(e,t)=>A(e,`Estimated capacities: ${C.join(`, `)}.`,d,t+22,T(400,12),o.muted)]);let re=Math.ceil(k.reduce((e,[t])=>e+t,0)+2*d),ie=document.createElement(`canvas`);ie.width=Math.round(c*n),ie.height=Math.round(re*n);let ae=ie.getContext(`2d`);ae.scale(n,n),ae.fillStyle=o.surface,ae.fillRect(0,0,c,re),ae.textBaseline=`alphabetic`;let j=d;for(let[e,t]of k)t(ae,j),j+=e;return ie}function Ql(e,t){if(t.step==null)return e.setValues($l(e,t));if(!e.engine.model.story[t.step])throw Error(`loadmap: the story has no step ${t.step+1}`);e.setStoryStep(t.step)}function $l(e,t){if(t.scenario==null)return{...t.set};let n=e.engine.model,r=n.scenarios.find(e=>e.label===t.scenario);if(!r){let e=n.scenarios.map(e=>`"${e.label}"`).join(`, `);throw Error(`loadmap: no scenario "${t.scenario}"; ${e?`the model has ${e}`:`the model has none`}`)}return{...r.values,...t.set}}async function q(e,t={},n){await e.ready();let r=e.board(),i=Ll(t.caption),a=t.size?.width??du(r.scene.width*(t.scale??2)),o=i?Rl(a):{top:0,bottom:0},s=t.size?.height??du(r.scene.height*(t.scale??2)+o.top+o.bottom),c=s-o.top-o.bottom,l=Math.min(a/r.scene.width,c/r.scene.height),u=r.scene.width*l,d=r.scene.height*l,f=n??document.createElement(`canvas`);(f.width!==a||f.height!==s)&&(f.width=a,f.height=s);let p=f.getContext(`2d`);p.setTransform(1,0,0,1,0,0),p.fillStyle=getComputedStyle(r.svg).getPropertyValue(`--lm-surface`).trim()||`#fff`,p.fillRect(0,0,a,s);let m=await pu(r.svg,Math.round(u),Math.round(d));return p.translate((a-u)/2,o.top+(c-d)/2),p.drawImage(m,0,0,u,d),e.engine.paintParticles(p,l),e.engine.cue&&Wl(p,e,e.engine.cue,u,d),p.setTransform(1,0,0,1,0,0),i&&Ul(p,e,i,a,s),f}async function eu(e,t={}){return au(await q(e,t))}async function tu(e,t){let n=t.format??`webm`,r=t.fps??(n===`gif`?15:30),i=t.story?e.engine.model.story:null;if(i&&!i.length)throw Error(`loadmap: the model has no story`);if(!(r>0)||!(i||t.seconds!=null&&t.seconds>0))throw Error(`loadmap: seconds and fps must be positive`);if(n===`gif`&&r>50)throw Error(`loadmap: a GIF plays at most 50 frames a second`);let a=i?[]:[...t.script??[]].sort((e,t)=>e.at-t.at),o=Ll(t.caption),s=()=>{let n=e.engine.cue?.step??e.storyStep(),r=i&&n!=null?i[n]:void 0;return o&&r?{...o,text:r.text,step:`${n+1} of ${i.length}`}:t.caption};await e.ready();let c=e.values(),l=e.storyStep();e.pause(),e.engine.stopStory({cut:!0});try{i&&(e.setStoryStep(null),e.setValues(e.engine.model.defaults()));for(let t of a.filter(e=>e.at<=0))Ql(e,t);await su(e,t.seed??1,t.warmup??2,r);let o=i?e.playStory():t.seconds,c=document.createElement(`canvas`);n===`gif`&&c.getContext(`2d`,{willReadFrequently:!0}),await q(e,{scale:t.scale??1,caption:s()},c);let l=n===`gif`?lu(c,r):await cu(c,n,r),u=Math.round(o*r),d=a.findIndex(e=>e.at>0);for(let n=0;n<u;n++){let i=n/r;for(;d>=0&&d<a.length&&a[d].at<=i;)Ql(e,a[d]),d++;await e.ready(),e.step(1/r),await q(e,{size:{width:c.width,height:c.height},caption:s()},c),await t.onFrame?.(n,c),await l.add(i)}return await l.finish()}finally{(i||e.storyStep()!==l)&&e.setStoryStep(l),e.setValues(c),e.resume()}}async function nu(e,t={}){return iu(e,t,()=>eu(e,t))}async function ru(e,t={}){return iu(e,t,async()=>{let n=t.scale??2,{inner:r,boardH:i}=Xl(e.board().scene);return au(await Zl(e,await q(e,{size:{width:du(r*n),height:du(i*n)}}),n))})}async function iu(e,t,n){await e.ready();let r=e.values();e.pause(),e.engine.stopStory({cut:!0});try{return(t.set||t.scenario!=null)&&e.setValues($l(e,t)),await su(e,t.seed??1,t.warmup??4,30),await n()}finally{e.setValues(r),e.resume()}}function au(e){return new Promise((t,n)=>e.toBlob(e=>e?t(e):n(Error(`loadmap: PNG failed`)),`image/png`))}function ou(e,t=`default`){let n={record:async t=>uu(await tu(e,t)),still:async t=>uu(await nu(e,t)),poster:async t=>uu(await ru(e,t)),svg:t=>iu(e,t,()=>Yl(e,t))};return globalThis.__loadmap??={},globalThis.__loadmap[t]=n,()=>{globalThis.__loadmap?.[t]===n&&delete globalThis.__loadmap[t]}}async function su(e,t,n,r){await e.ready(),e.reset(t);for(let t=0,i=Math.round(n*r);t<i;t++)e.step(1/r)}async function cu(e,t,n){let r=await fu(t,e.width,e.height),i=new Fl({format:t===`mp4`?new Cl({fastStart:`in-memory`}):new Dl,target:new sl}),a=new Mo(e,{codec:r,bitrate:Ka,keyFrameInterval:2});return i.addVideoTrack(a,{frameRate:n}),await i.start(),{add:e=>a.add(e,1/n),finish:async()=>{a.close(),await i.finalize();let e=i.target.buffer;return new Blob([e],{type:t===`mp4`?`video/mp4`:`video/webm`})}}}function lu(e,t){let n=(0,Il.GIFEncoder)(),r=e.getContext(`2d`),i=e=>Math.round(100*e/t),a=0;return{add:async()=>{let{data:t,width:o,height:s}=r.getImageData(0,0,e.width,e.height),c=(0,Il.quantize)(t,256),l=10*(i(a+1)-i(a));a++,n.writeFrame((0,Il.applyPalette)(t,c),o,s,{palette:c,delay:l,repeat:0})},finish:async()=>(n.finish(),new Blob([n.bytes()],{type:`image/gif`}))}}async function uu(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}var du=e=>Math.max(2,Math.round(e/2)*2);async function fu(e,t,n){let r=e===`mp4`?[`avc`,`vp9`,`av1`]:[`vp9`,`vp8`,`av1`];for(let e of r)if(await qa(e,{width:t,height:n}))return e;throw Error(`loadmap: this browser cannot encode ${e} video`)}async function pu(e,t,n){let r=Kl(e,t,n),i=URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(r)],{type:`image/svg+xml`}));try{let e=new Image;return e.src=i,await e.decode(),e}finally{URL.revokeObjectURL(i)}}var mu=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function ee(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function te(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function re(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,re(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+te(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),re(o,r,i,``,function(e){return e})):o!=null&&(ee(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+te(a,u),c+=re(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+te(a,u++),c+=re(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return re(ne(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ie(e,t,n){if(e==null)return e;var r=[],i=0;return re(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ae(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var j=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function oe(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,j)}catch(e){j(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function se(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else oe(se.bind(null,e))}var ce={map:ie,forEach:function(e,t,n){ie(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ie(e,function(){t++}),t},toArray:function(e){return ie(e,function(e){return e})||[]},only:function(e){if(!ee(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ce,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=se,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ee,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ae}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=oe,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),hu=t(((e,t)=>{t.exports=mu()})),gu={establish:1.2,in:1,close:.5,out:1,back:.4},_u=e=>Math.max(1.6,e+.7),vu=(e,t)=>gu.in+gu.close+_u(t)+gu.out+e.seconds,yu=(e,t)=>e.reduce((e,n)=>e+vu(n,t),gu.establish),bu=e=>({x:0,y:0,w:e.width,h:e.height});function xu(e,t){return t.stages.map(t=>e.stages[t]?.component).find(Boolean)??t.component??void 0}function Su(e,t,n,r,i){let a=new Set(e.nodes.map(e=>e.id)),o=new Set;for(let e of a)r.a.nodes[e]!==r.b.nodes[e]&&o.add(e);let s=new Set(r.a.edges.map(e=>e.id)),c=new Set(r.b.edges.map(e=>e.id));for(let e of[...r.a.edges,...r.b.edges])if(s.has(e.id)!==c.has(e.id))for(let t of[e.from,e.to])a.has(t)&&o.add(t);let l=t=>e.nodes.filter(e=>t&&xu(n,e)===t).map(e=>e.id),u=t=>e.nodes.filter(e=>t.has(e.id)).map(e=>e.id);if(i)return u(new Set([...l(i),...o]));if(o.size)return u(o);let d=e.nodes.filter(e=>{let r=xu(n,e);return r&&t.components[r]?.state!==n.components[r]?.state});return d.length?d.map(e=>e.id):l(n.firstLimit?.id)}var Cu=2.5,wu=.8;function Tu(e,t,n={}){let r=bu(e),i=e.nodes.filter(e=>t.includes(e.id));if(!i.length||!(e.width>0&&e.height>0))return r;let a=Math.min(...i.map(e=>e.x)),o=Math.min(...i.map(e=>e.y)),s=Math.max(...i.map(e=>e.x+e.w)),c=Math.max(...i.map(e=>e.y+e.h)),l=e.width/e.height,u=Math.max(s-a+60,(c-o+60)*l,e.width/Cu);if(u>wu*e.width&&!n.hold)return r;u=Math.min(u,e.width);let d=u/l,f=(e,t)=>Math.max(0,Math.min(t,e));return{x:f((a+s-u)/2,e.width-u),y:f((o+c-d)/2,e.height-d),w:u,h:d}}var Eu=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2;function Du(e,t,n){let r=Eu(Math.max(0,Math.min(1,n))),i=e.w*(t.w/e.w)**r,a=e.h*(t.h/e.h)**r,o=e.x+e.w/2+(t.x+t.w/2-e.x-e.w/2)*r,s=e.y+e.h/2+(t.y+t.h/2-e.y-e.h/2)*r;return{x:o-i/2,y:s-a/2,w:i,h:a}}var Ou=e=>e.split(`,`)[0].trim(),ku=2;function Au(e,t,n,r){if(n.title)return`${r+1} · ${n.title}`;let i=(t,n)=>{if(t===`load`)return`${s(n)}×`;let r=e.params.find(e=>e.id===t)?.def;return typeof n==`boolean`?n?`on`:`off`:r&&r.kind!==`load`&&`format`in r&&r.format?r.format(n):typeof n==`number`?s(n):String(n)},a=Object.keys(n.values).filter(e=>t[e]!==n.values[e]),o=a.slice(0,ku).map(r=>{let a=r===`load`?e.load.label:e.params.find(e=>e.id===r)?.def.label??r,o=n.values[r],s=t[r];return typeof o==`boolean`?`${Ou(a)} ${i(r,o)}`:`${Ou(a)} ${i(r,s)} → ${i(r,o)}`});a.length>ku&&o.push(`${a.length-ku} more`);let c=o.join(`, `)||`Nothing changes`;return`${r+1} · ${n.scenario&&a.length?`${n.scenario}: ${c}`:c}`}function ju(e,t,n){return n.slice(0,2).map(n=>{let r=e.components[n],i=t?.components[n];if(!r)return``;let a=e=>e==null?`off`:f(e);return i?`${r.name} ${a(r.util)} → ${a(i.util)}`:`${r.name} ${a(r.util)}`}).filter(Boolean).join(` · `)}var Mu=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Nu=t(((e,t)=>{t.exports=Mu()})),J=hu(),Y=Nu(),Pu=[`var(--lm-s1)`,`var(--lm-s2)`,`var(--lm-s3)`,`var(--lm-s4)`];function Fu(e,t){return t==null?`var(--lm-fg)`:Pu[e.scenarios.findIndex(e=>e.label===t)]??`var(--lm-muted)`}var Iu=e=>e.label??`These values`;function Lu(e,t){let n=e.dateAt(t);return n?_(n,!0):t!=null&&t<=1&&e.growth?`now`:``}function Ru(e,t){if(!t)return``;let[n,r]=[Lu(e,t.low),Lu(e,t.high)];return!r||n===r?n:`${n}–${r}`}function zu(e){return(0,J.useMemo)(()=>xe(e.model,e.values.load),[e.model,e.values.load])}function Bu({lm:e}){let{model:t}=e;return t.scenarios.length?(0,Y.jsxs)(`fieldset`,{className:`lm-scenarios`,children:[(0,Y.jsx)(`legend`,{children:`Scenario`}),t.scenarios.map(n=>(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":e.scenario?.label===n.label,onClick:()=>e.setScenario(n.label),children:[(0,Y.jsx)(`i`,{style:{background:Fu(t,n.label)}}),n.label]},n.label)),!e.scenario&&(0,Y.jsx)(`span`,{className:`lm-own`,children:`your own values`})]}):null}function Vu(e){return e==null||!Number.isFinite(e)||e===0?``:Math.abs(e-1)<.005?`same`:`${e>1?`+`:`−`}${f(Math.abs(e-1))}`}function Hu({lm:e,title:t=`Scenarios compared`}){let{model:n}=e,r=zu(e);if(r.rows.length<2)return null;let i=`${f(n.thresholds.target)} target`,a=e=>(0,Y.jsxs)(Y.Fragment,{children:[e?u(e,n.searchMax,!0):l(null),Ru(n,e)&&(0,Y.jsx)(`small`,{children:Ru(n,e)})]});return(0,Y.jsxs)(`div`,{className:`lm-card lm-compare`,children:[(0,Y.jsx)(`h3`,{children:t}),(0,Y.jsx)(`p`,{className:`lm-compare-text`,children:r.text}),(0,Y.jsx)(`div`,{className:`lm-table-wrap`,children:(0,Y.jsxs)(`table`,{className:`lm-table`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`col`,children:`Scenario`}),(0,Y.jsx)(`th`,{scope:`col`,children:`First limit`}),(0,Y.jsx)(`th`,{scope:`col`,children:i}),(0,Y.jsx)(`th`,{scope:`col`,children:`Runs out`})]})}),(0,Y.jsx)(`tbody`,{children:r.rows.map(t=>(0,Y.jsxs)(`tr`,{"data-scenario":t.label,"aria-current":e.scenario?.label===t.label||void 0,children:[(0,Y.jsxs)(`th`,{scope:`row`,children:[(0,Y.jsx)(`i`,{style:{background:Fu(n,t.label)}}),t.label]}),(0,Y.jsx)(`td`,{className:`lm-text`,children:t.firstLimit?.name??`—`}),(0,Y.jsx)(`td`,{"data-multiple":t.target??``,"data-high":t.targetRange?.high??``,children:a(t.targetRange)}),(0,Y.jsx)(`td`,{"data-multiple":t.full??``,"data-high":t.fullRange?.high??``,children:a(t.fullRange)})]},t.label))})]})}),(0,Y.jsxs)(`h3`,{children:[i,`, by component`]}),(0,Y.jsx)(`div`,{className:`lm-table-wrap`,children:(0,Y.jsxs)(`table`,{className:`lm-table`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`col`,children:`Component`}),r.rows.map(e=>(0,Y.jsx)(`th`,{scope:`col`,children:e.label},e.label))]})}),(0,Y.jsx)(`tbody`,{children:n.componentIds.map((e,t)=>(0,Y.jsxs)(`tr`,{"data-component":e,children:[(0,Y.jsx)(`th`,{scope:`row`,children:r.rows[0].components[t].name}),r.rows.map((e,r)=>{let i=e.components[t];return(0,Y.jsxs)(`td`,{"data-multiple":i.target??``,children:[i.targetRange==null?`off`:u(i.targetRange,n.searchMax,!0),r>0&&Vu(i.change)&&(0,Y.jsx)(`small`,{children:Vu(i.change)})]},e.label)})]},e))})]})})]})}function Uu(e){let t=(0,J.useRef)(null),[n,r]=(0,J.useState)({width:e,height:0});return(0,J.useEffect)(()=>{let e=t.current;if(!e)return;let n=new ResizeObserver(([t])=>{let n=Math.round(t?.contentRect.width??e.clientWidth),i=Math.round(t?.contentRect.height??e.clientHeight);n>0&&r(e=>e.width===n&&e.height===i?e:{width:n,height:i})});return n.observe(e),()=>n.disconnect()},[]),[t,n]}function Wu(e){let{model:t,values:n}=e,r=JSON.stringify({...n,load:null});return(0,J.useMemo)(()=>Ce(t,{...n,load:t.load.default}),[t,r])}function Gu(e){let[t,n]=(0,J.useState)(()=>(e,t)=>e.length*6.7);return(0,J.useLayoutEffect)(()=>{let t=e.current&&document.createElement(`canvas`).getContext(`2d`);if(!t)return;let r=getComputedStyle(e.current).getPropertyValue(`--lm-mono`).trim()||`monospace`;n(()=>(e,n=400)=>(t.font=`${n} 11px ${r}`,t.measureText(e).width))},[e]),t}function Ku(e,t,n){let r=[];for(let i=Math.floor(Math.log10(e));i<=Math.ceil(Math.log10(t));i++)for(let a of n?[1,2,5]:[1]){let n=a*10**i;n>=e*.999&&n<=t*1.001&&r.push(Number(n.toPrecision(6)))}return r}function qu({lm:e,title:t=`Headroom`}){let{model:n,values:r}=e,i=Wu(e),[a,{width:o}]=Uu(640),[c,d]=(0,J.useState)(null),p=(0,J.useId)().replace(/:/g,``),m=Gu(a),h=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{let e=h.current;e&&c!=null&&(e.style.left=`${Math.max(0,Math.min(C(E[c])+10,v-e.offsetWidth))}px`)});let g=!!n.growth,_={l:44,r:14,t:14,b:g?40:26},v=o,y=Math.round(Math.min(300,Math.max(200,v*.45))),b=v-_.l-_.r,x=y-_.t-_.b,S=Math.max(1.5,n.thresholds.full*1.5),C=e=>_.l+b*Math.log(e/i.from)/Math.log(i.to/i.from),w=e=>_.t+x*(1-Math.min(e,S*1.2)/S),T=e=>{let t=``,n=!1;for(let[r,i]of e)i==null?n=!1:(t+=`${n?`L`:`M`}${C(r).toFixed(1)} ${w(i).toFixed(1)}`,n=!0);return t},E=i.lines[0]?.envelope.map(([e])=>e)??[],D=i.lines.find(e=>e.selected),O=v>=480,ee=Ku(i.from,i.to,O),k=e=>O||Number.isInteger(Math.log10(e)),A=e=>{let t=0;for(let n=1;n<E.length;n++)Math.abs(C(E[n])-e)<Math.abs(C(E[t])-e)&&(t=n);return t},te=e=>{let t=e.currentTarget.ownerSVGElement.getBoundingClientRect();d(A(e.clientX-t.left))},ne=e=>{let t=c??A(C(Math.min(i.to,Math.max(i.from,r.load))));e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),d(Math.max(0,Math.min(E.length-1,t+(e.key===`ArrowRight`?1:-1))))):e.key===`Escape`&&d(null)},re=e=>{let t=e.upper.flatMap(([t,n],r)=>{let i=e.lower[r][1];return n==null||i==null?[]:[[t,n,i]]});if(t.length<2)return``;let n=t.map(([e,t])=>`${C(e).toFixed(1)} ${w(t).toFixed(1)}`),r=t.map(([e,,t])=>`${C(e).toFixed(1)} ${w(t).toFixed(1)}`).reverse();return`M${n.join(`L`)}L${r.join(`L`)}Z`},ie=(e,t)=>e&&ae(e)?u(e,n.searchMax):l(t,n.searchMax),ae=e=>l(e.low,n.searchMax)!==l(e.high,n.searchMax),j=i.lines.map(e=>`${Iu(e)} reaches the ${f(n.thresholds.target)} target at ${ie(e.targetRange,e.target)} and ${f(n.thresholds.full)} at ${ie(e.fullRange,e.full)}`).join(`; `),oe=C(Math.min(i.to,Math.max(i.from,r.load))),se=c==null?null:E[c],ce={x:0,textAnchor:`start`},le={x:v,textAnchor:`end`},ue=(e,t,n,r=4)=>{let i={x:e+r,textAnchor:`start`},a={x:e-r,textAnchor:`end`},o=e+r+t<=v,s=e-r-t>=0;return(n===`right`||!s)&&o?i:s?a:e<v/2?ce:le},de=(e,t)=>e-t/2<0?ce:e+t/2>v?le:{x:e,textAnchor:`middle`},fe=`shown: ${s(r.load)}×`,pe=(e,t,n)=>(0,Y.jsx)(`text`,{...ue(t,m(e,600),`left`,6),y:n,className:`lm-mark`,children:e});return(0,Y.jsxs)(`div`,{className:`lm-card lm-headroom`,children:[(0,Y.jsx)(`h3`,{children:t}),i.lines.length>1&&(0,Y.jsxs)(`div`,{className:`lm-legend`,children:[i.lines.map(e=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`b`,{className:`lm-key`,style:{background:Fu(n,e.label)}}),Iu(e)]},Iu(e))),D&&(0,Y.jsxs)(`span`,{children:[`thin lines: each component of `,Iu(D)]})]}),(0,Y.jsxs)(`div`,{className:`lm-chart`,ref:a,role:`slider`,"aria-label":`Utilization over the load multiple. ${j}.`,"aria-valuemin":i.from,"aria-valuemax":i.to,"aria-valuenow":se??r.load,"aria-valuetext":se==null?`${s(r.load)}×`:`${s(se)}×: ${i.lines.map(e=>`${Iu(e)} ${e.envelope[c][1]==null?`off`:f(e.envelope[c][1])}`).join(`, `)}`,tabIndex:0,onKeyDown:ne,onBlur:()=>d(null),children:[(0,Y.jsxs)(`svg`,{width:v,height:y,viewBox:`0 0 ${v} ${y}`,"aria-hidden":`true`,children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsx)(`clipPath`,{id:p,children:(0,Y.jsx)(`rect`,{x:_.l,y:_.t,width:b,height:x+2})})}),[0,n.thresholds.target,n.thresholds.full].map(e=>(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)(`line`,{x1:_.l,x2:v-_.r,y1:w(e),y2:w(e),stroke:`var(--lm-line)`}),(0,Y.jsx)(`text`,{x:_.l-6,y:w(e)+4,textAnchor:`end`,className:`lm-axis`,children:f(e)})]},e)),(0,Y.jsx)(`text`,{x:v-_.r,y:w(n.thresholds.target)-5,textAnchor:`end`,className:`lm-axis`,children:`target`}),ee.map(e=>{let t=`${s(e)}×`,r=g&&e>1?Lu(n,e):``;return(0,Y.jsxs)(`g`,{className:`lm-axis`,children:[(0,Y.jsx)(`line`,{x1:C(e),x2:C(e),y1:_.t+x,y2:_.t+x+4,stroke:`var(--lm-line)`}),k(e)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`text`,{...de(C(e),m(t)),y:_.t+x+16,children:t}),r&&(0,Y.jsx)(`text`,{...de(C(e),m(r)),y:_.t+x+30,children:r})]})]},e)}),(0,Y.jsxs)(`g`,{clipPath:`url(#${p})`,children:[[...i.lines].sort((e,t)=>Number(e.selected)-Number(t.selected)).map(e=>e.band?(0,Y.jsx)(`path`,{"data-band":Iu(e),d:re(e.band),fill:Fu(n,e.label),fillOpacity:e.selected?.2:.08},Iu(e)):null),D?.components.map(e=>(0,Y.jsx)(`path`,{d:T(e.points),fill:`none`,stroke:`var(--lm-muted)`,strokeOpacity:`.55`,strokeWidth:`1`},e.id)),[...i.lines].sort((e,t)=>Number(e.selected)-Number(t.selected)).map(e=>(0,Y.jsx)(`path`,{"data-line":Iu(e),d:T(e.envelope),fill:`none`,stroke:Fu(n,e.label),strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`},Iu(e)))]}),(0,Y.jsx)(`line`,{x1:oe,x2:oe,y1:_.t,y2:_.t+x,stroke:`var(--lm-fg)`,strokeOpacity:`.45`}),(0,Y.jsx)(`text`,{...ue(oe,m(fe),`right`),y:_.t+10,className:`lm-axis`,children:fe}),i.lines.flatMap(e=>[[`target`,e.targetRange,n.thresholds.target],[`full`,e.fullRange,n.thresholds.full]].map(([t,r,a])=>{if(!e.band||!r||!Number.isFinite(r.low)||r.low>i.to)return null;let[o,s]=[C(Math.max(i.from,r.low)),C(Math.min(i.to,r.high))],c=w(a);return(0,Y.jsxs)(`g`,{"data-range":t,"data-scenario":Iu(e),"data-low":r.low,"data-high":r.high,stroke:Fu(n,e.label),strokeWidth:e.selected?3:2,strokeOpacity:e.selected?1:.6,children:[(0,Y.jsx)(`line`,{x1:o,x2:s,y1:c,y2:c}),(0,Y.jsx)(`line`,{x1:o,x2:o,y1:c-5,y2:c+5}),Number.isFinite(r.high)&&r.high<=i.to&&(0,Y.jsx)(`line`,{x1:s,x2:s,y1:c-5,y2:c+5})]},`${Iu(e)}/${t}/range`)})),i.lines.flatMap(e=>[[`target`,e.target,e.targetRange,n.thresholds.target],[`full`,e.full,e.fullRange,n.thresholds.full]].map(([t,r,a,o])=>r!=null&&Number.isFinite(r)&&r>=i.from&&r<=i.to?(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)(`circle`,{"data-crossing":t,"data-scenario":Iu(e),"data-multiple":r,cx:C(r),cy:w(o),r:`4`,fill:Fu(n,e.label),stroke:`var(--lm-surface)`,strokeWidth:`2`}),e.selected&&pe(a&&ae(a)?u(a,n.searchMax,!0):l(r,n.searchMax),C(a&&ae(a)?Math.max(i.from,a.low):r),w(o)-8)]},`${Iu(e)}/${t}`):null)),se!=null&&(0,Y.jsx)(`line`,{x1:C(se),x2:C(se),y1:_.t,y2:_.t+x,stroke:`var(--lm-fg)`,strokeOpacity:`.8`}),(0,Y.jsx)(`rect`,{x:_.l,y:_.t,width:b,height:x,fill:`transparent`,onPointerMove:te,onPointerDown:te,onPointerLeave:()=>d(null)})]}),c!=null&&se!=null&&(0,Y.jsxs)(`div`,{className:`lm-tip`,role:`status`,ref:h,style:{left:C(se)+10,top:_.t},children:[(0,Y.jsxs)(`b`,{children:[s(se),`×`,Lu(n,se)&&` · ${Lu(n,se)}`]}),i.lines.map(e=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`b`,{className:`lm-key`,style:{background:Fu(n,e.label)}}),(0,Y.jsx)(`strong`,{children:e.envelope[c][1]==null?`off`:f(e.envelope[c][1])}),` `,Iu(e)]},Iu(e))),D?.components.map(e=>(0,Y.jsxs)(`span`,{className:`lm-sub`,children:[(0,Y.jsx)(`strong`,{children:e.points[c][1]==null?`off`:f(e.points[c][1])}),` `,e.name]},e.id))]})]})]})}var X={off:`var(--lm-line)`,ok:`var(--lm-ok)`,warn:`var(--lm-warn)`,over:`var(--lm-drop)`},Ju=e=>[`accent`,`alt`,`ok`,`warn`,`drop`,`muted`].includes(e)?`var(--lm-${e})`:e;function Z({lm:e,legend:t=!0,onNodeClick:n,selected:r=null}){let{scene:i,engine:a,reducedMotion:o}=e,s=(0,J.useRef)(n);s.current=n;let[c]=(0,J.useState)(()=>e=>s.current?.(e)),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(0,J.useRef)(null),p=(0,J.useRef)(null),m=(0,J.useRef)(null),h=(0,J.useRef)(null),g=e.fullScreen,[_,v]=(0,J.useState)(null),y=(0,J.useId)();(0,J.useLayoutEffect)(()=>{i&&a.setScene(i,{cut:o})},[a,i,o]);let b=(0,J.useSyncExternalStore)(a.subscribe,()=>a.frameId),x=a.frame;(0,J.useEffect)(()=>{a.bind(l.current,u.current)},[a,x,o]),(0,J.useLayoutEffect)(()=>a.applyCamera()),(0,J.useEffect)(()=>{e.root&&a.readColors(e.root)},[a,i,e.root]),(0,J.useEffect)(()=>{a.drawnValues=JSON.stringify(e.values),a.drawnFocus=e.focus,a.drawnFrame=b}),(0,J.useEffect)(()=>{let e=p.current;if(!e)return;let t=new ResizeObserver(()=>a.resize());return t.observe(e),()=>t.disconnect()},[a]);let S=()=>{let e=d.current,t=p.current,n=a.camera,r=h.current;if(!n&&!a.cue)return;if(!e||!t||!a.frame||e.scrollHeight<=e.clientHeight){r?.style.removeProperty(`top`),r?.style.removeProperty(`bottom`);return}let i=t.clientHeight/a.frame.height;n&&(e.scrollTop=t.offsetTop+(n.y+n.h/2)*i-e.clientHeight/2),r&&(r.style.top=`${Math.max(0,e.scrollTop-t.offsetTop+(f.current?.offsetHeight??0))}px`,r.style.bottom=`auto`)};(0,J.useEffect)(()=>{let e=0,t=0,n=r=>{let i=t?Math.min(.05,(r-t)/1e3):0;t=r,!a.paused&&a.scene&&(a.step(i,{particles:!o}),a.draw({particles:!o}),S()),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>cancelAnimationFrame(e)},[a,o]);let C=(0,J.useRef)(!1);(0,J.useEffect)(()=>{C.current&&!g&&m.current?.focus(),C.current=g},[g]),(0,J.useEffect)(()=>{let t=d.current,n=f.current,r=e.root;if(!g||!i||!t||!n||!r)return;let a=e=>Number.parseFloat(e)||0,o=()=>{let e=getComputedStyle(r),o=a(e.paddingTop)+a(e.paddingBottom),s=t=>{let n=getComputedStyle(t);n.display!==`none`&&n.position!==`absolute`&&n.position!==`fixed`&&(o+=a(e.rowGap)+(a(n.flexGrow)>0?a(n.minHeight):t.offsetHeight))};for(let e of r.children)e!==t&&s(e);getComputedStyle(r,`::after`).content!==`none`&&(o+=a(e.rowGap));let c=r.clientHeight-o-n.offsetHeight-a(getComputedStyle(t).rowGap),l=Math.min(t.clientWidth,c*i.width/i.height);t.style.setProperty(`--lm-fit`,`${Math.max(0,Math.floor(l))}px`)},s=new ResizeObserver(o),c=()=>{s.disconnect(),s.observe(n),s.observe(r);for(let e of r.children)s.observe(e)};c();let l=new MutationObserver(()=>{c(),o()});return l.observe(r,{childList:!0,attributeFilter:[`data-mode`]}),()=>{s.disconnect(),l.disconnect(),t.style.removeProperty(`--lm-fit`)}},[g,i,e.root]);let{setFullScreenMode:w,fullScreenMode:T}=e,E=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let t=e.root;if(!g||!t)return;let n=e=>{if(e.key!==`f`&&e.key!==`F`||e.ctrlKey||e.metaKey||e.altKey||Q(e.composedPath()[0]??null)||t.querySelector(`:scope > [data-drawer]`)||(e.preventDefault(),e.repeat))return;let n=T===`focus`?`panels`:`focus`;document.activeElement?.closest(`.lm-dock, .lm-line`)&&E.current?.querySelector(`[data-mode="${n}"]`)?.focus(),w(n)};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[g,T,w,e.root]),(0,Y.jsxs)(`div`,{className:`lm-wrap`,ref:d,children:[(0,Y.jsxs)(`div`,{className:`lm-bar`,ref:f,children:[t?(0,Y.jsx)(Yu,{lm:e}):(0,Y.jsx)(`span`,{}),(0,Y.jsxs)(`span`,{className:`lm-tools`,children:[g&&(0,Y.jsx)(`fieldset`,{className:`lm-modes`,"aria-label":`Full screen shows (F)`,ref:E,children:[`panels`,`focus`].map(e=>(0,Y.jsx)(`button`,{type:`button`,"data-mode":e,"aria-pressed":T===e,"aria-keyshortcuts":`F`,onClick:()=>w(e),children:e===`panels`?`Panels`:`Focus`},e))}),(0,Y.jsx)(`button`,{type:`button`,className:`lm-btn`,onClick:e.toggleFullScreen,"aria-pressed":g,ref:m,children:g?`✕ Close`:`⤢ Full screen`})]})]}),(0,Y.jsxs)(`div`,{className:`lm-board`,ref:p,style:x?{aspectRatio:`${x.width} / ${x.height}`}:{minHeight:240},children:[x&&(0,Y.jsx)(Zu,{lm:e,scene:x,svgRef:l,rates:o,setTip:v,onClick:n?c:void 0,selected:r}),(0,Y.jsx)(`canvas`,{ref:u,hidden:o}),e.cue&&(0,Y.jsxs)(`div`,{className:`lm-title`,"data-top":e.cue.top||void 0,"aria-hidden":`true`,ref:h,children:[(0,Y.jsx)(`b`,{children:e.cue.title}),e.cue.detail&&(0,Y.jsx)(`span`,{children:e.cue.detail})]})]}),x&&_&&!e.storyPlaying&&(0,Y.jsx)(ad,{lm:e,scene:x,id:_.id,board:p.current,detailId:y})]})}function Q(e){return e instanceof HTMLElement?e.isContentEditable||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?!0:e instanceof HTMLInputElement&&![`range`,`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`file`,`color`].includes(e.type):!1}function Yu({lm:e}){let t=e.view.def.flows,n=Object.values(e.ev.overload).some(e=>e.merge)||Object.values(e.ev.stages).some(e=>e.kind===`fanout`);return(0,Y.jsxs)(`div`,{className:`lm-legend`,children:[Object.entries(t).map(([e,t])=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`i`,{style:{background:Ju(t.color)}}),t.label??e]},e)),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`i`,{style:{background:`var(--lm-ok)`}}),`done`]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`i`,{style:{background:`var(--lm-drop)`}}),`dropped or rejected`]}),n&&(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`i`,{style:{background:`var(--lm-muted)`}}),`superseded or unread`]}),(0,Y.jsx)(`span`,{children:e.reducedMotion?`line width: rate`:`one dot ≈ ${e.engine.sim.dotScale.toLocaleString(`en-US`)} a second · ${e.engine.sim.speed}× speed`})]})}var Xu=(e,t)=>xu(e.ev,t),Zu=(0,J.memo)(function({lm:e,scene:t,svgRef:n,rates:r,setTip:i,onClick:a,selected:o}){let s=(0,J.useId)().replace(/:/g,``),{labels:c,ev:l}=e,u=t=>{let n=Xu(e,t);return n?l.components[n]?.state??null:null},d=t=>{let n=Xu(e,t),r=n?l.components[n]:void 0,s=c.nodes[t.id]?.title;if(!r)return a?{tabIndex:0,role:`button`,className:`lm-node`,"aria-label":s??t.id,"aria-pressed":o===t.id,onClick:()=>a(t.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a(t.id))}}:{};let u=()=>{i(e=>e?.pinned&&e.id===t.id?null:{id:t.id,pinned:!0}),a?.(t.id)};return{tabIndex:0,role:`button`,className:`lm-node`,"aria-label":`${s&&s!==r.name?`${s}, `:``}${r.name}: ${r.util==null?`switched off`:f(r.util)}`,...a?{"aria-pressed":o===t.id}:{},onPointerEnter:e=>e.pointerType===`mouse`&&i(e=>e?.pinned?e:{id:t.id,pinned:!1}),onPointerLeave:e=>e.pointerType===`mouse`&&i(e=>e?.pinned?e:null),onFocus:()=>i(e=>e?.pinned?e:{id:t.id,pinned:!1}),onBlur:()=>i(e=>e?.pinned?e:null),onClick:u,onKeyDown:e=>{e.key===`Escape`&&i(null),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u())}}},p=t.nodes.map(e=>c.nodes[e.id]?.title).join(`, `),m=l.firstLimit;return(0,Y.jsxs)(`svg`,{ref:n,viewBox:`0 0 ${t.width} ${t.height}`,role:`group`,"aria-label":`Diagram: ${p}`,children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsx)(`marker`,{id:s,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Y.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--lm-muted)`})})}),r&&(0,Y.jsx)(ed,{lm:e,scene:t}),t.edges.map(e=>(0,Y.jsx)($u,{e,text:c.edges[e.id],marker:s},e.id)),t.nodes.map(t=>(0,Y.jsx)(nd,{n:t,state:u(t),title:c.nodes[t.id]?.title,sub:c.nodes[t.id]?.sub,lm:e,focused:!!e.focus&&Xu(e,t)===e.focus,selected:o===t.id,handlers:d(t)},t.id)),m&&t.nodes.filter(t=>Xu(e,t)===m.id).map(e=>(0,Y.jsx)(id,{n:e},e.id))]})}),Qu=e=>e.map(([e,t],n)=>`${n?`L`:`M`}${e} ${t}`).join(` `);function $u({e,text:t,marker:n}){let r=e.draw!=null&&e.draw<1;return(0,Y.jsxs)(`g`,{opacity:e.fade,children:[(0,Y.jsx)(`path`,{d:Qu(e.points),fill:`none`,stroke:`var(--lm-muted)`,strokeOpacity:`.7`,markerEnd:r?void 0:`url(#${n})`,...r?{pathLength:1,strokeDasharray:1,strokeDashoffset:1-e.draw}:{}}),e.label&&t&&(0,Y.jsx)(`text`,{x:e.label.x+e.label.w/2,y:e.label.y+e.label.h/2+4,textAnchor:`middle`,fontSize:`11`,fill:`var(--lm-muted)`,children:t})]})}function ed({lm:e,scene:t}){let{ev:n}=e,r=e.view.def.flows,i=Math.max(1e-9,...Object.values(n.flows)),a=[];for(let e of Object.keys(r)){let o=[t.flowFrom[e],...(n.routes[e]??[]).map(e=>t.stageNode[e])].filter((e,t,n)=>e&&e!==n[t-1]),s=n.flows[e]??0,c=o.slice(1).map((e,t)=>[o[t],e,s]),l=(n.routes[e]??[]).at(-1),u=l?n.stages[l]:void 0;if(u?.kind===`fanout`)for(let n of u.to[e]??[])c.push([t.stageNode[l],t.stageNode[n.stage],s*n.share]);for(let[n,o,s]of c){let c=t.edges.find(e=>e.from===n&&e.to===o);c&&a.push((0,Y.jsx)(`path`,{d:Qu(c.points),fill:`none`,stroke:Ju(r[e].color),strokeOpacity:`.45`,strokeWidth:1.5+6*Math.min(s,i)/i},`${e}:${c.id}`))}}return(0,Y.jsx)(`g`,{children:a})}function td({s:e,children:t,anchor:n=`middle`,fill:r=`currentColor`,opacity:i}){return(0,Y.jsx)(`text`,{x:e.x,y:e.y,fontSize:e.size,fontWeight:e.weight,textAnchor:n,fill:r,opacity:i,children:t})}function nd({n:e,state:t,title:n,sub:r,lm:i,focused:a,selected:o,handlers:s}){let c=t?X[t]:`var(--lm-line)`,l=i.view.def.flows,u=e.kind===`pool`?i.ev.stages[e.stages[0]??``]:void 0,d=u?.kind===`workers`?u.running:e.members.length,f=t=>t>=d&&t<(u?.kind===`workers`?u.pods:e.members.length),p=e.fade==null?void 0:`translate(${e.x+e.w/2} ${e.y+e.h/2}) scale(${.92+.08*e.fade}) translate(${-e.x-e.w/2} ${-e.y-e.h/2})`;return(0,Y.jsxs)(`g`,{style:{color:`var(--lm-fg)`},opacity:e.fade,transform:p,"data-node":e.id,"data-focus":a||void 0,"data-selected":o||void 0,...s,children:[e.shape===`cylinder`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`path`,{d:`M${e.x} ${e.y+6} A${e.w/2} 6 0 0 1 ${e.x+e.w} ${e.y+6} V${e.y+e.h-6} A${e.w/2} 6 0 0 1 ${e.x} ${e.y+e.h-6} Z`,fill:`var(--lm-surface)`,stroke:c,strokeWidth:`1.5`}),(0,Y.jsx)(`path`,{d:`M${e.x} ${e.y+6} A${e.w/2} 6 0 0 0 ${e.x+e.w} ${e.y+6}`,fill:`none`,stroke:c,strokeWidth:`1.5`})]}):(0,Y.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:`6`,fill:`var(--lm-surface)`,stroke:c,strokeWidth:`1.5`}),(0,Y.jsx)(td,{s:e.title,children:n}),e.sub&&r&&(0,Y.jsx)(td,{s:e.sub,fill:`var(--lm-muted)`,children:r}),e.members.map((e,t)=>(0,Y.jsxs)(`g`,{"data-idle":f(t)||void 0,opacity:f(t)?.45*(e.fade??1):e.fade,children:[(0,Y.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:`4`,fill:`none`,stroke:`var(--lm-line)`,strokeDasharray:f(t)?`3 3`:void 0}),(0,Y.jsx)(td,{s:e.spot,anchor:`start`,fill:`var(--lm-muted)`,children:e.label})]},e.label)),e.groups.map((e,t)=>(0,Y.jsx)(td,{s:e.spot,anchor:`start`,fill:Ju(l[e.flow]?.color??`muted`),opacity:e.fade,children:e.text},`${e.flow}#${t}`)),e.cells.map(e=>(0,Y.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:`1.5`,opacity:e.fade,fill:`var(--lm-lane)`,stroke:Ju(l[e.flow]?.color??`muted`),strokeOpacity:`.6`},`${e.stage}/${e.flow}/${e.index}`)),e.slots.map(t=>(0,Y.jsxs)(`g`,{opacity:t.fade,children:[(0,Y.jsx)(`rect`,{x:t.x,y:t.y,width:t.w,height:t.h,rx:`2`,fill:`var(--lm-surface)`,stroke:`currentColor`,strokeOpacity:`.45`}),(0,Y.jsx)(`rect`,{"data-slot":t.index,"data-stage":e.stages[0],"data-y":t.y,"data-s":t.w,x:t.x+1,y:t.y+t.h-1,width:t.w-2,height:0,rx:`1`,fill:`var(--lm-accent)`})]},t.index)),o&&(0,Y.jsx)(`rect`,{className:`lm-selected`,x:e.x-3,y:e.y-3,width:e.w+6,height:e.h+6,rx:`8`,fill:`none`,stroke:`var(--lm-accent)`,strokeWidth:`2.5`}),a&&(0,Y.jsx)(`rect`,{className:`lm-focus`,x:e.x-5,y:e.y-5,width:e.w+10,height:e.h+10,rx:`9`,fill:`none`,stroke:`var(--lm-accent)`,strokeWidth:`2`,strokeDasharray:`5 4`})]})}var rd=72;function id({n:e}){let t={x:e.x-7,y:e.y-7,width:e.w+14,height:e.h+14,rx:10},n=e.x+e.w+7-rd-8;return(0,Y.jsxs)(`g`,{className:`lm-halo`,"data-halo":``,"data-cx":e.x+e.w/2,"data-cy":e.y+e.h/2,opacity:e.fade,pointerEvents:`none`,children:[(0,Y.jsx)(`rect`,{...t,"data-glow":``,fill:`none`,stroke:`var(--lm-drop)`,strokeWidth:`10`,strokeOpacity:`.22`}),(0,Y.jsx)(`rect`,{...t,fill:`none`,stroke:`var(--lm-drop)`,strokeWidth:`2.5`}),(0,Y.jsx)(`rect`,{x:n,y:t.y-7.5,width:rd,height:`15`,rx:`3`,fill:`var(--lm-drop)`}),(0,Y.jsx)(`text`,{x:n+rd/2,y:t.y+3.5,textAnchor:`middle`,fontSize:`9.5`,fontWeight:`600`,letterSpacing:`.06em`,fill:`var(--lm-surface)`,children:`FIRST LIMIT`})]})}function ad({lm:e,scene:t,id:n,board:r,detailId:i}){let{model:a,ev:o}=e,d=t.nodes.find(e=>e.id===n),p=d&&Xu(e,d),m=zu(e),h=a.scenarios.length>1?m.rows:[];(0,J.useEffect)(()=>{let e=r?.querySelector(`[data-node="${CSS.escape(n)}"]`);return e?.setAttribute(`aria-describedby`,i),()=>e?.removeAttribute(`aria-describedby`)},[r,n,i]);let g=p?o.components[p]:void 0,_=(0,J.useRef)(null),v=d&&`${d.x} ${d.y} ${d.w} ${d.h}`;if((0,J.useLayoutEffect)(()=>{let e=_.current,n=e?.offsetParent;if(!e||!d||!r||!(n instanceof HTMLElement))return;let i=()=>{let i=r.clientWidth/t.width,a=n.getBoundingClientRect(),o=e=>e-a.top-n.clientTop+n.scrollTop,s=0,c=innerHeight;for(let e=n;e;e=e.parentElement){if(getComputedStyle(e).overflowY===`visible`)continue;let t=e.getBoundingClientRect();s=Math.max(s,t.top),c=Math.min(c,t.bottom)}let[l,u]=[o(s)+4,o(c)-4],f=e.offsetHeight,p=r.offsetTop+d.y*i,m=r.offsetTop+(d.y+d.h)*i,h=m+6,g=p-6-f,_=(d.y+d.h/2<t.height/2?[h,g]:[g,h]).find(e=>e>=l&&e+f<=u),v=u-m>=p-l?h:g;e.style.top=`${Math.max(l,Math.min(_??v,u-f))}px`,e.style.left=`${Math.max(0,Math.min(r.offsetLeft+d.x*i,n.clientWidth-e.offsetWidth))}px`};i();let a=new ResizeObserver(i);return a.observe(e),a.observe(r),document.addEventListener(`scroll`,i,{capture:!0,passive:!0}),addEventListener(`resize`,i),()=>{a.disconnect(),document.removeEventListener(`scroll`,i,{capture:!0}),removeEventListener(`resize`,i)}},[v,r,t]),!d||!g||!r)return null;let y=(e,t)=>e?N(e,a.searchMax,a.dateAt):l(t,a.searchMax),b=e=>Math.abs(e)>=1e3?c(e):s(e),x=g.capacity;return(0,Y.jsxs)(`div`,{id:i,className:`lm-tip lm-detail`,role:`tooltip`,ref:_,children:[(0,Y.jsxs)(`b`,{children:[g.name,g===o.firstLimit&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`first`,children:`first limit`})]}),g.util==null||!x?(0,Y.jsx)(`span`,{children:`switched off`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:f(g.util)}),` · `,b(g.demand??0),` of `,s(x.value),` `,x.unit,x.within?` ±${f(x.within)}`:``]}),(0,Y.jsxs)(`span`,{className:`lm-sub`,children:[`capacity`,` `,(0,Y.jsx)(`span`,{className:`lm-prov`,"data-kind":x.provenance,children:x.provenance}),x.source?`, ${x.source}`:``]}),(0,Y.jsxs)(`span`,{children:[f(a.thresholds.target),` at `,y(g.targetRange,g.target)]}),(0,Y.jsxs)(`span`,{children:[f(a.thresholds.full),` at `,y(g.fullRange,g.full)]}),od(e,d).map(e=>(0,Y.jsx)(`span`,{children:e},e)),g.over&&(0,Y.jsxs)(`span`,{className:`lm-sub`,children:[`Past `,f(a.thresholds.full),`: `,g.over,`.`]})]}),h.length>0&&(0,Y.jsxs)(`span`,{className:`lm-sub`,children:[f(a.thresholds.target),` by scenario:`,` `,h.map((e,t)=>{let n=e.components.find(e=>e.id===p);return(0,Y.jsxs)(`span`,{className:`lm-nowrap`,children:[t>0&&` · `,(0,Y.jsx)(`b`,{className:`lm-key`,style:{background:Fu(a,e.label)}}),e.label,` `,n?.targetRange==null?`off`:u(n.targetRange,a.searchMax,!0)]},e.label)})]})]})}function od(e,t){let n=[];for(let r of t.stages){let t=e.ev.stages[r];t?.kind===`workers`&&t.autoscale&&n.push(`${t.running} of ${t.pods} pods running, each held near ${f(t.autoscale.target)}`),t?.kind===`cache`&&n.push(`${f(t.hit)} answered here`),(t?.kind===`pass`||t?.kind===`limit`||t?.kind===`cache`)&&t.shed>0&&n.push(`${f(t.shed)} of what reaches it turned away`)}return n}var sd=null;function cd(){return sd??=ld(()=>new Worker(new URL(new URL(`elk.worker-4x4hA5S2.js`,import.meta.url).href,``+import.meta.url),{type:`module`,name:`loadmap-elk`})),sd}function ld(e){let t=null,n=typeof Worker>`u`,r=!1,i=0,a=new Map,o=e=>{r||typeof Worker>`u`||(r=!0,console.info(`loadmap: the layout runs on the main thread, slower to start: the ELK worker did not start (${e}). A page can hand one in, <Loadmap elk={workerElk(() => new Worker(…))}>; a Content-Security-Policy must allow it (worker-src).`))},s=e=>{o(e),n=!0,t?.terminate(),t=null;for(let[e,t]of a)a.delete(e),Ve().then(e=>e.layout(t.graph)).then(t.resolve,t.reject)},c=()=>{if(t||n)return t;try{t=e()}catch(e){return s(e instanceof Error?e.message:String(e)),null}return t.onmessage=({data:e})=>{let t=a.get(e.id);t&&(a.delete(e.id),e.error==null?t.resolve(e.graph):t.reject(Error(e.error)))},t.onerror=e=>{e.preventDefault(),s(e.message||`it failed to load or to run`)},t};return{layout(e){let t=c();return t?new Promise((n,r)=>{let o=i++;a.set(o,{graph:e,resolve:n,reject:r}),t.postMessage({id:o,graph:e})}):(o(`no Worker here`),Ve().then(t=>t.layout(e)))}}}function ud({lm:e}){let{measure:t}=e.ev;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`lm-verdict`,"data-tier":e.ev.verdict.tier,"aria-live":`polite`,children:e.ev.verdict.text}),t&&(0,Y.jsx)(`p`,{className:`lm-measure`,"data-component":t.component,children:t.text})]})}var dd=e=>e?.within?`±${f(e.within)}`:``;function fd({lm:e,title:t=`Where it runs out, in order`}){let{ev:n,model:r}=e,i=Math.max(1.5,r.thresholds.full*1.5),a=e=>`${e/i*100}%`,o=(e,t)=>e?u(e,r.searchMax,!0):l(t,r.searchMax);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:t}),(0,Y.jsxs)(`div`,{className:`lm-scale`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{style:{left:0,transform:`none`},children:`0`}),(0,Y.jsxs)(`span`,{style:{left:a(r.thresholds.target)},children:[f(r.thresholds.target),` target`]}),(0,Y.jsx)(`span`,{style:{left:a(r.thresholds.full)},children:f(r.thresholds.full)}),(0,Y.jsx)(`span`,{style:{left:`100%`,transform:`translateX(-100%)`},children:f(i)})]}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsx)(`div`,{className:`lm-limits`,children:n.ranked.map(e=>(0,Y.jsxs)(`div`,{className:`lm-lim`,"data-component":e.id,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`b`,{children:[e.name,e===n.firstLimit&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`first`,children:`first limit`}),e.capacity?.provenance===`estimated`?(0,Y.jsxs)(`span`,{className:`lm-tag`,"data-kind":`estimated`,children:[`estimate`,e.capacity.within?` ${dd(e.capacity)}`:``]}):!!e.capacity?.within&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`range`,children:dd(e.capacity)})]}),(0,Y.jsx)(`span`,{className:`lm-sub`,children:e.describe??(e.capacity?`${s(e.capacity.value)} ${e.capacity.unit}`:`switched off`)})]}),(0,Y.jsxs)(`div`,{className:`lm-track`,role:`img`,"aria-label":`${e.name} at ${e.util==null?`off`:f(e.util)}`,children:[(0,Y.jsx)(`div`,{className:`lm-fill`,"data-state":e.state,style:{width:`${Math.min(100,(e.util??0)/i*100)}%`}}),(0,Y.jsx)(`div`,{className:`lm-tick`,style:{left:a(r.thresholds.target)}}),(0,Y.jsx)(`div`,{className:`lm-tick`,style:{left:a(r.thresholds.full)}})]}),(0,Y.jsxs)(`div`,{className:`lm-val`,children:[e.util==null?`—`:`${f(e.util)} · ${vd(e.demand??0)} ${e.capacity?.unit??``}`,(0,Y.jsx)(`small`,{children:e.util==null?`switched off`:`${f(r.thresholds.target)} at ${o(e.targetRange,e.target)} · full at ${o(e.fullRange,e.full)}`})]})]},e.id))})]})}function pd({lm:e}){let[,t]=(0,J.useState)(0);(0,J.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),250);return()=>clearInterval(e)},[]);let{ev:n,engine:r,model:i}=e,a=r.sim,o=e=>i.def.flows[e]?.label??e,l=[];for(let e of Object.values(n.stages)){if(e.kind===`queue`)for(let t of i.flowIds.filter(t=>n.routes[t]?.includes(e.id))){let r=a.queue(e.id,t),i=n.overload[t]??{};l.push({key:`${e.id}/${t}/lag`,value:p(r.lag),label:`${o(t)} lag in ${e.label}`,state:r.lag>60?`over`:r.lag>5?`warn`:`ok`}),i.merge&&l.push({key:`${e.id}/${t}/merge`,value:c(r.merged),label:`${o(t)} superseded /s (${i.merge.reason??`newest kept`})`,state:r.merged>.5?`warn`:`ok`}),i.drop&&l.push({key:`${e.id}/${t}/drop`,value:c(r.dropped),label:`${o(t)} dropped /s (${i.drop.reason??`too old`})`,state:r.dropped>.5?`over`:`ok`})}if(e.kind===`workers`){let t=a.busy(e.id);l.push({key:`${e.id}/busy`,value:f(t),label:`${e.label} busy`,state:t>.95?`over`:t>.5?`warn`:`ok`}),e.autoscale&&l.push({key:`${e.id}/pods`,value:`${e.running} of ${e.pods}`,label:`${e.label} pods running`,state:e.running<e.pods?`ok`:(n.components[e.component]?.util??0)>i.thresholds.full?`over`:`warn`})}e.kind===`cache`&&l.push({key:`${e.id}/hits`,value:c(a.arriving(e.id)*(1-a.shed(e.id))*e.hit),label:`answered at ${e.label} /s (${f(e.hit)} hits)`,state:`ok`}),(e.kind===`pass`||e.kind===`limit`||e.kind===`cache`)&&a.shed(e.id)>0&&l.push({key:`${e.id}/shed`,value:f(a.shed(e.id)),label:`rejected at ${e.label}`,state:`over`})}for(let e of i.flowIds){let t=n.retry[e];if(!t||!(t.rate>0))continue;let r=t.attempts/t.rate;l.push({key:`${e}/attempts`,value:`${s(r)}×`,label:`${o(e)} attempts per ${i.def.flows[e]?.unit??`unit`}`,state:r>1.05?`warn`:`ok`}),l.push({key:`${e}/failed`,value:f(t.failed),label:`${o(e)} failing after ${t.times} ${t.times===1?`retry`:`retries`}`,state:t.failed>.005?`over`:`ok`})}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`Live`}),(0,Y.jsx)(`div`,{className:`lm-meters`,children:l.map(e=>(0,Y.jsxs)(`div`,{className:`lm-meter`,"data-state":e.state,children:[(0,Y.jsx)(`b`,{children:e.value}),(0,Y.jsx)(`span`,{title:e.label,children:e.label})]},e.key))})]})}function md({lm:e}){let t=e.model.load,n=e.values.load;return(0,Y.jsxs)(`label`,{className:`lm-range`,children:[(0,Y.jsxs)(`span`,{children:[t.label,` `,(0,Y.jsxs)(`output`,{children:[s(n),`×`]})]}),(0,Y.jsx)(`input`,{type:`range`,min:t.min,max:t.max,step:t.step,value:n,onChange:t=>e.setValues({load:Number(t.target.value)})})]})}function hd({lm:e}){let{model:t,values:n,setValues:r,ev:i}=e,a=n;return(0,Y.jsxs)(`div`,{className:`lm-card lm-controls`,children:[(0,Y.jsx)(`h3`,{children:`Load`}),(0,Y.jsx)(md,{lm:e}),(0,Y.jsx)(`div`,{className:`lm-presets`,children:i.presets.map(e=>{let t=Object.entries(e.values).every(([e,t])=>a[e]===t);return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>r(e.values),children:e.label},e.label)})}),t.params.length>1&&(0,Y.jsx)(`h3`,{children:`Design`}),t.params.map(({id:e,def:n})=>{if(n.kind===`load`)return null;let i=t.isEnabled(e,a),o=n.tag&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`estimated`,children:n.tag});return n.kind===`switch`?(0,Y.jsxs)(`label`,{className:`lm-switch${i?``:` lm-off`}`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:!!a[e],disabled:!i,onChange:t=>r({[e]:t.target.checked})}),(0,Y.jsxs)(`span`,{children:[n.label,o]}),n.hint&&(0,Y.jsx)(`small`,{children:n.hint})]},e):n.kind===`select`?(0,Y.jsxs)(`label`,{className:`lm-select${i?``:` lm-off`}`,children:[(0,Y.jsxs)(`span`,{children:[n.label,o]}),(0,Y.jsx)(`select`,{value:String(a[e]),disabled:!i,onChange:t=>{let i=n.options.find(e=>String(e)===t.target.value);r({[e]:i})},children:n.options.map(e=>(0,Y.jsx)(`option`,{value:String(e),children:n.format?n.format(e):String(e)},String(e)))}),n.hint&&(0,Y.jsx)(`small`,{children:n.hint})]},e):(0,Y.jsxs)(`label`,{className:`lm-range${i?``:` lm-off`}`,children:[(0,Y.jsxs)(`span`,{children:[n.label,o,` `,(0,Y.jsx)(`output`,{children:n.format?n.format(a[e]):s(a[e])})]}),(0,Y.jsx)(`input`,{type:`range`,min:n.min,max:n.max,step:n.step,value:a[e],disabled:!i,onChange:t=>r({[e]:Number(t.target.value)})}),n.hint&&(0,Y.jsx)(`small`,{children:n.hint})]},e)})]})}function gd({lm:e,extra:t=[]}){return(0,Y.jsxs)(`div`,{className:`lm-card`,children:[(0,Y.jsx)(`h3`,{children:`What this assumes`}),(0,Y.jsxs)(`ul`,{className:`lm-facts`,children:[t.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t)),e.ev.assumptions.map(e=>(0,Y.jsx)(`li`,{children:_d(e)},e.kind===`capacity`?`c:${e.component}`:`f:${e.name}`))]})]})}function _d(e){if(e.kind===`capacity`){let t=e.capacity;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`b`,{children:[e.name,`:`]}),` `,s(t.value),` `,t.unit,t.within?` ${dd(t)}`:``,`,`,` `,(0,Y.jsx)(`span`,{className:`lm-prov`,"data-kind":t.provenance,children:t.provenance}),t.source?` (${t.source})`:``,`.`]})}let t=e.fit;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`b`,{children:[e.name,`:`]}),` `,t.y,` = `,yd(t.a),` + `,yd(t.b),` × `,t.x,`, r² `,t.r2.toFixed(3),` over `,t.n,` points,`,` `,(0,Y.jsx)(`span`,{className:`lm-prov`,"data-kind":`measured`,children:`measured`}),t.source?` (${t.source})`:``,`.`]})}var vd=e=>Math.abs(e)>=1e3?c(e):s(e),yd=e=>Number(e.toPrecision(3)).toString(),bd={verdict:`Verdict`,live:`Live`,limits:`Limits`,controls:`Load`,headroom:`Headroom`,compare:`Compare`,assumptions:`Assumptions`};function xd({lm:e,verdict:t=!0,extra:n=0,open:r,assumptions:i}){let{ev:a,model:o,values:c}=e,d=a.firstLimit,p=a.target,m=`${f(o.thresholds.target)} target`,h=d?.capacity,g=h?h.provenance===`estimated`?`est${h.within?` ${dd(h)}`:``}`:dd(h):``,_=a.ranked.filter(e=>(e.util??0)>o.thresholds.full),v=p?Ru(o,p):``,y=a.assumptions.filter(e=>e.kind===`capacity`&&e.capacity.provenance===`estimated`).length;return(0,Y.jsxs)(Y.Fragment,{children:[t&&(0,Y.jsx)(`p`,{className:`lm-headline`,title:a.verdict.text,"aria-live":`polite`,children:!d||!p?a.verdict.text:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`b`,{className:`lm-num`,children:[s(c.load),`×`]}),` ·`,` `,c.load<p.low?(0,Y.jsxs)(Y.Fragment,{children:[`the `,m,` holds to `,(0,Y.jsx)(`b`,{className:`lm-num`,children:u(p,o.searchMax,!0)}),v&&` (${v})`]}):(0,Y.jsxs)(Y.Fragment,{children:[`past the `,m,` from `,(0,Y.jsx)(`b`,{className:`lm-num`,children:l(p.low,o.searchMax)})]}),` `,`· first limit `,(0,Y.jsx)(`b`,{children:d.name}),g&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":h?.provenance===`estimated`?`estimated`:`range`,children:g}),_.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[` `,`· `,(0,Y.jsx)(`b`,{children:_.map(e=>e.name).join(`, `)}),` past capacity`]})]})}),r&&t&&(0,Y.jsx)(`button`,{type:`button`,className:`lm-link`,onClick:e=>r(`verdict`,e.currentTarget),children:`Why ›`}),r&&i&&(0,Y.jsxs)(`button`,{type:`button`,className:`lm-link`,onClick:e=>r(`assumptions`,e.currentTarget),children:[`What this assumes · `,a.assumptions.length+n,y>0&&` (${y} estimated)`,` ›`]})]})}var Sd=[`controls`,`live`,`limits`,`headroom`,`compare`];function Cd({lm:e,panels:t,open:n}){let r=Sd.filter(e=>t.includes(e)),[i,a]=(0,J.useState)(null);if(!r.length)return null;let o=i&&r.includes(i)?i:r[0];return(0,Y.jsxs)(`div`,{className:`lm-dock`,children:[(0,Y.jsx)(`fieldset`,{className:`lm-tabs`,"aria-label":`Panels`,children:r.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":e===o,onClick:()=>a(e),children:bd[e]},e))}),r.map(t=>(0,Y.jsx)(wd,{lm:e,panel:t,open:n,active:t===o},t))]})}function wd({lm:e,panel:t,open:n,active:r}){let i=(0,J.useRef)(null),a=(0,J.useRef)(null);return Ed(i,a),(0,Y.jsxs)(`div`,{className:`lm-mini`,"data-mini":t,"data-active":r||void 0,ref:i,children:[t===`controls`?(0,Y.jsx)(hd,{lm:e}):t===`compare`?(0,Y.jsx)(Hu,{lm:e}):(0,Y.jsx)(`div`,{className:`lm-card`,children:t===`live`?(0,Y.jsx)(pd,{lm:e}):t===`limits`?(0,Y.jsx)(Dd,{lm:e}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`Headroom`}),(0,Y.jsx)(Od,{lm:e})]})}),(0,Y.jsx)(`button`,{type:`button`,className:`lm-more`,ref:a,"aria-label":`${bd[t]}, all of it`,onClick:e=>n(t,e.currentTarget),children:`›`})]})}var Td=`.lm-meter, .lm-mini-lim, .lm-controls > *, .lm-table tbody tr`;function Ed(e,t){(0,J.useEffect)(()=>{let n=e.current?.querySelector(`.lm-card`);if(!n)return;let r=()=>{let e=n.getBoundingClientRect(),r=e.bottom-Number.parseFloat(getComputedStyle(n).paddingBottom||`0`),i=0;for(let t of n.querySelectorAll(Td)){let n=e.height>0&&t.getBoundingClientRect().bottom>r+.5;t.toggleAttribute(`data-clip`,n),n&&!t.matches(`h3`)&&i++}t.current&&(t.current.dataset.more=i?`+${i}`:``)},i=new ResizeObserver(r);i.observe(n);let a=new MutationObserver(r);return a.observe(n,{childList:!0,subtree:!0}),r(),()=>{i.disconnect(),a.disconnect()}},[e,t])}function Dd({lm:e}){let{ev:t,model:n}=e,r=Math.max(1.5,n.thresholds.full*1.5),i=e=>`${e/r*100}%`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`Where it runs out`}),(0,Y.jsx)(`div`,{className:`lm-mini-limits`,children:t.ranked.map(e=>(0,Y.jsxs)(`div`,{className:`lm-mini-lim`,"data-component":e.id,children:[(0,Y.jsxs)(`span`,{className:`lm-name`,title:e.name,children:[e.name,e.capacity?.provenance===`estimated`?(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`estimated`,children:`est`}):!!e.capacity?.within&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`range`,children:`±`})]}),(0,Y.jsxs)(`span`,{className:`lm-track`,role:`img`,"aria-label":`${e.name} at ${e.util==null?`off`:f(e.util)}`,children:[(0,Y.jsx)(`span`,{className:`lm-fill`,"data-state":e.state,style:{width:`${Math.min(100,(e.util??0)/r*100)}%`}}),(0,Y.jsx)(`span`,{className:`lm-tick`,style:{left:i(n.thresholds.target)}}),(0,Y.jsx)(`span`,{className:`lm-tick`,style:{left:i(n.thresholds.full)}})]}),(0,Y.jsx)(`span`,{className:`lm-val`,children:e.util==null?`—`:f(e.util)}),(0,Y.jsx)(`span`,{className:`lm-val lm-sub`,children:e.util==null?`off`:e.full!=null&&!Number.isFinite(e.full)?`full > ${s(n.searchMax)}×`:`full ${e.fullRange?u(e.fullRange,n.searchMax,!0):l(e.full,n.searchMax)}`})]},e.id))})]})}function Od({lm:e}){let{model:t,values:n}=e,r=Wu(e),[i,{width:a,height:o}]=Uu(240),s=Math.max(1.5,t.thresholds.full*1.5),c=e=>a*Math.log(e/r.from)/Math.log(r.to/r.from),d=e=>8+(o-10)*(1-Math.min(e,s*1.2)/s),p=e=>{let t=``,n=!1;for(let[r,i]of e)i==null?n=!1:(t+=`${n?`L`:`M`}${c(r).toFixed(1)} ${d(i).toFixed(1)}`,n=!0);return t},m=r.lines.find(e=>e.selected)??r.lines[0],h=f(t.thresholds.target),g=m?`${m.targetRange?u(m.targetRange,t.searchMax,!0):l(m.target,t.searchMax)}`:``,_=m?Ru(t,m.targetRange):``,v=c(Math.min(r.to,Math.max(r.from,n.load)));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`lm-spark`,ref:i,children:o>0&&(0,Y.jsxs)(`svg`,{width:a,height:o,"aria-hidden":`true`,children:[(0,Y.jsx)(`line`,{className:`lm-spark-th`,x1:0,x2:a,y1:d(t.thresholds.target),y2:d(t.thresholds.target)}),r.lines.map(e=>(0,Y.jsx)(`path`,{d:p(e.envelope),fill:`none`,stroke:Fu(t,e.label),strokeWidth:e.selected?2:1.25},e.label??``)),(0,Y.jsx)(`line`,{className:`lm-spark-load`,x1:v,x2:v,y1:0,y2:o})]})}),m&&(0,Y.jsxs)(`p`,{className:`lm-spark-text`,title:`${m.label??`It`} reaches the ${h} target at ${g}`,children:[m.label??`It`,` reaches the `,h,` target at `,g,_&&` (${_})`,`.`]})]})}function kd({lm:e}){let t=(0,J.useRef)(null),{story:n}=e.model;if(!n.length)return null;let r=e.cue?.step??e.step,i=n.length-1,a=t=>{let n=Math.max(0,Math.min(i,t));(n!==r||e.storyPlaying)&&e.setStep(n)},o=e=>{if(e.key===`ArrowRight`)a(r==null?0:r+1);else if(e.key===`ArrowLeft`&&r!=null)a(r-1);else return;e.preventDefault()},s=e.storyPlaying;return(0,Y.jsxs)(`fieldset`,{className:`lm-story`,onKeyDown:o,ref:t,tabIndex:-1,"data-playing":s||void 0,children:[(0,Y.jsx)(`legend`,{children:`Story`}),(0,Y.jsx)(`span`,{className:`lm-sr`,"aria-live":`polite`,children:r==null?`A walk through this model in ${n.length} steps.`:`${r+1} of ${n.length}. ${n[r].text}${e.stepChanged?` You changed the values since.`:``}`}),(0,Y.jsxs)(`p`,{"aria-hidden":`true`,children:[(0,Y.jsxs)(`span`,{"data-shown":r==null||void 0,children:[`A walk through this model in `,n.length,` steps.`]}),n.map((t,i)=>(0,Y.jsxs)(`span`,{"data-shown":i===r||void 0,children:[(0,Y.jsxs)(`b`,{children:[i+1,` of `,n.length]}),` `,t.text,(0,Y.jsx)(`em`,{"data-shown":i===r&&e.stepChanged||void 0,children:` You changed the values since.`})]},i))]}),r!=null&&(0,Y.jsx)(`span`,{className:`lm-story-progress`,"aria-hidden":`true`,children:n.map((t,n)=>(0,Y.jsx)(`i`,{"data-state":n<r?`done`:n===r?`now`:void 0,style:n===r?{"--lm-step":`${vu(t,e.engine.transition)}s`}:void 0},n===r?`${n}-${s}`:n))}),(0,Y.jsxs)(`span`,{className:`lm-story-nav`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>e.setStoryPlaying(!s),"aria-pressed":s,children:s?`❚❚ Pause`:`▶ Play`}),r!=null&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(r-1),"aria-disabled":r===0,children:`Back`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(r==null?0:r+1),"aria-disabled":r===i,children:r==null?`Start`:`Next`}),r!=null&&e.stepChanged&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{e.setStep(r),t.current?.focus()},children:`Show again`}),r!=null&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>e.setStep(null),"aria-label":`Leave the story`,children:`Done`})]})]})}var Ad=`
|
|
16
|
+
`)[0]}`:void 0}function wn(e){let t=Object.entries(Nt).filter(([,t])=>t.children.includes(e)).map(([e])=>e===``?`the top level`:e);return t.length?`it goes in ${t.join(` or `)}`:void 0}var Tn=t((e=>{var t=Object.defineProperty;(e=>t(e,`__esModule`,{value:!0}))(e),((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(e,{GIFEncoder:()=>k,applyPalette:()=>S,default:()=>ce,nearestColor:()=>ee,nearestColorIndex:()=>D,nearestColorIndexWithDistance:()=>O,prequantize:()=>x,quantize:()=>_,snapColorsToPalette:()=>T});var n={signature:`GIF`,version:`89a`,trailer:59,extensionIntroducer:33,applicationExtensionLabel:255,graphicControlExtensionLabel:249,imageSeparator:44,signatureSize:3,versionSize:3,globalColorTableFlagMask:128,colorResolutionMask:112,sortFlagMask:8,globalColorTableSizeMask:7,applicationIdentifierSize:8,applicationAuthCodeSize:3,disposalMethodMask:28,userInputFlagMask:2,transparentColorFlagMask:1,localColorTableFlagMask:128,interlaceFlagMask:64,idSortFlagMask:32,localColorTableSizeMask:7};function r(e=256){let t=0,n=new Uint8Array(e);return{get buffer(){return n.buffer},reset(){t=0},bytesView(){return n.subarray(0,t)},bytes(){return n.slice(0,t)},writeByte(e){r(t+1),n[t]=e,t++},writeBytes(e,i=0,a=e.length){r(t+a);for(let r=0;r<a;r++)n[t++]=e[r+i]},writeBytesView(e,i=0,a=e.byteLength){r(t+a),n.set(e.subarray(i,i+a),t),t+=a}};function r(e){var r=n.length;if(r>=e)return;e=Math.max(e,r*(r<1048576?2:1.125)>>>0),r!=0&&(e=Math.max(e,256));let i=n;n=new Uint8Array(e),t>0&&n.set(i.subarray(0,t),0)}}var i=12,a=5003,o=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function s(e,t,n,s,c=r(512),l=new Uint8Array(256),u=new Int32Array(a),d=new Int32Array(a)){let f=u.length,p=Math.max(2,s);l.fill(0),d.fill(0),u.fill(-1);let m=0,h=0,g=p+1,_=g,v=!1,y=_,b=(1<<y)-1,x=1<<g-1,S=x+1,C=x+2,w=0,T=n[0],E=0;for(let e=f;e<65536;e*=2)++E;E=8-E,c.writeByte(p),O(x);let D=n.length;for(let e=1;e<D;e++)next_block:{let t=n[e],r=(t<<i)+T,a=t<<E^T;if(u[a]===r){T=d[a];break next_block}let o=a===0?1:f-a;for(;u[a]>=0;)if(a-=o,a<0&&(a+=f),u[a]===r){T=d[a];break next_block}O(T),T=t,C<1<<i?(d[a]=C++,u[a]=r):(u.fill(-1),C=x+2,v=!0,O(x))}return O(T),O(S),c.writeByte(0),c.bytesView();function O(e){for(m&=o[h],h>0?m|=e<<h:m=e,h+=y;h>=8;)l[w++]=m&255,w>=254&&(c.writeByte(w),c.writeBytesView(l,0,w),w=0),m>>=8,h-=8;if((C>b||v)&&(v?(y=_,b=(1<<y)-1,v=!1):(++y,b=y===i?1<<y:(1<<y)-1)),e==S){for(;h>0;)l[w++]=m&255,w>=254&&(c.writeByte(w),c.writeBytesView(l,0,w),w=0),m>>=8,h-=8;w>0&&(c.writeByte(w),c.writeBytesView(l,0,w),w=0)}}}var c=s;function l(e,t,n){return e<<8&63488|t<<2&992|n>>3}function u(e,t,n,r){return e>>4|t&240|(n&240)<<4|(r&240)<<8}function d(e,t,n){return e>>4<<8|t&240|n>>4}function f(e,t,n){return e<t?t:e>n?n:e}function p(e){return e*e}function m(e,t,n){var r=0,i=1e100;let a=e[t],o=a.cnt,s=a.ac,c=a.rc,l=a.gc,u=a.bc;for(var d=a.fw;d!=0;d=e[d].fw){let t=e[d],a=t.cnt,m=o*a/(o+a);if(!(m>=i)){var f=0;n&&(f+=m*p(t.ac-s),f>=i)||(f+=m*p(t.rc-c),f>=i||(f+=m*p(t.gc-l),f>=i||(f+=m*p(t.bc-u),f>=i||(i=f,r=d))))}}a.err=i,a.nn=r}function h(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}function g(e,t){let n=Array(t===`rgb444`?4096:65536),r=e.length;if(t===`rgba4444`)for(let t=0;t<r;++t){let r=e[t],i=r>>24&255,a=r>>16&255,o=r>>8&255,s=r&255,c=u(s,o,a,i),l=c in n?n[c]:n[c]=h();l.rc+=s,l.gc+=o,l.bc+=a,l.ac+=i,l.cnt++}else if(t===`rgb444`)for(let t=0;t<r;++t){let r=e[t],i=r>>16&255,a=r>>8&255,o=r&255,s=d(o,a,i),c=s in n?n[s]:n[s]=h();c.rc+=o,c.gc+=a,c.bc+=i,c.cnt++}else for(let t=0;t<r;++t){let r=e[t],i=r>>16&255,a=r>>8&255,o=r&255,s=l(o,a,i),c=s in n?n[s]:n[s]=h();c.rc+=o,c.gc+=a,c.bc+=i,c.cnt++}return n}function _(e,t,n={}){let{format:r=`rgb565`,clearAlpha:i=!0,clearAlphaColor:a=0,clearAlphaThreshold:o=0,oneBitAlpha:s=!1}=n;if(!e||!e.buffer||!(e instanceof Uint8Array)&&!(e instanceof Uint8ClampedArray))throw Error(`quantize() expected RGBA Uint8Array data`);let c=new Uint32Array(e.buffer),l=n.useSqrt!==!1,u=r===`rgba4444`,d=g(c,r),h=d.length,_=h-1,y=new Uint32Array(h+1);for(var b=0,x=0;x<h;++x){let e=d[x];if(e!=null){var S=1/e.cnt;u&&(e.ac*=S),e.rc*=S,e.gc*=S,e.bc*=S,d[b++]=e}}p(t)/b<.022&&(l=!1);for(var x=0;x<b-1;++x)d[x].fw=x+1,d[x+1].bk=x,l&&(d[x].cnt=Math.sqrt(d[x].cnt));l&&(d[x].cnt=Math.sqrt(d[x].cnt));var C,w,T;for(x=0;x<b;++x){m(d,x,!1);var E=d[x].err;for(w=++y[0];w>1&&(T=w>>1,!(d[C=y[T]].err<=E));w=T)y[w]=C;y[w]=x}var D=b-t;for(x=0;x<D;){for(var O;;){var ee=y[1];if(O=d[ee],O.tm>=O.mtm&&d[O.nn].mtm<=O.tm)break;O.mtm==_?ee=y[1]=y[y[0]--]:(m(d,ee,!1),O.tm=x);var E=d[ee].err;for(w=1;(T=w+w)<=y[0]&&(T<y[0]&&d[y[T]].err>d[y[T+1]].err&&T++,!(E<=d[C=y[T]].err));w=T)y[w]=C;y[w]=ee}var k=d[O.nn],A=O.cnt,te=k.cnt,S=1/(A+te);u&&(O.ac=S*(A*O.ac+te*k.ac)),O.rc=S*(A*O.rc+te*k.rc),O.gc=S*(A*O.gc+te*k.gc),O.bc=S*(A*O.bc+te*k.bc),O.cnt+=k.cnt,O.mtm=++x,d[k.bk].fw=k.fw,d[k.fw].bk=k.bk,k.mtm=_}let ne=[];var re=0;for(x=0;;++re){let e=f(Math.round(d[x].rc),0,255),t=f(Math.round(d[x].gc),0,255),n=f(Math.round(d[x].bc),0,255),r=255;u&&(r=f(Math.round(d[x].ac),0,255),s&&(r=r<=(typeof s==`number`?s:127)?0:255),i&&r<=o&&(e=t=n=a,r=0));let c=u?[e,t,n,r]:[e,t,n];if(v(ne,c)||ne.push(c),(x=d[x].fw)==0)break}return ne}function v(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2],a=r.length>=4&&t.length>=4?r[3]===t[3]:!0;if(i&&a)return!0}return!1}function y(e,t){for(var n=0,r=0;r<e.length;r++){let i=e[r]-t[r];n+=i*i}return n}function b(e,t){return t>1?Math.round(e/t)*t:e}function x(e,{roundRGB:t=5,roundAlpha:n=10,oneBitAlpha:r=null}={}){let i=new Uint32Array(e.buffer);for(let e=0;e<i.length;e++){let a=i[e],o=a>>24&255,s=a>>16&255,c=a>>8&255,l=a&255;o=b(o,n),r&&(o=o<=(typeof r==`number`?r:127)?0:255),l=b(l,t),c=b(c,t),s=b(s,t),i[e]=o<<24|s<<16|c<<8|l}}function S(e,t,n=`rgb565`){if(!e||!e.buffer||!(e instanceof Uint8Array)&&!(e instanceof Uint8ClampedArray))throw Error(`quantize() expected RGBA Uint8Array data`);if(t.length>256)throw Error(`applyPalette() only works with 256 colors or less`);let r=new Uint32Array(e.buffer),i=r.length,a=n===`rgb444`?4096:65536,o=new Uint8Array(i),s=Array(a);if(n===`rgba4444`)for(let e=0;e<i;e++){let n=r[e],i=n>>24&255,a=n>>16&255,c=n>>8&255,l=n&255,d=u(l,c,a,i),f=d in s?s[d]:s[d]=C(l,c,a,i,t);o[e]=f}else{let e=n===`rgb444`?d:l;for(let n=0;n<i;n++){let i=r[n],a=i>>16&255,c=i>>8&255,l=i&255,u=e(l,c,a),d=u in s?s[u]:s[u]=w(l,c,a,t);o[n]=d}}return o}function C(e,t,n,r,i){let a=0,o=1e100;for(let s=0;s<i.length;s++){let c=i[s],l=c[3],u=E(l-r);if(u>o)continue;let d=c[0];if(u+=E(d-e),u>o)continue;let f=c[1];if(u+=E(f-t),u>o)continue;let p=c[2];u+=E(p-n),u>o||(o=u,a=s)}return a}function w(e,t,n,r){let i=0,a=1e100;for(let o=0;o<r.length;o++){let s=r[o],c=s[0],l=E(c-e);if(l>a)continue;let u=s[1];if(l+=E(u-t),l>a)continue;let d=s[2];l+=E(d-n),l>a||(a=l,i=o)}return i}function T(e,t,n=5){if(!e.length||!t.length)return;let r=e.map(e=>e.slice(0,3)),i=n*n,a=e[0].length;for(let n=0;n<t.length;n++){let o=t[n];o=o.length<a?[o[0],o[1],o[2],255]:o.length>a?o.slice(0,3):o.slice();let s=O(r,o.slice(0,3),y),c=s[0],l=s[1];l>0&&l<=i&&(e[c]=o)}}function E(e){return e*e}function D(e,t,n=y){let r=1/0,i=-1;for(let a=0;a<e.length;a++){let o=e[a],s=n(t,o);s<r&&(r=s,i=a)}return i}function O(e,t,n=y){let r=1/0,i=-1;for(let a=0;a<e.length;a++){let o=e[a],s=n(t,o);s<r&&(r=s,i=a)}return[i,r]}function ee(e,t,n=y){return e[D(e,t,n)]}function k(e={}){let{initialCapacity:t=4096,auto:i=!0}=e,a=r(t),o=5003,s=new Uint8Array(256),c=new Int32Array(o),l=new Int32Array(o),u=!1;return{reset(){a.reset(),u=!1},finish(){a.writeByte(n.trailer)},bytes(){return a.bytes()},bytesView(){return a.bytesView()},get buffer(){return a.buffer},get stream(){return a},writeHeader:d,writeFrame(e,t,n,r={}){let{transparent:o=!1,transparentIndex:f=0,delay:p=0,palette:m=null,repeat:h=0,colorDepth:g=8,dispose:_=-1}=r,v=!1;if(i?u||=(v=!0,d(),!0):v=!!r.first,t=Math.max(0,Math.floor(t)),n=Math.max(0,Math.floor(n)),v){if(!m)throw Error(`First frame must include a { palette } option`);te(a,t,n,m,g),re(a,m),h>=0&&ne(a,h)}let y=Math.round(p/10);A(a,_,y,o,f);let b=!!m&&!v;ie(a,t,n,b?m:null),b&&re(a,m),ae(a,e,t,n,g,s,c,l)}};function d(){oe(a,`GIF89a`)}}function A(e,t,n,r,i){e.writeByte(33),e.writeByte(249),e.writeByte(4),i<0&&(i=0,r=!1);var a,o;r?(a=1,o=2):(a=0,o=0),t>=0&&(o=t&7),o<<=2,e.writeByte(o|0|a),j(e,n),e.writeByte(i||0),e.writeByte(0)}function te(e,t,n,r,i=8){let a=se(r.length)-1,o=i-1<<4|128|a;j(e,t),j(e,n),e.writeBytes([o,0,0])}function ne(e,t){e.writeByte(33),e.writeByte(255),e.writeByte(11),oe(e,`NETSCAPE2.0`),e.writeByte(3),e.writeByte(1),j(e,t),e.writeByte(0)}function re(e,t){let n=1<<se(t.length);for(let r=0;r<n;r++){let n=[0,0,0];r<t.length&&(n=t[r]),e.writeByte(n[0]),e.writeByte(n[1]),e.writeByte(n[2])}}function ie(e,t,n,r){if(e.writeByte(44),j(e,0),j(e,0),j(e,t),j(e,n),r){let t=se(r.length)-1;e.writeByte(128|t)}else e.writeByte(0)}function ae(e,t,n,r,i=8,a,o,s){c(n,r,t,i,e,a,o,s)}function j(e,t){e.writeByte(t&255),e.writeByte(t>>8&255)}function oe(e,t){for(var n=0;n<t.length;n++)e.writeByte(t.charCodeAt(n))}function se(e){return Math.max(Math.ceil(Math.log2(e)),1)}var ce=k}));function F(e){if(!e)throw Error(`Assertion failed.`)}var En=Math.PI/180,Dn=180/Math.PI,On=e=>{let t=(e%360+360)%360;if(t===0||t===90||t===180||t===270)return t;throw Error(`Invalid rotation ${e}.`)},kn=[1,0,0,0,1,0,0,0,1],An=(e,t,n)=>{let[r,i,,a,o]=e,s=Math.abs(r)*t+Math.abs(a)*n,c=Math.abs(i)*t+Math.abs(o)*n;return In(In(Pn(-t/2,-n/2),e),Pn(s/2,c/2))},jn=e=>{let[t,n]=e;return On(cr(Math.atan2(n,Mn(e)?-t:t)*Dn,90))},Mn=e=>{let[t,n,,r,i]=e;return t*i-n*r<0},Nn=e=>{let t=e*En,n=Math.round(Math.cos(t)),r=Math.round(Math.sin(t));return[n,r,0,-r,n,0,0,0,1]},Pn=(e,t)=>[1,0,0,0,1,0,e,t,1],Fn=(e,t)=>[e,0,0,0,t,0,0,0,1],In=(e,t)=>{let n=Array(9);for(let r=0;r<3;r++)for(let i=0;i<3;i++)n[3*r+i]=e[3*r]*t[i]+e[3*r+1]*t[3+i]+e[3*r+2]*t[6+i];return n},Ln=(e,t,n,r)=>({rotation:On(e+(t?-n:n)),flip:t!==r}),Rn=e=>e&&e[e.length-1],zn=e=>e>=0&&e<2**32,Bn=e=>e>=-(2**31)&&e<2**31,I=e=>{let t=0;for(;e.readBits(1)===0&&t<32;)t++;if(t>=32)throw Error(`Invalid exponential-Golomb code.`);return 2**t-1+e.readBits(t)},Vn=e=>{let t=I(e);return t%2==0?-(t/2):(t+1)/2},Hn=(e,t,n,r)=>{for(let i=t;i<n;i++){let t=Math.floor(i/8),a=e[t],o=7-(i&7);a&=~(1<<o),a|=(r&1<<n-i-1)>>n-i-1<<o,e[t]=a}},Un=e=>e.constructor===Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),Wn=e=>e.constructor===DataView?e:ArrayBuffer.isView(e)?new DataView(e.buffer,e.byteOffset,e.byteLength):new DataView(e),Gn=globalThis.TextEncoder===void 0?class{constructor(){this.encoding=`utf-8`}encode(e=``){let t=new Uint8Array(3*e.length),n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i<128)t[n++]=i;else if(i<2048)t[n++]=192|i>>6,t[n++]=128|i&63;else if(i<55296||i>57343)t[n++]=224|i>>12,t[n++]=128|i>>6&63,t[n++]=128|i&63;else{let a=r+1<e.length?e.charCodeAt(r+1):0;i<56320&&a>=56320&&a<=57343?(i=65536+(i-55296<<10)+(a-56320),r++,t[n++]=240|i>>18,t[n++]=128|i>>12&63,t[n++]=128|i>>6&63,t[n++]=128|i&63):(t[n++]=239,t[n++]=191,t[n++]=189)}}return t.slice(0,n)}}:globalThis.TextEncoder;globalThis.TextDecoder===void 0||globalThis.TextDecoder;var Kn=new Gn,qn={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},Jn={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},Yn={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},Xn=e=>!e||e.primaries==null&&e.transfer==null&&e.matrix==null&&e.fullRange==null,Zn=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e),Qn=class{constructor(){this.currentPromise=Promise.resolve(),this.pending=0}async acquire(){let e,t=new Promise(t=>{let n=!1;e=()=>{n||=(t(),this.pending--,!0)}}),n=this.currentPromise;return this.currentPromise=t,this.pending++,await n,e}},$n=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``),er=e=>(e=e>>1&1431655765|(e&1431655765)<<1,e=e>>2&858993459|(e&858993459)<<2,e=e>>4&252645135|(e&252645135)<<4,e=e>>8&16711935|(e&16711935)<<8,e=e>>16&65535|(e&65535)<<16,e>>>0),tr=(e,t,n)=>{let r=0,i=e.length-1,a=-1;for(;r<=i;){let o=r+(i-r+1)/2|0;n(e[o])<=t?(a=o,r=o+1):i=o-1}return a},nr=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},rr=e=>{throw Error(`Unexpected value: ${e}`)},ir=(e,t,n)=>{let r=e.getUint8(t),i=e.getUint8(t+1),a=e.getUint8(t+2);return n?r|i<<8|a<<16:r<<16|i<<8|a},ar=(e,t,n,r)=>{n>>>=0,n&=16777215,r?(e.setUint8(t,n&255),e.setUint8(t+1,n>>>8&255),e.setUint8(t+2,n>>>16&255)):(e.setUint8(t,n>>>16&255),e.setUint8(t+1,n>>>8&255),e.setUint8(t+2,n&255))},or=(e,t,n)=>Math.max(t,Math.min(n,e)),sr=(e,t,n)=>e+(t-e)*n,cr=(e,t)=>Math.round(e/t)*t,lr=(e,t)=>Math.round(e*t)/t,ur=(e,t)=>Math.floor(e*t)/t,dr=e=>{let t=0;for(;e!==0;)e&=e-1,t++;return t},fr=/^[a-z]{3}$/,pr=e=>fr.test(e),mr=1e6*(1+2**-52),hr=(e,t)=>{let n=e<0?-1:1;e=Math.abs(e);let r=0,i=1,a=1,o=0,s=e;for(;;){let e=Math.floor(s),c=e*a+r,l=e*o+i;if(l>t)return{num:n*a,den:o};if(r=a,i=o,a=c,o=l,s=1/(s-e),!isFinite(s))break}return{num:n*a,den:o}},gr=class{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}},_r=null,vr=()=>_r===null?_r=!!(typeof navigator<`u`&&(navigator.vendor?.match(/apple/i)||/AppleWebKit/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent))):_r,yr=null,br=()=>yr===null?yr=typeof navigator<`u`&&navigator.userAgent?.includes(`Firefox`):yr,xr=null,Sr=()=>xr===null?xr=!(typeof navigator>`u`||!navigator.vendor?.includes(`Google Inc`)&&!/Chrome/.test(navigator.userAgent)):xr,Cr=null,wr=()=>{if(Cr!==null)return Cr;if(typeof navigator>`u`)return null;let e=/\bChrome\/(\d+)/.exec(navigator.userAgent);return e?Cr=Number(e[1]):null},Tr=e=>globalThis.isSecureContext!==void 0&&!globalThis.isSecureContext?`${e} is not available in this environment; this may be because this page is running in an insecure context. Try serving your page over HTTPS or use localhost.`:`${e} is not available in this environment.`,Er=e=>e instanceof DOMException&&e.name===`QuotaExceededError`&&/reclaimed/i.test(e.message),Dr=(async()=>{})().constructor,Or=e=>e instanceof Dr||e instanceof Promise||typeof e?.then==`function`,kr=function*(e){for(let t in e){let n=e[t];n!==void 0&&(yield{key:t,value:n})}},Ar=e=>{switch(e.toLowerCase()){case`image/jpeg`:case`image/jpg`:return`.jpg`;case`image/png`:return`.png`;case`image/gif`:return`.gif`;case`image/webp`:return`.webp`;case`image/bmp`:return`.bmp`;case`image/svg+xml`:return`.svg`;case`image/tiff`:return`.tiff`;case`image/avif`:return`.avif`;case`image/x-icon`:case`image/vnd.microsoft.icon`:return`.ico`;default:return null}},jr=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Mr=()=>{Symbol.dispose??=Symbol(`Symbol.dispose`)},Nr=e=>typeof e==`number`&&!Number.isNaN(e),Pr=(e,t)=>{let n=-1,r=1/0;for(let i=0;i<e.length;i++){let a=t(e[i]);(n===-1||a<r)&&(r=a,n=i)}return n},Fr=e=>{F(Number.isInteger(e.num)),F(Number.isInteger(e.den)),F(e.den!==0);let t=Math.abs(e.num),n=Math.abs(e.den);for(;n!==0;){let e=t%n;t=n,n=e}let r=t||1;return{num:e.num/r,den:e.den/r}},Ir=(e,t)=>{if(typeof e!=`object`||!e)throw TypeError(`${t} must be an object.`);if(!Number.isInteger(e.left)||e.left<0)throw TypeError(`${t}.left must be a non-negative integer.`);if(!Number.isInteger(e.top)||e.top<0)throw TypeError(`${t}.top must be a non-negative integer.`);if(!Number.isInteger(e.width)||e.width<0)throw TypeError(`${t}.width must be a non-negative integer.`);if(!Number.isInteger(e.height)||e.height<0)throw TypeError(`${t}.height must be a non-negative integer.`)},Lr=e=>new Promise(t=>setTimeout(t,e)),Rr=e=>Array.isArray(e)?e:[e],zr=class{constructor(){this._listeners=new Map}on(e,t,n){this._listeners.has(e)||this._listeners.set(e,new Set);let r={fn:t,once:n?.once??!1};return this._listeners.get(e).add(r),()=>{this._listeners.get(e)?.delete(r)}}_emit(...e){let[t,n]=e,r=this._listeners.get(t);if(r)for(let e of r){try{e.fn(n)}catch(e){console.error(e)}e.once&&r.delete(e)}}},Br=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(e=>typeof e==`string`),Vr;(function(e){e[e.Silent=0]=`Silent`,e[e.Errors=1]=`Errors`,e[e.Warnings=2]=`Warnings`,e[e.Info=3]=`Info`})(Vr||={});var Hr=class e{constructor(){}static get level(){return e._level}static set level(t){if(t!==Vr.Silent&&t!==Vr.Errors&&t!==Vr.Warnings&&t!==Vr.Info)throw TypeError(`Invalid log level. Use one of the values of the LogLevel enum.`);e._level=t}static get _emitter(){return e._emitterInstance??=new zr}static on(t,n,r){return e._emitter.on(t,n,r)}static _error(...t){e._emitter._emit(`error`,t),e._level>=Vr.Errors&&console.error(...t)}static _warn(...t){e._emitter._emit(`warn`,t),e._level>=Vr.Warnings&&console.warn(...t)}static _info(...t){e._emitter._emit(`info`,t),e._level>=Vr.Info&&console.info(...t)}};Hr._level=Vr.Info,Hr._emitterInstance=null;var Ur=class{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(typeof t!=`string`)throw TypeError(`mimeType must be a string.`)}},Wr=class{constructor(e,t,n,r){if(this.data=e,this.mimeType=t,this.name=n,this.description=r,!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(t!==void 0&&typeof t!=`string`)throw TypeError(`mimeType, when provided, must be a string.`);if(n!==void 0&&typeof n!=`string`)throw TypeError(`name, when provided, must be a string.`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`description, when provided, must be a string.`)}},Gr=e=>{if(!e||typeof e!=`object`)throw TypeError(`tags must be an object.`);if(e.title!==void 0&&typeof e.title!=`string`)throw TypeError(`tags.title, when provided, must be a string.`);if(e.description!==void 0&&typeof e.description!=`string`)throw TypeError(`tags.description, when provided, must be a string.`);if(e.artist!==void 0&&typeof e.artist!=`string`)throw TypeError(`tags.artist, when provided, must be a string.`);if(e.album!==void 0&&typeof e.album!=`string`)throw TypeError(`tags.album, when provided, must be a string.`);if(e.albumArtist!==void 0&&typeof e.albumArtist!=`string`)throw TypeError(`tags.albumArtist, when provided, must be a string.`);if(e.trackNumber!==void 0&&(!Number.isInteger(e.trackNumber)||e.trackNumber<=0))throw TypeError(`tags.trackNumber, when provided, must be a positive integer.`);if(e.tracksTotal!==void 0&&(!Number.isInteger(e.tracksTotal)||e.tracksTotal<=0))throw TypeError(`tags.tracksTotal, when provided, must be a positive integer.`);if(e.discNumber!==void 0&&(!Number.isInteger(e.discNumber)||e.discNumber<=0))throw TypeError(`tags.discNumber, when provided, must be a positive integer.`);if(e.discsTotal!==void 0&&(!Number.isInteger(e.discsTotal)||e.discsTotal<=0))throw TypeError(`tags.discsTotal, when provided, must be a positive integer.`);if(e.genre!==void 0&&typeof e.genre!=`string`)throw TypeError(`tags.genre, when provided, must be a string.`);if(e.date!==void 0&&(!(e.date instanceof Date)||Number.isNaN(e.date.getTime())))throw TypeError(`tags.date, when provided, must be a valid Date.`);if(e.creationTime!==void 0&&e.creationTime!==null&&(!(e.creationTime instanceof Date)||Number.isNaN(e.creationTime.getTime())))throw TypeError(`tags.creationTime, when provided, must be a valid Date or null.`);if(e.beatsPerMinute!==void 0&&(!Number.isInteger(e.beatsPerMinute)||e.beatsPerMinute<=0))throw TypeError(`tags.beatsPerMinute, when provided, must be a positive integer.`);if(e.lyrics!==void 0&&typeof e.lyrics!=`string`)throw TypeError(`tags.lyrics, when provided, must be a string.`);if(e.images!==void 0){if(!Array.isArray(e.images))throw TypeError(`tags.images, when provided, must be an array.`);for(let t of e.images){if(!t||typeof t!=`object`)throw TypeError(`Each image in tags.images must be an object.`);if(!(t.data instanceof Uint8Array))throw TypeError(`Each image.data must be a Uint8Array.`);if(typeof t.mimeType!=`string`)throw TypeError(`Each image.mimeType must be a string.`);if(![`coverFront`,`coverBack`,`unknown`].includes(t.kind))throw TypeError(`Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.`)}}if(e.comment!==void 0&&typeof e.comment!=`string`)throw TypeError(`tags.comment, when provided, must be a string.`);if(e.raw!==void 0){if(!e.raw||typeof e.raw!=`object`)throw TypeError(`tags.raw, when provided, must be an object.`);for(let t of Object.values(e.raw))if(t!==null&&typeof t!=`string`&&!(Array.isArray(t)&&t.every(e=>typeof e==`string`))&&!(t instanceof Uint8Array)&&!(Array.isArray(t)&&t.every(e=>e instanceof Uint8Array))&&!(t instanceof Ur)&&!(t instanceof Wr)&&!Br(t))throw TypeError(`Each value in tags.raw must be a string, string array, Uint8Array, Uint8Array array, RichImageData, AttachedFile, Record<string, string>, or null.`)}},Kr=e=>{if(!e||typeof e!=`object`)throw TypeError(`disposition must be an object.`);if(e.default!==void 0&&typeof e.default!=`boolean`)throw TypeError(`disposition.default must be a boolean.`);if(e.primary!==void 0&&typeof e.primary!=`boolean`)throw TypeError(`disposition.primary must be a boolean.`);if(e.forced!==void 0&&typeof e.forced!=`boolean`)throw TypeError(`disposition.forced must be a boolean.`);if(e.original!==void 0&&typeof e.original!=`boolean`)throw TypeError(`disposition.original must be a boolean.`);if(e.commentary!==void 0&&typeof e.commentary!=`boolean`)throw TypeError(`disposition.commentary must be a boolean.`);if(e.hearingImpaired!==void 0&&typeof e.hearingImpaired!=`boolean`)throw TypeError(`disposition.hearingImpaired must be a boolean.`);if(e.visuallyImpaired!==void 0&&typeof e.visuallyImpaired!=`boolean`)throw TypeError(`disposition.visuallyImpaired must be a boolean.`)},qr=class e{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){let e=Math.floor(this.pos/8),t=this.bytes[e]??0,n=7-(this.pos&7),r=(t&1<<n)>>n;return this.pos++,r}readBits(e){if(e===1)return this.readBit();let t=0;for(let n=0;n<e;n++)t<<=1,t|=this.readBit();return t}writeBits(e,t){let n=this.pos+e;for(let e=this.pos;e<n;e++){let r=Math.floor(e/8),i=this.bytes[r],a=7-(e&7);i&=~(1<<a),i|=(t&1<<n-e-1)>>n-e-1<<a,this.bytes[r]=i}this.pos=n}copyBits(e,t){let n=0;for(;n<e-7;n+=8)this.writeBits(8,t.readBits(8));let r=e-n;r>0&&this.writeBits(r,t.readBits(r))}readAlignedByte(){if(this.pos%8!=0)throw Error(`Bitstream is not byte-aligned.`);let e=this.pos/8,t=this.bytes[e]??0;return this.pos+=8,t}skipBits(e){this.pos+=e}getBitsLeft(){return this.bytes.length*8-this.pos}clone(){let t=new e(this.bytes);return t.pos=this.pos,t}},Jr=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Yr=[-1,1,2,3,4,5,6,8],Xr=[1,2,3,4,6,7,17,19,20,21,22],Zr=e=>{if(!e||e.byteLength<2)throw TypeError(`AAC description must be at least 2 bytes long.`);let t=new qr(e),n=Qr(t),{frequencyIndex:r,sampleRate:i}=$r(t),a=t.readBits(4),o=null;a>=1&&a<=7&&(o=Yr[a]);let s=n,c=!1,l=i;(n===5||n===29)&&(c=n===29,l=$r(t).sampleRate,s=Qr(t),s===22&&t.skipBits(4));let u=1024;if(Xr.includes(s)&&(u=t.readBits(1)?960:1024),n!==5&&n!==29)for(;t.getBitsLeft()>15;){let e=t.pos;if(t.readBits(11)!==695)t.pos=e+1;else{Qr(t)===5&&t.readBits(1)&&(l=$r(t).sampleRate,t.getBitsLeft()>11&&t.readBits(11)===1352&&(c=!!t.readBits(1)));break}}return o!==null&&o>1&&(c=!1),{objectType:n,coreObjectType:s,frequencyIndex:r,channelConfiguration:a,coreSampleRate:i,outputSampleRate:l,outputNumberOfChannels:c&&o===1?2:o,frameLength:u}},Qr=e=>{let t=e.readBits(5);return t===31?32+e.readBits(6):t},$r=e=>{let t=e.readBits(4);return t===15?{frequencyIndex:t,sampleRate:e.readBits(24)}:{frequencyIndex:t,sampleRate:t<Jr.length?Jr[t]:null}},ei=e=>{let t=e.objectType===5||e.objectType===29,n=e.objectType===29,r=t?e.outputSampleRate/2:e.outputSampleRate,i=n?1:e.outputNumberOfChannels,a=Yr.indexOf(i);if(a===-1)throw TypeError(`Unsupported number of channels: ${e.outputNumberOfChannels}`);let o=16;e.objectType>=32&&(o+=6),ri(r)===15&&(o+=24),t&&(o+=9,ri(e.outputSampleRate)===15&&(o+=24));let s=Math.ceil(o/8),c=new Uint8Array(s),l=new qr(c);return ti(l,e.objectType),ni(l,r),l.writeBits(4,a),t&&(ni(l,e.outputSampleRate),ti(l,2)),l.writeBits(3,0),c},ti=(e,t)=>{t<32?e.writeBits(5,t):(e.writeBits(5,31),e.writeBits(6,t-32))},ni=(e,t)=>{let n=ri(t);e.writeBits(4,n),n===15&&e.writeBits(24,t)},ri=e=>{let t=Jr.indexOf(e);return t===-1?15:t},ii=[48e3,44100,32e3],ai=[24e3,22050,16e3],oi=`Mediabunny v1.65.0`,si;(function(e){e[e.NON_IDR_SLICE=1]=`NON_IDR_SLICE`,e[e.SLICE_DPA=2]=`SLICE_DPA`,e[e.SLICE_DPB=3]=`SLICE_DPB`,e[e.SLICE_DPC=4]=`SLICE_DPC`,e[e.IDR=5]=`IDR`,e[e.SEI=6]=`SEI`,e[e.SPS=7]=`SPS`,e[e.PPS=8]=`PPS`,e[e.AUD=9]=`AUD`,e[e.SPS_EXT=13]=`SPS_EXT`})(si||={});var ci;(function(e){e[e.RASL_N=8]=`RASL_N`,e[e.RASL_R=9]=`RASL_R`,e[e.BLA_W_LP=16]=`BLA_W_LP`,e[e.RSV_IRAP_VCL23=23]=`RSV_IRAP_VCL23`,e[e.VPS_NUT=32]=`VPS_NUT`,e[e.SPS_NUT=33]=`SPS_NUT`,e[e.PPS_NUT=34]=`PPS_NUT`,e[e.AUD_NUT=35]=`AUD_NUT`,e[e.PREFIX_SEI_NUT=39]=`PREFIX_SEI_NUT`,e[e.SUFFIX_SEI_NUT=40]=`SUFFIX_SEI_NUT`})(ci||={});var li=function*(e){let t=0,n=-1;for(;t<e.length-2;){let r=e.indexOf(0,t);if(r===-1||r>=e.length-2)break;t=r;let i=0;t+3<e.length&&e[t+1]===0&&e[t+2]===0&&e[t+3]===1?i=4:e[t+1]===0&&e[t+2]===1&&(i=3),i===0?t++:(n!==-1&&t>n&&(yield{offset:n,length:t-n}),n=t+i,t=n)}n!==-1&&n<e.length&&(yield{offset:n,length:e.length-n})},ui=function*(e,t){let n=0,r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;n+t<=e.length;){let e;t===1?e=r.getUint8(n):t===2?e=r.getUint16(n,!1):t===3?e=ir(r,n,!1):(F(t===4),e=r.getUint32(n,!1)),n+=t,yield{offset:n,length:e},n+=e}},di=(e,t)=>t.description?ui(e,(Un(t.description)[4]&3)+1):li(e),fi=e=>e&31,pi=e=>{let t=new Uint8Array(e.length),n=e.length,r=0;for(let i=0;i<n;i++)i+2<n&&e[i]===0&&e[i+1]===0&&e[i+2]===3?(t[r++]=0,t[r++]=0,i+=2):t[r++]=e[i];return t.subarray(0,r)};new Uint8Array([0,0,0,1]);var mi=(e,t)=>{let n=e.reduce((e,n)=>e+t+n.byteLength,0),r=new Uint8Array(n),i=0;for(let n of e){let e=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(t){case 1:e.setUint8(i,n.byteLength);break;case 2:e.setUint16(i,n.byteLength,!1);break;case 3:ar(e,i,n.byteLength,!1);break;case 4:e.setUint32(i,n.byteLength,!1)}i+=t,r.set(n,i),i+=n.byteLength}return r},hi=e=>{try{let t=[],n=[],r=[];for(let i of li(e)){let a=e.subarray(i.offset,i.offset+i.length),o=fi(a[0]);o===si.SPS&&t.length<31?t.push(a):o===si.PPS&&n.length<255?n.push(a):o===si.SPS_EXT&&r.length<255&&r.push(a)}if(t.length===0||n.length===0)return null;let i=t[0],a=yi(i);if(!a)return null;let o=a.profileIdc===100||a.profileIdc===110||a.profileIdc===122||a.profileIdc===144;return{configurationVersion:1,avcProfileIndication:a.profileIdc,profileCompatibility:a.constraintFlags,avcLevelIndication:a.levelIdc,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:n,chromaFormat:o?a.chromaFormatIdc:null,bitDepthLumaMinus8:o?a.bitDepthLumaMinus8:null,bitDepthChromaMinus8:o?a.bitDepthChromaMinus8:null,sequenceParameterSetExt:o?r:null}}catch(e){return Hr._error(`Error building AVC Decoder Configuration Record:`,e),null}},gi=e=>{let t=[];t.push(e.configurationVersion),t.push(e.avcProfileIndication),t.push(e.profileCompatibility),t.push(e.avcLevelIndication),t.push(252|e.lengthSizeMinusOne&3),t.push(224|e.sequenceParameterSets.length&31);for(let n of e.sequenceParameterSets){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}t.push(e.pictureParameterSets.length);for(let n of e.pictureParameterSets){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}if((e.avcProfileIndication===100||e.avcProfileIndication===110||e.avcProfileIndication===122||e.avcProfileIndication===144)&&e.chromaFormat!==null){F(e.bitDepthLumaMinus8!==null),F(e.bitDepthChromaMinus8!==null),F(e.sequenceParameterSetExt!==null),t.push(252|e.chromaFormat&3),t.push(248|e.bitDepthLumaMinus8&7),t.push(248|e.bitDepthChromaMinus8&7),t.push(e.sequenceParameterSetExt.length);for(let n of e.sequenceParameterSetExt){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}}return new Uint8Array(t)},_i=e=>{try{let t=Wn(e),n=0,r=t.getUint8(n++),i=t.getUint8(n++),a=t.getUint8(n++),o=t.getUint8(n++),s=t.getUint8(n++)&3,c=t.getUint8(n++)&31,l=[];for(let r=0;r<c;r++){let r=t.getUint16(n,!1);n+=2,l.push(e.subarray(n,n+r)),n+=r}let u=t.getUint8(n++),d=[];for(let r=0;r<u;r++){let r=t.getUint16(n,!1);n+=2,d.push(e.subarray(n,n+r)),n+=r}let f={configurationVersion:r,avcProfileIndication:i,profileCompatibility:a,avcLevelIndication:o,lengthSizeMinusOne:s,sequenceParameterSets:l,pictureParameterSets:d,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if((i===100||i===110||i===122||i===144)&&n+4<=e.length){let r=t.getUint8(n++)&3,i=t.getUint8(n++)&7,a=t.getUint8(n++)&7,o=t.getUint8(n++);f.chromaFormat=r,f.bitDepthLumaMinus8=i,f.bitDepthChromaMinus8=a;let s=[];for(let r=0;r<o;r++){let r=t.getUint16(n,!1);n+=2,s.push(e.subarray(n,n+r)),n+=r}f.sequenceParameterSetExt=s}return f}catch(e){return Hr._error(`Error deserializing AVC Decoder Configuration Record:`,e),null}},vi={1:{num:1,den:1},2:{num:12,den:11},3:{num:10,den:11},4:{num:16,den:11},5:{num:40,den:33},6:{num:24,den:11},7:{num:20,den:11},8:{num:32,den:11},9:{num:80,den:33},10:{num:18,den:11},11:{num:15,den:11},12:{num:64,den:33},13:{num:160,den:99},14:{num:4,den:3},15:{num:3,den:2},16:{num:2,den:1}},yi=e=>{try{let t=pi(e),n=new qr(t);if(n.skipBits(1),n.skipBits(2),n.readBits(5)!==7)return null;let r=n.readAlignedByte(),i=n.readAlignedByte(),a=n.readAlignedByte();I(n);let o=1,s=0,c=0,l=0;if((r===100||r===110||r===122||r===244||r===44||r===83||r===86||r===118||r===128)&&(o=I(n),o===3&&(l=n.readBits(1)),s=I(n),c=I(n),n.skipBits(1),n.readBits(1))){for(let e=0;e<(o===3?12:8);e++)if(n.readBits(1)){let t=e<6?16:64,r=8,i=8;for(let e=0;e<t;e++){if(i!==0){let e=Vn(n);i=(r+e+256)%256}r=i===0?r:i}}}I(n);let u=I(n);if(u===0)I(n);else if(u===1){n.skipBits(1),Vn(n),Vn(n);let e=I(n);for(let t=0;t<e;t++)Vn(n)}I(n),n.skipBits(1);let d=I(n),f=I(n),p=16*(d+1),m=16*(f+1),h=p,g=m,_=n.readBits(1);if(_||n.skipBits(1),n.skipBits(1),n.readBits(1)){let e=I(n),t=I(n),r=I(n),i=I(n),a,s;if((l===0?o:0)===0)a=1,s=2-_;else{let e=o===3?1:2,t=o===1?2:1;a=e,s=t*(2-_)}h-=a*(e+t),g-=s*(r+i)}if(h<=0||g<=0)return null;let v=2,y=2,b=2,x=0,S={num:1,den:1},C=null,w=null,T=null,E=null,D=n.pos;if(n.readBits(1)){if(n.readBits(1)){let e=n.readBits(8);if(e===255)S={num:n.readBits(16),den:n.readBits(16)};else{let t=vi[e];t&&(S=t)}}n.readBits(1)&&n.skipBits(1),n.readBits(1)&&(n.skipBits(3),x=n.readBits(1),n.readBits(1)&&(v=n.readBits(8),y=n.readBits(8),b=n.readBits(8))),n.readBits(1)&&(I(n),I(n)),n.readBits(1)&&(n.skipBits(32),n.skipBits(32),n.skipBits(1));let e=n.readBits(1);e&&bi(n);let t=n.readBits(1);t&&bi(n),(e||t)&&n.skipBits(1),n.skipBits(1),T=n.pos,E=n.readBits(1),E&&(n.skipBits(1),I(n),I(n),I(n),I(n),C=Math.min(I(n),16),w=Math.min(I(n),16))}if(C===null){F(w===null);let e=i&16;if((r===44||r===86||r===100||r===110||r===122||r===244)&&e)C=0,w=0;else{let e=d+1,t=f+1,n=(2-_)*t,r=Bo.find(e=>e.level>=a)??Rn(Bo),i=Math.min(Math.floor(r.maxDpbMbs/(e*n)),16);C=i,w=i}}return F(w!==null),{emulationUnpreventedBytes:t,profileIdc:r,constraintFlags:i,levelIdc:a,frameMbsOnlyFlag:_,chromaFormatIdc:o,bitDepthLumaMinus8:s,bitDepthChromaMinus8:c,codedWidth:p,codedHeight:m,displayWidth:h,displayHeight:g,pixelAspectRatio:S,colourPrimaries:v,matrixCoefficients:b,transferCharacteristics:y,fullRangeFlag:x,numReorderFrames:C,maxDecFrameBuffering:w,vuiParametersFlagBitOffset:D,bitstreamRestrictionFlagBitOffset:T,bitstreamRestrictionFlag:E}}catch(e){return Hr._error(`Error parsing AVC SPS:`,e),null}},bi=e=>{let t=I(e);e.skipBits(4),e.skipBits(4);for(let n=0;n<=t;n++)I(e),I(e),e.skipBits(1);e.skipBits(5),e.skipBits(5),e.skipBits(5),e.skipBits(5)},xi=(e,t)=>t.description?ui(e,(Un(t.description)[21]&3)+1):li(e),Si=e=>e>>1&63,Ci=e=>{try{let t=new qr(pi(e));t.skipBits(16),t.readBits(4);let n=t.readBits(3),r=t.readBits(1),{general_profile_space:i,general_tier_flag:a,general_profile_idc:o,general_profile_compatibility_flags:s,general_constraint_indicator_flags:c,general_level_idc:l}=Ti(t,n);I(t);let u=I(t),d=0;u===3&&(d=t.readBits(1));let f=I(t),p=I(t),m=f,h=p;if(t.readBits(1)){let e=I(t),n=I(t),r=I(t),i=I(t),a=1,o=1,s=d===0?u:0;s===1?(a=2,o=2):s===2&&(a=2,o=1),m-=(e+n)*a,h-=(r+i)*o}if(m<=0||h<=0)return null;let g=I(t),_=I(t);I(t);let v=t.readBits(1)?0:n,y=0;for(let e=v;e<=n;e++)I(t),y=I(t),I(t);if(I(t),I(t),I(t),I(t),I(t),I(t),t.readBits(1)&&t.readBits(1)&&Ei(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&(t.skipBits(4),t.skipBits(4),I(t),I(t),t.skipBits(1)),Di(t,I(t)),t.readBits(1)){let e=I(t);for(let n=0;n<e;n++)I(t),t.skipBits(1)}t.skipBits(1),t.skipBits(1);let b=2,x=2,S=2,C=0,w=0,T={num:1,den:1};if(t.readBits(1)){let e=ki(t,n);T=e.pixelAspectRatio,b=e.colourPrimaries,x=e.transferCharacteristics,S=e.matrixCoefficients,C=e.fullRangeFlag,w=e.minSpatialSegmentationIdc}return{displayWidth:m,displayHeight:h,pixelAspectRatio:T,colourPrimaries:b,transferCharacteristics:x,matrixCoefficients:S,fullRangeFlag:C,maxDecFrameBuffering:Math.min(y+1,16),spsMaxSubLayersMinus1:n,spsTemporalIdNestingFlag:r,generalProfileSpace:i,generalTierFlag:a,generalProfileIdc:o,generalProfileCompatibilityFlags:s,generalConstraintIndicatorFlags:c,generalLevelIdc:l,chromaFormatIdc:u,bitDepthLumaMinus8:g,bitDepthChromaMinus8:_,minSpatialSegmentationIdc:w}}catch(e){return Hr._error(`Error parsing HEVC SPS:`,e),null}},wi=e=>{try{let t=[],n=[],r=[],i=[],a=65535;for(let o of li(e)){let s=e.subarray(o.offset,o.offset+o.length),c=Si(s[0]);c===ci.VPS_NUT&&t.length<a?t.push(s):c===ci.SPS_NUT&&n.length<a?n.push(s):c===ci.PPS_NUT&&r.length<a?r.push(s):(c===ci.PREFIX_SEI_NUT||c===ci.SUFFIX_SEI_NUT)&&i.length<a&&i.push(s)}if(n.length===0||r.length===0)return null;let o=Ci(n[0]);if(!o)return null;let s=0;if(r.length>0){let e=r[0],t=new qr(pi(e));t.skipBits(16),I(t),I(t),t.skipBits(1),t.skipBits(1),t.skipBits(3),t.skipBits(1),t.skipBits(1),I(t),I(t),Vn(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&I(t),Vn(t),Vn(t),t.skipBits(1),t.skipBits(1),t.skipBits(1),t.skipBits(1);let n=t.readBits(1),i=t.readBits(1);s=!n&&!i?0:n&&!i?2:!n&&i?3:0}let c=[...t.length?[{arrayCompleteness:1,nalUnitType:ci.VPS_NUT,nalUnits:t}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:ci.SPS_NUT,nalUnits:n}]:[],...r.length?[{arrayCompleteness:1,nalUnitType:ci.PPS_NUT,nalUnits:r}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:Si(i[0][0]),nalUnits:i}]:[]];return{configurationVersion:1,generalProfileSpace:o.generalProfileSpace,generalTierFlag:o.generalTierFlag,generalProfileIdc:o.generalProfileIdc,generalProfileCompatibilityFlags:o.generalProfileCompatibilityFlags,generalConstraintIndicatorFlags:o.generalConstraintIndicatorFlags,generalLevelIdc:o.generalLevelIdc,minSpatialSegmentationIdc:o.minSpatialSegmentationIdc,parallelismType:s,chromaFormatIdc:o.chromaFormatIdc,bitDepthLumaMinus8:o.bitDepthLumaMinus8,bitDepthChromaMinus8:o.bitDepthChromaMinus8,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:o.spsMaxSubLayersMinus1+1,temporalIdNested:o.spsTemporalIdNestingFlag,lengthSizeMinusOne:3,arrays:c}}catch(e){return Hr._error(`Error building HEVC Decoder Configuration Record:`,e),null}},Ti=(e,t)=>{let n=e.readBits(2),r=e.readBits(1),i=e.readBits(5),a=0;for(let t=0;t<32;t++)a=a<<1|e.readBits(1);let o=new Uint8Array(6);for(let t=0;t<6;t++)o[t]=e.readBits(8);let s=e.readBits(8),c=[],l=[];for(let n=0;n<t;n++)c.push(e.readBits(1)),l.push(e.readBits(1));if(t>0)for(let n=t;n<8;n++)e.skipBits(2);for(let n=0;n<t;n++)c[n]&&e.skipBits(88),l[n]&&e.skipBits(8);return{general_profile_space:n,general_tier_flag:r,general_profile_idc:i,general_profile_compatibility_flags:a,general_constraint_indicator_flags:o,general_level_idc:s}},Ei=e=>{for(let t=0;t<4;t++)for(let n=0;n<(t===3?2:6);n++)if(!e.readBits(1))I(e);else{let n=Math.min(64,1<<4+(t<<1));t>1&&Vn(e);for(let t=0;t<n;t++)Vn(e)}},Di=(e,t)=>{let n=[];for(let r=0;r<t;r++)n[r]=Oi(e,r,t,n)},Oi=(e,t,n,r)=>{let i=0,a=0,o=0;if(t!==0&&(a=e.readBits(1)),a){o=t===n?t-(I(e)+1):t-1,e.readBits(1),I(e);let a=r[o]??0;for(let t=0;t<=a;t++)e.readBits(1)||e.readBits(1);i=r[o]}else{let t=I(e),n=I(e);for(let n=0;n<t;n++)I(e),e.readBits(1);for(let t=0;t<n;t++)I(e),e.readBits(1);i=t+n}return i},ki=(e,t)=>{let n=2,r=2,i=2,a=0,o=0,s={num:1,den:1};if(e.readBits(1)){let t=e.readBits(8);if(t===255)s={num:e.readBits(16),den:e.readBits(16)};else{let e=vi[t];e&&(s=e)}}return e.readBits(1)&&e.readBits(1),e.readBits(1)&&(e.readBits(3),a=e.readBits(1),e.readBits(1)&&(n=e.readBits(8),r=e.readBits(8),i=e.readBits(8))),e.readBits(1)&&(I(e),I(e)),e.readBits(1),e.readBits(1),e.readBits(1),e.readBits(1)&&(I(e),I(e),I(e),I(e)),e.readBits(1)&&(e.readBits(32),e.readBits(32),e.readBits(1)&&I(e),e.readBits(1)&&Ai(e,!0,t)),e.readBits(1)&&(e.readBits(1),e.readBits(1),e.readBits(1),o=I(e),I(e),I(e),I(e),I(e)),{pixelAspectRatio:s,colourPrimaries:n,transferCharacteristics:r,matrixCoefficients:i,fullRangeFlag:a,minSpatialSegmentationIdc:o}},Ai=(e,t,n)=>{let r=!1,i=!1,a=!1;t&&(r=e.readBits(1)===1,i=e.readBits(1)===1,(r||i)&&(a=e.readBits(1)===1,a&&(e.readBits(8),e.readBits(5),e.readBits(1),e.readBits(5)),e.readBits(4),e.readBits(4),a&&e.readBits(4),e.readBits(5),e.readBits(5),e.readBits(5)));for(let t=0;t<=n;t++){let t=e.readBits(1)===1,n=!0;t||(n=e.readBits(1)===1);let o=!1;n?I(e):o=e.readBits(1)===1;let s=1;o||(s=I(e)+1),r&&ji(e,s,a),i&&ji(e,s,a)}},ji=(e,t,n)=>{for(let r=0;r<t;r++)I(e),I(e),n&&(I(e),I(e)),e.readBits(1)},Mi=e=>{let t=[];t.push(e.configurationVersion),t.push((e.generalProfileSpace&3)<<6|(e.generalTierFlag&1)<<5|e.generalProfileIdc&31),t.push(e.generalProfileCompatibilityFlags>>>24&255),t.push(e.generalProfileCompatibilityFlags>>>16&255),t.push(e.generalProfileCompatibilityFlags>>>8&255),t.push(e.generalProfileCompatibilityFlags&255),t.push(...e.generalConstraintIndicatorFlags),t.push(e.generalLevelIdc&255),t.push(240|e.minSpatialSegmentationIdc>>8&15),t.push(e.minSpatialSegmentationIdc&255),t.push(252|e.parallelismType&3),t.push(252|e.chromaFormatIdc&3),t.push(248|e.bitDepthLumaMinus8&7),t.push(248|e.bitDepthChromaMinus8&7),t.push(e.avgFrameRate>>8&255),t.push(e.avgFrameRate&255),t.push((e.constantFrameRate&3)<<6|(e.numTemporalLayers&7)<<3|(e.temporalIdNested&1)<<2|e.lengthSizeMinusOne&3),t.push(e.arrays.length&255);for(let n of e.arrays){t.push((n.arrayCompleteness&1)<<7|n.nalUnitType&63),t.push(n.nalUnits.length>>8&255),t.push(n.nalUnits.length&255);for(let e of n.nalUnits){t.push(e.length>>8&255),t.push(e.length&255);for(let n=0;n<e.length;n++)t.push(e[n])}}return new Uint8Array(t)},Ni;(function(e){e[e.audAllowed=0]=`audAllowed`,e[e.beforeFirstVcl=1]=`beforeFirstVcl`,e[e.afterFirstVcl=2]=`afterFirstVcl`,e[e.eoBitstreamAllowed=3]=`eoBitstreamAllowed`,e[e.noMoreDataAllowed=4]=`noMoreDataAllowed`})(Ni||={});var Pi={1:{colourPrimaries:5,transferCharacteristics:6,matrixCoefficients:5},2:{colourPrimaries:1,transferCharacteristics:1,matrixCoefficients:1},3:{colourPrimaries:6,transferCharacteristics:6,matrixCoefficients:6},4:{colourPrimaries:7,transferCharacteristics:7,matrixCoefficients:7},5:{colourPrimaries:9,transferCharacteristics:14,matrixCoefficients:9},7:{colourPrimaries:1,transferCharacteristics:13,matrixCoefficients:0}},Fi=e=>{let t=new qr(e);if(t.readBits(2)!==2)return null;let n=t.readBits(1),r=(t.readBits(1)<<1)+n;if(r===3&&t.skipBits(1),t.readBits(1)===1||t.readBits(1)!==0||(t.skipBits(2),t.readBits(24)!==4817730))return null;let i=8;r>=2&&(i=t.readBits(1)?12:10);let a=t.readBits(3),o=0,s=0;if(a!==7){if(s=t.readBits(1),r===1||r===3){let e=t.readBits(1),n=t.readBits(1);o=!e&&!n?3:e&&!n?2:1,t.skipBits(1)}else o=1}else o=3,s=1;let c=t.readBits(16),l=t.readBits(16),u=(c+1)*(l+1),d=Rn(z).level;for(let e of z)if(u<=e.maxPictureSize){d=e.level;break}let f=Pi[a],p=f?.colourPrimaries??2,m=f?.transferCharacteristics??2,h=f?.matrixCoefficients??2;return{profile:r,level:d,bitDepth:i,chromaSubsampling:o,videoFullRangeFlag:s,colourPrimaries:p,transferCharacteristics:m,matrixCoefficients:h}},Ii=function*(e){let t=new qr(e),n=()=>{let e=0;for(let n=0;n<8;n++){let r=t.readAlignedByte();if(e+=(r&127)*2**(n*7),!(r&128))break;if(n===7&&r&128)return null}return e>2**32-1?null:e};for(;t.getBitsLeft()>=8;){t.skipBits(1);let r=t.readBits(4),i=t.readBits(1),a=t.readBits(1);t.skipBits(1),i&&t.skipBits(8);let o;if(a){let e=n();if(e===null)return;o=e}else o=Math.floor(t.getBitsLeft()/8);F(t.pos%8==0),yield{type:r,data:e.subarray(t.pos/8,t.pos/8+o)},t.skipBits(o*8)}},Li=e=>{for(let{type:t,data:n}of Ii(e)){if(t!==1)continue;let e=new qr(n),r=e.readBits(3);e.readBits(1);let i=e.readBits(1),a=0,o=0,s=0;if(i)a=e.readBits(5);else{let t=e.readBits(1),n=0;if(t){if(e.skipBits(32),e.skipBits(32),e.readBits(1)){let t=0;for(;t<32&&!e.readBits(1);)t++;t<32&&e.skipBits(t)}n=e.readBits(1),n&&(s=e.readBits(5),e.skipBits(32),e.skipBits(5),e.skipBits(5))}let r=e.readBits(1),i=e.readBits(5);for(let t=0;t<=i;t++){e.skipBits(12);let i=e.readBits(5);if(t===0&&(a=i),i>7){let n=e.readBits(1);t===0&&(o=n)}if(n&&e.readBits(1)){let t=s+1;e.skipBits(t),e.skipBits(t),e.skipBits(1)}r&&e.readBits(1)&&e.skipBits(4)}}let c=e.readBits(4),l=e.readBits(4),u=c+1;e.skipBits(u);let d=l+1;e.skipBits(d);let f=0;if(f=i?0:e.readBits(1),f&&(e.skipBits(4),e.skipBits(3)),e.skipBits(1),e.skipBits(1),e.skipBits(1),!i){e.skipBits(1),e.skipBits(1),e.skipBits(1),e.skipBits(1);let t=e.readBits(1);t&&(e.skipBits(1),e.skipBits(1));let n=e.readBits(1),r=0;r=n?2:e.readBits(1),r>0&&(e.readBits(1)||e.skipBits(1)),t&&e.skipBits(3)}e.skipBits(1),e.skipBits(1),e.skipBits(1);let p=e.readBits(1),m=8;r===2&&p?m=e.readBits(1)?12:10:r<=2&&(m=p?10:8);let h=0;r!==1&&(h=e.readBits(1));let g=2,_=2,v=2;e.readBits(1)&&(g=e.readBits(8),_=e.readBits(8),v=e.readBits(8));let y=0,b=1,x=1,S=0;return h?y=e.readBits(1):g===1&&_===13&&v===0?(y=1,b=0,x=0):(y=e.readBits(1),r===0?(b=1,x=1):r===1?(b=0,x=0):m===12?(b=e.readBits(1),x=b?e.readBits(1):0):(b=1,x=0),b&&x&&(S=e.readBits(2))),{profile:r,level:a,tier:o,bitDepth:m,monochrome:h,chromaSubsamplingX:b,chromaSubsamplingY:x,chromaSamplePosition:S,videoFullRangeFlag:y,colourPrimaries:g,transferCharacteristics:_,matrixCoefficients:v}}return null},Ri=e=>e.colourPrimaries!==2||e.transferCharacteristics!==2||e.matrixCoefficients!==2,zi=e=>{if(e.byteLength<19)throw Error(`Invalid Opus identification header: too short.`);let t=Wn(e),n=t.getUint8(9),r=t.getUint16(10,!0),i=t.getUint32(12,!0),a=t.getInt16(16,!0),o=t.getUint8(18),s=null;return o&&(s=e.subarray(19,21+n)),{outputChannelCount:n,preSkip:r,inputSampleRate:i,outputGain:a,channelMappingFamily:o,channelMappingTable:s}},Bi=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960],Vi=e=>{let t=e[0]>>3,n=e[0]&3,r;return r=n===0?1:n===1||n===2?2:e[1]&63,{durationInSamples:Bi[t]*r}},Hi=(e,t,n)=>{switch(e){case`avc`:for(let e of di(n,t)){let t=n[e.offset],r=fi(t);if(r>=si.NON_IDR_SLICE&&r<=si.SLICE_DPC)return`delta`;if(r===si.IDR)return`key`;if(r===si.SEI&&!Sr()){let t=pi(n.subarray(e.offset,e.offset+e.length)),r=1;do{let e=0;for(;;){let n=t[r++];if(n===void 0||(e+=n,n<255))break}let n=0;for(;;){let e=t[r++];if(e===void 0||(n+=e,e<255))break}if(e===6){let e=new qr(t);e.pos=8*r;let n=-1;try{n=I(e)}catch{}let i=e.readBits(1);if(n===0&&i===1)return`key`}r+=n}while(r<t.length-1)}}return`delta`;case`hevc`:for(let e of xi(n,t)){let t=Si(n[e.offset]);if(t<ci.BLA_W_LP)return`delta`;if(t<=ci.RSV_IRAP_VCL23)return`key`}return`delta`;case`vp8`:return n[0]&1?`delta`:`key`;case`vp9`:{let e=new qr(n);if(e.readBits(2)!==2)return null;let t=e.readBits(1);return(e.readBits(1)<<1)+t===3&&e.skipBits(1),e.readBits(1)?null:e.readBits(1)===0?`key`:`delta`}case`av1`:{let e=!1;for(let{type:t,data:r}of Ii(n))if(t===1){let t=new qr(r);t.skipBits(4),e=!!t.readBits(1)}else if(t===3||t===6||t===7){if(e)return`key`;let t=new qr(r);return t.readBits(1)?null:t.readBits(2)===0?`key`:`delta`}return null}case`prores`:return`key`;default:rr(e),F(!1)}},Ui=(e,t)=>e===`truehd`?(t.byteLength>=8?Wn(t).getUint32(4):null)===4168249274?`key`:`delta`:`key`,Wi;(function(e){e[e.STREAMINFO=0]=`STREAMINFO`,e[e.VORBIS_COMMENT=4]=`VORBIS_COMMENT`,e[e.PICTURE=6]=`PICTURE`})(Wi||={});var Gi=e=>{if(e.length<7||e[0]!==11||e[1]!==119)return null;let t=new qr(e);t.skipBits(16),t.skipBits(16);let n=t.readBits(2);if(n===3)return null;let r=t.readBits(6),i=t.readBits(5);if(i>8)return null;let a=t.readBits(3),o=t.readBits(3);return o&1&&o!==1&&t.skipBits(2),o&4&&t.skipBits(2),o===2&&t.skipBits(2),{fscod:n,bsid:i,bsmod:a,acmod:o,lfeon:t.readBits(1),bitRateCode:Math.floor(r/2)}};new Uint8Array([5,4,65,67,45,51]),new Uint8Array([5,4,69,65,67,51]);var Ki=[1,2,3,6],qi=e=>{if(e.length<6||e[0]!==11||e[1]!==119)return null;let t=new qr(e);t.skipBits(16);let n=t.readBits(2);if(t.skipBits(3),n!==0&&n!==2)return null;let r=t.readBits(11),i=t.readBits(2),a=0,o;i===3?(a=t.readBits(2),o=3):o=t.readBits(2);let s=t.readBits(3),c=t.readBits(1),l=t.readBits(5);if(l<11||l>16)return null;let u=Ki[o],d;return d=i<3?ii[i]/1e3:ai[a]/1e3,{dataRate:Math.round((r+1)*d/(u*16)),substreams:[{fscod:i,fscod2:a,bsid:l,bsmod:0,acmod:s,lfeon:c,numDepSub:0,chanLoc:0}]}},Ji=8,Yi=[0,8e3,16e3,32e3,0,0,11025,22050,44100,0,0,12e3,24e3,48e3,96e3,192e3],Xi=[32e3,56e3,64e3,96e3,112e3,128e3,192e3,224e3,256e3,32e4,384e3,448e3,512e3,576e3,64e4,768e3,96e4,1024e3,1152e3,128e4,1344e3,1408e3,1411200,1472e3,1536e3,192e4,2048e3,3072e3,384e4,0,0,0],Zi=[16,16,20,20,0,24,24,0],Qi=[1,2,2,2,2,3,3,4,4,5,6,6,6,7,8,8],$i=[1,2,2,2,2,3,18,19,6,7,518,323,83,519,582,535],ea=8,ta=[32e3,44100,48e3,0],na=[8e3,16e3,32e3,64e3,128e3,22050,44100,88200,176400,352800,12e3,24e3,48e3,96e3,192e3,384e3],ra=[512,1024,2048,4096],ia=e=>{let t=L(e),n=Wn(e),r=t?Math.ceil(t.frameSize/4)*4:0,i=null;for(;r+4<=e.length&&n.getUint32(r)===1683496997;){let t=aa(e.subarray(r));if(!t)break;i??=t,r+=t.frameSize}if(t)return{frameSize:i?r:t.frameSize,sampleRate:t.sampleRate,numberOfChannels:t.numberOfChannels,sampleCount:t.sampleCount,channelLayout:t.channelLayout,pcmResolution:t.pcmResolution,bitRate:t.bitRate,core:t,hasExtensions:i!==null};if(!i?.asset)return null;let{asset:a}=i;return{frameSize:r,sampleRate:a.sampleRate,numberOfChannels:a.numberOfChannels,sampleCount:a.sampleCount,channelLayout:a.channelLayout,pcmResolution:a.pcmResolution,bitRate:0,core:null,hasExtensions:!0}},L=e=>{if(e.length<18||e[0]!==127||e[1]!==254||e[2]!==128||e[3]!==1)return null;let t=new qr(e);if(t.skipBits(32),t.skipBits(1),t.readBits(5)!==31)return null;let n=t.readBits(1),r=t.readBits(7)+1;if(r%Ji!==0)return null;let i=t.readBits(14)+1;if(i<96)return null;let a=t.readBits(6);if(a>=Qi.length)return null;let o=Yi[t.readBits(4)];if(o===0)return null;let s=Xi[t.readBits(5)];if(t.readBits(1)!==0)return null;t.skipBits(4),t.skipBits(5);let c=t.readBits(2);if(c===3)return null;t.skipBits(1),n&&t.skipBits(16),t.skipBits(7);let l=Zi[t.readBits(3)];if(l===0)return null;let u=c!==0;return{frameSize:i,sampleRate:o,numberOfChannels:Qi[a]+ +!!u,sampleCount:r*32,channelLayout:$i[a]|(u?ea:0),amode:a,lfePresent:u,bitRate:s,pcmResolution:l}},aa=e=>{if(e.length<10||e[0]!==100||e[1]!==88||e[2]!==32||e[3]!==37)return null;let t=new qr(e);t.skipBits(32),t.skipBits(8);let n=t.readBits(2),r=t.readBits(1),i=8+4*r,a=16+4*r;t.skipBits(i);let o=t.readBits(a)+1,s={frameSize:o,asset:null};if(!t.readBits(1))return s;let c=ta[t.readBits(2)],l=512*(t.readBits(3)+1);t.readBits(1)&&t.skipBits(36);let u=t.readBits(3)+1,d=t.readBits(3)+1,f=[];for(let e=0;e<u;e++)f.push(t.readBits(n+1));for(let e of f)t.skipBits(8*dr(e));if(t.readBits(1)){t.skipBits(2);let e=t.readBits(2)+1<<2,n=t.readBits(2)+1;t.skipBits(n*e)}for(let e=0;e<d;e++)t.skipBits(a);t.skipBits(9),t.skipBits(3),t.readBits(1)&&t.skipBits(4),t.readBits(1)&&t.skipBits(24),t.readBits(1)&&t.skipBits(8*(t.readBits(10)+1));let p=t.readBits(5)+1,m=na[t.readBits(4)],h=t.readBits(8)+1,g=0;if(t.readBits(1)&&(h>2&&t.skipBits(1),h>6&&t.skipBits(1),t.readBits(1))){let e=t.readBits(2)+1<<2;g=t.readBits(e)}return c===0||t.getBitsLeft()<0?s:{frameSize:o,asset:{sampleRate:m,numberOfChannels:h,sampleCount:Math.round(l*m/c),channelLayout:g,pcmResolution:p}}},oa=e=>{let t=new Uint8Array(20),n=Wn(t);n.setUint32(0,e.sampleRate),n.setUint32(4,e.bitRate),n.setUint32(8,e.bitRate),t[12]=e.pcmResolution;let r=e.core&&!e.hasExtensions?1:0,i=new qr(t);return i.seekToByte(13),i.writeBits(2,Math.max(ra.indexOf(e.sampleCount),0)),i.writeBits(5,r),i.writeBits(1,+!!e.core?.lfePresent),i.writeBits(6,e.core?.amode??0),i.writeBits(14,e.core?e.core.frameSize-1:0),i.writeBits(1,0),i.writeBits(3,0),i.writeBits(16,e.channelLayout),i.writeBits(1,0),i.writeBits(1,0),i.writeBits(1,0),i.writeBits(5,0),t},sa=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,ca=/(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})/,la=e=>{let t=ca.exec(e);if(!t)throw Error(`Expected match.`);return 36e5*Number(t[1]||`0`)+6e4*Number(t[2])+1e3*Number(t[3])+Number(t[4])},ua=e=>{let t=Math.floor(e/36e5),n=Math.floor(e%36e5/6e4),r=Math.floor(e%6e4/1e3),i=e%1e3;return t.toString().padStart(2,`0`)+`:`+n.toString().padStart(2,`0`)+`:`+r.toString().padStart(2,`0`)+`.`+i.toString().padStart(3,`0`)},da=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},fa=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});Mr();var pa=-1/0,ma=-1/0,ha=null;typeof FinalizationRegistry<`u`&&(ha=new FinalizationRegistry(e=>{let t=performance.now();e.type===`video`?(t-pa>=1e3&&(Hr._error(`A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them.`),pa=t),typeof VideoFrame<`u`&&e.data instanceof VideoFrame&&e.data.close()):(t-ma>=1e3&&(Hr._error(`An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them.`),ma=t),typeof AudioData<`u`&&e.data instanceof AudioData&&e.data.close())}));var ga=class{constructor(){this._referenceCount=0,this._lastAllocationBuffer=null}},_a=[`I420`,`I420P10`,`I420P12`,`I420A`,`I420AP10`,`I420AP12`,`I422`,`I422P10`,`I422P12`,`I422A`,`I422AP10`,`I422AP12`,`I444`,`I444P10`,`I444P12`,`I444A`,`I444AP10`,`I444AP12`,`NV12`,`RGBA`,`RGBX`,`BGRA`,`BGRX`],va=new Set(_a),ya=class e{get codedWidth(){return this.visibleRect.width}get codedHeight(){return this.visibleRect.height}get displayWidth(){return this.rotation%180==0?this.squarePixelWidth:this.squarePixelHeight}get displayHeight(){return this.rotation%180==0?this.squarePixelHeight:this.squarePixelWidth}get microsecondTimestamp(){return Math.trunc(mr*this.timestamp)}get microsecondDuration(){return Math.trunc(mr*this.duration)}get hasAlpha(){return this.format&&this.format.includes(`A`)}constructor(t,n){if(this._closed=!1,t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer||ArrayBuffer.isView(t)){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.format===void 0||!va.has(n.format))throw TypeError(`init.format must be one of: `+_a.join(`, `));if(!Number.isInteger(n.codedWidth)||n.codedWidth<=0)throw TypeError(`init.codedWidth must be a positive integer.`);if(!Number.isInteger(n.codedHeight)||n.codedHeight<=0)throw TypeError(`init.codedHeight must be a positive integer.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n.flip!==void 0&&typeof n.flip!=`boolean`)throw TypeError(`init.flip, when provided, must be a boolean.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(n.layout!==void 0){if(!Array.isArray(n.layout))throw TypeError(`init.layout, when provided, must be an array.`);for(let e of n.layout){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`Each entry in init.layout must be an object.`);if(!Number.isInteger(e.offset)||e.offset<0)throw TypeError(`plane.offset must be a non-negative integer.`);if(!Number.isInteger(e.stride)||e.stride<0)throw TypeError(`plane.stride must be a non-negative integer.`)}}if(n.visibleRect!==void 0&&Ir(n.visibleRect,`init.visibleRect`),n.displayWidth!==void 0&&(!Number.isInteger(n.displayWidth)||n.displayWidth<=0))throw TypeError(`init.displayWidth, when provided, must be a positive integer.`);if(n.displayHeight!==void 0&&(!Number.isInteger(n.displayHeight)||n.displayHeight<=0))throw TypeError(`init.displayHeight, when provided, must be a positive integer.`);if(n.displayWidth!==void 0!=(n.displayHeight!==void 0))throw TypeError(`init.displayWidth and init.displayHeight must be either both provided or both omitted.`);this.format=n.format,this.rotation=n.rotation??0,this.flip=n.flip??!1,this.timestamp=n.timestamp,this.duration=n.duration??0;let e=n.layout??Aa(n.format,n.codedWidth,n.codedHeight),r=n.colorSpace??null;r===null&&(r=this.format===`RGBA`||this.format===`RGBX`||this.format===`BGRA`||this.format===`BGRX`?{primaries:`bt709`,transfer:`iec61966-2-1`,matrix:`rgb`,fullRange:!0}:{primaries:`bt709`,transfer:`bt709`,matrix:`bt709`,fullRange:!1}),this.visibleRect={left:n.visibleRect?.left??0,top:n.visibleRect?.top??0,width:n.visibleRect?.width??n.codedWidth,height:n.visibleRect?.height??n.codedHeight},n.displayWidth===void 0?(this.squarePixelWidth=this.visibleRect.width,this.squarePixelHeight=this.visibleRect.height):(this.squarePixelWidth=this.rotation%180==0?n.displayWidth:n.displayHeight,this.squarePixelHeight=this.rotation%180==0?n.displayHeight:n.displayWidth),this._data=n._doNotCopy?Un(t):Un(t).slice(),this._layout=e,this.colorSpace=new Ta(r)}else if(typeof VideoFrame<`u`&&t instanceof VideoFrame){if(n?.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n?.flip!==void 0&&typeof n.flip!=`boolean`)throw TypeError(`init.flip, when provided, must be a boolean.`);if(n?.timestamp!==void 0&&!Number.isFinite(n?.timestamp))throw TypeError(`init.timestamp, when provided, must be a number.`);if(n?.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);n?.visibleRect!==void 0&&Ir(n.visibleRect,`init.visibleRect`),this._data=t,this._layout=null,this.format=t.format,this.visibleRect={left:t.visibleRect?.x??0,top:t.visibleRect?.y??0,width:t.visibleRect?.width??t.codedWidth,height:t.visibleRect?.height??t.codedHeight},this.rotation=n?.rotation??0,this.flip=n?.flip??!1,this.squarePixelWidth=t.displayWidth,this.squarePixelHeight=t.displayHeight,this.timestamp=n?.timestamp??t.timestamp/1e6,this.duration=n?.duration??(t.duration??0)/1e6;let{primaries:e,transfer:r,matrix:i,fullRange:a}=t.colorSpace;this.colorSpace=new Ta({primaries:e!==null&&e in qn?e:null,transfer:r!==null&&r in Jn?r:null,matrix:i!==null&&i in Yn?i:null,fullRange:a})}else if(typeof HTMLImageElement<`u`&&t instanceof HTMLImageElement||typeof SVGImageElement<`u`&&t instanceof SVGImageElement||typeof ImageBitmap<`u`&&t instanceof ImageBitmap||typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement||typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n.flip!==void 0&&typeof n.flip!=`boolean`)throw TypeError(`init.flip, when provided, must be a boolean.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(n.visibleRect!==void 0&&Ir(n.visibleRect,`init.visibleRect`),typeof VideoFrame<`u`)return new e(new VideoFrame(t,{timestamp:Math.trunc(n.timestamp*mr),duration:Math.trunc((n.duration??0)*mr)||void 0,visibleRect:n.visibleRect&&{x:n.visibleRect.left,y:n.visibleRect.top,width:n.visibleRect.width,height:n.visibleRect.height}}),n);let r=0,i=0;if(`naturalWidth`in t?(r=t.naturalWidth,i=t.naturalHeight):`videoWidth`in t?(r=t.videoWidth,i=t.videoHeight):`width`in t&&(r=Number(t.width),i=Number(t.height)),!r||!i)throw TypeError(`Could not determine dimensions.`);let a=n.visibleRect??{left:0,top:0,width:r,height:i},o=new OffscreenCanvas(a.width,a.height),s=o.getContext(`2d`,{alpha:br(),willReadFrequently:!0});if(!s)throw Error(`OffscreenCanvas must have support for the '2d' context in order to create a VideoSample from this data.`);s.drawImage(t,-a.left,-a.top),this._data=o,this._layout=null,this.format=`RGBX`,this.visibleRect={left:0,top:0,width:a.width,height:a.height},this.squarePixelWidth=a.width,this.squarePixelHeight=a.height,this.rotation=n.rotation??0,this.flip=n.flip??!1,this.timestamp=n.timestamp,this.duration=n.duration??0,this.colorSpace=new Ta({matrix:`rgb`,primaries:`bt709`,transfer:`iec61966-2-1`,fullRange:!0})}else if(t instanceof ga){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n.flip!==void 0&&typeof n.flip!=`boolean`)throw TypeError(`init.flip, when provided, must be a boolean.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(this._data=t,t._referenceCount++,this.format=t.getFormat(),this.format!==null&&!_a.includes(this.format))throw TypeError(`getFormat() must return a VideoSamplePixelFormat or null.`);if(this.visibleRect={left:0,top:0,width:t.getCodedWidth(),height:t.getCodedHeight()},!Number.isInteger(this.visibleRect.width)||this.visibleRect.width<=0)throw TypeError(`getCodedWidth() must return a positive integer.`);if(!Number.isInteger(this.visibleRect.height)||this.visibleRect.height<=0)throw TypeError(`getCodedHeight() must return a positive integer.`);if(this.squarePixelWidth=t.getSquarePixelWidth(),!Number.isInteger(this.squarePixelWidth)||this.squarePixelWidth<=0)throw TypeError(`getSquarePixelWidth() must return a positive integer.`);if(this.squarePixelHeight=t.getSquarePixelHeight(),!Number.isInteger(this.squarePixelHeight)||this.squarePixelHeight<=0)throw TypeError(`getSquarePixelHeight() must return a positive integer.`);this.rotation=n.rotation??0,this.flip=n.flip??!1,this.timestamp=n.timestamp,this.duration=n.duration??0,this.colorSpace=t.getColorSpace()}else throw TypeError(`Invalid data type: Must be a BufferSource, CanvasImageSource, or VideoSampleResource.`);this.encodeOptions=n?.encodeOptions??{},this.pixelAspectRatio=Fr({num:this.squarePixelWidth*this.codedHeight,den:this.squarePixelHeight*this.codedWidth}),ha?.register(this,{type:`video`,data:this._data},this)}clone(){if(this._closed)throw Error(`VideoSample is closed.`);return F(this._data!==null),this._data instanceof ga?new e(this._data,{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,flip:this.flip,encodeOptions:this.encodeOptions}):Ea(this._data)?new e(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,flip:this.flip,encodeOptions:this.encodeOptions}):this._data instanceof Uint8Array?(F(this._layout),new e(this._data,{format:this.format,layout:this._layout,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation,flip:this.flip,visibleRect:this.visibleRect,displayWidth:this.displayWidth,displayHeight:this.displayHeight,encodeOptions:this.encodeOptions,_doNotCopy:!0})):new e(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation,flip:this.flip,visibleRect:this.visibleRect,displayWidth:this.displayWidth,displayHeight:this.displayHeight,encodeOptions:this.encodeOptions})}close(){this._closed||=(ha?.unregister(this),this._data instanceof ga?(this._data._referenceCount--,this._data._referenceCount===0&&this._data.close()):Ea(this._data)?this._data.close():this._data=null,!0)}allocationSize(e={}){if(ka(e),this._closed)throw Error(`VideoSample is closed.`);if((e.format??this.format)==null)throw Error(`Cannot get allocation size when format is null.`);return Ea(this._data)?this._data.allocationSize(e):Ma(this,e).allocationSize}async copyTo(t,n={}){if(!Zn(t))throw TypeError(`destination must be an ArrayBuffer or an ArrayBuffer view.`);if(ka(n),this._closed)throw Error(`VideoSample is closed.`);if((n.format??this.format)==null)throw Error(`Cannot copy video sample data when format is null.`);if(F(this._data!==null),Ea(this._data))return this._data.copyTo(t,n);if(n.format&&![`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(this.format)&&[`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(n.format)){if(this._data instanceof ga){let r={stack:[],error:void 0,hasError:!1};try{let i=da(r,await this._data.toRgbSample({timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,flip:this.flip},n.colorSpace??`srgb`),!1);if(!(i instanceof e))throw TypeError(`toRgbSample() must return a VideoSample.`);if(![`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(i.format))throw Error(`Sample returned by toRgbSample was expected to have an RGB format, got '${i.format}' instead.`);return await i.copyTo(t,n)}catch(e){r.error=e,r.hasError=!0}finally{fa(r)}}else{if(typeof VideoFrame>`u`)throw Error(`For this sample, converting from a non-RGB to an RGB format requires VideoFrame to be defined.`);let e=this.toVideoFrame(),r=await e.copyTo(t,n);return e.close(),r}}let r=Ma(this,n);F(this.format);let i=Un(t);if(i.byteLength<r.allocationSize)throw TypeError(`Destination buffer too small. Required: ${r.allocationSize}, Available: ${i.byteLength}`);let a=ja(this.format),o;if(this._data instanceof ga){let e=this._data.getDataPlanes();if(Or(e)&&(e=await e),!Array.isArray(e)||e.some(e=>!(e.data instanceof Uint8Array)||!Number.isInteger(e.stride)||e.stride<0))throw TypeError(`getDataPlanes() must return an array of objects with a Uint8Array "data" property and a non-negative integer "stride" property.`);o=e}else if(this._data instanceof Uint8Array)F(this._layout),F(this._layout.length===a.length),o=this._layout.map((e,t)=>{let n=Math.ceil(this.codedHeight/a[t].heightDivisor);return{data:this._data.subarray(e.offset,e.offset+e.stride*n),stride:e.stride}});else{let e=this._data.getContext(`2d`);F(e),o=[{data:Un(e.getImageData(0,0,this.codedWidth,this.codedHeight).data),stride:4*this.codedWidth}]}let s=[],c=a.length;for(let e=0;e<c;e++){let t=r.computedLayouts[e],n=o[e].stride,a=o[e].data,c=t.sourceTop*n;c+=t.sourceLeftBytes;let l=t.destinationOffset,u=t.sourceWidthBytes,d={offset:l,stride:t.destinationStride};for(let e=0;e<t.sourceHeight;e++){if(c+u>a.byteLength)throw Error(`Source buffer OOB read.`);if(l+u>i.byteLength)throw Error(`Destination buffer OOB write.`);let e=a.subarray(c,c+u);i.set(e,l),c+=n,l+=t.destinationStride}s.push(d)}if(n.format!==void 0){let e=this.format.startsWith(`RGB`)!==n.format.startsWith(`RGB`),t=this.format.includes(`X`)&&n.format.includes(`A`);if(e||t)for(let n=0;n<r.allocationSize;n+=4){if(e){let e=i[n],t=i[n+2];i[n]=t,i[n+2]=e}t&&(i[n+3]=255)}}return s}toVideoFrame(){if(this._closed)throw Error(`VideoSample is closed.`);if(F(this._data!==null),this._data instanceof ga){if(this.format===null)throw Error(`Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if format is null.`);let e=this._data.getDataPlanes();if(Or(e))throw Error(`Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if getDataPlanes() returns a promise.`);let t=e.reduce((e,t)=>e+t.data.byteLength,0),n=new Uint8Array(t),r=0,i=[];for(let t of e)n.set(t.data,r),i.push(r),r+=t.data.byteLength;return new VideoFrame(n,{format:this.format,layout:e.map((e,t)=>({offset:i[t],stride:e.stride})),codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration,colorSpace:this.colorSpace,visibleRect:this.visibleRect,displayWidth:this.squarePixelWidth,displayHeight:this.squarePixelHeight})}return Ea(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?(F(this._layout),new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,layout:this._layout,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace,visibleRect:this.visibleRect,displayWidth:this.squarePixelWidth,displayHeight:this.squarePixelHeight})):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,n,r,i,a,o,s,c){let l=0,u=0,d=this.displayWidth,f=this.displayHeight,p=0,m=0,h=this.displayWidth,g=this.displayHeight;if(a===void 0?(p=t,m=n,r!==void 0&&(h=r,g=i)):(l=t,u=n,d=r,f=i,p=a,m=o,s===void 0?(h=d,g=f):(h=s,g=c)),!(typeof CanvasRenderingContext2D<`u`&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<`u`&&e instanceof OffscreenCanvasRenderingContext2D))throw TypeError(`context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.`);if(!Number.isFinite(l))throw TypeError(`sx must be a number.`);if(!Number.isFinite(u))throw TypeError(`sy must be a number.`);if(!Number.isFinite(d)||d<0)throw TypeError(`sWidth must be a non-negative number.`);if(!Number.isFinite(f)||f<0)throw TypeError(`sHeight must be a non-negative number.`);if(!Number.isFinite(p))throw TypeError(`dx must be a number.`);if(!Number.isFinite(m))throw TypeError(`dy must be a number.`);if(!Number.isFinite(h)||h<0)throw TypeError(`dWidth must be a non-negative number.`);if(!Number.isFinite(g)||g<0)throw TypeError(`dHeight must be a non-negative number.`);if(this._closed)throw Error(`VideoSample is closed.`);({sx:l,sy:u,sWidth:d,sHeight:f}=this._unmapSourceRegion(l,u,d,f,this.rotation,this.flip));let _=this.toCanvasImageSource();e.save();let v=p+h/2,y=m+g/2;e.translate(v,y),this.flip&&e.scale(-1,1),e.rotate(this.rotation*Math.PI/180);let b=this.rotation%180==0?1:h/g;e.scale(1/b,b),e.drawImage(_,l,u,d,f,-h/2,-g/2,h,g),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<`u`&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<`u`&&e instanceof OffscreenCanvasRenderingContext2D))throw TypeError(`context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.`);if(!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(![`fill`,`contain`,`cover`].includes(t.fit))throw TypeError(`options.fit must be 'fill', 'contain', or 'cover'.`);if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw TypeError(`options.rotation, when provided, must be 0, 90, 180, or 270.`);if(t.flip!==void 0&&typeof t.flip!=`boolean`)throw TypeError(`options.flip, when provided, must be a boolean.`);t.crop!==void 0&&Oa(t.crop,`options.`);let n=e.canvas.width,r=e.canvas.height,i=t.rotation??this.rotation,a=t.flip??this.flip,[o,s]=i%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth],c=t.crop;c&&=Da(c,o,s);let l,u,d,f,{sx:p,sy:m,sWidth:h,sHeight:g}=this._unmapSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??o,t.crop?.height??s,i,a);if(t.fit===`fill`)l=0,u=0,d=n,f=r;else{let[e,i]=t.crop?[t.crop.width,t.crop.height]:[o,s],a=t.fit===`contain`?Math.min(n/e,r/i):Math.max(n/e,r/i);d=e*a,f=i*a,l=(n-d)/2,u=(r-f)/2}e.save();let _=i%180==0?1:d/f;e.translate(n/2,r/2),a&&e.scale(-1,1),e.rotate(i*Math.PI/180),e.scale(1/_,_),e.translate(-n/2,-r/2),e.drawImage(this.toCanvasImageSource(),p,m,h,g,l,u,d,f),e.restore()}_unmapSourceRegion(e,t,n,r,i,a){return a&&(e=(i%180==0?this.squarePixelWidth:this.squarePixelHeight)-e-n),i===90?[e,t,n,r]=[t,this.squarePixelHeight-e-n,r,n]:i===180?[e,t]=[this.squarePixelWidth-e-n,this.squarePixelHeight-t-r]:i===270&&([e,t,n,r]=[this.squarePixelWidth-t-r,e,r,n]),{sx:e,sy:t,sWidth:n,sHeight:r}}_drawWithFitAndMipmapping(e,t,n){let r=e.width,i=e.height,[a,o]=n.rotation%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth],s=n.crop?n.crop.width:a,c=n.crop?n.crop.height:o,l=0;2*r<s&&2*i<c&&(l=Math.floor(Math.log2(Math.min(s/r,c/i))));let u=r*2**l,d=i*2**l,{canvas:f,context:p,isNew:m}=l>0?wa(u,d):{canvas:e,context:t,isNew:n.targetIsFresh};p.imageSmoothingQuality=`high`,n.fillBlack?(p.fillStyle=`black`,p.fillRect(0,0,u,d)):m||p.clearRect(0,0,u,d),this.drawWithFit(p,{fit:n.fit,rotation:n.rotation,flip:n.flip,crop:n.crop}),p.globalCompositeOperation=`copy`;for(let e=l;e>1;e--){let t=r*2**e,n=i*2**e;p.drawImage(f,0,0,t,n,0,0,t/2,n/2)}p.globalCompositeOperation=`source-over`,l>0&&(t.imageSmoothingQuality=`high`,t.globalCompositeOperation=`copy`,t.drawImage(f,0,0,2*r,2*i,0,0,r,i),t.globalCompositeOperation=`source-over`)}toCanvasImageSource(){if(this._closed)throw Error(`VideoSample is closed.`);if(F(this._data!==null),this._data instanceof ga||this._data instanceof Uint8Array){let e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}return this._data}async transform(t){if(!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(t.width!==void 0&&(!Number.isInteger(t.width)||t.width<=0))throw TypeError(`options.width, when provided, must be a positive integer.`);if(t.height!==void 0&&(!Number.isInteger(t.height)||t.height<=0))throw TypeError(`options.height, when provided, must be a positive integer.`);if(t.roundDimensionsTo!==void 0&&(!Number.isInteger(t.roundDimensionsTo)||t.roundDimensionsTo<=0))throw TypeError(`options.roundDimensionsTo, when provided, must be a positive integer.`);if(t.fit!==void 0&&![`fill`,`contain`,`cover`].includes(t.fit))throw TypeError(`options.fit, when provided, must be one of "fill", "contain", or "cover".`);if(t.width!==void 0&&t.height!==void 0&&t.fit===void 0)throw TypeError(`When both options.width and options.height are provided, options.fit must also be provided.`);if(t.rotate!==void 0&&![0,90,180,270].includes(t.rotate))throw TypeError(`options.rotate, when provided, must be 0, 90, 180 or 270.`);if(t.flip!==void 0&&typeof t.flip!=`boolean`)throw TypeError(`options.flip, when provided, must be a boolean.`);if(t.crop!==void 0&&Oa(t.crop,`options.`),t.alpha!==void 0&&![`keep`,`discard`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'keep' or 'discard'.`);let{rotation:n,flip:r}=Ln(this.rotation,this.flip,t.rotate??0,t.flip??!1),[i,a]=n%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth],o=t.crop;o&&=Da(o,i,a);let s=o?o.width:i,c=o?o.height:a,l=s/c,u,d;t.width!==void 0&&t.height===void 0?(u=t.width,d=u/l):t.width===void 0&&t.height!==void 0?(d=t.height,u=d*l):t.width!==void 0&&t.height!==void 0?(u=t.width,d=t.height):(u=s,d=c),u=cr(u,t.roundDimensionsTo??1),d=cr(d,t.roundDimensionsTo??1);let f={width:u,height:d,fit:t.fit??`fill`,rotation:n,flip:r,crop:o??{left:0,top:0,width:i,height:a},alpha:t.alpha??`keep`};for(let e of ba){let t=e(this,f);if(Or(t)&&(t=await t),t!==null)return t}let{canvas:p,context:m,isNew:h}=wa(f.width,f.height);return this._drawWithFitAndMipmapping(p,m,{fit:f.fit,rotation:f.rotation,flip:f.flip,crop:f.crop,targetIsFresh:h,fillBlack:f.alpha===`discard`}),new e(p,{timestamp:this.timestamp,duration:this.duration,rotation:0,flip:!1})}setRotation(e){if(![0,90,180,270].includes(e))throw TypeError(`newRotation must be 0, 90, 180, or 270.`);this.rotation=e}setFlip(e){if(typeof e!=`boolean`)throw TypeError(`newFlip must be a boolean.`);this.flip=e}setTimestamp(e){if(!Number.isFinite(e))throw TypeError(`newTimestamp must be a number.`);this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw TypeError(`newDuration must be a non-negative number.`);this.duration=e}setEncodeOptions(e){if(!e||typeof e!=`object`)throw TypeError(`newEncodeOptions must be an object.`);this.encodeOptions=e}[Symbol.dispose](){this.close()}},ba=[],xa=3,Sa=[],Ca=0,wa=(e,t)=>{for(let n of Sa)if(n.canvas.width===e&&n.canvas.height===t)return n.age=Ca++,{canvas:n.canvas,context:n.context,isNew:!1};let n;if(typeof OffscreenCanvas<`u`)n=new OffscreenCanvas(e,t);else{if(typeof window>`u`||typeof document>`u`)throw Error(`Cannot transform VideoSamples in this environment. Either run in an environment with OffscreenCanvas or HTMLCanvasElement, or supply a custom VideoSample transformer using registerVideoSampleTransformer().`);n=document.createElement(`canvas`),n.width=e,n.height=t}let r=n.getContext(`2d`,{alpha:!0,willReadFrequently:!1});if(!r)throw Error(`The '2d' canvas context is required to transform VideoSamples. Register a custom transformer using registerVideoSampleTransformer to work around this limitation.`);return Sa.length>=xa&&Sa.splice(Pr(Sa,e=>e.age),1),Sa.push({canvas:n,context:r,age:Ca++}),{canvas:n,context:r,isNew:!0}},Ta=class{constructor(e){if(e!==void 0){if(!e||typeof e!=`object`)throw TypeError(`init.colorSpace, when provided, must be an object.`);let t=Object.keys(qn);if(e.primaries!=null&&!t.includes(e.primaries))throw TypeError(`init.colorSpace.primaries, when provided, must be one of ${t.join(`, `)}.`);let n=Object.keys(Jn);if(e.transfer!=null&&!n.includes(e.transfer))throw TypeError(`init.colorSpace.transfer, when provided, must be one of ${n.join(`, `)}.`);let r=Object.keys(Yn);if(e.matrix!=null&&!r.includes(e.matrix))throw TypeError(`init.colorSpace.matrix, when provided, must be one of ${r.join(`, `)}.`);if(e.fullRange!=null&&typeof e.fullRange!=`boolean`)throw TypeError(`init.colorSpace.fullRange, when provided, must be a boolean.`)}this.primaries=e?.primaries??null,this.transfer=e?.transfer??null,this.matrix=e?.matrix??null,this.fullRange=e?.fullRange??null}toJSON(){return{primaries:this.primaries,transfer:this.transfer,matrix:this.matrix,fullRange:this.fullRange}}},Ea=e=>typeof VideoFrame<`u`&&e instanceof VideoFrame,Da=(e,t,n)=>{let r=Math.min(e.left,t),i=Math.min(e.top,n),a=Math.min(e.width,t-r),o=Math.min(e.height,n-i);return F(a>=0),F(o>=0),{left:r,top:i,width:a,height:o}},Oa=(e,t)=>{if(!e||typeof e!=`object`)throw TypeError(t+`crop, when provided, must be an object.`);if(!Number.isInteger(e.left)||e.left<0)throw TypeError(t+`crop.left must be a non-negative integer.`);if(!Number.isInteger(e.top)||e.top<0)throw TypeError(t+`crop.top must be a non-negative integer.`);if(!Number.isInteger(e.width)||e.width<0)throw TypeError(t+`crop.width must be a non-negative integer.`);if(!Number.isInteger(e.height)||e.height<0)throw TypeError(t+`crop.height must be a non-negative integer.`)},ka=e=>{if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.colorSpace!==void 0&&![`display-p3`,`srgb`].includes(e.colorSpace))throw TypeError(`options.colorSpace, when provided, must be 'display-p3' or 'srgb'.`);if(e.format!==void 0&&typeof e.format!=`string`)throw TypeError(`options.format, when provided, must be a string.`);if(e.layout!==void 0){if(!Array.isArray(e.layout))throw TypeError(`options.layout, when provided, must be an array.`);for(let t of e.layout){if(!t||typeof t!=`object`)throw TypeError(`Each entry in options.layout must be an object.`);if(!Number.isInteger(t.offset)||t.offset<0)throw TypeError(`plane.offset must be a non-negative integer.`);if(!Number.isInteger(t.stride)||t.stride<0)throw TypeError(`plane.stride must be a non-negative integer.`)}}if(e.rect!==void 0){if(!e.rect||typeof e.rect!=`object`)throw TypeError(`options.rect, when provided, must be an object.`);if(e.rect.x!==void 0&&(!Number.isInteger(e.rect.x)||e.rect.x<0))throw TypeError(`options.rect.x, when provided, must be a non-negative integer.`);if(e.rect.y!==void 0&&(!Number.isInteger(e.rect.y)||e.rect.y<0))throw TypeError(`options.rect.y, when provided, must be a non-negative integer.`);if(e.rect.width!==void 0&&(!Number.isInteger(e.rect.width)||e.rect.width<0))throw TypeError(`options.rect.width, when provided, must be a non-negative integer.`);if(e.rect.height!==void 0&&(!Number.isInteger(e.rect.height)||e.rect.height<0))throw TypeError(`options.rect.height, when provided, must be a non-negative integer.`)}},Aa=(e,t,n)=>{let r=ja(e),i=[],a=0;for(let e of r){let r=Math.ceil(t/e.widthDivisor),o=Math.ceil(n/e.heightDivisor),s=r*e.sampleBytes,c=s*o;i.push({offset:a,stride:s}),a+=c}return i},ja=e=>{let t=(e,t,n,r,i)=>{let a=[{sampleBytes:e,widthDivisor:1,heightDivisor:1},{sampleBytes:t,widthDivisor:n,heightDivisor:r},{sampleBytes:t,widthDivisor:n,heightDivisor:r}];return i&&a.push({sampleBytes:e,widthDivisor:1,heightDivisor:1}),a};switch(e){case`I420`:return t(1,1,2,2,!1);case`I420P10`:case`I420P12`:return t(2,2,2,2,!1);case`I420A`:return t(1,1,2,2,!0);case`I420AP10`:case`I420AP12`:return t(2,2,2,2,!0);case`I422`:return t(1,1,2,1,!1);case`I422P10`:case`I422P12`:return t(2,2,2,1,!1);case`I422A`:return t(1,1,2,1,!0);case`I422AP10`:case`I422AP12`:return t(2,2,2,1,!0);case`I444`:return t(1,1,1,1,!1);case`I444P10`:case`I444P12`:return t(2,2,1,1,!1);case`I444A`:return t(1,1,1,1,!0);case`I444AP10`:case`I444AP12`:return t(2,2,1,1,!0);case`NV12`:return[{sampleBytes:1,widthDivisor:1,heightDivisor:1},{sampleBytes:2,widthDivisor:2,heightDivisor:2}];case`RGBA`:case`RGBX`:case`BGRA`:case`BGRX`:return[{sampleBytes:4,widthDivisor:1,heightDivisor:1}];default:rr(e),F(!1)}},Ma=(e,t)=>{let n={left:0,top:0,width:e.codedWidth,height:e.codedHeight},r=t.rect,i=Na(n,r,e.codedWidth,e.codedHeight,e.format),a=t.layout,o;if(!t.format||t.format===e.format)o=e.format;else if([`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(t.format))o=t.format;else throw Error(`NotSupportedError: Invalid destination format.`);return Fa(i,o,a)},Na=(e,t,n,r,i)=>{let a={...e};if(t!==void 0){if(t.width===0||t.height===0)throw TypeError(`visibleRect dimensions cannot be zero.`);if((t.x||0)+(t.width||0)>n)throw TypeError(`visibleRect exceeds codedWidth.`);if((t.y||0)+(t.height||0)>r)throw TypeError(`visibleRect exceeds codedHeight.`);a.x=t.x||0,a.y=t.y||0,a.width=t.width||0,a.height=t.height||0}if(!Pa(i,a))throw TypeError(`visibleRect alignment is invalid for the format.`);return a},Pa=(e,t)=>{if(e===null)return!0;let n=ja(e);for(let e=0;e<n.length;e++){let r=n[e],i=r.widthDivisor,a=r.heightDivisor;if((t.x||0)%i!==0||(t.y||0)%a!==0)return!1}return!0},Fa=(e,t,n)=>{let r=ja(t),i=r.length;if(n!==void 0&&n.length!==i)throw TypeError(`Layout must have ${i} planes.`);let a=0,o=[],s=[];for(let t=0;t<i;t++){let i=r[t],c=i.sampleBytes,l=i.widthDivisor,u=i.heightDivisor,d={destinationOffset:0,destinationStride:0,sourceTop:0,sourceHeight:0,sourceLeftBytes:0,sourceWidthBytes:0};if(d.sourceTop=Math.ceil(Math.trunc(e.y||0)/u),d.sourceHeight=Math.ceil(Math.trunc(e.height||0)/u),d.sourceLeftBytes=Math.floor(Math.trunc(e.x||0)/l)*c,d.sourceWidthBytes=Math.floor(Math.trunc(e.width||0)/l)*c,n!==void 0){let e=n[t];if(e.stride<d.sourceWidthBytes)throw TypeError(`Stride for plane ${t} is too small.`);d.destinationOffset=e.offset,d.destinationStride=e.stride}else d.destinationOffset=a,d.destinationStride=d.sourceWidthBytes;let f=d.destinationStride*d.sourceHeight+d.destinationOffset;if(f>4294967295)throw TypeError(`Allocation size exceeds limit.`);s.push(f),a=Math.max(a,f);for(let e=0;e<t;e++){let n=o[e];if(!(s[t]<=n.destinationOffset||s[e]<=d.destinationOffset))throw TypeError(`Planes overlap.`)}o.push(d)}return{allocationSize:a,computedLayouts:o}},Ia=new Map,La=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!Fo.includes(e.codec))throw TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${Fo.join(`, `)}.`);let t=e.bitrate;if(e.quality===void 0&&t===void 0)throw TypeError(`config.quality must be provided.`);if(e.quality!==void 0&&t!==void 0)throw TypeError(`config.quality and config.bitrate cannot both be provided.`);if(e.quality!==void 0&&!(e.quality instanceof Ba))throw TypeError(`config.quality, when provided, must be a Quality.`);if(t!==void 0&&!(t instanceof Ba)&&(!Number.isInteger(t)||t<=0))throw TypeError(`config.bitrate, when provided, must be a positive integer or a quality.`);if(e.keyFrameInterval!==void 0&&(!Number.isFinite(e.keyFrameInterval)||e.keyFrameInterval<0))throw TypeError(`config.keyFrameInterval, when provided, must be a non-negative number.`);if(e.sizeChangeBehavior!==void 0&&![`deny`,`passThrough`,`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.`);if(e.transform!==void 0){if(typeof e.transform!=`object`||!e.transform)throw TypeError(`config.transform, when provided, must be an object.`);if(e.transform.width!==void 0&&(!Number.isInteger(e.transform.width)||e.transform.width<=0))throw TypeError(`config.transform.width, when provided, must be a positive integer.`);if(e.transform.height!==void 0&&(!Number.isInteger(e.transform.height)||e.transform.height<=0))throw TypeError(`config.transform.height, when provided, must be a positive integer.`);if(e.transform.fit!==void 0&&![`fill`,`contain`,`cover`].includes(e.transform.fit))throw TypeError(`config.transform.fit, when provided, must be one of "fill", "contain", or "cover".`);if(e.transform.width!==void 0&&e.transform.height!==void 0&&e.transform.fit===void 0&&![`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`When both config.transform.width and config.transform.height are provided, config.transform.fit must also be provided.`);if(e.transform.fit!==void 0&&[`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior)&&e.transform.fit!==e.sizeChangeBehavior)throw TypeError(`config.transform.fit, when provided, cannot differ from config.sizeChangeBehavior when config.sizeChangeBehavior is 'fill', 'contain' or 'cover', as sizeChangeBehavior already determines the fitting algorithm.`);if(e.transform.rotate!==void 0&&![0,90,180,270].includes(e.transform.rotate))throw TypeError(`config.transform.rotate, when provided, must be 0, 90, 180 or 270.`);if(e.transform.flip!==void 0&&typeof e.transform.flip!=`boolean`)throw TypeError(`config.transform.flip, when provided, must be a boolean.`);if(e.transform.crop!==void 0&&Oa(e.transform.crop,`config.transform.`),e.transform.process!==void 0&&typeof e.transform.process!=`function`)throw TypeError(`config.transform.process, when provided, must be a function.`);if(e.transform.frameRate!==void 0&&(!Number.isFinite(e.transform.frameRate)||e.transform.frameRate<=0))throw TypeError(`config.transform.frameRate, when provided, must be a finite positive number.`);if(e.transform.force!==void 0&&typeof e.transform.force!=`boolean`)throw TypeError(`config.transform.force, when provided, must be a boolean.`)}if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedPacket, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);if(e.onEncodedSample!==void 0&&typeof e.onEncodedSample!=`function`)throw TypeError(`config.onEncodedSample, when provided, must be a function.`);Ra(e.codec,e)},Ra=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.alpha!==void 0&&![`discard`,`keep`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'discard' or 'keep'.`);let n=t.bitrateMode;if(n!==void 0&&![`constant`,`variable`].includes(n))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.latencyMode!==void 0&&![`quality`,`realtime`].includes(t.latencyMode))throw TypeError(`latencyMode, when provided, must be 'quality' or 'realtime'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&rs(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);if(t.hardwareAcceleration!==void 0&&![`no-preference`,`prefer-hardware`,`prefer-software`].includes(t.hardwareAcceleration))throw TypeError(`hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.`);if(t.scalabilityMode!==void 0&&typeof t.scalabilityMode!=`string`)throw TypeError(`scalabilityMode, when provided, must be a string.`);if(t.contentHint!==void 0&&typeof t.contentHint!=`string`)throw TypeError(`contentHint, when provided, must be a string.`)},za=e=>{let t=e.bitrateMode,n=e.quality._toVideoRateControl(e.codec,e.width,e.height,t),r=(t,n,r)=>({codec:e.fullCodecString??Jo(e.codec,e.width,e.height,r,e.alpha===`keep`),width:e.width,height:e.height,displayWidth:e.squarePixelWidth,displayHeight:e.squarePixelHeight,bitrate:t,bitrateMode:n,alpha:e.alpha??`discard`,framerate:e.framerate,latencyMode:e.latencyMode,hardwareAcceleration:e.hardwareAcceleration,scalabilityMode:e.scalabilityMode,contentHint:e.contentHint,...is(e.codec)}),i=[];return n.quantizer!==null&&i.push({config:r(void 0,`quantizer`,n.bitrate),quantizer:n.quantizer}),n.bitrateMode!==`quantizer`&&i.push({config:r(n.bitrate,n.bitrateMode,n.bitrate),quantizer:null}),F(i.length>0),i},Ba=class{constructor(e){if((typeof e==`number`||typeof e==`string`)&&(e={quality:e}),!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.bitrateMode!==void 0&&![`constant`,`variable`].includes(e.bitrateMode))throw TypeError(`options.bitrateMode, when provided, must be 'constant' or 'variable'.`);if(`quality`in e){if(typeof e.quality==`string`?!(e.quality in Va):typeof e.quality!=`number`||Number.isNaN(e.quality))throw TypeError(`options.quality must be a number, or one of 'very-low', 'low', 'medium', 'high' or 'very-high'.`);if(e.preferBitrate!==void 0&&typeof e.preferBitrate!=`boolean`)throw TypeError(`options.preferBitrate, when provided, must be a boolean.`);if(`bitrate`in e||`quantizer`in e)throw TypeError(`options.quality cannot be combined with options.bitrate or options.quantizer.`);this._quality=typeof e.quality==`string`?Va[e.quality]:e.quality,this._preferBitrate=e.preferBitrate??!1,this._bitrate=void 0,this._quantizer=void 0}else{if(e.bitrate!==void 0&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`options.bitrate, when provided, must be a positive integer.`);if(e.quantizer!==void 0&&(!Number.isInteger(e.quantizer)||e.quantizer<0))throw TypeError(`options.quantizer, when provided, must be a non-negative integer.`);if(e.bitrate===void 0&&e.quantizer===void 0)throw TypeError(`At least one of options.bitrate or options.quantizer must be set.`);if(`preferBitrate`in e)throw TypeError(`options.preferBitrate can only be combined with options.quality.`);this._quality=void 0,this._preferBitrate=!1,this._bitrate=e.bitrate,this._quantizer=e.quantizer}this._bitrateMode=e.bitrateMode}_toVideoRateControl(e,t,n,r){let i=Ha[e],a=null,o=this._bitrateMode??r??`variable`;if(this._quantizer!==void 0){if(!i){if(this._bitrate===void 0)throw Error(`Codec '${e}' does not support quantizer-based encoding. Provide a bitrate in the Quality to define a fallback.`)}else if(this._quantizer<i.min||this._quantizer>i.max){if(this._bitrate===void 0)throw Error(`Quantizer ${this._quantizer} is out of range for codec '${e}'; must be between ${i.min} and ${i.max}.`)}else a=this._quantizer,this._bitrate===void 0&&(o=`quantizer`)}else this._bitrate===void 0&&i&&!this._preferBitrate&&(F(this._quality!==void 0),a=or(Math.round(sr(i.worst,i.best,this._quality)),i.min,i.max));let s;if(this._bitrate!==void 0)s=this._bitrate;else{let r=this._quality;r===void 0&&(F(a!==null&&i),r=or((a-i.worst)/(i.best-i.worst),0,1)),s=Wa(e,t,n,Ua(r))}return{quantizer:a,bitrate:s,bitrateMode:o}}_toVideoBitrate(e,t,n){return this._bitrate===void 0?(F(this._quality!==void 0),Wa(e,t,n,Ua(this._quality))):this._bitrate}_toAudioBitrate(e){if(Io.includes(e)||e===`flac`||e===`truehd`)return;if(this._bitrate!==void 0)return this._bitrate;if(this._quality===void 0)throw Error(`This Quality defines neither a quality level nor a bitrate and therefore cannot be used for audio encoding.`);let t=Ua(this._quality),n={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3,ac3:384e3,eac3:192e3,dts:768e3}[e];if(!n)throw Error(`Unhandled codec: ${e}`);let r=n*t;return e===`aac`?r=[96e3,128e3,16e4,192e3].reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e):e===`opus`||e===`vorbis`?r=Math.max(6e3,r):e===`mp3`&&(r=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e)),Math.round(r/1e3)*1e3}},Va={"very-low":0,low:.25,medium:.5,high:.75,"very-high":1},Ha={avc:{min:0,max:51,worst:41,best:16},hevc:{min:0,max:51,worst:41,best:16},vp9:(wr()??1/0)<145?{min:0,max:63,worst:52,best:20}:{min:0,max:255,worst:208,best:80},av1:{min:0,max:255,worst:208,best:80}},Ua=e=>.3*Math.exp(2.5538*e),Wa=(e,t,n,r)=>{let i=t*n,a=3e6,o=a*(i/2073600)**.95*{avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2,prores:22e7/a}[e]*r;return Math.ceil(o/1e3)*1e3},Ga=(e,t)=>{if(e===`avc`)return{avc:{quantizer:t}};if(e===`hevc`)return{hevc:{quantizer:t}};if(e===`vp9`)return{vp9:{quantizer:t}};if(e===`av1`)return{av1:{quantizer:t}};F(!1)},Ka=new Ba(`high`),qa=async(e,t={})=>{let{width:n=1280,height:r=720,quality:i,bitrate:a,frameRate:o,...s}=t;if(!Fo.includes(e))return!1;if(!Number.isInteger(n)||n<=0)throw TypeError(`width must be a positive integer.`);if(!Number.isInteger(r)||r<=0)throw TypeError(`height must be a positive integer.`);if(i!==void 0&&!(i instanceof Ba))throw TypeError(`quality, when provided, must be a Quality.`);if(i!==void 0&&a!==void 0)throw TypeError(`quality and bitrate cannot both be provided.`);if(a!==void 0&&!(a instanceof Ba)&&(!Number.isInteger(a)||a<=0))throw TypeError(`bitrate must be a positive integer or a quality.`);if(o!==void 0&&(!Number.isFinite(o)||o<=0))throw TypeError(`frameRate, when provided, must be a finite positive number.`);Ra(e,s);let c=Ja(i,a)??new Ba(`medium`),l;try{l=za({codec:e,width:n,height:r,quality:c,framerate:o,...s,alpha:`discard`})}catch{return!1}let u=JSON.stringify(l),d=Ia.get(u);if(d)return d;let f=(async()=>{for(let{config:t}of l)if(Ya.some(n=>n.supports(e,t)))return!0;if(typeof VideoEncoder>`u`||(n%2==1||r%2==1)&&(e===`avc`||e===`hevc`))return!1;for(let{config:t,quantizer:i}of l){try{if(!(await VideoEncoder.isConfigSupported(t)).supported)continue}catch{continue}if(!br()||await new Promise(async a=>{try{let o=new VideoEncoder({output:()=>{},error:()=>a(!1)});o.configure(t);let s=new Uint8Array(n*r*4),c=new VideoFrame(s,{format:`RGBA`,codedWidth:n,codedHeight:r,timestamp:0});o.encode(c,i===null?void 0:Ga(e,i)),c.close(),await o.flush(),a(!0)}catch{a(!1)}}))return!0}return!1})();return Ia.set(u,f),f},Ja=(e,t)=>{if(e!==void 0)return e;if(t!==void 0)return t instanceof Ba?t:new Ba({bitrate:t})},Ya=[],Xa=new Uint8Array,Za=class e{constructor(e,t,n,r,i=-1,a,o){if(this.data=e,this.type=t,this.timestamp=n,this.duration=r,this.sequenceNumber=i,e===Xa&&a===void 0)throw Error(`Internal error: byteLength must be explicitly provided when constructing metadata-only packets.`);if(a===void 0&&(a=e.byteLength),!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(t!==`key`&&t!==`delta`)throw TypeError(`type must be either "key" or "delta".`);if(!Number.isFinite(n))throw TypeError(`timestamp must be a number.`);if(!Number.isFinite(r)||r<0)throw TypeError(`duration must be a non-negative number.`);if(!Number.isFinite(i))throw TypeError(`sequenceNumber must be a number.`);if(!Number.isInteger(a)||a<0)throw TypeError(`byteLength must be a non-negative integer.`);if(o!==void 0&&(typeof o!=`object`||!o))throw TypeError(`sideData, when provided, must be an object.`);if(o?.alpha!==void 0&&!(o.alpha instanceof Uint8Array))throw TypeError(`sideData.alpha, when provided, must be a Uint8Array.`);if(o?.alphaByteLength!==void 0&&(!Number.isInteger(o.alphaByteLength)||o.alphaByteLength<0))throw TypeError(`sideData.alphaByteLength, when provided, must be a non-negative integer.`);this.byteLength=a,this.sideData=o??{},this.sideData.alpha&&this.sideData.alphaByteLength===void 0&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===Xa}get microsecondTimestamp(){return Math.trunc(mr*this.timestamp)}get microsecondDuration(){return Math.trunc(mr*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to a video chunk.`);if(typeof EncodedVideoChunk>`u`)throw Error(`EncodedVideoChunk is not available in this environment.`);return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw TypeError(`This packet does not contain alpha side data.`);if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to a video chunk.`);if(typeof EncodedVideoChunk>`u`)throw Error(`EncodedVideoChunk is not available in this environment.`);return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to an audio chunk.`);if(typeof EncodedAudioChunk>`u`)throw Error(`EncodedAudioChunk is not available in this environment.`);return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(t,n){if(!(t instanceof EncodedVideoChunk||t instanceof EncodedAudioChunk))throw TypeError(`chunk must be an EncodedVideoChunk or EncodedAudioChunk.`);let r=new Uint8Array(t.byteLength);return t.copyTo(r),new e(r,t.type,t.timestamp/1e6,(t.duration??0)/1e6,void 0,void 0,n)}clone(t){if(t!==void 0&&(typeof t!=`object`||!t))throw TypeError(`options, when provided, must be an object.`);if(t?.data!==void 0&&!(t.data instanceof Uint8Array))throw TypeError(`options.data, when provided, must be a Uint8Array.`);if(t?.type!==void 0&&t.type!==`key`&&t.type!==`delta`)throw TypeError(`options.type, when provided, must be either "key" or "delta".`);if(t?.timestamp!==void 0&&!Number.isFinite(t.timestamp))throw TypeError(`options.timestamp, when provided, must be a number.`);if(t?.duration!==void 0&&!Number.isFinite(t.duration))throw TypeError(`options.duration, when provided, must be a number.`);if(t?.sequenceNumber!==void 0&&!Number.isFinite(t.sequenceNumber))throw TypeError(`options.sequenceNumber, when provided, must be a number.`);if(t?.sideData!==void 0&&(typeof t.sideData!=`object`||t.sideData===null))throw TypeError(`options.sideData, when provided, must be an object.`);return new e(t?.data??this.data,t?.type??this.type,t?.timestamp??this.timestamp,t?.duration??this.duration,t?.sequenceNumber??this.sequenceNumber,this.byteLength,t?.sideData??this.sideData)}},Qa=2082844800,$a=e=>{let t=(e.hasVideo?`video/`:e.hasAudio?`audio/`:`application/`)+(e.isQuickTime?`quicktime`:`mp4`);if(e.codecStrings.length>0){let n=[...new Set(e.codecStrings)];t+=`; codecs="${n.join(`, `)}"`}return t},eo=class{constructor(e){this.value=e}},to=class{constructor(e){this.value=e}},no=class{constructor(e){this.value=e}},ro=class{constructor(e){this.value=e}},R;(function(e){e[e.EBML=440786851]=`EBML`,e[e.EBMLVersion=17030]=`EBMLVersion`,e[e.EBMLReadVersion=17143]=`EBMLReadVersion`,e[e.EBMLMaxIDLength=17138]=`EBMLMaxIDLength`,e[e.EBMLMaxSizeLength=17139]=`EBMLMaxSizeLength`,e[e.DocType=17026]=`DocType`,e[e.DocTypeVersion=17031]=`DocTypeVersion`,e[e.DocTypeReadVersion=17029]=`DocTypeReadVersion`,e[e.Void=236]=`Void`,e[e.Segment=408125543]=`Segment`,e[e.SeekHead=290298740]=`SeekHead`,e[e.Seek=19899]=`Seek`,e[e.SeekID=21419]=`SeekID`,e[e.SeekPosition=21420]=`SeekPosition`,e[e.Duration=17545]=`Duration`,e[e.Info=357149030]=`Info`,e[e.TimestampScale=2807729]=`TimestampScale`,e[e.DateUTC=17505]=`DateUTC`,e[e.MuxingApp=19840]=`MuxingApp`,e[e.WritingApp=22337]=`WritingApp`,e[e.Tracks=374648427]=`Tracks`,e[e.TrackEntry=174]=`TrackEntry`,e[e.TrackNumber=215]=`TrackNumber`,e[e.TrackUID=29637]=`TrackUID`,e[e.TrackType=131]=`TrackType`,e[e.FlagEnabled=185]=`FlagEnabled`,e[e.FlagDefault=136]=`FlagDefault`,e[e.FlagForced=21930]=`FlagForced`,e[e.FlagOriginal=21934]=`FlagOriginal`,e[e.FlagHearingImpaired=21931]=`FlagHearingImpaired`,e[e.FlagVisualImpaired=21932]=`FlagVisualImpaired`,e[e.FlagCommentary=21935]=`FlagCommentary`,e[e.FlagLacing=156]=`FlagLacing`,e[e.Name=21358]=`Name`,e[e.Language=2274716]=`Language`,e[e.LanguageBCP47=2274717]=`LanguageBCP47`,e[e.CodecID=134]=`CodecID`,e[e.CodecPrivate=25506]=`CodecPrivate`,e[e.CodecDelay=22186]=`CodecDelay`,e[e.SeekPreRoll=22203]=`SeekPreRoll`,e[e.DefaultDuration=2352003]=`DefaultDuration`,e[e.Video=224]=`Video`,e[e.PixelWidth=176]=`PixelWidth`,e[e.PixelHeight=186]=`PixelHeight`,e[e.DisplayWidth=21680]=`DisplayWidth`,e[e.DisplayHeight=21690]=`DisplayHeight`,e[e.DisplayUnit=21682]=`DisplayUnit`,e[e.AlphaMode=21440]=`AlphaMode`,e[e.Audio=225]=`Audio`,e[e.SamplingFrequency=181]=`SamplingFrequency`,e[e.Channels=159]=`Channels`,e[e.BitDepth=25188]=`BitDepth`,e[e.SimpleBlock=163]=`SimpleBlock`,e[e.BlockGroup=160]=`BlockGroup`,e[e.Block=161]=`Block`,e[e.BlockAdditions=30113]=`BlockAdditions`,e[e.BlockMore=166]=`BlockMore`,e[e.BlockAdditional=165]=`BlockAdditional`,e[e.BlockAddID=238]=`BlockAddID`,e[e.BlockDuration=155]=`BlockDuration`,e[e.ReferenceBlock=251]=`ReferenceBlock`,e[e.Cluster=524531317]=`Cluster`,e[e.Timestamp=231]=`Timestamp`,e[e.Cues=475249515]=`Cues`,e[e.CuePoint=187]=`CuePoint`,e[e.CueTime=179]=`CueTime`,e[e.CueTrackPositions=183]=`CueTrackPositions`,e[e.CueTrack=247]=`CueTrack`,e[e.CueClusterPosition=241]=`CueClusterPosition`,e[e.CueRelativePosition=240]=`CueRelativePosition`,e[e.Colour=21936]=`Colour`,e[e.MatrixCoefficients=21937]=`MatrixCoefficients`,e[e.TransferCharacteristics=21946]=`TransferCharacteristics`,e[e.Primaries=21947]=`Primaries`,e[e.Range=21945]=`Range`,e[e.Projection=30320]=`Projection`,e[e.ProjectionType=30321]=`ProjectionType`,e[e.ProjectionPoseYaw=30323]=`ProjectionPoseYaw`,e[e.ProjectionPosePitch=30324]=`ProjectionPosePitch`,e[e.ProjectionPoseRoll=30325]=`ProjectionPoseRoll`,e[e.Attachments=423732329]=`Attachments`,e[e.AttachedFile=24999]=`AttachedFile`,e[e.FileDescription=18046]=`FileDescription`,e[e.FileName=18030]=`FileName`,e[e.FileMediaType=18016]=`FileMediaType`,e[e.FileData=18012]=`FileData`,e[e.FileUID=18094]=`FileUID`,e[e.Chapters=272869232]=`Chapters`,e[e.Tags=307544935]=`Tags`,e[e.Tag=29555]=`Tag`,e[e.Targets=25536]=`Targets`,e[e.TargetTypeValue=26826]=`TargetTypeValue`,e[e.TargetType=25546]=`TargetType`,e[e.TagTrackUID=25541]=`TagTrackUID`,e[e.TagEditionUID=25545]=`TagEditionUID`,e[e.TagChapterUID=25540]=`TagChapterUID`,e[e.TagAttachmentUID=25542]=`TagAttachmentUID`,e[e.SimpleTag=26568]=`SimpleTag`,e[e.TagName=17827]=`TagName`,e[e.TagLanguage=17530]=`TagLanguage`,e[e.TagString=17543]=`TagString`,e[e.TagBinary=17541]=`TagBinary`,e[e.ContentEncodings=28032]=`ContentEncodings`,e[e.ContentEncoding=25152]=`ContentEncoding`,e[e.ContentEncodingOrder=20529]=`ContentEncodingOrder`,e[e.ContentEncodingScope=20530]=`ContentEncodingScope`,e[e.ContentCompression=20532]=`ContentCompression`,e[e.ContentCompAlgo=16980]=`ContentCompAlgo`,e[e.ContentCompSettings=16981]=`ContentCompSettings`,e[e.ContentEncryption=20533]=`ContentEncryption`})(R||={});var io=[R.EBML,R.Segment],ao=[R.SeekHead,R.Info,R.Cluster,R.Tracks,R.Cues,R.Attachments,R.Chapters,R.Tags];[...io,...ao];var oo=e=>e<256?1:e<65536?2:e<1<<24?3:e<2**32?4:e<2**40?5:6,so=e=>e<1n<<8n?1:e<1n<<16n?2:e<1n<<24n?3:e<1n<<32n?4:e<1n<<40n?5:e<1n<<48n?6:e<1n<<56n?7:8,co=e=>e>=-64&&e<64?1:e>=-8192&&e<8192?2:e>=-1048576&&e<1<<20?3:e>=-134217728&&e<1<<27?4:e>=-(2**34)&&e<2**34?5:6,lo=e=>{if(e<127)return 1;if(e<16383)return 2;if(e<(1<<21)-1)return 3;if(e<(1<<28)-1)return 4;if(e<2**35-1)return 5;if(e<2**42-1)return 6;throw Error(`EBML varint size not supported `+e)},uo=class{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap,this.dataOffsets=new WeakMap}writeByte(e){this.helperView.setUint8(0,e),this.writer.write(this.helper.subarray(0,1))}writeFloat32(e){this.helperView.setFloat32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeFloat64(e){this.helperView.setFloat64(0,e,!1),this.writer.write(this.helper)}writeUnsignedInt(e,t=oo(e)){let n=0;switch(t){case 6:this.helperView.setUint8(n++,e/2**40|0);case 5:this.helperView.setUint8(n++,e/2**32|0);case 4:this.helperView.setUint8(n++,e>>24);case 3:this.helperView.setUint8(n++,e>>16);case 2:this.helperView.setUint8(n++,e>>8);case 1:this.helperView.setUint8(n++,e);break;default:throw Error(`Bad unsigned int size `+t)}this.writer.write(this.helper.subarray(0,n))}writeUnsignedBigInt(e,t=so(e)){let n=0;for(let r=t-1;r>=0;r--)this.helperView.setUint8(n++,Number(e>>BigInt(r*8)&255n));this.writer.write(this.helper.subarray(0,n))}writeSignedInt(e,t=co(e)){e<0&&(e+=2**(t*8)),this.writeUnsignedInt(e,t)}writeVarInt(e,t=lo(e)){let n=0;switch(t){case 1:this.helperView.setUint8(n++,128|e);break;case 2:this.helperView.setUint8(n++,64|e>>8),this.helperView.setUint8(n++,e);break;case 3:this.helperView.setUint8(n++,32|e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 4:this.helperView.setUint8(n++,16|e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 5:this.helperView.setUint8(n++,8|e/2**32&7),this.helperView.setUint8(n++,e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 6:this.helperView.setUint8(n++,4|e/2**40&3),this.helperView.setUint8(n++,e/2**32|0),this.helperView.setUint8(n++,e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;default:throw Error(`Bad EBML varint size `+t)}this.writer.write(this.helper.subarray(0,n))}writeAsciiString(e){this.writer.write(new Uint8Array(e.split(``).map(e=>e.charCodeAt(0))))}writeEBML(e){if(e!==null){if(e instanceof Uint8Array)this.writer.write(e);else if(Array.isArray(e))for(let t of e)this.writeEBML(t);else if(this.offsets.set(e,this.writer.getPos()),this.writeUnsignedInt(e.id),Array.isArray(e.data)){let t=this.writer.getPos(),n=e.size===-1?1:e.size??4;e.size===-1?this.writeByte(255):this.writer.seek(this.writer.getPos()+n);let r=this.writer.getPos();if(this.dataOffsets.set(e,r),this.writeEBML(e.data),e.size!==-1){let e=this.writer.getPos()-r,i=this.writer.getPos();this.writer.seek(t),this.writeVarInt(e,n),this.writer.seek(i)}}else if(typeof e.data==`number`){let t=e.size??oo(e.data);this.writeVarInt(t),this.writeUnsignedInt(e.data,t)}else if(typeof e.data==`bigint`){let t=e.size??so(e.data);this.writeVarInt(t),this.writeUnsignedBigInt(e.data,t)}else if(typeof e.data==`string`)this.writeVarInt(e.data.length),this.writeAsciiString(e.data);else if(e.data instanceof Uint8Array)this.writeVarInt(e.data.byteLength,e.size),this.writer.write(e.data);else if(e.data instanceof eo)this.writeVarInt(4),this.writeFloat32(e.data.value);else if(e.data instanceof to)this.writeVarInt(8),this.writeFloat64(e.data.value);else if(e.data instanceof no){let t=e.size??co(e.data.value);this.writeVarInt(t),this.writeSignedInt(e.data.value,t)}else if(e.data instanceof ro){let t=Kn.encode(e.data.value);this.writeVarInt(t.length),this.writer.write(t)}else rr(e.data)}}},fo=Date.UTC(2001,0,1),po={avc:`V_MPEG4/ISO/AVC`,hevc:`V_MPEGH/ISO/HEVC`,vp8:`V_VP8`,vp9:`V_VP9`,av1:`V_AV1`,prores:`V_PRORES`,aac:`A_AAC`,mp3:`A_MPEG/L3`,opus:`A_OPUS`,vorbis:`A_VORBIS`,flac:`A_FLAC`,ac3:`A_AC3`,eac3:`A_EAC3`,dts:`A_DTS`,truehd:`A_TRUEHD`,"pcm-u8":`A_PCM/INT/LIT`,"pcm-s16":`A_PCM/INT/LIT`,"pcm-s16be":`A_PCM/INT/BIG`,"pcm-s24":`A_PCM/INT/LIT`,"pcm-s24be":`A_PCM/INT/BIG`,"pcm-s32":`A_PCM/INT/LIT`,"pcm-s32be":`A_PCM/INT/BIG`,"pcm-f32":`A_PCM/FLOAT/IEEE`,"pcm-f64":`A_PCM/FLOAT/IEEE`,webvtt:`S_TEXT/WEBVTT`},mo=e=>{let t=(e.hasVideo?`video/`:e.hasAudio?`audio/`:`application/`)+(e.isWebM?`webm`:`x-matroska`);if(e.codecStrings.length>0){let n=[...new Set(e.codecStrings.filter(Boolean))];t+=`; codecs="${n.join(`, `)}"`}return t},ho=e=>{let t=e.filePos;if(e.remainingLength<7)return null;let n=new qr(yo(e,7));if(n.readBits(12)!==4095||(n.skipBits(1),n.readBits(2)!==0))return null;let r=n.readBits(1),i=n.readBits(2)+1,a=n.readBits(4);if(a>=Jr.length)return null;n.skipBits(1);let o=n.readBits(3);if(o===0)throw Error(`ADTS frames with channel configuration 0 are not supported.`);n.skipBits(1),n.skipBits(1),n.skipBits(1),n.skipBits(1);let s=n.readBits(13);n.skipBits(11);let c=n.readBits(2)+1;if(c!==1)throw Error(`ADTS frames with more than one AAC frame are not supported.`);let l=null;if(r===0){if(e.remainingLength<2)return null;l=bo(e)}return s<e.filePos-t?null:{objectType:i,samplingFrequencyIndex:a,channelConfiguration:o,frameLength:s,numberOfAacFrames:c,crcCheck:l,startPos:t}},go=t(((e,t)=>{t.exports={}})),_o=class e{constructor(e,t,n,r,i){this.bytes=e,this.view=t,this.offset=n,this.start=r,this.end=i,this.bufferPos=r-n}static tempFromBytes(t){return new e(t,Wn(t),0,0,t.length)}get length(){return this.end-this.start}get filePos(){return this.offset+this.bufferPos}set filePos(e){this.bufferPos=e-this.offset}get remainingLength(){return Math.max(this.end-this.filePos,0)}skip(e){this.bufferPos+=e}slice(t,n=this.end-t){if(t<this.start||t+n>this.end)throw RangeError(`Slicing outside of original slice.`);return new e(this.bytes,this.view,this.offset,t,t+n)}},vo=(e,t)=>{if(t<0||e.filePos<e.start||e.filePos+t>e.end)throw RangeError(`Tried reading [${e.filePos}, ${e.filePos+t}), but slice is [${e.start}, ${e.end}). This is likely an internal error, please report it alongside the file that caused it.`)},yo=(e,t)=>{vo(e,t);let n=e.bytes.subarray(e.bufferPos,e.bufferPos+t);return e.bufferPos+=t,n},bo=e=>{vo(e,2);let t=e.view.getUint16(e.bufferPos,!1);return e.bufferPos+=2,t},xo=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},So=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Co=class{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._nominalBitrate=null}_ensureValidAdd(){if(!this._connectedTrack)throw Error(`Source is not connected to an output track.`);if(this._connectedTrack.output.state===`canceled`)throw Error(`Output has been canceled.`);if(this._connectedTrack.output.state===`finalizing`||this._connectedTrack.output.state===`finalized`)throw Error(`Output has been finalized.`);if(this._connectedTrack.output.state===`pending`)throw Error(`Output has not started.`);if(this._closed)throw Error(`Source is closed.`)}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;let e=this._connectedTrack;if(!e)throw Error(`Cannot call close without connecting the source to an output track.`);if(e.output.state===`pending`)throw Error(`Cannot call close before output has been started.`);this._closingPromise=(async()=>{await this._flushAndClose(!1),this._closed=!0,e.output.state!==`finalizing`&&e.output.state!==`finalized`&&e.output._muxer.onTrackClose(e)})()}async _flushOrWaitForOngoingClose(e){return this._closingPromise??=(async()=>{await this._flushAndClose(e),this._closed=!0})()}},wo=class extends Co{constructor(e){if(super(),!Fo.includes(e))throw TypeError(`Invalid video codec '${e}'. Must be one of: ${Fo.join(`, `)}.`);this._codec=e}},To=(e,t)=>{if(e.metadata.hasOnlyKeyPackets&&t.type!==`key`)throw Error(`Cannot add non-key packets to a hasOnlyKeyPackets video track.`)},Eo=class{setError(e){this.errorSet||=(this.error=e,!0)}constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.encoderConfig=null,this.encodersReclaimed=!1,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.emittedEncoderPackets=0,this.chunkTimestampsAreShiftedByDuration=!1,this.codedWidth=null,this.codedHeight=null,this.outputWidth=null,this.outputHeight=null,this.frameRateLastSample=null,this.frameRateLastTimestamp=null,this.frameRateLastEndTimestamp=null,this.preciseTimings=[],this.customEncoder=null,this.customEncoderCallSerializer=new gr,this.customEncoderQueueSize=0,this.defaultEncodeOptions={},this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null,this.errorSet=!1,this.lastMuxerPromise=Promise.resolve(),this.closed=!1}async add(e,t,n){let r=e;try{this.checkForEncoderError(),this.source._ensureValidAdd();let i=this.encodingConfig,a=i.sizeChangeBehavior??`deny`,o=!1;if(this.codedWidth!==null&&this.codedHeight!==null){if((e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight)&&(o=!0,a===`deny`))throw Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${e.codedWidth}x${e.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'deny' in the encoding options.`)}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;if(i.transform?.width!==void 0||i.transform?.height!==void 0||i.transform?.rotate!==void 0||i.transform?.flip!==void 0||i.transform?.crop!==void 0||i.transform?.force===!0||o&&a!==`passThrough`){let n=i.transform?.width,r=i.transform?.height,s=i.transform?.fit??`fill`;o&&a!==`passThrough`&&(F(this.outputWidth),F(this.outputHeight),F(a!==`deny`),n=this.outputWidth,r=this.outputHeight,s=a);let c=await e.transform({width:n,height:r,roundDimensionsTo:2,crop:i.transform?.crop,rotate:i.transform?.rotate,flip:i.transform?.flip,fit:s,alpha:i.alpha});(this.outputWidth===null||this.outputHeight===null)&&(this.outputWidth=c.displayWidth,this.outputHeight=c.displayHeight),t&&e.close(),e=c,t=!0}else(this.outputWidth===null||this.outputHeight===null)&&(this.outputWidth=e.codedWidth,this.outputHeight=e.codedHeight);let s=i.transform?.frameRate;if(s!==void 0){let i=e.timestamp+e.duration,a=ur(e.timestamp,s);if(this.frameRateLastSample!==null){if(a<=this.frameRateLastTimestamp){this.frameRateLastSample.close(),this.frameRateLastSample=e.clone(),this.frameRateLastEndTimestamp=i;return}await this.padFrameRate(a,n)}e===r&&(e=e.clone(),t=!0),e.setTimestamp(a),e.setDuration(1/s),this.frameRateLastSample?.close(),this.frameRateLastSample=e.clone(),this.frameRateLastTimestamp=a,this.frameRateLastEndTimestamp=i}await this.processAndEncode(e,n)}finally{t&&e.close()}}async processAndEncode(e,t){let n=this.encodingConfig,r;if(n.transform?.process){let t=n.transform.process(e);if(Or(t)&&(t=await t),t===null)return;Array.isArray(t)||(t=[t]);let i=[];try{for(let n of t)n instanceof ya?i.push(n):typeof VideoFrame<`u`&&n instanceof VideoFrame?i.push(new ya(n)):i.push(new ya(n,{timestamp:e.timestamp,duration:e.duration}))}catch(n){for(let t of i)t!==e&&t.close();for(let n of t)(n instanceof ya&&n!==e||typeof VideoFrame<`u`&&n instanceof VideoFrame)&&n.close();throw n}r=i}else r=[e];try{for(let e of r){if(this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),F(this.encoderInitialized),this.closed)break;this.encodersReclaimed&&this.recreateWebCodecsEncoders();let n=this.encodingConfig.keyFrameInterval??2,r=Math.floor(e.timestamp/n),i={...this.defaultEncodeOptions,...e.encodeOptions,...t},a={...i,keyFrame:i.keyFrame===void 0?n===0||r!==this.lastMultipleOfKeyFrameInterval:i.keyFrame};if(this.lastMultipleOfKeyFrameInterval=r,this.encodingConfig.onEncodedSample?.(e),this.customEncoder){this.customEncoderQueueSize++;let t=e.clone(),n=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(t,a)).catch(e=>this.setError(e)).finally(()=>{this.customEncoderQueueSize--,t.close()});this.customEncoderQueueSize>=4&&await n}else{F(this.encoder);let t=e.toVideoFrame(),n=tr(this.preciseTimings,t.timestamp,e=>e.microsecondTimestamp),r=n===-1?null:this.preciseTimings[n];if(r&&r.microsecondTimestamp===t.timestamp?(r.timestamp!==e.timestamp&&(r.timestampIsValid=!1),r.duration!==e.duration&&(r.durationIsValid=!1)):(this.preciseTimings.splice(n+1,0,{microsecondTimestamp:t.timestamp,timestamp:e.timestamp,duration:e.duration,timestampIsValid:!0,durationIsValid:!0}),this.preciseTimings.length>128&&this.preciseTimings.shift()),!this.alphaEncoder)try{this.encoder.encode(t,a)}finally{t.close()}else if(t.format&&!t.format.includes(`A`)||this.splitterCreationFailed){this.alphaFrameQueue.push(null);try{this.encoder.encode(t,a)}finally{t.close()}}else{this.splitter||=new Ao;let{colorFrame:e,alphaFrame:n}=await this.splitter.split(t);this.alphaFrameQueue.push(n);try{this.encoder.encode(e,a)}finally{e.close()}}this.encoder.encodeQueueSize>=4&&await new Promise(e=>this.encoder.addEventListener(`dequeue`,e,{once:!0}))}await this.lastMuxerPromise}}finally{for(let t of r)t!==e&&t.close()}}async padFrameRate(e,t){let n=this.encodingConfig.transform.frameRate;F(this.frameRateLastSample);let r=Math.round((e-this.frameRateLastTimestamp)*n);for(let e=1;e<r;e++){let r={stack:[],error:void 0,hasError:!1};try{let i=xo(r,this.frameRateLastSample.clone(),!1);i.setTimestamp(this.frameRateLastTimestamp+e/n),i.setDuration(1/n),await this.processAndEncode(i,t)}catch(e){r.error=e,r.hasError=!0}finally{So(r)}}}ensureEncoder(e){this.ensureEncoderPromise=(async()=>{let t=Ja(this.encodingConfig.quality,this.encodingConfig.bitrate);F(t!==void 0);let n=za({...this.encodingConfig,quality:t,width:e.codedWidth,height:e.codedHeight,squarePixelWidth:e.squarePixelWidth,squarePixelHeight:e.squarePixelHeight,framerate:this.source._connectedTrack?.metadata.frameRate}),r=null,i;for(let e of n){let t=e.config;if(this.encodingConfig.onEncoderConfig?.(t),i=Ya.find(e=>e.supports(this.encodingConfig.codec,t)),i){r=e;break}if(typeof VideoEncoder<`u`){if(t.alpha=`discard`,this.encodingConfig.alpha===`keep`&&(t.latencyMode=`quality`),(t.width%2==1||t.height%2==1)&&(this.encodingConfig.codec===`avc`||this.encodingConfig.codec===`hevc`))throw Error(`The dimensions ${t.width}x${t.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);try{if((await VideoEncoder.isConfigSupported(t)).supported){r=e;break}}catch{}}}if(!r){if(typeof VideoEncoder>`u`)throw Error(Tr(`VideoEncoder`));let e=n[0].config,t=n.map(({config:e,quantizer:t})=>t===null?`${e.bitrate} bps`:`quantizer ${t}`);throw Error(`This specific encoder configuration (${e.codec}, ${t.join(` / `)}, ${e.width}x${e.height}, hardware acceleration: ${e.hardwareAcceleration??`no-preference`}) is not supported in this environment. Consider using another codec or changing your video parameters.`)}let a=r.config;r.quantizer===null?this.source._nominalBitrate=a.bitrate??null:this.defaultEncodeOptions=Ga(this.encodingConfig.codec,r.quantizer),i?(this.customEncoder=new i,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=a,this.customEncoder.onPacket=(e,t)=>{if(!(e instanceof Za))throw TypeError(`The first argument passed to onPacket must be an EncodedPacket.`);if(t!==void 0&&(!t||typeof t!=`object`))throw TypeError(`The second argument passed to onPacket must be an object or undefined.`);To(this.source._connectedTrack,e),this.encodingConfig.onEncodedPacket?.(e,t),this.lastMuxerPromise=this.muxer.addEncodedVideoPacket(this.source._connectedTrack,e,t).catch(e=>{this.setError(e)})},this.customEncoder.onError=e=>{this.setError(e)},await this.customEncoder.init()):(this.encoderConfig=a,this.encodingConfig.codec===`avc`&&br()&&(this.chunkTimestampsAreShiftedByDuration=await Oo()),this.createWebCodecsEncoders()),F(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}createWebCodecsEncoders(){let e=this.encoderConfig;F(e);let t=[],n=[],r=0,i=0,a=(e,t)=>{Er(e)?this.encodersReclaimed=!0:(e.stack=t,this.setError(e))},o=Error(`Encoding error`).stack;if(this.encoder=new VideoEncoder({output:(e,a)=>{if(!this.alphaEncoder){this.addPacket(e,null,a);return}let o=this.alphaFrameQueue.shift();F(o!==void 0),o?(this.alphaEncoder.encode(o,{...this.defaultEncodeOptions,keyFrame:e.type===`key`}),i++,o.close(),t.push({chunk:e,meta:a})):i===0?this.addPacket(e,null,a):(n.push(r+i),t.push({chunk:e,meta:a}))},error:e=>a(e,o)}),this.encoder.configure(e),this.encodingConfig.alpha===`keep`){let o=Error(`Encoding error`).stack;this.alphaEncoder=new VideoEncoder({output:(e,a)=>{i--;let o=t.shift();for(F(o!==void 0),this.addPacket(o.chunk,e,o.meta),r++;n.length>0&&n[0]===r;){n.shift();let e=t.shift();F(e!==void 0),this.addPacket(e.chunk,null,e.meta)}},error:e=>a(e,o)}),this.alphaEncoder.configure(e)}}addPacket(e,t,n){let r={};if(t){let e=new Uint8Array(t.byteLength);t.copyTo(e),r.alpha=e}let i=Za.fromEncodedChunk(e,r),a=this.encoderConfig;if(F(a),n?.decoderConfig&&(n.decoderConfig.codec=Zo({width:a.width,height:a.height,codec:this.encodingConfig.codec,codecDescription:n.decoderConfig.description?Un(n.decoderConfig.description):null,colorSpace:n.decoderConfig.colorSpace??null,avcType:a.codec.includes(`avc1.`)?1:a.codec.includes(`avc3.`)?3:null,avcCodecInfo:this.encodingConfig.codec===`avc`&&!n.decoderConfig.description?hi(i.data):null,hevcCodecInfo:this.encodingConfig.codec===`hevc`&&!n.decoderConfig.description?wi(i.data):null,vp9CodecInfo:this.encodingConfig.codec===`vp9`?Fi(i.data):null,av1CodecInfo:this.encodingConfig.codec===`av1`?Li(i.data):null,proresFormat:null}),this.encodingConfig.codec===`avc`&&n.decoderConfig.description&&br())){let e=_i(Un(n.decoderConfig.description)),t=e?.sequenceParameterSets[0];if(t&&t[0]===t[1]){F(e),t=t.subarray(1);let r=e.pictureParameterSets[0];r&&=r.subarray(1);let i=gi({...e,sequenceParameterSets:[t],pictureParameterSets:r?[r]:[]});n.decoderConfig.description=i}}let o=e.timestamp;this.chunkTimestampsAreShiftedByDuration&&(o-=e.duration??0,i=i.clone({timestamp:o/1e6}));let s=tr(this.preciseTimings,o,e=>e.microsecondTimestamp),c=s===-1?null:this.preciseTimings[s],l=null;this.emittedEncoderPackets===0&&i.type===`delta`&&n?.decoderConfig&&(l=Hi(this.encodingConfig.codec,n.decoderConfig,i.data)),(c&&c.microsecondTimestamp===o||l!==null)&&(i=i.clone({timestamp:c?.timestampIsValid?c.timestamp:void 0,duration:c?.durationIsValid?c.duration:void 0,type:l??void 0})),To(this.source._connectedTrack,i),this.encodingConfig.onEncodedPacket?.(i,n),this.lastMuxerPromise=this.muxer.addEncodedVideoPacket(this.source._connectedTrack,i,n).catch(e=>{this.setError(e)}),this.emittedEncoderPackets++}recreateWebCodecsEncoders(){F(this.encoder),this.encoder.state!==`closed`&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!==`closed`&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(e=>e?.close()),this.alphaFrameQueue.length=0,this.encodersReclaimed=!1,this.lastMultipleOfKeyFrameInterval=-1,this.createWebCodecsEncoders()}async flushAndClose(e){try{if(!e&&(this.checkForEncoderError(),this.frameRateLastSample)){let e=this.encodingConfig.transform.frameRate,t=ur(this.frameRateLastEndTimestamp,e);await this.padFrameRate(t)}this.closed=!0,e||(this.customEncoder?this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()):this.encoder&&!this.encodersReclaimed&&(await this.encoder.flush(),await this.alphaEncoder?.flush(),await Lr(25)))}finally{this.closed=!0,this.frameRateLastSample?.close(),this.frameRateLastSample=null,this.customEncoder?await this.customEncoderCallSerializer.call(()=>this.customEncoder.close()).catch(e=>this.setError(e)):this.encoder&&(this.encoder.state!==`closed`&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!==`closed`&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(e=>e?.close()),this.alphaFrameQueue.length=0,this.splitter?.close())}e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.errorSet)throw this.error}},Do=null,Oo=()=>Do??=(async()=>{let e=null,t=new VideoEncoder({output:t=>{e??=t.timestamp},error:()=>{}});try{t.configure({codec:`avc1.64001f`,width:1280,height:720});let e=new VideoFrame(new Uint8Array(1382400),{format:`I420`,codedWidth:1280,codedHeight:720,timestamp:0,duration:500});t.encode(e,{keyFrame:!0}),e.close(),await t.flush()}catch{return!1}finally{t.state!==`closed`&&t.close()}return e===500})(),ko=null,Ao=class{constructor(){this.worker=null,this.pendingRequests=new Map,this.nextRequestId=0}split(e){if(!this.worker){if(!ko){let e=new Blob([`(${jo.toString()})()`],{type:`application/javascript`});ko=URL.createObjectURL(e)}this.worker=new Worker(ko),this.worker.addEventListener(`message`,e=>{let t=e.data,n=this.pendingRequests.get(t.id);n&&(this.pendingRequests.delete(t.id),`error`in t?n.reject(Error(t.error)):n.resolve({colorFrame:t.colorFrame,alphaFrame:t.alphaFrame}))}),this.worker.addEventListener(`error`,e=>{let t=Error(e.message||`Color/alpha splitter worker error.`);for(let e of this.pendingRequests.values())e.reject(t);this.pendingRequests.clear()})}let t=this.nextRequestId++,n=nr();return this.pendingRequests.set(t,n),this.worker.postMessage({id:t,sourceFrame:e},{transfer:[e]}),n.promise}close(){this.worker?.terminate(),this.worker=null;let e=Error(`Color/alpha splitter closed.`);for(let t of this.pendingRequests.values())t.reject(e);this.pendingRequests.clear()}},jo=()=>{let e=null,t=Promise.resolve();self.addEventListener(`message`,e=>{let{id:r,sourceFrame:i}=e.data;t=t.then(async()=>{try{let{colorFrame:e,alphaFrame:t}=await n(i);self.postMessage({id:r,colorFrame:e,alphaFrame:t},{transfer:[e,t]})}catch(e){self.postMessage({id:r,error:e.message})}finally{i.close()}})});let n=async t=>{let n=t.format;if(!n)throw Error(`CPU color/alpha splitting requires a known VideoFrame format.`);let a=t.allocationSize();if(e&&e.byteLength===a||(e=new Uint8Array(a)),await t.copyTo(e),n===`RGBA`||n===`BGRA`)return r(e,n,t);if(n===`I420A`||n===`I420AP10`||n===`I420AP12`||n===`I422A`||n===`I422AP10`||n===`I422AP12`||n===`I444A`||n===`I444AP10`||n===`I444AP12`)return i(e,n,t);throw Error(`CPU color/alpha splitting does not support format '${n}'.`)},r=(e,t,n)=>{let r=n.visibleRect?.width??n.codedWidth,i=n.visibleRect?.height??n.codedHeight,a=r*i,o=a+Math.ceil(r/2)*Math.ceil(i/2)*2,s=new Uint8Array(o);for(let t=0,n=3;t<a;t++,n+=4)s[t]=e[n];s.fill(128,a);let c=new VideoFrame(e,{format:t===`RGBA`?`RGBX`:`BGRX`,codedWidth:r,codedHeight:i,timestamp:n.timestamp,duration:n.duration??void 0}),l={format:`I420`,codedWidth:r,codedHeight:i,timestamp:n.timestamp,duration:n.duration??void 0,colorSpace:{fullRange:!0,matrix:`bt709`,primaries:`bt709`,transfer:`bt709`},transfer:[s.buffer]};return{colorFrame:c,alphaFrame:new VideoFrame(s,l)}},i=(e,t,n)=>{let r=n.visibleRect?.width??n.codedWidth,i=n.visibleRect?.height??n.codedHeight,a=t.includes(`P10`),o=t.includes(`P12`),s=a||o?2:1,c,l;t.startsWith(`I420`)?(c=Math.ceil(r/2),l=Math.ceil(i/2)):t.startsWith(`I422`)?(c=Math.ceil(r/2),l=i):(c=r,l=i);let u=r*i,d=c*l,f=u*s,p=d*s,m=u*s,h=f+p*2,g=t.replace(`A`,``),_=Math.ceil(r/2)*Math.ceil(i/2),v=m+_*s*2,y=new Uint8Array(v),b=h;y.set(e.subarray(b,b+m),0);let x=m,S=a?512:o?2048:128;s===1?y.fill(S,x):new Uint16Array(y.buffer,x,2*_).fill(S);let C=a?`I420P10`:o?`I420P12`:`I420`,w=new VideoFrame(e.subarray(0,h),{format:g,codedWidth:r,codedHeight:i,timestamp:n.timestamp,duration:n.duration??void 0}),T={format:C,codedWidth:r,codedHeight:i,timestamp:n.timestamp,duration:n.duration??void 0,colorSpace:{fullRange:!0,matrix:`bt709`,primaries:`bt709`,transfer:`bt709`},transfer:[y.buffer]};return{colorFrame:w,alphaFrame:new VideoFrame(y,T)}}},Mo=class extends wo{constructor(e,t){if(!(typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas))throw TypeError(`canvas must be an HTMLCanvasElement or OffscreenCanvas.`);La(t),super(t.codec),this._encoder=new Eo(this,t),this._canvas=e}add(e,t=0,n){if(!Number.isFinite(e))throw TypeError(`timestamp must be a finite number.`);if(!Number.isFinite(t)||t<0)throw TypeError(`duration must be a non-negative number.`);let r=new ya(this._canvas,{timestamp:e,duration:t});return this._encoder.add(r,!0,n)}_flushAndClose(e){return this._encoder.flushAndClose(e)}},No=class extends Co{constructor(e){if(super(),!Ro.includes(e))throw TypeError(`Invalid audio codec '${e}'. Must be one of: ${Ro.join(`, `)}.`);this._codec=e}},Po=class extends Co{constructor(e){if(super(),!zo.includes(e))throw TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${zo.join(`, `)}.`);this._codec=e}},Fo=[`avc`,`hevc`,`vp9`,`av1`,`vp8`,`prores`],Io=[`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,`pcm-u8`,`pcm-s8`,`ulaw`,`alaw`],Lo=[`aac`,`opus`,`mp3`,`vorbis`,`flac`,`ac3`,`eac3`,`dts`,`truehd`],Ro=[...Lo,...Io],zo=[`webvtt`],Bo=[{maxMacroblocks:99,maxBitrate:64e3,maxDpbMbs:396,level:10},{maxMacroblocks:396,maxBitrate:192e3,maxDpbMbs:900,level:11},{maxMacroblocks:396,maxBitrate:384e3,maxDpbMbs:2376,level:12},{maxMacroblocks:396,maxBitrate:768e3,maxDpbMbs:2376,level:13},{maxMacroblocks:396,maxBitrate:2e6,maxDpbMbs:2376,level:20},{maxMacroblocks:792,maxBitrate:4e6,maxDpbMbs:4752,level:21},{maxMacroblocks:1620,maxBitrate:4e6,maxDpbMbs:8100,level:22},{maxMacroblocks:1620,maxBitrate:1e7,maxDpbMbs:8100,level:30},{maxMacroblocks:3600,maxBitrate:14e6,maxDpbMbs:18e3,level:31},{maxMacroblocks:5120,maxBitrate:2e7,maxDpbMbs:20480,level:32},{maxMacroblocks:8192,maxBitrate:2e7,maxDpbMbs:32768,level:40},{maxMacroblocks:8192,maxBitrate:5e7,maxDpbMbs:32768,level:41},{maxMacroblocks:8704,maxBitrate:5e7,maxDpbMbs:34816,level:42},{maxMacroblocks:22080,maxBitrate:135e6,maxDpbMbs:110400,level:50},{maxMacroblocks:36864,maxBitrate:24e7,maxDpbMbs:184320,level:51},{maxMacroblocks:36864,maxBitrate:24e7,maxDpbMbs:184320,level:52},{maxMacroblocks:139264,maxBitrate:24e7,maxDpbMbs:696320,level:60},{maxMacroblocks:139264,maxBitrate:48e7,maxDpbMbs:696320,level:61},{maxMacroblocks:139264,maxBitrate:8e8,maxDpbMbs:696320,level:62}],Vo=[{maxPictureSize:36864,maxBitrate:128e3,tier:`L`,level:30},{maxPictureSize:122880,maxBitrate:15e5,tier:`L`,level:60},{maxPictureSize:245760,maxBitrate:3e6,tier:`L`,level:63},{maxPictureSize:552960,maxBitrate:6e6,tier:`L`,level:90},{maxPictureSize:983040,maxBitrate:1e7,tier:`L`,level:93},{maxPictureSize:2228224,maxBitrate:12e6,tier:`L`,level:120},{maxPictureSize:2228224,maxBitrate:3e7,tier:`H`,level:120},{maxPictureSize:2228224,maxBitrate:2e7,tier:`L`,level:123},{maxPictureSize:2228224,maxBitrate:5e7,tier:`H`,level:123},{maxPictureSize:8912896,maxBitrate:25e6,tier:`L`,level:150},{maxPictureSize:8912896,maxBitrate:1e8,tier:`H`,level:150},{maxPictureSize:8912896,maxBitrate:4e7,tier:`L`,level:153},{maxPictureSize:8912896,maxBitrate:16e7,tier:`H`,level:153},{maxPictureSize:8912896,maxBitrate:6e7,tier:`L`,level:156},{maxPictureSize:8912896,maxBitrate:24e7,tier:`H`,level:156},{maxPictureSize:35651584,maxBitrate:6e7,tier:`L`,level:180},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:180},{maxPictureSize:35651584,maxBitrate:12e7,tier:`L`,level:183},{maxPictureSize:35651584,maxBitrate:48e7,tier:`H`,level:183},{maxPictureSize:35651584,maxBitrate:24e7,tier:`L`,level:186},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:186}],z=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}],Ho=[{maxPictureSize:147456,maxBitrate:15e5,tier:`M`,level:0},{maxPictureSize:278784,maxBitrate:3e6,tier:`M`,level:1},{maxPictureSize:665856,maxBitrate:6e6,tier:`M`,level:4},{maxPictureSize:1065024,maxBitrate:1e7,tier:`M`,level:5},{maxPictureSize:2359296,maxBitrate:12e6,tier:`M`,level:8},{maxPictureSize:2359296,maxBitrate:3e7,tier:`H`,level:8},{maxPictureSize:2359296,maxBitrate:2e7,tier:`M`,level:9},{maxPictureSize:2359296,maxBitrate:5e7,tier:`H`,level:9},{maxPictureSize:8912896,maxBitrate:3e7,tier:`M`,level:12},{maxPictureSize:8912896,maxBitrate:1e8,tier:`H`,level:12},{maxPictureSize:8912896,maxBitrate:4e7,tier:`M`,level:13},{maxPictureSize:8912896,maxBitrate:16e7,tier:`H`,level:13},{maxPictureSize:8912896,maxBitrate:6e7,tier:`M`,level:14},{maxPictureSize:8912896,maxBitrate:24e7,tier:`H`,level:14},{maxPictureSize:35651584,maxBitrate:6e7,tier:`M`,level:15},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:15},{maxPictureSize:35651584,maxBitrate:6e7,tier:`M`,level:16},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:16},{maxPictureSize:35651584,maxBitrate:1e8,tier:`M`,level:17},{maxPictureSize:35651584,maxBitrate:48e7,tier:`H`,level:17},{maxPictureSize:35651584,maxBitrate:16e7,tier:`M`,level:18},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:18},{maxPictureSize:35651584,maxBitrate:16e7,tier:`M`,level:19},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:19}],Uo=`.01.01.01.01.00`,Wo=`.0.110.01.01.01.0`,Go=[`ap4x`,`ap4h`,`apch`,`apcn`,`apcs`,`apco`],Ko=[`dtsc`,`dtsh`,`dtsl`,`dtse`],qo=[{fourCc:`apco`,bitrate:45e6,alpha:!1},{fourCc:`apcs`,bitrate:102e6,alpha:!1},{fourCc:`apcn`,bitrate:147e6,alpha:!1},{fourCc:`apch`,bitrate:22e7,alpha:!1},{fourCc:`ap4h`,bitrate:33e7,alpha:!0},{fourCc:`ap4x`,bitrate:5e8,alpha:!0}],Jo=(e,t,n,r,i)=>{if(e===`avc`){let e=vr(),i=e?66:100,a=Math.ceil(t/16)*Math.ceil(n/16),o=Bo.find(e=>a<=e.maxMacroblocks&&r<=e.maxBitrate)??Rn(Bo),s=o?o.level:0;return`avc1.${i.toString(16).padStart(2,`0`)}${e?`40`:`00`}${s.toString(16).padStart(2,`0`)}`}if(e===`hevc`){let e=t*n,i=Vo.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??Rn(Vo);return`hev1.1.6.${i.tier}${i.level}.B0`}if(e===`vp8`)return`vp8`;if(e===`vp9`){let e=t*n;return`vp09.00.${(z.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??Rn(z)).level.toString().padStart(2,`0`)}.08`}if(e===`av1`){let e=t*n,i=Ho.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??Rn(Ho);return`av01.0.${i.level.toString().padStart(2,`0`)}${i.tier}.08`}if(e===`prores`){let e=(t*n/2073600)**.95,a=qo.filter(e=>e.alpha===i),o=a[0].fourCc,s=1/0;for(let{fourCc:t,bitrate:n}of a){let i=Math.abs(n*e-r);i<s&&(s=i,o=t)}return o}throw rr(e),TypeError(`Unhandled codec '${String(e)}'.`)},Yo=e=>{let t=e.split(`.`);return[1,1,Number(t[1]),2,1,Number(t[2]),3,1,Number(t[3]),4,1,t[4]?Number(t[4]):1]},Xo=e=>{let t=e.split(`.`),n=Number(t[1]),r=t[2],i=Number(r.slice(0,-1)),a=(n<<5)+i,o=+(r.slice(-1)===`H`),s=Number(t[3]),c=s===8?0:1,l=+(s===12),u=t[4]?Number(t[4]):0,d=t[5]?Number(t[5][0]):1,f=t[5]?Number(t[5][1]):1,p=t[5]?Number(t[5][2]):0;return[129,a,(o<<7)+(c<<6)+(l<<5)+(u<<4)+(d<<3)+(f<<2)+p,0]},Zo=e=>{let{codec:t,codecDescription:n,colorSpace:r,avcCodecInfo:i,hevcCodecInfo:a,vp9CodecInfo:o,av1CodecInfo:s,proresFormat:c}=e;if(t===`avc`){if(F(e.avcType!==null),i){let t=new Uint8Array([i.avcProfileIndication,i.profileCompatibility,i.avcLevelIndication]);return`avc${e.avcType}.${$n(t)}`}if(!n||n.byteLength<4)throw TypeError(`AVC decoder description is not provided or is not at least 4 bytes long.`);return`avc${e.avcType}.${$n(n.subarray(1,4))}`}if(t===`hevc`){let e,t,r,i,o,s;if(a)e=a.generalProfileSpace,t=a.generalProfileIdc,r=er(a.generalProfileCompatibilityFlags),i=a.generalTierFlag,o=a.generalLevelIdc,s=[...a.generalConstraintIndicatorFlags];else{if(!n||n.byteLength<23)throw TypeError(`HEVC decoder description is not provided or is not at least 23 bytes long.`);let a=Wn(n),c=a.getUint8(1);e=c>>6&3,t=c&31,r=er(a.getUint32(2)),i=c>>5&1,o=a.getUint8(12),s=[];for(let e=0;e<6;e++)s.push(a.getUint8(6+e))}let c=`hev1.`;for(c+=[``,`A`,`B`,`C`][e]+t,c+=`.`,c+=r.toString(16).toUpperCase(),c+=`.`,c+=i===0?`L`:`H`,c+=o;s.length>0&&s[s.length-1]===0;)s.pop();return s.length>0&&(c+=`.`,c+=s.map(e=>e.toString(16).toUpperCase()).join(`.`)),c}if(t===`vp8`)return`vp8`;if(t===`vp9`){if(!o){let t=e.width*e.height,n=Rn(z).level;for(let e of z)if(t<=e.maxPictureSize){n=e.level;break}return`vp09.00.${n.toString().padStart(2,`0`)}.08`}let t=o.profile.toString().padStart(2,`0`),n=o.level.toString().padStart(2,`0`),r=o.bitDepth.toString().padStart(2,`0`),i=o.chromaSubsampling.toString().padStart(2,`0`),a=o.colourPrimaries.toString().padStart(2,`0`),s=o.transferCharacteristics.toString().padStart(2,`0`),c=o.matrixCoefficients.toString().padStart(2,`0`),l=o.videoFullRangeFlag.toString().padStart(2,`0`),u=`vp09.${t}.${n}.${r}.${i}`;return u+=`.${a}.${s}.${c}.${l}`,u.endsWith(Uo)&&(u=u.slice(0,-15)),u}if(t===`av1`){if(!s){let t=e.width*e.height,n=Rn(z).level;for(let e of z)if(t<=e.maxPictureSize){n=e.level;break}return`av01.0.${n.toString().padStart(2,`0`)}M.08`}let t=s.profile,n=s.level.toString().padStart(2,`0`),i=s.tier?`H`:`M`,a=s.bitDepth.toString().padStart(2,`0`),o=s.monochrome?`1`:`0`,c=100*s.chromaSubsamplingX+10*s.chromaSubsamplingY+1*(s.chromaSubsamplingX&&s.chromaSubsamplingY?s.chromaSamplePosition:0),l,u,d,f;Ri(s)?(l=s.colourPrimaries,u=s.transferCharacteristics,d=s.matrixCoefficients,f=s.videoFullRangeFlag):(l=r?.primaries?qn[r.primaries]:1,u=r?.transfer?Jn[r.transfer]:1,d=r?.matrix?Yn[r.matrix]:1,f=+!!r?.fullRange);let p=`av01.${t}.${n}${i}.${a}`;return p+=`.${o}.${c.toString().padStart(3,`0`)}`,p+=`.${l.toString().padStart(2,`0`)}`,p+=`.${u.toString().padStart(2,`0`)}`,p+=`.${d.toString().padStart(2,`0`)}`,p+=`.${f}`,p.endsWith(Wo)&&(p=p.slice(0,-17)),p}if(t===`prores`)return c??`apch`;throw t!==null&&rr(t),TypeError(`Unhandled codec '${t}'.`)},Qo=(e,t)=>{switch(e){case`aac`:{if(!t.description)return 1024/t.sampleRate;let e=Zr(Un(t.description));if(e.coreSampleRate===null)throw Error(`Invalid AAC sampling frequency index.`);return e.frameLength/e.coreSampleRate}case`opus`:return es;case`mp3`:{let{sampleRate:e,numberOfChannels:n}=t,r=e>=32e3,i=r?1152:576,a=r?32e3:8e3,o=r?511:255,s=r?n===1?17:32:n===1?9:17,c=Math.floor(i/8*a/e)-4-s;return(1+Math.ceil(o/c))*i/e}case`vorbis`:{F(t.description);let e=Un(t.description),n=1,r=2;for(;r>0;)e[n++]<255&&r--;return(1<<(e[n+28]>>4))/2/t.sampleRate}case`ac3`:case`eac3`:return 256/t.sampleRate;case`dts`:return 512/t.sampleRate;case`flac`:case`truehd`:case`pcm-s16`:case`pcm-s16be`:case`pcm-s24`:case`pcm-s24be`:case`pcm-s32`:case`pcm-s32be`:case`pcm-f32`:case`pcm-f32be`:case`pcm-f64`:case`pcm-f64be`:case`pcm-u8`:case`pcm-s8`:case`ulaw`:case`alaw`:return 0;default:rr(e),F(!1)}},$o=48e3,es=.4,ts=/^pcm-([usf])(\d+)(be)?$/,ns=e=>{if(F(Io.includes(e)),e===`ulaw`)return{dataType:`ulaw`,sampleSize:1,littleEndian:!0,silentValue:255};if(e===`alaw`)return{dataType:`alaw`,sampleSize:1,littleEndian:!0,silentValue:213};let t=ts.exec(e);F(t);let n;n=t[1]===`u`?`unsigned`:t[1]===`s`?`signed`:`float`;let r=Number(t[2])/8,i=t[3]!==`be`;return{dataType:n,sampleSize:r,littleEndian:i,silentValue:e===`pcm-u8`?128:0}},rs=e=>e.startsWith(`avc1`)||e.startsWith(`avc3`)?`avc`:e.startsWith(`hev1`)||e.startsWith(`hvc1`)?`hevc`:e===`vp8`?`vp8`:e.startsWith(`vp09`)?`vp9`:e.startsWith(`av01`)?`av1`:Go.includes(e)?`prores`:e===`mp3`||e===`mp4a.69`||e===`mp4a.6B`||e===`mp4a.6b`||e===`mp4a.40.34`?`mp3`:e.startsWith(`mp4a.40.`)||e===`mp4a.67`?`aac`:e===`opus`||e===`Opus`?`opus`:e===`vorbis`?`vorbis`:e===`flac`?`flac`:e===`ac-3`||e===`ac3`?`ac3`:e===`ec-3`||e===`eac3`?`eac3`:Ko.includes(e)?`dts`:e===`mlpa`?`truehd`:e===`ulaw`?`ulaw`:e===`alaw`?`alaw`:ts.test(e)?e:e===`webvtt`?`webvtt`:null,is=e=>e===`avc`?{avc:{format:`avc`}}:e===`hevc`?{hevc:{format:`hevc`}}:{},as=[`avc1`,`avc3`,`hev1`,`hvc1`,`vp8`,`vp09`,`av01`,...Go],os=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,ss=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,cs=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,ls=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,us=(e,t)=>{if(!e)throw TypeError(`Video chunk metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Video chunk metadata must be an object.`);if(!e.decoderConfig)throw TypeError(`Video chunk metadata must include a decoder configuration.`);if(typeof e.decoderConfig!=`object`)throw TypeError(`Video chunk metadata decoder configuration must be an object.`);if(typeof e.decoderConfig.codec!=`string`)throw TypeError(`Video chunk metadata decoder configuration must specify a codec string.`);if(!as.some(t=>e.decoderConfig.codec.startsWith(t)))throw TypeError(`Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the Mediabunny Codec Registry.`);if(!Number.isInteger(e.decoderConfig.codedWidth)||e.decoderConfig.codedWidth<=0)throw TypeError(`Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).`);if(!Number.isInteger(e.decoderConfig.codedHeight)||e.decoderConfig.codedHeight<=0)throw TypeError(`Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).`);if(e.decoderConfig.displayAspectWidth!==void 0&&(!Number.isInteger(e.decoderConfig.displayAspectWidth)||e.decoderConfig.displayAspectWidth<=0))throw TypeError(`Video chunk metadata decoder configuration displayAspectWidth, when defined, must be a positive integer.`);if(e.decoderConfig.displayAspectHeight!==void 0&&(!Number.isInteger(e.decoderConfig.displayAspectHeight)||e.decoderConfig.displayAspectHeight<=0))throw TypeError(`Video chunk metadata decoder configuration displayAspectHeight, when defined, must be a positive integer.`);if(e.decoderConfig.displayAspectWidth!==void 0!=(e.decoderConfig.displayAspectHeight!==void 0))throw TypeError(`Video chunk metadata decoder configuration must specify both displayAspectWidth and displayAspectHeight, or neither.`);if(e.decoderConfig.description!==void 0&&!Zn(e.decoderConfig.description))throw TypeError(`Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.`);if(e.decoderConfig.colorSpace!==void 0){let{colorSpace:t}=e.decoderConfig;if(typeof t!=`object`)throw TypeError(`Video chunk metadata decoder configuration colorSpace, when provided, must be an object.`);let n=Object.keys(qn);if(t.primaries!=null&&!n.includes(t.primaries))throw TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${n.join(`, `)}.`);let r=Object.keys(Jn);if(t.transfer!=null&&!r.includes(t.transfer))throw TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${r.join(`, `)}.`);let i=Object.keys(Yn);if(t.matrix!=null&&!i.includes(t.matrix))throw TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${i.join(`, `)}.`);if(t.fullRange!=null&&typeof t.fullRange!=`boolean`)throw TypeError(`Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.`)}if(e.decoderConfig.codec.startsWith(`avc1`)||e.decoderConfig.codec.startsWith(`avc3`)){if(!os.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.`)}else if(e.decoderConfig.codec.startsWith(`hev1`)||e.decoderConfig.codec.startsWith(`hvc1`)){if(!ss.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.`)}else if(e.decoderConfig.codec.startsWith(`vp8`)){if(e.decoderConfig.codec!==`vp8`)throw TypeError(`Video chunk metadata decoder configuration codec string for VP8 must be "vp8".`)}else if(e.decoderConfig.codec.startsWith(`vp09`)){if(!cs.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section "Codecs Parameter String" of https://www.webmproject.org/vp9/mp4/.`)}else if(e.decoderConfig.codec.startsWith(`av01`)){if(!ls.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section "Codecs Parameter String" of https://aomediacodec.github.io/av1-isobmff/.`)}else if(Go.some(t=>e.decoderConfig.codec.startsWith(t))&&!Go.some(t=>e.decoderConfig.codec===t))throw TypeError(`Video chunk metadata decoder configuration codec string for ProRes must be one of the valid ProRes four-character codes: ${Go.join(`, `)}.`);if(t!==null&&rs(e.decoderConfig.codec)!==t)throw TypeError(`Video chunk metadata decoder configuration codec string '${e.decoderConfig.codec}' does not fit to the track codec '${t}'.`)},ds=[`mp4a`,`mp3`,`opus`,`vorbis`,`flac`,`ulaw`,`alaw`,`pcm`,`ac-3`,`ec-3`,`dts`,`mlpa`],fs=(e,t)=>{if(!e)throw TypeError(`Audio chunk metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Audio chunk metadata must be an object.`);if(!e.decoderConfig)throw TypeError(`Audio chunk metadata must include a decoder configuration.`);if(typeof e.decoderConfig!=`object`)throw TypeError(`Audio chunk metadata decoder configuration must be an object.`);if(typeof e.decoderConfig.codec!=`string`)throw TypeError(`Audio chunk metadata decoder configuration must specify a codec string.`);if(!ds.some(t=>e.decoderConfig.codec.startsWith(t)))throw TypeError(`Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the Mediabunny Codec Registry.`);if(!Number.isInteger(e.decoderConfig.sampleRate)||e.decoderConfig.sampleRate<=0)throw TypeError(`Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).`);if(!Number.isInteger(e.decoderConfig.numberOfChannels)||e.decoderConfig.numberOfChannels<=0)throw TypeError(`Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).`);if(e.decoderConfig.description!==void 0&&!Zn(e.decoderConfig.description))throw TypeError(`Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.`);if(e.decoderConfig.codec.startsWith(`mp4a`)&&e.decoderConfig.codec!==`mp4a.69`&&e.decoderConfig.codec!==`mp4a.6B`&&e.decoderConfig.codec!==`mp4a.6b`){if(![`mp4a.40.2`,`mp4a.40.02`,`mp4a.40.5`,`mp4a.40.05`,`mp4a.40.29`,`mp4a.67`].includes(e.decoderConfig.codec))throw TypeError(`Audio chunk metadata decoder configuration codec string for AAC must be a valid AAC codec string as specified in https://www.w3.org/TR/webcodecs-aac-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`mp3`)||e.decoderConfig.codec.startsWith(`mp4a`)){if(e.decoderConfig.codec!==`mp3`&&e.decoderConfig.codec!==`mp4a.69`&&e.decoderConfig.codec!==`mp4a.6B`&&e.decoderConfig.codec!==`mp4a.6b`)throw TypeError(`Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".`)}else if(e.decoderConfig.codec.startsWith(`opus`)){if(e.decoderConfig.codec!==`opus`)throw TypeError(`Audio chunk metadata decoder configuration codec string for Opus must be "opus".`);if(e.decoderConfig.description&&e.decoderConfig.description.byteLength<18)throw TypeError(`Audio chunk metadata decoder configuration description, when specified, is expected to be an Identification Header as specified in Section 5.1 of RFC 7845.`)}else if(e.decoderConfig.codec.startsWith(`vorbis`)){if(e.decoderConfig.codec!==`vorbis`)throw TypeError(`Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".`);if(!e.decoderConfig.description)throw TypeError(`Audio chunk metadata decoder configuration for Vorbis must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-vorbis-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`flac`)){if(e.decoderConfig.codec!==`flac`)throw TypeError(`Audio chunk metadata decoder configuration codec string for FLAC must be "flac".`);if(!e.decoderConfig.description||e.decoderConfig.description.byteLength<42)throw TypeError(`Audio chunk metadata decoder configuration for FLAC must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-flac-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`ac-3`)||e.decoderConfig.codec.startsWith(`ac3`)){if(e.decoderConfig.codec!==`ac-3`)throw TypeError(`Audio chunk metadata decoder configuration codec string for AC-3 must be "ac-3".`)}else if(e.decoderConfig.codec.startsWith(`ec-3`)||e.decoderConfig.codec.startsWith(`eac3`)){if(e.decoderConfig.codec!==`ec-3`)throw TypeError(`Audio chunk metadata decoder configuration codec string for EC-3 must be "ec-3".`)}else if(e.decoderConfig.codec.startsWith(`dts`)){if(!Ko.includes(e.decoderConfig.codec))throw TypeError(`Audio chunk metadata decoder configuration codec string for DTS must be one of the following four-character codes: ${Ko.join(`, `)}.`)}else if(e.decoderConfig.codec.startsWith(`mlpa`)){if(e.decoderConfig.codec!==`mlpa`)throw TypeError(`Audio chunk metadata decoder configuration codec string for TrueHD must be "mlpa".`)}else if((e.decoderConfig.codec.startsWith(`pcm`)||e.decoderConfig.codec.startsWith(`ulaw`)||e.decoderConfig.codec.startsWith(`alaw`))&&!Io.includes(e.decoderConfig.codec))throw TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${Io.join(`, `)}).`);if(t!==null&&rs(e.decoderConfig.codec)!==t)throw TypeError(`Audio chunk metadata decoder configuration codec string '${e.decoderConfig.codec}' does not fit to the track codec '${t}'.`)},ps=e=>{if(!e)throw TypeError(`Subtitle metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Subtitle metadata must be an object.`);if(!e.config)throw TypeError(`Subtitle metadata must include a config object.`);if(typeof e.config!=`object`)throw TypeError(`Subtitle metadata config must be an object.`);if(typeof e.config.description!=`string`)throw TypeError(`Subtitle metadata config description must be a string.`)},ms=class{constructor(e){this.mutex=new Qn,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateTimestamp(e,t,n){let r=this.trackTimestampInfo.get(e);if(r){if(n&&(r.maxTimestampBeforeLastKeyPacket=r.maxTimestamp),r.maxTimestampBeforeLastKeyPacket!==null&&t<r.maxTimestampBeforeLastKeyPacket)throw Error(`Timestamps cannot be smaller than the largest timestamp of the previous GOP (a GOP begins with a key packet and ends right before the next key packet). Got ${t}s, but largest timestamp is ${r.maxTimestampBeforeLastKeyPacket}s.`);r.maxTimestamp=Math.max(r.maxTimestamp,t)}else{if(!n)throw Error(`First packet must be a key packet.`);r={maxTimestamp:t,maxTimestampBeforeLastKeyPacket:null},this.trackTimestampInfo.set(e,r)}}},hs=class{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeU64(e){this.helperView.setUint32(0,Math.floor(e/2**32),!1),this.helperView.setUint32(4,e,!1),this.writer.write(this.helper.subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)this.helperView.setUint8(t%8,e.charCodeAt(t)),t%8==7&&this.writer.write(this.helper);e.length%8!=0&&this.writer.write(this.helper.subarray(0,e.length%8))}writeBox(e){if(this.offsets.set(e,this.writer.getPos()),e.contents&&!e.children)this.writeBoxHeader(e,e.size??e.contents.byteLength+8),this.writer.write(e.contents);else{let t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(let t of e.children)t&&this.writeBox(t);let n=this.writer.getPos(),r=e.size??n-t;this.writer.seek(t),this.writeBoxHeader(e,r),this.writer.seek(n)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}measureBoxHeader(e){return 8+(e.largeSize?8:0)}patchBox(e){let t=this.offsets.get(e);F(t!==void 0);let n=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(n)}measureBox(e){if(e.contents&&!e.children)return this.measureBoxHeader(e)+e.contents.byteLength;{let t=this.measureBoxHeader(e);if(e.contents&&(t+=e.contents.byteLength),e.children)for(let n of e.children)n&&(t+=this.measureBox(n));return t}}},B=new Uint8Array(8),gs=new DataView(B.buffer),_s=e=>[(e%256+256)%256],V=e=>(gs.setUint16(0,e,!1),[B[0],B[1]]),vs=e=>(gs.setInt16(0,e,!1),[B[0],B[1]]),ys=e=>(gs.setUint32(0,e,!1),[B[1],B[2],B[3]]),H=e=>(gs.setUint32(0,e,!1),[B[0],B[1],B[2],B[3]]),bs=e=>(gs.setInt32(0,e,!1),[B[0],B[1],B[2],B[3]]),xs=e=>(gs.setUint32(0,Math.floor(e/2**32),!1),gs.setUint32(4,e,!1),[B[0],B[1],B[2],B[3],B[4],B[5],B[6],B[7]]),Ss=e=>(gs.setInt32(0,Math.floor(e/2**32),!1),gs.setUint32(4,e,!1),[B[0],B[1],B[2],B[3],B[4],B[5],B[6],B[7]]),Cs=e=>(gs.setInt16(0,256*e,!1),[B[0],B[1]]),ws=e=>(gs.setInt32(0,2**16*e,!1),[B[0],B[1],B[2],B[3]]),Ts=e=>(gs.setInt32(0,2**30*e,!1),[B[0],B[1],B[2],B[3]]),Es=(e,t)=>{let n=[],r=e;do{let e=r&127;r>>=7,n.length>0&&(e|=128),n.push(e),t!==void 0&&t--}while(r>0||t);return n.reverse()},U=(e,t=!1)=>{let n=Array(e.length).fill(null).map((t,n)=>e.charCodeAt(n));return t&&n.push(0),n},Ds=e=>[ws(e[0]),ws(e[1]),Ts(e[2]),ws(e[3]),ws(e[4]),Ts(e[5]),ws(e[6]),ws(e[7]),Ts(e[8])],W=(e,t,n)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:n}),G=(e,t,n,r,i)=>W(e,[_s(t),ys(n),r??[]],i),Os=e=>e.isQuickTime?W(`ftyp`,[U(`qt `),H(512),U(`qt `)]):e.fragmented?e.cmaf?W(`ftyp`,[U(`iso5`),H(512),U(`iso5`),U(`iso6`),U(`mp41`),U(`cmfc`),U(`dash`)]):W(`ftyp`,[U(`iso5`),H(512),U(`iso5`),U(`iso6`),U(`mp41`)]):W(`ftyp`,[U(`isom`),H(512),U(`isom`),e.holdsAvc?U(`avc1`):[],U(`mp41`)]),ks=()=>W(`styp`,[U(`iso5`),H(0),U(`iso5`),U(`iso6`),U(`mp41`),U(`cmfc`),U(`dash`)]),As=(e,t)=>{let n=Math.max(0,e.minWrittenTimestamp),r=Math.max(0,e.maxWrittenEndTimestamp-n);return Number.isFinite(r)||(r=0),G(`sidx`,1,0,[H(1),H(ul),xs(K(n,ul)),xs(0),V(0),V(1),H(t&2147483647),H(K(r,ul)),H(0)])},js=e=>({type:`mdat`,largeSize:e}),Ms=e=>({type:`free`,size:e}),Ns=e=>W(`moov`,void 0,[Ps(e.creationTime,e.trackDatas),...e.trackDatas.map(t=>Fs(t,e.creationTime)),e.isFragmented?Ec(e.trackDatas):null,Vc(e)]),Ps=(e,t)=>{let n=Math.max(0,...t.map(e=>Math.max(0,K(pl(e),ul)+K(e.startTimestampOffset??0,ul)))),r=Math.max(0,...t.map(e=>e.track.id))+1,i=!zn(e)||!zn(n),a=i?xs:H;return G(`mvhd`,+i,0,[a(e),a(e),H(ul),a(n),ws(1),Cs(1),Array(10).fill(0),Ds(kn),Array(24).fill(0),H(r)])},Fs=(e,t)=>{let n=fl(e),r=e.startTimestampOffset!==null&&e.startTimestampOffset!==0;return W(`trak`,void 0,[Is(e,t),r?Ls(e):null,Rs(e,t),n.name===void 0?null:W(`udta`,void 0,[W(`name`,[...Kn.encode(n.name)])])])},Is=(e,t)=>{let n=Math.max(0,K(pl(e),ul)+K(e.startTimestampOffset??0,ul)),r=!zn(t)||!zn(n),i=r?xs:H,a;if(e.type===`video`&&e.track.metadata.transformationMatrix)a=e.track.metadata.transformationMatrix;else if(e.type===`video`){let{rotation:t,flip:n}=e.track.metadata;a=An(In(Nn(t??0),Fn(n?-1:1,1)),e.info.width,e.info.height)}else a=kn;let o=2;e.track.metadata.disposition?.default!==!1&&(o|=1);let s=e.type===`video`?0:e.type===`audio`?1:e.type===`subtitle`?2:rr(e);return G(`tkhd`,+r,o,[i(t),i(t),H(e.track.id),H(0),i(n),Array(8).fill(0),V(0),V(s),Cs(+(e.type===`audio`)),V(0),Ds(a),ws(e.type===`video`?e.info.width:0),ws(e.type===`video`?e.info.height:0)])},Ls=e=>{let t=e.startTimestampOffset;if(F(t!==null),t>0){let n=K(t,ul),r=K(pl(e),ul),i=!zn(n)||!zn(r),a=i?xs:H,o=i?Ss:bs;return W(`edts`,void 0,[G(`elst`,+!!i,0,[H(2),a(n),o(-1),ws(1),a(r),o(0),ws(1)])])}{let n=K(-t,e.timescale),r=Math.max(0,K(pl(e),ul)+K(t,ul)),i=!Bn(n)||!zn(r),a=i?xs:H,o=i?Ss:bs;return W(`edts`,void 0,[G(`elst`,+!!i,0,[H(1),a(r),o(n),ws(1)])])}},Rs=(e,t)=>W(`mdia`,void 0,[zs(e,t),Hs(!0,Bs[e.type],Vs[e.type]),Us(e)]),zs=(e,t)=>{let n=K(pl(e),e.timescale),r=!zn(t)||!zn(n),i=r?xs:H;return G(`mdhd`,+r,0,[i(t),i(t),H(e.timescale),i(n),V(nl(e.track.metadata.languageCode??`und`)),V(0)])},Bs={video:`vide`,audio:`soun`,subtitle:`text`},Vs={video:`MediabunnyVideoHandler`,audio:`MediabunnySoundHandler`,subtitle:`MediabunnyTextHandler`},Hs=(e,t,n,r=`\0\0\0\0`)=>G(`hdlr`,0,0,[e?U(`mhlr`):H(0),U(t),U(r),H(0),H(0),U(n,!0)]),Us=e=>W(`minf`,void 0,[Ws[e.type](),Gs(),Js(e)]),Ws={video:()=>G(`vmhd`,0,1,[V(0),V(0),V(0),V(0)]),audio:()=>G(`smhd`,0,0,[V(0),V(0)]),subtitle:()=>G(`nmhd`,0,0)},Gs=()=>W(`dinf`,void 0,[Ks()]),Ks=()=>G(`dref`,0,0,[H(1)],[qs()]),qs=()=>G(`url `,0,1),Js=e=>{let t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(e=>e.sampleCompositionTimeOffset!==0);return W(`stbl`,void 0,[Ys(e),vc(e),t?Cc(e):null,t?wc(e):null,bc(e),xc(e),Sc(e),yc(e),...Tc(e.samples,!1)])},Ys=e=>{let t;if(e.type===`video`)t=Xs(Xc(e.track.source._codec,e.info.decoderConfig.codec),e);else if(e.type===`audio`){let n=Qc(e.track.source._codec,e.info.decoderConfig.codec,e.muxer.isQuickTime);F(n),t=ic(n,e)}else e.type===`subtitle`&&(t=gc(el[e.track.source._codec],e));return F(t),G(`stsd`,0,0,[H(1)],[t])},Xs=(e,t)=>W(e,[[,,,,,,].fill(0),V(1),V(0),V(0),Array(12).fill(0),V(t.info.width),V(t.info.height),H(4718592),H(4718592),H(0),V(1),_s(oi.length),U(oi),Array(31-oi.length).fill(0),V(t.info.hasAlphaChannel?32:24),vs(65535)],[Zc[t.track.source._codec]?.(t)??null,Qs(t),Xn(t.info.decoderConfig.colorSpace)?null:$s(t),Zs(t)]),Zs=e=>e.avgBitrate===0&&e.maxBitrate===0?null:W(`btrt`,[H(0),H(e.maxBitrate),H(e.avgBitrate)]),Qs=e=>e.info.pixelAspectRatio.num===e.info.pixelAspectRatio.den?null:W(`pasp`,[H(e.info.pixelAspectRatio.num),H(e.info.pixelAspectRatio.den)]),$s=e=>{let t=e.info.decoderConfig.colorSpace;return W(`colr`,[U(e.muxer.isQuickTime?`nclc`:`nclx`),V(t?.primaries==null?2:qn[t.primaries]),V(t?.transfer==null?2:Jn[t.transfer]),V(t?.matrix==null?2:Yn[t.matrix]),e.muxer.isQuickTime?[]:_s(!!t?.fullRange<<7)])},ec=e=>e.info.decoderConfig&&W(`avcC`,[...Un(e.info.decoderConfig.description)]),tc=e=>e.info.decoderConfig&&W(`hvcC`,[...Un(e.info.decoderConfig.description)]),nc=e=>{if(!e.info.decoderConfig)return null;let t=e.info.decoderConfig,n=t.codec.split(`.`),r=Number(n[1]),i=Number(n[2]),a=Number(n[3]),o=n[4]?Number(n[4]):1,s=n[8]?Number(n[8]):Number(t.colorSpace?.fullRange??0),c=(a<<4)+(o<<1)+s,l=n[5]?Number(n[5]):t.colorSpace?.primaries?qn[t.colorSpace.primaries]:1,u=n[6]?Number(n[6]):t.colorSpace?.transfer?Jn[t.colorSpace.transfer]:1,d=n[7]?Number(n[7]):t.colorSpace?.matrix?Yn[t.colorSpace.matrix]:1;return G(`vpcC`,1,0,[_s(r),_s(i),_s(c),_s(l),_s(u),_s(d),V(0)])},rc=e=>W(`av1C`,Xo(e.info.decoderConfig.codec)),ic=(e,t)=>{let n=0,r,i=16,a=Io.includes(t.track.source._codec);if(a){let e=t.track.source._codec,{sampleSize:r}=ns(e);i=8*r,i>16&&(n=1)}if(t.muxer.isQuickTime&&t.track.source._codec!==`truehd`&&(n=1),n===0)r=[[,,,,,,].fill(0),V(1),V(n),V(0),H(0),V(t.info.numberOfChannels),V(i),V(0),V(0),t.track.source._codec===`truehd`?H(t.info.sampleRate):[V(t.info.sampleRate<2**16?t.info.sampleRate:0),V(0)]];else{let e=a?0:-2;r=[[,,,,,,].fill(0),V(1),V(n),V(0),H(0),V(t.info.numberOfChannels),V(Math.min(i,16)),vs(e),V(0),V(t.info.sampleRate<2**16?t.info.sampleRate:0),V(0),a?[H(1),H(i/8),H(t.info.numberOfChannels*i/8)]:[H(0),H(0),H(0)],H(2)]}return W(e,r,[$c(t.track.source._codec,t.muxer.isQuickTime)?.(t)??null,Zs(t)])},ac=e=>{let t;switch(e.track.source._codec){case`aac`:t=64;break;case`mp3`:t=107;break;case`vorbis`:t=221;break;default:throw Error(`Unhandled audio codec: ${e.track.source._codec}`)}let n=[..._s(t),..._s(21),...ys(0),...H(e.maxBitrate),...H(e.avgBitrate)];if(e.info.decoderConfig.description){let t=Un(e.info.decoderConfig.description);n=[...n,..._s(5),...Es(t.byteLength),...t]}return n=[...V(1),..._s(0),..._s(4),...Es(n.length),...n,..._s(6),..._s(1),..._s(2)],n=[..._s(3),...Es(n.length),...n],G(`esds`,0,0,n)},oc=e=>W(`wave`,void 0,[sc(e),cc(e),W(`\0\0\0\0`)]),sc=e=>W(`frma`,[U(Qc(e.track.source._codec,e.info.decoderConfig.codec,e.muxer.isQuickTime))]),cc=e=>{let{littleEndian:t}=ns(e.track.source._codec);return W(`enda`,[V(+t)])},lc=e=>{let t=e.info.numberOfChannels,n=312,r=e.info.sampleRate,i=0,a=0,o=new Uint8Array,s=e.info.decoderConfig?.description;if(s){F(s.byteLength>=18);let e=zi(Un(s));t=e.outputChannelCount,n=e.preSkip,r=e.inputSampleRate,i=e.outputGain,a=e.channelMappingFamily,e.channelMappingTable&&(o=e.channelMappingTable)}return W(`dOps`,[_s(0),_s(t),V(n),H(r),vs(i),_s(a),...o])},uc=e=>{let t=e.info.decoderConfig?.description;return F(t),G(`dfLa`,0,0,[...Un(t).subarray(4)])},dc=e=>{let{littleEndian:t,sampleSize:n}=ns(e.track.source._codec);return G(`pcmC`,0,0,[_s(+t),_s(8*n)])},fc=e=>{F(e.info.primingPacket);let t=Gi(e.info.primingPacket.data);if(!t)throw Error(`Couldn't extract AC-3 frame info from the audio packet. Ensure the packets contain valid AC-3 sync frames (as specified in ETSI TS 102 366).`);let n=new Uint8Array(3),r=new qr(n);return r.writeBits(2,t.fscod),r.writeBits(5,t.bsid),r.writeBits(3,t.bsmod),r.writeBits(3,t.acmod),r.writeBits(1,t.lfeon),r.writeBits(5,t.bitRateCode),r.writeBits(5,0),W(`dac3`,[...n])},pc=e=>{F(e.info.primingPacket);let t=qi(e.info.primingPacket.data);if(!t)throw Error(`Couldn't extract E-AC-3 frame info from the audio packet. Ensure the packets contain valid E-AC-3 sync frames (as specified in ETSI TS 102 366).`);let n=16;for(let e of t.substreams)n+=23,e.numDepSub>0?n+=9:n+=1;let r=Math.ceil(n/8),i=new Uint8Array(r),a=new qr(i);a.writeBits(13,t.dataRate),a.writeBits(3,t.substreams.length-1);for(let e of t.substreams)a.writeBits(2,e.fscod),a.writeBits(5,e.bsid),a.writeBits(1,0),a.writeBits(1,0),a.writeBits(3,e.bsmod),a.writeBits(3,e.acmod),a.writeBits(1,e.lfeon),a.writeBits(3,0),a.writeBits(4,e.numDepSub),e.numDepSub>0?a.writeBits(9,e.chanLoc):a.writeBits(1,0);return W(`dec3`,[...i])},mc=e=>{F(e.info.primingPacket);let t=ia(e.info.primingPacket.data);if(!t)throw Error(`Couldn't extract DTS frame info from the audio packet. Ensure the packets contain valid DTS frames as specified in ETSI TS 102 114.`);return W(`ddts`,[...oa(t)])},hc=e=>{F(e.info.primingPacket);let t=e.info.primingPacket.data;if(Ui(`truehd`,t)!==`key`)throw Error(`Couldn't extract TrueHD stream info from the audio packet. Ensure the first packet is an access unit carrying a major sync.`);let n=Wn(t),r=n.getUint32(8),i=n.getUint16(18)&32767;return W(`dmlp`,[H(r),V(i<<1),H(0)])},gc=(e,t)=>W(e,[[,,,,,,].fill(0),V(1)],[tl[t.track.source._codec](t),Zs(t)]),_c=e=>W(`vttC`,[...Kn.encode(e.info.config.description)]),vc=e=>G(`stts`,0,0,[H(e.timeToSampleTable.length),e.timeToSampleTable.map(e=>[H(e.sampleCount),H(e.sampleDelta)])]),yc=e=>{if(e.samples.every(e=>e.type===`key`))return null;let t=[...e.samples.entries()].filter(([,e])=>e.type===`key`);return G(`stss`,0,0,[H(t.length),t.map(([e])=>H(e+1))])},bc=e=>G(`stsc`,0,0,[H(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(e=>[H(e.firstChunk),H(e.samplesPerChunk),H(1)])]),xc=e=>{if(e.type===`audio`&&e.info.requiresPcmTransformation){let{sampleSize:t}=ns(e.track.source._codec);return G(`stsz`,0,0,[H(t*e.info.numberOfChannels),H(e.samples.reduce((t,n)=>t+K(n.duration,e.timescale),0))])}return G(`stsz`,0,0,[H(0),H(e.samples.length),e.samples.map(e=>H(e.size))])},Sc=e=>e.finalizedChunks.length>0&&Rn(e.finalizedChunks).offset>=2**32?G(`co64`,0,0,[H(e.finalizedChunks.length),e.finalizedChunks.map(e=>xs(e.offset))]):G(`stco`,0,0,[H(e.finalizedChunks.length),e.finalizedChunks.map(e=>H(e.offset))]),Cc=e=>G(`ctts`,1,0,[H(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(e=>[H(e.sampleCount),bs(e.sampleCompositionTimeOffset)])]),wc=e=>{if(F(e.compositionTimeOffsetTable.length>0),e.samples.length===0)return null;let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let r=0;r<e.compositionTimeOffsetTable.length;r++){let i=e.compositionTimeOffsetTable[r];t=Math.min(t,i.sampleCompositionTimeOffset),n=Math.max(n,i.sampleCompositionTimeOffset)}for(let t=0;t<e.samples.length;t++){let n=e.samples[t];r=Math.min(r,K(n.timestamp,e.timescale)),i=Math.max(i,K(n.timestamp+n.duration,e.timescale))}let a=Math.max(-t,0);return i>=2**31?null:G(`cslg`,0,0,[bs(a),bs(t),bs(n),bs(r),bs(i)])},Tc=(e,t)=>{let n=[];for(let t of e)if(n.length===0)n.push({sampleCount:1,prerollSamples:t.prerollSamples});else{let e=n[n.length-1];e.prerollSamples===t.prerollSamples?e.sampleCount++:n.push({sampleCount:1,prerollSamples:t.prerollSamples})}let r=n.filter(e=>e.prerollSamples!==0);if(r.length===0)return[];let i=t?65537:1;return[G(`sgpd`,1,0,[U(`roll`),H(2),H(r.length),...r.map(e=>vs(e.prerollSamples))]),G(`sbgp`,0,0,[U(`roll`),H(n.length),...n.map(e=>[H(e.sampleCount),H(e.prerollSamples===0?0:i++)])])]},Ec=e=>W(`mvex`,void 0,e.map(Dc)),Dc=e=>G(`trex`,0,0,[H(e.track.id),H(1),H(0),H(0),H(0)]),Oc=(e,t)=>W(`moof`,void 0,[kc(e),...t.map(jc)]),kc=e=>G(`mfhd`,0,0,[H(e)]),Ac=e=>{let t=0,n=0,r=e.type===`delta`;return n|=+r,t|=r?1:2,t<<24|n<<16},jc=e=>W(`traf`,void 0,[Mc(e),Nc(e),Pc(e),...Tc(e.currentChunk.samples,!0)]),Mc=e=>{F(e.currentChunk);let t=0;t|=8,t|=16,t|=32,t|=131072;let n=e.currentChunk.samples[1]??e.currentChunk.samples[0],r={duration:n.timescaleUnitsToNextSample,size:n.size,flags:Ac(n)};return G(`tfhd`,0,t,[H(e.track.id),H(r.duration),H(r.size),H(r.flags)])},Nc=e=>(F(e.currentChunk),G(`tfdt`,1,0,[xs(K(e.currentChunk.startTimestamp,e.timescale))])),Pc=e=>{F(e.currentChunk);let t=e.currentChunk.samples.map(e=>e.timescaleUnitsToNextSample),n=e.currentChunk.samples.map(e=>e.size),r=e.currentChunk.samples.map(Ac),i=e.currentChunk.samples.map(t=>K(t.timestamp-t.decodeTimestamp,e.timescale)),a=new Set(t),o=new Set(n),s=new Set(r),c=new Set(i),l=s.size===2&&r[0]!==r[1],u=a.size>1,d=o.size>1,f=!l&&s.size>1,p=c.size>1||[...c].some(e=>e!==0),m=0;return m|=1,m|=4*l,m|=256*u,m|=512*d,m|=1024*f,m|=2048*p,G(`trun`,1,m,[H(e.currentChunk.samples.length),H(e.currentChunk.offset-e.currentChunk.moofOffset||0),l?H(r[0]):[],e.currentChunk.samples.map((e,a)=>[u?H(t[a]):[],d?H(n[a]):[],f?H(r[a]):[],p?bs(i[a]):[]])])},Fc=e=>W(`mfra`,void 0,[...e.map(Ic),Lc()]),Ic=e=>{let t=[];for(let n of e.finalizedChunks){let r=n.samples.findIndex(e=>e.type===`key`);if(r===-1)continue;let i=n.samples[r];t.push([xs(K(i.timestamp,e.timescale)),xs(n.moofOffset),H(n.trafIndex+1),H(1),H(r+1)])}return G(`tfra`,1,0,[H(e.track.id),H(63),H(t.length),t])},Lc=()=>G(`mfro`,0,0,[H(0)]),Rc=()=>W(`vtte`),zc=(e,t,n,r,i)=>W(`vttc`,void 0,[i===null?null:W(`vsid`,[bs(i)]),n===null?null:W(`iden`,[...Kn.encode(n)]),t===null?null:W(`ctim`,[...Kn.encode(ua(t))]),r===null?null:W(`sttg`,[...Kn.encode(r)]),W(`payl`,[...Kn.encode(e)])]),Bc=e=>W(`vtta`,[...Kn.encode(e)]),Vc=e=>{let t=[],n=e.format._options.metadataFormat??`auto`,r=e.output._metadataTags;if(n===`mdir`||n===`auto`&&!e.isQuickTime){let e=qc(r);e&&t.push(e)}else if(n===`mdta`){let e=Jc(r);e&&t.push(e)}else(n===`udta`||n===`auto`&&e.isQuickTime)&&Hc(t,e.output._metadataTags);return t.length===0?null:W(`udta`,void 0,t)},Hc=(e,t)=>{for(let{key:n,value:r}of kr(t))switch(n){case`title`:e.push(Uc(`©nam`,r));break;case`description`:e.push(Uc(`©des`,r));break;case`artist`:e.push(Uc(`©ART`,r));break;case`album`:e.push(Uc(`©alb`,r));break;case`albumArtist`:e.push(Uc(`albr`,r));break;case`genre`:e.push(Uc(`©gen`,r));break;case`date`:e.push(Uc(`©day`,r.toISOString().slice(0,10)));break;case`comment`:e.push(Uc(`©cmt`,r));break;case`lyrics`:e.push(Uc(`©lyr`,r));break;case`raw`:break;case`creationTime`:break;case`discNumber`:case`discsTotal`:case`trackNumber`:case`tracksTotal`:case`beatsPerMinute`:case`images`:break;default:rr(n)}if(t.raw)for(let n in t.raw){let r=t.raw[n];r==null||n.length!==4||e.some(e=>e.type===n)||(typeof r==`string`?e.push(Uc(n,r)):r instanceof Uint8Array&&e.push(W(n,Array.from(r))))}},Uc=(e,t)=>{let n=Kn.encode(t);return W(e,[V(n.length),V(nl(`und`)),Array.from(n)])},Wc={"image/jpeg":13,"image/png":14,"image/bmp":27},Gc=new Set([`HMMT`,`loci`,`chpl`]),Kc=(e,t)=>{let n=[];for(let{key:r,value:i}of kr(e))switch(r){case`title`:n.push({key:t?`title`:`©nam`,value:Yc(i)});break;case`description`:n.push({key:t?`description`:`©des`,value:Yc(i)});break;case`artist`:n.push({key:t?`artist`:`©ART`,value:Yc(i)});break;case`album`:n.push({key:t?`album`:`©alb`,value:Yc(i)});break;case`albumArtist`:n.push({key:t?`album_artist`:`aART`,value:Yc(i)});break;case`comment`:n.push({key:t?`comment`:`©cmt`,value:Yc(i)});break;case`genre`:n.push({key:t?`genre`:`©gen`,value:Yc(i)});break;case`beatsPerMinute`:t||n.push({key:`tmpo`,value:W(`data`,[H(21),H(0),V(i)])});break;case`lyrics`:n.push({key:t?`lyrics`:`©lyr`,value:Yc(i)});break;case`date`:n.push({key:t?`date`:`©day`,value:Yc(i.toISOString().slice(0,10))});break;case`images`:for(let e of i)e.kind===`coverFront`&&n.push({key:`covr`,value:W(`data`,[H(Wc[e.mimeType]??0),H(0),Array.from(e.data)])});break;case`trackNumber`:if(t){let t=e.tracksTotal===void 0?i.toString():`${i}/${e.tracksTotal}`;n.push({key:`track`,value:Yc(t)})}else n.push({key:`trkn`,value:W(`data`,[H(0),H(0),V(0),V(i),V(e.tracksTotal??0),V(0)])});break;case`discNumber`:t||n.push({key:`disc`,value:W(`data`,[H(0),H(0),V(0),V(i),V(e.discsTotal??0),V(0)])});break;case`tracksTotal`:case`discsTotal`:break;case`raw`:break;case`creationTime`:break;default:rr(r)}if(e.raw)for(let r in e.raw){let i=e.raw[r];i==null||!t&&(r.length!==4||Gc.has(r))||n.some(e=>e.key===r)||(typeof i==`string`?n.push({key:r,value:Yc(i)}):i instanceof Uint8Array?n.push({key:r,value:W(`data`,[H(0),H(0),Array.from(i)])}):i instanceof Ur&&n.push({key:r,value:W(`data`,[H(Wc[i.mimeType]??0),H(0),Array.from(i.data)])}))}return n},qc=e=>{let t=Kc(e,!1);return t.length===0?null:G(`meta`,0,0,void 0,[Hs(!1,`mdir`,``,`appl`),W(`ilst`,void 0,t.map(e=>W(e.key,void 0,[e.value])))])},Jc=e=>{let t=Kc(e,!0);return t.length===0?null:W(`meta`,void 0,[Hs(!1,`mdta`,``),G(`keys`,0,0,[H(t.length)],t.map(e=>W(`mdta`,[...Kn.encode(e.key)]))),W(`ilst`,void 0,t.map((e,t)=>W(String.fromCharCode(...H(t+1)),void 0,[e.value])))])},Yc=e=>W(`data`,[H(1),H(0),...Kn.encode(e)]),Xc=(e,t)=>{switch(e){case`avc`:return t.startsWith(`avc3`)?`avc3`:`avc1`;case`hevc`:return`hvc1`;case`vp8`:return`vp08`;case`vp9`:return`vp09`;case`av1`:return`av01`;case`prores`:return t}},Zc={avc:ec,hevc:tc,vp8:nc,vp9:nc,av1:rc,prores:null},Qc=(e,t,n)=>{switch(e){case`aac`:return`mp4a`;case`mp3`:return`mp4a`;case`opus`:return`Opus`;case`vorbis`:return`mp4a`;case`flac`:return`fLaC`;case`ulaw`:return`ulaw`;case`alaw`:return`alaw`;case`pcm-u8`:return`raw `;case`pcm-s8`:return`sowt`;case`ac3`:return`ac-3`;case`eac3`:return`ec-3`;case`dts`:return t;case`truehd`:return`mlpa`}if(n)switch(e){case`pcm-s16`:return`sowt`;case`pcm-s16be`:return`twos`;case`pcm-s24`:return`in24`;case`pcm-s24be`:return`in24`;case`pcm-s32`:return`in32`;case`pcm-s32be`:return`in32`;case`pcm-f32`:return`fl32`;case`pcm-f32be`:return`fl32`;case`pcm-f64`:return`fl64`;case`pcm-f64be`:return`fl64`}else switch(e){case`pcm-s16`:return`ipcm`;case`pcm-s16be`:return`ipcm`;case`pcm-s24`:return`ipcm`;case`pcm-s24be`:return`ipcm`;case`pcm-s32`:return`ipcm`;case`pcm-s32be`:return`ipcm`;case`pcm-f32`:return`fpcm`;case`pcm-f32be`:return`fpcm`;case`pcm-f64`:return`fpcm`;case`pcm-f64be`:return`fpcm`}},$c=(e,t)=>{switch(e){case`aac`:return ac;case`mp3`:return ac;case`opus`:return lc;case`vorbis`:return ac;case`flac`:return uc;case`ac3`:return fc;case`eac3`:return pc;case`dts`:return mc;case`truehd`:return hc}if(t)switch(e){case`pcm-s24`:return oc;case`pcm-s24be`:return oc;case`pcm-s32`:return oc;case`pcm-s32be`:return oc;case`pcm-f32`:return oc;case`pcm-f32be`:return oc;case`pcm-f64`:return oc;case`pcm-f64be`:return oc}else switch(e){case`pcm-s16`:return dc;case`pcm-s16be`:return dc;case`pcm-s24`:return dc;case`pcm-s24be`:return dc;case`pcm-s32`:return dc;case`pcm-s32be`:return dc;case`pcm-f32`:return dc;case`pcm-f32be`:return dc;case`pcm-f64`:return dc;case`pcm-f64be`:return dc}return null},el={webvtt:`wvtt`},tl={webvtt:_c},nl=e=>{F(e.length===3);let t=0;for(let n=0;n<3;n++)t<<=5,t+=e.charCodeAt(n)-96;return t},rl=class{constructor(e,t){if(this.finalized=!1,this.started=!1,this.pos=0,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1,e._writerAcquired)throw Error(`Can't have multiple Writers for the same Target.`);this.target=e,e._setMonotonicity(t),e._writerAcquired=!0}start(){F(!this.started),this.target._start(),this.started=!0}write(e){F(this.started&&!this.finalized),this.maybeTrackWrites(e),this.target._write(e,this.pos),this.pos+=e.byteLength}seek(e){this.pos=e}getPos(){return this.pos}async flush(){return F(this.started&&!this.finalized),this.target._flush()}async finalize(){F(this.started&&!this.finalized),await this.target._finalize(),this.finalized=!0}maybeTrackWrites(e){if(!this.trackedWrites)return;let t=this.getPos();if(t<this.trackedStart){if(t+e.byteLength<=this.trackedStart)return;e=e.subarray(this.trackedStart-t),t=0}let n=t+e.byteLength-this.trackedStart,r=this.trackedWrites.byteLength;for(;r<n;)r*=2;if(r!==this.trackedWrites.byteLength){let e=new Uint8Array(r);e.set(this.trackedWrites,0),this.trackedWrites=e}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(1024),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw Error(`Internal error: Can't get tracked writes since nothing was tracked.`);let e={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,e}};go();var il=class extends zr{constructor(){super(...arguments),this._writerAcquired=!1,this._monotonicity=null,this.onwrite=null}_setMonotonicity(e){this._monotonicity!==!1&&(this._monotonicity=e)}_dispatchWrite(e,t){this.onwrite?.(e,t),this._emit(`write`,{start:e,end:t})}slice(e){if(!Number.isInteger(e)||e<0)throw TypeError(`offset must be a non-negative integer.`);return new cl(this,e)}},al=2**16,ol=2**32,sl=class extends il{constructor(e={}){if(super(),this.buffer=null,this._maxPos=0,!e||typeof e!=`object`)throw TypeError(`BufferTarget options, when provided, must be an object.`);if(e.onFinalize!==void 0&&typeof e.onFinalize!=`function`)throw TypeError(`options.onFinalize, when provided, must be a function.`);if(this._options=e,this._supportsResize=`resize`in new ArrayBuffer(0),this._supportsResize)try{this._buffer=new ArrayBuffer(al,{maxByteLength:ol})}catch{this._buffer=new ArrayBuffer(al),this._supportsResize=!1}else this._buffer=new ArrayBuffer(al);this._bytes=new Uint8Array(this._buffer)}_ensureSize(e){F(this._buffer),F(this._bytes);let t=this._buffer.byteLength;for(;t<e;)t*=2;if(t!==this._buffer.byteLength){if(t>ol)throw Error(`ArrayBuffer exceeded maximum size of ${ol} bytes. Please consider using another target.`);if(this._supportsResize)this._buffer.resize(t);else{let e=new ArrayBuffer(t),n=new Uint8Array(e);n.set(this._bytes,0),this._buffer=e,this._bytes=n}}}_start(){}_write(e,t){F(this._bytes),this._ensureSize(t+e.byteLength),this._bytes.set(e,t),this._maxPos=Math.max(this._maxPos,t+e.byteLength),this._dispatchWrite(t,t+e.byteLength)}async _flush(){}async _finalize(){F(this._buffer),this.buffer=`transferToFixedLength`in this._buffer?this._buffer.transferToFixedLength(this._maxPos):this._buffer.slice(0,this._maxPos),this._buffer=null,this._bytes=null,this._options.onFinalize&&await this._options.onFinalize(this.buffer),this._emit(`finalized`)}async _close(){}_getSlice(e,t){return F(this._bytes),this._bytes.slice(e,t)}},cl=class extends il{constructor(e,t){super(),this._baseTarget=e,this._offset=t}_start(){}_write(e,t){this._baseTarget._write(e,this._offset+t),this._dispatchWrite(t,t+e.byteLength)}_flush(){return this._baseTarget._flush()}async _finalize(){this._emit(`finalized`)}async _close(){}_setMonotonicity(e){super._setMonotonicity(e),this._baseTarget._setMonotonicity(e)}},ll=class{constructor(e,t){if(this.rootPath=e,this.getTarget=t,typeof e!=`string`)throw TypeError(`rootPath must be a string.`);if(typeof t!=`function`)throw TypeError(`getTarget must be a function.`)}},ul=57600,dl=.5,fl=e=>{let t={},n=e.track;return n.metadata.name!==void 0&&(t.name=n.metadata.name),t},K=(e,t,n=!0)=>{let r=e*t;return n?Math.round(r):r},pl=e=>{if(e.samples.length===0)return 0;let t=1/0,n=-1/0;for(let r=0;r<e.samples.length;r++){let i=e.samples[r];i.timestamp<t&&(t=i.timestamp),i.timestamp+i.duration>n&&(n=i.timestamp+i.duration)}return t===1/0?0:n-t},ml=class extends ms{constructor(e,t){super(e),this.writer=null,this.boxWriter=null,this.initWriter=null,this.initBoxWriter=null,this.auxTarget=new sl,this.auxWriter=new rl(this.auxTarget,!1),this.auxBoxWriter=new hs(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=nr(),this.finalizedChunks=[],this.wroteFragmentedHeader=!1,this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.minWrittenTimestamp=1/0,this.maxWrittenEndTimestamp=-1/0,this.segmentHeaderSize=null,this.format=t,this.formatOptions={...t._options},this.isQuickTime=t instanceof Tl,this.isCmaf=t instanceof wl,this.minimumFragmentDuration=this.formatOptions.minimumFragmentDuration??(t instanceof wl?1/0:1),this.auxWriter.start()}async start(){let e=await this.mutex.acquire(),t=this.output._metadataTags.creationTime===void 0?new Date:this.output._metadataTags.creationTime;if(this.creationTime=t?Math.floor(t.getTime()/1e3)+Qa:0,t&&this.creationTime<=0)throw Error(`creationTime must be after 1904-01-01T00:00:00Z for MP4/QuickTime files.`);if(this.isCmaf?(this.fastStart=`fragmented`,this.isFragmented=!0):(this.writer=await this.output._getRootWriter(e=>this.formatOptions.fastStart===void 0?e instanceof sl:this.formatOptions.fastStart===`fragmented`),this.boxWriter=new hs(this.writer),this.fastStart=this.formatOptions.fastStart??(this.writer.target instanceof sl&&`in-memory`),this.isFragmented=this.fastStart===`fragmented`),this.isCmaf){if(!this.output._hasInitTarget())throw Error(`CMAF outputs require the initTarget field in OutputOptions to be set; the init segment will be written to it.`);let e=new rl(await this.output._getInitTarget(),!0);e.start(),this.initWriter=e,this.initBoxWriter=new hs(e)}let n=this.output.tracks.some(e=>e.isVideoTrack()&&e.source._codec===`avc`);{let e=this.initBoxWriter??this.boxWriter;if(F(e),this.formatOptions.onFtyp&&e.writer.startTrackingWrites(),e.writeBox(Os({isQuickTime:this.isQuickTime,holdsAvc:n,fragmented:this.isFragmented,cmaf:this.isCmaf})),this.formatOptions.onFtyp){let{data:t,start:n}=e.writer.stopTrackingWrites();this.formatOptions.onFtyp(t,n)}this.ftypSize=e.writer.getPos(),this.isCmaf&&await this.initWriter.flush()}if(this.fastStart!==`in-memory`){if(this.fastStart===`reserve`)for(let e of this.output.tracks){if(e.metadata.maximumPacketCount===void 0)throw Error(`All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.`);if(e.metadata.maximumPacketCount>2**32-1)throw Error(`Track #${e.id} has a maximumPacketCount of ${e.metadata.maximumPacketCount}, which exceeds the maximum of ${2**32-1} packets per track that a non-fragmented file can hold.`)}else this.isFragmented||(F(this.writer),F(this.boxWriter),this.formatOptions.onMdat&&this.writer.startTrackingWrites(),this.mdat=js(!0),this.boxWriter.writeBox(this.mdat))}await this.writer?.flush();for(let e of this.output.tracks)e.isVideoTrack()&&e.metadata.decoderConfig?this.getVideoTrackData(e,e.metadata.primingPacket??null,{decoderConfig:e.metadata.decoderConfig}):e.isAudioTrack()&&e.metadata.decoderConfig&&this.getAudioTrackData(e,e.metadata.primingPacket??null,{decoderConfig:e.metadata.decoderConfig});e()}allTracksAreKnown(){for(let e of this.output.tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;let e=this.trackDatas.map(e=>e.type===`video`||e.type===`audio`?e.info.decoderConfig.codec:{webvtt:`wvtt`}[e.track.source._codec]);return $a({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(e=>e.type===`video`),hasAudio:this.trackDatas.some(e=>e.type===`audio`),codecStrings:e})}getVideoTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;us(n,e.source._codec),F(n),F(n.decoderConfig);let i={...n.decoderConfig};F(i.codedWidth!==void 0),F(i.codedHeight!==void 0);let a=!1;if(e.source._codec===`avc`&&!i.description){if(!t)throw Error(`No AVC description provided; you must therefore provide a priming packet.`);let e=hi(t.data);if(!e)throw Error(`Couldn't extract an AVCDecoderConfigurationRecord from the AVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.264) when not providing a description, or provide a description (must be an AVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in AVCC format.`);i.description=gi(e),a=!0}else if(e.source._codec===`hevc`&&!i.description){if(!t)throw Error(`No HEVC description provided; you must therefore provide a priming packet.`);let e=wi(t.data);if(!e)throw Error(`Couldn't extract an HEVCDecoderConfigurationRecord from the HEVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.265) when not providing a description, or provide a description (must be an HEVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in HEVC format.`);i.description=Mi(e),a=!0}let o=hr(1/(e.metadata.frameRate??57600),1e6).den,s=i.displayAspectWidth,c=i.displayAspectHeight,l=s===void 0||c===void 0?{num:1,den:1}:Fr({num:s*i.codedHeight,den:c*i.codedWidth}),u=i.codec===`ap4h`||i.codec===`ap4x`,d={muxer:this,track:e,type:`video`,info:{width:i.codedWidth,height:i.codedHeight,pixelAspectRatio:l,decoderConfig:i,requiresAnnexBTransformation:a,hasAlphaChannel:u},timescale:o,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1,avgBitrate:e.source._nominalBitrate??e.metadata.averageBitrate??0,maxBitrate:e.source._nominalBitrate??e.metadata.bitrate??0};return this.trackDatas.push(d),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),d}getAudioTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;fs(n,e.source._codec),F(n),F(n.decoderConfig);let i={...n.decoderConfig},a=!1;if(e.source._codec===`aac`&&!i.description){if(!t)throw Error(`No AAC description provided; you must therefore provide a priming packet.`);let e=ho(_o.tempFromBytes(t.data));if(!e)throw Error(`Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.`);let n=Jr[e.samplingFrequencyIndex],r=Yr[e.channelConfiguration];if(n===void 0||r===void 0)throw Error(`Invalid ADTS frame header.`);i.description=ei({objectType:e.objectType,outputSampleRate:n,outputNumberOfChannels:r}),a=!0}if(!t){if(e.source._codec===`ac3`||e.source._codec===`eac3`)throw Error(`AC-3/E-AC-3 require a priming packet.`);if(e.source._codec===`dts`)throw Error(`DTS requires a priming packet.`);if(e.source._codec===`truehd`)throw Error(`TrueHD requires a priming packet.`)}let o={muxer:this,track:e,type:`audio`,info:{numberOfChannels:n.decoderConfig.numberOfChannels,sampleRate:n.decoderConfig.sampleRate,decoderConfig:i,requiresPcmTransformation:!this.isFragmented&&Io.includes(e.source._codec),expectedNextPcmPacketTimestamp:null,requiresAdtsStripping:a,primingPacket:t,preroll:{packetCount:0,accumulatedAudioSamples:0,audioSampleDurationHistory:[]}},timescale:i.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1,avgBitrate:e.source._nominalBitrate??e.metadata.averageBitrate??0,maxBitrate:e.source._nominalBitrate??e.metadata.bitrate??0};return this.trackDatas.push(o),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),o}getSubtitleTrackData(e,t){let n=this.trackDatas.find(t=>t.track===e);if(n)return n;ps(t),F(t),F(t.config);let r={muxer:this,track:e,type:`subtitle`,info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,startTimestampOffset:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],closed:!1,avgBitrate:e.source._nominalBitrate??e.metadata.averageBitrate??0,maxBitrate:e.source._nominalBitrate??e.metadata.bitrate??0,lastCueEndTimestamp:null,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(r),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getVideoTrackData(e,t,n),i=t.data;if(r.info.requiresAnnexBTransformation){let e=[...li(i)].map(e=>i.subarray(e.offset,e.offset+e.length));if(e.length===0)throw Error(`Failed to transform packet data. Make sure all packets are provided in Annex B format, as specified in ITU-T-REC-H.264 and ITU-T-REC-H.265.`);i=mi(e,4)}this.validateTimestamp(r.track,t.timestamp,t.type===`key`);let a=this.createSampleForTrack(r,i,t.timestamp,t.duration,t.type,0);await this.registerSample(r,a)}finally{r()}}async addEncodedAudioPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getAudioTrackData(e,t,n),i=t.data;if(r.info.requiresAdtsStripping){let e=ho(_o.tempFromBytes(i));if(!e)throw Error(`Expected ADTS frame, didn't get one.`);let t=e.crcCheck===null?7:9;i=i.subarray(t)}this.validateTimestamp(r.track,t.timestamp,t.type===`key`);let a=t.timestamp,o=t.duration;if(r.info.requiresPcmTransformation){let e=ns(r.info.decoderConfig.codec).sampleSize*r.info.numberOfChannels;if(o=i.byteLength/e/r.info.sampleRate,r.info.expectedNextPcmPacketTimestamp!==null){let e=a-r.info.expectedNextPcmPacketTimestamp;if(e<.01)a=r.info.expectedNextPcmPacketTimestamp;else{let t=await this.padWithSilence(r,r.info.expectedNextPcmPacketTimestamp,e);a=r.info.expectedNextPcmPacketTimestamp+t}}r.info.expectedNextPcmPacketTimestamp=a+o}let{preroll:s}=r.info,c=0;if(e.source._codec===`aac`||e.source._codec===`vorbis`)c=-Math.min(1,s.packetCount);else if(e.source._codec===`mp3`)c=-Math.min(2,s.packetCount);else if(e.source._codec===`opus`){let e=Math.round(es*$o);c=-s.audioSampleDurationHistory.length;let t=Vi(i);for(s.accumulatedAudioSamples+=t.durationInSamples,s.audioSampleDurationHistory.push(t.durationInSamples);s.accumulatedAudioSamples-s.audioSampleDurationHistory[0]>=e;)s.accumulatedAudioSamples-=s.audioSampleDurationHistory.shift(),F(s.audioSampleDurationHistory.length>0)}s.packetCount++;let l=this.createSampleForTrack(r,i,a,o,t.type,c);await this.registerSample(r,l)}finally{r()}}async padWithSilence(e,t,n){let r=K(n,e.timescale);if(n=r/e.timescale,r>0){let{sampleSize:i,silentValue:a}=ns(e.info.decoderConfig.codec),o=r*e.info.numberOfChannels,s=new Uint8Array(i*o).fill(a),c=this.createSampleForTrack(e,new Uint8Array(s.buffer),t,n,`key`,0);await this.registerSample(e,c)}return n}async addSubtitleCue(e,t,n){let r=await this.mutex.acquire();try{let r=this.getSubtitleTrackData(e,n);this.validateTimestamp(r.track,t.timestamp,!0),e.source._codec===`webvtt`&&(r.cueQueue.push(t),await this.processWebVTTCues(r,t.timestamp))}finally{r()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){e.lastCueEndTimestamp??=Math.min(0,e.cueQueue[0].timestamp);let n=new Set([]);for(let r of e.cueQueue)F(r.timestamp<=t),F(e.lastCueEndTimestamp<=r.timestamp+r.duration),n.add(Math.max(r.timestamp,e.lastCueEndTimestamp)),n.add(r.timestamp+r.duration);let r=[...n].sort((e,t)=>e-t),i=r[0],a=r[1]??i;if(t<a)break;if(e.lastCueEndTimestamp<i){this.auxWriter.seek(0);let t=Rc();this.auxBoxWriter.writeBox(t);let n=this.auxTarget._getSlice(0,this.auxWriter.getPos()),r=this.createSampleForTrack(e,n,e.lastCueEndTimestamp,i-e.lastCueEndTimestamp,`key`,0);await this.registerSample(e,r),e.lastCueEndTimestamp=i}this.auxWriter.seek(0);for(let t=0;t<e.cueQueue.length;t++){let n=e.cueQueue[t];if(n.timestamp>=a)break;sa.lastIndex=0;let r=sa.test(n.text),o=n.timestamp+n.duration,s=e.cueToSourceId.get(n);if(s===void 0&&a<o&&(s=e.nextSourceId++,e.cueToSourceId.set(n,s)),n.notes){let e=Bc(n.notes);this.auxBoxWriter.writeBox(e)}let c=zc(n.text,r?i:null,n.identifier??null,n.settings??null,s??null);this.auxBoxWriter.writeBox(c),o===a&&e.cueQueue.splice(t--,1)}let o=this.auxTarget._getSlice(0,this.auxWriter.getPos()),s=this.createSampleForTrack(e,o,i,a-i,`key`,0);await this.registerSample(e,s),e.lastCueEndTimestamp=a}}createSampleForTrack(e,t,n,r,i,a){return{timestamp:n,decodeTimestamp:n,duration:r,data:t,size:t.byteLength,type:i,timescaleUnitsToNextSample:K(r,e.timescale),prerollSamples:a}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type===`audio`&&e.info.requiresPcmTransformation){F(!this.isFragmented),e.startTimestampOffset??=e.timestampProcessingQueue[0].timestamp;let t=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){let r=e.timestampProcessingQueue[n],i=K(r.duration,e.timescale);t+=i}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:t,sampleDelta:1});else{let n=Rn(e.timeToSampleTable);n.sampleCount+=t}e.timestampProcessingQueue.length=0;return}let n=e.timestampProcessingQueue.map(e=>e.timestamp).sort((e,t)=>e-t);this.isFragmented?e.startTimestampOffset??=Math.min(n[0],0):e.startTimestampOffset??=n[0];for(let t=0;t<e.timestampProcessingQueue.length;t++){let r=e.timestampProcessingQueue[t];r.decodeTimestamp=n[t];let i=K(r.timestamp-r.decodeTimestamp,e.timescale),a=K(r.duration,e.timescale);if(e.lastTimescaleUnits!==null){F(e.lastSample);let t=K(r.decodeTimestamp,e.timescale,!1),n=Math.round(t-e.lastTimescaleUnits);if(F(n>=0),e.lastTimescaleUnits+=n,e.lastSample.timescaleUnitsToNextSample=n,!this.isFragmented){let t=Rn(e.timeToSampleTable);if(F(t),t.sampleCount===1){t.sampleDelta=n;let r=e.timeToSampleTable[e.timeToSampleTable.length-2];r&&r.sampleDelta===n&&(r.sampleCount++,e.timeToSampleTable.pop(),t=r)}else t.sampleDelta!==n&&(t.sampleCount--,e.timeToSampleTable.push(t={sampleCount:1,sampleDelta:n}));t.sampleDelta===a?t.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:a});let r=Rn(e.compositionTimeOffsetTable);F(r),r.sampleCompositionTimeOffset===i?r.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i})}}else e.lastTimescaleUnits=K(r.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:a}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i}));e.lastSample=r}if(e.timestampProcessingQueue.length=0,F(e.lastSample),F(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){F(t.type===`key`);let n=K(t.timestamp,e.timescale,!1),r=Math.round(n-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=r}}async registerSample(e,t){t.type===`key`&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),e.sampleQueue.push(t),await this.interleaveSamples()}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart===`reserve`)){let t=e.track.metadata.maximumPacketCount;if(F(t!==void 0),e.samples.length>t)throw Error(`Track #${e.track.id} has already reached the maximum packet count (${t}). Either add less packets or increase the maximum packet count.`)}let n=!1;if(!e.currentChunk)n=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);let r=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){let i=this.trackDatas.every(n=>{if(e===n)return t.type===`key`;let r=n.sampleQueue[0];return r?r.type===`key`:n.closed});r>=this.minimumFragmentDuration&&i&&t.timestamp>this.maxWrittenTimestamp&&(n=!0,await this.finalizeFragment())}else n=r>=dl}if(n){if(!this.isFragmented){let e=this.trackDatas.filter(e=>e.currentChunk&&t.timestamp-e.currentChunk.startTimestamp>=dl).sort((e,t)=>e.currentChunk.startTimestamp-t.currentChunk.startTimestamp);for(let t of e)await this.finalizeCurrentChunk(t)}e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null,trafIndex:null}}F(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp),this.maxWrittenEndTimestamp=Math.max(this.maxWrittenEndTimestamp,t.timestamp+t.duration),this.minWrittenTimestamp=Math.min(this.minWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){F(!this.isFragmented),F(this.writer);let t=e.currentChunk;F(t),e.currentChunk=null,e.finalizedChunks.push(t),this.finalizedChunks.push(t);let n=t.samples.length;if(e.type===`audio`&&e.info.requiresPcmTransformation&&(n=t.samples.reduce((t,n)=>t+K(n.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||Rn(e.compactlyCodedChunkTable).samplesPerChunk!==n)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:n}),this.fastStart===`in-memory`)t.offset=0;else{t.offset=this.writer.getPos();for(let e of t.samples)F(e.data),this.writer.write(e.data),e.data=null;await this.writer.flush()}}async interleaveSamples(e=!1){if(e||this.allTracksAreKnown()){this.fastStart===`reserve`&&!this.mdat&&await this.createFastStartReserveMdat();outer:for(;;){let t=null,n=1/0;for(let r of this.trackDatas){if(!e&&r.sampleQueue.length===0&&!r.closed)break outer;r.sampleQueue.length>0&&r.sampleQueue[0].timestamp<n&&(t=r,n=r.sampleQueue[0].timestamp)}if(!t)break;let r=t.sampleQueue.shift();await this.addSampleToTrack(t,r)}}}async finalizeFragment(e=!this.isCmaf){if(F(this.isFragmented),!this.wroteFragmentedHeader){this.wroteFragmentedHeader=!0;let e=this.initBoxWriter??this.boxWriter;F(e),this.formatOptions.onMoov&&e.writer.startTrackingWrites(),this.ensureOneEnabledTrack();let t=Ns(this);if(e.writeBox(t),this.formatOptions.onMoov){let{data:t,start:n}=e.writer.stopTrackingWrites();this.formatOptions.onMoov(t,n)}if(this.isCmaf){F(this.initWriter),await this.initWriter.flush(),await this.initWriter.finalize(),this.writer=await this.output._getRootWriter(!0),this.boxWriter=new hs(this.writer);let e=this.boxWriter.measureBox(ks()),t=this.boxWriter.measureBox(As(this,0));this.segmentHeaderSize=e+t,this.writer.seek(this.segmentHeaderSize)}}F(this.writer),F(this.boxWriter);let t=this.trackDatas.filter(e=>e.currentChunk);if(t.length===0){e&&await this.writer.flush();return}let n=this.nextFragmentNumber++,r=Oc(n,t),i=this.writer.getPos(),a=i+this.boxWriter.measureBox(r),o=a+8,s=1/0;for(let e=0;e<t.length;e++){let n=t[e];F(n.currentChunk),F(n.startTimestampOffset!==null),n.currentChunk.offset=o,n.currentChunk.moofOffset=i,n.currentChunk.trafIndex=e,n.currentChunk.startTimestamp-=n.startTimestampOffset;for(let e of n.currentChunk.samples)o+=e.size,e.timestamp-=n.startTimestampOffset,e.decodeTimestamp-=n.startTimestampOffset;s=Math.min(s,n.currentChunk.startTimestamp)}let c=o-a,l=c>=2**32;if(l)for(let e of t)e.currentChunk.offset+=8;this.formatOptions.onMoof&&this.writer.startTrackingWrites();let u=Oc(n,t);if(this.boxWriter.writeBox(u),this.formatOptions.onMoof){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMoof(e,t,s)}F(this.writer.getPos()===a),this.formatOptions.onMdat&&this.writer.startTrackingWrites();let d=js(l);d.size=c,this.boxWriter.writeBox(d),this.writer.seek(a+(l?16:8));for(let e of t)for(let t of e.currentChunk.samples)this.writer.write(t.data),t.data=null;if(this.formatOptions.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMdat(e,t)}for(let e of t)e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk),e.currentChunk=null;e&&await this.writer.flush()}async createFastStartReserveMdat(){F(this.writer),F(this.boxWriter),this.ensureOneEnabledTrack();let e=Ns(this),t=this.boxWriter.measureBox(e)+this.computeSampleTableSizeUpperBound()+4096;F(this.ftypSize!==null),this.writer.seek(this.ftypSize+t),this.formatOptions.onMdat&&this.writer.startTrackingWrites(),this.mdat=js(!0),this.boxWriter.writeBox(this.mdat)}computeSampleTableSizeUpperBound(){F(this.fastStart===`reserve`);let e=0;for(let t of this.trackDatas){let n=t.track.metadata.maximumPacketCount;F(n!==void 0),e+=8*Math.ceil(2/3*n),e+=4*n,e+=8*Math.ceil(2/3*n),e+=12*Math.ceil(2/3*n),e+=4*n,e+=8*n,t.type===`audio`&&(e+=2*n,e+=8*n)}return e}async onTrackClose(e){let t=await this.mutex.acquire(),n=this.trackDatas.find(t=>t.track===e);n&&(n.closed=!0,n.type===`subtitle`&&e.source._codec===`webvtt`&&await this.processWebVTTCues(n,1/0),this.processTimestamps(n)),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),await this.interleaveSamples(),t()}ensureOneEnabledTrack(){for(let e of[`video`,`audio`,`subtitle`]){let t=this.trackDatas.filter(t=>t.type===e);if(t.length!==0&&!t.some(e=>e.track.metadata.disposition?.default!==!1)){let e=t[0];e.track.metadata.disposition={...e.track.metadata.disposition,default:!0}}}}async forceFragmentFinalization(){F(this.isFragmented);let e=await this.mutex.acquire();try{for(let e of this.trackDatas)e.type===`subtitle`&&e.track.source._codec===`webvtt`&&await this.processWebVTTCues(e,1/0),this.processTimestamps(e);await this.interleaveSamples(!0),await this.finalizeFragment()}finally{e()}}async finalize(){let e=await this.mutex.acquire();this.allTracksKnown.resolve(),this.ensureOneEnabledTrack();for(let e of this.trackDatas)e.closed=!0,e.type===`subtitle`&&e.track.source._codec===`webvtt`&&await this.processWebVTTCues(e,1/0),this.processTimestamps(e);if(await this.interleaveSamples(!0),this.isFragmented)await this.finalizeFragment(!1);else{let e=this.trackDatas.filter(e=>e.currentChunk).sort((e,t)=>e.currentChunk.startTimestamp-t.currentChunk.startTimestamp);for(let t of e)await this.finalizeCurrentChunk(t);for(let e of this.trackDatas){let t=pl(e);if(t>0){let n=0;for(let t of e.samples)n+=t.size;e.avgBitrate=Math.round(8*n/t)}else e.avgBitrate=0;let n=0,r=0,i=0;for(let t=0;t<e.samples.length;t++){let a=e.samples[t];for(r+=a.size;a.decodeTimestamp-e.samples[n].decodeTimestamp>=1;)r-=e.samples[n].size,n++;i=Math.max(i,r)}if(e.maxBitrate=8*i,e.startTimestampOffset!==null)for(let t=0;t<e.samples.length;t++){let n=e.samples[t];n.timestamp-=e.startTimestampOffset,n.decodeTimestamp-=e.startTimestampOffset}}}if(F(this.writer),F(this.boxWriter),this.fastStart===`in-memory`){this.mdat=js(!1);let e;for(let t=0;t<2;t++){let t=Ns(this),n=this.boxWriter.measureBox(t);e=this.boxWriter.measureBox(this.mdat);let r=this.writer.getPos()+n+e;for(let t of this.finalizedChunks){t.offset=r;for(let{data:n}of t.samples)F(n),r+=n.byteLength,e+=n.byteLength}if(r<2**32)break;e>=2**32&&(this.mdat.largeSize=!0)}this.formatOptions.onMoov&&this.writer.startTrackingWrites();let t=Ns(this);if(this.boxWriter.writeBox(t),this.formatOptions.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMoov(e,t)}this.formatOptions.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=e,this.boxWriter.writeBox(this.mdat);for(let e of this.finalizedChunks)for(let t of e.samples)F(t.data),this.writer.write(t.data),t.data=null;if(this.formatOptions.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMdat(e,t)}}else if(this.isFragmented){if(this.isCmaf){let e=this.segmentHeaderSize===null?0:this.writer.getPos()-this.segmentHeaderSize;this.writer.seek(0),this.boxWriter.writeBox(ks()),this.boxWriter.writeBox(As(this,e))}else{let e=this.writer.getPos(),t=Fc(this.trackDatas);this.boxWriter.writeBox(t);let n=this.writer.getPos()-e;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(n)}}else{F(this.mdat);let e=this.boxWriter.offsets.get(this.mdat);F(e!==void 0);let t=this.writer.getPos()-e;if(this.mdat.size=t,this.mdat.largeSize=t>=2**32,this.boxWriter.patchBox(this.mdat),this.formatOptions.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMdat(e,t)}let n=Ns(this);if(this.fastStart===`reserve`){F(this.ftypSize!==null);let e=this.boxWriter.offsets.get(this.mdat)-this.ftypSize,t=this.boxWriter.measureBox(n);if(t+8>e)throw Error(`The moov box (${t} bytes) plus a free box (8 bytes) exceed the space reserved for them (${e} bytes) with fastStart: 'reserve'. This is a bug; please report it.`);this.writer.seek(this.ftypSize),this.formatOptions.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n),this.boxWriter.writeBox(Ms(e-t))}else this.formatOptions.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n);if(this.formatOptions.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.formatOptions.onMoov(e,t)}}e()}},hl=-(2**15),gl=2**15-1,_l=6,vl=5,yl={video:1,audio:2,subtitle:17},bl=class extends ms{constructor(e,t){super(e),this.trackDatas=[],this.allTracksKnown=nr(),this.segment=null,this.segmentInfo=null,this.seekHead=null,this.tracksElement=null,this.tagsElement=null,this.attachmentsElement=null,this.segmentDuration=null,this.cues=null,this.currentClusterBlocks=[],this.currentClusterStartMsTimestamp=null,this.currentClusterMaxMsTimestamp=null,this.startTimestamp=1/0,this.endTimestamp=-1/0,this.warnedAboutTooNegativeTimestamp=!1,this.format=t}async start(){let e=await this.mutex.acquire();this.writer=await this.output._getRootWriter(!!this.format._options.appendOnly),this.ebmlWriter=new uo(this.writer),this.writeEBMLHeader(),this.createSegmentInfo(),this.createCues(),await this.writer.flush();for(let e of this.output.tracks)e.isVideoTrack()&&e.metadata.decoderConfig?this.getVideoTrackData(e,e.metadata.primingPacket??null,{decoderConfig:e.metadata.decoderConfig}):e.isAudioTrack()&&e.metadata.decoderConfig&&this.getAudioTrackData(e,e.metadata.primingPacket??null,{decoderConfig:e.metadata.decoderConfig});e()}writeEBMLHeader(){this.format._options.onEbmlHeader&&this.writer.startTrackingWrites();let e={id:R.EBML,data:[{id:R.EBMLVersion,data:1},{id:R.EBMLReadVersion,data:1},{id:R.EBMLMaxIDLength,data:4},{id:R.EBMLMaxSizeLength,data:8},{id:R.DocType,data:this.format instanceof Dl?`webm`:`matroska`},{id:R.DocTypeVersion,data:4},{id:R.DocTypeReadVersion,data:2}]};if(this.ebmlWriter.writeEBML(e),this.format._options.onEbmlHeader){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onEbmlHeader(e,t)}}maybeCreateSeekHead(e){if(this.format._options.appendOnly)return;let t=new Uint8Array([28,83,187,107]),n=new Uint8Array([21,73,169,102]),r=new Uint8Array([22,84,174,107]),i=new Uint8Array([25,65,164,105]),a=new Uint8Array([18,84,195,103]),o={id:R.SeekHead,data:[{id:R.Seek,data:[{id:R.SeekID,data:n},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.segmentInfo)-this.segmentDataOffset:0}]},{id:R.Seek,data:[{id:R.SeekID,data:r},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.tracksElement)-this.segmentDataOffset:0}]},this.attachmentsElement?{id:R.Seek,data:[{id:R.SeekID,data:i},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.attachmentsElement)-this.segmentDataOffset:0}]}:null,this.tagsElement?{id:R.Seek,data:[{id:R.SeekID,data:a},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.tagsElement)-this.segmentDataOffset:0}]}:null,{id:R.Seek,data:[{id:R.SeekID,data:t},{id:R.SeekPosition,size:5,data:e?this.ebmlWriter.offsets.get(this.cues)-this.segmentDataOffset:0}]}]};this.seekHead=o}createSegmentInfo(){let e={id:R.Duration,data:new to(0)};this.segmentDuration=e;let t=this.output._metadataTags.creationTime===void 0?new Date:this.output._metadataTags.creationTime,n=null;if(t){let e=1000000n*BigInt(t.getTime()-fo);if(BigInt.asIntN(64,e)!==e)throw Error(`creationTime is out of the range representable by Matroska files.`);n={id:R.DateUTC,size:8,data:BigInt.asUintN(64,e)}}let r={id:R.Info,data:[{id:R.TimestampScale,data:1e6},this.format._options.appendOnly?null:e,n,{id:R.MuxingApp,data:oi},{id:R.WritingApp,data:oi}]};this.segmentInfo=r}createTracks(){let e={id:R.Tracks,data:[]};this.tracksElement=e;for(let t of this.trackDatas){let n=po[t.track.source._codec];F(n),t.type===`audio`&&t.track.source._codec===`dts`&&(t.info.decoderConfig.codec===`dtse`?n=`A_DTS/EXPRESS`:t.info.decoderConfig.codec===`dtsl`&&(n=`A_DTS/LOSSLESS`));let r=0;if(t.type===`audio`){let e=Qo(t.track.source._codec,t.info.decoderConfig);r=Math.round(1e9*e)}e.data.push({id:R.TrackEntry,data:[{id:R.TrackNumber,data:t.track.id},{id:R.TrackUID,data:t.track.id},{id:R.TrackType,data:yl[t.type]},t.track.metadata.disposition?.default===!1?{id:R.FlagDefault,data:0}:null,t.track.metadata.disposition?.forced?{id:R.FlagForced,data:1}:null,t.track.metadata.disposition?.hearingImpaired?{id:R.FlagHearingImpaired,data:1}:null,t.track.metadata.disposition?.visuallyImpaired?{id:R.FlagVisualImpaired,data:1}:null,t.track.metadata.disposition?.original?{id:R.FlagOriginal,data:1}:null,t.track.metadata.disposition?.commentary?{id:R.FlagCommentary,data:1}:null,{id:R.FlagLacing,data:0},{id:R.Language,data:t.track.metadata.languageCode??`und`},{id:R.CodecID,data:n},t.codecPrivate?{id:R.CodecPrivate,data:Un(t.codecPrivate)}:null,t.type===`audio`&&t.info.codecDelay?{id:R.CodecDelay,data:Math.round(1e9*t.info.codecDelay)}:null,r>0?{id:R.SeekPreRoll,data:r}:null,t.track.metadata.name===void 0?null:{id:R.Name,data:new ro(t.track.metadata.name)},t.type===`video`?this.videoSpecificTrackInfo(t):null,t.type===`audio`?this.audioSpecificTrackInfo(t):null,t.type===`subtitle`?this.subtitleSpecificTrackInfo(t):null]})}}videoSpecificTrackInfo(e){let{frameRate:t,transformationMatrix:n}=e.track.metadata,r=[t?{id:R.DefaultDuration,data:1e9/t}:null],i,a,o;if(n){i=jn(n);let e=In(Nn(-i),n);a=Math.sign(e[0]),o=Math.sign(e[4]),o===-1&&(o=1,a=-a,i=On(i+180))}else i=e.track.metadata.rotation??0,a=e.track.metadata.flip?-1:1,o=1;let s=i?On(a===-1?i:-i):0,c=Math.round(Math.acos(a)*Dn),l=Math.round(Math.acos(o)*Dn),u=!!e.info.aspectRatio&&e.info.aspectRatio.num*e.info.height!==e.info.aspectRatio.den*e.info.width,d=e.info.decoderConfig.colorSpace,f={id:R.Video,data:[{id:R.PixelWidth,data:e.info.width},{id:R.PixelHeight,data:e.info.height},u?{id:R.DisplayWidth,data:e.info.aspectRatio.num}:null,u?{id:R.DisplayHeight,data:e.info.aspectRatio.den}:null,u?{id:R.DisplayUnit,data:3}:null,e.info.alphaMode?{id:R.AlphaMode,data:1}:null,Xn(d)?null:{id:R.Colour,data:[{id:R.MatrixCoefficients,data:d?.matrix==null?2:Yn[d.matrix]},{id:R.TransferCharacteristics,data:d?.transfer==null?2:Jn[d.transfer]},{id:R.Primaries,data:d?.primaries==null?2:qn[d.primaries]},{id:R.Range,data:d?.fullRange==null?0:d.fullRange?2:1}]},s||c||l?{id:R.Projection,data:[{id:R.ProjectionType,data:0},c?{id:R.ProjectionPoseYaw,data:new eo(c)}:null,l?{id:R.ProjectionPosePitch,data:new eo(l)}:null,s?{id:R.ProjectionPoseRoll,data:new eo((s+180)%360-180)}:null]}:null]};return r.push(f),r}audioSpecificTrackInfo(e){let t=Io.includes(e.track.source._codec)?ns(e.track.source._codec):null;return[{id:R.Audio,data:[{id:R.SamplingFrequency,data:new eo(e.info.sampleRate)},{id:R.Channels,data:e.info.numberOfChannels},t?{id:R.BitDepth,data:8*t.sampleSize}:null]}]}subtitleSpecificTrackInfo(e){return[]}maybeCreateTags(){let e=[],t=(t,n)=>{e.push({id:R.SimpleTag,data:[{id:R.TagName,data:new ro(t)},typeof n==`string`?{id:R.TagString,data:new ro(n)}:{id:R.TagBinary,data:n}]})},n=this.output._metadataTags,r=new Set;for(let{key:e,value:i}of kr(n))switch(e){case`title`:t(`TITLE`,i),r.add(`TITLE`);break;case`description`:t(`DESCRIPTION`,i),r.add(`DESCRIPTION`);break;case`artist`:t(`ARTIST`,i),r.add(`ARTIST`);break;case`album`:t(`ALBUM`,i),r.add(`ALBUM`);break;case`albumArtist`:t(`ALBUM_ARTIST`,i),r.add(`ALBUM_ARTIST`);break;case`genre`:t(`GENRE`,i),r.add(`GENRE`);break;case`beatsPerMinute`:t(`BPM`,i.toString()),r.add(`BPM`);break;case`comment`:t(`COMMENT`,i),r.add(`COMMENT`);break;case`lyrics`:t(`LYRICS`,i),r.add(`LYRICS`);break;case`date`:t(`DATE`,i.toISOString().slice(0,10)),r.add(`DATE`);break;case`trackNumber`:t(`PART_NUMBER`,n.tracksTotal===void 0?i.toString():`${i}/${n.tracksTotal}`),r.add(`PART_NUMBER`);break;case`discNumber`:t(`DISC`,n.discsTotal===void 0?i.toString():`${i}/${n.discsTotal}`),r.add(`DISC`);break;case`tracksTotal`:case`discsTotal`:break;case`images`:case`raw`:case`creationTime`:break;default:rr(e)}if(n.raw)for(let e in n.raw){let i=n.raw[e];i==null||r.has(e)||(typeof i==`string`||i instanceof Uint8Array)&&t(e,i)}e.length!==0&&(this.tagsElement={id:R.Tags,data:[{id:R.Tag,data:[{id:R.Targets,data:[{id:R.TargetTypeValue,data:50},{id:R.TargetType,data:`MOVIE`}]},...e]}]})}maybeCreateAttachments(){let e=this.output._metadataTags,t=[],n=new Set,r=e.images??[];for(let e of r){let r=e.name;r===void 0&&(r=(e.kind===`coverFront`?`cover`:e.kind===`coverBack`?`back`:`image`)+(Ar(e.mimeType)??``));let i;for(;;){i=0n;for(let e=0;e<8;e++)i<<=8n,i|=BigInt(Math.floor(Math.random()*256));if(i!==0n&&!n.has(i))break}n.add(i),t.push({id:R.AttachedFile,data:[e.description===void 0?null:{id:R.FileDescription,data:new ro(e.description)},{id:R.FileName,data:new ro(r)},{id:R.FileMediaType,data:e.mimeType},{id:R.FileData,data:e.data},{id:R.FileUID,data:i}]})}for(let[n,i]of Object.entries(e.raw??{}))i instanceof Wr&&/^\d+$/.test(n)&&(r.find(e=>e.mimeType===i.mimeType&&jr(e.data,i.data))||t.push({id:R.AttachedFile,data:[i.description===void 0?null:{id:R.FileDescription,data:new ro(i.description)},{id:R.FileName,data:new ro(i.name??``)},{id:R.FileMediaType,data:i.mimeType??``},{id:R.FileData,data:i.data},{id:R.FileUID,data:BigInt(n)}]}));t.length!==0&&(this.attachmentsElement={id:R.Attachments,data:t})}createSegment(){this.createTracks(),this.maybeCreateTags(),this.maybeCreateAttachments(),this.maybeCreateSeekHead(!1);let e={id:R.Segment,size:this.format._options.appendOnly?-1:_l,data:[this.seekHead,this.segmentInfo,this.tracksElement,this.attachmentsElement,this.tagsElement]};if(this.segment=e,this.format._options.onSegmentHeader&&this.writer.startTrackingWrites(),this.ebmlWriter.writeEBML(e),this.format._options.onSegmentHeader){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onSegmentHeader(e,t)}}createCues(){this.cues={id:R.Cues,data:[]}}get segmentDataOffset(){return F(this.segment),this.ebmlWriter.dataOffsets.get(this.segment)}allTracksAreKnown(){for(let e of this.output.tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;let e=this.trackDatas.map(e=>e.type===`video`||e.type===`audio`?e.info.decoderConfig.codec:{webvtt:`wvtt`}[e.track.source._codec]);return mo({isWebM:this.format instanceof Dl,hasVideo:this.trackDatas.some(e=>e.type===`video`),hasAudio:this.trackDatas.some(e=>e.type===`audio`),codecStrings:e})}getVideoTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;us(n,e.source._codec),F(n),F(n.decoderConfig),F(n.decoderConfig.codedWidth!==void 0),F(n.decoderConfig.codedHeight!==void 0);let i=n.decoderConfig.displayAspectWidth,a=n.decoderConfig.displayAspectHeight,o=i===void 0||a===void 0?null:Fr({num:i,den:a}),s={track:e,type:`video`,info:{width:n.decoderConfig.codedWidth,height:n.decoderConfig.codedHeight,aspectRatio:o,decoderConfig:n.decoderConfig,alphaMode:e.metadata.canBeTransparent||(t?!!t.sideData.alpha:null)},chunkQueue:[],lastWrittenMsTimestamp:null,codecPrivate:n.decoderConfig.description??null,closed:!1};return e.source._codec===`vp9`?s.codecPrivate=new Uint8Array(Yo(s.info.decoderConfig.codec)):e.source._codec===`av1`?s.codecPrivate=new Uint8Array(Xo(s.info.decoderConfig.codec)):e.source._codec===`prores`&&(s.codecPrivate=Kn.encode(n.decoderConfig.codec)),this.trackDatas.push(s),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),s}getAudioTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;fs(n,e.source._codec),F(n),F(n.decoderConfig);let i={...n.decoderConfig},a=!1;if(e.source._codec===`aac`&&!i.description){if(!t)throw Error(`No AAC description provided; you must therefore provide a priming packet.`);let e=ho(_o.tempFromBytes(t.data));if(!e)throw Error(`Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.`);let n=Jr[e.samplingFrequencyIndex],r=Yr[e.channelConfiguration];if(n===void 0||r===void 0)throw Error(`Invalid ADTS frame header.`);i.description=ei({objectType:e.objectType,outputSampleRate:n,outputNumberOfChannels:r}),a=!0}let o={track:e,type:`audio`,info:{numberOfChannels:n.decoderConfig.numberOfChannels,sampleRate:n.decoderConfig.sampleRate,decoderConfig:i,requiresAdtsStripping:a,codecDelay:null},chunkQueue:[],lastWrittenMsTimestamp:null,codecPrivate:i.description??null,closed:!1};return this.trackDatas.push(o),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),o}getSubtitleTrackData(e,t){let n=this.trackDatas.find(t=>t.track===e);if(n)return n;ps(t),F(t),F(t.config);let r={track:e,type:`subtitle`,info:{config:t.config},chunkQueue:[],lastWrittenMsTimestamp:null,codecPrivate:Kn.encode(t.config.description),closed:!1};return this.trackDatas.push(r),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getVideoTrackData(e,t,n);r.info.alphaMode??=!!t.sideData.alpha;let i=t.data;if(e.source._codec===`prores`){if(i.byteLength<8)throw Error(`ProRes packet too small, expected at least 8 bytes.`);i=i.subarray(8)}let a=t.type===`key`;this.validateTimestamp(r.track,t.timestamp,a);let o=t.timestamp,s=t.duration;e.metadata.frameRate!==void 0&&(o=lr(o,e.metadata.frameRate),s=lr(s,e.metadata.frameRate));let c=r.info.alphaMode?t.sideData.alpha??null:null,l=this.createInternalChunk(i,o,s,t.type,c);e.source._codec===`vp9`&&this.fixVP9ColorSpace(r,l),r.chunkQueue.push(l),await this.interleaveChunks()}finally{r()}}async addEncodedAudioPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getAudioTrackData(e,t,n),i=t.data;if(r.info.requiresAdtsStripping){let e=ho(_o.tempFromBytes(i));if(!e)throw Error(`Expected ADTS frame, didn't get one.`);let t=e.crcCheck===null?7:9;i=i.subarray(t)}let a=t.type===`key`;this.validateTimestamp(r.track,t.timestamp,a),r.info.codecDelay??=Math.max(-t.timestamp,0);let o=this.createInternalChunk(i,t.timestamp+r.info.codecDelay,t.duration,t.type);r.chunkQueue.push(o),await this.interleaveChunks()}finally{r()}}async addSubtitleCue(e,t,n){let r=await this.mutex.acquire();try{let r=this.getSubtitleTrackData(e,n);this.validateTimestamp(r.track,t.timestamp,!0);let i=t.text,a=Math.round(t.timestamp*1e3);sa.lastIndex=0,i=i.replace(sa,e=>`<${ua(la(e.slice(1,-1))-a)}>`);let o=Kn.encode(i),s=`${t.settings??``}\n${t.identifier??``}\n${t.notes??``}`,c=this.createInternalChunk(o,t.timestamp,t.duration,`key`,s.trim()?Kn.encode(s):null);r.chunkQueue.push(c),await this.interleaveChunks()}finally{r()}}async interleaveChunks(e=!1){if(e||this.allTracksAreKnown()){outer:for(;;){let t=null,n=1/0;for(let r of this.trackDatas){if(!e&&r.chunkQueue.length===0&&!r.closed)break outer;r.chunkQueue.length>0&&r.chunkQueue[0].timestamp<n&&(t=r,n=r.chunkQueue[0].timestamp)}if(!t)break;let r=t.chunkQueue.shift();this.addBlock(t,r)}e||await this.writer.flush()}}fixVP9ColorSpace(e,t){if(t.type!==`key`||!e.info.decoderConfig.colorSpace||!e.info.decoderConfig.colorSpace.matrix)return;let n=new qr(t.data);n.skipBits(2);let r=n.readBits(1),i=(n.readBits(1)<<1)+r;if(i===3&&n.skipBits(1),n.readBits(1)||n.readBits(1)!==0||(n.skipBits(2),n.readBits(24)!==4817730))return;i>=2&&n.skipBits(1);let a={rgb:7,bt709:2,bt470bg:1,smpte170m:3}[e.info.decoderConfig.colorSpace.matrix];Hn(t.data,n.pos,n.pos+3,a)}createInternalChunk(e,t,n,r,i=null){return{data:e,type:r,timestamp:t,duration:n,additions:i}}addBlock(e,t){this.segment||this.createSegment();let n=Math.round(1e3*t.timestamp),r=this.trackDatas.every(n=>{if(e===n)return t.type===`key`;let r=n.chunkQueue[0];return r?r.type===`key`:n.closed}),i=!1;if(this.currentClusterStartMsTimestamp===null)i=!0;else{F(this.currentClusterMaxMsTimestamp!==null);let e=n-this.currentClusterStartMsTimestamp;i=r&&n>this.currentClusterMaxMsTimestamp&&e>=1e3*(this.format._options.minimumClusterDuration??1)||e>gl}if(i&&this.startNewCluster(n),n-this.currentClusterStartMsTimestamp<hl){if(!this.warnedAboutTooNegativeTimestamp){let e=this.format instanceof Dl?`WebM`:`Matroska`;Hr._warn(`Packets had to be discarded because their timestamp is too negative to represent in ${e}.`),this.warnedAboutTooNegativeTimestamp=!0}}else this.currentClusterBlocks.push({trackData:e,chunk:t,msTimestamp:n,previousMsTimestamp:e.lastWrittenMsTimestamp}),this.startTimestamp=Math.min(this.startTimestamp,n),this.endTimestamp=Math.max(this.endTimestamp,n+Math.round(1e3*t.duration)),e.lastWrittenMsTimestamp=n,this.currentClusterMaxMsTimestamp=Math.max(this.currentClusterMaxMsTimestamp,n)}startNewCluster(e){this.currentClusterStartMsTimestamp!==null&&this.writeCurrentCluster();let t=Math.max(0,e);this.currentClusterStartMsTimestamp=t,this.currentClusterMaxMsTimestamp=t}writeCurrentCluster(){F(this.currentClusterStartMsTimestamp!==null);let e=this.currentClusterStartMsTimestamp,t=new Map,n=new Map;for(let e of this.currentClusterBlocks)e.chunk.type===`key`&&!t.has(e.trackData)&&t.set(e.trackData,e),n.set(e.trackData,e);let r=new Map;for(let t of this.currentClusterBlocks)r.set(t,this.createBlockElement(t,e,n.get(t.trackData)===t));let i={id:R.Cluster,size:this.format._options.appendOnly?-1:vl,data:[{id:R.Timestamp,data:e},...r.values()]};if(this.format._options.onCluster&&this.writer.startTrackingWrites(),this.ebmlWriter.writeEBML(i),this.currentClusterBlocks=[],this.format._options.onCluster){let{data:t,start:n}=this.writer.stopTrackingWrites();this.format._options.onCluster(t,n,e/1e3)}let a=this.ebmlWriter.offsets.get(i)-this.segmentDataOffset,o=this.ebmlWriter.dataOffsets.get(i),s=new Map;for(let e of t.values())s.has(e.msTimestamp)||s.set(e.msTimestamp,[]),s.get(e.msTimestamp).push(e);let c=[...s.entries()].sort((e,t)=>e[0]-t[0]);for(let[e,t]of c)F(this.cues),this.cues.data.push({id:R.CuePoint,data:[{id:R.CueTime,data:Math.max(0,e)},...t.map(e=>{let t=this.ebmlWriter.offsets.get(r.get(e));return{id:R.CueTrackPositions,data:[{id:R.CueTrack,data:e.trackData.track.id},{id:R.CueClusterPosition,data:a},{id:R.CueRelativePosition,data:t-o}]}})]})}createBlockElement(e,t,n){let{trackData:r,chunk:i,msTimestamp:a}=e,o=new Uint8Array(4),s=new DataView(o.buffer);s.setUint8(0,128|r.track.id),s.setInt16(1,a-t,!1);let c=Math.round(1e3*i.duration);return i.additions||r.type===`subtitle`||n&&c>0?{id:R.BlockGroup,data:[{id:R.Block,data:[o,i.data]},i.type===`delta`?{id:R.ReferenceBlock,data:new no(e.previousMsTimestamp-a)}:null,i.additions?{id:R.BlockAdditions,data:[{id:R.BlockMore,data:[{id:R.BlockAddID,data:1},{id:R.BlockAdditional,data:i.additions}]}]}:null,c>0?{id:R.BlockDuration,data:c}:null]}:(s.setUint8(3,Number(i.type===`key`)<<7),{id:R.SimpleBlock,data:[o,i.data]})}async onTrackClose(e){let t=await this.mutex.acquire(),n=this.trackDatas.find(t=>t.track===e);n&&(n.closed=!0),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),await this.interleaveChunks(),t()}async finalize(){let e=await this.mutex.acquire();this.allTracksKnown.resolve();for(let e of this.trackDatas)e.closed=!0;if(this.segment||this.createSegment(),await this.interleaveChunks(!0),this.currentClusterStartMsTimestamp!==null&&this.writeCurrentCluster(),F(this.cues),this.ebmlWriter.writeEBML(this.cues),!this.format._options.appendOnly){let e=this.writer.getPos()-this.segmentDataOffset;this.writer.seek(this.ebmlWriter.offsets.get(this.segment)+4),this.ebmlWriter.writeVarInt(e,_l);let t=this.startTimestamp===1/0?0:this.endTimestamp;this.segmentDuration.data=new to(t),this.writer.seek(this.ebmlWriter.offsets.get(this.segmentDuration)),this.ebmlWriter.writeEBML(this.segmentDuration),F(this.seekHead),this.writer.seek(this.ebmlWriter.offsets.get(this.seekHead)),this.maybeCreateSeekHead(!0),this.ebmlWriter.writeEBML(this.seekHead)}e()}},xl=class{get supportsVideoRotationMetadata(){return this.supportsVideoTransformationMetadata}get requiresMaximumPacketCount(){return!1}getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>Fo.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>Ro.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>zo.includes(e))}_codecUnsupportedHint(e){return``}_isFragmentedIsobmff(){return!1}},Sl=class extends xl{constructor(e={}){if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.fastStart!==void 0&&![!1,`in-memory`,`reserve`,`fragmented`].includes(e.fastStart))throw TypeError(`options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.`);if(e.minimumFragmentDuration!==void 0&&(!Nr(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw TypeError(`options.minimumFragmentDuration, when provided, must be a non-negative number.`);if(e.onFtyp!==void 0&&typeof e.onFtyp!=`function`)throw TypeError(`options.onFtyp, when provided, must be a function.`);if(e.onMoov!==void 0&&typeof e.onMoov!=`function`)throw TypeError(`options.onMoov, when provided, must be a function.`);if(e.onMdat!==void 0&&typeof e.onMdat!=`function`)throw TypeError(`options.onMdat, when provided, must be a function.`);if(e.onMoof!==void 0&&typeof e.onMoof!=`function`)throw TypeError(`options.onMoof, when provided, must be a function.`);if(e.metadataFormat!==void 0&&![`mdir`,`mdta`,`udta`,`auto`].includes(e.metadataFormat))throw TypeError(`options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.`);super(),this._options=e}getSupportedTrackCounts(){let e=2**32-1;return{video:{min:0,max:e},audio:{min:0,max:e},subtitle:{min:0,max:e},total:{min:0,max:e}}}get supportsVideoTransformationMetadata(){return!0}get supportsTimestampedMediaData(){return!0}get negativeTimestampSupport(){return`full`}get requiresMaximumPacketCount(){return this._options.fastStart===`reserve`}_createMuxer(e){return new ml(e,this)}_isFragmentedIsobmff(){return this._options.fastStart===`fragmented`}},Cl=class extends Sl{constructor(e){super(e)}get _name(){return`MP4`}get fileExtension(){return`.mp4`}get mimeType(){return`video/mp4`}getSupportedCodecs(){return[...Fo,...Lo,`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,...zo]}_codecUnsupportedHint(e){return new Tl().getSupportedCodecs().includes(e)?` Switching to MOV will grant support for this codec.`:``}},wl=class extends Sl{constructor(e){super(e)}get _name(){return`CMAF`}get fileExtension(){return`.m4s`}get mimeType(){return`video/mp4`}getSupportedCodecs(){return[...Fo,...Lo,`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,...zo]}},Tl=class extends Sl{constructor(e){super(e)}get _name(){return`MOV`}get fileExtension(){return`.mov`}get mimeType(){return`video/quicktime`}getSupportedCodecs(){return[...Fo,...Ro]}_codecUnsupportedHint(e){return new Cl().getSupportedCodecs().includes(e)?` Switching to MP4 will grant support for this codec.`:``}},El=class extends xl{constructor(e={}){if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.appendOnly!==void 0&&typeof e.appendOnly!=`boolean`)throw TypeError(`options.appendOnly, when provided, must be a boolean.`);if(e.minimumClusterDuration!==void 0&&(!Nr(e.minimumClusterDuration)||e.minimumClusterDuration<0))throw TypeError(`options.minimumClusterDuration, when provided, must be a non-negative number.`);if(e.onEbmlHeader!==void 0&&typeof e.onEbmlHeader!=`function`)throw TypeError(`options.onEbmlHeader, when provided, must be a function.`);if(e.onSegmentHeader!==void 0&&typeof e.onSegmentHeader!=`function`)throw TypeError(`options.onHeader, when provided, must be a function.`);if(e.onCluster!==void 0&&typeof e.onCluster!=`function`)throw TypeError(`options.onCluster, when provided, must be a function.`);super(),this._options=e}_createMuxer(e){return new bl(e,this)}get _name(){return`Matroska`}getSupportedTrackCounts(){return{video:{min:0,max:127},audio:{min:0,max:127},subtitle:{min:0,max:127},total:{min:0,max:127}}}get fileExtension(){return`.mkv`}get mimeType(){return`video/x-matroska`}getSupportedCodecs(){return[...Fo,...Lo,...Io.filter(e=>![`pcm-s8`,`pcm-f32be`,`pcm-f64be`,`ulaw`,`alaw`].includes(e)),...zo]}get supportsVideoTransformationMetadata(){return!1}get supportsTimestampedMediaData(){return!0}get negativeTimestampSupport(){return`prefer-non-negative`}},Dl=class extends El{constructor(e){super(e)}getSupportedCodecs(){return[...Fo.filter(e=>[`vp8`,`vp9`,`av1`].includes(e)),...Ro.filter(e=>[`opus`,`vorbis`].includes(e)),...zo]}get _name(){return`WebM`}get fileExtension(){return`.webm`}get mimeType(){return`video/webm`}_codecUnsupportedHint(e){return new El().getSupportedCodecs().includes(e)?` Switching to MKV will grant support for this codec.`:``}},Ol=[`video`,`audio`,`subtitle`],kl=class e{constructor(e,t,n,r,i){this.id=e,this.output=t,this.type=n,this.source=r,this.metadata=i}isVideoTrack(){return this.type===`video`}isAudioTrack(){return this.type===`audio`}isSubtitleTrack(){return this.type===`subtitle`}canBePairedWith(t){if(!(t instanceof e))throw TypeError(`other must be an OutputTrack.`);if(this===t)return!1;let n=Rr(this.metadata.group),r=Rr(t.metadata.group);for(let e of n)if(this.type!==t.type&&r.some(t=>e===t)||r.some(t=>e._pairedGroups.has(t)))return!0;return!1}},Al=class extends kl{constructor(e,t,n,r){super(e,t,`video`,n,r)}},jl=class extends kl{constructor(e,t,n,r){super(e,t,`audio`,n,r)}},Ml=class extends kl{constructor(e,t,n,r){super(e,t,`subtitle`,n,r)}},Nl=class e{constructor(){this._pairedGroups=new Set}pairWith(t){if(!(t instanceof e))throw TypeError(`other must be an OutputTrackGroup.`);if(this===t)throw TypeError(`Cannot pair a group with itself.`);this._pairedGroups.add(t),t._pairedGroups.add(this)}},Pl=e=>{if(!e||typeof e!=`object`)throw TypeError(`metadata must be an object.`);if(e.languageCode!==void 0&&!pr(e.languageCode))throw TypeError(`metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.`);if(e.name!==void 0&&typeof e.name!=`string`)throw TypeError(`metadata.name, when provided, must be a string.`);if(e.disposition!==void 0&&Kr(e.disposition),e.maximumPacketCount!==void 0&&(!Number.isInteger(e.maximumPacketCount)||e.maximumPacketCount<0))throw TypeError(`metadata.maximumPacketCount, when provided, must be a non-negative integer.`);if(e.bitrate!==void 0&&(!Number.isFinite(e.bitrate)||e.bitrate<0))throw TypeError(`metadata.bitrate, when provided, must be a non-negative number.`);if(e.averageBitrate!==void 0&&(!Number.isFinite(e.averageBitrate)||e.averageBitrate<0))throw TypeError(`metadata.averageBitrate, when provided, must be a non-negative number.`);if(e.group!==void 0&&!(e.group instanceof Nl)&&(!Array.isArray(e.group)||e.group.some(e=>!(e instanceof Nl))))throw TypeError(`metadata.group, when provided, must be an OutputTrackGroup instance or an array of OutputTrackGroup instances.`)},Fl=class extends zr{get target(){let e=`Output.target cannot be used when using PathedTarget with an async callback. Use the 'target' event instead.`;if(this._rootTargetPromise)throw TypeError(e);let t=this._getRootTarget();if(Or(t))throw TypeError(e);return t}constructor(e){if(super(),this.state=`pending`,this.defaultTrackGroup=new Nl,this.tracks=[],this._onFinalize=null,this._unfinalizedTargets=new Set,this._rootWriterPromise=null,this._startPromise=null,this._cancelPromise=null,this._finalizePromise=null,this._mutex=new Qn,this._metadataTags={},this._rootTarget=null,this._rootTargetPromise=null,this._firstMediaStreamTimestamp=null,!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(!(e.format instanceof xl))throw TypeError(`options.format must be an OutputFormat.`);if(!(e.target instanceof il||e.target instanceof ll))throw TypeError(`options.target must be a Target or a PathedTarget.`);if(e.target instanceof il&&this._rememberTarget(e.target),e.initTarget!==void 0&&!(e.initTarget instanceof il)&&typeof e.initTarget!=`function`)throw Error(`options.initTarget, when provided, must be a Target or a function that returns or resolves to a Target.`);if(e.onFinalize!==void 0&&typeof e.onFinalize!=`function`)throw TypeError(`options.onFinalize, when provided, must be a function.`);this.format=e.format,this._target=e.target,this._onFinalize=e.onFinalize??null,this._initTarget=e.initTarget??null,this._initTarget instanceof il&&this._rememberTarget(this._initTarget),this._muxer=e.format._createMuxer(this)}_getTargetValidated(e){F(this._target instanceof ll);let t=this._target.getTarget(e),n=e=>{if(!(e instanceof il))throw TypeError(`getTarget must return a Target.`);return e};return Or(t)?t.then(n):n(t)}async _getTarget(e){F(this._target instanceof ll);let t=await this._getTargetValidated(e);return this._emit(`target`,{target:t,request:e,isRoot:e.isRoot}),this.state===`canceled`?await t._close():this._rememberTarget(t),t}_rememberTarget(e){this._unfinalizedTargets.add(e),e.on(`finalized`,()=>this._unfinalizedTargets.delete(e),{once:!0})}async _getInitTarget(){if(F(this._initTarget!==null),this._initTarget instanceof il)return this._initTarget;let e=await this._initTarget();return this.state===`canceled`?await e._close():this._rememberTarget(e),e}_hasInitTarget(){return this._initTarget!==null}_getRootTarget(){if(this._rootTarget)return this._rootTarget;if(this._rootTargetPromise)return this._rootTargetPromise;if(this._target instanceof il)return this._emit(`target`,{target:this._target,request:null,isRoot:!0}),this._rootTarget=this._target,this._target;let e={path:this._target.rootPath,isRoot:!0,mimeType:this.format.mimeType},t=this._getTargetValidated(e),n=t=>(this.state===`canceled`?t._close():this._rememberTarget(t),this._emit(`target`,{target:t,request:e,isRoot:!0}),this._rootTarget=t,t);return Or(t)?this._rootTargetPromise=t.then(n):n(t)}_getRootWriter(e){return this._rootWriterPromise??=(async()=>{let t=await this._getRootTarget(),n=new rl(t,typeof e==`boolean`?e:e(t));return n.start(),n})()}addVideoTrack(e,t={}){if(!(e instanceof wo))throw TypeError(`source must be a VideoSource.`);if(Pl(t),t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);if(t.flip!==void 0&&typeof t.flip!=`boolean`)throw TypeError(`metadata.flip, when provided, must be a boolean.`);if(t.transformationMatrix!==void 0&&(!Array.isArray(t.transformationMatrix)||t.transformationMatrix.length!==9||!t.transformationMatrix.every(e=>Number.isFinite(e))))throw TypeError(`metadata.transformationMatrix, when provided, must be an array of 9 finite numbers.`);if(t.frameRate!==void 0&&(!Number.isFinite(t.frameRate)||t.frameRate<=0))throw TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);if(t.hasOnlyKeyPackets!==void 0&&typeof t.hasOnlyKeyPackets!=`boolean`)throw TypeError(`metadata.hasOnlyKeyPackets, when provided, must be a boolean.`);if(t.canBeTransparent!==void 0&&typeof t.canBeTransparent!=`boolean`)throw TypeError(`metadata.canBeTransparent, when provided, must be a boolean.`);if(t.decoderConfig!==void 0&&us({decoderConfig:t.decoderConfig},e._codec),t.primingPacket!==void 0){if(!(t.primingPacket instanceof Za))throw TypeError(`metadata.primingPacket, when provided, must be an EncodedPacket.`);if(t.decoderConfig===void 0)throw TypeError(`metadata.primingPacket can only be provided alongside metadata.decoderConfig.`)}let n={...t};return n.group??=this.defaultTrackGroup,this._addTrack(new Al(this.tracks.length+1,this,e,n))}addAudioTrack(e,t={}){if(!(e instanceof No))throw TypeError(`source must be an AudioSource.`);if(Pl(t),t.decoderConfig!==void 0&&fs({decoderConfig:t.decoderConfig},e._codec),t.primingPacket!==void 0){if(!(t.primingPacket instanceof Za))throw TypeError(`metadata.primingPacket, when provided, must be an EncodedPacket.`);if(t.decoderConfig===void 0)throw TypeError(`metadata.primingPacket can only be provided alongside metadata.decoderConfig.`)}let n={...t};return n.group??=this.defaultTrackGroup,this._addTrack(new jl(this.tracks.length+1,this,e,n))}addSubtitleTrack(e,t={}){if(!(e instanceof Po))throw TypeError(`source must be a SubtitleSource.`);Pl(t);let n={...t};return n.group??=this.defaultTrackGroup,this._addTrack(new Ml(this.tracks.length+1,this,e,n))}setMetadataTags(e){if(Gr(e),this.state!==`pending`)throw Error(`Cannot set metadata tags after output has been started or canceled.`);this._metadataTags=e}_addTrack(e){if(this.state!==`pending`)throw Error(`Cannot add track after output has been started or canceled.`);if(e.source._connectedTrack)throw Error(`Source is already used for a track.`);let t=this.format.getSupportedTrackCounts(),n=this.tracks.reduce((t,n)=>t+ +(n.type===e.type),0),r=t[e.type].max;if(n===r)throw Error(r===0?`${this.format._name} does not support ${e.type} tracks.`:`${this.format._name} does not support more than ${r} ${e.type} track${r===1?``:`s`}.`);let i=t.total.max;if(this.tracks.length===i)throw Error(`${this.format._name} does not support more than ${i} tracks${i===1?``:`s`} in total.`);if(e.isVideoTrack()){let t=this.format.getSupportedVideoCodecs();if(t.length===0)throw Error(`${this.format._name} does not support video tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${t.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(e.source._codec))}else if(e.isAudioTrack()){let t=this.format.getSupportedAudioCodecs();if(t.length===0)throw Error(`${this.format._name} does not support audio tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${t.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(e.source._codec))}else if(e.isSubtitleTrack()){let t=this.format.getSupportedSubtitleCodecs();if(t.length===0)throw Error(`${this.format._name} does not support subtitle tracks.`+this.format._codecUnsupportedHint(e.source._codec));if(!t.includes(e.source._codec))throw Error(`Codec '${e.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${t.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(e.source._codec))}return this.tracks.push(e),e.source._connectedTrack=e,e}hasEnoughTracks(){let e=this.format.getSupportedTrackCounts();for(let t of Ol)if(this.tracks.reduce((e,n)=>e+ +(n.type===t),0)<e[t].min)return!1;let t=e.total.min;return!(this.tracks.length<t)}async start(){let e=this.format.getSupportedTrackCounts();for(let t of Ol){let n=this.tracks.reduce((e,n)=>e+ +(n.type===t),0),r=e[t].min;if(n<r)throw Error(r===e[t].max?`${this.format._name} requires exactly ${r} ${t} track${r===1?``:`s`}.`:`${this.format._name} requires at least ${r} ${t} track${r===1?``:`s`}.`)}let t=e.total.min;if(this.tracks.length<t)throw Error(t===e.total.max?`${this.format._name} requires exactly ${t} track${t===1?``:`s`}.`:`${this.format._name} requires at least ${t} track${t===1?``:`s`}.`);if(this.state===`canceled`)throw Error(`Output has been canceled.`);return this._startPromise?(Hr._warn(`Output has already been started.`),this._startPromise):this._startPromise=(async()=>{this.state=`started`;let e=this._mutex.acquire();try{await this._muxer.start();let e=this.tracks.map(e=>e.source._start());await Promise.all(e)}finally{(await e)()}})()}getMimeType(){return this._muxer.getMimeType()}async cancel(){if(this.state===`canceled`)return this._cancelPromise??void 0;if(this.state===`finalizing`||this.state===`finalized`)this.state===`finalized`&&Hr._warn(`Output has already been finalized.`);else return this._cancelPromise=(async()=>{this.state=`canceled`;let e=await this._mutex.acquire();try{let e=this.tracks.map(e=>e.source._flushOrWaitForOngoingClose(!0));await Promise.all(e),await Promise.all([...this._unfinalizedTargets].map(e=>e._close())),this._unfinalizedTargets.clear()}finally{e()}})()}async finalize(){if(this.state===`pending`)throw Error(`Cannot finalize before starting.`);if(this.state===`canceled`)throw Error(`Cannot finalize after canceling.`);return this._finalizePromise?(Hr._warn(`Output has already been finalized.`),this._finalizePromise):this._finalizePromise=(async()=>{this.state=`finalizing`;let e=await this._mutex.acquire();try{let e=this.tracks.map(e=>e.source._flushOrWaitForOngoingClose(!1));if(await Promise.all(e),await this._muxer.finalize(),this._rootWriterPromise){let e=await this._rootWriterPromise;e.finalized||(await e.flush(),await e.finalize())}this._onFinalize&&await this._onFinalize(),this.state=`finalized`}catch(e){throw this.state=`canceled`,e}finally{await Promise.all([...this._unfinalizedTargets].map(e=>e._close().catch(()=>{}))),this._unfinalizedTargets.clear(),e()}})()}},Il=Tn(),Ll=e=>e===!0?{}:e||null;function Rl(e){let t=Math.max(1,e/900);return{u:t,top:Math.round(44*t),bottom:Math.round(84*t)}}function zl(e){let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(`--lm-${e}`).trim()||n;return{font:t.fontFamily||`sans-serif`,mono:n(`mono`,`monospace`),bg:n(`bg`,`#eef2f5`),surface:n(`surface`,`#ffffff`),fg:n(`fg`,`#17212b`),accent:n(`accent`,`#0b6b8f`),muted:n(`muted`,`#5d6d7c`),line:n(`line`,`#c6d0da`),ok:n(`ok`,`#2a7f5a`),warn:n(`warn`,`#b86e00`),drop:n(`drop`,`#b7392e`),series:[1,2,3,4].map(e=>n(`s${e}`,`#5d6d7c`))}}var Bl=(e,t)=>t===`over`?e.drop:t===`warn`?e.warn:e.ok;function Vl(e,t){let{model:n,ev:r}=e.engine,i=n.scenarioOf(r.values);return{title:t.title??n.title??``,where:[t.step,i?.label,`${s(r.values.load)}× today`].filter(Boolean).join(` · `),verdict:t.text??r.verdict.text,tier:r.verdict.tier}}function Hl(e,t,n,r=1/0){let i=[],a=``;for(let r of t.split(/\s+/).filter(Boolean)){let t=a?`${a} ${r}`:r;!a||e(t)<=n?a=t:(i.push(a),a=r)}if(a&&i.push(a),i.length<=r)return i;let o=i.slice(0,r),s=o[r-1];for(;s&&e(`${s}…`)>n;)s=s.slice(0,-1);return o[r-1]=`${s.trimEnd()}…`,o}function Ul(e,t,n,r,i){let a=zl(t.board().svg),{u:o,top:s,bottom:c}=Rl(r),l=Vl(t,n),u=14*o;e.save(),e.setTransform(1,0,0,1,0,0),e.fillStyle=a.line,e.fillRect(0,s-o,r,o),e.fillRect(0,i-c,r,o),e.textBaseline=`middle`,e.font=`500 ${13*o}px ${a.font}`,e.fillStyle=a.muted,e.textAlign=`right`,e.fillText(l.where,r-u,s/2);let d=e.measureText(l.where).width;e.font=`600 ${16*o}px ${a.font}`,e.fillStyle=a.fg,e.textAlign=`left`,e.fillText(l.title,u,s/2,Math.max(0,r-3*u-d)),e.fillStyle=Bl(a,l.tier),e.fillRect(u,i-c+12*o,4*o,c-24*o),e.font=`400 ${14*o}px ${a.font}`,e.fillStyle=a.fg,e.textBaseline=`top`,Hl(t=>e.measureText(t).width,l.verdict,r-2*u-14*o,3).forEach((t,n)=>{e.fillText(t,u+14*o,i-c+(14+n*20)*o)}),e.restore()}function Wl(e,t,n,r,i){let a=t.board(),o=zl(a.svg),s=Math.max(.75,r/a.scene.width),c=r/s<=520,l=12*s;e.save(),e.textBaseline=`top`,e.textAlign=`left`;let u=`600 ${(c?11.5:13.5)*s}px ${o.font}`,d=`500 ${11.5*s}px ${o.mono}`;e.font=u;let f=c?r-16*s:Math.min(476*s,r-2*l)-28*s,p=Hl(t=>e.measureText(t).width,n.title,f,c?1:2);e.font=d;let m=c||!n.detail?[]:Hl(t=>e.measureText(t).width,n.detail,f,1),h=18*s,g=(c?6:15)*s+p.length*h+m.length*16*s;e.font=u;let _=Math.max(...p.map(t=>e.measureText(t).width),...m.map(t=>(e.font=d,e.measureText(t).width))),v=c?r:_+28*s,y=c?0:l,b=c?0:n.top?l:i-l-g;e.globalAlpha=.94,e.fillStyle=o.surface,e.fillRect(y,b,v,g),e.globalAlpha=1,c||(e.fillStyle=o.accent,e.fillRect(y,b,4*s,g));let x=y+(c?8:16)*s,S=b+(c?3:7)*s;e.font=u,e.fillStyle=o.fg;for(let t of p)e.fillText(t,x,S),S+=h;e.font=d,e.fillStyle=o.muted;for(let t of m)e.fillText(t,x,S);e.restore()}var Gl=[`fill`,`stroke`,`color`];function Kl(e,t,n){let r=e.cloneNode(!0),i=[e,...e.querySelectorAll(`*`)],a=[r,...r.querySelectorAll(`*`)];i.forEach((e,t)=>{let n=getComputedStyle(e),r=a[t];for(let e of Gl){let t=r.getAttribute(e);t&&(t.includes(`var(`)||t===`currentColor`)&&r.setAttribute(e,n.getPropertyValue(e))}r.style?.color&&(r.style.color=n.color);for(let e of[`tabindex`,`aria-describedby`,`class`])r.removeAttribute(e)});let o=getComputedStyle(e);return r.setAttribute(`font-family`,o.fontFamily),r.setAttribute(`color`,o.color),r.setAttribute(`width`,String(t)),r.setAttribute(`height`,String(n)),r.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),r}var ql=`http://www.w3.org/2000/svg`;function Jl(e,t,n){let r=document.createElementNS(ql,e);for(let[e,n]of Object.entries(t))r.setAttribute(e,String(n));return n!=null&&(r.textContent=n),r}async function Yl(e,t={}){await e.ready();let n=e.board(),{width:r,height:i}=n.scene,a=Kl(n.svg,r,i),o=Jl(`g`,{});for(let t of e.engine.dots())o.appendChild(Jl(`circle`,t.ring?{cx:t.x.toFixed(2),cy:t.y.toFixed(2),r:t.r-t.ring/2,fill:`none`,stroke:t.color,"stroke-width":t.ring,...t.alpha<1?{"stroke-opacity":t.alpha.toFixed(3)}:{}}:{cx:t.x.toFixed(2),cy:t.y.toFixed(2),r:t.r,fill:t.color,...t.alpha<1?{"fill-opacity":t.alpha.toFixed(3)}:{}}));a.appendChild(o);let s=Ll(t.caption);if(!s)return new XMLSerializer().serializeToString(a);let c=zl(n.svg),{top:l,bottom:u}=Rl(r),d=i+l+u,f=Vl(e,s),p=Jl(`svg`,{xmlns:ql,width:r,height:d,viewBox:`0 0 ${r} ${d}`,"font-family":c.font});p.appendChild(Jl(`rect`,{width:r,height:d,fill:c.surface})),p.appendChild(Jl(`text`,{x:14,y:l/2+5,"font-size":16,"font-weight":600,fill:c.fg},f.title)),p.appendChild(Jl(`text`,{x:r-14,y:l/2+5,"font-size":13,"text-anchor":`end`,fill:c.muted},f.where)),p.appendChild(Jl(`rect`,{x:0,y:l-1,width:r,height:1,fill:c.line})),a.setAttribute(`y`,String(l)),p.appendChild(a),p.appendChild(Jl(`rect`,{x:0,y:l+i,width:r,height:1,fill:c.line})),p.appendChild(Jl(`rect`,{x:14,y:l+i+12,width:4,height:u-24,fill:Bl(c,f.tier)}));let m=document.createElement(`canvas`).getContext(`2d`);return m.font=`400 14px ${c.font}`,Hl(e=>m.measureText(e).width,f.verdict,r-42,3).forEach((e,t)=>{p.appendChild(Jl(`text`,{x:28,y:l+i+28+t*20,"font-size":14,fill:c.fg},e))}),new XMLSerializer().serializeToString(p)}function Xl(e){let t=Math.max(720,Math.min(1400,e.width+48)),n=t-48;return{W:t,pad:24,inner:n,boardH:e.height*n/e.width}}async function Zl(e,t,n=2){let r=e.board(),{model:i,ev:a}=e.engine,o=zl(r.svg),{W:c,pad:d,inner:p,boardH:m}=Xl(r.scene),h=e=>{let t=i.dateAt(e);return t?` (${_(t,!0)})`:``},g=(e,t)=>e?`${u(e,i.searchMax,!0)}${h(e.low)}`:`${l(t,i.searchMax)}${h(t)}`,v=Vl(e,{}),y=i.growth,x=[v.where,y&&`load grows ${s(y.rate*100)} % a ${y.per} from ${_(b(y.asOf))}`].filter(Boolean).join(` · `),S=i.scenarios.length>1?xe(i,a.values.load):null,C=a.assumptions.flatMap(e=>e.kind===`capacity`&&e.capacity.provenance===`estimated`?[e.name]:[]),w=document.createElement(`canvas`).getContext(`2d`),T=(e,t,n=!1)=>`${e} ${t}px ${n?o.mono:o.font}`,E=(e,t,n)=>(w.font=t,Hl(e=>w.measureText(e).width,e,n)),D=E(v.verdict,T(400,15),p-20),O=a.measure?E(a.measure.text,T(400,13),p-20):[],ee=S?E(S.text,T(400,14),p):[],k=[],A=(e,t,n,r,i,a,o=`left`)=>{e.font=i,e.fillStyle=a,e.textAlign=o,e.fillText(t,n,r)},te=e=>k.push([30,(t,n)=>A(t,e.toUpperCase(),d,n+20,T(600,11),o.muted)]);k.push([34,(e,t)=>A(e,v.title,d,t+26,T(600,22),o.fg)]),k.push([26,(e,t)=>A(e,x,d,t+16,T(400,13),o.muted)]),k.push([m+16,(e,n)=>{e.fillStyle=o.line,e.fillRect(d-1,n+7,p+2,m+2),e.drawImage(t,d,n+8,p,m)}]),k.push([D.length*22+20,(e,t)=>{e.fillStyle=Bl(o,v.tier),e.fillRect(d,t+6,4,D.length*22+8),D.forEach((n,r)=>{A(e,n,d+16,t+24+r*22,T(400,15),o.fg)})}]),O.length&&k.push([O.length*18+6,(e,t)=>{O.forEach((n,r)=>{A(e,n,d+16,t+14+r*18,T(400,13),o.muted)})}]),te(`Where it runs out, in order`);let ne=Math.max(1.5,i.thresholds.full*1.5);k.push([16,(e,t)=>{let n=i.thresholds;A(e,`0`,d,t+10,T(400,11,!0),o.muted),A(e,`${f(n.target)} target`,d+p*n.target/ne,t+10,T(400,11,!0),o.muted,`center`),A(e,f(n.full),d+p*n.full/ne,t+10,T(400,11,!0),o.muted,`center`),A(e,f(ne),c-d,t+10,T(400,11,!0),o.muted,`right`)}]);for(let e of a.ranked)k.push([46,(t,n)=>{let r=e===a.firstLimit?` · limit`:``;A(t,`${e.name}${r}`,d,n+16,T(600,14),o.fg);let s=e.util==null?`switched off`:`${f(e.util)} now · ${f(i.thresholds.target)} at ${g(e.targetRange,e.target)} · ${f(i.thresholds.full)} at ${g(e.fullRange,e.full)}`;A(t,s,c-d,n+16,T(400,12,!0),o.muted,`right`),t.fillStyle=o.bg,t.fillRect(d,n+24,p,10),t.fillStyle=e.state===`over`?o.drop:e.state===`warn`?o.warn:o.ok,t.fillRect(d,n+24,p*Math.min(ne,e.util??0)/ne,10),t.fillStyle=o.fg;for(let e of[i.thresholds.target,i.thresholds.full])t.fillRect(d+p*e/ne,n+22,1,14)}]);S&&(te(`Scenarios compared`),k.push([ee.length*20+6,(e,t)=>{ee.forEach((n,r)=>{A(e,n,d,t+15+r*20,T(400,14),o.fg)})}]),S.rows.forEach((e,t)=>{k.push([26,(n,r)=>{n.fillStyle=o.series[t]??o.muted,n.beginPath(),n.arc(d+5,r+13,5,0,Math.PI*2),n.fill(),A(n,e.label,d+18,r+18,T(600,14),o.fg);let a=`limited by ${e.firstLimit?.name??`—`} · ${f(i.thresholds.target)} at ${g(e.targetRange,e.target)} · runs out at ${g(e.fullRange,e.full)}`;A(n,a,c-d,r+18,T(400,12,!0),o.muted,`right`)}])})),C.length&&k.push([30,(e,t)=>A(e,`Estimated capacities: ${C.join(`, `)}.`,d,t+22,T(400,12),o.muted)]);let re=Math.ceil(k.reduce((e,[t])=>e+t,0)+2*d),ie=document.createElement(`canvas`);ie.width=Math.round(c*n),ie.height=Math.round(re*n);let ae=ie.getContext(`2d`);ae.scale(n,n),ae.fillStyle=o.surface,ae.fillRect(0,0,c,re),ae.textBaseline=`alphabetic`;let j=d;for(let[e,t]of k)t(ae,j),j+=e;return ie}function Ql(e,t){if(t.step==null)return e.setValues($l(e,t));if(!e.engine.model.story[t.step])throw Error(`loadmap: the story has no step ${t.step+1}`);e.setStoryStep(t.step)}function $l(e,t){if(t.scenario==null)return{...t.set};let n=e.engine.model,r=n.scenarios.find(e=>e.label===t.scenario);if(!r){let e=n.scenarios.map(e=>`"${e.label}"`).join(`, `);throw Error(`loadmap: no scenario "${t.scenario}"; ${e?`the model has ${e}`:`the model has none`}`)}return{...r.values,...t.set}}async function q(e,t={},n){await e.ready();let r=e.board(),i=Ll(t.caption),a=t.size?.width??du(r.scene.width*(t.scale??2)),o=i?Rl(a):{top:0,bottom:0},s=t.size?.height??du(r.scene.height*(t.scale??2)+o.top+o.bottom),c=s-o.top-o.bottom,l=Math.min(a/r.scene.width,c/r.scene.height),u=r.scene.width*l,d=r.scene.height*l,f=n??document.createElement(`canvas`);(f.width!==a||f.height!==s)&&(f.width=a,f.height=s);let p=f.getContext(`2d`);p.setTransform(1,0,0,1,0,0),p.fillStyle=getComputedStyle(r.svg).getPropertyValue(`--lm-surface`).trim()||`#fff`,p.fillRect(0,0,a,s);let m=await pu(r.svg,Math.round(u),Math.round(d));return p.translate((a-u)/2,o.top+(c-d)/2),p.drawImage(m,0,0,u,d),e.engine.paintParticles(p,l),e.engine.cue&&Wl(p,e,e.engine.cue,u,d),p.setTransform(1,0,0,1,0,0),i&&Ul(p,e,i,a,s),f}async function eu(e,t={}){return au(await q(e,t))}async function tu(e,t){let n=t.format??`webm`,r=t.fps??(n===`gif`?15:30),i=t.story?e.engine.model.story:null;if(i&&!i.length)throw Error(`loadmap: the model has no story`);if(!(r>0)||!(i||t.seconds!=null&&t.seconds>0))throw Error(`loadmap: seconds and fps must be positive`);if(n===`gif`&&r>50)throw Error(`loadmap: a GIF plays at most 50 frames a second`);let a=i?[]:[...t.script??[]].sort((e,t)=>e.at-t.at),o=Ll(t.caption),s=()=>{let n=e.engine.cue?.step??e.storyStep(),r=i&&n!=null?i[n]:void 0;return o&&r?{...o,text:r.text,step:`${n+1} of ${i.length}`}:t.caption};await e.ready();let c=e.values(),l=e.storyStep();e.pause(),e.engine.stopStory({cut:!0});try{i&&(e.setStoryStep(null),e.setValues(e.engine.model.defaults()));for(let t of a.filter(e=>e.at<=0))Ql(e,t);await su(e,t.seed??1,t.warmup??2,r);let o=i?e.playStory():t.seconds,c=document.createElement(`canvas`);n===`gif`&&c.getContext(`2d`,{willReadFrequently:!0}),await q(e,{scale:t.scale??1,caption:s()},c);let l=n===`gif`?lu(c,r):await cu(c,n,r),u=Math.round(o*r),d=a.findIndex(e=>e.at>0);for(let n=0;n<u;n++){let i=n/r;for(;d>=0&&d<a.length&&a[d].at<=i;)Ql(e,a[d]),d++;await e.ready(),e.step(1/r),await q(e,{size:{width:c.width,height:c.height},caption:s()},c),await t.onFrame?.(n,c),await l.add(i)}return await l.finish()}finally{(i||e.storyStep()!==l)&&e.setStoryStep(l),e.setValues(c),e.resume()}}async function nu(e,t={}){return iu(e,t,()=>eu(e,t))}async function ru(e,t={}){return iu(e,t,async()=>{let n=t.scale??2,{inner:r,boardH:i}=Xl(e.board().scene);return au(await Zl(e,await q(e,{size:{width:du(r*n),height:du(i*n)}}),n))})}async function iu(e,t,n){await e.ready();let r=e.values();e.pause(),e.engine.stopStory({cut:!0});try{return(t.set||t.scenario!=null)&&e.setValues($l(e,t)),await su(e,t.seed??1,t.warmup??4,30),await n()}finally{e.setValues(r),e.resume()}}function au(e){return new Promise((t,n)=>e.toBlob(e=>e?t(e):n(Error(`loadmap: PNG failed`)),`image/png`))}function ou(e,t=`default`){let n={record:async t=>uu(await tu(e,t)),still:async t=>uu(await nu(e,t)),poster:async t=>uu(await ru(e,t)),svg:t=>iu(e,t,()=>Yl(e,t))};return globalThis.__loadmap??={},globalThis.__loadmap[t]=n,()=>{globalThis.__loadmap?.[t]===n&&delete globalThis.__loadmap[t]}}async function su(e,t,n,r){await e.ready(),e.reset(t);for(let t=0,i=Math.round(n*r);t<i;t++)e.step(1/r)}async function cu(e,t,n){let r=await fu(t,e.width,e.height),i=new Fl({format:t===`mp4`?new Cl({fastStart:`in-memory`}):new Dl,target:new sl}),a=new Mo(e,{codec:r,bitrate:Ka,keyFrameInterval:2});return i.addVideoTrack(a,{frameRate:n}),await i.start(),{add:e=>a.add(e,1/n),finish:async()=>{a.close(),await i.finalize();let e=i.target.buffer;return new Blob([e],{type:t===`mp4`?`video/mp4`:`video/webm`})}}}function lu(e,t){let n=(0,Il.GIFEncoder)(),r=e.getContext(`2d`),i=e=>Math.round(100*e/t),a=0;return{add:async()=>{let{data:t,width:o,height:s}=r.getImageData(0,0,e.width,e.height),c=(0,Il.quantize)(t,256),l=10*(i(a+1)-i(a));a++,n.writeFrame((0,Il.applyPalette)(t,c),o,s,{palette:c,delay:l,repeat:0})},finish:async()=>(n.finish(),new Blob([n.bytes()],{type:`image/gif`}))}}async function uu(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}var du=e=>Math.max(2,Math.round(e/2)*2);async function fu(e,t,n){let r=e===`mp4`?[`avc`,`vp9`,`av1`]:[`vp9`,`vp8`,`av1`];for(let e of r)if(await qa(e,{width:t,height:n}))return e;throw Error(`loadmap: this browser cannot encode ${e} video`)}async function pu(e,t,n){let r=Kl(e,t,n),i=URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(r)],{type:`image/svg+xml`}));try{let e=new Image;return e.src=i,await e.decode(),e}finally{URL.revokeObjectURL(i)}}var mu=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function ee(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function te(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function re(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,re(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+te(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),re(o,r,i,``,function(e){return e})):o!=null&&(ee(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+te(a,u),c+=re(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+te(a,u++),c+=re(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return re(ne(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ie(e,t,n){if(e==null)return e;var r=[],i=0;return re(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ae(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var j=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function oe(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,j)}catch(e){j(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function se(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else oe(se.bind(null,e))}var ce={map:ie,forEach:function(e,t,n){ie(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ie(e,function(){t++}),t},toArray:function(e){return ie(e,function(e){return e})||[]},only:function(e){if(!ee(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ce,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=se,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ee,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ae}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=oe,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),hu=t(((e,t)=>{t.exports=mu()})),gu=2,_u=[``,`limit`,`2nd`,`3rd`],vu=e=>e.targetRange?.low??e.target;function yu(e,t){let n=new Map,r=e.firstLimit;if(!r)return n;let i=e=>l(vu(e),t.searchMax);return n.set(r.id,{rank:1,text:`LIMIT · ${i(r)}`,word:`limit`}),e.ranked.filter(e=>e!==r&&e.util!=null).slice(0,gu).forEach((e,r)=>{let a=vu(e);if(a==null||!Number.isFinite(a)||a>t.load.max)return;let o=r+2;n.set(e.id,{rank:o,text:`${_u[o]} · ${i(e)}`,word:_u[o]})}),n}var bu=e=>e.charAt(0).toUpperCase()+e.slice(1),xu=(e,t)=>!!e.firstLimit&&!!t.firstLimit&&e.firstLimit.id!==t.firstLimit.id;function Su(e,t,n){let r=e.firstLimit,i=t.firstLimit;if(!r||!i||!xu(e,t))return null;let a=l(vu(i),n.searchMax),o=vu(r),s=t.components[r.id]?vu(t.components[r.id]):null;return o!=null&&(s==null||s>o)?`${r.name} fixed: ${i.short} ${i.plural?`are`:`is`} next, at ${a}`:`${bu(i.short)} ${i.plural?`overtake`:`overtakes`} ${r.short}: the limit is ${a} now`}var Cu={establish:1.2,in:1,close:.5,hand:1.8,out:1,back:.4},wu=e=>Math.max(1.6,e+.7),Tu=(e,t,n=!1)=>Cu.in+Cu.close+wu(t)+(n?Cu.hand:0)+Cu.out+e.seconds;function Eu(e,t,n){let r=t,i=Cu.establish;for(let t of e.story){let a=e.evaluate(t.values);i+=Tu(t,n,xu(r,a)),r=a}return i}var Du=e=>({x:0,y:0,w:e.width,h:e.height});function Ou(e,t){return t.stages.map(t=>e.stages[t]?.component).find(Boolean)??t.component??void 0}function ku(e,t,n,r,i){let a=new Set(e.nodes.map(e=>e.id)),o=new Set;for(let e of a)r.a.nodes[e]!==r.b.nodes[e]&&o.add(e);let s=new Set(r.a.edges.map(e=>e.id)),c=new Set(r.b.edges.map(e=>e.id));for(let e of[...r.a.edges,...r.b.edges])if(s.has(e.id)!==c.has(e.id))for(let t of[e.from,e.to])a.has(t)&&o.add(t);let l=t=>e.nodes.filter(e=>t&&Ou(n,e)===t).map(e=>e.id),u=t=>e.nodes.filter(e=>t.has(e.id)).map(e=>e.id);if(i)return u(new Set([...l(i),...o]));if(o.size)return u(o);let d=e.nodes.filter(e=>{let r=Ou(n,e);return r&&t.components[r]?.state!==n.components[r]?.state});return d.length?d.map(e=>e.id):l(n.firstLimit?.id)}var Au=2.5,ju=.8;function Mu(e,t,n={}){let r=Du(e),i=e.nodes.filter(e=>t.includes(e.id));if(!i.length||!(e.width>0&&e.height>0))return r;let a=Math.min(...i.map(e=>e.x)),o=Math.min(...i.map(e=>e.y)),s=Math.max(...i.map(e=>e.x+e.w)),c=Math.max(...i.map(e=>e.y+e.h)),l=e.width/e.height,u=Math.max(s-a+60,(c-o+60)*l,e.width/Au);if(u>ju*e.width&&!n.hold)return r;u=Math.min(u,e.width);let d=u/l,f=(e,t)=>Math.max(0,Math.min(t,e));return{x:f((a+s-u)/2,e.width-u),y:f((o+c-d)/2,e.height-d),w:u,h:d}}var Nu=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2;function Pu(e,t,n){let r=Nu(Math.max(0,Math.min(1,n))),i=e.w*(t.w/e.w)**r,a=e.h*(t.h/e.h)**r,o=e.x+e.w/2+(t.x+t.w/2-e.x-e.w/2)*r,s=e.y+e.h/2+(t.y+t.h/2-e.y-e.h/2)*r;return{x:o-i/2,y:s-a/2,w:i,h:a}}var Fu=e=>e.split(`,`)[0].trim(),Iu=2;function Lu(e,t,n,r){if(n.title)return`${r+1} · ${n.title}`;let i=(t,n)=>{if(t===`load`)return`${s(n)}×`;let r=e.params.find(e=>e.id===t)?.def;return typeof n==`boolean`?n?`on`:`off`:r&&r.kind!==`load`&&`format`in r&&r.format?r.format(n):typeof n==`number`?s(n):String(n)},a=Object.keys(n.values).filter(e=>t[e]!==n.values[e]),o=a.slice(0,Iu).map(r=>{let a=r===`load`?e.load.label:e.params.find(e=>e.id===r)?.def.label??r,o=n.values[r],s=t[r];return typeof o==`boolean`?`${Fu(a)} ${i(r,o)}`:`${Fu(a)} ${i(r,s)} → ${i(r,o)}`});a.length>Iu&&o.push(`${a.length-Iu} more`);let c=o.join(`, `)||`Nothing changes`;return`${r+1} · ${n.scenario&&a.length?`${n.scenario}: ${c}`:c}`}function Ru(e,t,n){return n.slice(0,2).map(n=>{let r=e.components[n],i=t?.components[n];if(!r)return``;let a=e=>e==null?`off`:f(e);return i?`${r.name} ${a(r.util)} → ${a(i.util)}`:`${r.name} ${a(r.util)}`}).filter(Boolean).join(` · `)}var zu=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Bu=t(((e,t)=>{t.exports=zu()})),J=hu(),Y=Bu(),Vu=[`var(--lm-s1)`,`var(--lm-s2)`,`var(--lm-s3)`,`var(--lm-s4)`];function Hu(e,t){return t==null?`var(--lm-fg)`:Vu[e.scenarios.findIndex(e=>e.label===t)]??`var(--lm-muted)`}var Uu=e=>e.label??`These values`;function Wu(e,t){let n=e.dateAt(t);return n?_(n,!0):t!=null&&t<=1&&e.growth?`now`:``}function Gu(e,t){if(!t)return``;let[n,r]=[Wu(e,t.low),Wu(e,t.high)];return!r||n===r?n:`${n}–${r}`}function Ku(e){return(0,J.useMemo)(()=>xe(e.model,e.values.load),[e.model,e.values.load])}function qu({lm:e}){let{model:t}=e;return t.scenarios.length?(0,Y.jsxs)(`fieldset`,{className:`lm-scenarios`,children:[(0,Y.jsx)(`legend`,{children:`Scenario`}),t.scenarios.map(n=>(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":e.scenario?.label===n.label,onClick:()=>e.setScenario(n.label),children:[(0,Y.jsx)(`i`,{style:{background:Hu(t,n.label)}}),n.label]},n.label)),!e.scenario&&(0,Y.jsx)(`span`,{className:`lm-own`,children:`your own values`})]}):null}function X(e){return e==null||!Number.isFinite(e)||e===0?``:Math.abs(e-1)<.005?`same`:`${e>1?`+`:`−`}${f(Math.abs(e-1))}`}function Ju({lm:e,title:t=`Scenarios compared`}){let{model:n}=e,r=Ku(e);if(r.rows.length<2)return null;let i=`${f(n.thresholds.target)} target`,a=e=>(0,Y.jsxs)(Y.Fragment,{children:[e?u(e,n.searchMax,!0):l(null),Gu(n,e)&&(0,Y.jsx)(`small`,{children:Gu(n,e)})]});return(0,Y.jsxs)(`div`,{className:`lm-card lm-compare`,children:[(0,Y.jsx)(`h3`,{children:t}),(0,Y.jsx)(`p`,{className:`lm-compare-text`,children:r.text}),(0,Y.jsx)(`div`,{className:`lm-table-wrap`,children:(0,Y.jsxs)(`table`,{className:`lm-table`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`col`,children:`Scenario`}),(0,Y.jsx)(`th`,{scope:`col`,children:`Limited by`}),(0,Y.jsx)(`th`,{scope:`col`,children:i}),(0,Y.jsx)(`th`,{scope:`col`,children:`Runs out`})]})}),(0,Y.jsx)(`tbody`,{children:r.rows.map(t=>(0,Y.jsxs)(`tr`,{"data-scenario":t.label,"aria-current":e.scenario?.label===t.label||void 0,children:[(0,Y.jsxs)(`th`,{scope:`row`,children:[(0,Y.jsx)(`i`,{style:{background:Hu(n,t.label)}}),t.label]}),(0,Y.jsx)(`td`,{className:`lm-text`,children:t.firstLimit?.name??`—`}),(0,Y.jsx)(`td`,{"data-multiple":t.target??``,"data-high":t.targetRange?.high??``,children:a(t.targetRange)}),(0,Y.jsx)(`td`,{"data-multiple":t.full??``,"data-high":t.fullRange?.high??``,children:a(t.fullRange)})]},t.label))})]})}),(0,Y.jsxs)(`h3`,{children:[i,`, by component`]}),(0,Y.jsx)(`div`,{className:`lm-table-wrap`,children:(0,Y.jsxs)(`table`,{className:`lm-table`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`col`,children:`Component`}),r.rows.map(e=>(0,Y.jsx)(`th`,{scope:`col`,children:e.label},e.label))]})}),(0,Y.jsx)(`tbody`,{children:n.componentIds.map((e,t)=>(0,Y.jsxs)(`tr`,{"data-component":e,children:[(0,Y.jsx)(`th`,{scope:`row`,children:r.rows[0].components[t].name}),r.rows.map((e,r)=>{let i=e.components[t];return(0,Y.jsxs)(`td`,{"data-multiple":i.target??``,children:[i.targetRange==null?`off`:u(i.targetRange,n.searchMax,!0),r>0&&X(i.change)&&(0,Y.jsx)(`small`,{children:X(i.change)})]},e.label)})]},e))})]})})]})}function Z(e){let t=(0,J.useRef)(null),[n,r]=(0,J.useState)({width:e,height:0});return(0,J.useEffect)(()=>{let e=t.current;if(!e)return;let n=new ResizeObserver(([t])=>{let n=Math.round(t?.contentRect.width??e.clientWidth),i=Math.round(t?.contentRect.height??e.clientHeight);n>0&&r(e=>e.width===n&&e.height===i?e:{width:n,height:i})});return n.observe(e),()=>n.disconnect()},[]),[t,n]}function Q(e){let{model:t,values:n}=e,r=JSON.stringify({...n,load:null});return(0,J.useMemo)(()=>Ce(t,{...n,load:t.load.default}),[t,r])}function Yu(e){let[t,n]=(0,J.useState)(()=>(e,t)=>e.length*6.7);return(0,J.useLayoutEffect)(()=>{let t=e.current&&document.createElement(`canvas`).getContext(`2d`);if(!t)return;let r=getComputedStyle(e.current).getPropertyValue(`--lm-mono`).trim()||`monospace`;n(()=>(e,n=400)=>(t.font=`${n} 11px ${r}`,t.measureText(e).width))},[e]),t}function Xu(e,t,n){let r=[];for(let i=Math.floor(Math.log10(e));i<=Math.ceil(Math.log10(t));i++)for(let a of n?[1,2,5]:[1]){let n=a*10**i;n>=e*.999&&n<=t*1.001&&r.push(Number(n.toPrecision(6)))}return r}function Zu({lm:e,title:t=`Headroom`}){let{model:n,values:r}=e,i=Q(e),[a,{width:o}]=Z(640),[c,d]=(0,J.useState)(null),p=(0,J.useId)().replace(/:/g,``),m=Yu(a),h=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{let e=h.current;e&&c!=null&&(e.style.left=`${Math.max(0,Math.min(C(E[c])+10,v-e.offsetWidth))}px`)});let g=!!n.growth,_={l:44,r:14,t:14,b:g?40:26},v=o,y=Math.round(Math.min(300,Math.max(200,v*.45))),b=v-_.l-_.r,x=y-_.t-_.b,S=Math.max(1.5,n.thresholds.full*1.5),C=e=>_.l+b*Math.log(e/i.from)/Math.log(i.to/i.from),w=e=>_.t+x*(1-Math.min(e,S*1.2)/S),T=e=>{let t=``,n=!1;for(let[r,i]of e)i==null?n=!1:(t+=`${n?`L`:`M`}${C(r).toFixed(1)} ${w(i).toFixed(1)}`,n=!0);return t},E=i.lines[0]?.envelope.map(([e])=>e)??[],D=i.lines.find(e=>e.selected),O=v>=480,ee=Xu(i.from,i.to,O),k=e=>O||Number.isInteger(Math.log10(e)),A=e=>{let t=0;for(let n=1;n<E.length;n++)Math.abs(C(E[n])-e)<Math.abs(C(E[t])-e)&&(t=n);return t},te=e=>{let t=e.currentTarget.ownerSVGElement.getBoundingClientRect();d(A(e.clientX-t.left))},ne=e=>{let t=c??A(C(Math.min(i.to,Math.max(i.from,r.load))));e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),d(Math.max(0,Math.min(E.length-1,t+(e.key===`ArrowRight`?1:-1))))):e.key===`Escape`&&d(null)},re=e=>{let t=e.upper.flatMap(([t,n],r)=>{let i=e.lower[r][1];return n==null||i==null?[]:[[t,n,i]]});if(t.length<2)return``;let n=t.map(([e,t])=>`${C(e).toFixed(1)} ${w(t).toFixed(1)}`),r=t.map(([e,,t])=>`${C(e).toFixed(1)} ${w(t).toFixed(1)}`).reverse();return`M${n.join(`L`)}L${r.join(`L`)}Z`},ie=(e,t)=>e&&ae(e)?u(e,n.searchMax):l(t,n.searchMax),ae=e=>l(e.low,n.searchMax)!==l(e.high,n.searchMax),j=i.lines.map(e=>`${Uu(e)} reaches the ${f(n.thresholds.target)} target at ${ie(e.targetRange,e.target)} and ${f(n.thresholds.full)} at ${ie(e.fullRange,e.full)}`).join(`; `),oe=C(Math.min(i.to,Math.max(i.from,r.load))),se=c==null?null:E[c],ce={x:0,textAnchor:`start`},le={x:v,textAnchor:`end`},ue=(e,t,n,r=4)=>{let i={x:e+r,textAnchor:`start`},a={x:e-r,textAnchor:`end`},o=e+r+t<=v,s=e-r-t>=0;return(n===`right`||!s)&&o?i:s?a:e<v/2?ce:le},de=(e,t)=>e-t/2<0?ce:e+t/2>v?le:{x:e,textAnchor:`middle`},fe=`shown: ${s(r.load)}×`,pe=(e,t,n)=>(0,Y.jsx)(`text`,{...ue(t,m(e,600),`left`,6),y:n,className:`lm-mark`,children:e});return(0,Y.jsxs)(`div`,{className:`lm-card lm-headroom`,children:[(0,Y.jsx)(`h3`,{children:t}),i.lines.length>1&&(0,Y.jsxs)(`div`,{className:`lm-legend`,children:[i.lines.map(e=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`b`,{className:`lm-key`,style:{background:Hu(n,e.label)}}),Uu(e)]},Uu(e))),D&&(0,Y.jsxs)(`span`,{children:[`thin lines: each component of `,Uu(D)]})]}),(0,Y.jsxs)(`div`,{className:`lm-chart`,ref:a,role:`slider`,"aria-label":`Utilization over the load multiple. ${j}.`,"aria-valuemin":i.from,"aria-valuemax":i.to,"aria-valuenow":se??r.load,"aria-valuetext":se==null?`${s(r.load)}×`:`${s(se)}×: ${i.lines.map(e=>`${Uu(e)} ${e.envelope[c][1]==null?`off`:f(e.envelope[c][1])}`).join(`, `)}`,tabIndex:0,onKeyDown:ne,onBlur:()=>d(null),children:[(0,Y.jsxs)(`svg`,{width:v,height:y,viewBox:`0 0 ${v} ${y}`,"aria-hidden":`true`,children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsx)(`clipPath`,{id:p,children:(0,Y.jsx)(`rect`,{x:_.l,y:_.t,width:b,height:x+2})})}),[0,n.thresholds.target,n.thresholds.full].map(e=>(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)(`line`,{x1:_.l,x2:v-_.r,y1:w(e),y2:w(e),stroke:`var(--lm-line)`}),(0,Y.jsx)(`text`,{x:_.l-6,y:w(e)+4,textAnchor:`end`,className:`lm-axis`,children:f(e)})]},e)),(0,Y.jsx)(`text`,{x:v-_.r,y:w(n.thresholds.target)-5,textAnchor:`end`,className:`lm-axis`,children:`target`}),ee.map(e=>{let t=`${s(e)}×`,r=g&&e>1?Wu(n,e):``;return(0,Y.jsxs)(`g`,{className:`lm-axis`,children:[(0,Y.jsx)(`line`,{x1:C(e),x2:C(e),y1:_.t+x,y2:_.t+x+4,stroke:`var(--lm-line)`}),k(e)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`text`,{...de(C(e),m(t)),y:_.t+x+16,children:t}),r&&(0,Y.jsx)(`text`,{...de(C(e),m(r)),y:_.t+x+30,children:r})]})]},e)}),(0,Y.jsxs)(`g`,{clipPath:`url(#${p})`,children:[[...i.lines].sort((e,t)=>Number(e.selected)-Number(t.selected)).map(e=>e.band?(0,Y.jsx)(`path`,{"data-band":Uu(e),d:re(e.band),fill:Hu(n,e.label),fillOpacity:e.selected?.2:.08},Uu(e)):null),D?.components.map(e=>(0,Y.jsx)(`path`,{d:T(e.points),fill:`none`,stroke:`var(--lm-muted)`,strokeOpacity:`.55`,strokeWidth:`1`},e.id)),[...i.lines].sort((e,t)=>Number(e.selected)-Number(t.selected)).map(e=>(0,Y.jsx)(`path`,{"data-line":Uu(e),d:T(e.envelope),fill:`none`,stroke:Hu(n,e.label),strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`},Uu(e)))]}),(0,Y.jsx)(`line`,{x1:oe,x2:oe,y1:_.t,y2:_.t+x,stroke:`var(--lm-fg)`,strokeOpacity:`.45`}),(0,Y.jsx)(`text`,{...ue(oe,m(fe),`right`),y:_.t+10,className:`lm-axis`,children:fe}),i.lines.flatMap(e=>[[`target`,e.targetRange,n.thresholds.target],[`full`,e.fullRange,n.thresholds.full]].map(([t,r,a])=>{if(!e.band||!r||!Number.isFinite(r.low)||r.low>i.to)return null;let[o,s]=[C(Math.max(i.from,r.low)),C(Math.min(i.to,r.high))],c=w(a);return(0,Y.jsxs)(`g`,{"data-range":t,"data-scenario":Uu(e),"data-low":r.low,"data-high":r.high,stroke:Hu(n,e.label),strokeWidth:e.selected?3:2,strokeOpacity:e.selected?1:.6,children:[(0,Y.jsx)(`line`,{x1:o,x2:s,y1:c,y2:c}),(0,Y.jsx)(`line`,{x1:o,x2:o,y1:c-5,y2:c+5}),Number.isFinite(r.high)&&r.high<=i.to&&(0,Y.jsx)(`line`,{x1:s,x2:s,y1:c-5,y2:c+5})]},`${Uu(e)}/${t}/range`)})),i.lines.flatMap(e=>[[`target`,e.target,e.targetRange,n.thresholds.target],[`full`,e.full,e.fullRange,n.thresholds.full]].map(([t,r,a,o])=>r!=null&&Number.isFinite(r)&&r>=i.from&&r<=i.to?(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)(`circle`,{"data-crossing":t,"data-scenario":Uu(e),"data-multiple":r,cx:C(r),cy:w(o),r:`4`,fill:Hu(n,e.label),stroke:`var(--lm-surface)`,strokeWidth:`2`}),e.selected&&pe(a&&ae(a)?u(a,n.searchMax,!0):l(r,n.searchMax),C(a&&ae(a)?Math.max(i.from,a.low):r),w(o)-8)]},`${Uu(e)}/${t}`):null)),se!=null&&(0,Y.jsx)(`line`,{x1:C(se),x2:C(se),y1:_.t,y2:_.t+x,stroke:`var(--lm-fg)`,strokeOpacity:`.8`}),(0,Y.jsx)(`rect`,{x:_.l,y:_.t,width:b,height:x,fill:`transparent`,onPointerMove:te,onPointerDown:te,onPointerLeave:()=>d(null)})]}),c!=null&&se!=null&&(0,Y.jsxs)(`div`,{className:`lm-tip`,role:`status`,ref:h,style:{left:C(se)+10,top:_.t},children:[(0,Y.jsxs)(`b`,{children:[s(se),`×`,Wu(n,se)&&` · ${Wu(n,se)}`]}),i.lines.map(e=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`b`,{className:`lm-key`,style:{background:Hu(n,e.label)}}),(0,Y.jsx)(`strong`,{children:e.envelope[c][1]==null?`off`:f(e.envelope[c][1])}),` `,Uu(e)]},Uu(e))),D?.components.map(e=>(0,Y.jsxs)(`span`,{className:`lm-sub`,children:[(0,Y.jsx)(`strong`,{children:e.points[c][1]==null?`off`:f(e.points[c][1])}),` `,e.name]},e.id))]})]})]})}var Qu={off:`var(--lm-line)`,ok:`var(--lm-ok)`,warn:`var(--lm-warn)`,over:`var(--lm-drop)`},$u=e=>[`accent`,`alt`,`ok`,`warn`,`drop`,`muted`].includes(e)?`var(--lm-${e})`:e;function ed({lm:e,legend:t=!0,onNodeClick:n,selected:r=null}){let{scene:i,engine:a,reducedMotion:o}=e,s=(0,J.useRef)(n);s.current=n;let[c]=(0,J.useState)(()=>e=>s.current?.(e)),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(0,J.useRef)(null),p=(0,J.useRef)(null),m=(0,J.useRef)(null),h=(0,J.useRef)(null),g=e.fullScreen,[_,v]=(0,J.useState)(null),y=(0,J.useId)();(0,J.useLayoutEffect)(()=>{i&&a.setScene(i,{cut:o})},[a,i,o]);let b=(0,J.useSyncExternalStore)(a.subscribe,()=>a.frameId),x=a.frame,S=(0,J.useSyncExternalStore)(a.subscribe,()=>a.handover);(0,J.useEffect)(()=>{a.bind(l.current,u.current)},[a,x,o]),(0,J.useLayoutEffect)(()=>{a.applyCamera(),a.drawHalos()}),(0,J.useEffect)(()=>{e.root&&a.readColors(e.root)},[a,i,e.root]),(0,J.useEffect)(()=>{a.drawnValues=JSON.stringify(e.values),a.drawnFocus=e.focus,a.drawnFrame=b}),(0,J.useEffect)(()=>{let e=p.current;if(!e)return;let t=new ResizeObserver(()=>a.resize());return t.observe(e),()=>t.disconnect()},[a]);let C=()=>{let e=d.current,t=p.current,n=a.camera,r=h.current;if(!n&&!a.cue)return;if(!e||!t||!a.frame||e.scrollHeight<=e.clientHeight){r?.style.removeProperty(`top`),r?.style.removeProperty(`bottom`);return}let i=t.clientHeight/a.frame.height;n&&(e.scrollTop=t.offsetTop+(n.y+n.h/2)*i-e.clientHeight/2),r&&(r.style.top=`${Math.max(0,e.scrollTop-t.offsetTop+(f.current?.offsetHeight??0))}px`,r.style.bottom=`auto`)};(0,J.useEffect)(()=>{let e=0,t=0,n=r=>{let i=t?Math.min(.05,(r-t)/1e3):0;t=r,!a.paused&&a.scene&&(a.step(i,{particles:!o}),a.draw({particles:!o}),C()),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>cancelAnimationFrame(e)},[a,o]);let w=(0,J.useRef)(!1);(0,J.useEffect)(()=>{w.current&&!g&&m.current?.focus(),w.current=g},[g]),(0,J.useEffect)(()=>{let t=d.current,n=f.current,r=e.root;if(!g||!i||!t||!n||!r)return;let a=e=>Number.parseFloat(e)||0,o=()=>{let e=getComputedStyle(r),o=a(e.paddingTop)+a(e.paddingBottom),s=t=>{let n=getComputedStyle(t);n.display!==`none`&&n.position!==`absolute`&&n.position!==`fixed`&&(o+=a(e.rowGap)+(a(n.flexGrow)>0?a(n.minHeight):t.offsetHeight))};for(let e of r.children)e!==t&&s(e);getComputedStyle(r,`::after`).content!==`none`&&(o+=a(e.rowGap));let c=r.clientHeight-o-n.offsetHeight-a(getComputedStyle(t).rowGap),l=Math.min(t.clientWidth,c*i.width/i.height);t.style.setProperty(`--lm-fit`,`${Math.max(0,Math.floor(l))}px`)},s=new ResizeObserver(o),c=()=>{s.disconnect(),s.observe(n),s.observe(r);for(let e of r.children)s.observe(e)};c();let l=new MutationObserver(()=>{c(),o()});return l.observe(r,{childList:!0,attributeFilter:[`data-mode`]}),()=>{s.disconnect(),l.disconnect(),t.style.removeProperty(`--lm-fit`)}},[g,i,e.root]);let{setFullScreenMode:T,fullScreenMode:E}=e,D=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let t=e.root;if(!g||!t||e.fill)return;let n=e=>{if(e.key!==`f`&&e.key!==`F`||e.ctrlKey||e.metaKey||e.altKey||td(e.composedPath()[0]??null)||t.querySelector(`:scope > [data-drawer]`)||(e.preventDefault(),e.repeat))return;let n=E===`focus`?`panels`:`focus`;document.activeElement?.closest(`.lm-dock, .lm-line`)&&D.current?.querySelector(`[data-mode="${n}"]`)?.focus(),T(n)};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[g,E,T,e.root,e.fill]),(0,Y.jsxs)(`div`,{className:`lm-wrap`,ref:d,children:[(0,Y.jsxs)(`div`,{className:`lm-bar`,ref:f,children:[t?(0,Y.jsx)(nd,{lm:e}):(0,Y.jsx)(`span`,{}),(0,Y.jsxs)(`span`,{className:`lm-tools`,children:[g&&!e.fill&&(0,Y.jsx)(`fieldset`,{className:`lm-modes`,"aria-label":`Full screen shows (F)`,ref:D,children:[`panels`,`focus`].map(e=>(0,Y.jsx)(`button`,{type:`button`,"data-mode":e,"aria-pressed":E===e,"aria-keyshortcuts":`F`,onClick:()=>T(e),children:e===`panels`?`Panels`:`Focus`},e))}),!e.fill&&(0,Y.jsx)(`button`,{type:`button`,className:`lm-btn`,onClick:e.toggleFullScreen,"aria-pressed":g,ref:m,children:g?`✕ Close`:`⤢ Full screen`})]})]}),(0,Y.jsxs)(`div`,{className:`lm-board`,ref:p,style:x?{aspectRatio:`${x.width} / ${x.height}`}:{minHeight:240},children:[x&&(0,Y.jsx)(id,{lm:e,scene:x,hand:S,svgRef:l,rates:o,setTip:v,onClick:n?c:void 0,selected:r}),(0,Y.jsx)(`canvas`,{ref:u,hidden:o}),e.cue&&(0,Y.jsxs)(`div`,{className:`lm-title`,"data-top":e.cue.top||void 0,"aria-hidden":`true`,ref:h,children:[(0,Y.jsx)(`b`,{children:e.cue.title}),e.cue.detail&&(0,Y.jsx)(`span`,{children:e.cue.detail})]})]}),x&&_&&!e.storyPlaying&&(0,Y.jsx)(pd,{lm:e,scene:x,id:_.id,board:p.current,detailId:y})]})}function td(e){return e instanceof HTMLElement?e.isContentEditable||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?!0:e instanceof HTMLInputElement&&![`range`,`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`file`,`color`].includes(e.type):!1}function nd({lm:e}){let t=e.view.def.flows,n=Object.values(e.ev.overload).some(e=>e.merge)||Object.values(e.ev.stages).some(e=>e.kind===`fanout`);return(0,Y.jsxs)(`div`,{className:`lm-legend`,children:[Object.entries(t).map(([e,t])=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`i`,{style:{background:$u(t.color)}}),t.label??e]},e)),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`i`,{style:{background:`var(--lm-ok)`}}),`done`]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`i`,{style:{background:`var(--lm-drop)`}}),`dropped or rejected`]}),n&&(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`i`,{style:{background:`var(--lm-muted)`}}),`superseded or unread`]}),(0,Y.jsx)(`span`,{children:e.reducedMotion?`line width: rate`:`one dot ≈ ${e.engine.sim.dotScale.toLocaleString(`en-US`)} a second · ${e.engine.sim.speed}× speed`})]})}var rd=(e,t)=>Ou(e.ev,t),id=(0,J.memo)(function({lm:e,scene:t,hand:n,svgRef:r,rates:i,setTip:a,onClick:o,selected:s}){let c=(0,J.useId)().replace(/:/g,``),{labels:u,ev:d}=e,p=t=>{let n=rd(e,t);return n?d.components[n]?.state??null:null},m=t=>{let n=rd(e,t),r=n?d.components[n]:void 0,i=u.nodes[t.id]?.title;if(!r)return o?{tabIndex:0,role:`button`,className:`lm-node`,"aria-label":i??t.id,"aria-pressed":s===t.id,onClick:()=>o(t.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o(t.id))}}:{};let c=()=>{a(e=>e?.pinned&&e.id===t.id?null:{id:t.id,pinned:!0}),o?.(t.id)};return{tabIndex:0,role:`button`,className:`lm-node`,"aria-label":`${i&&i!==r.name?`${i}, `:``}${r.name}: ${r.util==null?`switched off`:f(r.util)}`,...o?{"aria-pressed":s===t.id}:{},onPointerEnter:e=>e.pointerType===`mouse`&&a(e=>e?.pinned?e:{id:t.id,pinned:!1}),onPointerLeave:e=>e.pointerType===`mouse`&&a(e=>e?.pinned?e:null),onFocus:()=>a(e=>e?.pinned?e:{id:t.id,pinned:!1}),onBlur:()=>a(e=>e?.pinned?e:null),onClick:c,onKeyDown:e=>{e.key===`Escape`&&a(null),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())}}},h=t.nodes.map(e=>u.nodes[e.id]?.title).join(`, `),g=yu(d,e.model),_=e.scene&&new Set(e.scene.nodes.map(e=>e.id)),v=n=>t.nodes.filter(t=>rd(e,t)===n&&(!_||_.has(t.id))),y=d.firstLimit,b=n&&n.from!==y?.id&&d.components[n.from]?d.components[n.from]:null,x=b?v(b.id):[],S=b&&g.get(b.id),C=b&&(S?S.text:`now ${l(vu(b),e.model.searchMax)}`);return(0,Y.jsxs)(`svg`,{ref:r,viewBox:`0 0 ${t.width} ${t.height}`,role:`group`,"aria-label":`Diagram: ${h}`,children:[(0,Y.jsx)(`defs`,{children:(0,Y.jsx)(`marker`,{id:c,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Y.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--lm-muted)`})})}),i&&(0,Y.jsx)(sd,{lm:e,scene:t}),t.edges.map(e=>(0,Y.jsx)(od,{e,text:u.edges[e.id],marker:c},e.id)),t.nodes.map(t=>(0,Y.jsx)(ld,{n:t,state:p(t),title:u.nodes[t.id]?.title,sub:u.nodes[t.id]?.sub,lm:e,focused:!!e.focus&&rd(e,t)===e.focus,selected:s===t.id,handlers:m(t)},t.id)),b&&x.map(e=>(0,Y.jsx)(dd,{n:e,kind:`was`,component:b.id},`was-${e.id}`)),y&&v(y.id).map((e,t)=>(0,Y.jsx)(dd,{n:e,kind:`limit`,component:y.id,tag:t?void 0:g.get(y.id)?.text},e.id)),[...g].map(([e,t])=>{let n=t.rank>1&&e!==b?.id?v(e)[0]:void 0;return n&&(0,Y.jsx)(fd,{n,text:t.text},e)}),C&&x[0]&&(0,Y.jsx)(fd,{n:x[0],text:C,was:!S})]})}),ad=e=>e.map(([e,t],n)=>`${n?`L`:`M`}${e} ${t}`).join(` `);function od({e,text:t,marker:n}){let r=e.draw!=null&&e.draw<1;return(0,Y.jsxs)(`g`,{opacity:e.fade,children:[(0,Y.jsx)(`path`,{d:ad(e.points),fill:`none`,stroke:`var(--lm-muted)`,strokeOpacity:`.7`,markerEnd:r?void 0:`url(#${n})`,...r?{pathLength:1,strokeDasharray:1,strokeDashoffset:1-e.draw}:{}}),e.label&&t&&(0,Y.jsx)(`text`,{x:e.label.x+e.label.w/2,y:e.label.y+e.label.h/2+4,textAnchor:`middle`,fontSize:`11`,fill:`var(--lm-muted)`,children:t})]})}function sd({lm:e,scene:t}){let{ev:n}=e,r=e.view.def.flows,i=Math.max(1e-9,...Object.values(n.flows)),a=[];for(let e of Object.keys(r)){let o=[t.flowFrom[e],...(n.routes[e]??[]).map(e=>t.stageNode[e])].filter((e,t,n)=>e&&e!==n[t-1]),s=n.flows[e]??0,c=o.slice(1).map((e,t)=>[o[t],e,s]),l=(n.routes[e]??[]).at(-1),u=l?n.stages[l]:void 0;if(u?.kind===`fanout`)for(let n of u.to[e]??[])c.push([t.stageNode[l],t.stageNode[n.stage],s*n.share]);for(let[n,o,s]of c){let c=t.edges.find(e=>e.from===n&&e.to===o);c&&a.push((0,Y.jsx)(`path`,{d:ad(c.points),fill:`none`,stroke:$u(r[e].color),strokeOpacity:`.45`,strokeWidth:1.5+6*Math.min(s,i)/i},`${e}:${c.id}`))}}return(0,Y.jsx)(`g`,{children:a})}function cd({s:e,children:t,anchor:n=`middle`,fill:r=`currentColor`,opacity:i}){return(0,Y.jsx)(`text`,{x:e.x,y:e.y,fontSize:e.size,fontWeight:e.weight,textAnchor:n,fill:r,opacity:i,children:t})}function ld({n:e,state:t,title:n,sub:r,lm:i,focused:a,selected:o,handlers:s}){let c=t?Qu[t]:`var(--lm-line)`,l=i.view.def.flows,u=e.kind===`pool`?i.ev.stages[e.stages[0]??``]:void 0,d=u?.kind===`workers`?u.running:e.members.length,f=t=>t>=d&&t<(u?.kind===`workers`?u.pods:e.members.length),p=e.fade==null?void 0:`translate(${e.x+e.w/2} ${e.y+e.h/2}) scale(${.92+.08*e.fade}) translate(${-e.x-e.w/2} ${-e.y-e.h/2})`;return(0,Y.jsxs)(`g`,{style:{color:`var(--lm-fg)`},opacity:e.fade,transform:p,"data-node":e.id,"data-focus":a||void 0,"data-selected":o||void 0,...s,children:[e.shape===`cylinder`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`path`,{d:`M${e.x} ${e.y+6} A${e.w/2} 6 0 0 1 ${e.x+e.w} ${e.y+6} V${e.y+e.h-6} A${e.w/2} 6 0 0 1 ${e.x} ${e.y+e.h-6} Z`,fill:`var(--lm-surface)`,stroke:c,strokeWidth:`1.5`}),(0,Y.jsx)(`path`,{d:`M${e.x} ${e.y+6} A${e.w/2} 6 0 0 0 ${e.x+e.w} ${e.y+6}`,fill:`none`,stroke:c,strokeWidth:`1.5`})]}):(0,Y.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:`6`,fill:`var(--lm-surface)`,stroke:c,strokeWidth:`1.5`}),(0,Y.jsx)(cd,{s:e.title,children:n}),e.sub&&r&&(0,Y.jsx)(cd,{s:e.sub,fill:`var(--lm-muted)`,children:r}),e.members.map((e,t)=>(0,Y.jsxs)(`g`,{"data-idle":f(t)||void 0,opacity:f(t)?.45*(e.fade??1):e.fade,children:[(0,Y.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:`4`,fill:`none`,stroke:`var(--lm-line)`,strokeDasharray:f(t)?`3 3`:void 0}),(0,Y.jsx)(cd,{s:e.spot,anchor:`start`,fill:`var(--lm-muted)`,children:e.label})]},e.label)),e.groups.map((e,t)=>(0,Y.jsx)(cd,{s:e.spot,anchor:`start`,fill:$u(l[e.flow]?.color??`muted`),opacity:e.fade,children:e.text},`${e.flow}#${t}`)),e.cells.map(e=>(0,Y.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:`1.5`,opacity:e.fade,fill:`var(--lm-lane)`,stroke:$u(l[e.flow]?.color??`muted`),strokeOpacity:`.6`},`${e.stage}/${e.flow}/${e.index}`)),e.slots.map(t=>(0,Y.jsxs)(`g`,{opacity:t.fade,children:[(0,Y.jsx)(`rect`,{x:t.x,y:t.y,width:t.w,height:t.h,rx:`2`,fill:`var(--lm-surface)`,stroke:`currentColor`,strokeOpacity:`.45`}),(0,Y.jsx)(`rect`,{"data-slot":t.index,"data-stage":e.stages[0],"data-y":t.y,"data-s":t.w,x:t.x+1,y:t.y+t.h-1,width:t.w-2,height:0,rx:`1`,fill:`var(--lm-accent)`})]},t.index)),o&&(0,Y.jsx)(`rect`,{className:`lm-selected`,x:e.x-3,y:e.y-3,width:e.w+6,height:e.h+6,rx:`8`,fill:`none`,stroke:`var(--lm-accent)`,strokeWidth:`2.5`}),a&&(0,Y.jsx)(`rect`,{className:`lm-focus`,x:e.x-5,y:e.y-5,width:e.w+10,height:e.h+10,rx:`9`,fill:`none`,stroke:`var(--lm-accent)`,strokeWidth:`2`,strokeDasharray:`5 4`})]})}var ud=(e,t)=>Math.ceil(12+e.length*t);function dd({n:e,kind:t,component:n,tag:r}){let i={x:e.x-7,y:e.y-7,width:e.w+14,height:e.h+14,rx:10},a=r?ud(r,5.6):0,o=e.x+e.w+7-a-8;return(0,Y.jsxs)(`g`,{className:`lm-halo`,"data-halo":t,"data-component":n,"data-fade":e.fade??1,pointerEvents:`none`,children:[(0,Y.jsxs)(`g`,{"data-ring":``,"data-cx":e.x+e.w/2,"data-cy":e.y+e.h/2,children:[(0,Y.jsx)(`rect`,{...i,"data-glow":``,fill:`none`,stroke:`var(--lm-drop)`,strokeWidth:`10`,strokeOpacity:`.22`}),(0,Y.jsx)(`rect`,{...i,fill:`none`,stroke:`var(--lm-drop)`,strokeWidth:`2.5`})]}),r&&(0,Y.jsxs)(`g`,{"data-tag":r,children:[(0,Y.jsx)(`rect`,{x:o,y:i.y-7.5,width:a,height:`15`,rx:`3`,fill:`var(--lm-drop)`}),(0,Y.jsx)(`text`,{x:o+a/2,y:i.y+3.5,textAnchor:`middle`,fontSize:`9.5`,fontWeight:`600`,letterSpacing:`.06em`,fill:`var(--lm-surface)`,children:r})]})]})}function fd({n:e,text:t,was:n}){let r=ud(t,4.9),i=e.x+e.w-r-6;return(0,Y.jsx)(`g`,{className:`lm-badge`,"data-badge":t,"data-was":n||void 0,opacity:e.fade,pointerEvents:`none`,children:(0,Y.jsxs)(`g`,{"data-show":``,children:[(0,Y.jsx)(`rect`,{x:i,y:e.y-7,width:r,height:`14`,rx:`7`,fill:`var(--lm-surface)`,stroke:`var(--lm-muted)`}),(0,Y.jsx)(`text`,{x:i+r/2,y:e.y+3,textAnchor:`middle`,fontSize:`8.5`,fontWeight:`600`,fill:`var(--lm-muted)`,children:t})]})})}function pd({lm:e,scene:t,id:n,board:r,detailId:i}){let{model:a,ev:o}=e,d=t.nodes.find(e=>e.id===n),p=d&&rd(e,d),m=Ku(e),h=a.scenarios.length>1?m.rows:[];(0,J.useEffect)(()=>{let e=r?.querySelector(`[data-node="${CSS.escape(n)}"]`);return e?.setAttribute(`aria-describedby`,i),()=>e?.removeAttribute(`aria-describedby`)},[r,n,i]);let g=p?o.components[p]:void 0,_=(0,J.useRef)(null),v=d&&`${d.x} ${d.y} ${d.w} ${d.h}`;if((0,J.useLayoutEffect)(()=>{let e=_.current,n=e?.offsetParent;if(!e||!d||!r||!(n instanceof HTMLElement))return;let i=()=>{let i=r.clientWidth/t.width,a=n.getBoundingClientRect(),o=e=>e-a.top-n.clientTop+n.scrollTop,s=0,c=innerHeight;for(let e=n;e;e=e.parentElement){if(getComputedStyle(e).overflowY===`visible`)continue;let t=e.getBoundingClientRect();s=Math.max(s,t.top),c=Math.min(c,t.bottom)}let[l,u]=[o(s)+4,o(c)-4],f=e.offsetHeight,p=r.offsetTop+d.y*i,m=r.offsetTop+(d.y+d.h)*i,h=m+6,g=p-6-f,_=(d.y+d.h/2<t.height/2?[h,g]:[g,h]).find(e=>e>=l&&e+f<=u),v=u-m>=p-l?h:g;e.style.top=`${Math.max(l,Math.min(_??v,u-f))}px`,e.style.left=`${Math.max(0,Math.min(r.offsetLeft+d.x*i,n.clientWidth-e.offsetWidth))}px`};i();let a=new ResizeObserver(i);return a.observe(e),a.observe(r),document.addEventListener(`scroll`,i,{capture:!0,passive:!0}),addEventListener(`resize`,i),()=>{a.disconnect(),document.removeEventListener(`scroll`,i,{capture:!0}),removeEventListener(`resize`,i)}},[v,r,t]),!d||!g||!r)return null;let y=(e,t)=>e?N(e,a.searchMax,a.dateAt):l(t,a.searchMax),b=e=>Math.abs(e)>=1e3?c(e):s(e),x=g.capacity,S=yu(o,a).get(g.id);return(0,Y.jsxs)(`div`,{id:i,className:`lm-tip lm-detail`,role:`tooltip`,ref:_,children:[(0,Y.jsxs)(`b`,{children:[g.name,S&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":S.rank===1?`first`:`rank`,children:S.word})]}),g.util==null||!x?(0,Y.jsx)(`span`,{children:`switched off`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:f(g.util)}),` · `,b(g.demand??0),` of `,s(x.value),` `,x.unit,x.within?` ±${f(x.within)}`:``]}),(0,Y.jsxs)(`span`,{className:`lm-sub`,children:[`capacity`,` `,(0,Y.jsx)(`span`,{className:`lm-prov`,"data-kind":x.provenance,children:x.provenance}),x.source?`, ${x.source}`:``]}),(0,Y.jsxs)(`span`,{children:[f(a.thresholds.target),` at `,y(g.targetRange,g.target)]}),(0,Y.jsxs)(`span`,{children:[f(a.thresholds.full),` at `,y(g.fullRange,g.full)]}),md(e,d).map(e=>(0,Y.jsx)(`span`,{children:e},e)),g.over&&(0,Y.jsxs)(`span`,{className:`lm-sub`,children:[`Past `,f(a.thresholds.full),`: `,g.over,`.`]})]}),h.length>0&&(0,Y.jsxs)(`span`,{className:`lm-sub`,children:[f(a.thresholds.target),` by scenario:`,` `,h.map((e,t)=>{let n=e.components.find(e=>e.id===p);return(0,Y.jsxs)(`span`,{className:`lm-nowrap`,children:[t>0&&` · `,(0,Y.jsx)(`b`,{className:`lm-key`,style:{background:Hu(a,e.label)}}),e.label,` `,n?.targetRange==null?`off`:u(n.targetRange,a.searchMax,!0)]},e.label)})]})]})}function md(e,t){let n=[];for(let r of t.stages){let t=e.ev.stages[r];t?.kind===`workers`&&t.autoscale&&n.push(`${t.running} of ${t.pods} pods running, each held near ${f(t.autoscale.target)}`),t?.kind===`cache`&&n.push(`${f(t.hit)} answered here`),(t?.kind===`pass`||t?.kind===`limit`||t?.kind===`cache`)&&t.shed>0&&n.push(`${f(t.shed)} of what reaches it turned away`)}return n}var hd=null;function gd(){return hd??=_d(()=>new Worker(new URL(new URL(`elk.worker-4x4hA5S2.js`,import.meta.url).href,``+import.meta.url),{type:`module`,name:`loadmap-elk`})),hd}function _d(e){let t=null,n=typeof Worker>`u`,r=!1,i=0,a=new Map,o=e=>{r||typeof Worker>`u`||(r=!0,console.info(`loadmap: the layout runs on the main thread, slower to start: the ELK worker did not start (${e}). A page can hand one in, <Loadmap elk={workerElk(() => new Worker(…))}>; a Content-Security-Policy must allow it (worker-src).`))},s=e=>{o(e),n=!0,t?.terminate(),t=null;for(let[e,t]of a)a.delete(e),Ve().then(e=>e.layout(t.graph)).then(t.resolve,t.reject)},c=()=>{if(t||n)return t;try{t=e()}catch(e){return s(e instanceof Error?e.message:String(e)),null}return t.onmessage=({data:e})=>{let t=a.get(e.id);t&&(a.delete(e.id),e.error==null?t.resolve(e.graph):t.reject(Error(e.error)))},t.onerror=e=>{e.preventDefault(),s(e.message||`it failed to load or to run`)},t};return{layout(e){let t=c();return t?new Promise((n,r)=>{let o=i++;a.set(o,{graph:e,resolve:n,reject:r}),t.postMessage({id:o,graph:e})}):(o(`no Worker here`),Ve().then(t=>t.layout(e)))}}}function vd({lm:e}){let{measure:t}=e.ev;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`lm-verdict`,"data-tier":e.ev.verdict.tier,"aria-live":`polite`,children:e.ev.verdict.text}),t&&(0,Y.jsx)(`p`,{className:`lm-measure`,"data-component":t.component,children:t.text})]})}var yd=e=>e?.within?`±${f(e.within)}`:``;function bd({lm:e,title:t=`Where it runs out, in order`}){let{ev:n,model:r}=e,i=Math.max(1.5,r.thresholds.full*1.5),a=e=>`${e/i*100}%`,o=(e,t)=>e?u(e,r.searchMax,!0):l(t,r.searchMax);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:t}),(0,Y.jsxs)(`div`,{className:`lm-scale`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{style:{left:0,transform:`none`},children:`0`}),(0,Y.jsxs)(`span`,{style:{left:a(r.thresholds.target)},children:[f(r.thresholds.target),` target`]}),(0,Y.jsx)(`span`,{style:{left:a(r.thresholds.full)},children:f(r.thresholds.full)}),(0,Y.jsx)(`span`,{style:{left:`100%`,transform:`translateX(-100%)`},children:f(i)})]}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsx)(`div`,{className:`lm-limits`,children:n.ranked.map(e=>(0,Y.jsxs)(`div`,{className:`lm-lim`,"data-component":e.id,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`b`,{children:[e.name,e===n.firstLimit&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`first`,children:`limit`}),e.capacity?.provenance===`estimated`?(0,Y.jsxs)(`span`,{className:`lm-tag`,"data-kind":`estimated`,children:[`estimate`,e.capacity.within?` ${yd(e.capacity)}`:``]}):!!e.capacity?.within&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`range`,children:yd(e.capacity)})]}),(0,Y.jsx)(`span`,{className:`lm-sub`,children:e.describe??(e.capacity?`${s(e.capacity.value)} ${e.capacity.unit}`:`switched off`)})]}),(0,Y.jsxs)(`div`,{className:`lm-track`,role:`img`,"aria-label":`${e.name} at ${e.util==null?`off`:f(e.util)}`,children:[(0,Y.jsx)(`div`,{className:`lm-fill`,"data-state":e.state,style:{width:`${Math.min(100,(e.util??0)/i*100)}%`}}),(0,Y.jsx)(`div`,{className:`lm-tick`,style:{left:a(r.thresholds.target)}}),(0,Y.jsx)(`div`,{className:`lm-tick`,style:{left:a(r.thresholds.full)}})]}),(0,Y.jsxs)(`div`,{className:`lm-val`,children:[e.util==null?`—`:`${f(e.util)} · ${Ed(e.demand??0)} ${e.capacity?.unit??``}`,(0,Y.jsx)(`small`,{children:e.util==null?`switched off`:`${f(r.thresholds.target)} at ${o(e.targetRange,e.target)} · full at ${o(e.fullRange,e.full)}`})]})]},e.id))})]})}function xd({lm:e}){let[,t]=(0,J.useState)(0);(0,J.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),250);return()=>clearInterval(e)},[]);let{ev:n,engine:r,model:i}=e,a=r.sim,o=e=>i.def.flows[e]?.label??e,l=[];for(let e of Object.values(n.stages)){if(e.kind===`queue`)for(let t of i.flowIds.filter(t=>n.routes[t]?.includes(e.id))){let r=a.queue(e.id,t),i=n.overload[t]??{};l.push({key:`${e.id}/${t}/lag`,value:p(r.lag),label:`${o(t)} lag in ${e.label}`,state:r.lag>60?`over`:r.lag>5?`warn`:`ok`}),i.merge&&l.push({key:`${e.id}/${t}/merge`,value:c(r.merged),label:`${o(t)} superseded /s (${i.merge.reason??`newest kept`})`,state:r.merged>.5?`warn`:`ok`}),i.drop&&l.push({key:`${e.id}/${t}/drop`,value:c(r.dropped),label:`${o(t)} dropped /s (${i.drop.reason??`too old`})`,state:r.dropped>.5?`over`:`ok`})}if(e.kind===`workers`){let t=a.busy(e.id);l.push({key:`${e.id}/busy`,value:f(t),label:`${e.label} busy`,state:t>.95?`over`:t>.5?`warn`:`ok`}),e.autoscale&&l.push({key:`${e.id}/pods`,value:`${e.running} of ${e.pods}`,label:`${e.label} pods running`,state:e.running<e.pods?`ok`:(n.components[e.component]?.util??0)>i.thresholds.full?`over`:`warn`})}e.kind===`cache`&&l.push({key:`${e.id}/hits`,value:c(a.arriving(e.id)*(1-a.shed(e.id))*e.hit),label:`answered at ${e.label} /s (${f(e.hit)} hits)`,state:`ok`}),(e.kind===`pass`||e.kind===`limit`||e.kind===`cache`)&&a.shed(e.id)>0&&l.push({key:`${e.id}/shed`,value:f(a.shed(e.id)),label:`rejected at ${e.label}`,state:`over`})}for(let e of i.flowIds){let t=n.retry[e];if(!t||!(t.rate>0))continue;let r=t.attempts/t.rate;l.push({key:`${e}/attempts`,value:`${s(r)}×`,label:`${o(e)} attempts per ${i.def.flows[e]?.unit??`unit`}`,state:r>1.05?`warn`:`ok`}),l.push({key:`${e}/failed`,value:f(t.failed),label:`${o(e)} failing after ${t.times} ${t.times===1?`retry`:`retries`}`,state:t.failed>.005?`over`:`ok`})}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`Live`}),(0,Y.jsx)(`div`,{className:`lm-meters`,children:l.map(e=>(0,Y.jsxs)(`div`,{className:`lm-meter`,"data-state":e.state,children:[(0,Y.jsx)(`b`,{children:e.value}),(0,Y.jsx)(`span`,{title:e.label,children:e.label})]},e.key))})]})}function Sd({lm:e}){let t=e.model.load,n=e.values.load;return(0,Y.jsxs)(`label`,{className:`lm-range`,children:[(0,Y.jsxs)(`span`,{children:[t.label,` `,(0,Y.jsxs)(`output`,{children:[s(n),`×`]})]}),(0,Y.jsx)(`input`,{type:`range`,min:t.min,max:t.max,step:t.step,value:n,onChange:t=>e.setValues({load:Number(t.target.value)})})]})}function Cd({lm:e}){let{model:t,values:n,setValues:r,ev:i}=e,a=n;return(0,Y.jsxs)(`div`,{className:`lm-card lm-controls`,children:[(0,Y.jsx)(`h3`,{children:`Load`}),(0,Y.jsx)(Sd,{lm:e}),(0,Y.jsx)(`div`,{className:`lm-presets`,children:i.presets.map(e=>{let t=Object.entries(e.values).every(([e,t])=>a[e]===t);return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>r(e.values),children:e.label},e.label)})}),t.params.length>1&&(0,Y.jsx)(`h3`,{children:`Design`}),t.params.map(({id:e,def:n})=>{if(n.kind===`load`)return null;let i=t.isEnabled(e,a),o=n.tag&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`estimated`,children:n.tag});return n.kind===`switch`?(0,Y.jsxs)(`label`,{className:`lm-switch${i?``:` lm-off`}`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:!!a[e],disabled:!i,onChange:t=>r({[e]:t.target.checked})}),(0,Y.jsxs)(`span`,{children:[n.label,o]}),n.hint&&(0,Y.jsx)(`small`,{children:n.hint})]},e):n.kind===`select`?(0,Y.jsxs)(`label`,{className:`lm-select${i?``:` lm-off`}`,children:[(0,Y.jsxs)(`span`,{children:[n.label,o]}),(0,Y.jsx)(`select`,{value:String(a[e]),disabled:!i,onChange:t=>{let i=n.options.find(e=>String(e)===t.target.value);r({[e]:i})},children:n.options.map(e=>(0,Y.jsx)(`option`,{value:String(e),children:n.format?n.format(e):String(e)},String(e)))}),n.hint&&(0,Y.jsx)(`small`,{children:n.hint})]},e):(0,Y.jsxs)(`label`,{className:`lm-range${i?``:` lm-off`}`,children:[(0,Y.jsxs)(`span`,{children:[n.label,o,` `,(0,Y.jsx)(`output`,{children:n.format?n.format(a[e]):s(a[e])})]}),(0,Y.jsx)(`input`,{type:`range`,min:n.min,max:n.max,step:n.step,value:a[e],disabled:!i,onChange:t=>r({[e]:Number(t.target.value)})}),n.hint&&(0,Y.jsx)(`small`,{children:n.hint})]},e)})]})}function wd({lm:e,extra:t=[]}){return(0,Y.jsxs)(`div`,{className:`lm-card`,children:[(0,Y.jsx)(`h3`,{children:`What this assumes`}),(0,Y.jsxs)(`ul`,{className:`lm-facts`,children:[t.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t)),e.ev.assumptions.map(e=>(0,Y.jsx)(`li`,{children:Td(e)},e.kind===`capacity`?`c:${e.component}`:`f:${e.name}`))]})]})}function Td(e){if(e.kind===`capacity`){let t=e.capacity;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`b`,{children:[e.name,`:`]}),` `,s(t.value),` `,t.unit,t.within?` ${yd(t)}`:``,`,`,` `,(0,Y.jsx)(`span`,{className:`lm-prov`,"data-kind":t.provenance,children:t.provenance}),t.source?` (${t.source})`:``,`.`]})}let t=e.fit;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`b`,{children:[e.name,`:`]}),` `,t.y,` = `,Dd(t.a),` + `,Dd(t.b),` × `,t.x,`, r² `,t.r2.toFixed(3),` over `,t.n,` points,`,` `,(0,Y.jsx)(`span`,{className:`lm-prov`,"data-kind":`measured`,children:`measured`}),t.source?` (${t.source})`:``,`.`]})}var Ed=e=>Math.abs(e)>=1e3?c(e):s(e),Dd=e=>Number(e.toPrecision(3)).toString(),Od={verdict:`Verdict`,live:`Live`,limits:`Limits`,controls:`Load`,headroom:`Headroom`,compare:`Compare`,assumptions:`Assumptions`};function kd({lm:e,verdict:t=!0,extra:n=0,open:r,assumptions:i}){let{ev:a,model:o,values:c}=e,d=a.firstLimit,p=a.target,m=`${f(o.thresholds.target)} target`,h=d?.capacity,g=h?h.provenance===`estimated`?`est${h.within?` ${yd(h)}`:``}`:yd(h):``,_=a.ranked.filter(e=>(e.util??0)>o.thresholds.full),v=p?Gu(o,p):``,y=a.assumptions.filter(e=>e.kind===`capacity`&&e.capacity.provenance===`estimated`).length;return(0,Y.jsxs)(Y.Fragment,{children:[t&&(0,Y.jsx)(`p`,{className:`lm-headline`,title:a.verdict.text,"aria-live":`polite`,children:!d||!p?a.verdict.text:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`b`,{className:`lm-num`,children:[s(c.load),`×`]}),` ·`,` `,c.load<p.low?(0,Y.jsxs)(Y.Fragment,{children:[`the `,m,` holds to `,(0,Y.jsx)(`b`,{className:`lm-num`,children:u(p,o.searchMax,!0)}),v&&` (${v})`]}):(0,Y.jsxs)(Y.Fragment,{children:[`past the `,m,` from `,(0,Y.jsx)(`b`,{className:`lm-num`,children:l(p.low,o.searchMax)})]}),` `,`· limited by `,(0,Y.jsx)(`b`,{children:d.name}),g&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":h?.provenance===`estimated`?`estimated`:`range`,children:g}),_.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[` `,`· `,(0,Y.jsx)(`b`,{children:_.map(e=>e.name).join(`, `)}),` past capacity`]})]})}),r&&t&&(0,Y.jsx)(`button`,{type:`button`,className:`lm-link`,onClick:e=>r(`verdict`,e.currentTarget),children:`Why ›`}),r&&i&&(0,Y.jsxs)(`button`,{type:`button`,className:`lm-link`,onClick:e=>r(`assumptions`,e.currentTarget),children:[`What this assumes · `,a.assumptions.length+n,y>0&&` (${y} estimated)`,` ›`]})]})}var Ad=[`controls`,`live`,`limits`,`headroom`,`compare`];function jd({lm:e,panels:t,open:n}){let r=Ad.filter(e=>t.includes(e)),[i,a]=(0,J.useState)(null);if(!r.length)return null;let o=i&&r.includes(i)?i:r[0];return(0,Y.jsxs)(`div`,{className:`lm-dock`,children:[(0,Y.jsx)(`fieldset`,{className:`lm-tabs`,"aria-label":`Panels`,children:r.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":e===o,onClick:()=>a(e),children:Od[e]},e))}),r.map(t=>(0,Y.jsx)(Md,{lm:e,panel:t,open:n,active:t===o},t))]})}function Md({lm:e,panel:t,open:n,active:r}){let i=(0,J.useRef)(null),a=(0,J.useRef)(null);return Pd(i,a),(0,Y.jsxs)(`div`,{className:`lm-mini`,"data-mini":t,"data-active":r||void 0,ref:i,children:[t===`controls`?(0,Y.jsx)(Cd,{lm:e}):t===`compare`?(0,Y.jsx)(Ju,{lm:e}):(0,Y.jsx)(`div`,{className:`lm-card`,children:t===`live`?(0,Y.jsx)(xd,{lm:e}):t===`limits`?(0,Y.jsx)(Fd,{lm:e}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`Headroom`}),(0,Y.jsx)(Id,{lm:e})]})}),(0,Y.jsx)(`button`,{type:`button`,className:`lm-more`,ref:a,"aria-label":`${Od[t]}, all of it`,onClick:e=>n(t,e.currentTarget),children:`›`})]})}var Nd=`.lm-meter, .lm-mini-lim, .lm-controls > *, .lm-table tbody tr`;function Pd(e,t){(0,J.useEffect)(()=>{let n=e.current?.querySelector(`.lm-card`);if(!n)return;let r=()=>{let e=n.getBoundingClientRect(),r=e.bottom-Number.parseFloat(getComputedStyle(n).paddingBottom||`0`),i=0;for(let t of n.querySelectorAll(Nd)){let n=e.height>0&&t.getBoundingClientRect().bottom>r+.5;t.toggleAttribute(`data-clip`,n),n&&!t.matches(`h3`)&&i++}t.current&&(t.current.dataset.more=i?`+${i}`:``)},i=new ResizeObserver(r);i.observe(n);let a=new MutationObserver(r);return a.observe(n,{childList:!0,subtree:!0}),r(),()=>{i.disconnect(),a.disconnect()}},[e,t])}function Fd({lm:e}){let{ev:t,model:n}=e,r=Math.max(1.5,n.thresholds.full*1.5),i=e=>`${e/r*100}%`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{children:`Where it runs out`}),(0,Y.jsx)(`div`,{className:`lm-mini-limits`,children:t.ranked.map(e=>(0,Y.jsxs)(`div`,{className:`lm-mini-lim`,"data-component":e.id,children:[(0,Y.jsxs)(`span`,{className:`lm-name`,title:e.name,children:[e.name,e.capacity?.provenance===`estimated`?(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`estimated`,children:`est`}):!!e.capacity?.within&&(0,Y.jsx)(`span`,{className:`lm-tag`,"data-kind":`range`,children:`±`})]}),(0,Y.jsxs)(`span`,{className:`lm-track`,role:`img`,"aria-label":`${e.name} at ${e.util==null?`off`:f(e.util)}`,children:[(0,Y.jsx)(`span`,{className:`lm-fill`,"data-state":e.state,style:{width:`${Math.min(100,(e.util??0)/r*100)}%`}}),(0,Y.jsx)(`span`,{className:`lm-tick`,style:{left:i(n.thresholds.target)}}),(0,Y.jsx)(`span`,{className:`lm-tick`,style:{left:i(n.thresholds.full)}})]}),(0,Y.jsx)(`span`,{className:`lm-val`,children:e.util==null?`—`:f(e.util)}),(0,Y.jsx)(`span`,{className:`lm-val lm-sub`,children:e.util==null?`off`:e.full!=null&&!Number.isFinite(e.full)?`full > ${s(n.searchMax)}×`:`full ${e.fullRange?u(e.fullRange,n.searchMax,!0):l(e.full,n.searchMax)}`})]},e.id))})]})}function Id({lm:e}){let{model:t,values:n}=e,r=Q(e),[i,{width:a,height:o}]=Z(240),s=Math.max(1.5,t.thresholds.full*1.5),c=e=>a*Math.log(e/r.from)/Math.log(r.to/r.from),d=e=>8+(o-10)*(1-Math.min(e,s*1.2)/s),p=e=>{let t=``,n=!1;for(let[r,i]of e)i==null?n=!1:(t+=`${n?`L`:`M`}${c(r).toFixed(1)} ${d(i).toFixed(1)}`,n=!0);return t},m=r.lines.find(e=>e.selected)??r.lines[0],h=f(t.thresholds.target),g=m?`${m.targetRange?u(m.targetRange,t.searchMax,!0):l(m.target,t.searchMax)}`:``,_=m?Gu(t,m.targetRange):``,v=c(Math.min(r.to,Math.max(r.from,n.load)));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`lm-spark`,ref:i,children:o>0&&(0,Y.jsxs)(`svg`,{width:a,height:o,"aria-hidden":`true`,children:[(0,Y.jsx)(`line`,{className:`lm-spark-th`,x1:0,x2:a,y1:d(t.thresholds.target),y2:d(t.thresholds.target)}),r.lines.map(e=>(0,Y.jsx)(`path`,{d:p(e.envelope),fill:`none`,stroke:Hu(t,e.label),strokeWidth:e.selected?2:1.25},e.label??``)),(0,Y.jsx)(`line`,{className:`lm-spark-load`,x1:v,x2:v,y1:0,y2:o})]})}),m&&(0,Y.jsxs)(`p`,{className:`lm-spark-text`,title:`${m.label??`It`} reaches the ${h} target at ${g}`,children:[m.label??`It`,` reaches the `,h,` target at `,g,_&&` (${_})`,`.`]})]})}function Ld({lm:e}){let t=(0,J.useRef)(null),{story:n}=e.model;if(!n.length)return null;let r=e.cue?.step??e.step,i=n.length-1,a=t=>{let n=Math.max(0,Math.min(i,t));(n!==r||e.storyPlaying)&&e.setStep(n)},o=e=>{if(e.key===`ArrowRight`)a(r==null?0:r+1);else if(e.key===`ArrowLeft`&&r!=null)a(r-1);else return;e.preventDefault()},s=e.storyPlaying;return(0,Y.jsxs)(`fieldset`,{className:`lm-story`,onKeyDown:o,ref:t,tabIndex:-1,"data-playing":s||void 0,children:[(0,Y.jsx)(`legend`,{children:`Story`}),(0,Y.jsx)(`span`,{className:`lm-sr`,"aria-live":`polite`,children:r==null?`A walk through this model in ${n.length} steps.`:`${r+1} of ${n.length}. ${n[r].text}${e.stepChanged?` You changed the values since.`:``}`}),(0,Y.jsxs)(`p`,{"aria-hidden":`true`,children:[(0,Y.jsxs)(`span`,{"data-shown":r==null||void 0,children:[`A walk through this model in `,n.length,` steps.`]}),n.map((t,i)=>(0,Y.jsxs)(`span`,{"data-shown":i===r||void 0,children:[(0,Y.jsxs)(`b`,{children:[i+1,` of `,n.length]}),` `,t.text,(0,Y.jsx)(`em`,{"data-shown":i===r&&e.stepChanged||void 0,children:` You changed the values since.`})]},i))]}),r!=null&&(0,Y.jsx)(`span`,{className:`lm-story-progress`,"aria-hidden":`true`,children:n.map((t,n)=>(0,Y.jsx)(`i`,{"data-state":n<r?`done`:n===r?`now`:void 0,style:n===r?{"--lm-step":`${e.cue?.seconds??Tu(t,e.engine.transition)}s`}:void 0},n===r?`${n}-${s}`:n))}),(0,Y.jsxs)(`span`,{className:`lm-story-nav`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>e.setStoryPlaying(!s),"aria-pressed":s,children:s?`❚❚ Pause`:`▶ Play`}),r!=null&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(r-1),"aria-disabled":r===0,children:`Back`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(r==null?0:r+1),"aria-disabled":r===i,children:r==null?`Start`:`Next`}),r!=null&&e.stepChanged&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{e.setStep(r),t.current?.focus()},children:`Show again`}),r!=null&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>e.setStep(null),"aria-label":`Leave the story`,children:`Done`})]})]})}var Rd=`
|
|
17
17
|
--lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;
|
|
18
18
|
--lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;
|
|
19
19
|
--lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;
|
|
20
|
-
--lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;`,
|
|
20
|
+
--lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;`,zd=`
|
|
21
21
|
--lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;
|
|
22
22
|
--lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;
|
|
23
23
|
--lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;
|
|
24
|
-
--lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark;`,
|
|
25
|
-
.lm { ${
|
|
24
|
+
--lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark;`,Bd=`
|
|
25
|
+
.lm { ${Rd}
|
|
26
26
|
--lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
27
27
|
--lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
28
28
|
font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-root-bg, var(--lm-bg));
|
|
29
29
|
display: grid; gap: 14px; padding: var(--lm-pad, 16px); min-width: 0; box-sizing: border-box; }
|
|
30
|
-
@media (prefers-color-scheme: dark) { .lm:not([data-theme="light"]) { ${
|
|
31
|
-
.lm[data-theme="dark"] { ${
|
|
30
|
+
@media (prefers-color-scheme: dark) { .lm:not([data-theme="light"]) { ${zd} } }
|
|
31
|
+
.lm[data-theme="dark"] { ${zd} }
|
|
32
32
|
.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }
|
|
33
33
|
.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }
|
|
34
34
|
.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }
|
|
@@ -63,6 +63,7 @@ import{r as e,t}from"./rolldown-runtime-pP25SEvz.js";(function(){let e=document.
|
|
|
63
63
|
.lm-side, .lm-card > .lm-panel { display: contents; }
|
|
64
64
|
.lm-panel { display: grid; gap: 14px; min-width: 0; }
|
|
65
65
|
.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; background: var(--lm-bg); overflow: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; position: relative; }
|
|
66
|
+
.lm[data-full="fill"] { height: 100%; padding: 10px; }
|
|
66
67
|
.lm[data-full="overlay"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }
|
|
67
68
|
.lm[data-full] > * { flex: none; }
|
|
68
69
|
/* a page of its own keeps the rest outside full screen, as <Loadmap> does */
|
|
@@ -204,7 +205,7 @@ import{r as e,t}from"./rolldown-runtime-pP25SEvz.js";(function(){let e=document.
|
|
|
204
205
|
.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }
|
|
205
206
|
.lm-tag[data-kind="first"] { color: var(--lm-surface); background: var(--lm-drop); }
|
|
206
207
|
.lm-tag[data-kind="estimated"] { color: var(--lm-warn); border: 1px solid currentColor; }
|
|
207
|
-
.lm-tag[data-kind="range"] { color: var(--lm-muted); border: 1px solid currentColor; }
|
|
208
|
+
.lm-tag[data-kind="range"], .lm-tag[data-kind="rank"] { color: var(--lm-muted); border: 1px solid currentColor; }
|
|
208
209
|
.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }
|
|
209
210
|
.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }
|
|
210
211
|
.lm-fill[data-state="warn"] { background: var(--lm-warn); } .lm-fill[data-state="over"] { background: var(--lm-drop); }
|
|
@@ -288,13 +289,13 @@ import{r as e,t}from"./rolldown-runtime-pP25SEvz.js";(function(){let e=document.
|
|
|
288
289
|
.lm-fill { transition: none; }
|
|
289
290
|
.lm-story[data-playing] .lm-story-progress i[data-state="now"]::before { animation: none; transform: none; }
|
|
290
291
|
}
|
|
291
|
-
`;function Nd(e=document){if(e.getElementById(`loadmap-css`))return;let t=e.createElement(`style`);t.id=`loadmap-css`,t.textContent=Md,e.head.appendChild(t)}var Pd=[0,.3],Fd=[.15,.8],Id=[.6,1],Ld=[.7,1],Rd=24,zd=(e,[t,n])=>Math.min(1,Math.max(0,(e-t)/(n-t))),Bd=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Vd=(e,t,n)=>e+(t-e)*n,Hd=(e,t,n)=>({...t,x:Vd(e.x,t.x,n),y:Vd(e.y,t.y,n),w:Vd(e.w,t.w,n),h:Vd(e.h,t.h,n)}),Ud=(e,t,n)=>({...t,x:Vd(e.x,t.x,n),y:Vd(e.y,t.y,n)}),Wd=(e,t)=>e.fade==null?{}:{fade:Vd(e.fade,1,t.enter)},Gd=(e,t)=>({...e,fade:(e.fade??1)*t.out});function Kd(e,t){let n=new Map(e.nodes.map(e=>[e.id,e])),r=new Set(t.nodes.map(e=>e.id)),i=new Map(e.edges.map(e=>[e.id,e])),a=new Set(t.edges.map(e=>e.id)),o=new Map;for(let e of t.edges){let t=i.get(e.id)?.points;t?.length&&e.points.length&&o.set(e.id,Jd(t,e.points)?[t,e.points]:[Xd(t,Rd),Xd(e.points,Rd)])}return s=>{if(s>=1)return t;let c=Bd(zd(s,Fd)),l={out:1-zd(s,Pd),enter:zd(s,Id)},u=zd(s,Ld),d=t.edges.map(e=>{let t=i.get(e.id),n=o.get(e.id);if(!t||!n)return{...e,fade:l.enter,draw:u};let[r,a]=n,s=r.map((e,t)=>[Vd(e[0],a[t][0],c),Vd(e[1],a[t][1],c)]),d=e.label&&(t.label?Hd(t.label,e.label,c):e.label);return{...e,points:s,label:d,...Wd(t,l),...t.draw==null?{}:{draw:Vd(t.draw,1,u)}}});for(let t of e.edges)a.has(t.id)||d.push(Gd(t,l));let f=t.nodes.map(e=>{let t=n.get(e.id);return t?qd(t,e,c,l):{...e,fade:l.enter}});for(let t of e.nodes)r.has(t.id)||f.push(Gd(t,l));return{...t,width:Vd(e.width,t.width,c),height:Vd(e.height,t.height,c),nodes:f,edges:d}}}function qd(e,t,n,r){let i=t.members.map((t,i)=>{let a=e.members[i];return a?{...Hd(a,t,n),spot:Ud(a.spot,t.spot,n),...Wd(a,r)}:{...t,fade:r.enter}});for(let n of e.members.slice(t.members.length))i.push(Gd(n,r));let a=e=>{let t=new Map;return e.map(e=>{let n=`${e.flow}|${e.text}`,r=t.get(n)??0;return t.set(n,r+1),`${n}|${r}`})},o=a(e.groups),s=new Map(e.groups.map((e,t)=>[o[t],e])),c=a(t.groups),l=t.groups.map((e,t)=>{let i=s.get(c[t]);return i?{...e,spot:Ud(i.spot,e.spot,n),...Wd(i,r)}:{...e,fade:r.enter}}),u=new Set(c);e.groups.forEach((e,t)=>{u.has(o[t])||l.push(Gd(e,r))});let d=e=>`${e.stage}/${e.flow}/${e.index}`,f=new Map(e.cells.map(e=>[d(e),e])),p=new Set(t.cells.map(d)),m=t.cells.map(e=>{let t=f.get(d(e));return t?{...Hd(t,e,n),...Wd(t,r)}:{...e,fade:r.enter}});for(let t of e.cells)p.has(d(t))||m.push(Gd(t,r));let h=new Map(e.slots.map(e=>[e.index,e])),g=new Set(t.slots.map(e=>e.index)),_=t.slots.map(e=>{let t=h.get(e.index);return t?{...Hd(t,e,n),...Wd(t,r)}:{...e,fade:r.enter}});for(let t of e.slots)g.has(t.index)||_.push(Gd(t,r));return{...Hd(e,t,n),...Wd(e,r),title:Ud(e.title,t.title,n),sub:t.sub&&(e.sub?Ud(e.sub,t.sub,n):t.sub),members:i,groups:l,cells:m,slots:_}}function Jd(e,t){return e.length===t.length&&e.every((n,r)=>r===0||Yd(e[r-1],n)===Yd(t[r-1],t[r]))}var Yd=(e,t)=>Math.abs(t[0]-e[0])>=Math.abs(t[1]-e[1])?`h`:`v`;function Xd(e,t){if(e.length<2)return Array.from({length:t},()=>e[0]??[0,0]);let n=[0];for(let t=1;t<e.length;t++)n.push(n[t-1]+Math.hypot(e[t][0]-e[t-1][0],e[t][1]-e[t-1][1]));let r=n.at(-1),i=[],a=1;for(let o=0;o<t;o++){let s=r*o/(t-1);for(;a<n.length-1&&n[a]<s;)a++;let c=n[a]-n[a-1],l=c>0?(s-n[a-1])/c:1,u=e[a-1],d=e[a];i.push([Vd(u[0],d[0],l),Vd(u[1],d[1],l)])}return i}function Zd(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var Qd=.7;function $d(e,t,n,r=1){let i=e*t,a=Array(i),o=Zd(r);for(let r=0;r<e;r++){let i=Array.from({length:t},(e,t)=>t);for(let e=t-1;e>0;e--){let t=Math.floor(o()*(e+1));[i[e],i[t]]=[i[t],i[e]]}i.forEach((i,o)=>{a[r*t+i]=n===`round-robin`?o*e+r:r*t+o})}let s=Array.from({length:i},()=>.92+o()*.16),c=s.reduce((e,t)=>e+t,0)/(i||1);return{rank:a,jitter:s.map(e=>e/c)}}function ef(e,t,n){let r=t.rank.length,i=Math.min(1,Math.max(0,n))*r,a=t.rank[e],o;if(i<=Qd*r){let e=Math.floor(i/Qd);o=a<e?Qd:a===e?i-e*Qd:0}else o=Qd+(i-Qd*r)/r;return Math.min(1,Math.max(0,o*(t.jitter[e]??1)))}var tf=()=>({backlog:0,lag:0,arriving:0,served:0,dropped:0,merged:0,merging:!1}),nf=1,rf=2e3,af=3,of=class{speed;time=0;particles=[];dotScale=1;#e;#t;#n;#r;#i=``;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=new Map;#d=new Map;#f=1;constructor(e,t,n={}){this.#e={seed:1,speed:10,dotTarget:28,minDots:1,maxDots:40,legSeconds:.45,maxParticles:800,...n},this.speed=this.#e.speed,this.#t=Zd(this.#e.seed),this.#n=e,this.update(t);for(let e of Object.values(t.stages))e.kind===`workers`&&this.#o.set(e.id,this.#m(e.id))}update(e){this.#r=e;let t=JSON.stringify(Object.values(e.stages).map(e=>e.kind===`queue`?[e.id,e.partitions]:e.kind===`workers`?[e.id,e.pods,e.perPod,e.fill]:[e.id,e.kind]));if(t!==this.#i){this.#i=t;let n=(t,n)=>{if(t.stage==null)return!0;let r=e.stages[t.stage];return r?t.cell==null?!0:r.kind===`queue`?t.cell<(r.partitions[n]??0):r.kind===`workers`&&t.cell<r.pods*r.perPod:!1};this.particles=this.particles.filter(e=>n(e.from,e.flow)&&n(e.to,e.flow)),this.#s.clear()}let n=this.#n.thresholds.full,r=Object.values(e.stages);this.#c.clear();for(let e of r)this.#c.set(e.id,`shed`in e?e.shed:0);this.#l.clear();for(let t of this.#n.flowIds){let n=e.flows[t]??0;for(let r of e.routes[t]??[]){this.#l.set(`${r}/${t}`,n);let i=e.stages[r];i.kind!==`fanout`&&(n*=1-(this.#c.get(r)??0)),i.kind===`cache`&&(n*=1-i.hit)}}this.#u.clear();let i=new Map;for(let t of r){let r=t.component?e.components[t.component]:void 0,a=1/0;if(r&&r.util!=null&&r.full!=null&&Number.isFinite(r.full)){if(r.full>0){let n=i.get(r.full);n||(n=this.#n.evaluate({...e.values,load:r.full}),i.set(r.full,n)),a=this.#n.flowIds.reduce((e,r)=>e+(n.at[t.id]?.[r]??0),0)}else{let i=this.#n.flowIds.reduce((n,r)=>n+(e.at[t.id]?.[r]??0),0);a=r.util>0?i*n/r.util:0}}this.#u.set(t.id,a)}let a=this.#n.flowIds.reduce((t,n)=>t+(e.flows[n]??0),0);this.dotScale=Math.max(1,m(a/this.#e.dotTarget))}step(e,t={}){if(!(e>0))return;let n=e*this.speed;this.time+=n,this.#g(n),t.particles!==!1&&(this.#_(e),this.#y(e))}queue(e,t){return this.#a.get(e)?.get(t)?.s??tf()}busy(e){return this.#o.get(e)??this.#m(e)}shed(e){return this.#c.get(e)??0}slotBusy(e,t){let n=this.#r.stages[e];if(n?.kind!==`workers`||t>=n.running*n.perPod)return 0;let r=`${e}/${n.running}`,i=this.#s.get(r);return i||(i=$d(n.running,n.perPod,n.fill,this.#e.seed),this.#s.set(r,i)),ef(t,i,this.busy(e))}arriving(e){return this.#n.flowIds.reduce((t,n)=>t+(this.#l.get(`${e}/${n}`)??0),0)}running(e){let t=this.#r.stages[e];return t?.kind===`workers`?t.running:0}#p(e){return this.#r.components[e]?.util??null}#m(e){let t=this.#r.stages[e],n=t?.component?this.#p(t.component):null;return Math.min(1,(n??0)/this.#n.thresholds.full*this.#h(e))}#h(e){let t=this.#r.stages[e];return t?.kind===`workers`&&t.running>0?t.pods/t.running:1}#g(e){let t=this.#r,n=[];for(let r of Object.values(t.stages)){if(r.kind!==`queue`)continue;let i=this.#a.get(r.id)??new Map;this.#a.set(r.id,i);for(let a of this.#n.flowIds){let o=t.routes[a]??[];if(!o.includes(r.id))continue;let s=i.get(a)??{cohorts:[],s:tf()};i.set(a,s);let c=this.#l.get(`${r.id}/${a}`)??0,l=Math.min(.95,Math.max(0,t.overload[a]?.merge?.share??0));s.s.merging=l>0&&cf(s.cohorts)>c*1;let u=c*e,d=s.cohorts.at(-1);d&&this.time-d.t<nf?d.n+=u:u>0&&s.cohorts.push({t:this.time,n:u}),s.cohorts.length>rf&&(s.cohorts=uf(s.cohorts));let f=o[o.indexOf(r.id)+1]??`∞`,p=s.s.merging?1/(1-l):1;n.push({q:r.id,f:a,fq:s,drainer:f,prio:this.#n.def.flows[a]?.priority??1,k:p})}}let r=new Map;for(let t of new Set(n.map(e=>e.drainer))){let i=n.filter(e=>e.drainer===t),a=t===`∞`?1/0:(this.#u.get(t)??1/0)*e;for(let n of[...new Set(i.map(e=>e.prio))].sort((e,t)=>e-t)){let o=i.filter(e=>e.prio===n),s=o.reduce((e,t)=>e+cf(t.fq.cohorts)/t.k,0),c=0;for(let t of o){let n=cf(t.fq.cohorts),r=Number.isFinite(a)?s>0?Math.min(n,a*n/s):0:n,i=r/t.k;lf(t.fq.cohorts,r),c+=i,t.fq.s.served=df(t.fq.s.served,i/e,e),t.fq.s.merged=df(t.fq.s.merged,(r-i)/e,e)}a=Math.max(0,a-c),r.set(t,(r.get(t)??0)+c)}}for(let{q:r,f:i,fq:a}of n){let n=0,o=t.overload[i]?.drop;if(o)for(;a.cohorts.length&&this.time-a.cohorts[0].t>o.olderThan;)n+=a.cohorts.shift().n;let s=this.#l.get(`${r}/${i}`)??0;cf(a.cohorts)<1e-9*Math.max(1,s)&&(a.cohorts=[]),a.s.backlog=cf(a.cohorts),a.s.lag=a.cohorts.length?this.time-a.cohorts[0].t:0,a.s.arriving=df(a.s.arriving,s,e),a.s.dropped=df(a.s.dropped,n/e,e)}for(let n of Object.values(t.stages)){if(n.kind!==`workers`)continue;let t=this.#u.get(n.id)??1/0,i=r.has(n.id)&&Number.isFinite(t)&&t>0?r.get(n.id)/(t*e)*this.#h(n.id):this.#m(n.id);this.#o.set(n.id,df(this.#o.get(n.id)??i,Math.min(1,i),e))}}#_(e){let{minDots:t,maxDots:n,legSeconds:r,maxParticles:i}=this.#e;for(let a of this.#n.flowIds){let o=this.#r.retry[a]?.rate??this.#r.flows[a]??0;if(o<=0)continue;let s=Math.min(n,Math.max(t,o/this.dotScale)),c=(this.#d.get(a)??0)+s*e;for(;c>=1;){if(--c,this.particles.length>=i)continue;let e=this.#r.routes[a][0];this.particles.push({id:this.#f++,flow:a,leg:0,phase:`move`,t:0,dur:r,from:{stage:null},to:this.#b(e,a)})}this.#d.set(a,c)}}#v(e){let t=this.#r.retry[e.flow],n=(e.attempt??0)+1;return!t||n>t.times||this.#t()>=t.retried?null:{id:this.#f++,flow:e.flow,leg:0,phase:`move`,t:0,dur:this.#e.legSeconds,from:{stage:null},to:this.#b(this.#r.routes[e.flow][0],e.flow),attempt:n}}#y(e){let t=this.#r,n=(e,t,n)=>{e.phase=`fade`,e.outcome=t,e.t=0,e.dur=n,e.from=e.to},r=e=>{let r=t.routes[e.flow];if(e.leg+1>=r.length)return n(e,`delivered`,.35);e.leg++,e.phase=`move`,e.t=0,e.dur=this.#e.legSeconds,e.from=e.to,e.to=this.#b(r[e.leg],e.flow)},i=[],a=e=>{n(e,`rejected`,.6);let t=this.particles.length+i.length<this.#e.maxParticles?this.#v(e):null;t&&i.push(t)};for(let o of this.particles){if(o.t+=e,o.t<o.dur)continue;if(o.phase===`move`&&o.back){n(o,`answered`,.35);continue}let s=t.stages[o.to.stage??``];if(o.phase===`fade`||!s)o.phase=`fade`,o.outcome??=`delivered`;else if(o.phase===`move`&&o.branch)n(o,this.#t()<this.shed(o.from.stage??``)||s.kind===`pass`&&this.#t()<this.shed(s.id)?`rejected`:`delivered`,.35);else if(o.phase===`move`&&s.kind===`fanout`){let e=0;for(let t of s.to[o.flow]??[]){let n=Math.floor(t.share)+ +(this.#t()<t.share%1);for(let r=0;r<n;r++,e++)this.particles.length+i.length<this.#e.maxParticles&&i.push({id:this.#f++,flow:o.flow,leg:o.leg,phase:`move`,t:0,dur:this.#e.legSeconds,from:o.to,to:{stage:t.stage},branch:t.stage})}e?n(o,`delivered`,0):n(o,`unread`,.6)}else if(o.phase===`move`){if((s.kind===`pass`||s.kind===`limit`||s.kind===`cache`)&&this.#t()<this.shed(s.id))a(o);else if(s.kind===`cache`&&this.#t()<s.hit){let e=o.from;o.from=o.to,o.to=e,o.t=0,o.dur=this.#e.legSeconds,o.back=!0}else if(s.kind===`queue`){let e=this.queue(s.id,o.flow).lag;o.phase=`hold`,o.t=0,o.dur=.12+Math.min(e,120)/120*2.6}else s.kind===`workers`?(o.phase=`hold`,o.t=0,o.dur=.15):r(o)}else if(o.phase===`hold`){let e=s.kind===`queue`?this.queue(s.id,o.flow):null,i=e&&e.arriving>0?Math.min(1,e.dropped/e.arriving):0,a=e?.merging?t.overload[o.flow]?.merge?.share??0:0;this.#t()<a?n(o,`superseded`,.6):this.#t()<i?n(o,`dropped`,.6):r(o)}}this.particles=this.particles.filter(e=>!(e.phase===`fade`&&e.t>=e.dur)).concat(i)}#b(e,t){let n=this.#r.stages[e];if(n?.kind===`queue`){let r=n.partitions[t]??0;return r>0?{stage:e,cell:Math.floor(this.#t()*r)}:{stage:e}}return n?.kind===`workers`?{stage:e,cell:this.#x(n.id,n.running*n.perPod)}:{stage:e}}#x(e,t){let n=0;for(let r=0;r<t;r++)n+=this.slotBusy(e,r);if(n<=.001)return Math.floor(this.#t()*t);let r=this.#t()*n;for(let n=0;n<t;n++)if(r-=this.slotBusy(e,n),r<=0)return n;return t-1}};function sf(e,t,n){return new of(e,t,n)}var cf=e=>e.reduce((e,t)=>e+t.n,0);function lf(e,t){let n=t;for(;n>0&&e.length;){let t=e[0];t.n<=n?(n-=t.n,e.shift()):(t.n-=n,n=0)}}function uf(e){let t=[];for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];t.push(i?{t:r.t,n:r.n+i.n}:r)}return t}function df(e,t,n){return e+(t-e)*Math.min(1,n/af)}var ff=[`accent`,`alt`,`ok`,`warn`,`drop`,`muted`,`fg`,`surface`,`line`],pf=1.4,mf=2.4;function hf(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}var gf=class{model;view;sim;ev;scene=null;frame=null;frameId=0;drawnFrame=-1;transition=.8;wantKey=``;drawnValues=``;wantFocus=null;storyStep=null;drawnFocus=null;paused=!1;reducedMotion=!1;camera=null;cue=null;host=null;colors={};svg=null;canvas=null;#e;#t=[];#n=new Map;#r=null;#i=new Set;#a=!1;#o={frame:-1,paths:new Map};#s=0;#c=null;constructor(e,t,n,r={}){this.model=e,this.view=t,this.ev=n,this.#e=r,this.sim=sf(e,n,r)}setEvaluation(e){if(e===this.ev)return;let t=JSON.stringify(e.values)===JSON.stringify(this.ev.values);this.ev=e,t||this.sim.update(e)}setScene(e,t={}){if(e===this.scene)return;let n=this.frame,r=this.transition;this.scene=e,this.#n.clear();let i=n&&!t.cut&&r>0&&Number.isFinite(r)&&(!this.paused||this.#a)&&n.direction===e.direction&&n.key!==e.key;this.#r=i?{at:Kd(n,e),t:0,seconds:r}:null,this.#l(i?this.#r.at(0):e)}subscribe=e=>(this.#i.add(e),()=>this.#i.delete(e));#l(e){this.frame=e,this.frameId++;for(let e of this.#i)e()}reset(e){this.sim=sf(this.model,this.ev,{...this.#e,seed:e??this.#e.seed}),this.#n.clear(),this.#s=0,this.#r&&this.scene&&(this.#r=null,this.#l(this.scene))}bind(e,t){let n=t!==this.canvas;if(this.svg=e,this.canvas=t,this.#t=[],e){for(let t of e.querySelectorAll(`rect[data-slot]`))this.#t.push({el:t,stage:t.dataset.stage,index:Number(t.dataset.slot),y:Number(t.dataset.y),s:Number(t.dataset.s)});n&&this.resize(),this.drawFills(),this.applyCamera()}}readColors(e){let t=getComputedStyle(e);for(let e of ff)this.colors[e]=t.getPropertyValue(`--lm-${e}`).trim()}flowColor(e){let t=this.view.def.flows[e]?.color??`accent`;return this.colors[t]||t}outcomeColor(e){return e===`dropped`||e===`rejected`?this.colors.drop||`#b7392e`:e===`superseded`||e===`unread`?this.colors.muted||`#5d6d7c`:this.colors.ok||`#2a7f5a`}resize(){let e=this.canvas;if(!e||!this.scene)return;let t=e.getBoundingClientRect();if(!t.width)return;let n=Math.min(2,globalThis.devicePixelRatio||1),r=Math.round(t.width*n),i=Math.round(t.height*n);(e.width!==r||e.height!==i)&&(e.width=r,e.height=i,this.draw())}step(e,t={}){this.#a=this.paused,this.sim.step(e,t),e>0&&(this.#s+=e);let n=this.#r;n&&e>0&&(n.t+=e/n.seconds,n.t>=1&&(this.#r=null),this.#l(n.at(n.t))),this.#c&&this.#f(e)}get playing(){return!!this.#c&&this.#c.shot!==`back`}playStory(e){return!this.frame||!this.model.story[e]?!1:(this.#c={i:e-1,shot:`establish`,t:0,from:bu(this.frame),close:bu(this.frame),zoom:!1,targets:[],components:[],before:this.ev,waiting:!1},this.#h(null),this.host?.playing(!0),!0)}stopStory(e={}){let t=this.#c;t&&(this.cue=null,this.host?.cue(null),t.shot!==`back`&&this.host?.playing(!1),e.cut||!this.camera||this.reducedMotion?(this.#c=null,this.#h(null)):this.#c={...t,shot:`back`,t:0,from:this.camera})}#u(){return!!this.scene&&this.scene.key===this.wantKey&&this.drawnValues===JSON.stringify(this.ev.values)}#d(e){return e.shot===`change`?_u(this.transition):e.shot===`wide`?this.model.story[e.i]?.seconds??0:gu[e.shot]}get story(){let e=this.#c;return e&&{i:e.i,shot:e.shot,t:e.t}}#f(e){let t=this.#c,n=this.frame;if(!n)return;if(t.waiting){if(!this.#u())return;t.waiting=!1}for(t.t+=e;this.#c===t&&t.t>=this.#d(t)&&!t.waiting;)t.t-=this.#d(t),this.#p(t);if(this.#c!==t)return;let r=this.#d(t)>0?t.t/this.#d(t):1,i=this.reducedMotion,a=bu(n),o;o=t.shot===`in`?i?t.close:Du(a,t.close,r):t.shot===`close`?t.close:t.shot===`change`?t.zoom?Tu(n,t.targets,{hold:!0}):a:t.shot===`out`||t.shot===`back`?i?a:Du(t.from,a,r):a,this.#h(o)}#p(e){let t=this.frame,n=this.model.story;if(e.shot===`back`)this.#c=null,this.#h(null);else if(e.shot===`establish`||e.shot===`wide`){if(e.i+1>=n.length){this.#c=null,this.#h(null),this.cue=null,this.host?.cue(null),this.host?.playing(!1);return}let r=e.i+1,i=n[r],a=this.model.evaluate(i.values),o=this.host,s=o?Su(t,this.ev,a,{a:o.shapes(this.ev),b:o.shapes(a)},i.focus):[],c=t.nodes.filter(e=>s.includes(e.id)),l=[...new Set(c.map(e=>xu(a,e)).filter(e=>e!=null))],u=Tu(t,s),d=u.w<t.width-1e-6;Object.assign(e,{i:r,shot:`in`,from:bu(t),close:u,zoom:d,targets:s,components:l,before:this.ev}),this.#m({step:r,title:Au(this.model,this.ev.values,i,r),detail:ju(this.ev,null,l),after:!1,top:u.y+u.h/2>t.height*.55})}else e.shot===`in`?e.shot=`close`:e.shot===`close`?(e.shot=`change`,e.waiting=!0,this.host?.show(e.i),this.#m({...this.cue,detail:ju(e.before,this.ev,e.components),after:!0})):e.shot===`change`?(e.shot=`out`,e.from=this.camera??bu(t)):e.shot===`out`&&(e.shot=`wide`)}#m(e){this.cue=e,this.host?.cue(e)}#h(e){let t=this.frame,n=t&&e&&Math.abs(e.x)<1e-6&&Math.abs(e.y)<1e-6&&Math.abs(e.w-t.width)<1e-6;this.camera=!e||n?null:e,this.applyCamera()}applyCamera(){let e=this.frame;if(!this.svg||!e)return;let t=this.camera??bu(e),n=`${t.x} ${t.y} ${t.w} ${t.h}`;this.svg.getAttribute(`viewBox`)!==n&&this.svg.setAttribute(`viewBox`,n)}draw(e={}){this.drawFills();let t=this.canvas,n=t?.getContext(`2d`);t&&n&&this.frame&&(n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),e.particles!==!1&&this.paintParticles(n,t.width/this.frame.width))}drawFills(){let e=this.ev.firstLimit,t=!this.reducedMotion&&(this.playing||e?.state===`warn`||e?.state===`over`),n=t?.5-.5*Math.cos(2*Math.PI*this.#s/mf):.5;for(let e of this.svg?.querySelectorAll(`g[data-halo]`)??[]){let[r,i]=[Number(e.dataset.cx),Number(e.dataset.cy)],a=1+.035*n;hf(e,`transform`,t?`translate(${r} ${i}) scale(${a.toFixed(4)}) translate(${-r} ${-i})`:``);let o=e.querySelector(`[data-glow]`);o&&hf(o,`stroke-opacity`,(.1+.25*n).toFixed(3))}for(let e of this.#t){let t=this.sim.slotBusy(e.stage,e.index),n=t<.02?0:(e.s-2)*t;e.el.setAttribute(`y`,(e.y+e.s-1-n).toFixed(2)),e.el.setAttribute(`height`,n.toFixed(2))}}dots(){let e=this.frame;if(!e)return[];let t=[],n=new Set;for(let r of this.sim.particles){n.add(r.id);let[i,a]=this.#g(e,r),o=r.to.cell!=null&&r.phase!==`move`,s=r.outcome===`delivered`||r.outcome===`answered`;t.push({x:i,y:a-(r.phase===`fade`&&!s?r.t/r.dur*8:0),r:o?3:3.4,color:r.phase===`fade`?this.outcomeColor(r.outcome):this.flowColor(r.flow),alpha:r.phase===`fade`?Math.max(0,1-r.t/r.dur):1,...r.attempt?{ring:pf}:{}})}for(let e of this.#n.keys())n.has(e)||this.#n.delete(e);return t}paintParticles(e,t){let n=this.frame;if(!n)return;let r=this.camera??bu(n),[i,a]=[n.width*t,n.height*t],o=Math.min(i/r.w,a/r.h);e.save(),e.transform(o,0,0,o,(i-r.w*o)/2-r.x*o,(a-r.h*o)/2-r.y*o);for(let t of this.dots())e.globalAlpha=t.alpha,e.beginPath(),t.ring?(e.strokeStyle=t.color,e.lineWidth=t.ring,e.arc(t.x,t.y,t.r-t.ring/2,0,Math.PI*2),e.stroke()):(e.fillStyle=t.color,e.arc(t.x,t.y,t.r,0,Math.PI*2),e.fill());e.restore()}#g(e,t){if(t.phase!==`move`)return De(e,t.to,t.flow);let n=`${t.leg}|${t.from.stage}|${t.from.cell}|${t.to.stage}|${t.to.cell}`;if(this.#r){let r=this.#o;r.frame!==this.frameId&&(r.frame=this.frameId,r.paths.clear());let i=`${t.flow}|${n}`,a=r.paths.get(i);return a||(a=Oe(e,t.from,t.to,t.flow),r.paths.set(i,a)),ke(a,t.t/t.dur)}let r=this.#n.get(t.id);return r&&r.key===n||(r={key:n,points:Oe(e,t.from,t.to,t.flow)},this.#n.set(t.id,r)),ke(r.points,t.t/t.dur)}};function _f(e,t,n={}){let r=()=>({...e.defaults(),...n.initial}),[i,a]=(0,J.useState)(()=>({model:e,values:r()})),o=(0,J.useRef)(null),s=i.values;i.model!==e&&(s=r(),o.current=null,a({model:e,values:s}));let c=!o.current||o.current.values===s,l=(0,J.useMemo)(()=>o.current?.values===s?o.current.ev:e.evaluate(s),[e,s]),u=(0,J.useRef)(null);u.current&&u.current.model===e&&u.current.view===t||(u.current=new gf(e,t,l,n));let d=u.current;d.transition=n.transition??.8;let[f,p]=(0,J.useState)(null),m=n.direction??`RIGHT`,[h,g]=(0,J.useState)(m),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(null),x=y?.view===t?y.scene:null,S=vf(`(prefers-reduced-motion: reduce)`);d.reducedMotion=S;let C=n.narrowBelow??640;(0,J.useEffect)(()=>{o.current&&o.current.values!==s||d.setEvaluation(l)},[d,l,s]),(0,J.useEffect)(()=>{if(!f)return;v(()=>yf(getComputedStyle(f).fontFamily));let e=new ResizeObserver(([e])=>{let t=e?.contentRect.width??f.clientWidth;g(t>0&&t<C?`DOWN`:m)});return e.observe(f),()=>e.disconnect()},[f,C,m]);let w=(0,J.useMemo)(()=>_?nt(t,l,{direction:h,measure:_}):``,[t,l,h,_]);c&&(d.wantKey=w);let T=n.elk;(0,J.useEffect)(()=>{if(!_||!w)return;let e=!0;return tt(t,d.ev,{direction:h,measure:_,elk:T??cd()}).then(n=>{e&&b({view:t,scene:n})},e=>console.error(`loadmap: layout failed`,e)),()=>{e=!1}},[w,t,d,h,_,T]);let E=(0,J.useMemo)(()=>et(t,l),[t,l]),D=(0,J.useRef)(s);c&&(D.current=s);let O=(0,J.useCallback)(t=>{let n={...D.current,...t};D.current=n;let r=e.evaluate(n);o.current={values:n,ev:r},d.setEvaluation(r),a({model:e,values:n})},[d,e]),[ee,k]=(0,J.useState)({engine:d,on:!1,cue:null}),A=ee.engine===d&&ee.on,te=ee.engine===d?ee.cue:null,ne=(0,J.useCallback)(()=>d.stopStory(),[d]),re=(0,J.useCallback)(e=>{ne(),O(e)},[ne,O]),ie=(0,J.useMemo)(()=>e.scenarioOf(s),[e,s]),ae=(0,J.useCallback)(t=>{let n=e.scenarios.find(e=>e.label===t);n&&re(n.values)},[e,re]),[j,oe]=(0,J.useState)({model:e,i:null}),se=j.model===e&&j.i!=null&&j.i<e.story.length?j.i:null,ce=(0,J.useCallback)(t=>{let n=t==null?void 0:e.story[t];n&&O(n.values),d.wantFocus=n?.focus??null,d.storyStep=n?t:null,oe({model:e,i:n?t:null})},[e,O,d]),le=(0,J.useCallback)(e=>{ne(),ce(e)},[ne,ce]),ue=se==null?void 0:e.story[se],de=!!ue&&Object.entries(ue.values).some(([e,t])=>s[e]!==t),fe=ue&&!de?ue.focus??null:null;d.wantFocus=fe,d.storyStep=se;let pe=(0,J.useRef)(_);pe.current=_,d.host={playing:e=>k(t=>({engine:d,on:e,cue:e&&t.engine===d?t.cue:null})),show:ce,cue:e=>k(t=>({engine:d,on:t.engine===d&&t.on,cue:e})),shapes:e=>rt(t,e,{direction:h,measure:pe.current??void 0})},(0,J.useEffect)(()=>{A&&de&&ne()},[A,de,ne]);let me=A&&e.story.length>0,he=(0,J.useCallback)(t=>{if(!t)return ne();let n=e.story.length-1;if(n<0)return;let r=se==null||se===n?0:de?se:se+1;de&&ce(null),d.playStory(r),!document.fullscreenElement&&!f?.hasAttribute(`data-full`)&&f?.querySelector(`.lm-board`)?.scrollIntoView({block:`nearest`})},[se,de,e,d,ne,ce,f]),[M,N]=(0,J.useState)(!1),[ge,_e]=(0,J.useState)(!1),ve=M||ge;(0,J.useEffect)(()=>{let e=()=>N(!!f&&document.fullscreenElement===f);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[f]);let ye=n.fullScreenMode??`panels`,[be,xe]=(0,J.useState)({start:ye,mode:ye}),Se=be.start===ye?be.mode:ye,Ce=(0,J.useCallback)(e=>xe({start:ye,mode:e}),[ye]);(0,J.useEffect)(()=>{if(!f||!ve)return;f.setAttribute(`data-full`,ge?`overlay`:`screen`);let e=ge&&typeof f.showPopover==`function`;return e&&(f.popover=`manual`,f.showPopover()),()=>{f.removeAttribute(`data-full`),e&&(f.hidePopover(),f.removeAttribute(`popover`))}},[f,ve,ge]),(0,J.useEffect)(()=>{if(f&&ve)return f.setAttribute(`data-mode`,Se),()=>f.removeAttribute(`data-mode`)},[f,ve,Se]),(0,J.useEffect)(()=>{if(!ge)return;let e=e=>e.key===`Escape`&&_e(!1);return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[ge]);let we=(0,J.useCallback)(()=>{f&&(ge?_e(!1):document.fullscreenElement?document.exitFullscreen().catch(()=>{}):f.requestFullscreen?f.requestFullscreen().catch(()=>_e(!0)):_e(!0))},[f,ge]);return{model:e,view:t,values:s,setValues:re,scenario:ie,setScenario:ae,step:se,stepChanged:de,setStep:le,focus:fe,storyPlaying:me,setStoryPlaying:he,cue:me?te:null,fullScreen:ve,toggleFullScreen:we,fullScreenMode:Se,setFullScreenMode:Ce,ev:l,scene:x,labels:E,direction:h,reducedMotion:S,engine:d,rootRef:p,root:f}}function vf(e){let[t,n]=(0,J.useState)(()=>typeof matchMedia==`function`&&matchMedia(e).matches);return(0,J.useEffect)(()=>{if(typeof matchMedia!=`function`)return;let t=matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function yf(e){let t=document.createElement(`canvas`).getContext(`2d`);return t?(n,r,i=400)=>(t.font=`${i} ${r}px ${e}`,Math.ceil(t.measureText(n).width)):(e,t)=>e.length*t*.6}function bf(){if(typeof document>`u`)return null;let e=document.documentElement,t=e.dataset.theme;return t===`dark`||t===`light`?t:e.classList.contains(`dark`)?`dark`:e.classList.contains(`light`)?`light`:null}var xf=new Set,Sf=null;function Cf(e){return xf.add(e),!Sf&&typeof MutationObserver<`u`&&(Sf=new MutationObserver(()=>{for(let e of xf)e()}),Sf.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`,`class`]})),()=>{xf.delete(e),xf.size||(Sf?.disconnect(),Sf=null)}}var wf=()=>()=>{};function Tf(e=`auto`){let t=(0,J.useSyncExternalStore)(e===`inherit`?Cf:wf,bf,()=>null);return e===`inherit`?t??`auto`:e}function Ef({lm:e,theme:t=`auto`,children:n}){(0,J.useEffect)(()=>Nd(),[]);let r=Tf(t);return(0,J.useEffect)(()=>{if(!e.root)return;e.engine.readColors(e.root);let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>e.root&&e.engine.readColors(e.root);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e.root,e.engine,r]),(0,Y.jsx)(`div`,{className:`lm`,"data-theme":r===`auto`?void 0:r,ref:e.rootRef,children:n})}var Df=[`verdict`,`live`,`limits`,`controls`,`headroom`,`compare`,`assumptions`];function Of({model:e,view:t,theme:n,title:r,assumptions:i,headroom:a=!0,compare:o=!0,fullScreen:s=Df,onNodeClick:c,selected:l,ref:u,...d}){let f=_f(e,t,d);(0,J.useImperativeHandle)(u,()=>kf(f),[f]);let p=o&&e.scenarios.length>1,m=[];a&&m.push(`headroom`),p&&m.push(`compare`);let h=(...e)=>e.some(e=>s.includes(e))?void 0:``,g=e=>s.includes(e)&&(e===`headroom`?a:e!==`compare`||p),_=f.fullScreen,v=_&&f.fullScreenMode===`focus`,[y,b]=(0,J.useState)(null);y&&!_&&b(null);let x=(0,J.useRef)(null);(0,J.useEffect)(()=>{y&&x.current?.focus()},[y]);let S=(e,t)=>b({panel:e,from:t}),C=()=>{y?.from.focus(),b(null)};(0,J.useEffect)(()=>{if(!y)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),y.from.focus(),b(null))};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[y]);let w=(...e)=>y&&e.includes(y.panel)?``:void 0,T=(e,t)=>(0,Y.jsx)(`div`,{className:`lm-panel`,"data-panel":e,"data-out":h(e),"data-drawn":w(e),children:(!_||y?.panel===e)&&t}),E=r!==!1&&(0,Y.jsx)(`h2`,{children:r??e.title}),D=g(`verdict`),O=v?D||g(`controls`):D||g(`assumptions`);return(0,Y.jsxs)(Ef,{lm:f,theme:n,children:[_?(0,Y.jsxs)(`div`,{className:`lm-head`,children:[E,(0,Y.jsx)(Bu,{lm:f})]}):(0,Y.jsxs)(Y.Fragment,{children:[E,(0,Y.jsx)(Bu,{lm:f})]}),(0,Y.jsx)(kd,{lm:f}),(0,Y.jsx)(Z,{lm:f,onNodeClick:c,selected:l}),_&&O&&(0,Y.jsxs)(`div`,{className:`lm-line`,"data-tier":f.ev.verdict.tier,children:[(0,Y.jsx)(xd,{lm:f,verdict:D,extra:i?.length,open:S,assumptions:!v&&g(`assumptions`)}),v&&g(`controls`)&&(0,Y.jsx)(md,{lm:f})]}),_&&!v&&(0,Y.jsx)(Cd,{lm:f,panels:Df.filter(g),open:S}),(0,Y.jsxs)(`div`,{className:`lm-side lm-drawer`,"data-out":h(`verdict`,`live`,`limits`,`controls`,...m,`assumptions`),"data-drawer":y?.panel,...y&&{role:`dialog`,"aria-label":`The whole panel`},children:[y&&(0,Y.jsx)(`div`,{className:`lm-drawer-bar`,"data-drawn":``,children:(0,Y.jsx)(`button`,{type:`button`,className:`lm-btn`,onClick:C,ref:x,children:`✕ Back to full screen`})}),T(`verdict`,(0,Y.jsx)(ud,{lm:f})),m.length>0&&(0,Y.jsxs)(`div`,{className:m.length>1?`lm-charts lm-strip`:`lm-charts`,"data-out":h(...m),"data-drawn":w(...m),children:[a&&T(`headroom`,(0,Y.jsx)(qu,{lm:f})),p&&T(`compare`,(0,Y.jsx)(Hu,{lm:f}))]}),(0,Y.jsxs)(`div`,{className:`lm-strip lm-live`,"data-out":h(`live`,`limits`,`controls`),"data-drawn":w(`live`,`limits`,`controls`),children:[(0,Y.jsxs)(`div`,{className:`lm-card`,"data-out":h(`live`,`limits`),"data-drawn":w(`live`,`limits`),children:[T(`live`,(0,Y.jsx)(pd,{lm:f})),T(`limits`,(0,Y.jsx)(fd,{lm:f}))]}),T(`controls`,(0,Y.jsx)(hd,{lm:f}))]}),T(`assumptions`,(0,Y.jsx)(gd,{lm:f,extra:i}))]})]})}function kf(e){let{engine:t}=e;return{engine:t,async ready(e=1e4){let n=performance.now(),r=()=>t.scene&&t.scene.key===t.wantKey&&t.svg&&t.drawnValues===JSON.stringify(t.ev.values)&&t.drawnFocus===t.wantFocus&&t.drawnFrame===t.frameId;for(;!r();){if(performance.now()-n>e)throw Error(`loadmap: layout not ready`);await new Promise(e=>requestAnimationFrame(e))}},pause:()=>{t.paused=!0},resume:()=>{t.paused=!1},values:()=>t.ev.values,setValues:t=>e.setValues(t),setStoryStep:t=>e.setStep(t),storyStep:()=>t.storyStep,playStory:()=>{if(!t.playStory(0))throw Error(`loadmap: the story cannot play: nothing is drawn yet, or there is none`);return yu(t.model.story,t.transition)},reset:e=>t.reset(e),step:e=>{t.step(e,{particles:!0}),t.draw({particles:!0})},board:()=>t.svg&&t.canvas&&t.frame?{svg:t.svg,canvas:t.canvas,scene:t.frame}:null}}var Af=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,k=ee.port2;ee.port1.onmessage=D,O=function(){k.postMessage(null)}}else O=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),jf=t(((e,t)=>{t.exports=Af()})),Mf=t((e=>{var t=hu();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),Nf=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Mf()})),Pf=t((e=>{var t=jf(),n=hu(),r=Nf();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),k=Symbol.for(`react.profiler`),A=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),j=Symbol.for(`react.lazy`),oe=Symbol.for(`react.activity`),se=Symbol.for(`react.legacy_hidden`),ce=Symbol.for(`react.memo_cache_sentinel`),le=Symbol.for(`react.view_transition`),ue=Symbol.for(`react.recoverable`),de=Symbol.iterator;function fe(e){return typeof e!=`object`||!e?null:(e=de&&e[de]||e[`@@iterator`],typeof e==`function`?e:null)}var pe=Symbol.for(`react.client.reference`);function me(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case k:return`Profiler`;case ee:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case oe:return`Activity`;case le:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case te:return e.displayName||`Context`;case A:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?me(e.type)||`Memo`:t;case j:t=e._payload,e=e._init;try{return me(e(t))}catch{}}return null}var he=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function ye(e){return{current:e}}function be(e){0>ve||(e.current=_e[ve],_e[ve]=null,ve--)}function xe(e,t){ve++,_e[ve]=e.current,e.current=t}var Se=ye(null),Ce=ye(null),we=ye(null),Te=ye(null);function Ee(e,t){switch(xe(we,t),xe(Ce,e),xe(Se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}be(Se),xe(Se,e)}function De(){be(Se),be(Ce),be(we)}function Oe(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,xe(Te,e)),t=Se.current;var n=dp(t,e.type);t!==n&&(xe(Ce,e),xe(Se,n))}function ke(e){Ce.current===e&&(be(Se),be(Ce)),Te.current===e&&(be(Te),sh._currentValue=ge)}var Ae,je;function Me(e){if(Ae===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ae=t&&t[1]||``,je=-1<e.stack.indexOf(`
|
|
292
|
+
`;function Vd(e=document){if(e.getElementById(`loadmap-css`))return;let t=e.createElement(`style`);t.id=`loadmap-css`,t.textContent=Bd,e.head.appendChild(t)}var Hd=[0,.3],Ud=[.15,.8],Wd=[.6,1],Gd=[.7,1],Kd=24,qd=(e,[t,n])=>Math.min(1,Math.max(0,(e-t)/(n-t))),Jd=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Yd=(e,t,n)=>e+(t-e)*n,Xd=(e,t,n)=>({...t,x:Yd(e.x,t.x,n),y:Yd(e.y,t.y,n),w:Yd(e.w,t.w,n),h:Yd(e.h,t.h,n)}),Zd=(e,t,n)=>({...t,x:Yd(e.x,t.x,n),y:Yd(e.y,t.y,n)}),Qd=(e,t)=>e.fade==null?{}:{fade:Yd(e.fade,1,t.enter)},$d=(e,t)=>({...e,fade:(e.fade??1)*t.out});function ef(e,t){let n=new Map(e.nodes.map(e=>[e.id,e])),r=new Set(t.nodes.map(e=>e.id)),i=new Map(e.edges.map(e=>[e.id,e])),a=new Set(t.edges.map(e=>e.id)),o=new Map;for(let e of t.edges){let t=i.get(e.id)?.points;t?.length&&e.points.length&&o.set(e.id,nf(t,e.points)?[t,e.points]:[af(t,Kd),af(e.points,Kd)])}return s=>{if(s>=1)return t;let c=Jd(qd(s,Ud)),l={out:1-qd(s,Hd),enter:qd(s,Wd)},u=qd(s,Gd),d=t.edges.map(e=>{let t=i.get(e.id),n=o.get(e.id);if(!t||!n)return{...e,fade:l.enter,draw:u};let[r,a]=n,s=r.map((e,t)=>[Yd(e[0],a[t][0],c),Yd(e[1],a[t][1],c)]),d=e.label&&(t.label?Xd(t.label,e.label,c):e.label);return{...e,points:s,label:d,...Qd(t,l),...t.draw==null?{}:{draw:Yd(t.draw,1,u)}}});for(let t of e.edges)a.has(t.id)||d.push($d(t,l));let f=t.nodes.map(e=>{let t=n.get(e.id);return t?tf(t,e,c,l):{...e,fade:l.enter}});for(let t of e.nodes)r.has(t.id)||f.push($d(t,l));return{...t,width:Yd(e.width,t.width,c),height:Yd(e.height,t.height,c),nodes:f,edges:d}}}function tf(e,t,n,r){let i=t.members.map((t,i)=>{let a=e.members[i];return a?{...Xd(a,t,n),spot:Zd(a.spot,t.spot,n),...Qd(a,r)}:{...t,fade:r.enter}});for(let n of e.members.slice(t.members.length))i.push($d(n,r));let a=e=>{let t=new Map;return e.map(e=>{let n=`${e.flow}|${e.text}`,r=t.get(n)??0;return t.set(n,r+1),`${n}|${r}`})},o=a(e.groups),s=new Map(e.groups.map((e,t)=>[o[t],e])),c=a(t.groups),l=t.groups.map((e,t)=>{let i=s.get(c[t]);return i?{...e,spot:Zd(i.spot,e.spot,n),...Qd(i,r)}:{...e,fade:r.enter}}),u=new Set(c);e.groups.forEach((e,t)=>{u.has(o[t])||l.push($d(e,r))});let d=e=>`${e.stage}/${e.flow}/${e.index}`,f=new Map(e.cells.map(e=>[d(e),e])),p=new Set(t.cells.map(d)),m=t.cells.map(e=>{let t=f.get(d(e));return t?{...Xd(t,e,n),...Qd(t,r)}:{...e,fade:r.enter}});for(let t of e.cells)p.has(d(t))||m.push($d(t,r));let h=new Map(e.slots.map(e=>[e.index,e])),g=new Set(t.slots.map(e=>e.index)),_=t.slots.map(e=>{let t=h.get(e.index);return t?{...Xd(t,e,n),...Qd(t,r)}:{...e,fade:r.enter}});for(let t of e.slots)g.has(t.index)||_.push($d(t,r));return{...Xd(e,t,n),...Qd(e,r),title:Zd(e.title,t.title,n),sub:t.sub&&(e.sub?Zd(e.sub,t.sub,n):t.sub),members:i,groups:l,cells:m,slots:_}}function nf(e,t){return e.length===t.length&&e.every((n,r)=>r===0||rf(e[r-1],n)===rf(t[r-1],t[r]))}var rf=(e,t)=>Math.abs(t[0]-e[0])>=Math.abs(t[1]-e[1])?`h`:`v`;function af(e,t){if(e.length<2)return Array.from({length:t},()=>e[0]??[0,0]);let n=[0];for(let t=1;t<e.length;t++)n.push(n[t-1]+Math.hypot(e[t][0]-e[t-1][0],e[t][1]-e[t-1][1]));let r=n.at(-1),i=[],a=1;for(let o=0;o<t;o++){let s=r*o/(t-1);for(;a<n.length-1&&n[a]<s;)a++;let c=n[a]-n[a-1],l=c>0?(s-n[a-1])/c:1,u=e[a-1],d=e[a];i.push([Yd(u[0],d[0],l),Yd(u[1],d[1],l)])}return i}function of(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var sf=.7;function cf(e,t,n,r=1){let i=e*t,a=Array(i),o=of(r);for(let r=0;r<e;r++){let i=Array.from({length:t},(e,t)=>t);for(let e=t-1;e>0;e--){let t=Math.floor(o()*(e+1));[i[e],i[t]]=[i[t],i[e]]}i.forEach((i,o)=>{a[r*t+i]=n===`round-robin`?o*e+r:r*t+o})}let s=Array.from({length:i},()=>.92+o()*.16),c=s.reduce((e,t)=>e+t,0)/(i||1);return{rank:a,jitter:s.map(e=>e/c)}}function lf(e,t,n){let r=t.rank.length,i=Math.min(1,Math.max(0,n))*r,a=t.rank[e],o;if(i<=sf*r){let e=Math.floor(i/sf);o=a<e?sf:a===e?i-e*sf:0}else o=sf+(i-sf*r)/r;return Math.min(1,Math.max(0,o*(t.jitter[e]??1)))}var uf=()=>({backlog:0,lag:0,arriving:0,served:0,dropped:0,merged:0,merging:!1}),df=1,ff=2e3,pf=3,mf=class{speed;time=0;particles=[];dotScale=1;#e;#t;#n;#r;#i=``;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=new Map;#d=new Map;#f=1;constructor(e,t,n={}){this.#e={seed:1,speed:10,dotTarget:28,minDots:1,maxDots:40,legSeconds:.45,maxParticles:800,...n},this.speed=this.#e.speed,this.#t=of(this.#e.seed),this.#n=e,this.update(t);for(let e of Object.values(t.stages))e.kind===`workers`&&this.#o.set(e.id,this.#m(e.id))}update(e){this.#r=e;let t=JSON.stringify(Object.values(e.stages).map(e=>e.kind===`queue`?[e.id,e.partitions]:e.kind===`workers`?[e.id,e.pods,e.perPod,e.fill]:[e.id,e.kind]));if(t!==this.#i){this.#i=t;let n=(t,n)=>{if(t.stage==null)return!0;let r=e.stages[t.stage];return r?t.cell==null?!0:r.kind===`queue`?t.cell<(r.partitions[n]??0):r.kind===`workers`&&t.cell<r.pods*r.perPod:!1};this.particles=this.particles.filter(e=>n(e.from,e.flow)&&n(e.to,e.flow)),this.#s.clear()}let n=this.#n.thresholds.full,r=Object.values(e.stages);this.#c.clear();for(let e of r)this.#c.set(e.id,`shed`in e?e.shed:0);this.#l.clear();for(let t of this.#n.flowIds){let n=e.flows[t]??0;for(let r of e.routes[t]??[]){this.#l.set(`${r}/${t}`,n);let i=e.stages[r];i.kind!==`fanout`&&(n*=1-(this.#c.get(r)??0)),i.kind===`cache`&&(n*=1-i.hit)}}this.#u.clear();let i=new Map;for(let t of r){let r=t.component?e.components[t.component]:void 0,a=1/0;if(r&&r.util!=null&&r.full!=null&&Number.isFinite(r.full)){if(r.full>0){let n=i.get(r.full);n||(n=this.#n.evaluate({...e.values,load:r.full}),i.set(r.full,n)),a=this.#n.flowIds.reduce((e,r)=>e+(n.at[t.id]?.[r]??0),0)}else{let i=this.#n.flowIds.reduce((n,r)=>n+(e.at[t.id]?.[r]??0),0);a=r.util>0?i*n/r.util:0}}this.#u.set(t.id,a)}let a=this.#n.flowIds.reduce((t,n)=>t+(e.flows[n]??0),0);this.dotScale=Math.max(1,m(a/this.#e.dotTarget))}step(e,t={}){if(!(e>0))return;let n=e*this.speed;this.time+=n,this.#g(n),t.particles!==!1&&(this.#_(e),this.#y(e))}queue(e,t){return this.#a.get(e)?.get(t)?.s??uf()}busy(e){return this.#o.get(e)??this.#m(e)}shed(e){return this.#c.get(e)??0}slotBusy(e,t){let n=this.#r.stages[e];if(n?.kind!==`workers`||t>=n.running*n.perPod)return 0;let r=`${e}/${n.running}`,i=this.#s.get(r);return i||(i=cf(n.running,n.perPod,n.fill,this.#e.seed),this.#s.set(r,i)),lf(t,i,this.busy(e))}arriving(e){return this.#n.flowIds.reduce((t,n)=>t+(this.#l.get(`${e}/${n}`)??0),0)}running(e){let t=this.#r.stages[e];return t?.kind===`workers`?t.running:0}#p(e){return this.#r.components[e]?.util??null}#m(e){let t=this.#r.stages[e],n=t?.component?this.#p(t.component):null;return Math.min(1,(n??0)/this.#n.thresholds.full*this.#h(e))}#h(e){let t=this.#r.stages[e];return t?.kind===`workers`&&t.running>0?t.pods/t.running:1}#g(e){let t=this.#r,n=[];for(let r of Object.values(t.stages)){if(r.kind!==`queue`)continue;let i=this.#a.get(r.id)??new Map;this.#a.set(r.id,i);for(let a of this.#n.flowIds){let o=t.routes[a]??[];if(!o.includes(r.id))continue;let s=i.get(a)??{cohorts:[],s:uf()};i.set(a,s);let c=this.#l.get(`${r.id}/${a}`)??0,l=Math.min(.95,Math.max(0,t.overload[a]?.merge?.share??0));s.s.merging=l>0&&gf(s.cohorts)>c*1;let u=c*e,d=s.cohorts.at(-1);d&&this.time-d.t<df?d.n+=u:u>0&&s.cohorts.push({t:this.time,n:u}),s.cohorts.length>ff&&(s.cohorts=vf(s.cohorts));let f=o[o.indexOf(r.id)+1]??`∞`,p=s.s.merging?1/(1-l):1;n.push({q:r.id,f:a,fq:s,drainer:f,prio:this.#n.def.flows[a]?.priority??1,k:p})}}let r=new Map;for(let t of new Set(n.map(e=>e.drainer))){let i=n.filter(e=>e.drainer===t),a=t===`∞`?1/0:(this.#u.get(t)??1/0)*e;for(let n of[...new Set(i.map(e=>e.prio))].sort((e,t)=>e-t)){let o=i.filter(e=>e.prio===n),s=o.reduce((e,t)=>e+gf(t.fq.cohorts)/t.k,0),c=0;for(let t of o){let n=gf(t.fq.cohorts),r=Number.isFinite(a)?s>0?Math.min(n,a*n/s):0:n,i=r/t.k;_f(t.fq.cohorts,r),c+=i,t.fq.s.served=yf(t.fq.s.served,i/e,e),t.fq.s.merged=yf(t.fq.s.merged,(r-i)/e,e)}a=Math.max(0,a-c),r.set(t,(r.get(t)??0)+c)}}for(let{q:r,f:i,fq:a}of n){let n=0,o=t.overload[i]?.drop;if(o)for(;a.cohorts.length&&this.time-a.cohorts[0].t>o.olderThan;)n+=a.cohorts.shift().n;let s=this.#l.get(`${r}/${i}`)??0;gf(a.cohorts)<1e-9*Math.max(1,s)&&(a.cohorts=[]),a.s.backlog=gf(a.cohorts),a.s.lag=a.cohorts.length?this.time-a.cohorts[0].t:0,a.s.arriving=yf(a.s.arriving,s,e),a.s.dropped=yf(a.s.dropped,n/e,e)}for(let n of Object.values(t.stages)){if(n.kind!==`workers`)continue;let t=this.#u.get(n.id)??1/0,i=r.has(n.id)&&Number.isFinite(t)&&t>0?r.get(n.id)/(t*e)*this.#h(n.id):this.#m(n.id);this.#o.set(n.id,yf(this.#o.get(n.id)??i,Math.min(1,i),e))}}#_(e){let{minDots:t,maxDots:n,legSeconds:r,maxParticles:i}=this.#e;for(let a of this.#n.flowIds){let o=this.#r.retry[a]?.rate??this.#r.flows[a]??0;if(o<=0)continue;let s=Math.min(n,Math.max(t,o/this.dotScale)),c=(this.#d.get(a)??0)+s*e;for(;c>=1;){if(--c,this.particles.length>=i)continue;let e=this.#r.routes[a][0];this.particles.push({id:this.#f++,flow:a,leg:0,phase:`move`,t:0,dur:r,from:{stage:null},to:this.#b(e,a)})}this.#d.set(a,c)}}#v(e){let t=this.#r.retry[e.flow],n=(e.attempt??0)+1;return!t||n>t.times||this.#t()>=t.retried?null:{id:this.#f++,flow:e.flow,leg:0,phase:`move`,t:0,dur:this.#e.legSeconds,from:{stage:null},to:this.#b(this.#r.routes[e.flow][0],e.flow),attempt:n}}#y(e){let t=this.#r,n=(e,t,n)=>{e.phase=`fade`,e.outcome=t,e.t=0,e.dur=n,e.from=e.to},r=e=>{let r=t.routes[e.flow];if(e.leg+1>=r.length)return n(e,`delivered`,.35);e.leg++,e.phase=`move`,e.t=0,e.dur=this.#e.legSeconds,e.from=e.to,e.to=this.#b(r[e.leg],e.flow)},i=[],a=e=>{n(e,`rejected`,.6);let t=this.particles.length+i.length<this.#e.maxParticles?this.#v(e):null;t&&i.push(t)};for(let o of this.particles){if(o.t+=e,o.t<o.dur)continue;if(o.phase===`move`&&o.back){n(o,`answered`,.35);continue}let s=t.stages[o.to.stage??``];if(o.phase===`fade`||!s)o.phase=`fade`,o.outcome??=`delivered`;else if(o.phase===`move`&&o.branch)n(o,this.#t()<this.shed(o.from.stage??``)||s.kind===`pass`&&this.#t()<this.shed(s.id)?`rejected`:`delivered`,.35);else if(o.phase===`move`&&s.kind===`fanout`){let e=0;for(let t of s.to[o.flow]??[]){let n=Math.floor(t.share)+ +(this.#t()<t.share%1);for(let r=0;r<n;r++,e++)this.particles.length+i.length<this.#e.maxParticles&&i.push({id:this.#f++,flow:o.flow,leg:o.leg,phase:`move`,t:0,dur:this.#e.legSeconds,from:o.to,to:{stage:t.stage},branch:t.stage})}e?n(o,`delivered`,0):n(o,`unread`,.6)}else if(o.phase===`move`){if((s.kind===`pass`||s.kind===`limit`||s.kind===`cache`)&&this.#t()<this.shed(s.id))a(o);else if(s.kind===`cache`&&this.#t()<s.hit){let e=o.from;o.from=o.to,o.to=e,o.t=0,o.dur=this.#e.legSeconds,o.back=!0}else if(s.kind===`queue`){let e=this.queue(s.id,o.flow).lag;o.phase=`hold`,o.t=0,o.dur=.12+Math.min(e,120)/120*2.6}else s.kind===`workers`?(o.phase=`hold`,o.t=0,o.dur=.15):r(o)}else if(o.phase===`hold`){let e=s.kind===`queue`?this.queue(s.id,o.flow):null,i=e&&e.arriving>0?Math.min(1,e.dropped/e.arriving):0,a=e?.merging?t.overload[o.flow]?.merge?.share??0:0;this.#t()<a?n(o,`superseded`,.6):this.#t()<i?n(o,`dropped`,.6):r(o)}}this.particles=this.particles.filter(e=>!(e.phase===`fade`&&e.t>=e.dur)).concat(i)}#b(e,t){let n=this.#r.stages[e];if(n?.kind===`queue`){let r=n.partitions[t]??0;return r>0?{stage:e,cell:Math.floor(this.#t()*r)}:{stage:e}}return n?.kind===`workers`?{stage:e,cell:this.#x(n.id,n.running*n.perPod)}:{stage:e}}#x(e,t){let n=0;for(let r=0;r<t;r++)n+=this.slotBusy(e,r);if(n<=.001)return Math.floor(this.#t()*t);let r=this.#t()*n;for(let n=0;n<t;n++)if(r-=this.slotBusy(e,n),r<=0)return n;return t-1}};function hf(e,t,n){return new mf(e,t,n)}var gf=e=>e.reduce((e,t)=>e+t.n,0);function _f(e,t){let n=t;for(;n>0&&e.length;){let t=e[0];t.n<=n?(n-=t.n,e.shift()):(t.n-=n,n=0)}}function vf(e){let t=[];for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];t.push(i?{t:r.t,n:r.n+i.n}:r)}return t}function yf(e,t,n){return e+(t-e)*Math.min(1,n/pf)}var bf=[`accent`,`alt`,`ok`,`warn`,`drop`,`muted`,`fg`,`surface`,`line`],xf=1.4,Sf=2.5,Cf=2.4;function wf(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Tf(e,t){t>=1?e.removeAttribute(`opacity`):wf(e,`opacity`,t.toFixed(3))}var Ef=class{model;view;sim;ev;scene=null;frame=null;frameId=0;drawnFrame=-1;transition=.8;wantKey=``;drawnValues=``;wantFocus=null;storyStep=null;drawnFocus=null;paused=!1;reducedMotion=!1;camera=null;cue=null;host=null;colors={};svg=null;canvas=null;#e;#t=[];#n=new Map;#r=null;#i=new Set;#a=!1;#o={frame:-1,paths:new Map};#s=0;#c=null;#l=null;constructor(e,t,n,r={}){this.model=e,this.view=t,this.ev=n,this.#e=r,this.sim=hf(e,n,r)}setEvaluation(e){if(e===this.ev)return;let t=JSON.stringify(e.values)===JSON.stringify(this.ev.values),n=this.ev.firstLimit?.id,r=e.firstLimit?.id;if(this.ev=e,t||this.sim.update(e),n===r)return;let i=this.#c?.shot===`change`,a=this.paused&&!this.#a;this.#d(n&&r&&this.frame&&!a?{from:n,to:r,t:0,fade:this.#l?.to===n?this.#u(this.#l,!1):1,...i?{out:.5,in:.6,inAt:1/0}:{out:.3,in:.3,inAt:this.reducedMotion?0:.3},story:i}:null)}#u(e,t){let n=(e,t)=>this.reducedMotion?+(e>=0):Nu(Math.max(0,Math.min(1,e/t)));return t?e.fade*(1-n(e.t,e.out)):n(e.t-e.inAt,e.in)}get handover(){return this.#l}#d(e){if(e!==this.#l){this.#l=e;for(let e of this.#i)e()}}setScene(e,t={}){if(e===this.scene)return;let n=this.frame,r=this.transition;this.scene=e,this.#n.clear();let i=n&&!t.cut&&r>0&&Number.isFinite(r)&&(!this.paused||this.#a)&&n.direction===e.direction&&n.key!==e.key;this.#r=i?{at:ef(n,e),t:0,seconds:r}:null,this.#f(i?this.#r.at(0):e)}subscribe=e=>(this.#i.add(e),()=>this.#i.delete(e));#f(e){this.frame=e,this.frameId++;for(let e of this.#i)e()}reset(e){this.sim=hf(this.model,this.ev,{...this.#e,seed:e??this.#e.seed}),this.#n.clear(),this.#s=0,this.#d(null),this.#r&&this.scene&&(this.#r=null,this.#f(this.scene))}bind(e,t){let n=t!==this.canvas;if(this.svg=e,this.canvas=t,this.#t=[],e){for(let t of e.querySelectorAll(`rect[data-slot]`))this.#t.push({el:t,stage:t.dataset.stage,index:Number(t.dataset.slot),y:Number(t.dataset.y),s:Number(t.dataset.s)});n&&this.resize(),this.drawFills(),this.applyCamera()}}readColors(e){let t=getComputedStyle(e);for(let e of bf)this.colors[e]=t.getPropertyValue(`--lm-${e}`).trim()}flowColor(e){let t=this.view.def.flows[e]?.color??`accent`;return this.colors[t]||t}outcomeColor(e){return e===`dropped`||e===`rejected`?this.colors.drop||`#b7392e`:e===`superseded`||e===`unread`?this.colors.muted||`#5d6d7c`:this.colors.ok||`#2a7f5a`}resize(){let e=this.canvas;if(!e||!this.scene)return;let t=e.getBoundingClientRect();if(!t.width)return;let n=Math.min(2,globalThis.devicePixelRatio||1),r=Math.round(t.width*n),i=Math.round(t.height*n);(e.width!==r||e.height!==i)&&(e.width=r,e.height=i,this.draw())}step(e,t={}){this.#a=this.paused,this.sim.step(e,t),e>0&&(this.#s+=e);let n=this.#l;n&&e>0&&this.#p()&&(n.t+=e,!n.story&&n.t>=Sf&&this.#d(null));let r=this.#r;r&&e>0&&(r.t+=e/r.seconds,r.t>=1&&(this.#r=null),this.#f(r.at(r.t))),this.#c&&this.#h(e)}get playing(){return!!this.#c&&this.#c.shot!==`back`}playStory(e){return!this.frame||!this.model.story[e]?!1:(this.#c={i:e-1,shot:`establish`,t:0,from:Du(this.frame),close:Du(this.frame),zoom:!1,targets:[],components:[],before:this.ev,waiting:!1,hand:null},this.#y(null),this.host?.playing(!0),!0)}stopStory(e={}){let t=this.#c;t&&(this.cue=null,this.host?.cue(null),this.#l?.story&&this.#d(null),t.shot!==`back`&&this.host?.playing(!1),e.cut||!this.camera||this.reducedMotion?(this.#c=null,this.#y(null)):this.#c={...t,shot:`back`,t:0,from:this.camera})}#p(){return!!this.scene&&this.scene.key===this.wantKey&&this.drawnValues===JSON.stringify(this.ev.values)}#m(e){return e.shot===`change`?wu(this.transition):e.shot===`hand`?Cu.hand:e.shot===`wide`?this.model.story[e.i]?.seconds??0:Cu[e.shot]}get story(){let e=this.#c;return e&&{i:e.i,shot:e.shot,t:e.t}}#h(e){let t=this.#c,n=this.frame;if(!n)return;if(t.waiting){if(!this.#p())return;t.waiting=!1}for(t.t+=e;this.#c===t&&t.t>=this.#m(t)&&!t.waiting;)t.t-=this.#m(t),this.#_(t);if(this.#c!==t)return;let r=this.#m(t)>0?t.t/this.#m(t):1,i=this.reducedMotion,a=Du(n),o;if(t.shot===`in`)o=i?t.close:Pu(a,t.close,r);else if(t.shot===`close`)o=t.close;else if(t.shot===`change`)o=t.zoom?Mu(n,t.targets,{hold:!0}):a;else if(t.shot===`hand`){let e=Mu(n,this.#g(t.hand?.to));o=i?e:Pu(t.from,e,t.t/1)}else o=t.shot===`out`||t.shot===`back`?i?a:Pu(t.from,a,r):a;this.#y(o);let s=this.#l;t.hand&&s?.story&&(i||s.t>=s.out)&&this.cue&&this.cue.detail!==t.hand.text&&this.#v({...this.cue,detail:t.hand.text})}#g(e){return(this.frame?.nodes??[]).filter(t=>e&&Ou(this.ev,t)===e).map(e=>e.id)}#_(e){let t=this.frame,n=this.model.story;if(e.shot===`back`)this.#c=null,this.#y(null);else if(e.shot===`establish`||e.shot===`wide`){if(this.#l?.story&&this.#d(null),e.i+1>=n.length){this.#c=null,this.#y(null),this.cue=null,this.host?.cue(null),this.host?.playing(!1);return}let r=e.i+1,i=n[r],a=this.model.evaluate(i.values),o=this.host,s=o?ku(t,this.ev,a,{a:o.shapes(this.ev),b:o.shapes(a)},i.focus):[],c=t.nodes.filter(e=>s.includes(e.id)),l=[...new Set(c.map(e=>Ou(a,e)).filter(e=>e!=null))],u=Mu(t,s),d=u.w<t.width-1e-6,f=Su(this.ev,a,this.model),p=f?{text:f,to:a.firstLimit.id}:null;Object.assign(e,{i:r,shot:`in`,from:Du(t),close:u,zoom:d,targets:s,components:l,before:this.ev,hand:p}),this.#v({step:r,title:Lu(this.model,this.ev.values,i,r),detail:Ru(this.ev,null,l),after:!1,top:u.y+u.h/2>t.height*.55,seconds:Tu(i,this.transition,!!p)})}else if(e.shot===`in`)e.shot=`close`;else if(e.shot===`close`)e.shot=`change`,e.waiting=!0,this.host?.show(e.i),this.#v({...this.cue,detail:Ru(e.before,this.ev,e.components),after:!0});else if(e.shot===`change`&&e.hand){e.shot=`hand`,e.from=this.camera??Du(t);let n=e.from,r=this.#g(e.hand.to),i=t.nodes.filter(e=>r.includes(e.id)).every(e=>e.x>=n.x&&e.y>=n.y&&e.x+e.w<=n.x+n.w&&e.y+e.h<=n.y+n.h);this.#l?.story&&(this.#l.inAt=this.#l.t+(this.reducedMotion||i?0:1))}else if(e.shot===`change`||e.shot===`hand`){e.shot=`out`,e.from=this.camera??Du(t);let n=this.#l;n?.story&&!Number.isFinite(n.inAt)&&(n.inAt=n.t)}else e.shot===`out`&&(e.shot=`wide`)}#v(e){this.cue=e,this.host?.cue(e)}#y(e){let t=this.frame,n=t&&e&&Math.abs(e.x)<1e-6&&Math.abs(e.y)<1e-6&&Math.abs(e.w-t.width)<1e-6;this.camera=!e||n?null:e,this.applyCamera()}applyCamera(){let e=this.frame;if(!this.svg||!e)return;let t=this.camera??Du(e),n=`${t.x} ${t.y} ${t.w} ${t.h}`;this.svg.getAttribute(`viewBox`)!==n&&this.svg.setAttribute(`viewBox`,n)}draw(e={}){this.drawFills();let t=this.canvas,n=t?.getContext(`2d`);t&&n&&this.frame&&(n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),e.particles!==!1&&this.paintParticles(n,t.width/this.frame.width))}drawFills(){this.drawHalos();for(let e of this.#t){let t=this.sim.slotBusy(e.stage,e.index),n=t<.02?0:(e.s-2)*t;e.el.setAttribute(`y`,(e.y+e.s-1-n).toFixed(2)),e.el.setAttribute(`height`,n.toFixed(2))}}drawHalos(){let e=this.ev.firstLimit,t=!this.reducedMotion&&(this.playing||e?.state===`warn`||e?.state===`over`),n=t?.5-.5*Math.cos(2*Math.PI*this.#s/Cf):.5,r=this.#l;for(let e of this.svg?.querySelectorAll(`g[data-halo]`)??[]){let i=e.dataset.halo===`was`,a=!i&&r?.to===e.dataset.component,o=i?r?this.#u(r,!0):0:a?this.#u(r,!1):1;Tf(e,Number(e.dataset.fade??1)*o);let s=e.querySelector(`[data-ring]`);if(!s)continue;let[c,l]=[Number(s.dataset.cx),Number(s.dataset.cy)],u=i?1:(1+.08*(1-o))*(t?1+.035*n:1);wf(s,`transform`,u===1?``:`translate(${c} ${l}) scale(${u.toFixed(4)}) translate(${-c} ${-l})`);let d=s.querySelector(`[data-glow]`);d&&wf(d,`stroke-opacity`,(.1+.25*n).toFixed(3))}if(!r)return;let i=(e,t)=>this.reducedMotion?+(e>=0):Nu(Math.max(0,Math.min(1,e/t)));for(let e of this.svg?.querySelectorAll(`g[data-badge][data-was] [data-show]`)??[])Tf(e,i(r.t,r.out)*(r.story?1:1-i(r.t-2.1,.4)))}dots(){let e=this.frame;if(!e)return[];let t=[],n=new Set;for(let r of this.sim.particles){n.add(r.id);let[i,a]=this.#b(e,r),o=r.to.cell!=null&&r.phase!==`move`,s=r.outcome===`delivered`||r.outcome===`answered`;t.push({x:i,y:a-(r.phase===`fade`&&!s?r.t/r.dur*8:0),r:o?3:3.4,color:r.phase===`fade`?this.outcomeColor(r.outcome):this.flowColor(r.flow),alpha:r.phase===`fade`?Math.max(0,1-r.t/r.dur):1,...r.attempt?{ring:xf}:{}})}for(let e of this.#n.keys())n.has(e)||this.#n.delete(e);return t}paintParticles(e,t){let n=this.frame;if(!n)return;let r=this.camera??Du(n),[i,a]=[n.width*t,n.height*t],o=Math.min(i/r.w,a/r.h);e.save(),e.transform(o,0,0,o,(i-r.w*o)/2-r.x*o,(a-r.h*o)/2-r.y*o);for(let t of this.dots())e.globalAlpha=t.alpha,e.beginPath(),t.ring?(e.strokeStyle=t.color,e.lineWidth=t.ring,e.arc(t.x,t.y,t.r-t.ring/2,0,Math.PI*2),e.stroke()):(e.fillStyle=t.color,e.arc(t.x,t.y,t.r,0,Math.PI*2),e.fill());e.restore()}#b(e,t){if(t.phase!==`move`)return De(e,t.to,t.flow);let n=`${t.leg}|${t.from.stage}|${t.from.cell}|${t.to.stage}|${t.to.cell}`;if(this.#r){let r=this.#o;r.frame!==this.frameId&&(r.frame=this.frameId,r.paths.clear());let i=`${t.flow}|${n}`,a=r.paths.get(i);return a||(a=Oe(e,t.from,t.to,t.flow),r.paths.set(i,a)),ke(a,t.t/t.dur)}let r=this.#n.get(t.id);return r&&r.key===n||(r={key:n,points:Oe(e,t.from,t.to,t.flow)},this.#n.set(t.id,r)),ke(r.points,t.t/t.dur)}};function Df(e,t,n={}){let r=()=>({...e.defaults(),...n.initial}),[i,a]=(0,J.useState)(()=>({model:e,values:r()})),o=(0,J.useRef)(null),s=i.values;i.model!==e&&(s=r(),o.current=null,a({model:e,values:s}));let c=!o.current||o.current.values===s,l=(0,J.useMemo)(()=>o.current?.values===s?o.current.ev:e.evaluate(s),[e,s]),u=(0,J.useRef)(null);u.current&&u.current.model===e&&u.current.view===t||(u.current=new Ef(e,t,l,n));let d=u.current;d.transition=n.transition??.8;let[f,p]=(0,J.useState)(null),m=n.direction??`RIGHT`,[h,g]=(0,J.useState)(m),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(null),x=y?.view===t?y.scene:null,S=Of(`(prefers-reduced-motion: reduce)`);d.reducedMotion=S;let C=n.narrowBelow??640;(0,J.useEffect)(()=>{o.current&&o.current.values!==s||d.setEvaluation(l)},[d,l,s]),(0,J.useEffect)(()=>{if(!f)return;v(()=>kf(getComputedStyle(f).fontFamily));let e=new ResizeObserver(([e])=>{let t=e?.contentRect.width??f.clientWidth;g(t>0&&t<C?`DOWN`:m)});return e.observe(f),()=>e.disconnect()},[f,C,m]);let w=(0,J.useMemo)(()=>_?nt(t,l,{direction:h,measure:_}):``,[t,l,h,_]);c&&(d.wantKey=w);let T=n.elk;(0,J.useEffect)(()=>{if(!_||!w)return;let e=!0;return tt(t,d.ev,{direction:h,measure:_,elk:T??gd()}).then(n=>{e&&b({view:t,scene:n})},e=>console.error(`loadmap: layout failed`,e)),()=>{e=!1}},[w,t,d,h,_,T]);let E=(0,J.useMemo)(()=>et(t,l),[t,l]),D=(0,J.useRef)(s);c&&(D.current=s);let O=(0,J.useCallback)(t=>{let n={...D.current,...t};D.current=n;let r=e.evaluate(n);o.current={values:n,ev:r},d.setEvaluation(r),a({model:e,values:n})},[d,e]),[ee,k]=(0,J.useState)({engine:d,on:!1,cue:null}),A=ee.engine===d&&ee.on,te=ee.engine===d?ee.cue:null,ne=(0,J.useCallback)(()=>d.stopStory(),[d]),re=(0,J.useCallback)(e=>{ne(),O(e)},[ne,O]),ie=(0,J.useMemo)(()=>e.scenarioOf(s),[e,s]),ae=(0,J.useCallback)(t=>{let n=e.scenarios.find(e=>e.label===t);n&&re(n.values)},[e,re]),[j,oe]=(0,J.useState)({model:e,i:null}),se=j.model===e&&j.i!=null&&j.i<e.story.length?j.i:null,ce=(0,J.useCallback)(t=>{let n=t==null?void 0:e.story[t];n&&O(n.values),d.wantFocus=n?.focus??null,d.storyStep=n?t:null,oe({model:e,i:n?t:null})},[e,O,d]),le=(0,J.useCallback)(e=>{ne(),ce(e)},[ne,ce]),ue=se==null?void 0:e.story[se],de=!!ue&&Object.entries(ue.values).some(([e,t])=>s[e]!==t),fe=ue&&!de?ue.focus??null:null;d.wantFocus=fe,d.storyStep=se;let pe=(0,J.useRef)(_);pe.current=_,d.host={playing:e=>k(t=>({engine:d,on:e,cue:e&&t.engine===d?t.cue:null})),show:ce,cue:e=>k(t=>({engine:d,on:t.engine===d&&t.on,cue:e})),shapes:e=>rt(t,e,{direction:h,measure:pe.current??void 0})},(0,J.useEffect)(()=>{A&&de&&ne()},[A,de,ne]);let me=A&&e.story.length>0,he=(0,J.useCallback)(t=>{if(!t)return ne();let n=e.story.length-1;if(n<0)return;let r=se==null||se===n?0:de?se:se+1;de&&ce(null),d.playStory(r),!document.fullscreenElement&&!f?.hasAttribute(`data-full`)&&f?.querySelector(`.lm-board`)?.scrollIntoView({block:`nearest`})},[se,de,e,d,ne,ce,f]),[M,N]=(0,J.useState)(!1),[ge,_e]=(0,J.useState)(!1),ve=!!n.fill,ye=ve||M||ge;(0,J.useEffect)(()=>{let e=()=>N(!!f&&document.fullscreenElement===f);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[f]);let be=n.fullScreenMode??`panels`,[xe,Se]=(0,J.useState)({start:be,mode:be}),Ce=xe.start===be?xe.mode:be,we=(0,J.useCallback)(e=>Se({start:be,mode:e}),[be]);(0,J.useEffect)(()=>{if(!f||!ye||ve)return;f.setAttribute(`data-full`,ge?`overlay`:`screen`);let e=ge&&typeof f.showPopover==`function`;return e&&(f.popover=`manual`,f.showPopover()),()=>{f.removeAttribute(`data-full`),e&&(f.hidePopover(),f.removeAttribute(`popover`))}},[f,ye,ge,ve]),(0,J.useEffect)(()=>{if(f&&ye&&!ve)return f.setAttribute(`data-mode`,Ce),()=>f.removeAttribute(`data-mode`)},[f,ye,Ce,ve]),(0,J.useEffect)(()=>{if(!ge)return;let e=e=>e.key===`Escape`&&_e(!1);return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[ge]);let Te=(0,J.useCallback)(()=>{f&&!ve&&(ge?_e(!1):document.fullscreenElement?document.exitFullscreen().catch(()=>{}):f.requestFullscreen?f.requestFullscreen().catch(()=>_e(!0)):_e(!0))},[f,ge,ve]);return{model:e,view:t,values:s,setValues:re,scenario:ie,setScenario:ae,step:se,stepChanged:de,setStep:le,focus:fe,storyPlaying:me,setStoryPlaying:he,cue:me?te:null,fullScreen:ye,fill:ve,toggleFullScreen:Te,fullScreenMode:Ce,setFullScreenMode:we,ev:l,scene:x,labels:E,direction:h,reducedMotion:S,engine:d,rootRef:p,root:f}}function Of(e){let[t,n]=(0,J.useState)(()=>typeof matchMedia==`function`&&matchMedia(e).matches);return(0,J.useEffect)(()=>{if(typeof matchMedia!=`function`)return;let t=matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function kf(e){let t=document.createElement(`canvas`).getContext(`2d`);return t?(n,r,i=400)=>(t.font=`${i} ${r}px ${e}`,Math.ceil(t.measureText(n).width)):(e,t)=>e.length*t*.6}function Af(){if(typeof document>`u`)return null;let e=document.documentElement,t=e.dataset.theme;return t===`dark`||t===`light`?t:e.classList.contains(`dark`)?`dark`:e.classList.contains(`light`)?`light`:null}var jf=new Set,Mf=null;function Nf(e){return jf.add(e),!Mf&&typeof MutationObserver<`u`&&(Mf=new MutationObserver(()=>{for(let e of jf)e()}),Mf.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`,`class`]})),()=>{jf.delete(e),jf.size||(Mf?.disconnect(),Mf=null)}}var Pf=()=>()=>{};function Ff(e=`auto`){let t=(0,J.useSyncExternalStore)(e===`inherit`?Nf:Pf,Af,()=>null);return e===`inherit`?t??`auto`:e}function If({lm:e,theme:t=`auto`,children:n}){(0,J.useEffect)(()=>Vd(),[]);let r=Ff(t);return(0,J.useEffect)(()=>{if(!e.root)return;e.engine.readColors(e.root);let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>e.root&&e.engine.readColors(e.root);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e.root,e.engine,r]),(0,Y.jsx)(`div`,{className:`lm`,"data-theme":r===`auto`?void 0:r,"data-full":e.fill?`fill`:void 0,"data-mode":e.fill?e.fullScreenMode:void 0,ref:e.rootRef,children:n})}var Lf=[`verdict`,`live`,`limits`,`controls`,`headroom`,`compare`,`assumptions`];function Rf({model:e,view:t,theme:n,title:r,assumptions:i,headroom:a=!0,compare:o=!0,fullScreen:s=Lf,onNodeClick:c,selected:l,ref:u,...d}){let f=Df(e,t,d);(0,J.useImperativeHandle)(u,()=>$(f),[f]);let p=o&&e.scenarios.length>1,m=[];a&&m.push(`headroom`),p&&m.push(`compare`);let h=(...e)=>e.some(e=>s.includes(e))?void 0:``,g=e=>s.includes(e)&&(e===`headroom`?a:e!==`compare`||p),_=f.fullScreen,v=_&&f.fullScreenMode===`focus`,[y,b]=(0,J.useState)(null);y&&!_&&b(null);let x=(0,J.useRef)(null);(0,J.useEffect)(()=>{y&&x.current?.focus()},[y]);let S=(e,t)=>b({panel:e,from:t}),C=()=>{y?.from.focus(),b(null)};(0,J.useEffect)(()=>{if(!y)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),y.from.focus(),b(null))};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[y]);let w=(...e)=>y&&e.includes(y.panel)?``:void 0,T=(e,t)=>(0,Y.jsx)(`div`,{className:`lm-panel`,"data-panel":e,"data-out":h(e),"data-drawn":w(e),children:(!_||y?.panel===e)&&t}),E=r!==!1&&(0,Y.jsx)(`h2`,{children:r??e.title}),D=g(`verdict`),O=v?D||g(`controls`):D||g(`assumptions`);return(0,Y.jsxs)(If,{lm:f,theme:n,children:[_?(0,Y.jsxs)(`div`,{className:`lm-head`,children:[E,(0,Y.jsx)(qu,{lm:f})]}):(0,Y.jsxs)(Y.Fragment,{children:[E,(0,Y.jsx)(qu,{lm:f})]}),(0,Y.jsx)(Ld,{lm:f}),(0,Y.jsx)(ed,{lm:f,onNodeClick:c,selected:l}),_&&O&&(0,Y.jsxs)(`div`,{className:`lm-line`,"data-tier":f.ev.verdict.tier,children:[(0,Y.jsx)(kd,{lm:f,verdict:D,extra:i?.length,open:S,assumptions:!v&&g(`assumptions`)}),v&&g(`controls`)&&(0,Y.jsx)(Sd,{lm:f})]}),_&&!v&&(0,Y.jsx)(jd,{lm:f,panels:Lf.filter(g),open:S}),(0,Y.jsxs)(`div`,{className:`lm-side lm-drawer`,"data-out":h(`verdict`,`live`,`limits`,`controls`,...m,`assumptions`),"data-drawer":y?.panel,...y&&{role:`dialog`,"aria-label":`The whole panel`},children:[y&&(0,Y.jsx)(`div`,{className:`lm-drawer-bar`,"data-drawn":``,children:(0,Y.jsx)(`button`,{type:`button`,className:`lm-btn`,onClick:C,ref:x,children:`✕ Back to full screen`})}),T(`verdict`,(0,Y.jsx)(vd,{lm:f})),m.length>0&&(0,Y.jsxs)(`div`,{className:m.length>1?`lm-charts lm-strip`:`lm-charts`,"data-out":h(...m),"data-drawn":w(...m),children:[a&&T(`headroom`,(0,Y.jsx)(Zu,{lm:f})),p&&T(`compare`,(0,Y.jsx)(Ju,{lm:f}))]}),(0,Y.jsxs)(`div`,{className:`lm-strip lm-live`,"data-out":h(`live`,`limits`,`controls`),"data-drawn":w(`live`,`limits`,`controls`),children:[(0,Y.jsxs)(`div`,{className:`lm-card`,"data-out":h(`live`,`limits`),"data-drawn":w(`live`,`limits`),children:[T(`live`,(0,Y.jsx)(xd,{lm:f})),T(`limits`,(0,Y.jsx)(bd,{lm:f}))]}),T(`controls`,(0,Y.jsx)(Cd,{lm:f}))]}),T(`assumptions`,(0,Y.jsx)(wd,{lm:f,extra:i}))]})]})}function $(e){let{engine:t}=e;return{engine:t,async ready(e=1e4){let n=performance.now(),r=()=>t.scene&&t.scene.key===t.wantKey&&t.svg&&t.drawnValues===JSON.stringify(t.ev.values)&&t.drawnFocus===t.wantFocus&&t.drawnFrame===t.frameId;for(;!r();){if(performance.now()-n>e)throw Error(`loadmap: layout not ready`);await new Promise(e=>requestAnimationFrame(e))}},pause:()=>{t.paused=!0},resume:()=>{t.paused=!1},values:()=>t.ev.values,setValues:t=>e.setValues(t),setStoryStep:t=>e.setStep(t),storyStep:()=>t.storyStep,playStory:()=>{let e=t.ev;if(!t.playStory(0))throw Error(`loadmap: the story cannot play: nothing is drawn yet, or there is none`);return Eu(t.model,e,t.transition)},reset:e=>t.reset(e),step:e=>{t.step(e,{particles:!0}),t.draw({particles:!0})},board:()=>t.svg&&t.canvas&&t.frame?{svg:t.svg,canvas:t.canvas,scene:t.frame}:null}}var zf=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,k=ee.port2;ee.port1.onmessage=D,O=function(){k.postMessage(null)}}else O=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Bf=t(((e,t)=>{t.exports=zf()})),Vf=t((e=>{var t=hu();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),Hf=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Vf()})),Uf=t((e=>{var t=Bf(),n=hu(),r=Hf();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),k=Symbol.for(`react.profiler`),A=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),j=Symbol.for(`react.lazy`),oe=Symbol.for(`react.activity`),se=Symbol.for(`react.legacy_hidden`),ce=Symbol.for(`react.memo_cache_sentinel`),le=Symbol.for(`react.view_transition`),ue=Symbol.for(`react.recoverable`),de=Symbol.iterator;function fe(e){return typeof e!=`object`||!e?null:(e=de&&e[de]||e[`@@iterator`],typeof e==`function`?e:null)}var pe=Symbol.for(`react.client.reference`);function me(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case k:return`Profiler`;case ee:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case oe:return`Activity`;case le:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case te:return e.displayName||`Context`;case A:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?me(e.type)||`Memo`:t;case j:t=e._payload,e=e._init;try{return me(e(t))}catch{}}return null}var he=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function ye(e){return{current:e}}function be(e){0>ve||(e.current=_e[ve],_e[ve]=null,ve--)}function xe(e,t){ve++,_e[ve]=e.current,e.current=t}var Se=ye(null),Ce=ye(null),we=ye(null),Te=ye(null);function Ee(e,t){switch(xe(we,t),xe(Ce,e),xe(Se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}be(Se),xe(Se,e)}function De(){be(Se),be(Ce),be(we)}function Oe(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,xe(Te,e)),t=Se.current;var n=dp(t,e.type);t!==n&&(xe(Ce,e),xe(Se,n))}function ke(e){Ce.current===e&&(be(Se),be(Ce)),Te.current===e&&(be(Te),sh._currentValue=ge)}var Ae,je;function Me(e){if(Ae===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ae=t&&t[1]||``,je=-1<e.stack.indexOf(`
|
|
292
293
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
293
294
|
`+Ae+e+je}var Ne=!1;function Pe(e,t){if(!e||Ne)return``;Ne=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
294
295
|
`),l=s.split(`
|
|
295
296
|
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
296
297
|
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ne=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Me(n):``}function Fe(e,t){switch(e.tag){case 26:case 27:case 5:return Me(e.type);case 16:return Me(`Lazy`);case 13:return e.child!==t&&t!==null?Me(`Suspense Fallback`):Me(`Suspense`);case 19:return Me(`SuspenseList`);case 0:case 15:return Pe(e.type,!1);case 11:return Pe(e.type.render,!1);case 1:return Pe(e.type,!0);case 31:return Me(`Activity`);case 30:return Me(`ViewTransition`);default:return``}}function Ie(e){try{var t=``,n=null;do t+=Fe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
297
298
|
Error generating stack: `+e.message+`
|
|
298
|
-
`+e.stack}}var Le=Object.prototype.hasOwnProperty,Re=t.unstable_scheduleCallback,ze=t.unstable_cancelCallback,Be=t.unstable_shouldYield,Ve=t.unstable_requestPaint,He=t.unstable_now,Ue=t.unstable_getCurrentPriorityLevel,We=t.unstable_ImmediatePriority,Ge=t.unstable_UserBlockingPriority,Ke=t.unstable_NormalPriority,qe=t.unstable_LowPriority,Je=t.unstable_IdlePriority,Ye=t.log,Xe=t.unstable_setDisableYieldValue,Ze=null,Qe=null;function $e(e){if(typeof Ye==`function`&&Xe(e),Qe&&typeof Qe.setStrictMode==`function`)try{Qe.setStrictMode(Ze,e)}catch{}}var et=Math.clz32?Math.clz32:rt,tt=Math.log,nt=Math.LN2;function rt(e){return e>>>=0,e===0?32:31-(tt(e)/nt|0)|0}var it=256,at=262144,ot=4194304;function st(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ct(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=st(n))):i=st(o):i=st(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=st(n))):i=st(o)):i=st(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function lt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ut(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-et(n),i=1<<r;t|=e[r],n&=~i}return t}function dt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ft(){var e=ot;return ot<<=1,!(ot&62914560)&&(ot=4194304),e}function pt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function mt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ht(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-et(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&>(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function gt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-et(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function _t(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-et(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function vt(e,t){var n=t&-t;return n=n&42?1:yt(n),(n&(e.suspendedLanes|t))===0?n:0}function yt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function bt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function xt(){var e=N.p;return e===0?(e=window.event,e===void 0?32:Ch(e.type)):e}function St(e,t){var n=N.p;try{return N.p=e,t()}finally{N.p=n}}var Ct=Math.random().toString(36).slice(2),wt=`__reactFiber$`+Ct,Tt=`__reactProps$`+Ct,Et=`__reactContainer$`+Ct,Dt=`__reactEvents$`+Ct,Ot=`__reactListeners$`+Ct,kt=`__reactHandles$`+Ct,At=`__reactResources$`+Ct,jt=`__reactMarker$`+Ct,Mt=`__reactLoad$`+Ct;function Nt(e){delete e[wt],delete e[Tt],delete e[Ot],delete e[kt]}function Pt(e){var t;if(t=e[wt])return t;for(var n=e.parentNode;n;){if(t=n[Et]||n[wt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=fm(e);e!==null;){if(n=e[wt])return n;e=fm(e)}return t}e=n,n=e.parentNode}return null}function Ft(e){if(e=e[wt]||e[Et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function It(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Lt(e){var t=e[At];return t||=e[At]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Rt(e){e[jt]=!0}function zt(e){e[Mt]=void 0}var Bt=new Set,Vt={};function Ht(e,t){Ut(e,t),Ut(e+`Capture`,t)}function Ut(e,t){for(Vt[e]=t,e=0;e<t.length;e++)Bt.add(t[e])}var Wt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Gt={},Kt={};function qt(e){return Le.call(Kt,e)?!0:Le.call(Gt,e)?!1:Wt.test(e)?Kt[e]=!0:(Gt[e]=!0,!1)}var P=!1;function Jt(){var e=P;return P=!1,e}function Yt(e,t,n){if(qt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Xt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function Zt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function Qt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function $t(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function en(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function tn(e){if(!e._valueTracker){var t=$t(e)?`checked`:`value`;e._valueTracker=en(e,t,``+e[t])}}function nn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=$t(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var rn=/[\n"\\]/g;function an(e){return e.replace(rn,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function on(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Qt(t)):e.value!==``+Qt(t)&&(e.value=``+Qt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):cn(e,Qt(n)):o===`number`&&e.value==t?cn(e,Qt(e.value)):cn(e,Qt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Qt(s):e.removeAttribute(`name`)}function sn(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){tn(e);return}n=n==null?``:``+Qt(n),t=t==null?n:``+Qt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),tn(e)}function cn(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function ln(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Qt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function un(e,t,n){t!=null&&(t=``+Qt(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+Qt(n)}function dn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(he(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Qt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),tn(e)}function fn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function mn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||pn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function hn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,P=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(mn(e,a,r),P=!0)}else for(var o in t)t.hasOwnProperty(o)&&mn(e,o,t[o])}function gn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var _n=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),vn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function yn(e){return vn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function bn(){}var xn=null;function Sn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Cn=null,wn=null;function Tn(e){var t=Ft(e);if(t&&(e=t.stateNode)){var n=e[Tt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(on(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+an(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Tt]||null;if(!a)throw Error(i(90));on(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&nn(r)}break a;case`textarea`:un(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&ln(e,!!n.multiple,t,!1)}}}var F=!1;function En(e,t,n){if(F)return e(t,n);F=!0;try{return e(t)}finally{if(F=!1,(Cn!==null||wn!==null)&&(Fd(),Cn&&(t=Cn,e=wn,wn=Cn=null,Tn(t),e)))for(t=0;t<e.length;t++)Tn(e[t])}}function Dn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Tt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var On=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,kn=!1;if(On)try{var An={};Object.defineProperty(An,"passive",{get:function(){kn=!0}}),window.addEventListener(`test`,An,An),window.removeEventListener(`test`,An,An)}catch{kn=!1}var jn=null,Mn=null,Nn=null;function Pn(){if(Nn)return Nn;var e,t=Mn,n=t.length,r,i=`value`in jn?jn.value:jn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Nn=i.slice(e,1<r?1-r:void 0)}function Fn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function In(){return!0}function Ln(){return!1}function Rn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?In:Ln,this.isPropagationStopped=Ln,this}return w(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=In)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=In)},persist:function(){},isPersistent:In}),t}var zn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bn=Rn(zn),I=w({},zn,{view:0,detail:0}),Vn=Rn(I),Hn,Un,Wn,Gn=w({},I,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nr,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Wn&&(Wn&&e.type===`mousemove`?(Hn=e.screenX-Wn.screenX,Un=e.screenY-Wn.screenY):Un=Hn=0,Wn=e),Hn)},movementY:function(e){return`movementY`in e?e.movementY:Un}}),Kn=Rn(Gn),qn=Rn(w({},Gn,{dataTransfer:0})),Jn=Rn(w({},I,{relatedTarget:0})),Yn=Rn(w({},zn,{animationName:0,elapsedTime:0,pseudoElement:0})),Xn=Rn(w({},zn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Zn=Rn(w({},zn,{data:0})),Qn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},$n={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},er={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function tr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=er[e])?!!t[e]:!1}function nr(){return tr}var rr=Rn(w({},I,{key:function(e){if(e.key){var t=Qn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Fn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?$n[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nr,charCode:function(e){return e.type===`keypress`?Fn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Fn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),ir=Rn(w({},Gn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),ar=Rn(w({},zn,{submitter:0})),or=Rn(w({},I,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nr})),sr=Rn(w({},zn,{propertyName:0,elapsedTime:0,pseudoElement:0})),cr=Rn(w({},Gn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),lr=Rn(w({},zn,{newState:0,oldState:0,source:0})),ur=[9,13,27,32],dr=On&&`CompositionEvent`in window,fr=null;On&&`documentMode`in document&&(fr=document.documentMode);var pr=On&&`TextEvent`in window&&!fr,mr=On&&(!dr||fr&&8<fr&&11>=fr),hr=` `,gr=!1;function _r(e,t){switch(e){case`keyup`:return ur.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function vr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var yr=!1;function br(e,t){switch(e){case`compositionend`:return vr(t);case`keypress`:return t.which===32?(gr=!0,hr):null;case`textInput`:return e=t.data,e===hr&&gr?null:e;default:return null}}function xr(e,t){if(yr)return e===`compositionend`||!dr&&_r(e,t)?(e=Pn(),Nn=Mn=jn=null,yr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return mr&&t.locale!==`ko`?null:t.data;default:return null}}var Sr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Cr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Sr[e.type]:t===`textarea`}function wr(e,t,n,r){Cn?wn?wn.push(r):wn=[r]:Cn=r,t=qf(t,`onChange`),0<t.length&&(n=new Bn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Tr=null,Er=null;function Dr(e){Bf(e,0)}function Or(e){if(nn(It(e)))return e}function kr(e,t){if(e===`change`)return t}var Ar=!1;if(On){var jr;if(On){var Mr=`oninput`in document;if(!Mr){var Nr=document.createElement(`div`);Nr.setAttribute(`oninput`,`return;`),Mr=typeof Nr.oninput==`function`}jr=Mr}else jr=!1;Ar=jr&&(!document.documentMode||9<document.documentMode)}function Pr(){Tr&&(Tr.detachEvent(`onpropertychange`,Fr),Er=Tr=null)}function Fr(e){if(e.propertyName===`value`&&Or(Er)){var t=[];wr(t,Er,e,Sn(e)),En(Dr,t)}}function Ir(e,t,n){e===`focusin`?(Pr(),Tr=t,Er=n,Tr.attachEvent(`onpropertychange`,Fr)):e===`focusout`&&Pr()}function Lr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Or(Er)}function Rr(e,t){if(e===`click`)return Or(t)}function zr(e,t){if(e===`input`||e===`change`)return Or(t)}function Br(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Vr=typeof Object.is==`function`?Object.is:Br;function Hr(e,t){if(Vr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Le.call(t,i)||!Vr(e[i],t[i]))return!1}return!0}function Ur(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Wr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Gr(e,t){var n=Wr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Wr(n)}}function Kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ur(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ur(e.document)}return t}function Jr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Yr=On&&`documentMode`in document&&11>=document.documentMode,Xr=null,Zr=null,Qr=null,$r=!1;function ei(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$r||Xr==null||Xr!==Ur(r)||(r=Xr,`selectionStart`in r&&Jr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Qr&&Hr(Qr,r)||(Qr=r,r=qf(Zr,`onSelect`),0<r.length&&(t=new Bn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Xr)))}function ti(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ni={animationend:ti(`Animation`,`AnimationEnd`),animationiteration:ti(`Animation`,`AnimationIteration`),animationstart:ti(`Animation`,`AnimationStart`),transitionrun:ti(`Transition`,`TransitionRun`),transitionstart:ti(`Transition`,`TransitionStart`),transitioncancel:ti(`Transition`,`TransitionCancel`),transitionend:ti(`Transition`,`TransitionEnd`)},ri={},ii={};On&&(ii=document.createElement(`div`).style,`AnimationEvent`in window||(delete ni.animationend.animation,delete ni.animationiteration.animation,delete ni.animationstart.animation),`TransitionEvent`in window||delete ni.transitionend.transition);function ai(e){if(ri[e])return ri[e];if(!ni[e])return e;var t=ni[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ii)return ri[e]=t[n];return e}var oi=ai(`animationend`),si=ai(`animationiteration`),ci=ai(`animationstart`),li=ai(`transitionrun`),ui=ai(`transitionstart`),di=ai(`transitioncancel`),fi=ai(`transitionend`),pi=new Map,mi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);mi.push(`scrollEnd`);function hi(e,t){pi.set(e,t),Ht(t,[e])}var gi=0;function _i(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=gd.identifierPrefix;var n=gi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function vi(e){if(e==null||typeof e==`string`)return e;var t=null,n=wd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function yi(e,t){return e=vi(e),t=vi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var bi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},xi=[],Si=0,Ci=0;function wi(){for(var e=Si,t=Ci=Si=0;t<e;){var n=xi[t];xi[t++]=null;var r=xi[t];xi[t++]=null;var i=xi[t];xi[t++]=null;var a=xi[t];if(xi[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Oi(n,i,a)}}function Ti(e,t,n,r){xi[Si++]=e,xi[Si++]=t,xi[Si++]=n,xi[Si++]=r,Ci|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Ei(e,t,n,r){return Ti(e,t,n,r),ki(e)}function Di(e,t){return Ti(e,null,null,t),ki(e)}function Oi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-et(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ki(e){if(50<Td)throw Td=0,Ed=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Ai={};function ji(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Mi(e,t,n,r){return new ji(e,t,n,r)}function Ni(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Pi(e,t){var n=e.alternate;return n===null?(n=Mi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Fi(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ii(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)Ni(r)&&(s=1);else if(typeof r==`string`)s=qm(e,n,Se.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case oe:return e=Mi(31,n,t,a),e.elementType=oe,e.lanes=o,e;case O:return Li(n.children,a,o,t);case ee:s=8,a|=24;break;case k:return e=Mi(12,n,t,a|2),e.elementType=k,e.lanes=o,e;case re:return e=Mi(13,n,t,a),e.elementType=re,e.lanes=o,e;case ie:return e=Mi(19,n,t,a),e.elementType=ie,e.lanes=o,e;case se:case le:return e=a|32,e=Mi(30,n,t,e),e.elementType=le,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case te:s=10;break a;case A:s=9;break a;case ne:s=11;break a;case ae:s=14;break a;case j:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Mi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Li(e,t,n,r){return e=Mi(7,e,r,t),e.lanes=n,e}function Ri(e,t,n){return e=Mi(6,e,null,t),e.lanes=n,e}function zi(e){var t=Mi(18,null,null,0);return t.stateNode=e,t}function Bi(e,t,n){return t=Mi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Vi=new WeakMap;function Hi(e,t){if(typeof e==`object`&&e){var n=Vi.get(e);return n===void 0?(t={value:e,source:t,stack:Ie(t)},Vi.set(e,t),t):n}return{value:e,source:t,stack:Ie(t)}}var Ui=[],Wi=0,Gi=null,Ki=0,qi=[],Ji=0,Yi=null,Xi=1,Zi=``;function Qi(e,t){Ui[Wi++]=Ki,Ui[Wi++]=Gi,Gi=e,Ki=t}function $i(e,t,n){qi[Ji++]=Xi,qi[Ji++]=Zi,qi[Ji++]=Yi,Yi=e;var r=Xi;e=Zi;var i=32-et(r)-1;r&=~(1<<i),n+=1;var a=32-et(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Xi=1<<32-et(t)+i|n<<i|r,Zi=a+e}else Xi=1<<a|n<<i|r,Zi=e}function ea(e){e.return!==null&&(Qi(e,1),$i(e,1,0))}function ta(e){for(;e===Gi;)Gi=Ui[--Wi],Ui[Wi]=null,Ki=Ui[--Wi],Ui[Wi]=null;for(;e===Yi;)Yi=qi[--Ji],qi[Ji]=null,Zi=qi[--Ji],qi[Ji]=null,Xi=qi[--Ji],qi[Ji]=null}function na(e,t){qi[Ji++]=Xi,qi[Ji++]=Zi,qi[Ji++]=Yi,Xi=t.id,Zi=t.overflow,Yi=e}var ra=null,ia=null,L=!1,aa=null,oa=!1,sa=Error(i(519));function ca(e){throw ma(Hi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),sa}function la(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[wt]=e,t[Tt]=r,n){case`dialog`:$(`cancel`,t),$(`close`,t);break;case`iframe`:case`object`:case`embed`:$(`load`,t);break;case`video`:case`audio`:for(n=0;n<Rf.length;n++)$(Rf[n],t);break;case`source`:$(`error`,t);break;case`img`:case`image`:case`link`:$(`error`,t),$(`load`,t);break;case`details`:$(`toggle`,t);break;case`input`:$(`invalid`,t),sn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:$(`invalid`,t);break;case`textarea`:$(`invalid`,t),dn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||$f(t.textContent,n)?(r.popover!=null&&($(`beforetoggle`,t),$(`toggle`,t)),r.onScroll!=null&&$(`scroll`,t),r.onScrollEnd!=null&&$(`scrollend`,t),r.onClick!=null&&(t.onclick=bn),t=!0):t=!1,t||ca(e,!0)}function ua(e){for(ra=e.return;ra;)switch(ra.tag){case 5:case 31:case 13:oa=!1;return;case 27:case 3:oa=!0;return;default:ra=ra.return}}function da(e){if(e!==ra)return!1;if(!L)return ua(e),L=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||pp(e.type,e.memoizedProps)),n=!n),n&&ia&&ca(e),ua(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ia=dm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ia=dm(e)}else t===27?(t=ia,Sp(e.type)?(e=um,um=null,ia=e):ia=t):ia=ra?lm(e.stateNode.nextSibling):null;return!0}function fa(){ia=ra=null,L=!1}function pa(){var e=aa;return e!==null&&(cd===null?cd=e:cd.push.apply(cd,e),aa=null),e}function ma(e){aa===null?aa=[e]:aa.push(e)}var ha=ye(null),ga=null,_a=null;function va(e,t,n){xe(ha,t._currentValue),t._currentValue=n}function ya(e){e._currentValue=ha.current,be(ha)}function ba(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function xa(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ba(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ba(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),ba(a.return,n,e),s=a.child,s=s===null?null:s.sibling):s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Sa(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Vr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===Te.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[sh]:e.push(sh))}a=a.return}return e!==null&&xa(t,e,n,r),t.flags|=262144,e!==null}function Ca(e){for(e=e.firstContext;e!==null;){if(!Vr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function wa(e){ga=e,_a=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ta(e){return Da(ga,e)}function Ea(e,t){return ga===null&&wa(e),Da(e,t)}function Da(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},_a===null){if(e===null)throw Error(i(308));_a=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else _a=_a.next=t;return n}var Oa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ka=t.unstable_scheduleCallback,Aa=t.unstable_NormalPriority,ja={$$typeof:te,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ma(){return{controller:new Oa,data:new Map,refCount:0}}function Na(e){e.refCount--,e.refCount===0&&ka(Aa,function(){e.controller.abort()})}function Pa(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Fa=null;function Ia(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var La=null,Ra=0,za=0,Ba=null;function Va(e,t){if(La===null){var n=La=[];Ra=0,za=Mf(),Ba={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ra++,t.then(Ha,Ha),t}function Ha(){if(--Ra===0&&(Fa=null,La!==null)){Ba!==null&&(Ba.status=`fulfilled`);var e=La;La=null,za=0,Ba=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ua(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Wa=M.S;M.S=function(e,t){if(dd=He(),typeof t==`object`&&t&&typeof t.then==`function`&&Va(e,t),Fa!==null)for(var n=_f;n!==null;)Pa(n,Fa),n=n.next;if(n=e.types,n!==null){for(var r=_f;r!==null;)Pa(r,n),r=r.next;if(za!==0){r=Fa,r===null&&(r=Fa=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Wa!==null&&Wa(e,t)};var Ga=ye(null);function Ka(){var e=Ga.current;return e===null?Ju.pooledCache:e}function qa(e,t){t===null?xe(Ga,Ga.current):xe(Ga,t.pool)}function Ja(){var e=Ka();return e===null?null:{parent:ja._currentValue,pool:e}}var Ya=Error(i(460)),Xa=Error(i(474)),Za=Error(i(542)),Qa={then:function(){}};function $a(e){return e=e.status,e===`fulfilled`||e===`rejected`}function eo(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(bn,bn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,R(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(bn,bn);else{if(e=Ju,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,R(e),e}throw no=t,Ya}}function to(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(no=e,Ya):e}}var no=null;function ro(){if(no===null)throw Error(i(459));var e=no;return no=null,e}function R(e){if(e===Ya||e===Za)throw Error(i(483))}var io=null,ao=0;function oo(e){var t=ao;return ao+=1,io===null&&(io=[]),eo(io,e,t)}function so(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function co(e,t){throw t.$$typeof===T?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function lo(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Pi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Ri(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===O?(e=d(e,t,n.props.children,r,n.key),so(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===j&&to(i)===t.type)?(t=a(t,n.props),so(t,n),t.return=e,t):(t=Ii(n.type,n.key,n.props,null,e.mode,r),so(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Bi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=Li(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Ri(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case E:return n=Ii(t.type,t.key,t.props,null,e.mode,n),so(n,t),n.return=e,n;case D:return t=Bi(t,e.mode,n),t.return=e,t;case j:return t=to(t),f(e,t,n)}if(he(t)||fe(t))return t=Li(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,oo(t),n);if(t.$$typeof===te)return f(e,Ea(e,t),n);co(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case E:return n.key===i?l(e,t,n,r):null;case D:return n.key===i?u(e,t,n,r):null;case j:return n=to(n),p(e,t,n,r)}if(he(n)||fe(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,oo(n),r);if(n.$$typeof===te)return p(e,t,Ea(e,n),r);co(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case E:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case D:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case j:return r=to(r),m(e,t,n,r,i)}if(he(r)||fe(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,oo(r),i);if(r.$$typeof===te)return m(e,t,n,Ea(t,r),i);co(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),L&&Qi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return L&&Qi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),L&&Qi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),L&&Qi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return L&&Qi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),L&&Qi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===O&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case E:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===O){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),so(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===j&&to(l)===r.type){n(e,r.sibling),c=a(r,o.props),so(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===O?(c=Li(o.props.children,e.mode,c,o.key),so(c,o),c.return=e,e=c):(c=Ii(o.type,o.key,o.props,null,e.mode,c),so(c,o),c.return=e,e=c)}return s(e);case D:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Bi(o,e.mode,c),c.return=e,e=c}return s(e);case j:return o=to(o),_(e,r,o,c)}if(he(o))return h(e,r,o,c);if(fe(o)){if(l=fe(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,oo(o),c);if(o.$$typeof===te)return _(e,r,Ea(e,o),c);co(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Ri(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ao=0;var i=_(e,t,n,r);return io=null,i}catch(t){if(t===Ya||t===Za)throw t;var a=Mi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var uo=lo(!0),fo=lo(!1),po=!1;function mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ho(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function go(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function _o(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,X&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ki(e),Oi(e,null,n),t}return Ti(e,r,t,n),ki(e)}function vo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}function yo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var bo=!1;function xo(){if(bo){var e=Ba;if(e!==null)throw e}}function So(e,t,n,r){bo=!1;var i=e.updateQueue;po=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Q&f)===f:(r&f)===f){f!==0&&f===za&&(bo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:po=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),nd|=o,e.lanes=o,e.memoizedState=d}}function Co(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function wo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Co(n[e],t)}var To=ye(null),Eo=ye(0);function Do(e,t){e=ed,xe(Eo,e),xe(To,t),ed=e|t.baseLanes}function Oo(){xe(Eo,ed),xe(To,To.current)}function ko(){ed=Eo.current,be(To),be(Eo)}var Ao=ye(null),jo=null;function Mo(e){var t=e.alternate;xe(Lo,Lo.current&1),xe(Ao,e),jo===null&&(t===null||To.current!==null||t.memoizedState!==null)&&(jo=e)}function No(e){xe(Lo,Lo.current),xe(Ao,e),jo===null&&(jo=e)}function Po(e){e.tag===22?(xe(Lo,Lo.current),xe(Ao,e),jo===null&&(jo=e)):Fo()}function Fo(){xe(Lo,Lo.current),xe(Ao,Ao.current)}function Io(e){be(Ao),jo===e&&(jo=null),be(Lo)}var Lo=ye(0);function Ro(e,t){xe(Ao,Ao.current),xe(Lo,t)}function zo(e){be(Lo),be(Ao),jo===e&&(jo=null)}function Bo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||om(n)||sm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Vo=0,z=null,Ho=null,Uo=null,Wo=!1,Go=!1,Ko=!1,qo=0,Jo=0,Yo=null,Xo=0;function Zo(){throw Error(i(321))}function Qo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Vr(e[n],t[n]))return!1;return!0}function $o(e,t,n,r,i,a){return Vo=a,z=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,M.H=e===null||e.memoizedState===null?uc:dc,Ko=!1,a=n(r,i),Ko=!1,Go&&(a=ts(t,n,r,i)),es(e),a}function es(e){M.H=lc;var t=Ho!==null&&Ho.next!==null;if(Vo=0,Uo=Ho=z=null,Wo=!1,Jo=0,Yo=null,t)throw Error(i(300));e===null||Oc||(e=e.dependencies,e!==null&&Ca(e)&&(Oc=!0))}function ts(e,t,n,r){z=e;var a=0;do{if(Go&&(Yo=null),Jo=0,Go=!1,25<=a)throw Error(i(301));if(a+=1,Uo=Ho=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}M.H=fc,o=t(n,r)}while(Go);return o}function ns(){var e=M.H,t=e.useState()[0];return t=typeof t.then==`function`?ls(t):t,e=e.useState()[0],(Ho===null?null:Ho.memoizedState)!==e&&(z.flags|=1024),t}function rs(){var e=qo!==0;return qo=0,e}function is(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function as(e){if(Wo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Wo=!1}Vo=0,Uo=Ho=z=null,Go=!1,Jo=qo=0,Yo=null}function os(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Uo===null?z.memoizedState=Uo=e:Uo=Uo.next=e,Uo}function ss(){if(Ho===null){var e=z.alternate;e=e===null?null:e.memoizedState}else e=Ho.next;var t=Uo===null?z.memoizedState:Uo.next;if(t!==null)Uo=t,Ho=e;else{if(e===null)throw z.alternate===null?Error(i(467)):Error(i(310));Ho=e,e={memoizedState:Ho.memoizedState,baseState:Ho.baseState,baseQueue:Ho.baseQueue,queue:Ho.queue,next:null},Uo===null?z.memoizedState=Uo=e:Uo=Uo.next=e}return Uo}function cs(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ls(e){var t=Jo;return Jo+=1,Yo===null&&(Yo=[]),e=eo(Yo,e,t),t=z,(Uo===null?t.memoizedState:Uo.next)===null&&(t=t.alternate,M.H=t===null||t.memoizedState===null?uc:dc),e}function us(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ls(e);if(e.$$typeof===ue)return;if(e.$$typeof===te)return Ta(e)}throw Error(i(438,String(e)))}function ds(e){var t=null,n=z.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=z.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=cs(),z.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ce;return t.index++,n}function fs(e,t){return typeof t==`function`?t(e):t}function ps(e){return ms(ss(),Ho,e)}function ms(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Vo&f)===f:(Q&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===za&&(d=!0);else if((Vo&p)===p){u=u.next,p===za&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,z.lanes|=p,nd|=p;f=u.action,Ko&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,z.lanes|=f,nd|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Vr(o,e.memoizedState)&&(Oc=!0,d&&(n=Ba,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function hs(e){var t=ss(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Vr(o,t.memoizedState)||(Oc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function B(e,t,n){var r=z,a=ss(),o=L;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Vr((Ho||a).memoizedState,n);if(s&&(a.memoizedState=n,Oc=!0),a=a.queue,Fs(V.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Uo!==null&&!!(Uo.memoizedState.tag&1),As(e?9:8,{destroy:void 0},_s.bind(null,r,a,n,t),null),e){if(r.flags|=2048,Ju===null)throw Error(i(349));o||Vo&127||gs(r,t,n)}return n}function gs(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=z.updateQueue,t===null?(t=cs(),z.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function _s(e,t,n,r){t.value=n,t.getSnapshot=r,vs(t)&&ys(e)}function V(e,t,n){return n(function(){vs(t)&&ys(e)})}function vs(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Vr(e,n)}catch{return!0}}function ys(e){var t=Di(e,2);t!==null&&Ad(t,e,2)}function H(e){var t=os();if(typeof e==`function`){var n=e;if(e=n(),Ko){$e(!0);try{n()}finally{$e(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:e},t}function bs(e,t,n,r){return e.baseState=n,ms(e,Ho,typeof r==`function`?r:fs)}function xs(e,t,n,r,a){if(oc(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};M.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ss(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ss(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=M.T,o={};o.types=a===null?null:a.types,M.T=o;try{var s=n(i,r),c=M.S;c!==null&&c(o,s),Cs(e,t,s)}catch(n){Ts(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),M.T=a}}else try{a=n(i,r),Cs(e,t,a)}catch(n){Ts(e,t,n)}}function Cs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ws(e,t,n)},function(n){return Ts(e,t,n)}):ws(e,t,n)}function ws(e,t,n){t.status=`fulfilled`,t.value=n,Es(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ss(e,n)))}function Ts(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Es(t),t=t.next;while(t!==r)}e.action=null}function Es(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function U(e,t){return t}function Ds(e,t){if(L){var n=Ju.formState;if(n!==null){a:{var r=z;if(L){if(ia){b:{for(var i=ia,a=oa;i.nodeType!==8;)if(!a||(i=lm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){ia=lm(i.nextSibling),r=i.data===`F!`;break a}}ca(r)}r=!1}r&&(t=n[0])}}return n=os(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:U,lastRenderedState:t},n.queue=r,n=rc.bind(null,z,r),r.dispatch=n,r=H(!1),a=ac.bind(null,z,!1,r.queue),r=os(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=xs.bind(null,z,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function W(e){return G(ss(),Ho,e)}function G(e,t,n){if(t=ms(e,t,U)[0],e=ps(fs)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ls(t)}catch(e){throw e===Ya?Za:e}else r=t;t=ss();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(z.flags|=2048,As(9,{destroy:void 0},Os.bind(null,i,n),null)),[r,a,e]}function Os(e,t){e.action=t}function ks(e){var t=ss(),n=Ho;if(n!==null)return G(t,n,e);ss(),t=t.memoizedState,n=ss();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function As(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=z.updateQueue,t===null&&(t=cs(),z.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function js(){return ss().memoizedState}function Ms(e,t,n,r){var i=os();z.flags|=e,i.memoizedState=As(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ns(e,t,n,r){var i=ss();r=r===void 0?null:r;var a=i.memoizedState.inst;Ho!==null&&r!==null&&Qo(r,Ho.memoizedState.deps)?i.memoizedState=As(t,a,n,r):(z.flags|=e,i.memoizedState=As(1|t,a,n,r))}function Ps(e,t){Ms(8390656,8,e,t)}function Fs(e,t){Ns(2048,8,e,t)}function Is(e){z.flags|=4;var t=z.updateQueue;if(t===null)t=cs(),z.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Ls(e){var t=ss().memoizedState;return Is({ref:t,nextImpl:e}),function(){if(X&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Rs(e,t){return Ns(4,2,e,t)}function zs(e,t){return Ns(4,4,e,t)}function Bs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Vs(e,t,n){n=n==null?null:n.concat([e]),Ns(4,4,Bs.bind(null,t,e),n)}function Hs(){}function Us(e,t){var n=ss();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Qo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ws(e,t){var n=ss();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Qo(t,r[1]))return r[0];if(r=e(),Ko){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r}function Gs(e,t,n){return n===void 0||Vo&1073741824&&!(Q&261930)?e.memoizedState=t:(e.memoizedState=n,e=Od(),z.lanes|=e,nd|=e,n)}function Ks(e,t,n,r){return Vr(n,t)?n:To.current===null?!(Vo&106)||Vo&1073741824&&!(Q&261930)?(Oc=!0,e.memoizedState=n):(e=Od(),z.lanes|=e,nd|=e,t):(e=Gs(e,n,r),Vr(e,t)||(Oc=!0),e)}function qs(e,t,n,r,i){var a=N.p;N.p=a!==0&&8>a?a:8;var o=M.T,s={};s.types=o===null?null:o.types,M.T=s,ac(e,!1,t,n);try{var c=i(),l=M.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ic(e,t,Ua(c,r),Dd(e)):ic(e,t,r,Dd(e))}catch(n){ic(e,t,{then:function(){},status:`rejected`,reason:n},Dd())}finally{N.p=a,o!==null&&s.types!==null&&(o.types=s.types),M.T=o}}function Js(){}function Ys(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Xs(e).queue;qs(e,a,t,ge,n===null?Js:function(){return Zs(e),n(r)})}function Xs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ge,baseState:ge,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:ge},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Zs(e){var t=Xs(e);t.next===null&&(t=e.alternate.memoizedState),ic(e,t.next.queue,{},Dd())}function Qs(){return Ta(sh)}function $s(){return ss().memoizedState}function ec(){return ss().memoizedState}function tc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Dd();e=go(n);var r=_o(t,e,n);r!==null&&(Ad(r,t,n),vo(r,t,n)),t={cache:Ma()},e.payload=t;return}t=t.return}}function nc(e,t,n){var r=Dd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},oc(e)?sc(t,n):(n=Ei(e,t,n,r),n!==null&&(Ad(n,e,r),cc(n,t,r)))}function rc(e,t,n){ic(e,t,n,Dd())}function ic(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(oc(e))sc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Vr(s,o))return Ti(e,t,i,0),Ju===null&&wi(),!1}catch{}if(n=Ei(e,t,i,r),n!==null)return Ad(n,e,r),cc(n,t,r),!0}return!1}function ac(e,t,n,r){if(r={lane:2,revertLane:Mf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},oc(e)){if(t)throw Error(i(479))}else t=Ei(e,n,r,2),t!==null&&Ad(t,e,2)}function oc(e){var t=e.alternate;return e===z||t!==null&&t===z}function sc(e,t){Go=Wo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function cc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}var lc={readContext:Ta,use:us,useCallback:Zo,useContext:Zo,useEffect:Zo,useImperativeHandle:Zo,useLayoutEffect:Zo,useInsertionEffect:Zo,useMemo:Zo,useReducer:Zo,useRef:Zo,useState:Zo,useDebugValue:Zo,useDeferredValue:Zo,useTransition:Zo,useSyncExternalStore:Zo,useId:Zo,useHostTransitionStatus:Zo,useFormState:Zo,useActionState:Zo,useOptimistic:Zo,useMemoCache:Zo,useCacheRefresh:Zo,useEffectEvent:Zo},uc={readContext:Ta,use:us,useCallback:function(e,t){return os().memoizedState=[e,t===void 0?null:t],e},useContext:Ta,useEffect:Ps,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ms(4194308,4,Bs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ms(4194308,4,e,t)},useInsertionEffect:function(e,t){Ms(4,2,e,t)},useMemo:function(e,t){var n=os();t=t===void 0?null:t;var r=e();if(Ko){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=os();if(n!==void 0){var i=n(t);if(Ko){$e(!0);try{n(t)}finally{$e(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=nc.bind(null,z,e),[r.memoizedState,e]},useRef:function(e){var t=os();return e={current:e},t.memoizedState=e},useState:function(e){e=H(e);var t=e.queue,n=rc.bind(null,z,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Hs,useDeferredValue:function(e,t){return Gs(os(),e,t)},useTransition:function(){var e=H(!1);return e=qs.bind(null,z,e.queue,!0,!1),os().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=z,a=os();if(L){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ju===null)throw Error(i(349));Q&127||gs(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Ps(V.bind(null,r,o,e),[e]),r.flags|=2048,As(9,{destroy:void 0},_s.bind(null,r,o,n,t),null),n},useId:function(){var e=os(),t=Ju.identifierPrefix;if(L){var n=Zi,r=Xi;n=(r&~(1<<32-et(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=qo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Xo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Qs,useFormState:Ds,useActionState:Ds,useOptimistic:function(e){var t=os();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=ac.bind(null,z,!0,n),n.dispatch=t,[e,t]},useMemoCache:ds,useCacheRefresh:function(){return os().memoizedState=tc.bind(null,z)},useEffectEvent:function(e){var t=os(),n={impl:e};return t.memoizedState=n,function(){if(X&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},dc={readContext:Ta,use:us,useCallback:Us,useContext:Ta,useEffect:Fs,useImperativeHandle:Vs,useInsertionEffect:Rs,useLayoutEffect:zs,useMemo:Ws,useReducer:ps,useRef:js,useState:function(){return ps(fs)},useDebugValue:Hs,useDeferredValue:function(e,t){return Ks(ss(),Ho.memoizedState,e,t)},useTransition:function(){var e=ps(fs)[0],t=ss().memoizedState;return[typeof e==`boolean`?e:ls(e),t]},useSyncExternalStore:B,useId:$s,useHostTransitionStatus:Qs,useFormState:W,useActionState:W,useOptimistic:function(e,t){return bs(ss(),Ho,e,t)},useMemoCache:ds,useCacheRefresh:ec,useEffectEvent:Ls},fc={readContext:Ta,use:us,useCallback:Us,useContext:Ta,useEffect:Fs,useImperativeHandle:Vs,useInsertionEffect:Rs,useLayoutEffect:zs,useMemo:Ws,useReducer:hs,useRef:js,useState:function(){return hs(fs)},useDebugValue:Hs,useDeferredValue:function(e,t){var n=ss();return Ho===null?Gs(n,e,t):Ks(n,Ho.memoizedState,e,t)},useTransition:function(){var e=hs(fs)[0],t=ss().memoizedState;return[typeof e==`boolean`?e:ls(e),t]},useSyncExternalStore:B,useId:$s,useHostTransitionStatus:Qs,useFormState:ks,useActionState:ks,useOptimistic:function(e,t){var n=ss();return Ho===null?(n.baseState=e,[e,n.queue.dispatch]):bs(n,Ho,e,t)},useMemoCache:ds,useCacheRefresh:ec,useEffectEvent:Ls};function pc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:w({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var mc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Dd(),i=go(r);i.payload=t,n!=null&&(i.callback=n),t=_o(e,i,r),t!==null&&(Ad(t,e,r),vo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Dd(),i=go(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=_o(e,i,r),t!==null&&(Ad(t,e,r),vo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Dd(),r=go(n);r.tag=2,t!=null&&(r.callback=t),t=_o(e,r,n),t!==null&&(Ad(t,e,n),vo(t,e,n))}};function hc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Hr(n,r)||!Hr(i,a):!0}function gc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&mc.enqueueReplaceState(t,t.state,null)}function _c(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=w({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function vc(e){bi(e)}function yc(e){console.error(e)}function bc(e){bi(e)}function xc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Sc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Cc(e,t,n){return n=go(n),n.tag=3,n.payload={element:null},n.callback=function(){xc(e,t)},n}function wc(e){return e=go(e),e.tag=3,e}function Tc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Sc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Sc(t,n,r),typeof i!=`function`&&(md===null?md=new Set([this]):md.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Ec(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Sa(t,n,a,!0),n=Ao.current,n!==null){switch(n.tag){case 31:case 13:case 19:return jo===null?Hd():n.alternate===null&&td===0&&(td=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Qa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),df(e,r,a)),!1;case 22:return n.flags|=65536,r===Qa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),df(e,r,a)),!1}throw Error(i(435,n.tag))}return df(e,r,a),Hd(),!1}if(L)return t=Ao.current,t===null?(r!==sa&&(t=Error(i(423),{cause:r}),ma(Hi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Hi(r,n),a=Cc(e.stateNode,r,a),yo(e,a),td!==4&&(td=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==sa&&(e=Error(i(422),{cause:r}),ma(Hi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Hi(o,n),sd===null?sd=[o]:sd.push(o),td!==4&&(td=2),t===null)return!0;r=Hi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Cc(n.stateNode,r,e),yo(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(md===null||!md.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=wc(a),Tc(a,e,n,r),yo(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Dc=Error(i(461)),Oc=!1;function kc(e,t,n,r){t.child=e===null?fo(t,null,n,r):uo(t,e.child,n,r)}function Ac(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return wa(t),r=$o(e,t,n,o,a,i),s=rs(),e!==null&&!Oc?(is(e,t,i),il(e,t,i)):(L&&s&&ea(t),t.flags|=1,kc(e,t,r,i),t.child)}function jc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Ni(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Mc(e,t,a,r,i)):(e=Ii(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!al(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Hr:n,n(o,r)&&e.ref===t.ref)return il(e,t,i)}return t.flags|=1,e=Pi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Mc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Hr(a,r)&&e.ref===t.ref){if(Oc=!1,t.pendingProps=r=a,al(e,i))e.flags&131072&&(Oc=!0);else return t.lanes=e.lanes,il(e,t,i)}}return Bc(e,t,n,r,i)}function Nc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Fc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&qa(t,a===null?null:a.cachePool),a===null?Oo():Do(t,a),Po(t);else return r=t.lanes=536870912,Fc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&qa(t,null),Oo(),Fo()):(qa(t,a.cachePool),Do(t,a),Fo(),t.memoizedState=null);return kc(e,t,i,n),t.child}function Pc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Fc(e,t,n,r,i){var a=Ka();return a=a===null?null:{parent:ja._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&qa(t,null),Oo(),Po(t),e!==null&&Sa(e,t,r,!0),t.childLanes=i,null}function Ic(e,t){return t=Yc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Lc(e,t,n){return uo(t,e.child,null,n),e=Ic(t,t.pendingProps),e.flags|=2,Io(t),t.memoizedState=null,e}function Rc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(L){if(r.mode===`hidden`)return e=Ic(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Pc(null,e);if(No(t),(e=ia)?(e=am(e,oa),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Yi===null?null:{id:Xi,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=zi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw ca(t);return t.lanes=536870912,null}return Ic(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(No(t),a){if(t.flags&256)t.flags&=-257,t=Lc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Oc||Sa(e,t,n,!1),a=(n&e.childLanes)!==0,Oc||a){if(To.current===null){if(r=Ju,r!==null&&(s=vt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Di(e,s),Ad(r,e,s),Dc;Hd()}t=Lc(e,t,n)}else e=o.treeContext,ia=lm(s.nextSibling),ra=t,L=!0,aa=null,oa=!1,e!==null&&na(t,e),t=Ic(t,r),t.flags|=134221824;return t}return e=Pi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function zc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Bc(e,t,n,r,i){return wa(t),n=$o(e,t,n,r,void 0,i),r=rs(),e!==null&&!Oc?(is(e,t,i),il(e,t,i)):(L&&r&&ea(t),t.flags|=1,kc(e,t,n,i),t.child)}function Vc(e,t,n,r,i,a){return wa(t),t.updateQueue=null,n=ts(t,r,n,i),es(e),r=rs(),e!==null&&!Oc?(is(e,t,a),il(e,t,a)):(L&&r&&ea(t),t.flags|=1,kc(e,t,n,a),t.child)}function Hc(e,t,n,r,i){if(wa(t),t.stateNode===null){var a=Ai,o=n.contextType;typeof o==`object`&&o&&(a=Ta(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=mc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},mo(t),o=n.contextType,a.context=typeof o==`object`&&o?Ta(o):Ai,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(pc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&mc.enqueueReplaceState(a,a.state,null),So(t,r,a,i),xo(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=_c(n,s);a.props=c;var l=a.context,u=n.contextType;o=Ai,typeof u==`object`&&u&&(o=Ta(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&gc(t,a,r,o),po=!1;var f=t.memoizedState;a.state=f,So(t,r,a,i),xo(),l=t.memoizedState,s||f!==l||po?(typeof d==`function`&&(pc(t,n,d,r),l=t.memoizedState),(c=po||hc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,ho(e,t),o=t.memoizedProps,u=_c(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Ai,typeof l==`object`&&l&&(c=Ta(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&gc(t,a,r,c),po=!1,f=t.memoizedState,a.state=f,So(t,r,a,i),xo();var p=t.memoizedState;o!==d||f!==p||po||e!==null&&e.dependencies!==null&&Ca(e.dependencies)?(typeof s==`function`&&(pc(t,n,s,r),p=t.memoizedState),(u=po||hc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ca(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,zc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=uo(t,e.child,null,i),t.child=uo(t,null,n,i)):kc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=il(e,t,i),e}function Uc(e,t,n,r){return fa(),t.flags|=256,kc(e,t,n,r),t.child}var Wc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Gc(e){return{baseLanes:e,cachePool:Ja()}}function Kc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ad),e}function qc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Lo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(L){if(i?Mo(t):Fo(),(e=ia)?(e=am(e,oa),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Yi===null?null:{id:Xi,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=zi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw ca(t);return t.lanes=sm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Fo(),i=t.mode,a=Yc({mode:`hidden`,children:a},i),r=Li(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Gc(n),r.childLanes=Kc(e,o,n),t.memoizedState=Wc,Pc(null,r)):(Mo(t),Jc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return Zc(e,t,a,o,r,c,s,n)}return i?(Fo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Pi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Li(i,a,n,null),i.flags|=2):i=Pi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Pc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Gc(n):(a=i.cachePool,a===null?a=Ja():(s=ja._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Kc(e,o,n),t.memoizedState=Wc,Pc(e.child,r)):(Mo(t),n=e.child,e=n.sibling,n=Pi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function Jc(e,t){return t=Yc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Yc(e,t){return e=Mi(22,e,null,t),e.lanes=0,e}function Xc(e,t,n){return uo(t,e.child,null,n),e=Jc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Zc(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(Mo(t),t.flags&=-257,Xc(e,t,c)):t.memoizedState===null?(Fo(),o=a.fallback,s=t.mode,a=Yc({mode:`visible`,children:a.children},s),o=Li(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,uo(t,e.child,null,c),a=t.child,a.memoizedState=Gc(c),a.childLanes=Kc(e,r,c),t.memoizedState=Wc,Pc(null,a)):(Fo(),t.child=e.child,t.flags|=128,null);if(Mo(t),sm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,ma({value:a,source:null,stack:null})),Xc(e,t,c)}if(Oc||Sa(e,t,c,!1),r=(c&e.childLanes)!==0,Oc||r){if(To.current!==null)return Xc(e,t,c);if(r=Ju,r!==null&&(a=vt(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,Di(e,a),Ad(r,e,a),Dc;return om(o)||Hd(),Xc(e,t,c)}return om(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,ia=lm(o.nextSibling),ra=t,L=!0,aa=null,oa=!1,e!==null&&na(t,e),t=Jc(t,a.children),t.flags|=134221824,t)}function Qc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ba(e.return,t,n)}function $c(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Bo(n)===null&&(t=e),e=e.sibling}return t}function el(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function tl(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function nl(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Lo.current;if(t.flags&128)return Ro(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Ro(t,o),i===`backwards`&&e!==null?(tl(e),kc(e,t,r,n),tl(e)):kc(e,t,r,n),r=L?Ki:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Qc(e,n,t);else if(e.tag===19)Qc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=$c(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,tl(t)),el(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Bo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}el(t,!0,n,null,a,r);break;case`together`:el(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=$c(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),el(t,!1,i,n,a,r)}return t.child}function rl(e,t,n){var r=t.pendingProps;return va(t,t.type,r.value),kc(e,t,r.children,n),t.child}function il(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),nd|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Sa(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Pi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Pi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function al(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Ca(e)))}function ol(e,t,n){switch(t.tag){case 3:Ee(t,t.stateNode.containerInfo),va(t,ja,e.memoizedState.cache),fa();break;case 27:case 5:Oe(t);break;case 4:Ee(t,t.stateNode.containerInfo);break;case 10:va(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,No(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Mo(t),t.flags|=128,null;r=Sa(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?qc(e,t,n):(Mo(t),e=il(e,t,n),e===null?null:e.sibling)}Mo(t);break;case 19:if(t.flags&128)return nl(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Sa(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return nl(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ro(t,Lo.current),r)break;return null;case 22:return t.lanes=0,Nc(e,t,n,t.pendingProps);case 24:va(t,ja,e.memoizedState.cache)}return il(e,t,n)}function sl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Oc=!0;else{if(!al(e,n)&&!(t.flags&128))return Oc=!1,ol(e,t,n);Oc=!!(e.flags&131072)}}else Oc=!1,L&&t.flags&1048576&&$i(t,Ki,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=to(t.elementType),t.type=e,typeof e==`function`)Ni(e)?(r=_c(e,r),t.tag=1,t=Hc(null,t,e,r,n)):(t.tag=0,t=Bc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===ne){t.tag=11,t=Ac(null,t,e,r,n);break a}if(a===ae){t.tag=14,t=jc(null,t,e,r,n);break a}if(a===te){t.tag=10,t.type=e,t=rl(null,t,n);break a}}throw t=me(e)||e,Error(i(306,t,``))}}return t;case 0:return Bc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=_c(r,t.pendingProps),Hc(e,t,r,a,n);case 3:a:{if(Ee(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ho(e,t),So(t,r,null,n);var s=t.memoizedState;if(r=s.cache,va(t,ja,r),r!==o.cache&&xa(t,[ja],n,!0),xo(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Uc(e,t,r,n);break a}if(r!==a){a=Hi(Error(i(424)),t),ma(a),t=Uc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(ia=lm(e.firstChild),ra=t,L=!0,aa=null,oa=!0,n=fo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(fa(),r===a){t=il(e,t,n);break a}kc(e,t,r,n)}t=t.child}return t;case 26:return zc(e,t),e===null?(n=Nm(t.type,null,t.pendingProps,null))?t.memoizedState=n:L||(t.stateNode=fp(t.type,t.pendingProps,we.current,t)):t.memoizedState=Nm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Oe(t),e===null&&L&&(r=t.stateNode=hm(t.type,t.pendingProps,we.current),ra=t,oa=!0,a=ia,Sp(t.type)?(um=a,ia=lm(r.firstChild)):ia=a),kc(e,t,t.pendingProps.children,n),zc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&L&&((a=r=ia)&&(r=rm(r,t.type,t.pendingProps,oa),r===null?a=!1:(t.stateNode=r,ra=t,ia=lm(r.firstChild),oa=!1,a=!0)),a||ca(t)),Oe(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,pp(a,o)?r=null:s!==null&&pp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=$o(e,t,ns,null,null,n),sh._currentValue=a),zc(e,t),kc(e,t,r,n),t.child;case 6:return e===null&&L&&((e=n=ia)&&(n=im(n,t.pendingProps,oa),n===null?e=!1:(t.stateNode=n,ra=t,ia=null,e=!0)),e||ca(t)),null;case 13:return qc(e,t,n);case 4:return Ee(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=uo(t,null,r,n):kc(e,t,r,n),t.child;case 11:return Ac(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,zc(e,t),kc(e,t,r,n),t.child;case 8:return kc(e,t,t.pendingProps.children,n),t.child;case 12:return kc(e,t,t.pendingProps.children,n),t.child;case 10:return rl(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,wa(t),a=Ta(a),r=r(a),t.flags|=1,kc(e,t,r,n),t.child;case 14:return jc(e,t,t.type,t.pendingProps,n);case 15:return Mc(e,t,t.type,t.pendingProps,n);case 19:return nl(e,t,n);case 31:return Rc(e,t,n);case 22:return Nc(e,t,n,t.pendingProps);case 24:return wa(t),r=Ta(ja),e===null?(a=Ka(),a===null&&(a=Ju,o=Ma(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},mo(t),va(t,ja,a)):((e.lanes&n)!==0&&(ho(e,t),So(t,null,null,n),xo()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,va(t,ja,r),r!==a.cache&&xa(t,[ja],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),va(t,ja,r))),kc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:L&&ea(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:zc(e,t),kc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function cl(e){e.flags|=4}function ll(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Jm(t,r):Jm(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(zd())e.flags|=8192;else throw no=Qa,Xa}}else e.flags&=-16777217}function ul(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Ym(t)){if(zd())e.flags|=8192;else throw no=Qa,Xa}}function dl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:ft(),e.lanes|=t,od|=t)}function fl(e,t){if(!L)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function K(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function pl(e,t,n){var r=t.pendingProps;switch(ta(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return K(t),null;case 1:return K(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ya(ja),De(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(da(t)?cl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,pa())),K(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(cl(t),o===null?(K(t),ll(t,a,null,r,n)):(K(t),ul(t,o))):o?o===e.memoizedState?(K(t),t.flags&=-16777217):(cl(t),K(t),ul(t,o)):(e=e.memoizedProps,e!==r&&cl(t),K(t),ll(t,a,e,r,n)),null;case 27:if(ke(t),n=we.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return K(t),t.subtreeFlags&=-33554433,null}e=Se.current,da(t)?la(t,e):(e=hm(a,r,n),t.stateNode=e,cl(t))}return K(t),t.subtreeFlags&=-33554433,null;case 5:if(ke(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return K(t),t.subtreeFlags&=-33554433,null}if(o=Se.current,da(t))la(t,o);else{var s=lp(we.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[wt]=t,o[Tt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&cl(t)}}return K(t),t.subtreeFlags&=-33554433,ll(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=we.current,da(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ra,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[wt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||$f(e.nodeValue,n)),e||ca(t,!0)}else e=lp(e).createTextNode(r),e[wt]=t,t.stateNode=e}return K(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=da(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[wt]=t}else fa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;K(t),e=!1}else n=pa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Io(t),t):(Io(t),null);if(t.flags&128)throw Error(i(558))}return K(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=da(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[wt]=t}else fa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;K(t),a=!1}else a=pa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Io(t),t):(Io(t),null)}return Io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),dl(t,t.updateQueue),K(t),null);case 4:return De(),e===null&&Uf(t.stateNode.containerInfo),t.flags|=67108864,K(t),null;case 10:return ya(t.type),K(t),null;case 19:if(zo(t),r=t.memoizedState,r===null)return K(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)fl(r,!1);else{if(td!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Bo(e),o!==null){for(t.flags|=128,fl(r,!1),e=o.updateQueue,t.updateQueue=e,dl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Fi(n,e),n=n.sibling;return Ro(t,Lo.current&1|2),L&&Qi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&He()>fd&&(t.flags|=128,a=!0,fl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Bo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,dl(t,e),fl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!L)return K(t),null}else 2*He()-r.renderingStartTime>fd&&n!==536870912&&(t.flags|=128,a=!0,fl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=He(),e.sibling=null,o=Lo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||L?Ro(t,o):(n=o,xe(Ao,t),xe(Lo,n),jo===null&&(jo=t)),L&&Qi(t,r.treeForkCount),e}return K(t),null;case 22:case 23:return Io(t),ko(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(K(t),t.subtreeFlags&6&&(t.flags|=8192)):K(t),n=t.updateQueue,n!==null&&dl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&be(Ga),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ya(ja),K(t),null;case 25:return null;case 30:return t.flags|=33554432,K(t),null}throw Error(i(156,t.tag))}function ml(e,t){switch(ta(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ya(ja),De(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ke(t),null;case 31:if(t.memoizedState!==null){if(Io(t),t.alternate===null)throw Error(i(340));fa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));fa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return zo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return De(),null;case 10:return ya(t.type),null;case 22:case 23:return Io(t),ko(),e!==null&&be(Ga),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ya(ja),null;case 25:return null;default:return null}}function hl(e,t){switch(ta(t),t.tag){case 3:ya(ja),De();break;case 26:case 27:case 5:ke(t);break;case 4:De();break;case 31:t.memoizedState!==null&&Io(t);break;case 13:Io(t);break;case 19:zo(t);break;case 10:ya(t.type);break;case 22:case 23:Io(t),ko(),e!==null&&be(Ga);break;case 24:ya(ja)}}function gl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){uf(t,t.return,e)}}function _l(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){uf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){uf(t,t.return,e)}}function vl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{wo(t,n)}catch(t){uf(e,e.return,t)}}}function yl(e,t,n){n.props=_c(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){uf(e,t,n)}}function bl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=_i(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);f(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){uf(e,t,n)}}function xl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){uf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){uf(e,t,n)}else n.current=null}}function Sl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)em(e.stateNode,t[n])}function Cl(e){for(var t=e.return;t!==null&&(El(t)&&em(e.stateNode,t.stateNode),!Tl(t));)t=t.return}function wl(e){for(var t=e.return;t!==null&&(El(t)&&tm(e.stateNode,t.stateNode),!Tl(t));)t=t.return}function Tl(e){return e.tag===5||e.tag===3||e.tag===27}function El(e){return e&&e.tag===7&&e.stateNode!==null}function Dl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){uf(e,e.return,t)}}function Ol(e,t,n){try{var r=e.stateNode;ip(r,e.type,n,t),r[Tt]=t}catch(t){uf(e,e.return,t)}}function kl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Sp(e.type)||e.tag===4}function Al(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||kl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Sp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function jl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=bn)),Sl(e,r),P=!0;else if(i!==4&&(i===27&&(Sl(e,r),r=null,Sp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(jl(e,t,n,r),e=e.sibling;e!==null;)jl(e,t,n,r),e=e.sibling}function Ml(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),Sl(e,r),P=!0;else if(i!==4&&(i===27&&(Sl(e,r),r=null,Sp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Ml(e,t,n,r),e=e.sibling;e!==null;)Ml(e,t,n,r),e=e.sibling}function Nl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);np(t,r,n),t[wt]=e,t[Tt]=n}catch(t){uf(e,e.return,t)}}var Pl=!1,Fl=null;function Il(e){(e.tag===30||e.subtreeFlags&33554432)&&(Pl=!0)}var Ll=null;function Rl(){var e=Ll;return Ll=null,e}var zl=0;function Bl(e,t,n,r,i){return zl=0,Vl(e.child,t,n,r,i)}function Vl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Op(o);r.push(s),s.view&&(a=!0)}else a||Op(o).view&&(a=!0);Pl=!0,Tp(o,zl===0?t:t+`_`+zl,n),zl++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||Vl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function Hl(e,t){for(;e!==null;)e.tag===5?Ep(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||Hl(e.child,t),e=e.sibling}function Ul(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Ul(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=yi(t.default,t.share),t!==`none`&&(Bl(e,n,t,null,!1)||Hl(e.child,!1))}e=e.sibling}}function Wl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=_i(r,n),a=yi(r.default,n.paired?r.share:r.enter);a===`none`?Ul(e):Bl(e,i,a,null,!1)?(Ul(e),n.paired||t||kd(e,r.onEnter)):Hl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Wl(e,t),e=e.sibling;else Ul(e)}function Gl(e){if(Fl!==null&&Fl.size!==0){var t=Fl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=yi(n.default,n.share);if(a!==`none`&&(Bl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,kd(e,n.onShare)):Hl(e.child,!1)),t.delete(r),t.size===0)break}}}Gl(e)}e=e.sibling}}}function Kl(e){if(e.tag===30){var t=e.memoizedProps,n=_i(t,e.stateNode),r=Fl===null?void 0:Fl.get(n),i=yi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Bl(e,n,i,null,!1)?r===void 0?kd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Fl.delete(n),kd(e,t.onShare)):Hl(e.child,!1)),Fl!==null&&Gl(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Kl(e),e=e.sibling;else Fl!==null&&Gl(e)}function ql(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=_i(t,e.stateNode);t=yi(t.default,t.update),e.flags&=-5,t!==`none`&&Bl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&ql(e);e=e.sibling}}function Jl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Hl(e.child,!1))}Jl(e)}e=e.sibling}}function Yl(e){if(e.tag===30)e.stateNode.paired=null,Hl(e.child,!1),Jl(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Yl(e),e=e.sibling;else Jl(e)}function Xl(e){for(e=e.child;e!==null;)e.tag===30?Hl(e.child,!1):e.subtreeFlags&33554432&&Xl(e),e=e.sibling}function Zl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&zl<a.length){var l=a[zl],u=Op(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Tp(c,zl===0?n:n+`_`+zl,i),s&&e.flags&4||(Ll===null&&(Ll=[]),Ll.push(c,zl===0?r:r+`_`+zl,t.memoizedProps)),zl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Zl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Ql(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=_i(n,r),a=yi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(kp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;zl=0,i=Zl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||kd(e,n.onUpdate))}else e.subtreeFlags&33554432&&Ql(e,t);e=e.sibling}}var $l=!1,q=!1,eu=!1,tu=!1,nu=typeof WeakSet==`function`?WeakSet:Set,ru=null,iu=!1,au=!1,ou=!1,su=!1;function cu(e,t,n){if(e=e.containerInfo,sp=gh,e=qr(e),Jr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(cp={focusedElem:e,selectionRange:r},gh=!1,n=(n&335544064)===n,ru=t,t=n?9270:1024;ru!==null;){if(e=ru,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Kl(r[a]);if(e.alternate===null&&e.flags&2)n&&Il(e),lu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Kl(r),lu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Il(e),lu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,ru=r):(n&&ql(e),lu(n))}}Fl=null}function lu(e){for(;ru!==null;){var t=ru,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=_c(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){uf(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)nm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:nm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=_i(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=yi(a.default,a.update),a!==`none`&&Bl(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,ru=r;break}ru=t.return}}function uu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ju(e,n),r&4&&gl(5,n);break;case 1:if(ju(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){uf(n,n.return,e)}else{var i=_c(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){uf(n,n.return,e)}}}r&64&&vl(n),r&512&&bl(n,n.return);break;case 3:if(ju(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{wo(e,t)}catch(e){uf(n,n.return,e)}}break;case 27:t===null&&r&4&&Nl(n);case 26:case 5:ju(e,n),t===null&&r&4&&Dl(n),r&512&&bl(n,n.return);break;case 12:ju(e,n);break;case 31:ju(e,n),r&4&&bu(e,n);break;case 13:ju(e,n),r&4&&xu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=mf.bind(null,n),cm(e,n))));break;case 22:if(r=n.memoizedState!==null||$l,!r){var a=t!==null&&t.memoizedState!==null||q;t=$l,i=q,$l=r,(q=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Nu(e,n,r)):ju(e,n),$l=t,q=i}break;case 30:ju(e,n),r&512&&bl(n,n.return);break;case 7:r&512&&bl(n,n.return);default:ju(e,n)}}function du(e,t){for(e=e.child;e!==null;)fu(e,t),e=e.sibling}function fu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){uf(e,e.return,t)}pu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,P=!0}catch(t){uf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?wp(s,!0):wp(e.stateNode,!1)}catch(t){uf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&du(e,t);break;default:du(e,t)}}function pu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:fu(n,r);break a;case 22:n.memoizedState===null&&pu(n,r);break a;default:pu(n,r)}}e=e.sibling}}function mu(e){var t=e.alternate;t!==null&&(e.alternate=null,mu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Nt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var gu=null,_u=!1;function vu(e,t,n){for(n=n.child;n!==null;)yu(e,t,n),n=n.sibling}function yu(e,t,n){if(Qe&&typeof Qe.onCommitFiberUnmount==`function`)try{Qe.onCommitFiberUnmount(Ze,n)}catch{}switch(n.tag){case 26:q||xl(n,t),vu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!q&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:q||xl(n,t),wl(n);var r=gu,i=_u;Sp(n.type)&&(gu=n.stateNode,_u=!1),vu(e,t,n),gm(n.stateNode,n.type,n.memoizedProps),gu=r,_u=i;break;case 5:q||xl(n,t),wl(n);case 6:if(n.tag===6&&wl(n),r=gu,i=_u,gu=null,vu(e,t,n),gu=r,_u=i,gu!==null){if(_u)try{(gu.nodeType===9?gu.body:gu.nodeName===`HTML`?gu.ownerDocument.body:gu).removeChild(n.stateNode),P=!0}catch(e){uf(n,t,e)}else try{gu.removeChild(n.stateNode),P=!0}catch(e){uf(n,t,e)}}break;case 18:gu!==null&&(_u?(e=gu,Cp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Hh(e)):Cp(gu,n.stateNode));break;case 4:r=gu,i=_u,gu=n.stateNode.containerInfo,_u=!0,vu(e,t,n),gu=r,_u=i;break;case 0:case 11:case 14:case 15:_l(2,n,t),q||_l(4,n,t),vu(e,t,n);break;case 1:q||(xl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&yl(n,t,r)),vu(e,t,n);break;case 21:vu(e,t,n);break;case 22:q=(r=q)||n.memoizedState!==null,vu(e,t,n),q=r;break;case 30:xl(n,t),vu(e,t,n);break;case 7:q||xl(n,t),vu(e,t,n);break;default:vu(e,t,n)}}function bu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Hh(e)}catch(e){uf(t,t.return,e)}}}function xu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Hh(e)}catch(e){uf(t,t.return,e)}}function Su(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new nu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new nu),t;default:throw Error(i(435,e.tag))}}function Cu(e,t){var n=Su(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=hf.bind(null,e,t);t.then(r,r)}})}function wu(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Sp(l.type)){gu=l.stateNode,_u=!1;break a}break;case 5:gu=l.stateNode,_u=!1;break a;case 3:case 4:gu=l.stateNode.containerInfo,_u=!0;break a}l=l.return}if(gu===null)throw Error(i(160));yu(s,c,o),gu=null,_u=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Eu(t,e,n),t=t.sibling}var Tu=null;function Eu(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}wu(t,e,n),Du(e),a&4&&(_l(3,e,e.return),gl(3,e),_l(5,e,e.return));break;case 1:wu(t,e,n),Du(e),a&512&&(q||r===null||xl(r,r.return)),a&64&&$l&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Tu,wu(t,e,n),Du(e),a&512&&(q||r===null||xl(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if($l)e.stateNode=fp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[jt]||r[wt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),np(r,t,n),r[wt]=e,Rt(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),np(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=Gm(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),np(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[wt]=e,Rt(r),t=r}e.stateNode=t}}else $l||Km(o,e.type,e.stateNode)}else e.stateNode=Bm(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Ol(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||q||t.parentNode.removeChild(t)):a.count--,n===null?$l||Km(o,e.type,e.stateNode):Bm(o,n,e.memoizedProps))}break;case 27:wu(t,e,n),Du(e),a&512&&(q||r===null||xl(r,r.return)),r!==null&&a&4&&Ol(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=eu,eu=!1,wu(t,e,n),eu=o,Du(e),a&512&&(q||r===null||xl(r,r.return)),e.flags&32){t=e.stateNode;try{fn(t,``),P=!0}catch(t){uf(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Ol(e,t,r===null?t:r.memoizedProps)),a&1024&&(tu=!0);break;case 6:if(wu(t,e,n),Du(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,P=!0}catch(t){uf(e,e.return,t)}}break;case 3:if(P=!1,Wm=null,o=Tu,Tu=bm(t.containerInfo),wu(t,e,n),Tu=o,Du(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{Hh(t.containerInfo)}catch(t){uf(e,e.return,t)}tu&&(tu=!1,Ou(e)),P=!1;break;case 4:a=eu,eu=$l,r=Jt(),o=Tu,Tu=bm(e.stateNode.containerInfo),wu(t,e,n),Du(e),Tu=o,P&&au&&(ou=!0),P=r,eu=a;break;case 12:wu(t,e,n),Du(e);break;case 31:wu(t,e,n),Du(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 13:wu(t,e,n),Du(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(ud=He()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=$l,l=q,u=eu;$l=c||o,eu=u||o,q=l||s,wu(t,e,n),q=l,eu=u,$l=c,Du(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||$l||q||(t=s||q,n=$l,r=q,$l=o||$l,q=t,Mu(e,2),$l=n,q=r),!o&&eu||du(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Cu(e,n))));break;case 19:wu(t,e,n),Du(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 30:a&512&&(q||r===null||xl(r,r.return)),a=Jt(),o=au,s=(n&335544064)===n,c=e.memoizedProps,au=s&&yi(c.default,c.update)!==`none`,wu(t,e,n),Du(e),s&&r!==null&&P&&(e.flags|=4),au=o,P=a;break;case 21:break;case 7:a&512&&(q||r===null||xl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:wu(t,e,n),Du(e)}}function Du(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(kl(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(El(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Tl(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;Ml(e,Al(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(fn(l,``),n.flags&=-33),Ml(e,Al(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;jl(e,Al(e),u,s);break;default:throw Error(i(161))}}catch(t){uf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Ou(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Ou(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,gh=!0,t.reset(),gh=!1),e=e.sibling}}function ku(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Au(t,e),t=t.sibling;else Ql(t,!1)}function Au(e,t){var n=e.alternate;if(n===null)Wl(e,!1);else switch(e.tag){case 3:if(su=iu=!1,Rl(),ku(t,e),!iu&&!ou){if(e=Ll,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Ep(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),su=!0}Ll=null;break;case 5:ku(t,e);break;case 4:r=iu,iu=!1,ku(t,e),iu&&(ou=!0),iu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?ku(t,e):Wl(e,!1));break;case 30:r=iu,i=Rl(),iu=!1,ku(t,e),iu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=_i(a,o),o=_i(n.memoizedProps,o);var s=yi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,zl=0,t=Zl(e,n,t,o,s,a,!0),zl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(kd(e,e.memoizedProps.onUpdate),Ll=i):i!==null&&(i.push.apply(i,Ll),Ll=i),iu=e.flags&32?!0:r;break;default:ku(t,e)}}function ju(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)uu(e,t.alternate,t),t=t.sibling}function Mu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:_l(4,n,n.return),Mu(n,r);break;case 1:xl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&yl(n,n.return,i),Mu(n,r);break;case 27:r&2&&gm(n.stateNode,n.type,n.memoizedProps);case 5:xl(n,n.return),n.tag!==5&&n.tag!==27||wl(n),Mu(n,r);break;case 6:wl(n);break;case 26:xl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||q||i.parentNode.removeChild(i),Mu(n,r);break;case 22:n.memoizedState===null&&Mu(n,r);break;case 30:xl(n,n.return),Mu(n,r);break;case 7:xl(n,n.return);default:Mu(n,r)}e=e.sibling}}function Nu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Nu(i,a,n),gl(4,a);break;case 1:if(Nu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){uf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)Co(l[i],c)}catch(e){uf(r,r.return,e)}}s&&o&64&&vl(a),bl(a,a.return);break;case 27:n&2&&Nl(a);case 5:a.tag!==5&&a.tag!==27||Cl(a),Nu(i,a,n),s&&r===null&&o&4&&Dl(a),bl(a,a.return);break;case 6:Cl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||$l||Km(bm(c.ownerDocument),a.type,c),Nu(i,a,n),s&&r===null&&o&4&&Dl(a),bl(a,a.return);break;case 12:Nu(i,a,n);break;case 31:Nu(i,a,n),s&&o&4&&bu(i,a);break;case 13:Nu(i,a,n),s&&o&4&&xu(i,a);break;case 22:a.memoizedState===null&&Nu(i,a,n),bl(a,a.return);break;case 30:Nu(i,a,n),bl(a,a.return);break;case 7:bl(a,a.return);default:Nu(i,a,n)}t=t.sibling}}function J(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Na(n))}function Y(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Na(e))}function Pu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Fu(e,t,n,r),t=t.sibling;else i&&Xl(t)}function Fu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&Yl(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Pu(e,t,n,r),a&2048&&gl(9,t);break;case 1:Pu(e,t,n,r);break;case 3:Pu(e,t,n,r),i&&su&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Na(a)));break;case 12:if(a&2048){Pu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){uf(t,t.return,e)}}else Pu(e,t,n,r);break;case 31:Pu(e,t,n,r);break;case 13:Pu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&Yl(t),o._visibility&2?Pu(e,t,n,r):(o._visibility|=2,Iu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&Yl(s),o._visibility&2?Pu(e,t,n,r):Lu(e,t)),a&2048&&J(s,t);break;case 24:Pu(e,t,n,r),a&2048&&Y(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Hl(a.child,!0),Hl(t.child,!0))),Pu(e,t,n,r);break;default:Pu(e,t,n,r)}}function Iu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Iu(a,o,s,c,i),gl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Iu(a,o,s,c,i)):u._visibility&2?Iu(a,o,s,c,i):Lu(a,o),i&&l&2048&&J(o.alternate,o);break;case 24:Iu(a,o,s,c,i),i&&l&2048&&Y(o.alternate,o);break;default:Iu(a,o,s,c,i)}t=t.sibling}}function Lu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Lu(n,r),i&2048&&J(r.alternate,r);break;case 24:Lu(n,r),i&2048&&Y(r.alternate,r);break;default:Lu(n,r)}t=t.sibling}}var Ru=8192;function zu(e,t,n){if(e.subtreeFlags&Ru)for(e=e.child;e!==null;)Bu(e,t,n),e=e.sibling}function Bu(e,t,n){switch(e.tag){case 26:zu(e,t,n),e.flags&Ru&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&Zm(n,e)):Qm(n,Tu,e.memoizedState,e.memoizedProps));break;case 5:zu(e,t,n),e.flags&Ru&&(e=e.stateNode,(t&335544128)===t&&Zm(n,e));break;case 3:case 4:var r=Tu;Tu=bm(e.stateNode.containerInfo),zu(e,t,n),Tu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ru,Ru=16777216,zu(e,t,n),Ru=r):zu(e,t,n));break;case 30:if((e.flags&Ru)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Fl===null&&(Fl=new Map),Fl.set(r,i)}zu(e,t,n);break;default:zu(e,t,n)}}function Vu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Hu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ru=r,Gu(r,e)}Vu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Uu(e),e=e.sibling}function Uu(e){switch(e.tag){case 0:case 11:case 15:Hu(e),e.flags&2048&&_l(9,e,e.return);break;case 3:Hu(e);break;case 12:Hu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Wu(e)):Hu(e);break;default:Hu(e)}}function Wu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ru=r,Gu(r,e)}Vu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:_l(8,t,t.return),Wu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Wu(t));break;default:Wu(t)}e=e.sibling}}function Gu(e,t){for(;ru!==null;){var n=ru;switch(n.tag){case 0:case 11:case 15:_l(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Na(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,ru=r;else a:for(n=e;ru!==null;){r=ru;var i=r.sibling,a=r.return;if(mu(r),r===n){ru=null;break a}if(i!==null){i.return=a,ru=i;break a}ru=a}}}var Ku={getCacheForType:function(e){var t=Ta(ja),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ta(ja).controller.signal}},qu=typeof WeakMap==`function`?WeakMap:Map,X=0,Ju=null,Z=null,Q=0,Yu=0,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0,td=0,nd=0,rd=0,id=0,ad=0,od=0,sd=null,cd=null,ld=!1,ud=0,dd=0,fd=1/0,pd=null,md=null,hd=0,gd=null,_d=null,vd=0,yd=0,bd=null,xd=null,Sd=null,Cd=null,wd=null,Td=0,Ed=null;function Dd(){return X&2&&Q!==0?Q&-Q:M.T===null?xt():Mf()}function Od(){if(ad===0){if(!(Q&536870912)||L){var e=at;at<<=1,!(at&3932160)&&(at=262144),ad=e}else ad=536870912}return e=Ao.current,e!==null&&(e.flags|=32),ad}function kd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Pp(_i(e.memoizedProps,n))),Cd===null&&(Cd=[]),Cd.push(t.bind(null,r))}}function Ad(e,t,n){(e===Ju&&(Yu===2||Yu===9)||e.cancelPendingCommit!==null)&&(Ld(e,0),Pd(e,Q,ad,!1)),mt(e,n),X&2&&e===Ju||(e===Ju&&(!(X&2)&&(rd|=n),td===4&&Pd(e,Q,ad,!1)),Cf(e))}function jd(e,t,n){if(X&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||lt(e,t),a=r?Gd(e,t):Ud(e,t,!0),o=r;do{if(a===0){Qu&&!r&&Pd(e,t,0,!1);break}if(n=e.current.alternate,o&&!Nd(n))a=Ud(e,t,!1),o=!1;else{if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=sd;var l=c.current.memoizedState.isDehydrated;if(l&&(Ld(c,s).flags|=256),s=Ud(c,s,!1),s!==2&&s!==6){if($u&&!l){c.errorRecoveryDisabledLanes|=o,rd|=o,a=4;break a}o=cd,cd=a,o!==null&&(cd===null?cd=o:cd.push.apply(cd,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Ld(e,0),Pd(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Pd(r,t,ad,!Zu);break a;case 2:cd=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=ud+300-He(),10<a)){if(Pd(r,t,ad,!Zu),ct(r,0,!0)!==0)break a;vd=t,r.timeoutHandle=gp(Md.bind(null,r,n,cd,pd,ld,t,ad,rd,od,Zu,o,`Throttled`,-0,0),a);break a}Md(r,n,cd,pd,ld,t,ad,rd,od,Zu,o,null,-0,0)}break}}while(1);Cf(e)}function Md(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:bn},Fl=null,Bu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=nh.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?ud-He():(a&4194048)===a?dd-He():0,m=eh(d,m),m!==null)?(vd=a,e.cancelPendingCommit=m(Qd.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Pd(e,a,o,!l)):Qd(e,t,a,n,r,i,o,s,c,l,u,d)}function Nd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Vr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Pd(e,t,n,r){t=ut(e,t),t&=~id,t&=~rd,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-et(i),o=1<<a;r[a]=-1,i&=~o}n!==0&>(e,n,t)}function Fd(){return X&6?!0:(wf(0,!1),!1)}function Id(){if(Z!==null){if(Yu===0)var e=Z.return;else e=Z,_a=ga=null,as(e),io=null,ao=0,e=Z;for(;e!==null;)hl(e.alternate,e),e=e.return;Z=null}}function Ld(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,_p(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),vd=0,Id(),Ju=e,Z=n=Pi(e.current,null),Q=t,Yu=0,Xu=null,Zu=!1,Qu=lt(e,t),$u=!1,od=ad=id=rd=nd=td=0,cd=sd=null,ld=!1,ed=ut(e,t),wi(),n}function Rd(e,t){z=null,M.H=lc,t===Ya||t===Za?(t=ro(),Yu=3):t===Xa?(t=ro(),Yu=4):Yu=t===Dc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Xu=t,Z===null&&(td=1,xc(e,Hi(t,e.current)))}function zd(){var e=Ao.current;return e===null?!0:(Q&4194048)===Q?jo===null:(Q&62914560)===Q||Q&536870912?e===jo:!1}function Bd(){var e=M.H;return M.H=lc,e===null?lc:e}function Vd(){var e=M.A;return M.A=Ku,e}function Hd(){td=4,Zu||(Q&4194048)!==Q&&Ao.current!==null||(Qu=!0),!(nd&134217727)&&!(rd&134217727)||Ju===null||Pd(Ju,Q,ad,!1)}function Ud(e,t,n){var r=X;X|=2;var i=Bd(),a=Vd();(Ju!==e||Q!==t)&&(pd=null,Ld(e,t)),t=!1;var o=td;a:do try{if(Yu!==0&&Z!==null){var s=Z,c=Xu;switch(Yu){case 8:Id(),o=6;break a;case 3:case 2:case 9:case 6:Ao.current===null&&(t=!0);var l=Yu;if(Yu=0,Xu=null,Yd(e,s,c,l),n&&Qu){o=0;break a}break;default:l=Yu,Yu=0,Xu=null,Yd(e,s,c,l)}}Wd(),o=td;break}catch(t){Rd(e,t)}while(1);return t&&e.shellSuspendCounter++,_a=ga=null,X=r,M.H=i,M.A=a,Z===null&&(Ju=null,Q=0,wi()),o}function Wd(){for(;Z!==null;)qd(Z)}function Gd(e,t){var n=X;X|=2;var r=Bd(),a=Vd();Ju!==e||Q!==t?(pd=null,fd=He()+500,Ld(e,t)):Qu=lt(e,t);a:do try{if(Yu!==0&&Z!==null){t=Z;var o=Xu;b:switch(Yu){case 1:Yu=0,Xu=null,Yd(e,t,o,1);break;case 2:case 9:if($a(o)){Yu=0,Xu=null,Jd(t);break}t=function(){Yu!==2&&Yu!==9||Ju!==e||(Yu=7),Cf(e)},o.then(t,t);break a;case 3:Yu=7;break a;case 4:Yu=5;break a;case 7:$a(o)?(Yu=0,Xu=null,Jd(t)):(Yu=0,Xu=null,Yd(e,t,o,7));break;case 5:var s=null;switch(Z.tag){case 26:s=Z.memoizedState;case 5:case 27:var c=Z;if(s?Ym(s):c.stateNode.complete){Yu=0,Xu=null;var l=c.sibling;if(l!==null)Z=l;else{var u=c.return;u===null?Z=null:(Z=u,Xd(u))}break b}}Yu=0,Xu=null,Yd(e,t,o,5);break;case 6:Yu=0,Xu=null,Yd(e,t,o,6);break;case 8:Id(),td=6;break a;default:throw Error(i(462))}}Kd();break}catch(t){Rd(e,t)}while(1);return _a=ga=null,M.H=r,M.A=a,X=n,Z===null?(Ju=null,Q=0,wi(),td):0}function Kd(){for(;Z!==null&&!Be();)qd(Z)}function qd(e){var t=sl(e.alternate,e,ed);e.memoizedProps=e.pendingProps,t===null?Xd(e):Z=t}function Jd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Vc(n,t,t.pendingProps,t.type,void 0,Q);break;case 11:t=Vc(n,t,t.pendingProps,t.type.render,t.ref,Q);break;case 5:as(t);var r=t;r===ra&&(L?(ua(r),r.tag===5&&r.stateNode!=null&&(ia=r.stateNode)):(ua(r),L=!0));default:hl(n,t),t=Z=Fi(t,ed),t=sl(n,t,ed)}e.memoizedProps=e.pendingProps,t===null?Xd(e):Z=t}function Yd(e,t,n,r){_a=ga=null,as(t),io=null,ao=0;var i=t.return;try{if(Ec(e,i,t,n,Q)){td=1,xc(e,Hi(n,e.current)),Z=null;return}}catch(t){if(i!==null)throw Z=i,t;td=1,xc(e,Hi(n,e.current)),Z=null;return}t.flags&32768?(L||r===1?e=!0:Qu||Q&536870912?e=!1:(Zu=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ao.current,r!==null&&r.tag===13&&(r.flags|=16384))),Zd(t,e)):Xd(t)}function Xd(e){var t=e;do{if(t.flags&32768){Zd(t,Zu);return}e=t.return;var n=pl(t.alternate,t,ed);if(n!==null){Z=n;return}if(t=t.sibling,t!==null){Z=t;return}Z=t=e}while(t!==null);td===0&&(td=5)}function Zd(e,t){do{var n=ml(e.alternate,e);if(n!==null){n.flags&=32767,Z=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Z=e;return}Z=e=n}while(e!==null);td=6,Z=null}function Qd(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do sf();while(hd!==0);if(X&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===Ju&&(Z=Ju=null,Q=0),_d=t,gd=e,vd=n,bd=a,xd=r,$d(e,t,n,s,c,l,f)}}function $d(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(yd=s,s|=Ci,ht(e,n,s,r,i,a),Cd=null,(n&335544064)===n?(wd=Ia(e),r=10262):(wd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,gf(Ke,function(){return cf(),null})):(e.callbackNode=null,e.callbackPriority=0),Pl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=M.T,M.T=null,i=N.p,N.p=2,a=X,X|=4;try{cu(e,t,n)}finally{X=a,N.p=i,M.T=r}}hd=1,Pl?Sd=Mp(o,e.containerInfo,wd,nf,rf,tf,af,cf,ef,null,null):(nf(),rf(),af())}function ef(e){if(hd!==0){var t=gd.onRecoverableError;t(e,{componentStack:null})}}function tf(){hd===3&&(hd=0,Au(_d,gd),hd=4)}function nf(){if(hd===1){hd=0;var e=gd,t=_d,n=vd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=M.T,M.T=null;var i=N.p;N.p=2;var a=X;X|=4;try{au=ou=!1,Eu(t,e,n),n=cp;var o=qr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Kr(s.ownerDocument.documentElement,s)){if(c!==null&&Jr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Gr(s,h),v=Gr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}gh=!!sp,cp=sp=null}finally{X=a,N.p=i,M.T=r}}e.current=t,hd=2}}function rf(){if(hd===2){hd=0;var e=gd,t=_d,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=M.T,M.T=null;var r=N.p;N.p=2;var i=X;X|=4;try{uu(e,t.alternate,t)}finally{X=i,N.p=r,M.T=n}}hd=3}}function af(){if(hd===4||hd===3){hd=0;var e=Sd;Sd=null,Ve();var t=gd,n=_d,r=vd,i=xd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?hd=5:(hd=0,_d=gd=null,of(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(md=null),bt(r),n=n.stateNode,Qe&&typeof Qe.onCommitFiberRoot==`function`)try{Qe.onCommitFiberRoot(Ze,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=M.T,a=N.p,N.p=2,M.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{M.T=n,N.p=a}}if(i=Cd,o=wd,wd=null,i!==null&&(Cd=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);vd&3&&sf(),Cf(t),a=t.pendingLanes,r&261930&&a&42?t===Ed?Td++:(Td=0,Ed=t):(Td=0,Ed=null),wf(0,!1)}}function of(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Na(t)))}function sf(){return Sd!==null&&(Sd.skipTransition(),Sd=null),nf(),rf(),af(),cf()}function cf(){if(hd!==5)return!1;var e=gd,t=yd;yd=0;var n=bt(vd),r=M.T,a=N.p;try{N.p=32>n?32:n,M.T=null,n=bd,bd=null;var o=gd,s=vd;if(hd=0,_d=gd=null,vd=0,X&6)throw Error(i(331));var c=X;if(X|=4,Uu(o.current),Fu(o,o.current,s,n),X=c,wf(0,!1),Qe&&typeof Qe.onPostCommitFiberRoot==`function`)try{Qe.onPostCommitFiberRoot(Ze,o)}catch{}return!0}finally{N.p=a,M.T=r,of(e,t)}}function lf(e,t,n){t=Hi(n,t),t=Cc(e.stateNode,t,2),e=_o(e,t,2),e!==null&&(mt(e,2),Cf(e))}function uf(e,t,n){if(e.tag===3)lf(e,e,n);else for(;t!==null;){if(t.tag===3){lf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(md===null||!md.has(r))){e=Hi(n,e),n=wc(2),r=_o(t,n,2),r!==null&&(Tc(n,r,t,e),mt(r,2),Cf(r));break}}t=t.return}}function df(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new qu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||($u=!0,i.add(n),e=ff.bind(null,e,t,n),t.then(e,e))}function ff(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ju===e&&(Q&n)===n&&(td===4||td===3&&(Q&62914560)===Q&&300>He()-ud?X&2?id|=n:Ld(e,0):id|=n,od===Q&&(od=0)),Cf(e)}function pf(e,t){t===0&&(t=ft()),e=Di(e,t),e!==null&&(mt(e,t),Cf(e))}function mf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),pf(e,n)}function hf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),pf(e,n)}function gf(e,t){return Re(e,t)}var _f=null,vf=null,yf=!1,bf=!1,xf=!1,Sf=0;function Cf(e){e!==vf&&e.next===null&&(vf===null?_f=vf=e:vf=vf.next=e),bf=!0,yf||(yf=!0,Af())}function wf(e,t){if(!xf&&bf){xf=!0;do for(var n=!1,r=_f;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-et(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,kf(r,a))}else a=Q,a=ct(r,r===Ju?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||lt(r,a)||(n=!0,kf(r,a))}r=r.next}while(n);xf=!1}}function Tf(){Ef()}function Ef(){bf=yf=!1;var e=0;Sf!==0&&hp()&&(e=Sf);for(var t=He(),n=null,r=_f;r!==null;){var i=r.next,a=Df(r,t);a===0?(r.next=null,n===null?_f=i:n.next=i,i===null&&(vf=n)):(n=r,(e!==0||a&3)&&(bf=!0)),r=i}hd!==0&&hd!==5||wf(e,!1),Sf!==0&&(Sf=0)}function Df(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-et(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=dt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Ju,n=Q,n=ct(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Yu===2||Yu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ze(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||lt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ze(r),bt(n)){case 2:case 8:n=Ge;break;case 32:n=Ke;break;case 268435456:n=Je;break;default:n=Ke}return r=Of.bind(null,e),n=Re(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ze(r),e.callbackPriority=2,e.callbackNode=null,2}function Of(e,t){if(hd!==0&&hd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(sf()&&e.callbackNode!==n)return null;var r=Q;return r=ct(e,e===Ju?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(jd(e,r,t),Df(e,He()),e.callbackNode!=null&&e.callbackNode===n?Of.bind(null,e):null)}function kf(e,t){if(sf())return null;jd(e,t,!0)}function Af(){bp(function(){X&6?Re(We,Tf):Ef()})}function Mf(){if(Sf===0){var e=za;e===0&&(e=it,it<<=1,!(it&261888)&&(it=256)),Sf=e}return Sf}function Pf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:yn(e)}function Ff(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Pf((i[Tt]||null).action),o=r.submitter;o&&(t=(t=o[Tt]||null)?Pf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Bn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Sf!==0){var e=new FormData(i,o);Ys(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),Ys(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var If=0;If<mi.length;If++){var Lf=mi[If];hi(Lf.toLowerCase(),`on`+(Lf[0].toUpperCase()+Lf.slice(1)))}hi(oi,`onAnimationEnd`),hi(si,`onAnimationIteration`),hi(ci,`onAnimationStart`),hi(`dblclick`,`onDoubleClick`),hi(`focusin`,`onFocus`),hi(`focusout`,`onBlur`),hi(li,`onTransitionRun`),hi(ui,`onTransitionStart`),hi(di,`onTransitionCancel`),hi(fi,`onTransitionEnd`),Ut(`onMouseEnter`,[`mouseout`,`mouseover`]),Ut(`onMouseLeave`,[`mouseout`,`mouseover`]),Ut(`onPointerEnter`,[`pointerout`,`pointerover`]),Ut(`onPointerLeave`,[`pointerout`,`pointerover`]),Ht(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Ht(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Ht(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Ht(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Ht(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Ht(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Rf=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),zf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Rf));function Bf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){bi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){bi(e)}i.currentTarget=null,a=c}}}}function $(e,t){var n=t[Dt];n===void 0&&(n=t[Dt]=new Set);var r=e+`__bubble`;n.has(r)||(Wf(t,e,2,!1),n.add(r))}function Vf(e,t,n){var r=0;t&&(r|=4),Wf(n,e,r,t)}var Hf=`_reactListening`+Math.random().toString(36).slice(2);function Uf(e){if(!e[Hf]){e[Hf]=!0,Bt.forEach(function(t){t!==`selectionchange`&&(zf.has(t)||Vf(t,!1,e),Vf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Hf]||(t[Hf]=!0,Vf(`selectionchange`,!1,t))}}function Wf(e,t,n,r){switch(Ch(t)){case 2:var i=_h;break;case 8:i=vh;break;default:i=yh}n=i.bind(null,t,n,e),i=void 0,!kn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Gf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=Pt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}En(function(){var r=a,i=Sn(n),s=[];a:{var c=pi.get(e);if(c!==void 0){var l=Bn,u=e;switch(e){case`keypress`:if(Fn(n)===0)break a;case`keydown`:case`keyup`:l=rr;break;case`focusin`:u=`focus`,l=Jn;break;case`focusout`:u=`blur`,l=Jn;break;case`beforeblur`:case`afterblur`:l=Jn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Kn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=qn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=or;break;case oi:case si:case ci:l=Yn;break;case fi:l=sr;break;case`scroll`:case`scrollend`:l=Vn;break;case`wheel`:l=cr;break;case`copy`:case`cut`:case`paste`:l=Xn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=ir;break;case`submit`:l=ar;break;case`toggle`:case`beforetoggle`:l=lr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Dn(m,p),g!=null&&d.push(Kf(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(l=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,l&&n!==xn&&(u=n.relatedTarget||n.fromElement)&&(Pt(u)||u[Et]))break a;(c||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?Pt(l):null,l!==null&&(f=o(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(c=null,l=r),c!==l&&(d=Kn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=ir,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:It(c),h=l==null?u:It(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,Pt(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=c&&l?C(c,l,Jf):null,c!==null&&Yf(s,u,c,d,!1),l!==null&&f!==null&&Yf(s,f,l,d,!0)))}a:{if(c=r?It(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=kr;else if(Cr(c)){if(Ar)_=zr;else{_=Lr;var v=Ir}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&gn(r.elementType)&&(_=kr):_=Rr;if(_&&=_(e,r)){wr(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?It(r):window,e){case`focusin`:(Cr(v)||v.contentEditable===`true`)&&(Xr=v,Zr=r,Qr=null);break;case`focusout`:Qr=Zr=Xr=null;break;case`mousedown`:$r=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:$r=!1,ei(s,n,i);break;case`selectionchange`:if(Yr)break;case`keydown`:case`keyup`:ei(s,n,i)}var y;if(dr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else yr?_r(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(mr&&n.locale!==`ko`&&(yr||b!==`onCompositionStart`?b===`onCompositionEnd`&&yr&&(y=Pn()):(jn=i,Mn=`value`in jn?jn.value:jn.textContent,yr=!0)),v=qf(r,b),0<v.length&&(b=new Zn(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=vr(n),y!==null&&(b.data=y)))),(y=pr?br(e,n):xr(e,n))&&(b=qf(r,`onBeforeInput`),0<b.length&&(v=new Zn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Ff(s,e,r,n,i)}Bf(s,t)})}function Kf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Dn(e,n),i!=null&&r.unshift(Kf(e,i,a)),i=Dn(e,t),i!=null&&r.push(Kf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Jf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Yf(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Dn(n,a),l!=null&&o.unshift(Kf(n,l,c))):i||(l=Dn(n,a),l!=null&&o.push(Kf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Xf=/\r\n?/g,Zf=/\u0000|\uFFFD/g;function Qf(e){return(typeof e==`string`?e:``+e).replace(Xf,`
|
|
299
|
-
`).replace(Zf,``)}function $f(e,t){return t=Qf(t),Qf(e)===t}function ep(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||fn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&fn(e,``+r);else return;break;case`className`:Xt(e,`class`,r);break;case`tabIndex`:Xt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Xt(e,n,r);break;case`style`:hn(e,r,o);return;case`data`:if(t!==`object`){Xt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=yn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&ep(e,t,`name`,a.name,a,null),ep(e,t,`formEncType`,a.formEncType,a,null),ep(e,t,`formMethod`,a.formMethod,a,null),ep(e,t,`formTarget`,a.formTarget,a,null)):(ep(e,t,`encType`,a.encType,a,null),ep(e,t,`method`,a.method,a,null),ep(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=yn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=bn);return;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=yn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:$(`beforetoggle`,e),$(`toggle`,e),Yt(e,`popover`,r);break;case`xlinkActuate`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Yt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=_n.get(n)||n,Yt(e,n,r);else return}P=!0}function tp(e,t,n,r,a,o){switch(n){case`style`:hn(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)fn(e,r);else if(typeof r==`number`||typeof r==`bigint`)fn(e,``+r);else return;break;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=bn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Vt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[Tt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}P=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Yt(e,n,r)}return}P=!0}function np(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:$(`error`,e),$(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,o,s,n,null)}}a&&ep(e,t,`srcSet`,n.srcSet,n,null),r&&ep(e,t,`src`,n.src,n,null);return;case`input`:$(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:ep(e,t,r,d,n,null)}}sn(e,o,c,l,u,s,a,!1);return;case`select`:for(a in $(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:ep(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&ln(e,!!r,n,!0):ln(e,!!r,t,!1);return;case`textarea`:for(s in $(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:ep(e,t,s,c,n,null)}dn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:ep(e,t,l,r,n,null)}return;case`dialog`:$(`beforetoggle`,e),$(`toggle`,e),$(`cancel`,e),$(`close`,e);break;case`iframe`:case`object`:$(`load`,e);break;case`video`:case`audio`:for(r=0;r<Rf.length;r++)$(Rf[r],e);break;case`image`:$(`error`,e),$(`load`,e);break;case`details`:$(`toggle`,e);break;case`embed`:case`source`:case`link`:$(`error`,e),$(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,u,r,n,null)}return;default:if(gn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&tp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&ep(e,t,c,r,n,null))}var rp={};function ip(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||ep(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(P=!0),o=m;break;case`name`:m!==f&&(P=!0),a=m;break;case`checked`:m!==f&&(P=!0),u=m;break;case`defaultChecked`:m!==f&&(P=!0),d=m;break;case`value`:m!==f&&(P=!0),s=m;break;case`defaultValue`:m!==f&&(P=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&ep(e,t,p,m,r,f)}}on(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||ep(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(P=!0),p=o;break;case`defaultValue`:o!==l&&(P=!0),c=o;break;case`multiple`:o!==l&&(P=!0),s=o;default:o!==l&&ep(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?ln(e,!!n,n?[]:``,!1):ln(e,!!n,t,!0)):ln(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:ep(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(P=!0),p=a;break;case`defaultValue`:a!==o&&(P=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&ep(e,t,s,a,r,o)}un(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:ep(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(P=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:ep(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&ep(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:ep(e,t,u,p,r,m)}return;default:if(gn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&tp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||tp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&ep(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||ep(e,t,f,p,r,m)}function ap(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function op(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&ap(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var sp=null,cp=null;function lp(e){return e.nodeType===9?e:e.ownerDocument}function up(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function dp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function fp(e,t,n,r){return n=lp(n).createElement(e),n[wt]=r,n[Tt]=t,np(n,e,t),Rt(n),n}function pp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var mp=null;function hp(){var e=window.event;return e&&e.type===`popstate`?e!==mp&&(mp=e,!0):(mp=null,!1)}var gp=typeof setTimeout==`function`?setTimeout:void 0,_p=typeof clearTimeout==`function`?clearTimeout:void 0,vp=typeof Promise==`function`?Promise:void 0,yp=typeof requestAnimationFrame==`function`?requestAnimationFrame:gp,bp=typeof queueMicrotask==`function`?queueMicrotask:vp===void 0?gp:function(e){return vp.resolve(null).then(e).catch(xp)};function xp(e){setTimeout(function(){throw e})}function Sp(e){return e===`head`}function Cp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Hh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_m(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_m(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[jt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_m(e.ownerDocument.body)}n=i}while(n);Hh(t)}function wp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Tp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Ep(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Dp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Op(e){return Dp(e.getBoundingClientRect(),getComputedStyle(e),e)}function kp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Dp(t,n,e)}function Ap(e){return e.documentElement.clientHeight}function jp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Mp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Ap(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Xm(f),u>$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Np(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Np.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Np.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Np.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Pp(e){return{name:e,group:new Np(`group`,e),imagePair:new Np(`image-pair`,e),old:new Np(`old`,e),new:new Np(`new`,e)}}function Fp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Fp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Bp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Rp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,Ip,e,s,r)}this._eventListeners=a}};function Ip(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Fp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Bp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Rp(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Lp,e,n,i),r.splice(t,1),a!==null&&a()}};function Lp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function Rp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function zp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Bp(e,t,n,r){if(e.length===0)return-1;r=zp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&zp(a.optionsOrUseCapture)===r)return i}return-1}Fp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Fp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,Vp,e,void 0,void 0)};function Vp(e,t){return e.tag!==6&&(e=_(e),pm(e,t))}Fp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,Hp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Vp(t[n],e);n--);};function Hp(e,t){return t.push(e),!1}Fp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=lp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,Up,e,void 0,void 0))};function Up(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Fp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,Wp,e,void 0,void 0)};function Wp(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Fp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,Gp,e,void 0,void 0);for(var n=t=0;n<Kp.length;n++){var r=Kp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Kp[t++]=r}Kp.length=t}};function Gp(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var Kp=[],qp=!1;function Jp(e,t,n){Kp.push({fragmentInstance:e,observer:t,instance:n}),qp||(qp=!0,mm(function(){qp=!1;var e=Kp;Kp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Fp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,Yp,e,void 0,void 0),e};function Yp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Fp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Fp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,Hp,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Xp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Xp(e,t,n,r,i){var a=Pt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function Zp(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Fp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,Hp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),Zp(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),Zp(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function Qp(e,t){return e=_(e),$p(e,t),!1}function $p(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function em(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Kp.length;i++){var a=Kp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Kp[r++]=a)}Kp.length=r,n.observe(e)}),$p(e,t))}function tm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Jp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nm(n),Nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[jt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lm(e.nextSibling),e===null)break}return null}function im(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lm(e.nextSibling),e===null))return null;return e}function am(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lm(e.nextSibling),e===null))return null;return e}function om(e){return e.data===`$?`||e.data===`$~`}function sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var um=null;function dm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function fm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function mm(e){yp(function(){yp(function(t){return e(t)})})}function hm(e,t,n){switch(t=lp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function gm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&ep(e,t,r,null,rp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===bn&&(e.onclick=null),Nt(e)}function _m(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Nt(e)}var vm=new Map,ym=new Set;function bm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var xm=N.d;N.d={f:Sm,r:Cm,D:Em,C:Dm,L:Om,m:km,X:jm,S:Am,M:Mm};function Sm(){var e=xm.f(),t=Fd();return e||t}function Cm(e){var t=Ft(e);t!==null&&t.tag===5&&t.type===`form`?Zs(t):xm.r(e)}var wm=typeof document>`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=an(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Rt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+an(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+an(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+an(n.imageSizes)+`"]`)):i+=`[href="`+an(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Mt]=!0,o.onload=o.onerror=function(){zt(o)}),Rt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+an(r)+`"][href="`+an(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Rt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Lt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Rt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Lt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Rt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Lt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Rt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=we.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Lt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Lt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Lt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+an(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Mt]){r.loading=1;return}}else t=e.createElement(`link`),t[Mt]=!0,t.onload=t.onerror=zt.bind(null,t),np(t,`link`,n),Rt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+an(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+an(n.href)+`"]`);if(r)return t.instance=r,Rt(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Rt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Rt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Rt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Rt(a),a):(r=n,(a=vm.get(o))&&(r=w({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Rt(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wm=null;function Gm(e,t,n){if(Wm===null){var r=new Map,i=Wm=new Map;i.set(n,r)}else i=Wm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[jt]||a[wt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Km(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Rt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Rt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$m===0&&($m=62500*op());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=nh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sh={$$typeof:te,Provider:null,Consumer:null,_currentValue:ge,_currentValue2:ge,_threadCount:0};function ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pt(0),this.hiddenUpdates=pt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function lh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Mi(3,null,null,t),e.current=a,a.stateNode=e,t=Ma(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},mo(a),e}function uh(e){return e?(e=Ai,e):Ai}function dh(e,t,n,r,i,a){i=uh(i),r.context===null?r.context=i:r.pendingContext=i,r=go(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=_o(e,r,t),n!==null&&(Ad(n,e,t),vo(n,e,t))}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(e.tag===13||e.tag===31){var t=Di(e,67108864);t!==null&&Ad(t,e,67108864),ph(e,67108864)}}function hh(e){if(e.tag===13||e.tag===31){var t=Dd();t=yt(t);var n=Di(e,t);n!==null&&Ad(n,e,t),ph(e,t)}}var gh=!0;function _h(e,t,n,r){var i=M.T;M.T=null;var a=N.p;try{N.p=2,yh(e,t,n,r)}finally{N.p=a,M.T=i}}function vh(e,t,n,r){var i=M.T;M.T=null;var a=N.p;try{N.p=8,yh(e,t,n,r)}finally{N.p=a,M.T=i}}function yh(e,t,n,r){if(gh){var i=bh(r);if(i===null)Gf(e,t,r,xh,n),Mh(e,r);else if(Ph(i,e,t,n,r))r.stopPropagation();else if(Mh(e,r),t&4&&-1<jh.indexOf(e)){for(;i!==null;){var a=Ft(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=st(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-et(o);s.entanglements[1]|=c,o&=~c}Cf(a),!(X&6)&&(fd=He()+500,wf(0,!1))}}break;case 31:case 13:s=Di(a,2),s!==null&&Ad(s,a,2),Fd(),ph(a,2)}if(a=bh(r),a===null&&Gf(e,t,r,xh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Gf(e,t,r,null,n)}}function bh(e){return e=Sn(e),Sh(e)}var xh=null;function Sh(e){if(xh=null,e=Pt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xh=e,null}function Ch(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Ue()){case We:return 2;case Ge:return 8;case Ke:case qe:return 32;case Je:return 268435456;default:return 32}default:return 32}}var wh=!1,Th=null,Eh=null,Dh=null,Oh=new Map,kh=new Map,Ah=[],jh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Mh(e,t){switch(e){case`focusin`:case`focusout`:Th=null;break;case`dragenter`:case`dragleave`:Eh=null;break;case`mouseover`:case`mouseout`:Dh=null;break;case`pointerover`:case`pointerout`:Oh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kh.delete(t.pointerId)}}function Nh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Ft(t),t!==null&&mh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ph(e,t,n,r,i){switch(t){case`focusin`:return Th=Nh(Th,e,t,n,r,i),!0;case`dragenter`:return Eh=Nh(Eh,e,t,n,r,i),!0;case`mouseover`:return Dh=Nh(Dh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Oh.set(a,Nh(Oh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kh.set(a,Nh(kh.get(a)||null,e,t,n,r,i)),!0}return!1}function Fh(e){var t=Pt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,St(e.priority,function(){hh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,St(e.priority,function(){hh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ih(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);xn=r,n.target.dispatchEvent(r),xn=null}else return t=Ft(n),t!==null&&mh(t),e.blockedOn=n,!1;t.shift()}return!0}function Lh(e,t,n){Ih(e)&&n.delete(t)}function Rh(){wh=!1,Th!==null&&Ih(Th)&&(Th=null),Eh!==null&&Ih(Eh)&&(Eh=null),Dh!==null&&Ih(Dh)&&(Dh=null),Oh.forEach(Lh),kh.forEach(Lh)}function zh(e,n){e.blockedOn===n&&(e.blockedOn=null,wh||(wh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rh)))}var Bh=null;function Vh(e){Bh!==e&&(Bh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Bh===e&&(Bh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sh(r||n)===null)continue;break}var a=Ft(n);a!==null&&(e.splice(t,3),t-=3,Ys(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hh(e){function t(t){return zh(t,e)}Th!==null&&zh(Th,e),Eh!==null&&zh(Eh,e),Dh!==null&&zh(Dh,e),Oh.forEach(t),kh.forEach(t);for(var n=0;n<Ah.length;n++){var r=Ah[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ah.length&&(n=Ah[0],n.blockedOn===null);)Fh(n),n.blockedOn===null&&Ah.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Tt]||null;if(typeof a==`function`)o||Vh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Tt]||null)s=o.formAction;else if(Sh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vh(n)}}}function Uh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Wh(e){this._internalRoot=e}Gh.prototype.render=Wh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dh(n,Dd(),e,t,null,null)},Gh.prototype.unmount=Wh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dh(e.current,2,null,e,null,null),Fd(),t[Et]=null}};function Gh(e){this._internalRoot=e}Gh.prototype.unstable_scheduleHydration=function(e){if(e){var t=xt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ah.length&&t!==0&&t<Ah[n].priority;n++);Ah.splice(n,0,e),n===0&&Fh(e)}};var Kh=n.version;if(Kh!==`19.3.1`)throw Error(i(527,Kh,`19.3.1`));N.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var qh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:M,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jh.isDisabled&&Jh.supportsFiber)try{Ze=Jh.inject(qh),Qe=Jh}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=vc,s=yc,c=bc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lh(e,1,!1,null,null,n,r,null,o,s,c,Uh),e[Et]=t.current,Uf(e),new Wh(t)}})),Ff=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Pf()}))(),If=await(await fetch(`definition.loadmap`)).text(),Lf=document.getElementById(`root`),Rf=vn(If);if(!Rf.ok||!Rf.definition){let e=document.createElement(`pre`);e.textContent=Rf.diagnostics.map(e=>vt(e,If,`definition.loadmap`)).join(`
|
|
300
|
-
`),
|
|
299
|
+
`+e.stack}}var Le=Object.prototype.hasOwnProperty,Re=t.unstable_scheduleCallback,ze=t.unstable_cancelCallback,Be=t.unstable_shouldYield,Ve=t.unstable_requestPaint,He=t.unstable_now,Ue=t.unstable_getCurrentPriorityLevel,We=t.unstable_ImmediatePriority,Ge=t.unstable_UserBlockingPriority,Ke=t.unstable_NormalPriority,qe=t.unstable_LowPriority,Je=t.unstable_IdlePriority,Ye=t.log,Xe=t.unstable_setDisableYieldValue,Ze=null,Qe=null;function $e(e){if(typeof Ye==`function`&&Xe(e),Qe&&typeof Qe.setStrictMode==`function`)try{Qe.setStrictMode(Ze,e)}catch{}}var et=Math.clz32?Math.clz32:rt,tt=Math.log,nt=Math.LN2;function rt(e){return e>>>=0,e===0?32:31-(tt(e)/nt|0)|0}var it=256,at=262144,ot=4194304;function st(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ct(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=st(n))):i=st(o):i=st(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=st(n))):i=st(o)):i=st(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function lt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ut(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-et(n),i=1<<r;t|=e[r],n&=~i}return t}function dt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ft(){var e=ot;return ot<<=1,!(ot&62914560)&&(ot=4194304),e}function pt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function mt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ht(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-et(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&>(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function gt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-et(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function _t(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-et(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function vt(e,t){var n=t&-t;return n=n&42?1:yt(n),(n&(e.suspendedLanes|t))===0?n:0}function yt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function bt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function xt(){var e=N.p;return e===0?(e=window.event,e===void 0?32:Ch(e.type)):e}function St(e,t){var n=N.p;try{return N.p=e,t()}finally{N.p=n}}var Ct=Math.random().toString(36).slice(2),wt=`__reactFiber$`+Ct,Tt=`__reactProps$`+Ct,Et=`__reactContainer$`+Ct,Dt=`__reactEvents$`+Ct,Ot=`__reactListeners$`+Ct,kt=`__reactHandles$`+Ct,At=`__reactResources$`+Ct,jt=`__reactMarker$`+Ct,Mt=`__reactLoad$`+Ct;function Nt(e){delete e[wt],delete e[Tt],delete e[Ot],delete e[kt]}function Pt(e){var t;if(t=e[wt])return t;for(var n=e.parentNode;n;){if(t=n[Et]||n[wt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=fm(e);e!==null;){if(n=e[wt])return n;e=fm(e)}return t}e=n,n=e.parentNode}return null}function Ft(e){if(e=e[wt]||e[Et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function It(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Lt(e){var t=e[At];return t||=e[At]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Rt(e){e[jt]=!0}function zt(e){e[Mt]=void 0}var Bt=new Set,Vt={};function Ht(e,t){Ut(e,t),Ut(e+`Capture`,t)}function Ut(e,t){for(Vt[e]=t,e=0;e<t.length;e++)Bt.add(t[e])}var Wt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Gt={},Kt={};function qt(e){return Le.call(Kt,e)?!0:Le.call(Gt,e)?!1:Wt.test(e)?Kt[e]=!0:(Gt[e]=!0,!1)}var P=!1;function Jt(){var e=P;return P=!1,e}function Yt(e,t,n){if(qt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Xt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function Zt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function Qt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function $t(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function en(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function tn(e){if(!e._valueTracker){var t=$t(e)?`checked`:`value`;e._valueTracker=en(e,t,``+e[t])}}function nn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=$t(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var rn=/[\n"\\]/g;function an(e){return e.replace(rn,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function on(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Qt(t)):e.value!==``+Qt(t)&&(e.value=``+Qt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):cn(e,Qt(n)):o===`number`&&e.value==t?cn(e,Qt(e.value)):cn(e,Qt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Qt(s):e.removeAttribute(`name`)}function sn(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){tn(e);return}n=n==null?``:``+Qt(n),t=t==null?n:``+Qt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),tn(e)}function cn(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function ln(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Qt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function un(e,t,n){t!=null&&(t=``+Qt(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+Qt(n)}function dn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(he(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Qt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),tn(e)}function fn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function mn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||pn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function hn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,P=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(mn(e,a,r),P=!0)}else for(var o in t)t.hasOwnProperty(o)&&mn(e,o,t[o])}function gn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var _n=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),vn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function yn(e){return vn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function bn(){}var xn=null;function Sn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Cn=null,wn=null;function Tn(e){var t=Ft(e);if(t&&(e=t.stateNode)){var n=e[Tt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(on(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+an(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Tt]||null;if(!a)throw Error(i(90));on(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&nn(r)}break a;case`textarea`:un(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&ln(e,!!n.multiple,t,!1)}}}var F=!1;function En(e,t,n){if(F)return e(t,n);F=!0;try{return e(t)}finally{if(F=!1,(Cn!==null||wn!==null)&&(Fd(),Cn&&(t=Cn,e=wn,wn=Cn=null,Tn(t),e)))for(t=0;t<e.length;t++)Tn(e[t])}}function Dn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Tt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var On=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,kn=!1;if(On)try{var An={};Object.defineProperty(An,"passive",{get:function(){kn=!0}}),window.addEventListener(`test`,An,An),window.removeEventListener(`test`,An,An)}catch{kn=!1}var jn=null,Mn=null,Nn=null;function Pn(){if(Nn)return Nn;var e,t=Mn,n=t.length,r,i=`value`in jn?jn.value:jn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Nn=i.slice(e,1<r?1-r:void 0)}function Fn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function In(){return!0}function Ln(){return!1}function Rn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?In:Ln,this.isPropagationStopped=Ln,this}return w(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=In)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=In)},persist:function(){},isPersistent:In}),t}var zn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bn=Rn(zn),I=w({},zn,{view:0,detail:0}),Vn=Rn(I),Hn,Un,Wn,Gn=w({},I,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nr,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Wn&&(Wn&&e.type===`mousemove`?(Hn=e.screenX-Wn.screenX,Un=e.screenY-Wn.screenY):Un=Hn=0,Wn=e),Hn)},movementY:function(e){return`movementY`in e?e.movementY:Un}}),Kn=Rn(Gn),qn=Rn(w({},Gn,{dataTransfer:0})),Jn=Rn(w({},I,{relatedTarget:0})),Yn=Rn(w({},zn,{animationName:0,elapsedTime:0,pseudoElement:0})),Xn=Rn(w({},zn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Zn=Rn(w({},zn,{data:0})),Qn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},$n={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},er={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function tr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=er[e])?!!t[e]:!1}function nr(){return tr}var rr=Rn(w({},I,{key:function(e){if(e.key){var t=Qn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Fn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?$n[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nr,charCode:function(e){return e.type===`keypress`?Fn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Fn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),ir=Rn(w({},Gn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),ar=Rn(w({},zn,{submitter:0})),or=Rn(w({},I,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nr})),sr=Rn(w({},zn,{propertyName:0,elapsedTime:0,pseudoElement:0})),cr=Rn(w({},Gn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),lr=Rn(w({},zn,{newState:0,oldState:0,source:0})),ur=[9,13,27,32],dr=On&&`CompositionEvent`in window,fr=null;On&&`documentMode`in document&&(fr=document.documentMode);var pr=On&&`TextEvent`in window&&!fr,mr=On&&(!dr||fr&&8<fr&&11>=fr),hr=` `,gr=!1;function _r(e,t){switch(e){case`keyup`:return ur.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function vr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var yr=!1;function br(e,t){switch(e){case`compositionend`:return vr(t);case`keypress`:return t.which===32?(gr=!0,hr):null;case`textInput`:return e=t.data,e===hr&&gr?null:e;default:return null}}function xr(e,t){if(yr)return e===`compositionend`||!dr&&_r(e,t)?(e=Pn(),Nn=Mn=jn=null,yr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return mr&&t.locale!==`ko`?null:t.data;default:return null}}var Sr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Cr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Sr[e.type]:t===`textarea`}function wr(e,t,n,r){Cn?wn?wn.push(r):wn=[r]:Cn=r,t=qf(t,`onChange`),0<t.length&&(n=new Bn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Tr=null,Er=null;function Dr(e){Rf(e,0)}function Or(e){if(nn(It(e)))return e}function kr(e,t){if(e===`change`)return t}var Ar=!1;if(On){var jr;if(On){var Mr=`oninput`in document;if(!Mr){var Nr=document.createElement(`div`);Nr.setAttribute(`oninput`,`return;`),Mr=typeof Nr.oninput==`function`}jr=Mr}else jr=!1;Ar=jr&&(!document.documentMode||9<document.documentMode)}function Pr(){Tr&&(Tr.detachEvent(`onpropertychange`,Fr),Er=Tr=null)}function Fr(e){if(e.propertyName===`value`&&Or(Er)){var t=[];wr(t,Er,e,Sn(e)),En(Dr,t)}}function Ir(e,t,n){e===`focusin`?(Pr(),Tr=t,Er=n,Tr.attachEvent(`onpropertychange`,Fr)):e===`focusout`&&Pr()}function Lr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Or(Er)}function Rr(e,t){if(e===`click`)return Or(t)}function zr(e,t){if(e===`input`||e===`change`)return Or(t)}function Br(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Vr=typeof Object.is==`function`?Object.is:Br;function Hr(e,t){if(Vr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Le.call(t,i)||!Vr(e[i],t[i]))return!1}return!0}function Ur(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Wr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Gr(e,t){var n=Wr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Wr(n)}}function Kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ur(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ur(e.document)}return t}function Jr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Yr=On&&`documentMode`in document&&11>=document.documentMode,Xr=null,Zr=null,Qr=null,$r=!1;function ei(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$r||Xr==null||Xr!==Ur(r)||(r=Xr,`selectionStart`in r&&Jr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Qr&&Hr(Qr,r)||(Qr=r,r=qf(Zr,`onSelect`),0<r.length&&(t=new Bn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Xr)))}function ti(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ni={animationend:ti(`Animation`,`AnimationEnd`),animationiteration:ti(`Animation`,`AnimationIteration`),animationstart:ti(`Animation`,`AnimationStart`),transitionrun:ti(`Transition`,`TransitionRun`),transitionstart:ti(`Transition`,`TransitionStart`),transitioncancel:ti(`Transition`,`TransitionCancel`),transitionend:ti(`Transition`,`TransitionEnd`)},ri={},ii={};On&&(ii=document.createElement(`div`).style,`AnimationEvent`in window||(delete ni.animationend.animation,delete ni.animationiteration.animation,delete ni.animationstart.animation),`TransitionEvent`in window||delete ni.transitionend.transition);function ai(e){if(ri[e])return ri[e];if(!ni[e])return e;var t=ni[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ii)return ri[e]=t[n];return e}var oi=ai(`animationend`),si=ai(`animationiteration`),ci=ai(`animationstart`),li=ai(`transitionrun`),ui=ai(`transitionstart`),di=ai(`transitioncancel`),fi=ai(`transitionend`),pi=new Map,mi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);mi.push(`scrollEnd`);function hi(e,t){pi.set(e,t),Ht(t,[e])}var gi=0;function _i(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=gd.identifierPrefix;var n=gi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function vi(e){if(e==null||typeof e==`string`)return e;var t=null,n=wd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function yi(e,t){return e=vi(e),t=vi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var bi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},xi=[],Si=0,Ci=0;function wi(){for(var e=Si,t=Ci=Si=0;t<e;){var n=xi[t];xi[t++]=null;var r=xi[t];xi[t++]=null;var i=xi[t];xi[t++]=null;var a=xi[t];if(xi[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Oi(n,i,a)}}function Ti(e,t,n,r){xi[Si++]=e,xi[Si++]=t,xi[Si++]=n,xi[Si++]=r,Ci|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Ei(e,t,n,r){return Ti(e,t,n,r),ki(e)}function Di(e,t){return Ti(e,null,null,t),ki(e)}function Oi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-et(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ki(e){if(50<Td)throw Td=0,Ed=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Ai={};function ji(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Mi(e,t,n,r){return new ji(e,t,n,r)}function Ni(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Pi(e,t){var n=e.alternate;return n===null?(n=Mi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Fi(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ii(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)Ni(r)&&(s=1);else if(typeof r==`string`)s=qm(e,n,Se.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case oe:return e=Mi(31,n,t,a),e.elementType=oe,e.lanes=o,e;case O:return Li(n.children,a,o,t);case ee:s=8,a|=24;break;case k:return e=Mi(12,n,t,a|2),e.elementType=k,e.lanes=o,e;case re:return e=Mi(13,n,t,a),e.elementType=re,e.lanes=o,e;case ie:return e=Mi(19,n,t,a),e.elementType=ie,e.lanes=o,e;case se:case le:return e=a|32,e=Mi(30,n,t,e),e.elementType=le,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case te:s=10;break a;case A:s=9;break a;case ne:s=11;break a;case ae:s=14;break a;case j:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Mi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Li(e,t,n,r){return e=Mi(7,e,r,t),e.lanes=n,e}function Ri(e,t,n){return e=Mi(6,e,null,t),e.lanes=n,e}function zi(e){var t=Mi(18,null,null,0);return t.stateNode=e,t}function Bi(e,t,n){return t=Mi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Vi=new WeakMap;function Hi(e,t){if(typeof e==`object`&&e){var n=Vi.get(e);return n===void 0?(t={value:e,source:t,stack:Ie(t)},Vi.set(e,t),t):n}return{value:e,source:t,stack:Ie(t)}}var Ui=[],Wi=0,Gi=null,Ki=0,qi=[],Ji=0,Yi=null,Xi=1,Zi=``;function Qi(e,t){Ui[Wi++]=Ki,Ui[Wi++]=Gi,Gi=e,Ki=t}function $i(e,t,n){qi[Ji++]=Xi,qi[Ji++]=Zi,qi[Ji++]=Yi,Yi=e;var r=Xi;e=Zi;var i=32-et(r)-1;r&=~(1<<i),n+=1;var a=32-et(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Xi=1<<32-et(t)+i|n<<i|r,Zi=a+e}else Xi=1<<a|n<<i|r,Zi=e}function ea(e){e.return!==null&&(Qi(e,1),$i(e,1,0))}function ta(e){for(;e===Gi;)Gi=Ui[--Wi],Ui[Wi]=null,Ki=Ui[--Wi],Ui[Wi]=null;for(;e===Yi;)Yi=qi[--Ji],qi[Ji]=null,Zi=qi[--Ji],qi[Ji]=null,Xi=qi[--Ji],qi[Ji]=null}function na(e,t){qi[Ji++]=Xi,qi[Ji++]=Zi,qi[Ji++]=Yi,Xi=t.id,Zi=t.overflow,Yi=e}var ra=null,ia=null,L=!1,aa=null,oa=!1,sa=Error(i(519));function ca(e){throw ma(Hi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),sa}function la(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[wt]=e,t[Tt]=r,n){case`dialog`:$(`cancel`,t),$(`close`,t);break;case`iframe`:case`object`:case`embed`:$(`load`,t);break;case`video`:case`audio`:for(n=0;n<If.length;n++)$(If[n],t);break;case`source`:$(`error`,t);break;case`img`:case`image`:case`link`:$(`error`,t),$(`load`,t);break;case`details`:$(`toggle`,t);break;case`input`:$(`invalid`,t),sn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:$(`invalid`,t);break;case`textarea`:$(`invalid`,t),dn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||$f(t.textContent,n)?(r.popover!=null&&($(`beforetoggle`,t),$(`toggle`,t)),r.onScroll!=null&&$(`scroll`,t),r.onScrollEnd!=null&&$(`scrollend`,t),r.onClick!=null&&(t.onclick=bn),t=!0):t=!1,t||ca(e,!0)}function ua(e){for(ra=e.return;ra;)switch(ra.tag){case 5:case 31:case 13:oa=!1;return;case 27:case 3:oa=!0;return;default:ra=ra.return}}function da(e){if(e!==ra)return!1;if(!L)return ua(e),L=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||pp(e.type,e.memoizedProps)),n=!n),n&&ia&&ca(e),ua(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ia=dm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ia=dm(e)}else t===27?(t=ia,Sp(e.type)?(e=um,um=null,ia=e):ia=t):ia=ra?lm(e.stateNode.nextSibling):null;return!0}function fa(){ia=ra=null,L=!1}function pa(){var e=aa;return e!==null&&(cd===null?cd=e:cd.push.apply(cd,e),aa=null),e}function ma(e){aa===null?aa=[e]:aa.push(e)}var ha=ye(null),ga=null,_a=null;function va(e,t,n){xe(ha,t._currentValue),t._currentValue=n}function ya(e){e._currentValue=ha.current,be(ha)}function ba(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function xa(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ba(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ba(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),ba(a.return,n,e),s=a.child,s=s===null?null:s.sibling):s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Sa(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Vr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===Te.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[sh]:e.push(sh))}a=a.return}return e!==null&&xa(t,e,n,r),t.flags|=262144,e!==null}function Ca(e){for(e=e.firstContext;e!==null;){if(!Vr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function wa(e){ga=e,_a=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ta(e){return Da(ga,e)}function Ea(e,t){return ga===null&&wa(e),Da(e,t)}function Da(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},_a===null){if(e===null)throw Error(i(308));_a=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else _a=_a.next=t;return n}var Oa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ka=t.unstable_scheduleCallback,Aa=t.unstable_NormalPriority,ja={$$typeof:te,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ma(){return{controller:new Oa,data:new Map,refCount:0}}function Na(e){e.refCount--,e.refCount===0&&ka(Aa,function(){e.controller.abort()})}function Pa(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Fa=null;function Ia(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var La=null,Ra=0,za=0,Ba=null;function Va(e,t){if(La===null){var n=La=[];Ra=0,za=jf(),Ba={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ra++,t.then(Ha,Ha),t}function Ha(){if(--Ra===0&&(Fa=null,La!==null)){Ba!==null&&(Ba.status=`fulfilled`);var e=La;La=null,za=0,Ba=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ua(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Wa=M.S;M.S=function(e,t){if(dd=He(),typeof t==`object`&&t&&typeof t.then==`function`&&Va(e,t),Fa!==null)for(var n=_f;n!==null;)Pa(n,Fa),n=n.next;if(n=e.types,n!==null){for(var r=_f;r!==null;)Pa(r,n),r=r.next;if(za!==0){r=Fa,r===null&&(r=Fa=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Wa!==null&&Wa(e,t)};var Ga=ye(null);function Ka(){var e=Ga.current;return e===null?Ju.pooledCache:e}function qa(e,t){t===null?xe(Ga,Ga.current):xe(Ga,t.pool)}function Ja(){var e=Ka();return e===null?null:{parent:ja._currentValue,pool:e}}var Ya=Error(i(460)),Xa=Error(i(474)),Za=Error(i(542)),Qa={then:function(){}};function $a(e){return e=e.status,e===`fulfilled`||e===`rejected`}function eo(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(bn,bn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,R(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(bn,bn);else{if(e=Ju,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,R(e),e}throw no=t,Ya}}function to(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(no=e,Ya):e}}var no=null;function ro(){if(no===null)throw Error(i(459));var e=no;return no=null,e}function R(e){if(e===Ya||e===Za)throw Error(i(483))}var io=null,ao=0;function oo(e){var t=ao;return ao+=1,io===null&&(io=[]),eo(io,e,t)}function so(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function co(e,t){throw t.$$typeof===T?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function lo(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Pi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Ri(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===O?(e=d(e,t,n.props.children,r,n.key),so(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===j&&to(i)===t.type)?(t=a(t,n.props),so(t,n),t.return=e,t):(t=Ii(n.type,n.key,n.props,null,e.mode,r),so(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Bi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=Li(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Ri(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case E:return n=Ii(t.type,t.key,t.props,null,e.mode,n),so(n,t),n.return=e,n;case D:return t=Bi(t,e.mode,n),t.return=e,t;case j:return t=to(t),f(e,t,n)}if(he(t)||fe(t))return t=Li(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,oo(t),n);if(t.$$typeof===te)return f(e,Ea(e,t),n);co(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case E:return n.key===i?l(e,t,n,r):null;case D:return n.key===i?u(e,t,n,r):null;case j:return n=to(n),p(e,t,n,r)}if(he(n)||fe(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,oo(n),r);if(n.$$typeof===te)return p(e,t,Ea(e,n),r);co(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case E:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case D:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case j:return r=to(r),m(e,t,n,r,i)}if(he(r)||fe(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,oo(r),i);if(r.$$typeof===te)return m(e,t,n,Ea(t,r),i);co(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),L&&Qi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return L&&Qi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),L&&Qi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),L&&Qi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return L&&Qi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),L&&Qi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===O&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case E:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===O){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),so(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===j&&to(l)===r.type){n(e,r.sibling),c=a(r,o.props),so(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===O?(c=Li(o.props.children,e.mode,c,o.key),so(c,o),c.return=e,e=c):(c=Ii(o.type,o.key,o.props,null,e.mode,c),so(c,o),c.return=e,e=c)}return s(e);case D:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Bi(o,e.mode,c),c.return=e,e=c}return s(e);case j:return o=to(o),_(e,r,o,c)}if(he(o))return h(e,r,o,c);if(fe(o)){if(l=fe(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,oo(o),c);if(o.$$typeof===te)return _(e,r,Ea(e,o),c);co(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Ri(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ao=0;var i=_(e,t,n,r);return io=null,i}catch(t){if(t===Ya||t===Za)throw t;var a=Mi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var uo=lo(!0),fo=lo(!1),po=!1;function mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ho(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function go(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function _o(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,X&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ki(e),Oi(e,null,n),t}return Ti(e,r,t,n),ki(e)}function vo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}function yo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var bo=!1;function xo(){if(bo){var e=Ba;if(e!==null)throw e}}function So(e,t,n,r){bo=!1;var i=e.updateQueue;po=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Q&f)===f:(r&f)===f){f!==0&&f===za&&(bo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:po=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),nd|=o,e.lanes=o,e.memoizedState=d}}function Co(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function wo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Co(n[e],t)}var To=ye(null),Eo=ye(0);function Do(e,t){e=ed,xe(Eo,e),xe(To,t),ed=e|t.baseLanes}function Oo(){xe(Eo,ed),xe(To,To.current)}function ko(){ed=Eo.current,be(To),be(Eo)}var Ao=ye(null),jo=null;function Mo(e){var t=e.alternate;xe(Lo,Lo.current&1),xe(Ao,e),jo===null&&(t===null||To.current!==null||t.memoizedState!==null)&&(jo=e)}function No(e){xe(Lo,Lo.current),xe(Ao,e),jo===null&&(jo=e)}function Po(e){e.tag===22?(xe(Lo,Lo.current),xe(Ao,e),jo===null&&(jo=e)):Fo()}function Fo(){xe(Lo,Lo.current),xe(Ao,Ao.current)}function Io(e){be(Ao),jo===e&&(jo=null),be(Lo)}var Lo=ye(0);function Ro(e,t){xe(Ao,Ao.current),xe(Lo,t)}function zo(e){be(Lo),be(Ao),jo===e&&(jo=null)}function Bo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||om(n)||sm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Vo=0,z=null,Ho=null,Uo=null,Wo=!1,Go=!1,Ko=!1,qo=0,Jo=0,Yo=null,Xo=0;function Zo(){throw Error(i(321))}function Qo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Vr(e[n],t[n]))return!1;return!0}function $o(e,t,n,r,i,a){return Vo=a,z=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,M.H=e===null||e.memoizedState===null?uc:dc,Ko=!1,a=n(r,i),Ko=!1,Go&&(a=ts(t,n,r,i)),es(e),a}function es(e){M.H=lc;var t=Ho!==null&&Ho.next!==null;if(Vo=0,Uo=Ho=z=null,Wo=!1,Jo=0,Yo=null,t)throw Error(i(300));e===null||Oc||(e=e.dependencies,e!==null&&Ca(e)&&(Oc=!0))}function ts(e,t,n,r){z=e;var a=0;do{if(Go&&(Yo=null),Jo=0,Go=!1,25<=a)throw Error(i(301));if(a+=1,Uo=Ho=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}M.H=fc,o=t(n,r)}while(Go);return o}function ns(){var e=M.H,t=e.useState()[0];return t=typeof t.then==`function`?ls(t):t,e=e.useState()[0],(Ho===null?null:Ho.memoizedState)!==e&&(z.flags|=1024),t}function rs(){var e=qo!==0;return qo=0,e}function is(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function as(e){if(Wo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Wo=!1}Vo=0,Uo=Ho=z=null,Go=!1,Jo=qo=0,Yo=null}function os(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Uo===null?z.memoizedState=Uo=e:Uo=Uo.next=e,Uo}function ss(){if(Ho===null){var e=z.alternate;e=e===null?null:e.memoizedState}else e=Ho.next;var t=Uo===null?z.memoizedState:Uo.next;if(t!==null)Uo=t,Ho=e;else{if(e===null)throw z.alternate===null?Error(i(467)):Error(i(310));Ho=e,e={memoizedState:Ho.memoizedState,baseState:Ho.baseState,baseQueue:Ho.baseQueue,queue:Ho.queue,next:null},Uo===null?z.memoizedState=Uo=e:Uo=Uo.next=e}return Uo}function cs(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ls(e){var t=Jo;return Jo+=1,Yo===null&&(Yo=[]),e=eo(Yo,e,t),t=z,(Uo===null?t.memoizedState:Uo.next)===null&&(t=t.alternate,M.H=t===null||t.memoizedState===null?uc:dc),e}function us(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ls(e);if(e.$$typeof===ue)return;if(e.$$typeof===te)return Ta(e)}throw Error(i(438,String(e)))}function ds(e){var t=null,n=z.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=z.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=cs(),z.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ce;return t.index++,n}function fs(e,t){return typeof t==`function`?t(e):t}function ps(e){return ms(ss(),Ho,e)}function ms(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Vo&f)===f:(Q&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===za&&(d=!0);else if((Vo&p)===p){u=u.next,p===za&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,z.lanes|=p,nd|=p;f=u.action,Ko&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,z.lanes|=f,nd|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Vr(o,e.memoizedState)&&(Oc=!0,d&&(n=Ba,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function hs(e){var t=ss(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Vr(o,t.memoizedState)||(Oc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function B(e,t,n){var r=z,a=ss(),o=L;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Vr((Ho||a).memoizedState,n);if(s&&(a.memoizedState=n,Oc=!0),a=a.queue,Fs(V.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Uo!==null&&!!(Uo.memoizedState.tag&1),As(e?9:8,{destroy:void 0},_s.bind(null,r,a,n,t),null),e){if(r.flags|=2048,Ju===null)throw Error(i(349));o||Vo&127||gs(r,t,n)}return n}function gs(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=z.updateQueue,t===null?(t=cs(),z.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function _s(e,t,n,r){t.value=n,t.getSnapshot=r,vs(t)&&ys(e)}function V(e,t,n){return n(function(){vs(t)&&ys(e)})}function vs(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Vr(e,n)}catch{return!0}}function ys(e){var t=Di(e,2);t!==null&&Ad(t,e,2)}function H(e){var t=os();if(typeof e==`function`){var n=e;if(e=n(),Ko){$e(!0);try{n()}finally{$e(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:e},t}function bs(e,t,n,r){return e.baseState=n,ms(e,Ho,typeof r==`function`?r:fs)}function xs(e,t,n,r,a){if(oc(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};M.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ss(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ss(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=M.T,o={};o.types=a===null?null:a.types,M.T=o;try{var s=n(i,r),c=M.S;c!==null&&c(o,s),Cs(e,t,s)}catch(n){Ts(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),M.T=a}}else try{a=n(i,r),Cs(e,t,a)}catch(n){Ts(e,t,n)}}function Cs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ws(e,t,n)},function(n){return Ts(e,t,n)}):ws(e,t,n)}function ws(e,t,n){t.status=`fulfilled`,t.value=n,Es(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ss(e,n)))}function Ts(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Es(t),t=t.next;while(t!==r)}e.action=null}function Es(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function U(e,t){return t}function Ds(e,t){if(L){var n=Ju.formState;if(n!==null){a:{var r=z;if(L){if(ia){b:{for(var i=ia,a=oa;i.nodeType!==8;)if(!a||(i=lm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){ia=lm(i.nextSibling),r=i.data===`F!`;break a}}ca(r)}r=!1}r&&(t=n[0])}}return n=os(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:U,lastRenderedState:t},n.queue=r,n=rc.bind(null,z,r),r.dispatch=n,r=H(!1),a=ac.bind(null,z,!1,r.queue),r=os(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=xs.bind(null,z,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function W(e){return G(ss(),Ho,e)}function G(e,t,n){if(t=ms(e,t,U)[0],e=ps(fs)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ls(t)}catch(e){throw e===Ya?Za:e}else r=t;t=ss();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(z.flags|=2048,As(9,{destroy:void 0},Os.bind(null,i,n),null)),[r,a,e]}function Os(e,t){e.action=t}function ks(e){var t=ss(),n=Ho;if(n!==null)return G(t,n,e);ss(),t=t.memoizedState,n=ss();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function As(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=z.updateQueue,t===null&&(t=cs(),z.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function js(){return ss().memoizedState}function Ms(e,t,n,r){var i=os();z.flags|=e,i.memoizedState=As(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ns(e,t,n,r){var i=ss();r=r===void 0?null:r;var a=i.memoizedState.inst;Ho!==null&&r!==null&&Qo(r,Ho.memoizedState.deps)?i.memoizedState=As(t,a,n,r):(z.flags|=e,i.memoizedState=As(1|t,a,n,r))}function Ps(e,t){Ms(8390656,8,e,t)}function Fs(e,t){Ns(2048,8,e,t)}function Is(e){z.flags|=4;var t=z.updateQueue;if(t===null)t=cs(),z.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Ls(e){var t=ss().memoizedState;return Is({ref:t,nextImpl:e}),function(){if(X&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Rs(e,t){return Ns(4,2,e,t)}function zs(e,t){return Ns(4,4,e,t)}function Bs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Vs(e,t,n){n=n==null?null:n.concat([e]),Ns(4,4,Bs.bind(null,t,e),n)}function Hs(){}function Us(e,t){var n=ss();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Qo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ws(e,t){var n=ss();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Qo(t,r[1]))return r[0];if(r=e(),Ko){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r}function Gs(e,t,n){return n===void 0||Vo&1073741824&&!(Q&261930)?e.memoizedState=t:(e.memoizedState=n,e=Od(),z.lanes|=e,nd|=e,n)}function Ks(e,t,n,r){return Vr(n,t)?n:To.current===null?!(Vo&106)||Vo&1073741824&&!(Q&261930)?(Oc=!0,e.memoizedState=n):(e=Od(),z.lanes|=e,nd|=e,t):(e=Gs(e,n,r),Vr(e,t)||(Oc=!0),e)}function qs(e,t,n,r,i){var a=N.p;N.p=a!==0&&8>a?a:8;var o=M.T,s={};s.types=o===null?null:o.types,M.T=s,ac(e,!1,t,n);try{var c=i(),l=M.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ic(e,t,Ua(c,r),Dd(e)):ic(e,t,r,Dd(e))}catch(n){ic(e,t,{then:function(){},status:`rejected`,reason:n},Dd())}finally{N.p=a,o!==null&&s.types!==null&&(o.types=s.types),M.T=o}}function Js(){}function Ys(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Xs(e).queue;qs(e,a,t,ge,n===null?Js:function(){return Zs(e),n(r)})}function Xs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ge,baseState:ge,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:ge},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Zs(e){var t=Xs(e);t.next===null&&(t=e.alternate.memoizedState),ic(e,t.next.queue,{},Dd())}function Qs(){return Ta(sh)}function $s(){return ss().memoizedState}function ec(){return ss().memoizedState}function tc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Dd();e=go(n);var r=_o(t,e,n);r!==null&&(Ad(r,t,n),vo(r,t,n)),t={cache:Ma()},e.payload=t;return}t=t.return}}function nc(e,t,n){var r=Dd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},oc(e)?sc(t,n):(n=Ei(e,t,n,r),n!==null&&(Ad(n,e,r),cc(n,t,r)))}function rc(e,t,n){ic(e,t,n,Dd())}function ic(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(oc(e))sc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Vr(s,o))return Ti(e,t,i,0),Ju===null&&wi(),!1}catch{}if(n=Ei(e,t,i,r),n!==null)return Ad(n,e,r),cc(n,t,r),!0}return!1}function ac(e,t,n,r){if(r={lane:2,revertLane:jf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},oc(e)){if(t)throw Error(i(479))}else t=Ei(e,n,r,2),t!==null&&Ad(t,e,2)}function oc(e){var t=e.alternate;return e===z||t!==null&&t===z}function sc(e,t){Go=Wo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function cc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}var lc={readContext:Ta,use:us,useCallback:Zo,useContext:Zo,useEffect:Zo,useImperativeHandle:Zo,useLayoutEffect:Zo,useInsertionEffect:Zo,useMemo:Zo,useReducer:Zo,useRef:Zo,useState:Zo,useDebugValue:Zo,useDeferredValue:Zo,useTransition:Zo,useSyncExternalStore:Zo,useId:Zo,useHostTransitionStatus:Zo,useFormState:Zo,useActionState:Zo,useOptimistic:Zo,useMemoCache:Zo,useCacheRefresh:Zo,useEffectEvent:Zo},uc={readContext:Ta,use:us,useCallback:function(e,t){return os().memoizedState=[e,t===void 0?null:t],e},useContext:Ta,useEffect:Ps,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ms(4194308,4,Bs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ms(4194308,4,e,t)},useInsertionEffect:function(e,t){Ms(4,2,e,t)},useMemo:function(e,t){var n=os();t=t===void 0?null:t;var r=e();if(Ko){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=os();if(n!==void 0){var i=n(t);if(Ko){$e(!0);try{n(t)}finally{$e(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=nc.bind(null,z,e),[r.memoizedState,e]},useRef:function(e){var t=os();return e={current:e},t.memoizedState=e},useState:function(e){e=H(e);var t=e.queue,n=rc.bind(null,z,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Hs,useDeferredValue:function(e,t){return Gs(os(),e,t)},useTransition:function(){var e=H(!1);return e=qs.bind(null,z,e.queue,!0,!1),os().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=z,a=os();if(L){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ju===null)throw Error(i(349));Q&127||gs(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Ps(V.bind(null,r,o,e),[e]),r.flags|=2048,As(9,{destroy:void 0},_s.bind(null,r,o,n,t),null),n},useId:function(){var e=os(),t=Ju.identifierPrefix;if(L){var n=Zi,r=Xi;n=(r&~(1<<32-et(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=qo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Xo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Qs,useFormState:Ds,useActionState:Ds,useOptimistic:function(e){var t=os();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=ac.bind(null,z,!0,n),n.dispatch=t,[e,t]},useMemoCache:ds,useCacheRefresh:function(){return os().memoizedState=tc.bind(null,z)},useEffectEvent:function(e){var t=os(),n={impl:e};return t.memoizedState=n,function(){if(X&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},dc={readContext:Ta,use:us,useCallback:Us,useContext:Ta,useEffect:Fs,useImperativeHandle:Vs,useInsertionEffect:Rs,useLayoutEffect:zs,useMemo:Ws,useReducer:ps,useRef:js,useState:function(){return ps(fs)},useDebugValue:Hs,useDeferredValue:function(e,t){return Ks(ss(),Ho.memoizedState,e,t)},useTransition:function(){var e=ps(fs)[0],t=ss().memoizedState;return[typeof e==`boolean`?e:ls(e),t]},useSyncExternalStore:B,useId:$s,useHostTransitionStatus:Qs,useFormState:W,useActionState:W,useOptimistic:function(e,t){return bs(ss(),Ho,e,t)},useMemoCache:ds,useCacheRefresh:ec,useEffectEvent:Ls},fc={readContext:Ta,use:us,useCallback:Us,useContext:Ta,useEffect:Fs,useImperativeHandle:Vs,useInsertionEffect:Rs,useLayoutEffect:zs,useMemo:Ws,useReducer:hs,useRef:js,useState:function(){return hs(fs)},useDebugValue:Hs,useDeferredValue:function(e,t){var n=ss();return Ho===null?Gs(n,e,t):Ks(n,Ho.memoizedState,e,t)},useTransition:function(){var e=hs(fs)[0],t=ss().memoizedState;return[typeof e==`boolean`?e:ls(e),t]},useSyncExternalStore:B,useId:$s,useHostTransitionStatus:Qs,useFormState:ks,useActionState:ks,useOptimistic:function(e,t){var n=ss();return Ho===null?(n.baseState=e,[e,n.queue.dispatch]):bs(n,Ho,e,t)},useMemoCache:ds,useCacheRefresh:ec,useEffectEvent:Ls};function pc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:w({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var mc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Dd(),i=go(r);i.payload=t,n!=null&&(i.callback=n),t=_o(e,i,r),t!==null&&(Ad(t,e,r),vo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Dd(),i=go(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=_o(e,i,r),t!==null&&(Ad(t,e,r),vo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Dd(),r=go(n);r.tag=2,t!=null&&(r.callback=t),t=_o(e,r,n),t!==null&&(Ad(t,e,n),vo(t,e,n))}};function hc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Hr(n,r)||!Hr(i,a):!0}function gc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&mc.enqueueReplaceState(t,t.state,null)}function _c(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=w({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function vc(e){bi(e)}function yc(e){console.error(e)}function bc(e){bi(e)}function xc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Sc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Cc(e,t,n){return n=go(n),n.tag=3,n.payload={element:null},n.callback=function(){xc(e,t)},n}function wc(e){return e=go(e),e.tag=3,e}function Tc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Sc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Sc(t,n,r),typeof i!=`function`&&(md===null?md=new Set([this]):md.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Ec(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Sa(t,n,a,!0),n=Ao.current,n!==null){switch(n.tag){case 31:case 13:case 19:return jo===null?Hd():n.alternate===null&&td===0&&(td=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Qa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),df(e,r,a)),!1;case 22:return n.flags|=65536,r===Qa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),df(e,r,a)),!1}throw Error(i(435,n.tag))}return df(e,r,a),Hd(),!1}if(L)return t=Ao.current,t===null?(r!==sa&&(t=Error(i(423),{cause:r}),ma(Hi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Hi(r,n),a=Cc(e.stateNode,r,a),yo(e,a),td!==4&&(td=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==sa&&(e=Error(i(422),{cause:r}),ma(Hi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Hi(o,n),sd===null?sd=[o]:sd.push(o),td!==4&&(td=2),t===null)return!0;r=Hi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Cc(n.stateNode,r,e),yo(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(md===null||!md.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=wc(a),Tc(a,e,n,r),yo(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Dc=Error(i(461)),Oc=!1;function kc(e,t,n,r){t.child=e===null?fo(t,null,n,r):uo(t,e.child,n,r)}function Ac(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return wa(t),r=$o(e,t,n,o,a,i),s=rs(),e!==null&&!Oc?(is(e,t,i),il(e,t,i)):(L&&s&&ea(t),t.flags|=1,kc(e,t,r,i),t.child)}function jc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Ni(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Mc(e,t,a,r,i)):(e=Ii(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!al(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Hr:n,n(o,r)&&e.ref===t.ref)return il(e,t,i)}return t.flags|=1,e=Pi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Mc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Hr(a,r)&&e.ref===t.ref){if(Oc=!1,t.pendingProps=r=a,al(e,i))e.flags&131072&&(Oc=!0);else return t.lanes=e.lanes,il(e,t,i)}}return Bc(e,t,n,r,i)}function Nc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Fc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&qa(t,a===null?null:a.cachePool),a===null?Oo():Do(t,a),Po(t);else return r=t.lanes=536870912,Fc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&qa(t,null),Oo(),Fo()):(qa(t,a.cachePool),Do(t,a),Fo(),t.memoizedState=null);return kc(e,t,i,n),t.child}function Pc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Fc(e,t,n,r,i){var a=Ka();return a=a===null?null:{parent:ja._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&qa(t,null),Oo(),Po(t),e!==null&&Sa(e,t,r,!0),t.childLanes=i,null}function Ic(e,t){return t=Yc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Lc(e,t,n){return uo(t,e.child,null,n),e=Ic(t,t.pendingProps),e.flags|=2,Io(t),t.memoizedState=null,e}function Rc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(L){if(r.mode===`hidden`)return e=Ic(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Pc(null,e);if(No(t),(e=ia)?(e=am(e,oa),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Yi===null?null:{id:Xi,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=zi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw ca(t);return t.lanes=536870912,null}return Ic(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(No(t),a){if(t.flags&256)t.flags&=-257,t=Lc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Oc||Sa(e,t,n,!1),a=(n&e.childLanes)!==0,Oc||a){if(To.current===null){if(r=Ju,r!==null&&(s=vt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Di(e,s),Ad(r,e,s),Dc;Hd()}t=Lc(e,t,n)}else e=o.treeContext,ia=lm(s.nextSibling),ra=t,L=!0,aa=null,oa=!1,e!==null&&na(t,e),t=Ic(t,r),t.flags|=134221824;return t}return e=Pi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function zc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Bc(e,t,n,r,i){return wa(t),n=$o(e,t,n,r,void 0,i),r=rs(),e!==null&&!Oc?(is(e,t,i),il(e,t,i)):(L&&r&&ea(t),t.flags|=1,kc(e,t,n,i),t.child)}function Vc(e,t,n,r,i,a){return wa(t),t.updateQueue=null,n=ts(t,r,n,i),es(e),r=rs(),e!==null&&!Oc?(is(e,t,a),il(e,t,a)):(L&&r&&ea(t),t.flags|=1,kc(e,t,n,a),t.child)}function Hc(e,t,n,r,i){if(wa(t),t.stateNode===null){var a=Ai,o=n.contextType;typeof o==`object`&&o&&(a=Ta(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=mc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},mo(t),o=n.contextType,a.context=typeof o==`object`&&o?Ta(o):Ai,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(pc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&mc.enqueueReplaceState(a,a.state,null),So(t,r,a,i),xo(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=_c(n,s);a.props=c;var l=a.context,u=n.contextType;o=Ai,typeof u==`object`&&u&&(o=Ta(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&gc(t,a,r,o),po=!1;var f=t.memoizedState;a.state=f,So(t,r,a,i),xo(),l=t.memoizedState,s||f!==l||po?(typeof d==`function`&&(pc(t,n,d,r),l=t.memoizedState),(c=po||hc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,ho(e,t),o=t.memoizedProps,u=_c(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Ai,typeof l==`object`&&l&&(c=Ta(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&gc(t,a,r,c),po=!1,f=t.memoizedState,a.state=f,So(t,r,a,i),xo();var p=t.memoizedState;o!==d||f!==p||po||e!==null&&e.dependencies!==null&&Ca(e.dependencies)?(typeof s==`function`&&(pc(t,n,s,r),p=t.memoizedState),(u=po||hc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ca(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,zc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=uo(t,e.child,null,i),t.child=uo(t,null,n,i)):kc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=il(e,t,i),e}function Uc(e,t,n,r){return fa(),t.flags|=256,kc(e,t,n,r),t.child}var Wc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Gc(e){return{baseLanes:e,cachePool:Ja()}}function Kc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ad),e}function qc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Lo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(L){if(i?Mo(t):Fo(),(e=ia)?(e=am(e,oa),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Yi===null?null:{id:Xi,overflow:Zi},retryLane:536870912,hydrationErrors:null},n=zi(e),n.return=t,t.child=n,ra=t,ia=null)):e=null,e===null)throw ca(t);return t.lanes=sm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Fo(),i=t.mode,a=Yc({mode:`hidden`,children:a},i),r=Li(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Gc(n),r.childLanes=Kc(e,o,n),t.memoizedState=Wc,Pc(null,r)):(Mo(t),Jc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return Zc(e,t,a,o,r,c,s,n)}return i?(Fo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Pi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Li(i,a,n,null),i.flags|=2):i=Pi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Pc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Gc(n):(a=i.cachePool,a===null?a=Ja():(s=ja._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Kc(e,o,n),t.memoizedState=Wc,Pc(e.child,r)):(Mo(t),n=e.child,e=n.sibling,n=Pi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function Jc(e,t){return t=Yc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Yc(e,t){return e=Mi(22,e,null,t),e.lanes=0,e}function Xc(e,t,n){return uo(t,e.child,null,n),e=Jc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Zc(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(Mo(t),t.flags&=-257,Xc(e,t,c)):t.memoizedState===null?(Fo(),o=a.fallback,s=t.mode,a=Yc({mode:`visible`,children:a.children},s),o=Li(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,uo(t,e.child,null,c),a=t.child,a.memoizedState=Gc(c),a.childLanes=Kc(e,r,c),t.memoizedState=Wc,Pc(null,a)):(Fo(),t.child=e.child,t.flags|=128,null);if(Mo(t),sm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,ma({value:a,source:null,stack:null})),Xc(e,t,c)}if(Oc||Sa(e,t,c,!1),r=(c&e.childLanes)!==0,Oc||r){if(To.current!==null)return Xc(e,t,c);if(r=Ju,r!==null&&(a=vt(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,Di(e,a),Ad(r,e,a),Dc;return om(o)||Hd(),Xc(e,t,c)}return om(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,ia=lm(o.nextSibling),ra=t,L=!0,aa=null,oa=!1,e!==null&&na(t,e),t=Jc(t,a.children),t.flags|=134221824,t)}function Qc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ba(e.return,t,n)}function $c(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Bo(n)===null&&(t=e),e=e.sibling}return t}function el(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function tl(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function nl(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Lo.current;if(t.flags&128)return Ro(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Ro(t,o),i===`backwards`&&e!==null?(tl(e),kc(e,t,r,n),tl(e)):kc(e,t,r,n),r=L?Ki:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Qc(e,n,t);else if(e.tag===19)Qc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=$c(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,tl(t)),el(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Bo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}el(t,!0,n,null,a,r);break;case`together`:el(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=$c(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),el(t,!1,i,n,a,r)}return t.child}function rl(e,t,n){var r=t.pendingProps;return va(t,t.type,r.value),kc(e,t,r.children,n),t.child}function il(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),nd|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Sa(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Pi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Pi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function al(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Ca(e)))}function ol(e,t,n){switch(t.tag){case 3:Ee(t,t.stateNode.containerInfo),va(t,ja,e.memoizedState.cache),fa();break;case 27:case 5:Oe(t);break;case 4:Ee(t,t.stateNode.containerInfo);break;case 10:va(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,No(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Mo(t),t.flags|=128,null;r=Sa(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?qc(e,t,n):(Mo(t),e=il(e,t,n),e===null?null:e.sibling)}Mo(t);break;case 19:if(t.flags&128)return nl(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Sa(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return nl(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ro(t,Lo.current),r)break;return null;case 22:return t.lanes=0,Nc(e,t,n,t.pendingProps);case 24:va(t,ja,e.memoizedState.cache)}return il(e,t,n)}function sl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Oc=!0;else{if(!al(e,n)&&!(t.flags&128))return Oc=!1,ol(e,t,n);Oc=!!(e.flags&131072)}}else Oc=!1,L&&t.flags&1048576&&$i(t,Ki,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=to(t.elementType),t.type=e,typeof e==`function`)Ni(e)?(r=_c(e,r),t.tag=1,t=Hc(null,t,e,r,n)):(t.tag=0,t=Bc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===ne){t.tag=11,t=Ac(null,t,e,r,n);break a}if(a===ae){t.tag=14,t=jc(null,t,e,r,n);break a}if(a===te){t.tag=10,t.type=e,t=rl(null,t,n);break a}}throw t=me(e)||e,Error(i(306,t,``))}}return t;case 0:return Bc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=_c(r,t.pendingProps),Hc(e,t,r,a,n);case 3:a:{if(Ee(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ho(e,t),So(t,r,null,n);var s=t.memoizedState;if(r=s.cache,va(t,ja,r),r!==o.cache&&xa(t,[ja],n,!0),xo(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Uc(e,t,r,n);break a}if(r!==a){a=Hi(Error(i(424)),t),ma(a),t=Uc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(ia=lm(e.firstChild),ra=t,L=!0,aa=null,oa=!0,n=fo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(fa(),r===a){t=il(e,t,n);break a}kc(e,t,r,n)}t=t.child}return t;case 26:return zc(e,t),e===null?(n=Nm(t.type,null,t.pendingProps,null))?t.memoizedState=n:L||(t.stateNode=fp(t.type,t.pendingProps,we.current,t)):t.memoizedState=Nm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Oe(t),e===null&&L&&(r=t.stateNode=hm(t.type,t.pendingProps,we.current),ra=t,oa=!0,a=ia,Sp(t.type)?(um=a,ia=lm(r.firstChild)):ia=a),kc(e,t,t.pendingProps.children,n),zc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&L&&((a=r=ia)&&(r=rm(r,t.type,t.pendingProps,oa),r===null?a=!1:(t.stateNode=r,ra=t,ia=lm(r.firstChild),oa=!1,a=!0)),a||ca(t)),Oe(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,pp(a,o)?r=null:s!==null&&pp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=$o(e,t,ns,null,null,n),sh._currentValue=a),zc(e,t),kc(e,t,r,n),t.child;case 6:return e===null&&L&&((e=n=ia)&&(n=im(n,t.pendingProps,oa),n===null?e=!1:(t.stateNode=n,ra=t,ia=null,e=!0)),e||ca(t)),null;case 13:return qc(e,t,n);case 4:return Ee(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=uo(t,null,r,n):kc(e,t,r,n),t.child;case 11:return Ac(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,zc(e,t),kc(e,t,r,n),t.child;case 8:return kc(e,t,t.pendingProps.children,n),t.child;case 12:return kc(e,t,t.pendingProps.children,n),t.child;case 10:return rl(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,wa(t),a=Ta(a),r=r(a),t.flags|=1,kc(e,t,r,n),t.child;case 14:return jc(e,t,t.type,t.pendingProps,n);case 15:return Mc(e,t,t.type,t.pendingProps,n);case 19:return nl(e,t,n);case 31:return Rc(e,t,n);case 22:return Nc(e,t,n,t.pendingProps);case 24:return wa(t),r=Ta(ja),e===null?(a=Ka(),a===null&&(a=Ju,o=Ma(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},mo(t),va(t,ja,a)):((e.lanes&n)!==0&&(ho(e,t),So(t,null,null,n),xo()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,va(t,ja,r),r!==a.cache&&xa(t,[ja],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),va(t,ja,r))),kc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:L&&ea(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:zc(e,t),kc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function cl(e){e.flags|=4}function ll(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Jm(t,r):Jm(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(zd())e.flags|=8192;else throw no=Qa,Xa}}else e.flags&=-16777217}function ul(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Ym(t)){if(zd())e.flags|=8192;else throw no=Qa,Xa}}function dl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:ft(),e.lanes|=t,od|=t)}function fl(e,t){if(!L)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function K(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function pl(e,t,n){var r=t.pendingProps;switch(ta(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return K(t),null;case 1:return K(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ya(ja),De(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(da(t)?cl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,pa())),K(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(cl(t),o===null?(K(t),ll(t,a,null,r,n)):(K(t),ul(t,o))):o?o===e.memoizedState?(K(t),t.flags&=-16777217):(cl(t),K(t),ul(t,o)):(e=e.memoizedProps,e!==r&&cl(t),K(t),ll(t,a,e,r,n)),null;case 27:if(ke(t),n=we.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return K(t),t.subtreeFlags&=-33554433,null}e=Se.current,da(t)?la(t,e):(e=hm(a,r,n),t.stateNode=e,cl(t))}return K(t),t.subtreeFlags&=-33554433,null;case 5:if(ke(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return K(t),t.subtreeFlags&=-33554433,null}if(o=Se.current,da(t))la(t,o);else{var s=lp(we.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[wt]=t,o[Tt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&cl(t)}}return K(t),t.subtreeFlags&=-33554433,ll(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&cl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=we.current,da(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ra,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[wt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||$f(e.nodeValue,n)),e||ca(t,!0)}else e=lp(e).createTextNode(r),e[wt]=t,t.stateNode=e}return K(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=da(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[wt]=t}else fa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;K(t),e=!1}else n=pa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Io(t),t):(Io(t),null);if(t.flags&128)throw Error(i(558))}return K(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=da(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[wt]=t}else fa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;K(t),a=!1}else a=pa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Io(t),t):(Io(t),null)}return Io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),dl(t,t.updateQueue),K(t),null);case 4:return De(),e===null&&Uf(t.stateNode.containerInfo),t.flags|=67108864,K(t),null;case 10:return ya(t.type),K(t),null;case 19:if(zo(t),r=t.memoizedState,r===null)return K(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)fl(r,!1);else{if(td!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Bo(e),o!==null){for(t.flags|=128,fl(r,!1),e=o.updateQueue,t.updateQueue=e,dl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Fi(n,e),n=n.sibling;return Ro(t,Lo.current&1|2),L&&Qi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&He()>fd&&(t.flags|=128,a=!0,fl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Bo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,dl(t,e),fl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!L)return K(t),null}else 2*He()-r.renderingStartTime>fd&&n!==536870912&&(t.flags|=128,a=!0,fl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=He(),e.sibling=null,o=Lo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||L?Ro(t,o):(n=o,xe(Ao,t),xe(Lo,n),jo===null&&(jo=t)),L&&Qi(t,r.treeForkCount),e}return K(t),null;case 22:case 23:return Io(t),ko(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(K(t),t.subtreeFlags&6&&(t.flags|=8192)):K(t),n=t.updateQueue,n!==null&&dl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&be(Ga),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ya(ja),K(t),null;case 25:return null;case 30:return t.flags|=33554432,K(t),null}throw Error(i(156,t.tag))}function ml(e,t){switch(ta(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ya(ja),De(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ke(t),null;case 31:if(t.memoizedState!==null){if(Io(t),t.alternate===null)throw Error(i(340));fa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));fa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return zo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return De(),null;case 10:return ya(t.type),null;case 22:case 23:return Io(t),ko(),e!==null&&be(Ga),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ya(ja),null;case 25:return null;default:return null}}function hl(e,t){switch(ta(t),t.tag){case 3:ya(ja),De();break;case 26:case 27:case 5:ke(t);break;case 4:De();break;case 31:t.memoizedState!==null&&Io(t);break;case 13:Io(t);break;case 19:zo(t);break;case 10:ya(t.type);break;case 22:case 23:Io(t),ko(),e!==null&&be(Ga);break;case 24:ya(ja)}}function gl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){uf(t,t.return,e)}}function _l(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){uf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){uf(t,t.return,e)}}function vl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{wo(t,n)}catch(t){uf(e,e.return,t)}}}function yl(e,t,n){n.props=_c(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){uf(e,t,n)}}function bl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=_i(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);f(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){uf(e,t,n)}}function xl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){uf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){uf(e,t,n)}else n.current=null}}function Sl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)em(e.stateNode,t[n])}function Cl(e){for(var t=e.return;t!==null&&(El(t)&&em(e.stateNode,t.stateNode),!Tl(t));)t=t.return}function wl(e){for(var t=e.return;t!==null&&(El(t)&&tm(e.stateNode,t.stateNode),!Tl(t));)t=t.return}function Tl(e){return e.tag===5||e.tag===3||e.tag===27}function El(e){return e&&e.tag===7&&e.stateNode!==null}function Dl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){uf(e,e.return,t)}}function Ol(e,t,n){try{var r=e.stateNode;ip(r,e.type,n,t),r[Tt]=t}catch(t){uf(e,e.return,t)}}function kl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Sp(e.type)||e.tag===4}function Al(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||kl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Sp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function jl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=bn)),Sl(e,r),P=!0;else if(i!==4&&(i===27&&(Sl(e,r),r=null,Sp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(jl(e,t,n,r),e=e.sibling;e!==null;)jl(e,t,n,r),e=e.sibling}function Ml(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),Sl(e,r),P=!0;else if(i!==4&&(i===27&&(Sl(e,r),r=null,Sp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(Ml(e,t,n,r),e=e.sibling;e!==null;)Ml(e,t,n,r),e=e.sibling}function Nl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);np(t,r,n),t[wt]=e,t[Tt]=n}catch(t){uf(e,e.return,t)}}var Pl=!1,Fl=null;function Il(e){(e.tag===30||e.subtreeFlags&33554432)&&(Pl=!0)}var Ll=null;function Rl(){var e=Ll;return Ll=null,e}var zl=0;function Bl(e,t,n,r,i){return zl=0,Vl(e.child,t,n,r,i)}function Vl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Op(o);r.push(s),s.view&&(a=!0)}else a||Op(o).view&&(a=!0);Pl=!0,Tp(o,zl===0?t:t+`_`+zl,n),zl++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||Vl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function Hl(e,t){for(;e!==null;)e.tag===5?Ep(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||Hl(e.child,t),e=e.sibling}function Ul(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Ul(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=yi(t.default,t.share),t!==`none`&&(Bl(e,n,t,null,!1)||Hl(e.child,!1))}e=e.sibling}}function Wl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=_i(r,n),a=yi(r.default,n.paired?r.share:r.enter);a===`none`?Ul(e):Bl(e,i,a,null,!1)?(Ul(e),n.paired||t||kd(e,r.onEnter)):Hl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Wl(e,t),e=e.sibling;else Ul(e)}function Gl(e){if(Fl!==null&&Fl.size!==0){var t=Fl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=yi(n.default,n.share);if(a!==`none`&&(Bl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,kd(e,n.onShare)):Hl(e.child,!1)),t.delete(r),t.size===0)break}}}Gl(e)}e=e.sibling}}}function Kl(e){if(e.tag===30){var t=e.memoizedProps,n=_i(t,e.stateNode),r=Fl===null?void 0:Fl.get(n),i=yi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Bl(e,n,i,null,!1)?r===void 0?kd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Fl.delete(n),kd(e,t.onShare)):Hl(e.child,!1)),Fl!==null&&Gl(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Kl(e),e=e.sibling;else Fl!==null&&Gl(e)}function ql(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=_i(t,e.stateNode);t=yi(t.default,t.update),e.flags&=-5,t!==`none`&&Bl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&ql(e);e=e.sibling}}function Jl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Hl(e.child,!1))}Jl(e)}e=e.sibling}}function Yl(e){if(e.tag===30)e.stateNode.paired=null,Hl(e.child,!1),Jl(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Yl(e),e=e.sibling;else Jl(e)}function Xl(e){for(e=e.child;e!==null;)e.tag===30?Hl(e.child,!1):e.subtreeFlags&33554432&&Xl(e),e=e.sibling}function Zl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&zl<a.length){var l=a[zl],u=Op(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Tp(c,zl===0?n:n+`_`+zl,i),s&&e.flags&4||(Ll===null&&(Ll=[]),Ll.push(c,zl===0?r:r+`_`+zl,t.memoizedProps)),zl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Zl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Ql(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=_i(n,r),a=yi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(kp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;zl=0,i=Zl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||kd(e,n.onUpdate))}else e.subtreeFlags&33554432&&Ql(e,t);e=e.sibling}}var $l=!1,q=!1,eu=!1,tu=!1,nu=typeof WeakSet==`function`?WeakSet:Set,ru=null,iu=!1,au=!1,ou=!1,su=!1;function cu(e,t,n){if(e=e.containerInfo,sp=gh,e=qr(e),Jr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(cp={focusedElem:e,selectionRange:r},gh=!1,n=(n&335544064)===n,ru=t,t=n?9270:1024;ru!==null;){if(e=ru,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Kl(r[a]);if(e.alternate===null&&e.flags&2)n&&Il(e),lu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Kl(r),lu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Il(e),lu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,ru=r):(n&&ql(e),lu(n))}}Fl=null}function lu(e){for(;ru!==null;){var t=ru,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=_c(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){uf(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)nm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:nm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=_i(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=yi(a.default,a.update),a!==`none`&&Bl(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,ru=r;break}ru=t.return}}function uu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ju(e,n),r&4&&gl(5,n);break;case 1:if(ju(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){uf(n,n.return,e)}else{var i=_c(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){uf(n,n.return,e)}}}r&64&&vl(n),r&512&&bl(n,n.return);break;case 3:if(ju(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{wo(e,t)}catch(e){uf(n,n.return,e)}}break;case 27:t===null&&r&4&&Nl(n);case 26:case 5:ju(e,n),t===null&&r&4&&Dl(n),r&512&&bl(n,n.return);break;case 12:ju(e,n);break;case 31:ju(e,n),r&4&&bu(e,n);break;case 13:ju(e,n),r&4&&xu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=mf.bind(null,n),cm(e,n))));break;case 22:if(r=n.memoizedState!==null||$l,!r){var a=t!==null&&t.memoizedState!==null||q;t=$l,i=q,$l=r,(q=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Nu(e,n,r)):ju(e,n),$l=t,q=i}break;case 30:ju(e,n),r&512&&bl(n,n.return);break;case 7:r&512&&bl(n,n.return);default:ju(e,n)}}function du(e,t){for(e=e.child;e!==null;)fu(e,t),e=e.sibling}function fu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){uf(e,e.return,t)}pu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,P=!0}catch(t){uf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?wp(s,!0):wp(e.stateNode,!1)}catch(t){uf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&du(e,t);break;default:du(e,t)}}function pu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:fu(n,r);break a;case 22:n.memoizedState===null&&pu(n,r);break a;default:pu(n,r)}}e=e.sibling}}function mu(e){var t=e.alternate;t!==null&&(e.alternate=null,mu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Nt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var gu=null,_u=!1;function vu(e,t,n){for(n=n.child;n!==null;)yu(e,t,n),n=n.sibling}function yu(e,t,n){if(Qe&&typeof Qe.onCommitFiberUnmount==`function`)try{Qe.onCommitFiberUnmount(Ze,n)}catch{}switch(n.tag){case 26:q||xl(n,t),vu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!q&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:q||xl(n,t),wl(n);var r=gu,i=_u;Sp(n.type)&&(gu=n.stateNode,_u=!1),vu(e,t,n),gm(n.stateNode,n.type,n.memoizedProps),gu=r,_u=i;break;case 5:q||xl(n,t),wl(n);case 6:if(n.tag===6&&wl(n),r=gu,i=_u,gu=null,vu(e,t,n),gu=r,_u=i,gu!==null){if(_u)try{(gu.nodeType===9?gu.body:gu.nodeName===`HTML`?gu.ownerDocument.body:gu).removeChild(n.stateNode),P=!0}catch(e){uf(n,t,e)}else try{gu.removeChild(n.stateNode),P=!0}catch(e){uf(n,t,e)}}break;case 18:gu!==null&&(_u?(e=gu,Cp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Hh(e)):Cp(gu,n.stateNode));break;case 4:r=gu,i=_u,gu=n.stateNode.containerInfo,_u=!0,vu(e,t,n),gu=r,_u=i;break;case 0:case 11:case 14:case 15:_l(2,n,t),q||_l(4,n,t),vu(e,t,n);break;case 1:q||(xl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&yl(n,t,r)),vu(e,t,n);break;case 21:vu(e,t,n);break;case 22:q=(r=q)||n.memoizedState!==null,vu(e,t,n),q=r;break;case 30:xl(n,t),vu(e,t,n);break;case 7:q||xl(n,t),vu(e,t,n);break;default:vu(e,t,n)}}function bu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Hh(e)}catch(e){uf(t,t.return,e)}}}function xu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Hh(e)}catch(e){uf(t,t.return,e)}}function Su(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new nu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new nu),t;default:throw Error(i(435,e.tag))}}function Cu(e,t){var n=Su(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=hf.bind(null,e,t);t.then(r,r)}})}function wu(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Sp(l.type)){gu=l.stateNode,_u=!1;break a}break;case 5:gu=l.stateNode,_u=!1;break a;case 3:case 4:gu=l.stateNode.containerInfo,_u=!0;break a}l=l.return}if(gu===null)throw Error(i(160));yu(s,c,o),gu=null,_u=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Eu(t,e,n),t=t.sibling}var Tu=null;function Eu(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}wu(t,e,n),Du(e),a&4&&(_l(3,e,e.return),gl(3,e),_l(5,e,e.return));break;case 1:wu(t,e,n),Du(e),a&512&&(q||r===null||xl(r,r.return)),a&64&&$l&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Tu,wu(t,e,n),Du(e),a&512&&(q||r===null||xl(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if($l)e.stateNode=fp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[jt]||r[wt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),np(r,t,n),r[wt]=e,Rt(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),np(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=Gm(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),np(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[wt]=e,Rt(r),t=r}e.stateNode=t}}else $l||Km(o,e.type,e.stateNode)}else e.stateNode=Bm(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Ol(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||q||t.parentNode.removeChild(t)):a.count--,n===null?$l||Km(o,e.type,e.stateNode):Bm(o,n,e.memoizedProps))}break;case 27:wu(t,e,n),Du(e),a&512&&(q||r===null||xl(r,r.return)),r!==null&&a&4&&Ol(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=eu,eu=!1,wu(t,e,n),eu=o,Du(e),a&512&&(q||r===null||xl(r,r.return)),e.flags&32){t=e.stateNode;try{fn(t,``),P=!0}catch(t){uf(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Ol(e,t,r===null?t:r.memoizedProps)),a&1024&&(tu=!0);break;case 6:if(wu(t,e,n),Du(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,P=!0}catch(t){uf(e,e.return,t)}}break;case 3:if(P=!1,Wm=null,o=Tu,Tu=bm(t.containerInfo),wu(t,e,n),Tu=o,Du(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{Hh(t.containerInfo)}catch(t){uf(e,e.return,t)}tu&&(tu=!1,Ou(e)),P=!1;break;case 4:a=eu,eu=$l,r=Jt(),o=Tu,Tu=bm(e.stateNode.containerInfo),wu(t,e,n),Du(e),Tu=o,P&&au&&(ou=!0),P=r,eu=a;break;case 12:wu(t,e,n),Du(e);break;case 31:wu(t,e,n),Du(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 13:wu(t,e,n),Du(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(ud=He()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=$l,l=q,u=eu;$l=c||o,eu=u||o,q=l||s,wu(t,e,n),q=l,eu=u,$l=c,Du(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||$l||q||(t=s||q,n=$l,r=q,$l=o||$l,q=t,Mu(e,2),$l=n,q=r),!o&&eu||du(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Cu(e,n))));break;case 19:wu(t,e,n),Du(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Cu(e,t)));break;case 30:a&512&&(q||r===null||xl(r,r.return)),a=Jt(),o=au,s=(n&335544064)===n,c=e.memoizedProps,au=s&&yi(c.default,c.update)!==`none`,wu(t,e,n),Du(e),s&&r!==null&&P&&(e.flags|=4),au=o,P=a;break;case 21:break;case 7:a&512&&(q||r===null||xl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:wu(t,e,n),Du(e)}}function Du(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(kl(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(El(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Tl(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;Ml(e,Al(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(fn(l,``),n.flags&=-33),Ml(e,Al(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;jl(e,Al(e),u,s);break;default:throw Error(i(161))}}catch(t){uf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Ou(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Ou(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,gh=!0,t.reset(),gh=!1),e=e.sibling}}function ku(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Au(t,e),t=t.sibling;else Ql(t,!1)}function Au(e,t){var n=e.alternate;if(n===null)Wl(e,!1);else switch(e.tag){case 3:if(su=iu=!1,Rl(),ku(t,e),!iu&&!ou){if(e=Ll,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Ep(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),su=!0}Ll=null;break;case 5:ku(t,e);break;case 4:r=iu,iu=!1,ku(t,e),iu&&(ou=!0),iu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?ku(t,e):Wl(e,!1));break;case 30:r=iu,i=Rl(),iu=!1,ku(t,e),iu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=_i(a,o),o=_i(n.memoizedProps,o);var s=yi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,zl=0,t=Zl(e,n,t,o,s,a,!0),zl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(kd(e,e.memoizedProps.onUpdate),Ll=i):i!==null&&(i.push.apply(i,Ll),Ll=i),iu=e.flags&32?!0:r;break;default:ku(t,e)}}function ju(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)uu(e,t.alternate,t),t=t.sibling}function Mu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:_l(4,n,n.return),Mu(n,r);break;case 1:xl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&yl(n,n.return,i),Mu(n,r);break;case 27:r&2&&gm(n.stateNode,n.type,n.memoizedProps);case 5:xl(n,n.return),n.tag!==5&&n.tag!==27||wl(n),Mu(n,r);break;case 6:wl(n);break;case 26:xl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||q||i.parentNode.removeChild(i),Mu(n,r);break;case 22:n.memoizedState===null&&Mu(n,r);break;case 30:xl(n,n.return),Mu(n,r);break;case 7:xl(n,n.return);default:Mu(n,r)}e=e.sibling}}function Nu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Nu(i,a,n),gl(4,a);break;case 1:if(Nu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){uf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)Co(l[i],c)}catch(e){uf(r,r.return,e)}}s&&o&64&&vl(a),bl(a,a.return);break;case 27:n&2&&Nl(a);case 5:a.tag!==5&&a.tag!==27||Cl(a),Nu(i,a,n),s&&r===null&&o&4&&Dl(a),bl(a,a.return);break;case 6:Cl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||$l||Km(bm(c.ownerDocument),a.type,c),Nu(i,a,n),s&&r===null&&o&4&&Dl(a),bl(a,a.return);break;case 12:Nu(i,a,n);break;case 31:Nu(i,a,n),s&&o&4&&bu(i,a);break;case 13:Nu(i,a,n),s&&o&4&&xu(i,a);break;case 22:a.memoizedState===null&&Nu(i,a,n),bl(a,a.return);break;case 30:Nu(i,a,n),bl(a,a.return);break;case 7:bl(a,a.return);default:Nu(i,a,n)}t=t.sibling}}function Pu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Na(n))}function Fu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Na(e))}function Iu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Lu(e,t,n,r),t=t.sibling;else i&&Xl(t)}function Lu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&Yl(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Iu(e,t,n,r),a&2048&&gl(9,t);break;case 1:Iu(e,t,n,r);break;case 3:Iu(e,t,n,r),i&&su&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Na(a)));break;case 12:if(a&2048){Iu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){uf(t,t.return,e)}}else Iu(e,t,n,r);break;case 31:Iu(e,t,n,r);break;case 13:Iu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&Yl(t),o._visibility&2?Iu(e,t,n,r):(o._visibility|=2,Ru(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&Yl(s),o._visibility&2?Iu(e,t,n,r):zu(e,t)),a&2048&&Pu(s,t);break;case 24:Iu(e,t,n,r),a&2048&&Fu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Hl(a.child,!0),Hl(t.child,!0))),Iu(e,t,n,r);break;default:Iu(e,t,n,r)}}function Ru(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Ru(a,o,s,c,i),gl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ru(a,o,s,c,i)):u._visibility&2?Ru(a,o,s,c,i):zu(a,o),i&&l&2048&&Pu(o.alternate,o);break;case 24:Ru(a,o,s,c,i),i&&l&2048&&Fu(o.alternate,o);break;default:Ru(a,o,s,c,i)}t=t.sibling}}function zu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:zu(n,r),i&2048&&Pu(r.alternate,r);break;case 24:zu(n,r),i&2048&&Fu(r.alternate,r);break;default:zu(n,r)}t=t.sibling}}var Bu=8192;function J(e,t,n){if(e.subtreeFlags&Bu)for(e=e.child;e!==null;)Y(e,t,n),e=e.sibling}function Y(e,t,n){switch(e.tag){case 26:J(e,t,n),e.flags&Bu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&Zm(n,e)):Qm(n,Tu,e.memoizedState,e.memoizedProps));break;case 5:J(e,t,n),e.flags&Bu&&(e=e.stateNode,(t&335544128)===t&&Zm(n,e));break;case 3:case 4:var r=Tu;Tu=bm(e.stateNode.containerInfo),J(e,t,n),Tu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Bu,Bu=16777216,J(e,t,n),Bu=r):J(e,t,n));break;case 30:if((e.flags&Bu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Fl===null&&(Fl=new Map),Fl.set(r,i)}J(e,t,n);break;default:J(e,t,n)}}function Vu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Hu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ru=r,Gu(r,e)}Vu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Uu(e),e=e.sibling}function Uu(e){switch(e.tag){case 0:case 11:case 15:Hu(e),e.flags&2048&&_l(9,e,e.return);break;case 3:Hu(e);break;case 12:Hu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Wu(e)):Hu(e);break;default:Hu(e)}}function Wu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ru=r,Gu(r,e)}Vu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:_l(8,t,t.return),Wu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Wu(t));break;default:Wu(t)}e=e.sibling}}function Gu(e,t){for(;ru!==null;){var n=ru;switch(n.tag){case 0:case 11:case 15:_l(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Na(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,ru=r;else a:for(n=e;ru!==null;){r=ru;var i=r.sibling,a=r.return;if(mu(r),r===n){ru=null;break a}if(i!==null){i.return=a,ru=i;break a}ru=a}}}var Ku={getCacheForType:function(e){var t=Ta(ja),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ta(ja).controller.signal}},qu=typeof WeakMap==`function`?WeakMap:Map,X=0,Ju=null,Z=null,Q=0,Yu=0,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0,td=0,nd=0,rd=0,id=0,ad=0,od=0,sd=null,cd=null,ld=!1,ud=0,dd=0,fd=1/0,pd=null,md=null,hd=0,gd=null,_d=null,vd=0,yd=0,bd=null,xd=null,Sd=null,Cd=null,wd=null,Td=0,Ed=null;function Dd(){return X&2&&Q!==0?Q&-Q:M.T===null?xt():jf()}function Od(){if(ad===0){if(!(Q&536870912)||L){var e=at;at<<=1,!(at&3932160)&&(at=262144),ad=e}else ad=536870912}return e=Ao.current,e!==null&&(e.flags|=32),ad}function kd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Pp(_i(e.memoizedProps,n))),Cd===null&&(Cd=[]),Cd.push(t.bind(null,r))}}function Ad(e,t,n){(e===Ju&&(Yu===2||Yu===9)||e.cancelPendingCommit!==null)&&(Ld(e,0),Pd(e,Q,ad,!1)),mt(e,n),X&2&&e===Ju||(e===Ju&&(!(X&2)&&(rd|=n),td===4&&Pd(e,Q,ad,!1)),Cf(e))}function jd(e,t,n){if(X&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||lt(e,t),a=r?Gd(e,t):Ud(e,t,!0),o=r;do{if(a===0){Qu&&!r&&Pd(e,t,0,!1);break}if(n=e.current.alternate,o&&!Nd(n))a=Ud(e,t,!1),o=!1;else{if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=sd;var l=c.current.memoizedState.isDehydrated;if(l&&(Ld(c,s).flags|=256),s=Ud(c,s,!1),s!==2&&s!==6){if($u&&!l){c.errorRecoveryDisabledLanes|=o,rd|=o,a=4;break a}o=cd,cd=a,o!==null&&(cd===null?cd=o:cd.push.apply(cd,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Ld(e,0),Pd(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Pd(r,t,ad,!Zu);break a;case 2:cd=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=ud+300-He(),10<a)){if(Pd(r,t,ad,!Zu),ct(r,0,!0)!==0)break a;vd=t,r.timeoutHandle=gp(Md.bind(null,r,n,cd,pd,ld,t,ad,rd,od,Zu,o,`Throttled`,-0,0),a);break a}Md(r,n,cd,pd,ld,t,ad,rd,od,Zu,o,null,-0,0)}break}}while(1);Cf(e)}function Md(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:bn},Fl=null,Y(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=nh.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?ud-He():(a&4194048)===a?dd-He():0,m=eh(d,m),m!==null)?(vd=a,e.cancelPendingCommit=m(Qd.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Pd(e,a,o,!l)):Qd(e,t,a,n,r,i,o,s,c,l,u,d)}function Nd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Vr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Pd(e,t,n,r){t=ut(e,t),t&=~id,t&=~rd,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-et(i),o=1<<a;r[a]=-1,i&=~o}n!==0&>(e,n,t)}function Fd(){return X&6?!0:(wf(0,!1),!1)}function Id(){if(Z!==null){if(Yu===0)var e=Z.return;else e=Z,_a=ga=null,as(e),io=null,ao=0,e=Z;for(;e!==null;)hl(e.alternate,e),e=e.return;Z=null}}function Ld(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,_p(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),vd=0,Id(),Ju=e,Z=n=Pi(e.current,null),Q=t,Yu=0,Xu=null,Zu=!1,Qu=lt(e,t),$u=!1,od=ad=id=rd=nd=td=0,cd=sd=null,ld=!1,ed=ut(e,t),wi(),n}function Rd(e,t){z=null,M.H=lc,t===Ya||t===Za?(t=ro(),Yu=3):t===Xa?(t=ro(),Yu=4):Yu=t===Dc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Xu=t,Z===null&&(td=1,xc(e,Hi(t,e.current)))}function zd(){var e=Ao.current;return e===null?!0:(Q&4194048)===Q?jo===null:(Q&62914560)===Q||Q&536870912?e===jo:!1}function Bd(){var e=M.H;return M.H=lc,e===null?lc:e}function Vd(){var e=M.A;return M.A=Ku,e}function Hd(){td=4,Zu||(Q&4194048)!==Q&&Ao.current!==null||(Qu=!0),!(nd&134217727)&&!(rd&134217727)||Ju===null||Pd(Ju,Q,ad,!1)}function Ud(e,t,n){var r=X;X|=2;var i=Bd(),a=Vd();(Ju!==e||Q!==t)&&(pd=null,Ld(e,t)),t=!1;var o=td;a:do try{if(Yu!==0&&Z!==null){var s=Z,c=Xu;switch(Yu){case 8:Id(),o=6;break a;case 3:case 2:case 9:case 6:Ao.current===null&&(t=!0);var l=Yu;if(Yu=0,Xu=null,Yd(e,s,c,l),n&&Qu){o=0;break a}break;default:l=Yu,Yu=0,Xu=null,Yd(e,s,c,l)}}Wd(),o=td;break}catch(t){Rd(e,t)}while(1);return t&&e.shellSuspendCounter++,_a=ga=null,X=r,M.H=i,M.A=a,Z===null&&(Ju=null,Q=0,wi()),o}function Wd(){for(;Z!==null;)qd(Z)}function Gd(e,t){var n=X;X|=2;var r=Bd(),a=Vd();Ju!==e||Q!==t?(pd=null,fd=He()+500,Ld(e,t)):Qu=lt(e,t);a:do try{if(Yu!==0&&Z!==null){t=Z;var o=Xu;b:switch(Yu){case 1:Yu=0,Xu=null,Yd(e,t,o,1);break;case 2:case 9:if($a(o)){Yu=0,Xu=null,Jd(t);break}t=function(){Yu!==2&&Yu!==9||Ju!==e||(Yu=7),Cf(e)},o.then(t,t);break a;case 3:Yu=7;break a;case 4:Yu=5;break a;case 7:$a(o)?(Yu=0,Xu=null,Jd(t)):(Yu=0,Xu=null,Yd(e,t,o,7));break;case 5:var s=null;switch(Z.tag){case 26:s=Z.memoizedState;case 5:case 27:var c=Z;if(s?Ym(s):c.stateNode.complete){Yu=0,Xu=null;var l=c.sibling;if(l!==null)Z=l;else{var u=c.return;u===null?Z=null:(Z=u,Xd(u))}break b}}Yu=0,Xu=null,Yd(e,t,o,5);break;case 6:Yu=0,Xu=null,Yd(e,t,o,6);break;case 8:Id(),td=6;break a;default:throw Error(i(462))}}Kd();break}catch(t){Rd(e,t)}while(1);return _a=ga=null,M.H=r,M.A=a,X=n,Z===null?(Ju=null,Q=0,wi(),td):0}function Kd(){for(;Z!==null&&!Be();)qd(Z)}function qd(e){var t=sl(e.alternate,e,ed);e.memoizedProps=e.pendingProps,t===null?Xd(e):Z=t}function Jd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Vc(n,t,t.pendingProps,t.type,void 0,Q);break;case 11:t=Vc(n,t,t.pendingProps,t.type.render,t.ref,Q);break;case 5:as(t);var r=t;r===ra&&(L?(ua(r),r.tag===5&&r.stateNode!=null&&(ia=r.stateNode)):(ua(r),L=!0));default:hl(n,t),t=Z=Fi(t,ed),t=sl(n,t,ed)}e.memoizedProps=e.pendingProps,t===null?Xd(e):Z=t}function Yd(e,t,n,r){_a=ga=null,as(t),io=null,ao=0;var i=t.return;try{if(Ec(e,i,t,n,Q)){td=1,xc(e,Hi(n,e.current)),Z=null;return}}catch(t){if(i!==null)throw Z=i,t;td=1,xc(e,Hi(n,e.current)),Z=null;return}t.flags&32768?(L||r===1?e=!0:Qu||Q&536870912?e=!1:(Zu=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ao.current,r!==null&&r.tag===13&&(r.flags|=16384))),Zd(t,e)):Xd(t)}function Xd(e){var t=e;do{if(t.flags&32768){Zd(t,Zu);return}e=t.return;var n=pl(t.alternate,t,ed);if(n!==null){Z=n;return}if(t=t.sibling,t!==null){Z=t;return}Z=t=e}while(t!==null);td===0&&(td=5)}function Zd(e,t){do{var n=ml(e.alternate,e);if(n!==null){n.flags&=32767,Z=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Z=e;return}Z=e=n}while(e!==null);td=6,Z=null}function Qd(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do sf();while(hd!==0);if(X&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===Ju&&(Z=Ju=null,Q=0),_d=t,gd=e,vd=n,bd=a,xd=r,$d(e,t,n,s,c,l,f)}}function $d(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(yd=s,s|=Ci,ht(e,n,s,r,i,a),Cd=null,(n&335544064)===n?(wd=Ia(e),r=10262):(wd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,gf(Ke,function(){return cf(),null})):(e.callbackNode=null,e.callbackPriority=0),Pl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=M.T,M.T=null,i=N.p,N.p=2,a=X,X|=4;try{cu(e,t,n)}finally{X=a,N.p=i,M.T=r}}hd=1,Pl?Sd=Mp(o,e.containerInfo,wd,nf,rf,tf,af,cf,ef,null,null):(nf(),rf(),af())}function ef(e){if(hd!==0){var t=gd.onRecoverableError;t(e,{componentStack:null})}}function tf(){hd===3&&(hd=0,Au(_d,gd),hd=4)}function nf(){if(hd===1){hd=0;var e=gd,t=_d,n=vd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=M.T,M.T=null;var i=N.p;N.p=2;var a=X;X|=4;try{au=ou=!1,Eu(t,e,n),n=cp;var o=qr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Kr(s.ownerDocument.documentElement,s)){if(c!==null&&Jr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Gr(s,h),v=Gr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}gh=!!sp,cp=sp=null}finally{X=a,N.p=i,M.T=r}}e.current=t,hd=2}}function rf(){if(hd===2){hd=0;var e=gd,t=_d,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=M.T,M.T=null;var r=N.p;N.p=2;var i=X;X|=4;try{uu(e,t.alternate,t)}finally{X=i,N.p=r,M.T=n}}hd=3}}function af(){if(hd===4||hd===3){hd=0;var e=Sd;Sd=null,Ve();var t=gd,n=_d,r=vd,i=xd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?hd=5:(hd=0,_d=gd=null,of(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(md=null),bt(r),n=n.stateNode,Qe&&typeof Qe.onCommitFiberRoot==`function`)try{Qe.onCommitFiberRoot(Ze,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=M.T,a=N.p,N.p=2,M.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{M.T=n,N.p=a}}if(i=Cd,o=wd,wd=null,i!==null&&(Cd=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);vd&3&&sf(),Cf(t),a=t.pendingLanes,r&261930&&a&42?t===Ed?Td++:(Td=0,Ed=t):(Td=0,Ed=null),wf(0,!1)}}function of(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Na(t)))}function sf(){return Sd!==null&&(Sd.skipTransition(),Sd=null),nf(),rf(),af(),cf()}function cf(){if(hd!==5)return!1;var e=gd,t=yd;yd=0;var n=bt(vd),r=M.T,a=N.p;try{N.p=32>n?32:n,M.T=null,n=bd,bd=null;var o=gd,s=vd;if(hd=0,_d=gd=null,vd=0,X&6)throw Error(i(331));var c=X;if(X|=4,Uu(o.current),Lu(o,o.current,s,n),X=c,wf(0,!1),Qe&&typeof Qe.onPostCommitFiberRoot==`function`)try{Qe.onPostCommitFiberRoot(Ze,o)}catch{}return!0}finally{N.p=a,M.T=r,of(e,t)}}function lf(e,t,n){t=Hi(n,t),t=Cc(e.stateNode,t,2),e=_o(e,t,2),e!==null&&(mt(e,2),Cf(e))}function uf(e,t,n){if(e.tag===3)lf(e,e,n);else for(;t!==null;){if(t.tag===3){lf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(md===null||!md.has(r))){e=Hi(n,e),n=wc(2),r=_o(t,n,2),r!==null&&(Tc(n,r,t,e),mt(r,2),Cf(r));break}}t=t.return}}function df(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new qu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||($u=!0,i.add(n),e=ff.bind(null,e,t,n),t.then(e,e))}function ff(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ju===e&&(Q&n)===n&&(td===4||td===3&&(Q&62914560)===Q&&300>He()-ud?X&2?id|=n:Ld(e,0):id|=n,od===Q&&(od=0)),Cf(e)}function pf(e,t){t===0&&(t=ft()),e=Di(e,t),e!==null&&(mt(e,t),Cf(e))}function mf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),pf(e,n)}function hf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),pf(e,n)}function gf(e,t){return Re(e,t)}var _f=null,vf=null,yf=!1,bf=!1,xf=!1,Sf=0;function Cf(e){e!==vf&&e.next===null&&(vf===null?_f=vf=e:vf=vf.next=e),bf=!0,yf||(yf=!0,Af())}function wf(e,t){if(!xf&&bf){xf=!0;do for(var n=!1,r=_f;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-et(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,kf(r,a))}else a=Q,a=ct(r,r===Ju?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||lt(r,a)||(n=!0,kf(r,a))}r=r.next}while(n);xf=!1}}function Tf(){Ef()}function Ef(){bf=yf=!1;var e=0;Sf!==0&&hp()&&(e=Sf);for(var t=He(),n=null,r=_f;r!==null;){var i=r.next,a=Df(r,t);a===0?(r.next=null,n===null?_f=i:n.next=i,i===null&&(vf=n)):(n=r,(e!==0||a&3)&&(bf=!0)),r=i}hd!==0&&hd!==5||wf(e,!1),Sf!==0&&(Sf=0)}function Df(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-et(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=dt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Ju,n=Q,n=ct(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Yu===2||Yu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ze(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||lt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ze(r),bt(n)){case 2:case 8:n=Ge;break;case 32:n=Ke;break;case 268435456:n=Je;break;default:n=Ke}return r=Of.bind(null,e),n=Re(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ze(r),e.callbackPriority=2,e.callbackNode=null,2}function Of(e,t){if(hd!==0&&hd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(sf()&&e.callbackNode!==n)return null;var r=Q;return r=ct(e,e===Ju?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(jd(e,r,t),Df(e,He()),e.callbackNode!=null&&e.callbackNode===n?Of.bind(null,e):null)}function kf(e,t){if(sf())return null;jd(e,t,!0)}function Af(){bp(function(){X&6?Re(We,Tf):Ef()})}function jf(){if(Sf===0){var e=za;e===0&&(e=it,it<<=1,!(it&261888)&&(it=256)),Sf=e}return Sf}function Mf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:yn(e)}function Nf(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Mf((i[Tt]||null).action),o=r.submitter;o&&(t=(t=o[Tt]||null)?Mf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Bn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Sf!==0){var e=new FormData(i,o);Ys(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),Ys(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Pf=0;Pf<mi.length;Pf++){var Ff=mi[Pf];hi(Ff.toLowerCase(),`on`+(Ff[0].toUpperCase()+Ff.slice(1)))}hi(oi,`onAnimationEnd`),hi(si,`onAnimationIteration`),hi(ci,`onAnimationStart`),hi(`dblclick`,`onDoubleClick`),hi(`focusin`,`onFocus`),hi(`focusout`,`onBlur`),hi(li,`onTransitionRun`),hi(ui,`onTransitionStart`),hi(di,`onTransitionCancel`),hi(fi,`onTransitionEnd`),Ut(`onMouseEnter`,[`mouseout`,`mouseover`]),Ut(`onMouseLeave`,[`mouseout`,`mouseover`]),Ut(`onPointerEnter`,[`pointerout`,`pointerover`]),Ut(`onPointerLeave`,[`pointerout`,`pointerover`]),Ht(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Ht(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Ht(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Ht(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Ht(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Ht(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var If=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Lf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(If));function Rf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){bi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){bi(e)}i.currentTarget=null,a=c}}}}function $(e,t){var n=t[Dt];n===void 0&&(n=t[Dt]=new Set);var r=e+`__bubble`;n.has(r)||(Wf(t,e,2,!1),n.add(r))}function zf(e,t,n){var r=0;t&&(r|=4),Wf(n,e,r,t)}var Vf=`_reactListening`+Math.random().toString(36).slice(2);function Uf(e){if(!e[Vf]){e[Vf]=!0,Bt.forEach(function(t){t!==`selectionchange`&&(Lf.has(t)||zf(t,!1,e),zf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Vf]||(t[Vf]=!0,zf(`selectionchange`,!1,t))}}function Wf(e,t,n,r){switch(Ch(t)){case 2:var i=_h;break;case 8:i=vh;break;default:i=yh}n=i.bind(null,t,n,e),i=void 0,!kn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Gf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=Pt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}En(function(){var r=a,i=Sn(n),s=[];a:{var c=pi.get(e);if(c!==void 0){var l=Bn,u=e;switch(e){case`keypress`:if(Fn(n)===0)break a;case`keydown`:case`keyup`:l=rr;break;case`focusin`:u=`focus`,l=Jn;break;case`focusout`:u=`blur`,l=Jn;break;case`beforeblur`:case`afterblur`:l=Jn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Kn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=qn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=or;break;case oi:case si:case ci:l=Yn;break;case fi:l=sr;break;case`scroll`:case`scrollend`:l=Vn;break;case`wheel`:l=cr;break;case`copy`:case`cut`:case`paste`:l=Xn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=ir;break;case`submit`:l=ar;break;case`toggle`:case`beforetoggle`:l=lr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Dn(m,p),g!=null&&d.push(Kf(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(l=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,l&&n!==xn&&(u=n.relatedTarget||n.fromElement)&&(Pt(u)||u[Et]))break a;(c||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?Pt(l):null,l!==null&&(f=o(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(c=null,l=r),c!==l&&(d=Kn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=ir,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:It(c),h=l==null?u:It(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,Pt(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=c&&l?C(c,l,Jf):null,c!==null&&Yf(s,u,c,d,!1),l!==null&&f!==null&&Yf(s,f,l,d,!0)))}a:{if(c=r?It(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=kr;else if(Cr(c)){if(Ar)_=zr;else{_=Lr;var v=Ir}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&gn(r.elementType)&&(_=kr):_=Rr;if(_&&=_(e,r)){wr(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?It(r):window,e){case`focusin`:(Cr(v)||v.contentEditable===`true`)&&(Xr=v,Zr=r,Qr=null);break;case`focusout`:Qr=Zr=Xr=null;break;case`mousedown`:$r=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:$r=!1,ei(s,n,i);break;case`selectionchange`:if(Yr)break;case`keydown`:case`keyup`:ei(s,n,i)}var y;if(dr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else yr?_r(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(mr&&n.locale!==`ko`&&(yr||b!==`onCompositionStart`?b===`onCompositionEnd`&&yr&&(y=Pn()):(jn=i,Mn=`value`in jn?jn.value:jn.textContent,yr=!0)),v=qf(r,b),0<v.length&&(b=new Zn(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=vr(n),y!==null&&(b.data=y)))),(y=pr?br(e,n):xr(e,n))&&(b=qf(r,`onBeforeInput`),0<b.length&&(v=new Zn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Nf(s,e,r,n,i)}Rf(s,t)})}function Kf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Dn(e,n),i!=null&&r.unshift(Kf(e,i,a)),i=Dn(e,t),i!=null&&r.push(Kf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Jf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Yf(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Dn(n,a),l!=null&&o.unshift(Kf(n,l,c))):i||(l=Dn(n,a),l!=null&&o.push(Kf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Xf=/\r\n?/g,Zf=/\u0000|\uFFFD/g;function Qf(e){return(typeof e==`string`?e:``+e).replace(Xf,`
|
|
300
|
+
`).replace(Zf,``)}function $f(e,t){return t=Qf(t),Qf(e)===t}function ep(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||fn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&fn(e,``+r);else return;break;case`className`:Xt(e,`class`,r);break;case`tabIndex`:Xt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Xt(e,n,r);break;case`style`:hn(e,r,o);return;case`data`:if(t!==`object`){Xt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=yn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&ep(e,t,`name`,a.name,a,null),ep(e,t,`formEncType`,a.formEncType,a,null),ep(e,t,`formMethod`,a.formMethod,a,null),ep(e,t,`formTarget`,a.formTarget,a,null)):(ep(e,t,`encType`,a.encType,a,null),ep(e,t,`method`,a.method,a,null),ep(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=yn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=bn);return;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=yn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:$(`beforetoggle`,e),$(`toggle`,e),Yt(e,`popover`,r);break;case`xlinkActuate`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Zt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Zt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Yt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=_n.get(n)||n,Yt(e,n,r);else return}P=!0}function tp(e,t,n,r,a,o){switch(n){case`style`:hn(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)fn(e,r);else if(typeof r==`number`||typeof r==`bigint`)fn(e,``+r);else return;break;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=bn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Vt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[Tt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}P=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Yt(e,n,r)}return}P=!0}function np(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:$(`error`,e),$(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,o,s,n,null)}}a&&ep(e,t,`srcSet`,n.srcSet,n,null),r&&ep(e,t,`src`,n.src,n,null);return;case`input`:$(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:ep(e,t,r,d,n,null)}}sn(e,o,c,l,u,s,a,!1);return;case`select`:for(a in $(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:ep(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&ln(e,!!r,n,!0):ln(e,!!r,t,!1);return;case`textarea`:for(s in $(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:ep(e,t,s,c,n,null)}dn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:ep(e,t,l,r,n,null)}return;case`dialog`:$(`beforetoggle`,e),$(`toggle`,e),$(`cancel`,e),$(`close`,e);break;case`iframe`:case`object`:$(`load`,e);break;case`video`:case`audio`:for(r=0;r<If.length;r++)$(If[r],e);break;case`image`:$(`error`,e),$(`load`,e);break;case`details`:$(`toggle`,e);break;case`embed`:case`source`:case`link`:$(`error`,e),$(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,u,r,n,null)}return;default:if(gn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&tp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&ep(e,t,c,r,n,null))}var rp={};function ip(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||ep(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(P=!0),o=m;break;case`name`:m!==f&&(P=!0),a=m;break;case`checked`:m!==f&&(P=!0),u=m;break;case`defaultChecked`:m!==f&&(P=!0),d=m;break;case`value`:m!==f&&(P=!0),s=m;break;case`defaultValue`:m!==f&&(P=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&ep(e,t,p,m,r,f)}}on(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||ep(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(P=!0),p=o;break;case`defaultValue`:o!==l&&(P=!0),c=o;break;case`multiple`:o!==l&&(P=!0),s=o;default:o!==l&&ep(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?ln(e,!!n,n?[]:``,!1):ln(e,!!n,t,!0)):ln(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:ep(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(P=!0),p=a;break;case`defaultValue`:a!==o&&(P=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&ep(e,t,s,a,r,o)}un(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:ep(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(P=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:ep(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&ep(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:ep(e,t,u,p,r,m)}return;default:if(gn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&tp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||tp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&ep(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||ep(e,t,f,p,r,m)}function ap(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function op(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&ap(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var sp=null,cp=null;function lp(e){return e.nodeType===9?e:e.ownerDocument}function up(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function dp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function fp(e,t,n,r){return n=lp(n).createElement(e),n[wt]=r,n[Tt]=t,np(n,e,t),Rt(n),n}function pp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var mp=null;function hp(){var e=window.event;return e&&e.type===`popstate`?e!==mp&&(mp=e,!0):(mp=null,!1)}var gp=typeof setTimeout==`function`?setTimeout:void 0,_p=typeof clearTimeout==`function`?clearTimeout:void 0,vp=typeof Promise==`function`?Promise:void 0,yp=typeof requestAnimationFrame==`function`?requestAnimationFrame:gp,bp=typeof queueMicrotask==`function`?queueMicrotask:vp===void 0?gp:function(e){return vp.resolve(null).then(e).catch(xp)};function xp(e){setTimeout(function(){throw e})}function Sp(e){return e===`head`}function Cp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Hh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_m(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_m(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[jt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_m(e.ownerDocument.body)}n=i}while(n);Hh(t)}function wp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Tp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Ep(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Dp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Op(e){return Dp(e.getBoundingClientRect(),getComputedStyle(e),e)}function kp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Dp(t,n,e)}function Ap(e){return e.documentElement.clientHeight}function jp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Mp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Ap(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Xm(f),u>$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Np(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Np.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Np.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Np.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Pp(e){return{name:e,group:new Np(`group`,e),imagePair:new Np(`image-pair`,e),old:new Np(`old`,e),new:new Np(`new`,e)}}function Fp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Fp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Bp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Rp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,Ip,e,s,r)}this._eventListeners=a}};function Ip(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Fp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Bp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Rp(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Lp,e,n,i),r.splice(t,1),a!==null&&a()}};function Lp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function Rp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function zp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Bp(e,t,n,r){if(e.length===0)return-1;r=zp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&zp(a.optionsOrUseCapture)===r)return i}return-1}Fp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Fp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,Vp,e,void 0,void 0)};function Vp(e,t){return e.tag!==6&&(e=_(e),pm(e,t))}Fp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,Hp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Vp(t[n],e);n--);};function Hp(e,t){return t.push(e),!1}Fp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=lp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,Up,e,void 0,void 0))};function Up(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Fp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,Wp,e,void 0,void 0)};function Wp(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Fp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,Gp,e,void 0,void 0);for(var n=t=0;n<Kp.length;n++){var r=Kp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Kp[t++]=r}Kp.length=t}};function Gp(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var Kp=[],qp=!1;function Jp(e,t,n){Kp.push({fragmentInstance:e,observer:t,instance:n}),qp||(qp=!0,mm(function(){qp=!1;var e=Kp;Kp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Fp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,Yp,e,void 0,void 0),e};function Yp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Fp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Fp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,Hp,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Xp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Xp(e,t,n,r,i){var a=Pt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function Zp(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Fp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,Hp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),Zp(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),Zp(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function Qp(e,t){return e=_(e),$p(e,t),!1}function $p(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function em(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Kp.length;i++){var a=Kp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Kp[r++]=a)}Kp.length=r,n.observe(e)}),$p(e,t))}function tm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Jp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nm(n),Nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[jt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lm(e.nextSibling),e===null)break}return null}function im(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lm(e.nextSibling),e===null))return null;return e}function am(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lm(e.nextSibling),e===null))return null;return e}function om(e){return e.data===`$?`||e.data===`$~`}function sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var um=null;function dm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function fm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function mm(e){yp(function(){yp(function(t){return e(t)})})}function hm(e,t,n){switch(t=lp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function gm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&ep(e,t,r,null,rp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===bn&&(e.onclick=null),Nt(e)}function _m(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Nt(e)}var vm=new Map,ym=new Set;function bm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var xm=N.d;N.d={f:Sm,r:Cm,D:Em,C:Dm,L:Om,m:km,X:jm,S:Am,M:Mm};function Sm(){var e=xm.f(),t=Fd();return e||t}function Cm(e){var t=Ft(e);t!==null&&t.tag===5&&t.type===`form`?Zs(t):xm.r(e)}var wm=typeof document>`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=an(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Rt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+an(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+an(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+an(n.imageSizes)+`"]`)):i+=`[href="`+an(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Mt]=!0,o.onload=o.onerror=function(){zt(o)}),Rt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+an(r)+`"][href="`+an(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Rt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Lt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Rt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Lt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Rt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Lt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Rt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=we.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Lt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Lt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Lt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+an(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Mt]){r.loading=1;return}}else t=e.createElement(`link`),t[Mt]=!0,t.onload=t.onerror=zt.bind(null,t),np(t,`link`,n),Rt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+an(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+an(n.href)+`"]`);if(r)return t.instance=r,Rt(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Rt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Rt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Rt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Rt(a),a):(r=n,(a=vm.get(o))&&(r=w({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Rt(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wm=null;function Gm(e,t,n){if(Wm===null){var r=new Map,i=Wm=new Map;i.set(n,r)}else i=Wm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[jt]||a[wt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Km(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Rt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Rt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$m===0&&($m=62500*op());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=nh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sh={$$typeof:te,Provider:null,Consumer:null,_currentValue:ge,_currentValue2:ge,_threadCount:0};function ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pt(0),this.hiddenUpdates=pt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function lh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Mi(3,null,null,t),e.current=a,a.stateNode=e,t=Ma(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},mo(a),e}function uh(e){return e?(e=Ai,e):Ai}function dh(e,t,n,r,i,a){i=uh(i),r.context===null?r.context=i:r.pendingContext=i,r=go(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=_o(e,r,t),n!==null&&(Ad(n,e,t),vo(n,e,t))}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(e.tag===13||e.tag===31){var t=Di(e,67108864);t!==null&&Ad(t,e,67108864),ph(e,67108864)}}function hh(e){if(e.tag===13||e.tag===31){var t=Dd();t=yt(t);var n=Di(e,t);n!==null&&Ad(n,e,t),ph(e,t)}}var gh=!0;function _h(e,t,n,r){var i=M.T;M.T=null;var a=N.p;try{N.p=2,yh(e,t,n,r)}finally{N.p=a,M.T=i}}function vh(e,t,n,r){var i=M.T;M.T=null;var a=N.p;try{N.p=8,yh(e,t,n,r)}finally{N.p=a,M.T=i}}function yh(e,t,n,r){if(gh){var i=bh(r);if(i===null)Gf(e,t,r,xh,n),Mh(e,r);else if(Ph(i,e,t,n,r))r.stopPropagation();else if(Mh(e,r),t&4&&-1<jh.indexOf(e)){for(;i!==null;){var a=Ft(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=st(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-et(o);s.entanglements[1]|=c,o&=~c}Cf(a),!(X&6)&&(fd=He()+500,wf(0,!1))}}break;case 31:case 13:s=Di(a,2),s!==null&&Ad(s,a,2),Fd(),ph(a,2)}if(a=bh(r),a===null&&Gf(e,t,r,xh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Gf(e,t,r,null,n)}}function bh(e){return e=Sn(e),Sh(e)}var xh=null;function Sh(e){if(xh=null,e=Pt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xh=e,null}function Ch(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Ue()){case We:return 2;case Ge:return 8;case Ke:case qe:return 32;case Je:return 268435456;default:return 32}default:return 32}}var wh=!1,Th=null,Eh=null,Dh=null,Oh=new Map,kh=new Map,Ah=[],jh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Mh(e,t){switch(e){case`focusin`:case`focusout`:Th=null;break;case`dragenter`:case`dragleave`:Eh=null;break;case`mouseover`:case`mouseout`:Dh=null;break;case`pointerover`:case`pointerout`:Oh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kh.delete(t.pointerId)}}function Nh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Ft(t),t!==null&&mh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ph(e,t,n,r,i){switch(t){case`focusin`:return Th=Nh(Th,e,t,n,r,i),!0;case`dragenter`:return Eh=Nh(Eh,e,t,n,r,i),!0;case`mouseover`:return Dh=Nh(Dh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Oh.set(a,Nh(Oh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kh.set(a,Nh(kh.get(a)||null,e,t,n,r,i)),!0}return!1}function Fh(e){var t=Pt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,St(e.priority,function(){hh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,St(e.priority,function(){hh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ih(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);xn=r,n.target.dispatchEvent(r),xn=null}else return t=Ft(n),t!==null&&mh(t),e.blockedOn=n,!1;t.shift()}return!0}function Lh(e,t,n){Ih(e)&&n.delete(t)}function Rh(){wh=!1,Th!==null&&Ih(Th)&&(Th=null),Eh!==null&&Ih(Eh)&&(Eh=null),Dh!==null&&Ih(Dh)&&(Dh=null),Oh.forEach(Lh),kh.forEach(Lh)}function zh(e,n){e.blockedOn===n&&(e.blockedOn=null,wh||(wh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rh)))}var Bh=null;function Vh(e){Bh!==e&&(Bh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Bh===e&&(Bh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sh(r||n)===null)continue;break}var a=Ft(n);a!==null&&(e.splice(t,3),t-=3,Ys(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hh(e){function t(t){return zh(t,e)}Th!==null&&zh(Th,e),Eh!==null&&zh(Eh,e),Dh!==null&&zh(Dh,e),Oh.forEach(t),kh.forEach(t);for(var n=0;n<Ah.length;n++){var r=Ah[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ah.length&&(n=Ah[0],n.blockedOn===null);)Fh(n),n.blockedOn===null&&Ah.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Tt]||null;if(typeof a==`function`)o||Vh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Tt]||null)s=o.formAction;else if(Sh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vh(n)}}}function Uh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Wh(e){this._internalRoot=e}Gh.prototype.render=Wh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dh(n,Dd(),e,t,null,null)},Gh.prototype.unmount=Wh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dh(e.current,2,null,e,null,null),Fd(),t[Et]=null}};function Gh(e){this._internalRoot=e}Gh.prototype.unstable_scheduleHydration=function(e){if(e){var t=xt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ah.length&&t!==0&&t<Ah[n].priority;n++);Ah.splice(n,0,e),n===0&&Fh(e)}};var Kh=n.version;if(Kh!==`19.3.1`)throw Error(i(527,Kh,`19.3.1`));N.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var qh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:M,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jh.isDisabled&&Jh.supportsFiber)try{Ze=Jh.inject(qh),Qe=Jh}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=vc,s=yc,c=bc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lh(e,1,!1,null,null,n,r,null,o,s,c,Uh),e[Et]=t.current,Uf(e),new Wh(t)}})),Wf=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Uf()}))(),Gf=await(await fetch(`definition.loadmap`)).text(),Kf=document.getElementById(`root`),qf=vn(Gf);if(!qf.ok||!qf.definition){let e=document.createElement(`pre`);e.textContent=qf.diagnostics.map(e=>vt(e,Gf,`definition.loadmap`)).join(`
|
|
301
|
+
`),Kf.replaceChildren(e)}else{let{model:e,view:t,options:n}=qf.definition;document.title=e.title??`loadmap`;let r=null;(0,Wf.createRoot)(Kf).render((0,J.createElement)(Rf,{model:e,view:t,..._n(n),ref:e=>{r?.(),r=e?ou(e):null}}))}
|