@shotstack/shotstack-studio 1.7.1 → 1.8.1

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.
@@ -1,4 +1,4 @@
1
- (function(q,Be){typeof exports=="object"&&typeof module<"u"?Be(exports,require("pixi.js"),require("howler"),require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js","howler","opentype.js"],Be):(q=typeof globalThis<"u"?globalThis:q||self,Be(q.ShotstackStudio={},q.PIXI,q.Howler,q.opentype))})(this,function(q,Be,zn,Hn){"use strict";function Oi(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}function Nn(s,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in s)){const n=Object.getOwnPropertyDescriptor(i,r);n&&Object.defineProperty(s,r,n.get?n:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}const R=Oi(Be),Un=Oi(zn),Rs=Oi(Hn);class jn{curves={};constructor(){this.initializeCurves()}initializeCurves(){this.curves={ease:[[.25,.1],[.25,1]],easeIn:[[.42,0],[1,1]],easeOut:[[0,0],[.58,1]],easeInOut:[[.42,0],[.58,1]],easeInQuad:[[.55,.085],[.68,.53]],easeInCubic:[[.55,.055],[.675,.19]],easeInQuart:[[.895,.03],[.685,.22]],easeInQuint:[[.755,.05],[.855,.06]],easeInSine:[[.47,0],[.745,.715]],easeInExpo:[[.95,.05],[.795,.035]],easeInCirc:[[.6,.04],[.98,.335]],easeInBack:[[.6,-.28],[.735,.045]],easeOutQuad:[[.25,.46],[.45,.94]],easeOutCubic:[[.215,.61],[.355,1]],easeOutQuart:[[.165,.84],[.44,1]],easeOutQuint:[[.23,1],[.32,1]],easeOutSine:[[.39,.575],[.565,1]],easeOutExpo:[[.19,1],[.22,1]],easeOutCirc:[[.075,.82],[.165,1]],easeOutBack:[[.175,.885],[.32,1.275]],easeInOutQuad:[[.455,.03],[.515,.955]],easeInOutCubic:[[.645,.045],[.355,1]],easeInOutQuart:[[.77,0],[.175,1]],easeInOutQuint:[[.86,0],[.07,1]],easeInOutSine:[[.445,.05],[.55,.95]],easeInOutExpo:[[1,0],[0,1]],easeInOutCirc:[[.785,.135],[.15,.86]],easeInOutBack:[[.68,-.55],[.265,1.55]]}}getValue(e,t,i,r){const n=this.curves[r??""]??this.curves.ease,[[o,a],[p,m]]=n,d=i+(3*o-3*p+1)*i*(1-i),l=e,c=e+(t-e)*a,u=e+(t-e)*m,h=t,f=d,b=1-f;return b**3*l+3*b**2*f*c+3*b*f**2*u+f**3*h}}class ke{property;length;cubicBuilder;constructor(e,t,i=0){this.property=this.createKeyframes(e,t,i),this.length=t,this.cubicBuilder=new jn}getValue(e){const t=this.property.find(r=>e>=r.start&&e<r.start+r.length);if(!t){if(this.property.length>0){if(e>=this.length)return this.property[this.property.length-1].to;if(e<0)return this.property[0].from}return 1}const i=(e-t.start)/t.length;switch(t.interpolation){case"bezier":return this.cubicBuilder.getValue(t.from,t.to,i,t.easing);case"constant":return t.from;case"linear":default:return t.from+(t.to-t.from)*i}}createKeyframes(e,t,i=0){if(typeof e=="number")return[{start:0,length:t,from:e,to:e}];if(!e.length)throw new Error("Keyframes should have at least one value.");const r=this.createNormalizedKeyframes(e);try{this.validateKeyframes(r)}catch(n){console.warn("Keyframe configuration issues detected:",n)}return this.insertFillerKeyframes(r,t,i)}createNormalizedKeyframes(e){return e.toSorted((t,i)=>t.start-i.start).map(t=>({...t,start:t.start*1e3,length:t.length*1e3}))}validateKeyframes(e){for(let t=0;t<e.length;t+=1){const i=e[t],r=e[t+1];if(!r){if(i.start+i.length>this.length)throw new Error("Last keyframe exceeds the maximum duration.");break}if(i.start+i.length>r.start)throw new Error("Overlapping keyframes detected.")}}insertFillerKeyframes(e,t,i=0){const r=[];for(let n=0;n<e.length;n+=1){const o=e[n],a=e[n+1];if(n===0&&o.start!==0){const d={start:0,length:o.start,from:i,to:o.from};r.push(d)}if(r.push(o),!a){if(o.start+o.length<t){const l=o.start+o.length,c={start:l,length:t-l,from:o.to,to:o.to};r.push(c)}break}if(o.start+o.length!==a.start){const d={start:o.start+o.length,length:a.start,from:o.to,to:a.from};r.push(d)}}return r}}class zt{static Name="AudioLoadParser";id;name;extension;validAudioExtensions;constructor(){this.id=zt.Name,this.name=zt.Name,this.extension={type:[R.ExtensionType.LoadParser],priority:R.LoaderParserPriority.Normal,ref:null},this.validAudioExtensions=["mp3","mpeg","ogg","wav"]}test(e){const t=e.split("?")[0]?.split(".").pop()??"";return this.validAudioExtensions.includes(t)}async load(e,t,i){return new Promise(r=>{const n={src:e},o=new Howl(n);o.on("load",()=>r(o)),o.on("loaderror",()=>r(null))})}unload(e){e?.unload()}}class Vn{clipConfiguration;constructor(e){this.clipConfiguration=e}build(e,t){const i=[],r=[],n=[],o=[],a=[],{effect:p,length:m}=this.clipConfiguration;if(!p)return{offsetXKeyframes:i,offsetYKeyframes:r,opacityKeyframes:n,scaleKeyframes:o,rotationKeyframes:a};const d=0;switch(this.getPresetName()){case"zoomIn":{const c=this.getZoomSpeed(),u=1*this.clipConfiguration.scale,h=c*this.clipConfiguration.scale;o.push({from:u,to:h,start:d,length:m,interpolation:"linear"});break}case"zoomOut":{const u=this.getZoomSpeed()*this.clipConfiguration.scale,h=1*this.clipConfiguration.scale;o.push({from:u,to:h,start:d,length:m,interpolation:"linear"});break}case"slideLeft":{let c=this.getSlideStart();const u=e.width+e.width*c*2,h=t.height/t.width*e.height;if(h<u){const f=Math.abs(u/e.width);o.push({from:f,to:f,start:d,length:m,interpolation:"linear"})}else c=(h-e.width)/2/e.width;i.push({from:c,to:-c,start:d,length:m});break}case"slideRight":{let c=this.getSlideStart();const u=e.width+e.width*c*2,h=t.height/t.width*e.height;if(h<u){const f=Math.abs(u/e.width);o.push({from:f,to:f,start:d,length:m,interpolation:"linear"})}else c=(h-e.width)/2/e.width;i.push({from:-c,to:c,start:d,length:m});break}case"slideUp":{let c=this.getSlideStart();const u=e.height+e.height*c*2,h=t.height/t.width*e.width;if(h<u){const f=Math.abs(u/e.height);o.push({from:f,to:f,start:d,length:m,interpolation:"linear"})}else c=(h-e.height)/2/e.height;r.push({from:c,to:-c,start:d,length:m});break}case"slideDown":{let c=this.getSlideStart();const u=e.height+e.height*c*2,h=t.height/t.width*e.width;if(h<u){const f=Math.abs(u/e.height);o.push({from:f,to:f,start:d,length:m,interpolation:"linear"})}else c=(h-e.height)/2/e.height;r.push({from:-c,to:c,start:d,length:m});break}}return{offsetXKeyframes:i,offsetYKeyframes:r,opacityKeyframes:n,scaleKeyframes:o,rotationKeyframes:a}}getPresetName(){const[e]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);return e}getZoomSpeed(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("zoom"))switch(t){case"Slow":return 1.1;case"Fast":return 1.7;default:return 1.3}return 0}getSlideStart(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("slide"))switch(t){case"Slow":return .03;case"Fast":return 1.7;default:return .12}return 0}}class Wn{clipConfiguration;constructor(e){this.clipConfiguration=e}build(){const e=[],t=[],i=[],r=[],n=[],o=this.buildInPreset();e.push(...o.offsetXKeyframes),t.push(...o.offsetYKeyframes),i.push(...o.opacityKeyframes),r.push(...o.scaleKeyframes),n.push(...o.rotationKeyframes);const a=this.buildOutPreset();return e.push(...a.offsetXKeyframes),t.push(...a.offsetYKeyframes),i.push(...a.opacityKeyframes),r.push(...a.scaleKeyframes),n.push(...a.rotationKeyframes),{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}buildInPreset(){const e=[],t=[],i=[],r=[],n=[];if(!this.clipConfiguration.transition?.in)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n};const o=0,a=this.getInPresetLength();switch(this.getInPresetName()){case"fade":{const d=Math.max(0,Math.min(this.clipConfiguration.opacity??1,1));i.push({from:0,to:d,start:o,length:a,interpolation:"linear"});break}case"zoom":{const d=this.clipConfiguration.scale+9,l=this.clipConfiguration.scale;r.push({from:d,to:l,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideLeft":{const m=this.clipConfiguration.offset?.x+.025,d=this.clipConfiguration.offset?.x;e.push({from:m,to:d,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideRight":{const m=this.clipConfiguration.offset?.x-.025,d=this.clipConfiguration.offset?.x;e.push({from:m,to:d,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideUp":{const m=this.clipConfiguration.offset?.y+.025,d=this.clipConfiguration.offset?.y;t.push({from:m,to:d,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideDown":{const m=this.clipConfiguration.offset?.y-.025,d=this.clipConfiguration.offset?.y;t.push({from:m,to:d,start:o,length:a,interpolation:"bezier",easing:"easeOut"}),i.push({from:0,to:1,start:o,length:a,interpolation:"bezier",easing:"easeOut"});break}case"carouselLeft":case"carouselRight":case"carouselUp":case"carouselDown":case"shuffleTopRight":case"shuffleRightTop":case"shuffleRightBottom":case"shuffleBottomRight":case"shuffleBottomLeft":case"shuffleLeftBottom":case"shuffleLeftTop":case"shuffleTopLeft":default:console.warn(`Unimplemented transition:in preset "${this.clipConfiguration.transition.in}"`);break}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}buildOutPreset(){const e=[],t=[],i=[],r=[],n=[];if(!this.clipConfiguration.transition?.out)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n};const o=this.getOutPresetLength(),a=this.clipConfiguration.length-o;switch(this.getOutPresetName()){case"fade":{const m=Math.max(0,Math.min(this.clipConfiguration.opacity??1,1));i.push({from:m,to:0,start:a,length:o,interpolation:"linear"});break}case"zoom":{const d=this.clipConfiguration.scale,l=d+9;r.push({from:d,to:l,start:a,length:o,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeOut"});break}case"slideLeft":{const m=this.clipConfiguration.offset?.x,d=m-.025;e.push({from:m,to:d,start:a,length:o,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeOut"});break}case"slideRight":{const m=this.clipConfiguration.offset?.x,d=m+.025;e.push({from:m,to:d,start:a,length:o,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeOut"});break}case"slideUp":{const m=this.clipConfiguration.offset?.y,d=m-.025;t.push({from:m,to:d,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideDown":{const m=this.clipConfiguration.offset?.y,d=m+.025;t.push({from:m,to:d,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),i.push({from:1,to:0,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"carouselLeft":case"carouselRight":case"carouselUp":case"carouselDown":case"shuffleTopRight":case"shuffleRightTop":case"shuffleRightBottom":case"shuffleBottomRight":case"shuffleBottomLeft":case"shuffleLeftBottom":case"shuffleLeftTop":case"shuffleTopLeft":default:console.warn(`Unimplemented transition:out preset "${this.clipConfiguration.transition.out}"`);break}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}getInPresetName(){const[e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);return e}getOutPresetName(){const[e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);return e}getInPresetLength(){const[,e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);switch(e){case"Slow":return 2;case"Fast":return .5;case"VeryFast":return .25;default:return 1}}getOutPresetLength(){const[,e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);switch(e){case"Slow":return 2;case"Fast":return .5;case"VeryFast":return .25;default:return 1}}}class Gn{static ButtonLeftClick=0;static ButtonRightClick=3}class Zn{containerSize;constructor(e){this.containerSize=e}relativeToAbsolute(e,t,i){switch(t){case"topLeft":return{x:i.x*this.containerSize.width,y:-i.y*this.containerSize.height};case"topRight":return{x:(i.x+1)*this.containerSize.width-e.width,y:-i.y*this.containerSize.height};case"bottomLeft":return{x:i.x*this.containerSize.width,y:(-i.y+1)*this.containerSize.height-e.height};case"bottomRight":return{x:(i.x+1)*this.containerSize.width-e.width,y:(-i.y+1)*this.containerSize.height-e.height};case"left":return{x:i.x*this.containerSize.width,y:(-i.y+.5)*this.containerSize.height-e.height/2};case"right":return{x:(i.x+1)*this.containerSize.width-e.width,y:(-i.y+.5)*this.containerSize.height-e.height/2};case"top":return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:-i.y*this.containerSize.height};case"bottom":return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:(-i.y+1)*this.containerSize.height-e.height};case"center":default:return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:(-i.y+.5)*this.containerSize.height-e.height/2}}}absoluteToRelative(e,t,i){switch(t){case"topLeft":return{x:i.x/this.containerSize.width,y:-(i.y/this.containerSize.height)};case"topRight":return{x:(i.x+e.width)/this.containerSize.width-1,y:-(i.y/this.containerSize.height)};case"bottomLeft":return{x:i.x/this.containerSize.width,y:-((i.y+e.height)/this.containerSize.height-1)};case"bottomRight":return{x:(i.x+e.width)/this.containerSize.width-1,y:-((i.y+e.height)/this.containerSize.height-1)};case"left":return{x:i.x/this.containerSize.width,y:-((i.y+e.height/2)/this.containerSize.height-.5)};case"right":return{x:(i.x+e.width)/this.containerSize.width-1,y:-((i.y+e.height/2)/this.containerSize.height-.5)};case"top":return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-(i.y/this.containerSize.height)};case"bottom":return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-((i.y+e.height)/this.containerSize.height-1)};case"center":default:return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-((i.y+e.height/2)/this.containerSize.height-.5)}}}}class Je{container;constructor(){this.container=new R.Container}getContainer(){return this.container}}class we extends Je{static SnapThreshold=20;static DiscardedFrameCount=Math.ceil(1/30*1e3);static ScaleHandleRadius=10;static RotationHandleRadius=10;static RotationHandleOffset=50;static OutlineWidth=5;static MinScale=.1;static MaxScale=5;layer;shouldDispose;edit;clipConfiguration;positionBuilder;offsetXKeyframeBuilder;offsetYKeyframeBuilder;scaleKeyframeBuilder;opacityKeyframeBuilder;rotationKeyframeBuilder;outline;topLeftScaleHandle;topRightScaleHandle;bottomLeftScaleHandle;bottomRightScaleHandle;rotationHandle;isHovering;isDragging;dragOffset;scaleDirection;scaleStart;scaleOffset;isRotating;rotationStart;rotationOffset;initialClipConfiguration;contentContainer;constructor(e,t){super(),this.edit=e,this.layer=0,this.shouldDispose=!1,this.clipConfiguration=t,this.positionBuilder=new Zn(e.size),this.outline=null,this.topLeftScaleHandle=null,this.topRightScaleHandle=null,this.bottomRightScaleHandle=null,this.bottomLeftScaleHandle=null,this.rotationHandle=null,this.isHovering=!1,this.isDragging=!1,this.dragOffset={x:0,y:0},this.scaleDirection=null,this.scaleStart=null,this.scaleOffset={x:0,y:0},this.isRotating=!1,this.rotationStart=null,this.rotationOffset={x:0,y:0},this.initialClipConfiguration=null,this.contentContainer=new R.Container,this.getContainer().addChild(this.contentContainer)}reconfigureAfterRestore(){this.configureKeyframes()}configureKeyframes(){if(this.offsetXKeyframeBuilder=new ke(this.clipConfiguration.offset?.x??0,this.getLength()),this.offsetYKeyframeBuilder=new ke(this.clipConfiguration.offset?.y??0,this.getLength()),this.scaleKeyframeBuilder=new ke(this.clipConfiguration.scale??1,this.getLength(),1),this.opacityKeyframeBuilder=new ke(this.clipConfiguration.opacity??1,this.getLength(),1),this.rotationKeyframeBuilder=new ke(this.clipConfiguration.transform?.rotate?.angle??0,this.getLength()),this.clipHasKeyframes())return;const e=[],t=[],i=[],r=[],n=[],o=new Vn(this.clipConfiguration).build(this.edit.size,this.getSize());e.push(...o.offsetXKeyframes),t.push(...o.offsetYKeyframes),i.push(...o.opacityKeyframes),r.push(...o.scaleKeyframes),n.push(...o.rotationKeyframes);const a=new Wn(this.clipConfiguration).build();e.push(...a.offsetXKeyframes),t.push(...a.offsetYKeyframes),i.push(...a.opacityKeyframes),r.push(...a.scaleKeyframes),n.push(...a.rotationKeyframes),e.length&&(this.offsetXKeyframeBuilder=new ke(e,this.getLength())),t.length&&(this.offsetYKeyframeBuilder=new ke(t,this.getLength())),i.length&&(this.opacityKeyframeBuilder=new ke(i,this.getLength(),1)),r.length&&(this.scaleKeyframeBuilder=new ke(r,this.getLength(),1)),n.length&&(this.rotationKeyframeBuilder=new ke(n,this.getLength()))}async load(){this.outline=new R.Graphics,this.getContainer().addChild(this.outline),this.topLeftScaleHandle=new R.Graphics,this.topRightScaleHandle=new R.Graphics,this.bottomRightScaleHandle=new R.Graphics,this.bottomLeftScaleHandle=new R.Graphics,this.rotationHandle=new R.Graphics,this.topLeftScaleHandle.zIndex=1e3,this.topRightScaleHandle.zIndex=1e3,this.bottomRightScaleHandle.zIndex=1e3,this.bottomLeftScaleHandle.zIndex=1e3,this.rotationHandle.zIndex=1e3,this.getContainer().addChild(this.topLeftScaleHandle),this.getContainer().addChild(this.topRightScaleHandle),this.getContainer().addChild(this.bottomRightScaleHandle),this.getContainer().addChild(this.bottomLeftScaleHandle),this.getContainer().addChild(this.rotationHandle),this.getContainer().sortableChildren=!0,this.getContainer().cursor="pointer",this.getContainer().eventMode="static",this.getContainer().on("pointerdown",this.onPointerStart.bind(this)),this.getContainer().on("pointermove",this.onPointerMove.bind(this)),this.getContainer().on("globalpointermove",this.onPointerMove.bind(this)),this.getContainer().on("pointerup",this.onPointerUp.bind(this)),this.getContainer().on("pointerupoutside",this.onPointerUp.bind(this)),this.getContainer().on("pointerover",this.onPointerOver.bind(this)),this.getContainer().on("pointerout",this.onPointerOut.bind(this))}update(e,t){if(this.getContainer().visible=this.isActive(),this.getContainer().zIndex=1e5-this.layer*100,!this.isActive())return;const i=this.getPivot(),r=this.getPosition(),n=this.getContainerScale();this.getContainer().scale.set(n.x,n.y),this.getContainer().pivot.set(i.x,i.y),this.getContainer().position.set(r.x+i.x,r.y+i.y);const o=this.getRotation();this.contentContainer.alpha=this.getOpacity(),this.getContainer().angle=o,this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.shouldDiscardFrame()&&(this.contentContainer.alpha=0)}draw(){if(!this.outline)return;const e=this.edit.isPlayerSelected(this),t=this.edit.isInExportMode();if((!this.isActive()||!e)&&!this.isHovering||t){this.outline.clear(),this.topLeftScaleHandle?.clear(),this.topRightScaleHandle?.clear(),this.bottomRightScaleHandle?.clear(),this.bottomLeftScaleHandle?.clear(),this.rotationHandle?.clear();return}const i=this.isHovering||this.isDragging?65535:16777215,r=this.getSize(),n=this.getScale();if(this.outline.clear(),this.outline.strokeStyle={width:we.OutlineWidth/n,color:i},this.outline.rect(0,0,r.width,r.height),this.outline.stroke(),!this.topLeftScaleHandle||!this.topRightScaleHandle||!this.bottomRightScaleHandle||!this.bottomLeftScaleHandle||!this.isActive()||!e)return;this.topLeftScaleHandle.fillStyle={color:i},this.topLeftScaleHandle.clear();const o=we.ScaleHandleRadius*2/n;if(this.topLeftScaleHandle.rect(-o/2,-o/2,o,o),this.topLeftScaleHandle.fill(),this.topRightScaleHandle.fillStyle={color:i},this.topRightScaleHandle.clear(),this.topRightScaleHandle.rect(r.width-o/2,-o/2,o,o),this.topRightScaleHandle.fill(),this.bottomRightScaleHandle.fillStyle={color:i},this.bottomRightScaleHandle.clear(),this.bottomRightScaleHandle.rect(r.width-o/2,r.height-o/2,o,o),this.bottomRightScaleHandle.fill(),this.bottomLeftScaleHandle.fillStyle={color:i},this.bottomLeftScaleHandle.clear(),this.bottomLeftScaleHandle.rect(-o/2,r.height-o/2,o,o),this.bottomLeftScaleHandle.fill(),!this.rotationHandle)return;const a=r.width/2,p=-50/n;this.rotationHandle.clear(),this.rotationHandle.fillStyle={color:i},this.rotationHandle.circle(a,p,we.RotationHandleRadius/n),this.rotationHandle.fill(),this.outline.strokeStyle={width:we.OutlineWidth/n,color:i},this.outline.moveTo(a,0),this.outline.lineTo(a,p),this.outline.stroke()}dispose(){this.outline?.destroy(),this.outline=null,this.topLeftScaleHandle?.destroy(),this.topLeftScaleHandle=null,this.topRightScaleHandle?.destroy(),this.topRightScaleHandle=null,this.bottomLeftScaleHandle?.destroy(),this.bottomLeftScaleHandle=null,this.bottomRightScaleHandle?.destroy(),this.bottomRightScaleHandle=null,this.rotationHandle?.destroy(),this.rotationHandle=null,this.contentContainer?.destroy()}getStart(){return this.clipConfiguration.start*1e3}getLength(){return this.clipConfiguration.length*1e3}getEnd(){return this.getStart()+this.getLength()}getPlaybackTime(){const e=this.edit.playbackTime-this.getStart();return e<0?0:e>this.getLength()?this.getLength():e}getOpacity(){return this.opacityKeyframeBuilder?.getValue(this.getPlaybackTime())??1}getPosition(){const e={x:this.offsetXKeyframeBuilder?.getValue(this.getPlaybackTime())??0,y:this.offsetYKeyframeBuilder?.getValue(this.getPlaybackTime())??0};return this.positionBuilder.relativeToAbsolute(this.getSize(),this.clipConfiguration.position??"center",e)}getPivot(){const e=this.getSize();return{x:e.width/2,y:e.height/2}}getFitScale(){if(this.clipConfiguration.width&&this.clipConfiguration.height)return 1;switch(this.clipConfiguration.fit??"crop"){case"crop":{const e=this.edit.size.width/this.getSize().width,t=this.edit.size.height/this.getSize().height;return this.edit.size.height>=this.edit.size.width?t:e}case"cover":return Math.max(this.edit.size.width/this.getSize().width,this.edit.size.height/this.getSize().height);case"contain":return Math.min(this.edit.size.width/this.getSize().width,this.edit.size.height/this.getSize().height);case"none":default:return 1}}getScale(){return(this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1)*this.getFitScale()}getContainerScale(){if(this.clipConfiguration.width&&this.clipConfiguration.height)return{x:1,y:1};const e=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1,t=this.getSize(),i=this.clipConfiguration.fit??"crop";if(t.width===0||t.height===0)return{x:e,y:e};const r=this.edit.size.width/t.width,n=this.edit.size.height/t.height;switch(i){case"contain":{const o=Math.min(r,n)*e;return{x:o,y:o}}case"crop":{const a=(this.edit.size.height>=this.edit.size.width?n:r)*e;return{x:a,y:a}}case"cover":return{x:r*e,y:n*e};case"none":default:return{x:e,y:e}}}getRotation(){return this.rotationKeyframeBuilder?.getValue(this.getPlaybackTime())??0}isActive(){return this.edit.playbackTime>=this.getStart()&&this.edit.playbackTime<this.getEnd()}shouldDiscardFrame(){return this.getPlaybackTime()<we.DiscardedFrameCount}onPointerStart(e){if(e.button!==Gn.ButtonLeftClick||(this.edit.events.emit("canvas:clip:clicked",{player:this}),this.initialClipConfiguration=structuredClone(this.clipConfiguration),this.clipHasKeyframes()))return;if(this.scaleDirection=null,this.topLeftScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="topLeft"),this.topRightScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="topRight"),this.bottomRightScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="bottomRight"),this.bottomLeftScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="bottomLeft"),this.scaleDirection!==null){this.scaleStart=this.getScale()/this.getFitScale();const p=e.getLocalPosition(this.edit.getContainer());this.scaleOffset=p;return}if(this.rotationHandle?.getBounds().containsPoint(e.globalX,e.globalY)){this.isRotating=!0,this.rotationStart=this.getRotation();const p=e.getLocalPosition(this.edit.getContainer());this.rotationOffset=p;return}this.isDragging=!0;const a=e.getLocalPosition(this.edit.getContainer());this.dragOffset={x:a.x-this.getContainer().position.x,y:a.y-this.getContainer().position.y}}onPointerMove(e){if(this.scaleDirection!==null&&this.scaleStart!==null){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPosition(),r=this.getPivot(),n={x:i.x+r.x,y:i.y+r.y},o=Math.sqrt((this.scaleOffset.x-n.x)**2+(this.scaleOffset.y-n.y)**2),p=Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)/o,m=this.scaleStart*p;this.clipConfiguration.scale=Math.max(we.MinScale,Math.min(m,we.MaxScale)),this.scaleKeyframeBuilder=new ke(this.clipConfiguration.scale,this.getLength(),1);return}if(this.isRotating&&this.rotationStart!==null){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPosition(),r=this.getPivot(),n={x:i.x+r.x,y:i.y+r.y},o=Math.atan2(this.rotationOffset.y-n.y,this.rotationOffset.x-n.x),p=(Math.atan2(t.y-n.y,t.x-n.x)-o)*(180/Math.PI);let m=this.rotationStart+p;const d=45,l=m%d,c=2;Math.abs(l)<c?m=Math.floor(m/d)*d:Math.abs(l-d)<c&&(m=Math.ceil(m/d)*d),this.clipConfiguration.transform||(this.clipConfiguration.transform={rotate:{angle:0}}),this.clipConfiguration.transform.rotate||(this.clipConfiguration.transform.rotate={angle:0}),this.clipConfiguration.transform.rotate.angle=m,this.rotationKeyframeBuilder=new ke(this.clipConfiguration.transform.rotate.angle,this.getLength());return}if(this.isDragging){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPivot(),r={x:t.x-this.dragOffset.x,y:t.y-this.dragOffset.y},n={x:r.x-i.x,y:r.y-i.y},o=[{x:0,y:0},{x:this.edit.size.width,y:0},{x:0,y:this.edit.size.height},{x:this.edit.size.width,y:this.edit.size.height}],a={x:this.edit.size.width/2,y:this.edit.size.height/2},p=[...o,a],m=[{x:n.x,y:n.y},{x:n.x+this.getSize().width,y:n.y},{x:n.x,y:n.y+this.getSize().height},{x:n.x+this.getSize().width,y:n.y+this.getSize().height}],d={x:n.x+this.getSize().width/2,y:n.y+this.getSize().height/2},l=[...m,d];let c=we.SnapThreshold,u=we.SnapThreshold,h=null,f=null;for(const g of l)for(const y of p){const v=Math.abs(g.x-y.x);v<c&&(c=v,h=n.x+(y.x-g.x));const _=Math.abs(g.y-y.y);_<u&&(u=_,f=n.y+(y.y-g.y))}h!==null&&(n.x=h),f!==null&&(n.y=f);const b=this.positionBuilder.absoluteToRelative(this.getSize(),this.clipConfiguration.position??"center",n);this.clipConfiguration.offset||(this.clipConfiguration.offset={x:0,y:0}),this.clipConfiguration.offset.x=b.x,this.clipConfiguration.offset.y=b.y,this.offsetXKeyframeBuilder=new ke(this.clipConfiguration.offset.x,this.getLength()),this.offsetYKeyframeBuilder=new ke(this.clipConfiguration.offset.y,this.getLength())}}onPointerUp(){(this.isDragging||this.scaleDirection!==null||this.isRotating)&&this.hasStateChanged()&&this.edit.setUpdatedClip(this,this.initialClipConfiguration,structuredClone(this.clipConfiguration)),this.isDragging=!1,this.dragOffset={x:0,y:0},this.scaleDirection=null,this.scaleStart=null,this.scaleOffset={x:0,y:0},this.isRotating=!1,this.rotationStart=null,this.rotationOffset={x:0,y:0},this.initialClipConfiguration=null}onPointerOver(){this.isHovering=!0}onPointerOut(){this.isHovering=!1}clipHasPresets(){return!!this.clipConfiguration.effect||!!this.clipConfiguration.transition?.in||!!this.clipConfiguration.transition?.out}clipHasKeyframes(){return[this.clipConfiguration.scale,this.clipConfiguration.offset?.x,this.clipConfiguration.offset?.y,this.clipConfiguration.transform?.rotate?.angle].some(e=>e&&typeof e!="number")}hasStateChanged(){if(!this.initialClipConfiguration)return!1;const e=this.clipConfiguration.offset?.x,t=this.clipConfiguration.offset?.y,i=this.clipConfiguration.scale,r=Number(this.clipConfiguration.transform?.rotate?.angle??0),n=this.initialClipConfiguration.offset?.x,o=this.initialClipConfiguration.offset?.y,a=this.initialClipConfiguration.scale,p=Number(this.initialClipConfiguration.transform?.rotate?.angle??0);return n!==void 0&&e!==n||o!==void 0&&t!==o||a!==void 0&&i!==a||r!==p}applyFixedDimensions(){const e=this.clipConfiguration.width,t=this.clipConfiguration.height;if(!e||!t)return;const i=this.contentContainer.children[0];if(!i||!i.texture)return;const r=i.texture.width,n=i.texture.height,o=this.clipConfiguration.fit||"crop";if(!this.contentContainer.mask){const p=new R.Graphics;p.rect(0,0,e,t),p.fill(16777215),this.contentContainer.addChild(p),this.contentContainer.mask=p}const a=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1;switch(i.anchor.set(.5,.5),o){case"cover":{const p=e/r,m=t/n;i.scale.set(p,m),i.position.set(e/2,t/2);break}case"crop":{const p=this.edit.size.width,m=this.edit.size.height;let d=1;(r>p||n>m)&&(d=Math.min(p/r,m/n));const l=r*d,c=n*d,u=Math.max(e/l,t/c),h=d<1?d*u:Math.max(1,u);i.scale.set(h,h),i.anchor.set(.5,.5),i.position.set(e/2,t/2);break}case"contain":{const p=e/r,m=t/n,d=Math.min(p,m);i.scale.set(d,d),i.position.set(e/2,t/2);break}case"none":default:{i.scale.set(1,1),i.position.set(e/2,t/2);break}}this.contentContainer.scale.set(a,a),this.contentContainer.position.set(e/2*(1-a),t/2*(1-a))}applyAnchorPositioning(e,t,i,r){const n=r.width,o=r.height;if(!!r.mask){r.position.set(0,0);return}const p=(e??"center").toLowerCase();let m=0,d=0;p.includes("left")||p==="left"?m=0:p.includes("right")||p==="right"?m=t-n:m=(t-n)/2,p.includes("top")||p==="top"?d=0:p.includes("bottom")||p==="bottom"?d=i-o:d=(i-o)/2,r.position.set(m,d)}}class Os extends we{audioResource;isPlaying;volumeKeyframeBuilder;syncTimer;constructor(e,t){super(e,t),this.audioResource=null,this.isPlaying=!1;const i=t.asset;this.volumeKeyframeBuilder=new ke(i.volume??1,this.getLength()),this.syncTimer=0}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,loadParser:zt.Name},r=await this.edit.assetLoader.load(t,i);if(!(r instanceof Un.Howl))throw new Error(`Invalid audio source '${e.src}'.`);this.audioResource=r,this.configureKeyframes()}update(e,t){super.update(e,t);const{trim:i=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,this.getContainer().alpha=0,!this.audioResource)return;const r=this.edit.isPlaying&&this.isActive(),n=this.getPlaybackTime();r&&(this.isPlaying||(this.isPlaying=!0,this.audioResource.seek(n/1e3+i),this.audioResource.play()),this.audioResource.volume()!==this.getVolume()&&this.audioResource.volume(this.getVolume()),Math.abs((this.audioResource.seek()-i)*1e3-n)>100&&this.audioResource.seek(n/1e3+i)),this.isPlaying&&!r&&(this.isPlaying=!1,this.audioResource.pause());const o=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&o&&(this.syncTimer=0,this.audioResource.seek(n/1e3+i))}draw(){super.draw()}dispose(){this.audioResource?.unload(),this.audioResource=null}getSize(){return{width:0,height:0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}}var Kn=`in vec2 aPosition;
1
+ (function(pe,Rt){typeof exports=="object"&&typeof module<"u"?Rt(exports,require("pixi.js"),require("howler"),require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","pixi.js","howler","opentype.js"],Rt):(pe=typeof globalThis<"u"?globalThis:pe||self,Rt(pe.ShotstackStudio={},pe.PIXI,pe.Howler,pe.opentype))})(this,function(pe,Rt,sh,nh){"use strict";var Pn=typeof document<"u"?document.currentScript:null;function On(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const L=On(Rt),ah=On(sh),Fo=On(nh);class oh{curves={};constructor(){this.initializeCurves()}initializeCurves(){this.curves={ease:[[.25,.1],[.25,1]],easeIn:[[.42,0],[1,1]],easeOut:[[0,0],[.58,1]],easeInOut:[[.42,0],[.58,1]],easeInQuad:[[.55,.085],[.68,.53]],easeInCubic:[[.55,.055],[.675,.19]],easeInQuart:[[.895,.03],[.685,.22]],easeInQuint:[[.755,.05],[.855,.06]],easeInSine:[[.47,0],[.745,.715]],easeInExpo:[[.95,.05],[.795,.035]],easeInCirc:[[.6,.04],[.98,.335]],easeInBack:[[.6,-.28],[.735,.045]],easeOutQuad:[[.25,.46],[.45,.94]],easeOutCubic:[[.215,.61],[.355,1]],easeOutQuart:[[.165,.84],[.44,1]],easeOutQuint:[[.23,1],[.32,1]],easeOutSine:[[.39,.575],[.565,1]],easeOutExpo:[[.19,1],[.22,1]],easeOutCirc:[[.075,.82],[.165,1]],easeOutBack:[[.175,.885],[.32,1.275]],easeInOutQuad:[[.455,.03],[.515,.955]],easeInOutCubic:[[.645,.045],[.355,1]],easeInOutQuart:[[.77,0],[.175,1]],easeInOutQuint:[[.86,0],[.07,1]],easeInOutSine:[[.445,.05],[.55,.95]],easeInOutExpo:[[1,0],[0,1]],easeInOutCirc:[[.785,.135],[.15,.86]],easeInOutBack:[[.68,-.55],[.265,1.55]]}}getValue(e,t,i,r){const n=this.curves[r??""]??this.curves.ease,[[a,o],[c,u]]=n,h=i+(3*a-3*c+1)*i*(1-i),l=e,d=e+(t-e)*o,f=e+(t-e)*u,p=t,m=h,b=1-m;return b**3*l+3*b**2*m*d+3*b*m**2*f+m**3*p}}class ot{property;length;cubicBuilder;constructor(e,t,i=0){this.property=this.createKeyframes(e,t,i),this.length=t,this.cubicBuilder=new oh}getValue(e){const t=this.property.find(r=>e>=r.start&&e<r.start+r.length);if(!t){if(this.property.length>0){if(e>=this.length)return this.property[this.property.length-1].to;if(e<0)return this.property[0].from}return 1}const i=(e-t.start)/t.length;switch(t.interpolation){case"bezier":return this.cubicBuilder.getValue(t.from,t.to,i,t.easing);case"constant":return t.from;case"linear":default:return t.from+(t.to-t.from)*i}}createKeyframes(e,t,i=0){if(typeof e=="number")return[{start:0,length:t,from:e,to:e}];if(!e.length)throw new Error("Keyframes should have at least one value.");const r=this.createNormalizedKeyframes(e);try{this.validateKeyframes(r)}catch(n){console.warn("Keyframe configuration issues detected:",n)}return this.insertFillerKeyframes(r,t,i)}createNormalizedKeyframes(e){return e.toSorted((t,i)=>t.start-i.start).map(t=>({...t,start:t.start*1e3,length:t.length*1e3}))}validateKeyframes(e){for(let t=0;t<e.length;t+=1){const i=e[t],r=e[t+1];if(!r){if(i.start+i.length>this.length)throw new Error("Last keyframe exceeds the maximum duration.");break}if(i.start+i.length>r.start)throw new Error("Overlapping keyframes detected.")}}insertFillerKeyframes(e,t,i=0){const r=[];for(let n=0;n<e.length;n+=1){const a=e[n],o=e[n+1];if(n===0&&a.start!==0){const h={start:0,length:a.start,from:i,to:a.from};r.push(h)}if(r.push(a),!o){if(a.start+a.length<t){const l=a.start+a.length,d={start:l,length:t-l,from:a.to,to:a.to};r.push(d)}break}if(a.start+a.length!==o.start){const h={start:a.start+a.length,length:o.start,from:a.to,to:o.from};r.push(h)}}return r}}class Ir{static Name="AudioLoadParser";id;name;extension;validAudioExtensions;constructor(){this.id=Ir.Name,this.name=Ir.Name,this.extension={type:[L.ExtensionType.LoadParser],priority:L.LoaderParserPriority.Normal,ref:null},this.validAudioExtensions=["mp3","mpeg","ogg","wav"]}test(e){const t=e.split("?")[0]?.split(".").pop()??"";return this.validAudioExtensions.includes(t)}async load(e,t,i){return new Promise(r=>{const n={src:e},a=new Howl(n);a.on("load",()=>r(a)),a.on("loaderror",()=>r(null))})}unload(e){e?.unload()}}class lh{clipConfiguration;constructor(e){this.clipConfiguration=e}build(e,t){const i=[],r=[],n=[],a=[],o=[],{effect:c,length:u}=this.clipConfiguration;if(!c)return{offsetXKeyframes:i,offsetYKeyframes:r,opacityKeyframes:n,scaleKeyframes:a,rotationKeyframes:o};const h=0;switch(this.getPresetName()){case"zoomIn":{const d=this.getZoomSpeed(),f=1*this.clipConfiguration.scale,p=d*this.clipConfiguration.scale;a.push({from:f,to:p,start:h,length:u,interpolation:"linear"});break}case"zoomOut":{const f=this.getZoomSpeed()*this.clipConfiguration.scale,p=1*this.clipConfiguration.scale;a.push({from:f,to:p,start:h,length:u,interpolation:"linear"});break}case"slideLeft":{let d=this.getSlideStart();const f=e.width+e.width*d*2,p=t.height/t.width*e.height;if(p<f){const m=Math.abs(f/e.width);a.push({from:m,to:m,start:h,length:u,interpolation:"linear"})}else d=(p-e.width)/2/e.width;i.push({from:d,to:-d,start:h,length:u});break}case"slideRight":{let d=this.getSlideStart();const f=e.width+e.width*d*2,p=t.height/t.width*e.height;if(p<f){const m=Math.abs(f/e.width);a.push({from:m,to:m,start:h,length:u,interpolation:"linear"})}else d=(p-e.width)/2/e.width;i.push({from:-d,to:d,start:h,length:u});break}case"slideUp":{let d=this.getSlideStart();const f=e.height+e.height*d*2,p=t.height/t.width*e.width;if(p<f){const m=Math.abs(f/e.height);a.push({from:m,to:m,start:h,length:u,interpolation:"linear"})}else d=(p-e.height)/2/e.height;r.push({from:d,to:-d,start:h,length:u});break}case"slideDown":{let d=this.getSlideStart();const f=e.height+e.height*d*2,p=t.height/t.width*e.width;if(p<f){const m=Math.abs(f/e.height);a.push({from:m,to:m,start:h,length:u,interpolation:"linear"})}else d=(p-e.height)/2/e.height;r.push({from:-d,to:d,start:h,length:u});break}}return{offsetXKeyframes:i,offsetYKeyframes:r,opacityKeyframes:n,scaleKeyframes:a,rotationKeyframes:o}}getPresetName(){const[e]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);return e}getZoomSpeed(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("zoom"))switch(t){case"Slow":return 1.1;case"Fast":return 1.7;default:return 1.3}return 0}getSlideStart(){const[e,t]=(this.clipConfiguration.effect??"").split(/(Slow|Fast)/);if(e.startsWith("slide"))switch(t){case"Slow":return .03;case"Fast":return 1.7;default:return .12}return 0}}class ch{clipConfiguration;constructor(e){this.clipConfiguration=e}build(){const e=[],t=[],i=[],r=[],n=[],a=this.buildInPreset();e.push(...a.offsetXKeyframes),t.push(...a.offsetYKeyframes),i.push(...a.opacityKeyframes),r.push(...a.scaleKeyframes),n.push(...a.rotationKeyframes);const o=this.buildOutPreset();return e.push(...o.offsetXKeyframes),t.push(...o.offsetYKeyframes),i.push(...o.opacityKeyframes),r.push(...o.scaleKeyframes),n.push(...o.rotationKeyframes),{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}buildInPreset(){const e=[],t=[],i=[],r=[],n=[];if(!this.clipConfiguration.transition?.in)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n};const a=0,o=this.getInPresetLength();switch(this.getInPresetName()){case"fade":{const h=Math.max(0,Math.min(this.clipConfiguration.opacity??1,1));i.push({from:0,to:h,start:a,length:o,interpolation:"linear"});break}case"zoom":{const h=this.clipConfiguration.scale+9,l=this.clipConfiguration.scale;r.push({from:h,to:l,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideLeft":{const u=this.clipConfiguration.offset?.x+.025,h=this.clipConfiguration.offset?.x;e.push({from:u,to:h,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideRight":{const u=this.clipConfiguration.offset?.x-.025,h=this.clipConfiguration.offset?.x;e.push({from:u,to:h,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideUp":{const u=this.clipConfiguration.offset?.y+.025,h=this.clipConfiguration.offset?.y;t.push({from:u,to:h,start:a,length:o,interpolation:"bezier",easing:"easeIn"}),i.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeIn"});break}case"slideDown":{const u=this.clipConfiguration.offset?.y-.025,h=this.clipConfiguration.offset?.y;t.push({from:u,to:h,start:a,length:o,interpolation:"bezier",easing:"easeOut"}),i.push({from:0,to:1,start:a,length:o,interpolation:"bezier",easing:"easeOut"});break}case"carouselLeft":case"carouselRight":case"carouselUp":case"carouselDown":case"shuffleTopRight":case"shuffleRightTop":case"shuffleRightBottom":case"shuffleBottomRight":case"shuffleBottomLeft":case"shuffleLeftBottom":case"shuffleLeftTop":case"shuffleTopLeft":default:console.warn(`Unimplemented transition:in preset "${this.clipConfiguration.transition.in}"`);break}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}buildOutPreset(){const e=[],t=[],i=[],r=[],n=[];if(!this.clipConfiguration.transition?.out)return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n};const a=this.getOutPresetLength(),o=this.clipConfiguration.length-a;switch(this.getOutPresetName()){case"fade":{const u=Math.max(0,Math.min(this.clipConfiguration.opacity??1,1));i.push({from:u,to:0,start:o,length:a,interpolation:"linear"});break}case"zoom":{const h=this.clipConfiguration.scale,l=h+9;r.push({from:h,to:l,start:o,length:a,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeOut"});break}case"slideLeft":{const u=this.clipConfiguration.offset?.x,h=u-.025;e.push({from:u,to:h,start:o,length:a,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeOut"});break}case"slideRight":{const u=this.clipConfiguration.offset?.x,h=u+.025;e.push({from:u,to:h,start:o,length:a,interpolation:"bezier",easing:"easeOut"}),i.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeOut"});break}case"slideUp":{const u=this.clipConfiguration.offset?.y,h=u-.025;t.push({from:u,to:h,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"slideDown":{const u=this.clipConfiguration.offset?.y,h=u+.025;t.push({from:u,to:h,start:o,length:a,interpolation:"bezier",easing:"easeIn"}),i.push({from:1,to:0,start:o,length:a,interpolation:"bezier",easing:"easeIn"});break}case"carouselLeft":case"carouselRight":case"carouselUp":case"carouselDown":case"shuffleTopRight":case"shuffleRightTop":case"shuffleRightBottom":case"shuffleBottomRight":case"shuffleBottomLeft":case"shuffleLeftBottom":case"shuffleLeftTop":case"shuffleTopLeft":default:console.warn(`Unimplemented transition:out preset "${this.clipConfiguration.transition.out}"`);break}return{offsetXKeyframes:e,offsetYKeyframes:t,opacityKeyframes:i,scaleKeyframes:r,rotationKeyframes:n}}getInPresetName(){const[e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);return e}getOutPresetName(){const[e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);return e}getInPresetLength(){const[,e]=(this.clipConfiguration.transition?.in??"").split(/(Slow|Fast|VeryFast)/);switch(e){case"Slow":return 2;case"Fast":return .5;case"VeryFast":return .25;default:return 1}}getOutPresetLength(){const[,e]=(this.clipConfiguration.transition?.out??"").split(/(Slow|Fast|VeryFast)/);switch(e){case"Slow":return 2;case"Fast":return .5;case"VeryFast":return .25;default:return 1}}}let uh=class{static ButtonLeftClick=0;static ButtonRightClick=3};class hh{containerSize;constructor(e){this.containerSize=e}relativeToAbsolute(e,t,i){switch(t){case"topLeft":return{x:i.x*this.containerSize.width,y:-i.y*this.containerSize.height};case"topRight":return{x:(i.x+1)*this.containerSize.width-e.width,y:-i.y*this.containerSize.height};case"bottomLeft":return{x:i.x*this.containerSize.width,y:(-i.y+1)*this.containerSize.height-e.height};case"bottomRight":return{x:(i.x+1)*this.containerSize.width-e.width,y:(-i.y+1)*this.containerSize.height-e.height};case"left":return{x:i.x*this.containerSize.width,y:(-i.y+.5)*this.containerSize.height-e.height/2};case"right":return{x:(i.x+1)*this.containerSize.width-e.width,y:(-i.y+.5)*this.containerSize.height-e.height/2};case"top":return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:-i.y*this.containerSize.height};case"bottom":return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:(-i.y+1)*this.containerSize.height-e.height};case"center":default:return{x:(i.x+.5)*this.containerSize.width-e.width/2,y:(-i.y+.5)*this.containerSize.height-e.height/2}}}absoluteToRelative(e,t,i){switch(t){case"topLeft":return{x:i.x/this.containerSize.width,y:-(i.y/this.containerSize.height)};case"topRight":return{x:(i.x+e.width)/this.containerSize.width-1,y:-(i.y/this.containerSize.height)};case"bottomLeft":return{x:i.x/this.containerSize.width,y:-((i.y+e.height)/this.containerSize.height-1)};case"bottomRight":return{x:(i.x+e.width)/this.containerSize.width-1,y:-((i.y+e.height)/this.containerSize.height-1)};case"left":return{x:i.x/this.containerSize.width,y:-((i.y+e.height/2)/this.containerSize.height-.5)};case"right":return{x:(i.x+e.width)/this.containerSize.width-1,y:-((i.y+e.height/2)/this.containerSize.height-.5)};case"top":return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-(i.y/this.containerSize.height)};case"bottom":return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-((i.y+e.height)/this.containerSize.height-1)};case"center":default:return{x:(i.x+e.width/2)/this.containerSize.width-.5,y:-((i.y+e.height/2)/this.containerSize.height-.5)}}}}class ci{container;constructor(){this.container=new L.Container}getContainer(){return this.container}}class Ye extends ci{static SnapThreshold=20;static DiscardedFrameCount=Math.ceil(1/30*1e3);static ScaleHandleRadius=10;static RotationHandleRadius=10;static RotationHandleOffset=50;static OutlineWidth=5;static MinScale=.1;static MaxScale=5;layer;shouldDispose;edit;clipConfiguration;positionBuilder;offsetXKeyframeBuilder;offsetYKeyframeBuilder;scaleKeyframeBuilder;opacityKeyframeBuilder;rotationKeyframeBuilder;outline;topLeftScaleHandle;topRightScaleHandle;bottomLeftScaleHandle;bottomRightScaleHandle;rotationHandle;isHovering;isDragging;dragOffset;scaleDirection;scaleStart;scaleOffset;isRotating;rotationStart;rotationOffset;initialClipConfiguration;contentContainer;constructor(e,t){super(),this.edit=e,this.layer=0,this.shouldDispose=!1,this.clipConfiguration=t,this.positionBuilder=new hh(e.size),this.outline=null,this.topLeftScaleHandle=null,this.topRightScaleHandle=null,this.bottomRightScaleHandle=null,this.bottomLeftScaleHandle=null,this.rotationHandle=null,this.isHovering=!1,this.isDragging=!1,this.dragOffset={x:0,y:0},this.scaleDirection=null,this.scaleStart=null,this.scaleOffset={x:0,y:0},this.isRotating=!1,this.rotationStart=null,this.rotationOffset={x:0,y:0},this.initialClipConfiguration=null,this.contentContainer=new L.Container,this.getContainer().addChild(this.contentContainer)}reconfigureAfterRestore(){this.configureKeyframes()}configureKeyframes(){if(this.offsetXKeyframeBuilder=new ot(this.clipConfiguration.offset?.x??0,this.getLength()),this.offsetYKeyframeBuilder=new ot(this.clipConfiguration.offset?.y??0,this.getLength()),this.scaleKeyframeBuilder=new ot(this.clipConfiguration.scale??1,this.getLength(),1),this.opacityKeyframeBuilder=new ot(this.clipConfiguration.opacity??1,this.getLength(),1),this.rotationKeyframeBuilder=new ot(this.clipConfiguration.transform?.rotate?.angle??0,this.getLength()),this.clipHasKeyframes())return;const e=[],t=[],i=[],r=[],n=[],a=new lh(this.clipConfiguration).build(this.edit.size,this.getSize());e.push(...a.offsetXKeyframes),t.push(...a.offsetYKeyframes),i.push(...a.opacityKeyframes),r.push(...a.scaleKeyframes),n.push(...a.rotationKeyframes);const o=new ch(this.clipConfiguration).build();e.push(...o.offsetXKeyframes),t.push(...o.offsetYKeyframes),i.push(...o.opacityKeyframes),r.push(...o.scaleKeyframes),n.push(...o.rotationKeyframes),e.length&&(this.offsetXKeyframeBuilder=new ot(e,this.getLength())),t.length&&(this.offsetYKeyframeBuilder=new ot(t,this.getLength())),i.length&&(this.opacityKeyframeBuilder=new ot(i,this.getLength(),1)),r.length&&(this.scaleKeyframeBuilder=new ot(r,this.getLength(),1)),n.length&&(this.rotationKeyframeBuilder=new ot(n,this.getLength()))}async load(){this.outline=new L.Graphics,this.getContainer().addChild(this.outline),this.topLeftScaleHandle=new L.Graphics,this.topRightScaleHandle=new L.Graphics,this.bottomRightScaleHandle=new L.Graphics,this.bottomLeftScaleHandle=new L.Graphics,this.rotationHandle=new L.Graphics,this.topLeftScaleHandle.zIndex=1e3,this.topRightScaleHandle.zIndex=1e3,this.bottomRightScaleHandle.zIndex=1e3,this.bottomLeftScaleHandle.zIndex=1e3,this.rotationHandle.zIndex=1e3,this.getContainer().addChild(this.topLeftScaleHandle),this.getContainer().addChild(this.topRightScaleHandle),this.getContainer().addChild(this.bottomRightScaleHandle),this.getContainer().addChild(this.bottomLeftScaleHandle),this.getContainer().addChild(this.rotationHandle),this.getContainer().sortableChildren=!0,this.getContainer().cursor="pointer",this.getContainer().eventMode="static",this.getContainer().on("pointerdown",this.onPointerStart.bind(this)),this.getContainer().on("pointermove",this.onPointerMove.bind(this)),this.getContainer().on("globalpointermove",this.onPointerMove.bind(this)),this.getContainer().on("pointerup",this.onPointerUp.bind(this)),this.getContainer().on("pointerupoutside",this.onPointerUp.bind(this)),this.getContainer().on("pointerover",this.onPointerOver.bind(this)),this.getContainer().on("pointerout",this.onPointerOut.bind(this))}update(e,t){if(this.getContainer().visible=this.isActive(),this.getContainer().zIndex=1e5-this.layer*100,!this.isActive())return;const i=this.getPivot(),r=this.getPosition(),n=this.getContainerScale();this.getContainer().scale.set(n.x,n.y),this.getContainer().pivot.set(i.x,i.y),this.getContainer().position.set(r.x+i.x,r.y+i.y);const a=this.getRotation();this.contentContainer.alpha=this.getOpacity(),this.getContainer().angle=a,this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.shouldDiscardFrame()&&(this.contentContainer.alpha=0)}draw(){if(!this.outline)return;const e=this.edit.isPlayerSelected(this),t=this.edit.isInExportMode();if((!this.isActive()||!e)&&!this.isHovering||t){this.outline.clear(),this.topLeftScaleHandle?.clear(),this.topRightScaleHandle?.clear(),this.bottomRightScaleHandle?.clear(),this.bottomLeftScaleHandle?.clear(),this.rotationHandle?.clear();return}const i=this.isHovering||this.isDragging?65535:16777215,r=this.getSize(),n=this.getScale();if(this.outline.clear(),this.outline.strokeStyle={width:Ye.OutlineWidth/n,color:i},this.outline.rect(0,0,r.width,r.height),this.outline.stroke(),!this.topLeftScaleHandle||!this.topRightScaleHandle||!this.bottomRightScaleHandle||!this.bottomLeftScaleHandle||!this.isActive()||!e)return;this.topLeftScaleHandle.fillStyle={color:i},this.topLeftScaleHandle.clear();const a=Ye.ScaleHandleRadius*2/n;if(this.topLeftScaleHandle.rect(-a/2,-a/2,a,a),this.topLeftScaleHandle.fill(),this.topRightScaleHandle.fillStyle={color:i},this.topRightScaleHandle.clear(),this.topRightScaleHandle.rect(r.width-a/2,-a/2,a,a),this.topRightScaleHandle.fill(),this.bottomRightScaleHandle.fillStyle={color:i},this.bottomRightScaleHandle.clear(),this.bottomRightScaleHandle.rect(r.width-a/2,r.height-a/2,a,a),this.bottomRightScaleHandle.fill(),this.bottomLeftScaleHandle.fillStyle={color:i},this.bottomLeftScaleHandle.clear(),this.bottomLeftScaleHandle.rect(-a/2,r.height-a/2,a,a),this.bottomLeftScaleHandle.fill(),!this.rotationHandle)return;const o=r.width/2,c=-50/n;this.rotationHandle.clear(),this.rotationHandle.fillStyle={color:i},this.rotationHandle.circle(o,c,Ye.RotationHandleRadius/n),this.rotationHandle.fill(),this.outline.strokeStyle={width:Ye.OutlineWidth/n,color:i},this.outline.moveTo(o,0),this.outline.lineTo(o,c),this.outline.stroke()}dispose(){this.outline?.destroy(),this.outline=null,this.topLeftScaleHandle?.destroy(),this.topLeftScaleHandle=null,this.topRightScaleHandle?.destroy(),this.topRightScaleHandle=null,this.bottomLeftScaleHandle?.destroy(),this.bottomLeftScaleHandle=null,this.bottomRightScaleHandle?.destroy(),this.bottomRightScaleHandle=null,this.rotationHandle?.destroy(),this.rotationHandle=null,this.contentContainer?.destroy()}getStart(){return this.clipConfiguration.start*1e3}getLength(){return this.clipConfiguration.length*1e3}getEnd(){return this.getStart()+this.getLength()}getPlaybackTime(){const e=this.edit.playbackTime-this.getStart();return e<0?0:e>this.getLength()?this.getLength():e}getOpacity(){return this.opacityKeyframeBuilder?.getValue(this.getPlaybackTime())??1}getPosition(){const e={x:this.offsetXKeyframeBuilder?.getValue(this.getPlaybackTime())??0,y:this.offsetYKeyframeBuilder?.getValue(this.getPlaybackTime())??0};return this.positionBuilder.relativeToAbsolute(this.getSize(),this.clipConfiguration.position??"center",e)}getPivot(){const e=this.getSize();return{x:e.width/2,y:e.height/2}}getFitScale(){if(this.clipConfiguration.width&&this.clipConfiguration.height)return 1;switch(this.clipConfiguration.fit??"crop"){case"crop":{const e=this.edit.size.width/this.getSize().width,t=this.edit.size.height/this.getSize().height;return this.edit.size.height>=this.edit.size.width?t:e}case"cover":return Math.max(this.edit.size.width/this.getSize().width,this.edit.size.height/this.getSize().height);case"contain":return Math.min(this.edit.size.width/this.getSize().width,this.edit.size.height/this.getSize().height);case"none":default:return 1}}getScale(){return(this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1)*this.getFitScale()}getContainerScale(){if(this.clipConfiguration.width&&this.clipConfiguration.height)return{x:1,y:1};const e=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1,t=this.getSize(),i=this.clipConfiguration.fit??"crop";if(t.width===0||t.height===0)return{x:e,y:e};const r=this.edit.size.width/t.width,n=this.edit.size.height/t.height;switch(i){case"contain":{const a=Math.min(r,n)*e;return{x:a,y:a}}case"crop":{const o=(this.edit.size.height>=this.edit.size.width?n:r)*e;return{x:o,y:o}}case"cover":return{x:r*e,y:n*e};case"none":default:return{x:e,y:e}}}getRotation(){return this.rotationKeyframeBuilder?.getValue(this.getPlaybackTime())??0}isActive(){return this.edit.playbackTime>=this.getStart()&&this.edit.playbackTime<this.getEnd()}shouldDiscardFrame(){return this.getPlaybackTime()<Ye.DiscardedFrameCount}onPointerStart(e){if(e.button!==uh.ButtonLeftClick||(this.edit.events.emit("canvas:clip:clicked",{player:this}),this.initialClipConfiguration=structuredClone(this.clipConfiguration),this.clipHasKeyframes()))return;if(this.scaleDirection=null,this.topLeftScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="topLeft"),this.topRightScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="topRight"),this.bottomRightScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="bottomRight"),this.bottomLeftScaleHandle?.getBounds().containsPoint(e.globalX,e.globalY)&&(this.scaleDirection="bottomLeft"),this.scaleDirection!==null){this.scaleStart=this.getScale()/this.getFitScale();const c=e.getLocalPosition(this.edit.getContainer());this.scaleOffset=c;return}if(this.rotationHandle?.getBounds().containsPoint(e.globalX,e.globalY)){this.isRotating=!0,this.rotationStart=this.getRotation();const c=e.getLocalPosition(this.edit.getContainer());this.rotationOffset=c;return}this.isDragging=!0;const o=e.getLocalPosition(this.edit.getContainer());this.dragOffset={x:o.x-this.getContainer().position.x,y:o.y-this.getContainer().position.y}}onPointerMove(e){if(this.scaleDirection!==null&&this.scaleStart!==null){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPosition(),r=this.getPivot(),n={x:i.x+r.x,y:i.y+r.y},a=Math.sqrt((this.scaleOffset.x-n.x)**2+(this.scaleOffset.y-n.y)**2),c=Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)/a,u=this.scaleStart*c;this.clipConfiguration.scale=Math.max(Ye.MinScale,Math.min(u,Ye.MaxScale)),this.scaleKeyframeBuilder=new ot(this.clipConfiguration.scale,this.getLength(),1);return}if(this.isRotating&&this.rotationStart!==null){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPosition(),r=this.getPivot(),n={x:i.x+r.x,y:i.y+r.y},a=Math.atan2(this.rotationOffset.y-n.y,this.rotationOffset.x-n.x),c=(Math.atan2(t.y-n.y,t.x-n.x)-a)*(180/Math.PI);let u=this.rotationStart+c;const h=45,l=u%h,d=2;Math.abs(l)<d?u=Math.floor(u/h)*h:Math.abs(l-h)<d&&(u=Math.ceil(u/h)*h),this.clipConfiguration.transform||(this.clipConfiguration.transform={rotate:{angle:0}}),this.clipConfiguration.transform.rotate||(this.clipConfiguration.transform.rotate={angle:0}),this.clipConfiguration.transform.rotate.angle=u,this.rotationKeyframeBuilder=new ot(this.clipConfiguration.transform.rotate.angle,this.getLength());return}if(this.isDragging){const t=e.getLocalPosition(this.edit.getContainer()),i=this.getPivot(),r={x:t.x-this.dragOffset.x,y:t.y-this.dragOffset.y},n={x:r.x-i.x,y:r.y-i.y},a=[{x:0,y:0},{x:this.edit.size.width,y:0},{x:0,y:this.edit.size.height},{x:this.edit.size.width,y:this.edit.size.height}],o={x:this.edit.size.width/2,y:this.edit.size.height/2},c=[...a,o],u=[{x:n.x,y:n.y},{x:n.x+this.getSize().width,y:n.y},{x:n.x,y:n.y+this.getSize().height},{x:n.x+this.getSize().width,y:n.y+this.getSize().height}],h={x:n.x+this.getSize().width/2,y:n.y+this.getSize().height/2},l=[...u,h];let d=Ye.SnapThreshold,f=Ye.SnapThreshold,p=null,m=null;for(const g of l)for(const y of c){const v=Math.abs(g.x-y.x);v<d&&(d=v,p=n.x+(y.x-g.x));const k=Math.abs(g.y-y.y);k<f&&(f=k,m=n.y+(y.y-g.y))}p!==null&&(n.x=p),m!==null&&(n.y=m);const b=this.positionBuilder.absoluteToRelative(this.getSize(),this.clipConfiguration.position??"center",n);this.clipConfiguration.offset||(this.clipConfiguration.offset={x:0,y:0}),this.clipConfiguration.offset.x=b.x,this.clipConfiguration.offset.y=b.y,this.offsetXKeyframeBuilder=new ot(this.clipConfiguration.offset.x,this.getLength()),this.offsetYKeyframeBuilder=new ot(this.clipConfiguration.offset.y,this.getLength())}}onPointerUp(){(this.isDragging||this.scaleDirection!==null||this.isRotating)&&this.hasStateChanged()&&this.edit.setUpdatedClip(this,this.initialClipConfiguration,structuredClone(this.clipConfiguration)),this.isDragging=!1,this.dragOffset={x:0,y:0},this.scaleDirection=null,this.scaleStart=null,this.scaleOffset={x:0,y:0},this.isRotating=!1,this.rotationStart=null,this.rotationOffset={x:0,y:0},this.initialClipConfiguration=null}onPointerOver(){this.isHovering=!0}onPointerOut(){this.isHovering=!1}clipHasPresets(){return!!this.clipConfiguration.effect||!!this.clipConfiguration.transition?.in||!!this.clipConfiguration.transition?.out}clipHasKeyframes(){return[this.clipConfiguration.scale,this.clipConfiguration.offset?.x,this.clipConfiguration.offset?.y,this.clipConfiguration.transform?.rotate?.angle].some(e=>e&&typeof e!="number")}hasStateChanged(){if(!this.initialClipConfiguration)return!1;const e=this.clipConfiguration.offset?.x,t=this.clipConfiguration.offset?.y,i=this.clipConfiguration.scale,r=Number(this.clipConfiguration.transform?.rotate?.angle??0),n=this.initialClipConfiguration.offset?.x,a=this.initialClipConfiguration.offset?.y,o=this.initialClipConfiguration.scale,c=Number(this.initialClipConfiguration.transform?.rotate?.angle??0);return n!==void 0&&e!==n||a!==void 0&&t!==a||o!==void 0&&i!==o||r!==c}applyFixedDimensions(){const e=this.clipConfiguration.width,t=this.clipConfiguration.height;if(!e||!t)return;const i=this.contentContainer.children[0];if(!i||!i.texture)return;const r=i.texture.width,n=i.texture.height,a=this.clipConfiguration.fit||"crop";if(!this.contentContainer.mask){const c=new L.Graphics;c.rect(0,0,e,t),c.fill(16777215),this.contentContainer.addChild(c),this.contentContainer.mask=c}const o=this.scaleKeyframeBuilder?.getValue(this.getPlaybackTime())??1;switch(i.anchor.set(.5,.5),a){case"cover":{const c=e/r,u=t/n;i.scale.set(c,u),i.position.set(e/2,t/2);break}case"crop":{const c=this.edit.size.width,u=this.edit.size.height;let h=1;(r>c||n>u)&&(h=Math.min(c/r,u/n));const l=r*h,d=n*h,f=Math.max(e/l,t/d),p=h<1?h*f:Math.max(1,f);i.scale.set(p,p),i.anchor.set(.5,.5),i.position.set(e/2,t/2);break}case"contain":{const c=e/r,u=t/n,h=Math.min(c,u);i.scale.set(h,h),i.position.set(e/2,t/2);break}case"none":default:{i.scale.set(1,1),i.position.set(e/2,t/2);break}}this.contentContainer.scale.set(o,o),this.contentContainer.position.set(e/2*(1-o),t/2*(1-o))}applyAnchorPositioning(e,t,i,r){const n=r.width,a=r.height;if(!!r.mask){r.position.set(0,0);return}const c=(e??"center").toLowerCase();let u=0,h=0;c.includes("left")||c==="left"?u=0:c.includes("right")||c==="right"?u=t-n:u=(t-n)/2,c.includes("top")||c==="top"?h=0:c.includes("bottom")||c==="bottom"?h=i-a:h=(i-a)/2,r.position.set(u,h)}}class Ro extends Ye{audioResource;isPlaying;volumeKeyframeBuilder;syncTimer;constructor(e,t){super(e,t),this.audioResource=null,this.isPlaying=!1;const i=t.asset;this.volumeKeyframeBuilder=new ot(i.volume??1,this.getLength()),this.syncTimer=0}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,loadParser:Ir.Name},r=await this.edit.assetLoader.load(t,i);if(!(r instanceof ah.Howl))throw new Error(`Invalid audio source '${e.src}'.`);this.audioResource=r,this.configureKeyframes()}update(e,t){super.update(e,t);const{trim:i=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,this.getContainer().alpha=0,!this.audioResource)return;const r=this.edit.isPlaying&&this.isActive(),n=this.getPlaybackTime();r&&(this.isPlaying||(this.isPlaying=!0,this.audioResource.seek(n/1e3+i),this.audioResource.play()),this.audioResource.volume()!==this.getVolume()&&this.audioResource.volume(this.getVolume()),Math.abs((this.audioResource.seek()-i)*1e3-n)>100&&this.audioResource.seek(n/1e3+i)),this.isPlaying&&!r&&(this.isPlaying=!1,this.audioResource.pause());const a=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&a&&(this.syncTimer=0,this.audioResource.seek(n/1e3+i))}draw(){super.draw()}dispose(){this.audioResource?.unload(),this.audioResource=null}getSize(){return{width:0,height:0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}}var dh=`in vec2 aPosition;
2
2
  out vec2 vTextureCoord;
3
3
 
4
4
  uniform vec4 uInputSize;
@@ -25,7 +25,7 @@ void main(void)
25
25
  gl_Position = filterVertexPosition();
26
26
  vTextureCoord = filterTextureCoord();
27
27
  }
28
- `,qn=`struct GlobalFilterUniforms {
28
+ `,fh=`struct GlobalFilterUniforms {
29
29
  uInputSize:vec4<f32>,
30
30
  uInputPixel:vec4<f32>,
31
31
  uInputClamp:vec4<f32>,
@@ -74,7 +74,7 @@ fn mainVertex(
74
74
  filterVertexPosition(aPosition),
75
75
  filterTextureCoord(aPosition)
76
76
  );
77
- }`,Xn=`precision highp float;
77
+ }`,ph=`precision highp float;
78
78
  in vec2 vTextureCoord;
79
79
  out vec4 finalColor;
80
80
 
@@ -115,7 +115,7 @@ void main(void) {
115
115
  vec4 outlineColor = vec4(vec3(uColor) * outlineAlpha, outlineAlpha);
116
116
  finalColor = contentColor + outlineColor;
117
117
  }
118
- `,Yn=`struct OutlineUniforms {
118
+ `,mh=`struct OutlineUniforms {
119
119
  uThickness:vec2<f32>,
120
120
  uColor:vec3<f32>,
121
121
  uAlpha:f32,
@@ -179,126 +179,128 @@ fn outlineMaxAlphaAtPos(uv: vec2<f32>) -> f32 {
179
179
  return maxAlpha;
180
180
  }
181
181
 
182
- const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,Qn=Object.defineProperty,Jn=(s,e,t)=>e in s?Qn(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,pt=(s,e,t)=>(Jn(s,typeof e!="symbol"?e+"":e,t),t);const oi=class kt extends Be.Filter{constructor(...e){let t=e[0]??{};typeof t=="number"&&(Be.deprecation("6.0.0","OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }"),t={thickness:t},e[1]!==void 0&&(t.color=e[1]),e[2]!==void 0&&(t.quality=e[2]),e[3]!==void 0&&(t.alpha=e[3]),e[4]!==void 0&&(t.knockout=e[4])),t={...kt.DEFAULT_OPTIONS,...t};const i=t.quality??.1,r=Be.GpuProgram.from({vertex:{source:qn,entryPoint:"mainVertex"},fragment:{source:Yn,entryPoint:"mainFragment"}}),n=Be.GlProgram.from({vertex:Kn,fragment:Xn.replace(/\$\{ANGLE_STEP\}/,kt.getAngleStep(i).toFixed(7)),name:"outline-filter"});super({gpuProgram:r,glProgram:n,resources:{outlineUniforms:{uThickness:{value:new Float32Array(2),type:"vec2<f32>"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:t.alpha,type:"f32"},uAngleStep:{value:0,type:"f32"},uKnockout:{value:t.knockout?1:0,type:"f32"}}}}),pt(this,"uniforms"),pt(this,"_thickness"),pt(this,"_quality"),pt(this,"_color"),this.uniforms=this.resources.outlineUniforms.uniforms,this.uniforms.uAngleStep=kt.getAngleStep(i),this._color=new Be.Color,this.color=t.color??0,Object.assign(this,t)}apply(e,t,i,r){this.uniforms.uThickness[0]=this.thickness/t.source.width,this.uniforms.uThickness[1]=this.thickness/t.source.height,e.applyFilter(this,t,i,r)}static getAngleStep(e){return parseFloat((Math.PI*2/Math.max(e*kt.MAX_SAMPLES,kt.MIN_SAMPLES)).toFixed(7))}get thickness(){return this._thickness}set thickness(e){this._thickness=this.padding=e}get color(){return this._color.value}set color(e){this._color.setValue(e);const[t,i,r]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=i,this.uniforms.uColor[2]=r}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get quality(){return this._quality}set quality(e){this._quality=e,this.uniforms.uAngleStep=kt.getAngleStep(e)}get knockout(){return this.uniforms.uKnockout===1}set knockout(e){this.uniforms.uKnockout=e?1:0}};pt(oi,"DEFAULT_OPTIONS",{thickness:1,color:0,alpha:1,quality:.1,knockout:!1}),pt(oi,"MIN_SAMPLES",1),pt(oi,"MAX_SAMPLES",100);let Fi=oi;class ea extends we{background;text;constructor(e,t){super(e,t),this.background=null,this.text=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=await this.parseDocument();if(!t)return;const i=new R.Graphics;t.background.color&&(i.fillStyle={color:t.background.color,alpha:t.background.opacity??1},i.rect(0,0,e.width??this.edit.size.width,e.height??this.edit.size.height),i.fill());const r=new R.Text;r.text=t.text;const{horizontal:n,vertical:o}=t.alignment;r.style={fontFamily:t.font?.family??"Open Sans",fontSize:t.font?.size??32,fill:t.font?.color??"#ffffff",fontWeight:(t.font?.weight??"400").toString(),wordWrap:!0,wordWrapWidth:e.width??this.edit.size.width,lineHeight:(t.font?.lineHeight??1)*(t.font?.size??32),align:n};let a=(e.width??this.edit.size.width)/2-r.width/2,p=(e.height??this.edit.size.height)/2-r.height/2;if(n==="left"&&(a=0),n==="right"&&(a=(e.width??this.edit.size.width)-r.width),o==="top"&&(p=0),o==="bottom"&&(p=(e.height??this.edit.size.height)-r.height),r.position={x:a,y:p},t.stroke.color&&t.stroke.width){const m=new Fi({thickness:t.stroke.width,color:t.stroke.color});r.filters=[m]}this.background=i,this.text=r,this.contentContainer.addChild(i),this.contentContainer.addChild(r),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}async parseDocument(){const e=this.clipConfiguration.asset,{html:t,css:i,position:r}=e;if(!t.includes('data-html-type="text"'))return console.warn("Unsupported html format."),null;const o=new DOMParser().parseFromString(t,"text/html").body.textContent??"",p=(await new CSSStyleSheet().replace(i)).cssRules[0],m={text:o,font:{},alignment:{},background:{},stroke:{}};if(p?.constructor.name!=="CSSStyleRule"||!("style"in p))return console.warn("Unsupported css format."),m;const d=p.style,l=this.parseAlignment(r??"center");m.font={color:d.color.length?d.color:void 0,family:d.fontFamily.length?d.fontFamily:void 0,size:d.fontSize.length?parseInt(d.fontSize,10):void 0,weight:d.fontWeight.length?parseInt(d.fontWeight,10):void 0,lineHeight:d.lineHeight.length?parseInt(d.lineHeight,10):void 0},m.alignment=l;let c="";return d.background.length&&(c=d.background),d.backgroundColor.length&&(c=d.backgroundColor),m.background={color:c.length?c:void 0,opacity:d.opacity.length?parseInt(d.opacity,10):void 0},m.stroke={width:d.strokeWidth.length?parseInt(d.strokeWidth,10):void 0,color:d.stroke.length?d.stroke:void 0},m}parseAlignment(e){switch(e){case"topLeft":return{horizontal:"left",vertical:"top"};case"top":return{horizontal:"center",vertical:"top"};case"topRight":return{horizontal:"right",vertical:"top"};case"left":return{horizontal:"left",vertical:"center"};case"right":return{horizontal:"right",vertical:"center"};case"bottomLeft":return{horizontal:"left",vertical:"bottom"};case"bottom":return{horizontal:"center",vertical:"bottom"};case"bottomRight":return{horizontal:"right",vertical:"bottom"};case"center":default:return{horizontal:"center",vertical:"center"}}}}class ta extends we{texture;sprite;originalSize;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.originalSize=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,crossovern:"anonymous",data:{}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof R.ImageSource))throw new Error(`Invalid image source '${e.src}'.`);this.texture=this.createCroppedTexture(r),this.sprite=new R.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null,this.originalSize=null}getSize(){return this.clipConfiguration.width&&this.clipConfiguration.height?{width:this.clipConfiguration.width,height:this.clipConfiguration.height}:{width:this.sprite?.width??0,height:this.sprite?.height??0}}createCroppedTexture(e){const t=this.clipConfiguration.asset;if(!t.crop)return e;const i=e.width,r=e.height,n=Math.floor((t.crop?.left??0)*i),o=Math.floor((t.crop?.right??0)*i),a=Math.floor((t.crop?.top??0)*r),p=Math.floor((t.crop?.bottom??0)*r),m=n,d=a,l=i-n-o,c=r-a-p,u=new R.Rectangle(m,d,l,c);return new R.Texture({source:e.source,frame:u})}}class Fs extends we{texture;sprite;isPlaying;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.isPlaying=!1}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,data:{autoPlay:!1,muted:!0}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof R.ImageSource||r?.source instanceof R.VideoSource))throw new Error(`Invalid luma source '${e.src}'.`);this.texture=r,this.sprite=new R.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.configureKeyframes()}update(e,t){if(super.update(e,t),!this.texture||!(this.texture.source instanceof R.VideoSource))return;const i=this.getPlaybackTime(),r=this.edit.isPlaying&&this.isActive();r&&(this.isPlaying||(this.isPlaying=!0,this.texture.source.resource.currentTime=i/1e3,this.texture.source.resource.play().catch(console.error)),this.texture.source.resource.volume!==this.getVolume()&&(this.texture.source.resource.volume=this.getVolume()),Math.abs(this.texture.source.resource.currentTime*1e3-i)>100&&(this.texture.source.resource.currentTime=i/1e3)),!r&&this.isPlaying&&(this.isPlaying=!1,this.texture.source.resource.pause()),!this.edit.isPlaying&&this.isActive()&&(this.texture.source.resource.currentTime=i/1e3)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null}getSize(){return{width:this.sprite?.width??0,height:this.sprite?.height??0}}getVolume(){return 0}getMask(){return this.sprite}}var oe;(function(s){s.assertEqual=r=>{};function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const n={};for(const o of r)n[o]=o;return n},s.getValidEnumValues=r=>{const n=s.objectKeys(r).filter(a=>typeof r[r[a]]!="number"),o={};for(const a of n)o[a]=r[a];return s.objectValues(o)},s.objectValues=r=>s.objectKeys(r).map(function(n){return r[n]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const n=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&n.push(o);return n},s.find=(r,n)=>{for(const o of r)if(n(o))return o},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function i(r,n=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(n)}s.joinValues=i,s.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(oe||(oe={}));var Ms;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Ms||(Ms={}));const j=oe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),et=s=>{switch(typeof s){case"undefined":return j.undefined;case"string":return j.string;case"number":return Number.isNaN(s)?j.nan:j.number;case"boolean":return j.boolean;case"function":return j.function;case"bigint":return j.bigint;case"symbol":return j.symbol;case"object":return Array.isArray(s)?j.array:s===null?j.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?j.promise:typeof Map<"u"&&s instanceof Map?j.map:typeof Set<"u"&&s instanceof Set?j.set:typeof Date<"u"&&s instanceof Date?j.date:j.object;default:return j.unknown}},M=oe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class qe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},i={_errors:[]},r=n=>{for(const o of n.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)i._errors.push(t(o));else{let a=i,p=0;for(;p<o.path.length;){const m=o.path[p];p===o.path.length-1?(a[m]=a[m]||{_errors:[]},a[m]._errors.push(t(o))):a[m]=a[m]||{_errors:[]},a=a[m],p++}}};return r(this),i}static assert(e){if(!(e instanceof qe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,oe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},i=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else i.push(e(r));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}qe.create=s=>new qe(s);const Mi=(s,e)=>{let t;switch(s.code){case M.invalid_type:s.received===j.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,oe.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${oe.joinValues(s.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${oe.joinValues(s.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${oe.joinValues(s.options)}, received '${s.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:oe.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case M.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case M.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,oe.assertNever(s)}return{message:t}};let ia=Mi;function sa(){return ia}const ra=s=>{const{data:e,path:t,errorMaps:i,issueData:r}=s,n=[...t,...r.path||[]],o={...r,path:n};if(r.message!==void 0)return{...r,path:n,message:r.message};let a="";const p=i.filter(m=>!!m).slice().reverse();for(const m of p)a=m(o,{data:e,defaultError:a}).message;return{...r,path:n,message:a}};function H(s,e){const t=sa(),i=ra({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Mi?void 0:Mi].filter(r=>!!r)});s.common.issues.push(i)}class Ie{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const r of t){if(r.status==="aborted")return J;r.status==="dirty"&&e.dirty(),i.push(r.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const r of t){const n=await r.key,o=await r.value;i.push({key:n,value:o})}return Ie.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};for(const r of t){const{key:n,value:o}=r;if(n.status==="aborted"||o.status==="aborted")return J;n.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(i[n.value]=o.value)}return{status:e.value,value:i}}}const J=Object.freeze({status:"aborted"}),Ht=s=>({status:"dirty",value:s}),Re=s=>({status:"valid",value:s}),Ls=s=>s.status==="aborted",Bs=s=>s.status==="dirty",Tt=s=>s.status==="valid",li=s=>typeof Promise<"u"&&s instanceof Promise;var V;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message})(V||(V={}));class tt{constructor(e,t,i,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=i,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const $s=(s,e)=>{if(Tt(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new qe(s.common.issues);return this._error=t,this._error}}};function ie(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:i,description:r}=s;if(e&&(t||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(o,a)=>{const{message:p}=s;return o.code==="invalid_enum_value"?{message:p??a.defaultError}:typeof a.data>"u"?{message:p??i??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:p??t??a.defaultError}},description:r}}class ae{get description(){return this._def.description}_getType(e){return et(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:et(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ie,ctx:{common:e.parent.common,data:e.data,parsedType:et(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(li(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){const i={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)},r=this._parseSync({data:e,path:i.path,parent:i});return $s(i,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return Tt(i)?{value:i.value}:{issues:t.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>Tt(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)},r=this._parse({data:e,path:i.path,parent:i}),n=await(li(r)?r:Promise.resolve(r));return $s(i,n)}refine(e,t){const i=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,n)=>{const o=e(r),a=()=>n.addIssue({code:M.custom,...i(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(p=>p?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((i,r)=>e(i)?!0:(r.addIssue(typeof t=="function"?t(i,r):t),!1))}_refinement(e){return new It({schema:this,typeName:ee.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return rt.create(this,this._def)}nullable(){return Pt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $e.create(this)}promise(){return di.create(this,this._def)}or(e){return hi.create([this,e],this._def)}and(e){return ui.create(this,e,this._def)}transform(e){return new It({...ie(this._def),schema:this,typeName:ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new zi({...ie(this._def),innerType:this,defaultValue:t,typeName:ee.ZodDefault})}brand(){return new Ea({typeName:ee.ZodBranded,type:this,...ie(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Hi({...ie(this._def),innerType:this,catchValue:t,typeName:ee.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ni.create(this,e)}readonly(){return Ui.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const na=/^c[^\s-]{8,}$/i,aa=/^[0-9a-z]+$/,oa=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0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ba=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,va=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ds="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",wa=new RegExp(`^${Ds}$`);function zs(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function _a(s){return new RegExp(`^${zs(s)}$`)}function xa(s){let e=`${Ds}T${zs(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ca(s,e){return!!((e==="v4"||!e)&&pa.test(s)||(e==="v6"||!e)&&ga.test(s))}function ka(s,e){if(!ha.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const i=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(i));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Ta(s,e){return!!((e==="v4"||!e)&&ma.test(s)||(e==="v6"||!e)&&ya.test(s))}class it extends ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==j.string){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_type,expected:j.string,received:n.parsedType}),J}const i=new Ie;let r;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:M.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="max")e.data.length>n.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:M.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="length"){const o=e.data.length>n.value,a=e.data.length<n.value;(o||a)&&(r=this._getOrReturnCtx(e,r),o?H(r,{code:M.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&H(r,{code:M.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),i.dirty())}else if(n.kind==="email")da.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"email",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="emoji")Li||(Li=new RegExp(fa,"u")),Li.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"emoji",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="uuid")la.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"uuid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="nanoid")ca.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"nanoid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid")na.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"cuid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid2")aa.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"cuid2",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="ulid")oa.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"ulid",code:M.invalid_string,message:n.message}),i.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),H(r,{validation:"url",code:M.invalid_string,message:n.message}),i.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"regex",code:M.invalid_string,message:n.message}),i.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),i.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:{startsWith:n.value},message:n.message}),i.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:{endsWith:n.value},message:n.message}),i.dirty()):n.kind==="datetime"?xa(n).test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:"datetime",message:n.message}),i.dirty()):n.kind==="date"?wa.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:"date",message:n.message}),i.dirty()):n.kind==="time"?_a(n).test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:M.invalid_string,validation:"time",message:n.message}),i.dirty()):n.kind==="duration"?ua.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"duration",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="ip"?Ca(e.data,n.version)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"ip",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="jwt"?ka(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"jwt",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="cidr"?Ta(e.data,n.version)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"cidr",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="base64"?ba.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"base64",code:M.invalid_string,message:n.message}),i.dirty()):n.kind==="base64url"?va.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:"base64url",code:M.invalid_string,message:n.message}),i.dirty()):oe.assertNever(n);return{status:i.value,value:e.data}}_regex(e,t,i){return this.refinement(r=>e.test(r),{validation:t,code:M.invalid_string,...V.errToObj(i)})}_addCheck(e){return new it({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...V.errToObj(e)})}url(e){return this._addCheck({kind:"url",...V.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...V.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...V.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...V.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...V.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...V.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...V.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...V.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...V.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...V.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...V.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...V.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...V.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...V.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...V.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...V.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...V.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...V.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...V.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...V.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...V.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...V.errToObj(t)})}nonempty(e){return this.min(1,V.errToObj(e))}trim(){return new it({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new it({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new it({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}it.create=s=>new it({checks:[],typeName:ee.ZodString,coerce:s?.coerce??!1,...ie(s)});function Sa(s,e){const t=(s.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,r=t>i?t:i,n=Number.parseInt(s.toFixed(r).replace(".","")),o=Number.parseInt(e.toFixed(r).replace(".",""));return n%o/10**r}class St extends ae{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==j.number){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_type,expected:j.number,received:n.parsedType}),J}let i;const r=new Ie;for(const n of this._def.checks)n.kind==="int"?oe.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:M.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="multipleOf"?Sa(e.data,n.value)!==0&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:M.not_finite,message:n.message}),r.dirty()):oe.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,V.toString(t))}gt(e,t){return this.setLimit("min",e,!1,V.toString(t))}lte(e,t){return this.setLimit("max",e,!0,V.toString(t))}lt(e,t){return this.setLimit("max",e,!1,V.toString(t))}setLimit(e,t,i,r){return new St({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:V.toString(r)}]})}_addCheck(e){return new St({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:V.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:V.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:V.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&oe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(t===null||i.value>t)&&(t=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}St.create=s=>new St({checks:[],typeName:ee.ZodNumber,coerce:s?.coerce||!1,...ie(s)});class Nt extends ae{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==j.bigint)return this._getInvalidInput(e);let i;const r=new Ie;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),H(i,{code:M.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):oe.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return H(t,{code:M.invalid_type,expected:j.bigint,received:t.parsedType}),J}gte(e,t){return this.setLimit("min",e,!0,V.toString(t))}gt(e,t){return this.setLimit("min",e,!1,V.toString(t))}lte(e,t){return this.setLimit("max",e,!0,V.toString(t))}lt(e,t){return this.setLimit("max",e,!1,V.toString(t))}setLimit(e,t,i,r){return new Nt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:V.toString(r)}]})}_addCheck(e){return new Nt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:V.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Nt.create=s=>new Nt({checks:[],typeName:ee.ZodBigInt,coerce:s?.coerce??!1,...ie(s)});class Bi extends ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==j.boolean){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.boolean,received:i.parsedType}),J}return Re(e.data)}}Bi.create=s=>new Bi({typeName:ee.ZodBoolean,coerce:s?.coerce||!1,...ie(s)});class ci extends ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==j.date){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_type,expected:j.date,received:n.parsedType}),J}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return H(n,{code:M.invalid_date}),J}const i=new Ie;let r;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:M.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:M.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):oe.assertNever(n);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ci({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:V.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:V.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ci.create=s=>new ci({checks:[],coerce:s?.coerce||!1,typeName:ee.ZodDate,...ie(s)});class Hs extends ae{_parse(e){if(this._getType(e)!==j.symbol){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.symbol,received:i.parsedType}),J}return Re(e.data)}}Hs.create=s=>new Hs({typeName:ee.ZodSymbol,...ie(s)});class Ns extends ae{_parse(e){if(this._getType(e)!==j.undefined){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.undefined,received:i.parsedType}),J}return Re(e.data)}}Ns.create=s=>new Ns({typeName:ee.ZodUndefined,...ie(s)});class Us extends ae{_parse(e){if(this._getType(e)!==j.null){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.null,received:i.parsedType}),J}return Re(e.data)}}Us.create=s=>new Us({typeName:ee.ZodNull,...ie(s)});class js extends ae{constructor(){super(...arguments),this._any=!0}_parse(e){return Re(e.data)}}js.create=s=>new js({typeName:ee.ZodAny,...ie(s)});class Vs extends ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Re(e.data)}}Vs.create=s=>new Vs({typeName:ee.ZodUnknown,...ie(s)});class st extends ae{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:M.invalid_type,expected:j.never,received:t.parsedType}),J}}st.create=s=>new st({typeName:ee.ZodNever,...ie(s)});class Ws extends ae{_parse(e){if(this._getType(e)!==j.undefined){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.void,received:i.parsedType}),J}return Re(e.data)}}Ws.create=s=>new Ws({typeName:ee.ZodVoid,...ie(s)});class $e extends ae{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),r=this._def;if(t.parsedType!==j.array)return H(t,{code:M.invalid_type,expected:j.array,received:t.parsedType}),J;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,a=t.data.length<r.exactLength.value;(o||a)&&(H(t,{code:o?M.too_big:M.too_small,minimum:a?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),i.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(H(t,{code:M.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),i.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(H(t,{code:M.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>r.type._parseAsync(new tt(t,o,t.path,a)))).then(o=>Ie.mergeArray(i,o));const n=[...t.data].map((o,a)=>r.type._parseSync(new tt(t,o,t.path,a)));return Ie.mergeArray(i,n)}get element(){return this._def.type}min(e,t){return new $e({...this._def,minLength:{value:e,message:V.toString(t)}})}max(e,t){return new $e({...this._def,maxLength:{value:e,message:V.toString(t)}})}length(e,t){return new $e({...this._def,exactLength:{value:e,message:V.toString(t)}})}nonempty(e){return this.min(1,e)}}$e.create=(s,e)=>new $e({type:s,minLength:null,maxLength:null,exactLength:null,typeName:ee.ZodArray,...ie(e)});function Et(s){if(s instanceof ye){const e={};for(const t in s.shape){const i=s.shape[t];e[t]=rt.create(Et(i))}return new ye({...s._def,shape:()=>e})}else return s instanceof $e?new $e({...s._def,type:Et(s.element)}):s instanceof rt?rt.create(Et(s.unwrap())):s instanceof Pt?Pt.create(Et(s.unwrap())):s instanceof mt?mt.create(s.items.map(e=>Et(e))):s}class ye extends ae{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=oe.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==j.object){const m=this._getOrReturnCtx(e);return H(m,{code:M.invalid_type,expected:j.object,received:m.parsedType}),J}const{status:i,ctx:r}=this._processInputParams(e),{shape:n,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof st&&this._def.unknownKeys==="strip"))for(const m in r.data)o.includes(m)||a.push(m);const p=[];for(const m of o){const d=n[m],l=r.data[m];p.push({key:{status:"valid",value:m},value:d._parse(new tt(r,l,r.path,m)),alwaysSet:m in r.data})}if(this._def.catchall instanceof st){const m=this._def.unknownKeys;if(m==="passthrough")for(const d of a)p.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(m==="strict")a.length>0&&(H(r,{code:M.unrecognized_keys,keys:a}),i.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const d of a){const l=r.data[d];p.push({key:{status:"valid",value:d},value:m._parse(new tt(r,l,r.path,d)),alwaysSet:d in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const m=[];for(const d of p){const l=await d.key,c=await d.value;m.push({key:l,value:c,alwaysSet:d.alwaysSet})}return m}).then(m=>Ie.mergeObjectSync(i,m)):Ie.mergeObjectSync(i,p)}get shape(){return this._def.shape()}strict(e){return V.errToObj,new ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,i)=>{const r=this._def.errorMap?.(t,i).message??i.defaultError;return t.code==="unrecognized_keys"?{message:V.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new ye({...this._def,unknownKeys:"strip"})}passthrough(){return new ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ye({...this._def,catchall:e})}pick(e){const t={};for(const i of oe.objectKeys(e))e[i]&&this.shape[i]&&(t[i]=this.shape[i]);return new ye({...this._def,shape:()=>t})}omit(e){const t={};for(const i of oe.objectKeys(this.shape))e[i]||(t[i]=this.shape[i]);return new ye({...this._def,shape:()=>t})}deepPartial(){return Et(this)}partial(e){const t={};for(const i of oe.objectKeys(this.shape)){const r=this.shape[i];e&&!e[i]?t[i]=r:t[i]=r.optional()}return new ye({...this._def,shape:()=>t})}required(e){const t={};for(const i of oe.objectKeys(this.shape))if(e&&!e[i])t[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof rt;)n=n._def.innerType;t[i]=n}return new ye({...this._def,shape:()=>t})}keyof(){return Ks(oe.objectKeys(this.shape))}}ye.create=(s,e)=>new ye({shape:()=>s,unknownKeys:"strip",catchall:st.create(),typeName:ee.ZodObject,...ie(e)}),ye.strictCreate=(s,e)=>new ye({shape:()=>s,unknownKeys:"strict",catchall:st.create(),typeName:ee.ZodObject,...ie(e)}),ye.lazycreate=(s,e)=>new ye({shape:s,unknownKeys:"strip",catchall:st.create(),typeName:ee.ZodObject,...ie(e)});class hi extends ae{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.options;function r(n){for(const a of n)if(a.result.status==="valid")return a.result;for(const a of n)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=n.map(a=>new qe(a.ctx.common.issues));return H(t,{code:M.invalid_union,unionErrors:o}),J}if(t.common.async)return Promise.all(i.map(async n=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(r);{let n;const o=[];for(const p of i){const m={...t,common:{...t.common,issues:[]},parent:null},d=p._parseSync({data:t.data,path:t.path,parent:m});if(d.status==="valid")return d;d.status==="dirty"&&!n&&(n={result:d,ctx:m}),m.common.issues.length&&o.push(m.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const a=o.map(p=>new qe(p));return H(t,{code:M.invalid_union,unionErrors:a}),J}}get options(){return this._def.options}}hi.create=(s,e)=>new hi({options:s,typeName:ee.ZodUnion,...ie(e)});function $i(s,e){const t=et(s),i=et(e);if(s===e)return{valid:!0,data:s};if(t===j.object&&i===j.object){const r=oe.objectKeys(e),n=oe.objectKeys(s).filter(a=>r.indexOf(a)!==-1),o={...s,...e};for(const a of n){const p=$i(s[a],e[a]);if(!p.valid)return{valid:!1};o[a]=p.data}return{valid:!0,data:o}}else if(t===j.array&&i===j.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let n=0;n<s.length;n++){const o=s[n],a=e[n],p=$i(o,a);if(!p.valid)return{valid:!1};r.push(p.data)}return{valid:!0,data:r}}else return t===j.date&&i===j.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class ui extends ae{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),r=(n,o)=>{if(Ls(n)||Ls(o))return J;const a=$i(n.value,o.value);return a.valid?((Bs(n)||Bs(o))&&t.dirty(),{status:t.value,value:a.data}):(H(i,{code:M.invalid_intersection_types}),J)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,o])=>r(n,o)):r(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}ui.create=(s,e,t)=>new ui({left:s,right:e,typeName:ee.ZodIntersection,...ie(t)});class mt extends ae{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==j.array)return H(i,{code:M.invalid_type,expected:j.array,received:i.parsedType}),J;if(i.data.length<this._def.items.length)return H(i,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J;!this._def.rest&&i.data.length>this._def.items.length&&(H(i,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...i.data].map((o,a)=>{const p=this._def.items[a]||this._def.rest;return p?p._parse(new tt(i,o,i.path,a)):null}).filter(o=>!!o);return i.common.async?Promise.all(n).then(o=>Ie.mergeArray(t,o)):Ie.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new mt({...this._def,rest:e})}}mt.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mt({items:s,typeName:ee.ZodTuple,rest:null,...ie(e)})};class Gs extends ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==j.map)return H(i,{code:M.invalid_type,expected:j.map,received:i.parsedType}),J;const r=this._def.keyType,n=this._def.valueType,o=[...i.data.entries()].map(([a,p],m)=>({key:r._parse(new tt(i,a,i.path,[m,"key"])),value:n._parse(new tt(i,p,i.path,[m,"value"]))}));if(i.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const p of o){const m=await p.key,d=await p.value;if(m.status==="aborted"||d.status==="aborted")return J;(m.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(m.value,d.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const p of o){const m=p.key,d=p.value;if(m.status==="aborted"||d.status==="aborted")return J;(m.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(m.value,d.value)}return{status:t.value,value:a}}}}Gs.create=(s,e,t)=>new Gs({valueType:e,keyType:s,typeName:ee.ZodMap,...ie(t)});class Ut extends ae{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==j.set)return H(i,{code:M.invalid_type,expected:j.set,received:i.parsedType}),J;const r=this._def;r.minSize!==null&&i.data.size<r.minSize.value&&(H(i,{code:M.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&i.data.size>r.maxSize.value&&(H(i,{code:M.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const n=this._def.valueType;function o(p){const m=new Set;for(const d of p){if(d.status==="aborted")return J;d.status==="dirty"&&t.dirty(),m.add(d.value)}return{status:t.value,value:m}}const a=[...i.data.values()].map((p,m)=>n._parse(new tt(i,p,i.path,m)));return i.common.async?Promise.all(a).then(p=>o(p)):o(a)}min(e,t){return new Ut({...this._def,minSize:{value:e,message:V.toString(t)}})}max(e,t){return new Ut({...this._def,maxSize:{value:e,message:V.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ut.create=(s,e)=>new Ut({valueType:s,minSize:null,maxSize:null,typeName:ee.ZodSet,...ie(e)});class Zs extends ae{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Zs.create=(s,e)=>new Zs({getter:s,typeName:ee.ZodLazy,...ie(e)});class Di extends ae{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),J}return{status:"valid",value:e.data}}get value(){return this._def.value}}Di.create=(s,e)=>new Di({value:s,typeName:ee.ZodLiteral,...ie(e)});function Ks(s,e){return new At({values:s,typeName:ee.ZodEnum,...ie(e)})}class At extends ae{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),i=this._def.values;return H(t,{expected:oe.joinValues(i),received:t.parsedType,code:M.invalid_type}),J}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),i=this._def.values;return H(t,{received:t.data,code:M.invalid_enum_value,options:i}),J}return Re(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return At.create(e,{...this._def,...t})}exclude(e,t=this._def){return At.create(this.options.filter(i=>!e.includes(i)),{...this._def,...t})}}At.create=Ks;class qs extends ae{_parse(e){const t=oe.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==j.string&&i.parsedType!==j.number){const r=oe.objectValues(t);return H(i,{expected:oe.joinValues(r),received:i.parsedType,code:M.invalid_type}),J}if(this._cache||(this._cache=new Set(oe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=oe.objectValues(t);return H(i,{received:i.data,code:M.invalid_enum_value,options:r}),J}return Re(e.data)}get enum(){return this._def.values}}qs.create=(s,e)=>new qs({values:s,typeName:ee.ZodNativeEnum,...ie(e)});class di extends ae{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==j.promise&&t.common.async===!1)return H(t,{code:M.invalid_type,expected:j.promise,received:t.parsedType}),J;const i=t.parsedType===j.promise?t.data:Promise.resolve(t.data);return Re(i.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}di.create=(s,e)=>new di({type:s,typeName:ee.ZodPromise,...ie(e)});class It extends ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:i}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:o=>{H(i,o),o.fatal?t.abort():t.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),r.type==="preprocess"){const o=r.transform(i.data,n);if(i.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return J;const p=await this._def.schema._parseAsync({data:a,path:i.path,parent:i});return p.status==="aborted"?J:p.status==="dirty"||t.value==="dirty"?Ht(p.value):p});{if(t.value==="aborted")return J;const a=this._def.schema._parseSync({data:o,path:i.path,parent:i});return a.status==="aborted"?J:a.status==="dirty"||t.value==="dirty"?Ht(a.value):a}}if(r.type==="refinement"){const o=a=>{const p=r.refinement(a,n);if(i.common.async)return Promise.resolve(p);if(p instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?J:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>a.status==="aborted"?J:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(r.type==="transform")if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Tt(o))return J;const a=r.transform(o.value,n);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>Tt(o)?Promise.resolve(r.transform(o.value,n)).then(a=>({status:t.value,value:a})):J);oe.assertNever(r)}}It.create=(s,e,t)=>new It({schema:s,typeName:ee.ZodEffects,effect:e,...ie(t)}),It.createWithPreprocess=(s,e,t)=>new It({schema:e,effect:{type:"preprocess",transform:s},typeName:ee.ZodEffects,...ie(t)});class rt extends ae{_parse(e){return this._getType(e)===j.undefined?Re(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}rt.create=(s,e)=>new rt({innerType:s,typeName:ee.ZodOptional,...ie(e)});class Pt extends ae{_parse(e){return this._getType(e)===j.null?Re(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pt.create=(s,e)=>new Pt({innerType:s,typeName:ee.ZodNullable,...ie(e)});class zi extends ae{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===j.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}zi.create=(s,e)=>new zi({innerType:s,typeName:ee.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class Hi extends ae{_parse(e){const{ctx:t}=this._processInputParams(e),i={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return li(r)?r.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new qe(i.common.issues)},input:i.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new qe(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}Hi.create=(s,e)=>new Hi({innerType:s,typeName:ee.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class Xs extends ae{_parse(e){if(this._getType(e)!==j.nan){const i=this._getOrReturnCtx(e);return H(i,{code:M.invalid_type,expected:j.nan,received:i.parsedType}),J}return{status:"valid",value:e.data}}}Xs.create=s=>new Xs({typeName:ee.ZodNaN,...ie(s)});class Ea extends ae{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ni extends ae{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?J:n.status==="dirty"?(t.dirty(),Ht(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const r=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return r.status==="aborted"?J:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:i.path,parent:i})}}static create(e,t){return new Ni({in:e,out:t,typeName:ee.ZodPipeline})}}class Ui extends ae{_parse(e){const t=this._def.innerType._parse(e),i=r=>(Tt(r)&&(r.value=Object.freeze(r.value)),r);return li(t)?t.then(r=>i(r)):i(t)}unwrap(){return this._def.innerType}}Ui.create=(s,e)=>new Ui({innerType:s,typeName:ee.ZodReadonly,...ie(e)});var ee;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(ee||(ee={}));const pe=it.create,D=St.create,Aa=Bi.create;st.create;const Ys=$e.create,te=ye.create,ji=hi.create;ui.create,mt.create;const nt=Di.create,_e=At.create;di.create,rt.create,Pt.create;const jt=pe().regex(/^#[A-Fa-f0-9]{6}$/,"Invalid hex color format"),Ia=te({offset:D().min(0).max(1),color:jt}).strict(),Pa=te({type:_e(["linear","radial"]).default("linear"),angle:D().min(0).max(360).default(0),stops:Ys(Ia).min(2)}).strict(),Ra=te({family:pe().default("Roboto"),size:D().min(8).max(500).default(48),weight:ji([pe(),D()]).default("400"),style:_e(["normal","italic","oblique"]).default("normal"),color:jt.default("#000000"),opacity:D().min(0).max(1).default(1)}).strict(),Oa=te({letterSpacing:D().default(0),lineHeight:D().min(.1).max(10).default(1.2),textTransform:_e(["none","uppercase","lowercase","capitalize"]).default("none"),textDecoration:_e(["none","underline","line-through"]).default("none"),gradient:Pa.optional()}).strict(),Fa=te({width:D().min(0).default(0),color:jt.default("#000000"),opacity:D().min(0).max(1).default(1)}).strict(),Ma=te({offsetX:D().default(0),offsetY:D().default(0),blur:D().min(0).default(0),color:jt.default("#000000"),opacity:D().min(0).max(1).default(.5)}).strict(),La=te({color:jt.optional(),opacity:D().min(0).max(1).default(1),borderRadius:D().min(0).default(0)}).strict(),Ba=te({horizontal:_e(["left","center","right"]).default("left"),vertical:_e(["top","middle","bottom"]).default("middle")}).strict(),$a=te({preset:_e(["fadeIn","slideIn","typewriter","shift","ascend","movingLetters","bounce","elastic","pulse"]),speed:D().min(.1).max(10).default(1),duration:D().min(.1).max(60).optional(),style:_e(["character","word"]).optional(),direction:_e(["left","right","up","down"]).optional()}).strict(),Da=te({src:pe().url("Invalid font URL"),family:pe(),weight:ji([pe(),D()]).default("400"),style:_e(["normal","italic","oblique"]).default("normal")}).strict(),fi=te({type:nt("rich-text"),text:pe().max(1e4).default(""),width:D().min(1).max(8192).optional(),height:D().min(1).max(8192).optional(),font:Ra.optional(),style:Oa.optional(),stroke:Fa.optional(),shadow:Ma.optional(),background:La.optional(),align:Ba.optional(),animation:$a.optional(),cacheEnabled:Aa().default(!0),pixelRatio:D().min(1).max(4).default(2),customFonts:Ys(Da).optional()}).strict();function Qs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function za(s){if(s.__esModule)return s;var e=s.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var r=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return s[i]}})}),t}var Js={exports:{}};(function(s,e){(function(t,i){s.exports=i()})(self,()=>{return t={7629:(r,n,o)=>{const a=o(375),p=o(8571),m=o(9474),d=o(1687),l=o(8652),c=o(8160),u=o(3292),h=o(6354),f=o(8901),b=o(9708),g=o(6914),y=o(2294),v=o(6133),_=o(1152),C=o(8863),S=o(2036),T={Base:class{constructor(w){this.type=w,this.$_root=null,this._definition={},this._reset()}_reset(){this._ids=new y.Ids,this._preferences=null,this._refs=new v.Manager,this._cache=null,this._valids=null,this._invalids=null,this._flags={},this._rules=[],this._singleRules=new Map,this.$_terms={},this.$_temp={ruleset:null,whens:{}}}describe(){return a(typeof b.describe=="function","Manifest functionality disabled"),b.describe(this)}allow(...w){return c.verifyFlat(w,"allow"),this._values(w,"_valids")}alter(w){a(w&&typeof w=="object"&&!Array.isArray(w),"Invalid targets argument"),a(!this._inRuleset(),"Cannot set alterations inside a ruleset");const x=this.clone();x.$_terms.alterations=x.$_terms.alterations||[];for(const k in w){const E=w[k];a(typeof E=="function","Alteration adjuster for",k,"must be a function"),x.$_terms.alterations.push({target:k,adjuster:E})}return x.$_temp.ruleset=!1,x}artifact(w){return a(w!==void 0,"Artifact cannot be undefined"),a(!this._cache,"Cannot set an artifact with a rule cache"),this.$_setFlag("artifact",w)}cast(w){return a(w===!1||typeof w=="string","Invalid to value"),a(w===!1||this._definition.cast[w],"Type",this.type,"does not support casting to",w),this.$_setFlag("cast",w===!1?void 0:w)}default(w,x){return this._default("default",w,x)}description(w){return a(w&&typeof w=="string","Description must be a non-empty string"),this.$_setFlag("description",w)}empty(w){const x=this.clone();return w!==void 0&&(w=x.$_compile(w,{override:!1})),x.$_setFlag("empty",w,{clone:!1})}error(w){return a(w,"Missing error"),a(w instanceof Error||typeof w=="function","Must provide a valid Error object or a function"),this.$_setFlag("error",w)}example(w,x={}){return a(w!==void 0,"Missing example"),c.assertOptions(x,["override"]),this._inner("examples",w,{single:!0,override:x.override})}external(w,x){return typeof w=="object"&&(a(!x,"Cannot combine options with description"),x=w.description,w=w.method),a(typeof w=="function","Method must be a function"),a(x===void 0||x&&typeof x=="string","Description must be a non-empty string"),this._inner("externals",{method:w,description:x},{single:!0})}failover(w,x){return this._default("failover",w,x)}forbidden(){return this.presence("forbidden")}id(w){return w?(a(typeof w=="string","id must be a non-empty string"),a(/^[^\.]+$/.test(w),"id cannot contain period character"),this.$_setFlag("id",w)):this.$_setFlag("id",void 0)}invalid(...w){return this._values(w,"_invalids")}label(w){return a(w&&typeof w=="string","Label name must be a non-empty string"),this.$_setFlag("label",w)}meta(w){return a(w!==void 0,"Meta cannot be undefined"),this._inner("metas",w,{single:!0})}note(...w){a(w.length,"Missing notes");for(const x of w)a(x&&typeof x=="string","Notes must be non-empty strings");return this._inner("notes",w)}only(w=!0){return a(typeof w=="boolean","Invalid mode:",w),this.$_setFlag("only",w)}optional(){return this.presence("optional")}prefs(w){a(w,"Missing preferences"),a(w.context===void 0,"Cannot override context"),a(w.externals===void 0,"Cannot override externals"),a(w.warnings===void 0,"Cannot override warnings"),a(w.debug===void 0,"Cannot override debug"),c.checkPreferences(w);const x=this.clone();return x._preferences=c.preferences(x._preferences,w),x}presence(w){return a(["optional","required","forbidden"].includes(w),"Unknown presence mode",w),this.$_setFlag("presence",w)}raw(w=!0){return this.$_setFlag("result",w?"raw":void 0)}result(w){return a(["raw","strip"].includes(w),"Unknown result mode",w),this.$_setFlag("result",w)}required(){return this.presence("required")}strict(w){const x=this.clone(),k=w!==void 0&&!w;return x._preferences=c.preferences(x._preferences,{convert:k}),x}strip(w=!0){return this.$_setFlag("result",w?"strip":void 0)}tag(...w){a(w.length,"Missing tags");for(const x of w)a(x&&typeof x=="string","Tags must be non-empty strings");return this._inner("tags",w)}unit(w){return a(w&&typeof w=="string","Unit name must be a non-empty string"),this.$_setFlag("unit",w)}valid(...w){c.verifyFlat(w,"valid");const x=this.allow(...w);return x.$_setFlag("only",!!x._valids,{clone:!1}),x}when(w,x){const k=this.clone();k.$_terms.whens||(k.$_terms.whens=[]);const E=u.when(k,w,x);if(!["any","link"].includes(k.type)){const P=E.is?[E]:E.switch;for(const O of P)a(!O.then||O.then.type==="any"||O.then.type===k.type,"Cannot combine",k.type,"with",O.then&&O.then.type),a(!O.otherwise||O.otherwise.type==="any"||O.otherwise.type===k.type,"Cannot combine",k.type,"with",O.otherwise&&O.otherwise.type)}return k.$_terms.whens.push(E),k.$_mutateRebuild()}cache(w){a(!this._inRuleset(),"Cannot set caching inside a ruleset"),a(!this._cache,"Cannot override schema cache"),a(this._flags.artifact===void 0,"Cannot cache a rule with an artifact");const x=this.clone();return x._cache=w||l.provider.provision(),x.$_temp.ruleset=!1,x}clone(){const w=Object.create(Object.getPrototypeOf(this));return this._assign(w)}concat(w){a(c.isSchema(w),"Invalid schema object"),a(this.type==="any"||w.type==="any"||w.type===this.type,"Cannot merge type",this.type,"with another type:",w.type),a(!this._inRuleset(),"Cannot concatenate onto a schema with open ruleset"),a(!w._inRuleset(),"Cannot concatenate a schema with open ruleset");let x=this.clone();if(this.type==="any"&&w.type!=="any"){const k=w.clone();for(const E of Object.keys(x))E!=="type"&&(k[E]=x[E]);x=k}x._ids.concat(w._ids),x._refs.register(w,v.toSibling),x._preferences=x._preferences?c.preferences(x._preferences,w._preferences):w._preferences,x._valids=S.merge(x._valids,w._valids,w._invalids),x._invalids=S.merge(x._invalids,w._invalids,w._valids);for(const k of w._singleRules.keys())x._singleRules.has(k)&&(x._rules=x._rules.filter(E=>E.keep||E.name!==k),x._singleRules.delete(k));for(const k of w._rules)w._definition.rules[k.method].multi||x._singleRules.set(k.name,k),x._rules.push(k);if(x._flags.empty&&w._flags.empty){x._flags.empty=x._flags.empty.concat(w._flags.empty);const k=Object.assign({},w._flags);delete k.empty,d(x._flags,k)}else if(w._flags.empty){x._flags.empty=w._flags.empty;const k=Object.assign({},w._flags);delete k.empty,d(x._flags,k)}else d(x._flags,w._flags);for(const k in w.$_terms){const E=w.$_terms[k];E?x.$_terms[k]?x.$_terms[k]=x.$_terms[k].concat(E):x.$_terms[k]=E.slice():x.$_terms[k]||(x.$_terms[k]=E)}return this.$_root._tracer&&this.$_root._tracer._combine(x,[this,w]),x.$_mutateRebuild()}extend(w){return a(!w.base,"Cannot extend type with another base"),f.type(this,w)}extract(w){return w=Array.isArray(w)?w:w.split("."),this._ids.reach(w)}fork(w,x){a(!this._inRuleset(),"Cannot fork inside a ruleset");let k=this;for(let E of[].concat(w))E=Array.isArray(E)?E:E.split("."),k=k._ids.fork(E,x,k);return k.$_temp.ruleset=!1,k}rule(w){const x=this._definition;c.assertOptions(w,Object.keys(x.modifiers)),a(this.$_temp.ruleset!==!1,"Cannot apply rules to empty ruleset or the last rule added does not support rule properties");const k=this.$_temp.ruleset===null?this._rules.length-1:this.$_temp.ruleset;a(k>=0&&k<this._rules.length,"Cannot apply rules to empty ruleset");const E=this.clone();for(let P=k;P<E._rules.length;++P){const O=E._rules[P],z=p(O);for(const I in w)x.modifiers[I](z,w[I]),a(z.name===O.name,"Cannot change rule name");E._rules[P]=z,E._singleRules.get(z.name)===O&&E._singleRules.set(z.name,z)}return E.$_temp.ruleset=!1,E.$_mutateRebuild()}get ruleset(){a(!this._inRuleset(),"Cannot start a new ruleset without closing the previous one");const w=this.clone();return w.$_temp.ruleset=w._rules.length,w}get $(){return this.ruleset}tailor(w){w=[].concat(w),a(!this._inRuleset(),"Cannot tailor inside a ruleset");let x=this;if(this.$_terms.alterations)for(const{target:k,adjuster:E}of this.$_terms.alterations)w.includes(k)&&(x=E(x),a(c.isSchema(x),"Alteration adjuster for",k,"failed to return a schema object"));return x=x.$_modify({each:k=>k.tailor(w),ref:!1}),x.$_temp.ruleset=!1,x.$_mutateRebuild()}tracer(){return _.location?_.location(this):this}validate(w,x){return C.entry(w,this,x)}validateAsync(w,x){return C.entryAsync(w,this,x)}$_addRule(w){typeof w=="string"&&(w={name:w}),a(w&&typeof w=="object","Invalid options"),a(w.name&&typeof w.name=="string","Invalid rule name");for(const O in w)a(O[0]!=="_","Cannot set private rule properties");const x=Object.assign({},w);x._resolve=[],x.method=x.method||x.name;const k=this._definition.rules[x.method],E=x.args;a(k,"Unknown rule",x.method);const P=this.clone();if(E){a(Object.keys(E).length===1||Object.keys(E).length===this._definition.rules[x.name].args.length,"Invalid rule definition for",this.type,x.name);for(const O in E){let z=E[O];if(k.argsByName){const I=k.argsByName.get(O);if(I.ref&&c.isResolvable(z))x._resolve.push(O),P.$_mutateRegister(z);else if(I.normalize&&(z=I.normalize(z),E[O]=z),I.assert){const L=c.validateArg(z,O,I);a(!L,L,"or reference")}}z!==void 0?E[O]=z:delete E[O]}}return k.multi||(P._ruleRemove(x.name,{clone:!1}),P._singleRules.set(x.name,x)),P.$_temp.ruleset===!1&&(P.$_temp.ruleset=null),k.priority?P._rules.unshift(x):P._rules.push(x),P}$_compile(w,x){return u.schema(this.$_root,w,x)}$_createError(w,x,k,E,P,O={}){const z=O.flags!==!1?this._flags:{},I=O.messages?g.merge(this._definition.messages,O.messages):this._definition.messages;return new h.Report(w,x,k,z,I,E,P)}$_getFlag(w){return this._flags[w]}$_getRule(w){return this._singleRules.get(w)}$_mapLabels(w){return w=Array.isArray(w)?w:w.split("."),this._ids.labels(w)}$_match(w,x,k,E){(k=Object.assign({},k)).abortEarly=!0,k._externals=!1,x.snapshot();const P=!C.validate(w,this,x,k,E).errors;return x.restore(),P}$_modify(w){return c.assertOptions(w,["each","once","ref","schema"]),y.schema(this,w)||this}$_mutateRebuild(){return a(!this._inRuleset(),"Cannot add this rule inside a ruleset"),this._refs.reset(),this._ids.reset(),this.$_modify({each:(w,{source:x,name:k,path:E,key:P})=>{const O=this._definition[x][k]&&this._definition[x][k].register;O!==!1&&this.$_mutateRegister(w,{family:O,key:P})}}),this._definition.rebuild&&this._definition.rebuild(this),this.$_temp.ruleset=!1,this}$_mutateRegister(w,{family:x,key:k}={}){this._refs.register(w,x),this._ids.register(w,{key:k})}$_property(w){return this._definition.properties[w]}$_reach(w){return this._ids.reach(w)}$_rootReferences(){return this._refs.roots()}$_setFlag(w,x,k={}){a(w[0]==="_"||!this._inRuleset(),"Cannot set flag inside a ruleset");const E=this._definition.flags[w]||{};if(m(x,E.default)&&(x=void 0),m(x,this._flags[w]))return this;const P=k.clone!==!1?this.clone():this;return x!==void 0?(P._flags[w]=x,P.$_mutateRegister(x)):delete P._flags[w],w[0]!=="_"&&(P.$_temp.ruleset=!1),P}$_parent(w,...x){return this[w][c.symbols.parent].call(this,...x)}$_validate(w,x,k){return C.validate(w,this,x,k)}_assign(w){w.type=this.type,w.$_root=this.$_root,w.$_temp=Object.assign({},this.$_temp),w.$_temp.whens={},w._ids=this._ids.clone(),w._preferences=this._preferences,w._valids=this._valids&&this._valids.clone(),w._invalids=this._invalids&&this._invalids.clone(),w._rules=this._rules.slice(),w._singleRules=p(this._singleRules,{shallow:!0}),w._refs=this._refs.clone(),w._flags=Object.assign({},this._flags),w._cache=null,w.$_terms={};for(const x in this.$_terms)w.$_terms[x]=this.$_terms[x]?this.$_terms[x].slice():null;w.$_super={};for(const x in this.$_super)w.$_super[x]=this._super[x].bind(w);return w}_bare(){const w=this.clone();w._reset();const x=w._definition.terms;for(const k in x){const E=x[k];w.$_terms[k]=E.init}return w.$_mutateRebuild()}_default(w,x,k={}){return c.assertOptions(k,"literal"),a(x!==void 0,"Missing",w,"value"),a(typeof x=="function"||!k.literal,"Only function value supports literal option"),typeof x=="function"&&k.literal&&(x={[c.symbols.literal]:!0,literal:x}),this.$_setFlag(w,x)}_generate(w,x,k){if(!this.$_terms.whens)return{schema:this};const E=[],P=[];for(let I=0;I<this.$_terms.whens.length;++I){const L=this.$_terms.whens[I];if(L.concat){E.push(L.concat),P.push(`${I}.concat`);continue}const F=L.ref?L.ref.resolve(w,x,k):w,Z=L.is?[L]:L.switch,Q=P.length;for(let X=0;X<Z.length;++X){const{is:Y,then:se,otherwise:re}=Z[X],Ce=`${I}${L.switch?"."+X:""}`;if(Y.$_match(F,x.nest(Y,`${Ce}.is`),k)){if(se){const ve=x.localize([...x.path,`${Ce}.then`],x.ancestors,x.schemas),{schema:ge,id:de}=se._generate(w,ve,k);E.push(ge),P.push(`${Ce}.then${de?`(${de})`:""}`);break}}else if(re){const ve=x.localize([...x.path,`${Ce}.otherwise`],x.ancestors,x.schemas),{schema:ge,id:de}=re._generate(w,ve,k);E.push(ge),P.push(`${Ce}.otherwise${de?`(${de})`:""}`);break}}if(L.break&&P.length>Q)break}const O=P.join(", ");if(x.mainstay.tracer.debug(x,"rule","when",O),!O)return{schema:this};if(!x.mainstay.tracer.active&&this.$_temp.whens[O])return{schema:this.$_temp.whens[O],id:O};let z=this;this._definition.generate&&(z=this._definition.generate(this,w,x,k));for(const I of E)z=z.concat(I);return this.$_root._tracer&&this.$_root._tracer._combine(z,[this,...E]),this.$_temp.whens[O]=z,{schema:z,id:O}}_inner(w,x,k={}){a(!this._inRuleset(),`Cannot set ${w} inside a ruleset`);const E=this.clone();return E.$_terms[w]&&!k.override||(E.$_terms[w]=[]),k.single?E.$_terms[w].push(x):E.$_terms[w].push(...x),E.$_temp.ruleset=!1,E}_inRuleset(){return this.$_temp.ruleset!==null&&this.$_temp.ruleset!==!1}_ruleRemove(w,x={}){if(!this._singleRules.has(w))return this;const k=x.clone!==!1?this.clone():this;k._singleRules.delete(w);const E=[];for(let P=0;P<k._rules.length;++P){const O=k._rules[P];O.name!==w||O.keep?E.push(O):k._inRuleset()&&P<k.$_temp.ruleset&&--k.$_temp.ruleset}return k._rules=E,k}_values(w,x){c.verifyFlat(w,x.slice(1,-1));const k=this.clone(),E=w[0]===c.symbols.override;if(E&&(w=w.slice(1)),!k[x]&&w.length?k[x]=new S:E&&(k[x]=w.length?new S:null,k.$_mutateRebuild()),!k[x])return k;E&&k[x].override();for(const P of w){a(P!==void 0,"Cannot call allow/valid/invalid with undefined"),a(P!==c.symbols.override,"Override must be the first value");const O=x==="_invalids"?"_valids":"_invalids";k[O]&&(k[O].remove(P),k[O].length||(a(x==="_valids"||!k._flags.only,"Setting invalid value",P,"leaves schema rejecting all values due to previous valid rule"),k[O]=null)),k[x].add(P,k._refs)}return k}}};T.Base.prototype[c.symbols.any]={version:c.version,compile:u.compile,root:"$_root"},T.Base.prototype.isImmutable=!0,T.Base.prototype.deny=T.Base.prototype.invalid,T.Base.prototype.disallow=T.Base.prototype.invalid,T.Base.prototype.equal=T.Base.prototype.valid,T.Base.prototype.exist=T.Base.prototype.required,T.Base.prototype.not=T.Base.prototype.invalid,T.Base.prototype.options=T.Base.prototype.prefs,T.Base.prototype.preferences=T.Base.prototype.prefs,r.exports=new T.Base},8652:(r,n,o)=>{const a=o(375),p=o(8571),m=o(8160),d={max:1e3,supported:new Set(["undefined","boolean","number","string"])};n.provider={provision:l=>new d.Cache(l)},d.Cache=class{constructor(l={}){m.assertOptions(l,["max"]),a(l.max===void 0||l.max&&l.max>0&&isFinite(l.max),"Invalid max cache size"),this._max=l.max||d.max,this._map=new Map,this._list=new d.List}get length(){return this._map.size}set(l,c){if(l!==null&&!d.supported.has(typeof l))return;let u=this._map.get(l);if(u)return u.value=c,void this._list.first(u);u=this._list.unshift({key:l,value:c}),this._map.set(l,u),this._compact()}get(l){const c=this._map.get(l);if(c)return this._list.first(c),p(c.value)}_compact(){if(this._map.size>this._max){const l=this._list.pop();this._map.delete(l.key)}}},d.List=class{constructor(){this.tail=null,this.head=null}unshift(l){return l.next=null,l.prev=this.head,this.head&&(this.head.next=l),this.head=l,this.tail||(this.tail=l),l}first(l){l!==this.head&&(this._remove(l),this.unshift(l))}pop(){return this._remove(this.tail)}_remove(l){const{next:c,prev:u}=l;return c.prev=u,u&&(u.next=c),l===this.tail&&(this.tail=c),l.prev=null,l.next=null,l}}},8160:(r,n,o)=>{const a=o(375),p=o(7916),m=o(5934);let d,l;const c={isoDate:/^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/};n.version=m.version,n.defaults={abortEarly:!0,allowUnknown:!1,artifacts:!1,cache:!0,context:null,convert:!0,dateFormat:"iso",errors:{escapeHtml:!1,label:"path",language:null,render:!0,stack:!1,wrap:{label:'"',array:"[]"}},externals:!0,messages:{},nonEnumerables:!1,noDefaults:!1,presence:"optional",skipFunctions:!1,stripUnknown:!1,warnings:!1},n.symbols={any:Symbol.for("@hapi/joi/schema"),arraySingle:Symbol("arraySingle"),deepDefault:Symbol("deepDefault"),errors:Symbol("errors"),literal:Symbol("literal"),override:Symbol("override"),parent:Symbol("parent"),prefs:Symbol("prefs"),ref:Symbol("ref"),template:Symbol("template"),values:Symbol("values")},n.assertOptions=function(u,h,f="Options"){a(u&&typeof u=="object"&&!Array.isArray(u),"Options must be of type object");const b=Object.keys(u).filter(g=>!h.includes(g));a(b.length===0,`${f} contain unknown keys: ${b}`)},n.checkPreferences=function(u){l=l||o(3378);const h=l.preferences.validate(u);if(h.error)throw new p([h.error.details[0].message])},n.compare=function(u,h,f){switch(f){case"=":return u===h;case">":return u>h;case"<":return u<h;case">=":return u>=h;case"<=":return u<=h}},n.default=function(u,h){return u===void 0?h:u},n.isIsoDate=function(u){return c.isoDate.test(u)},n.isNumber=function(u){return typeof u=="number"&&!isNaN(u)},n.isResolvable=function(u){return!!u&&(u[n.symbols.ref]||u[n.symbols.template])},n.isSchema=function(u,h={}){const f=u&&u[n.symbols.any];return!!f&&(a(h.legacy||f.version===n.version,"Cannot mix different versions of joi schemas"),!0)},n.isValues=function(u){return u[n.symbols.values]},n.limit=function(u){return Number.isSafeInteger(u)&&u>=0},n.preferences=function(u,h){d=d||o(6914),u=u||{},h=h||{};const f=Object.assign({},u,h);return h.errors&&u.errors&&(f.errors=Object.assign({},u.errors,h.errors),f.errors.wrap=Object.assign({},u.errors.wrap,h.errors.wrap)),h.messages&&(f.messages=d.compile(h.messages,u.messages)),delete f[n.symbols.prefs],f},n.tryWithPath=function(u,h,f={}){try{return u()}catch(b){throw b.path!==void 0?b.path=h+"."+b.path:b.path=h,f.append&&(b.message=`${b.message} (${b.path})`),b}},n.validateArg=function(u,h,{assert:f,message:b}){if(n.isSchema(f)){const g=f.validate(u);return g.error?g.error.message:void 0}if(!f(u))return h?`${h} ${b}`:b},n.verifyFlat=function(u,h){for(const f of u)a(!Array.isArray(f),"Method no longer accepts array arguments:",h)}},3292:(r,n,o)=>{const a=o(375),p=o(8160),m=o(6133),d={};n.schema=function(l,c,u={}){p.assertOptions(u,["appendPath","override"]);try{return d.schema(l,c,u)}catch(h){throw u.appendPath&&h.path!==void 0&&(h.message=`${h.message} (${h.path})`),h}},d.schema=function(l,c,u){a(c!==void 0,"Invalid undefined schema"),Array.isArray(c)&&(a(c.length,"Invalid empty array schema"),c.length===1&&(c=c[0]));const h=(f,...b)=>u.override!==!1?f.valid(l.override,...b):f.valid(...b);if(d.simple(c))return h(l,c);if(typeof c=="function")return l.custom(c);if(a(typeof c=="object","Invalid schema content:",typeof c),p.isResolvable(c))return h(l,c);if(p.isSchema(c))return c;if(Array.isArray(c)){for(const f of c)if(!d.simple(f))return l.alternatives().try(...c);return h(l,...c)}return c instanceof RegExp?l.string().regex(c):c instanceof Date?h(l.date(),c):(a(Object.getPrototypeOf(c)===Object.getPrototypeOf({}),"Schema can only contain plain objects"),l.object().keys(c))},n.ref=function(l,c){return m.isRef(l)?l:m.create(l,c)},n.compile=function(l,c,u={}){p.assertOptions(u,["legacy"]);const h=c&&c[p.symbols.any];if(h)return a(u.legacy||h.version===p.version,"Cannot mix different versions of joi schemas:",h.version,p.version),c;if(typeof c!="object"||!u.legacy)return n.schema(l,c,{appendPath:!0});const f=d.walk(c);return f?f.compile(f.root,c):n.schema(l,c,{appendPath:!0})},d.walk=function(l){if(typeof l!="object")return null;if(Array.isArray(l)){for(const u of l){const h=d.walk(u);if(h)return h}return null}const c=l[p.symbols.any];if(c)return{root:l[c.root],compile:c.compile};a(Object.getPrototypeOf(l)===Object.getPrototypeOf({}),"Schema can only contain plain objects");for(const u in l){const h=d.walk(l[u]);if(h)return h}return null},d.simple=function(l){return l===null||["boolean","string","number"].includes(typeof l)},n.when=function(l,c,u){if(u===void 0&&(a(c&&typeof c=="object","Missing options"),u=c,c=m.create(".")),Array.isArray(u)&&(u={switch:u}),p.assertOptions(u,["is","not","then","otherwise","switch","break"]),p.isSchema(c))return a(u.is===void 0,'"is" can not be used with a schema condition'),a(u.not===void 0,'"not" can not be used with a schema condition'),a(u.switch===void 0,'"switch" can not be used with a schema condition'),d.condition(l,{is:c,then:u.then,otherwise:u.otherwise,break:u.break});if(a(m.isRef(c)||typeof c=="string","Invalid condition:",c),a(u.not===void 0||u.is===void 0,'Cannot combine "is" with "not"'),u.switch===void 0){let f=u;u.not!==void 0&&(f={is:u.not,then:u.otherwise,otherwise:u.then,break:u.break});let b=f.is!==void 0?l.$_compile(f.is):l.$_root.invalid(null,!1,0,"").required();return a(f.then!==void 0||f.otherwise!==void 0,'options must have at least one of "then", "otherwise", or "switch"'),a(f.break===void 0||f.then===void 0||f.otherwise===void 0,"Cannot specify then, otherwise, and break all together"),u.is===void 0||m.isRef(u.is)||p.isSchema(u.is)||(b=b.required()),d.condition(l,{ref:n.ref(c),is:b,then:f.then,otherwise:f.otherwise,break:f.break})}a(Array.isArray(u.switch),'"switch" must be an array'),a(u.is===void 0,'Cannot combine "switch" with "is"'),a(u.not===void 0,'Cannot combine "switch" with "not"'),a(u.then===void 0,'Cannot combine "switch" with "then"');const h={ref:n.ref(c),switch:[],break:u.break};for(let f=0;f<u.switch.length;++f){const b=u.switch[f],g=f===u.switch.length-1;p.assertOptions(b,g?["is","then","otherwise"]:["is","then"]),a(b.is!==void 0,'Switch statement missing "is"'),a(b.then!==void 0,'Switch statement missing "then"');const y={is:l.$_compile(b.is),then:l.$_compile(b.then)};if(m.isRef(b.is)||p.isSchema(b.is)||(y.is=y.is.required()),g){a(u.otherwise===void 0||b.otherwise===void 0,'Cannot specify "otherwise" inside and outside a "switch"');const v=u.otherwise!==void 0?u.otherwise:b.otherwise;v!==void 0&&(a(h.break===void 0,"Cannot specify both otherwise and break"),y.otherwise=l.$_compile(v))}h.switch.push(y)}return h},d.condition=function(l,c){for(const u of["then","otherwise"])c[u]===void 0?delete c[u]:c[u]=l.$_compile(c[u]);return c}},6354:(r,n,o)=>{const a=o(5688),p=o(8160),m=o(3328);n.Report=class{constructor(d,l,c,u,h,f,b){if(this.code=d,this.flags=u,this.messages=h,this.path=f.path,this.prefs=b,this.state=f,this.value=l,this.message=null,this.template=null,this.local=c||{},this.local.label=n.label(this.flags,this.state,this.prefs,this.messages),this.value===void 0||this.local.hasOwnProperty("value")||(this.local.value=this.value),this.path.length){const g=this.path[this.path.length-1];typeof g!="object"&&(this.local.key=g)}}_setTemplate(d){if(this.template=d,!this.flags.label&&this.path.length===0){const l=this._template(this.template,"root");l&&(this.local.label=l)}}toString(){if(this.message)return this.message;const d=this.code;if(!this.prefs.errors.render)return this.code;const l=this._template(this.template)||this._template(this.prefs.messages)||this._template(this.messages);return l===void 0?`Error code "${d}" is not defined, your custom type is missing the correct messages definition`:(this.message=l.render(this.value,this.state,this.prefs,this.local,{errors:this.prefs.errors,messages:[this.prefs.messages,this.messages]}),this.prefs.errors.label||(this.message=this.message.replace(/^"" /,"").trim()),this.message)}_template(d,l){return n.template(this.value,d,l||this.code,this.state,this.prefs)}},n.path=function(d){let l="";for(const c of d)typeof c!="object"&&(typeof c=="string"?(l&&(l+="."),l+=c):l+=`[${c}]`);return l},n.template=function(d,l,c,u,h){if(!l)return;if(m.isTemplate(l))return c!=="root"?l:null;let f=h.errors.language;if(p.isResolvable(f)&&(f=f.resolve(d,u,h)),f&&l[f]){if(l[f][c]!==void 0)return l[f][c];if(l[f]["*"]!==void 0)return l[f]["*"]}return l[c]?l[c]:l["*"]},n.label=function(d,l,c,u){if(!c.errors.label)return"";if(d.label)return d.label;let h=l.path;return c.errors.label==="key"&&l.path.length>1&&(h=l.path.slice(-1)),n.path(h)||n.template(null,c.messages,"root",l,c)||u&&n.template(null,u,"root",l,c)||"value"},n.process=function(d,l,c){if(!d)return null;const{override:u,message:h,details:f}=n.details(d);if(u)return u;if(c.errors.stack)return new n.ValidationError(h,f,l);const b=Error.stackTraceLimit;Error.stackTraceLimit=0;const g=new n.ValidationError(h,f,l);return Error.stackTraceLimit=b,g},n.details=function(d,l={}){let c=[];const u=[];for(const h of d){if(h instanceof Error){if(l.override!==!1)return{override:h};const b=h.toString();c.push(b),u.push({message:b,type:"override",context:{error:h}});continue}const f=h.toString();c.push(f),u.push({message:f,path:h.path.filter(b=>typeof b!="object"),type:h.code,context:h.local})}return c.length>1&&(c=[...new Set(c)]),{message:c.join(". "),details:u}},n.ValidationError=class extends Error{constructor(d,l,c){super(d),this._original=c,this.details=l}static isError(d){return d instanceof n.ValidationError}},n.ValidationError.prototype.isJoi=!0,n.ValidationError.prototype.name="ValidationError",n.ValidationError.prototype.annotate=a.error},8901:(r,n,o)=>{const a=o(375),p=o(8571),m=o(8160),d=o(6914),l={};n.type=function(c,u){const h=Object.getPrototypeOf(c),f=p(h),b=c._assign(Object.create(f)),g=Object.assign({},u);delete g.base,f._definition=g;const y=h._definition||{};g.messages=d.merge(y.messages,g.messages),g.properties=Object.assign({},y.properties,g.properties),b.type=g.type,g.flags=Object.assign({},y.flags,g.flags);const v=Object.assign({},y.terms);if(g.terms)for(const T in g.terms){const w=g.terms[T];a(b.$_terms[T]===void 0,"Invalid term override for",g.type,T),b.$_terms[T]=w.init,v[T]=w}g.terms=v,g.args||(g.args=y.args),g.prepare=l.prepare(g.prepare,y.prepare),g.coerce&&(typeof g.coerce=="function"&&(g.coerce={method:g.coerce}),g.coerce.from&&!Array.isArray(g.coerce.from)&&(g.coerce={method:g.coerce.method,from:[].concat(g.coerce.from)})),g.coerce=l.coerce(g.coerce,y.coerce),g.validate=l.validate(g.validate,y.validate);const _=Object.assign({},y.rules);if(g.rules)for(const T in g.rules){const w=g.rules[T];a(typeof w=="object","Invalid rule definition for",g.type,T);let x=w.method;if(x===void 0&&(x=function(){return this.$_addRule(T)}),x&&(a(!f[T],"Rule conflict in",g.type,T),f[T]=x),a(!_[T],"Rule conflict in",g.type,T),_[T]=w,w.alias){const k=[].concat(w.alias);for(const E of k)f[E]=w.method}w.args&&(w.argsByName=new Map,w.args=w.args.map(k=>(typeof k=="string"&&(k={name:k}),a(!w.argsByName.has(k.name),"Duplicated argument name",k.name),m.isSchema(k.assert)&&(k.assert=k.assert.strict().label(k.name)),w.argsByName.set(k.name,k),k)))}g.rules=_;const C=Object.assign({},y.modifiers);if(g.modifiers)for(const T in g.modifiers){a(!f[T],"Rule conflict in",g.type,T);const w=g.modifiers[T];a(typeof w=="function","Invalid modifier definition for",g.type,T);const x=function(k){return this.rule({[T]:k})};f[T]=x,C[T]=w}if(g.modifiers=C,g.overrides){f._super=h,b.$_super={};for(const T in g.overrides)a(h[T],"Cannot override missing",T),g.overrides[T][m.symbols.parent]=h[T],b.$_super[T]=h[T].bind(b);Object.assign(f,g.overrides)}g.cast=Object.assign({},y.cast,g.cast);const S=Object.assign({},y.manifest,g.manifest);return S.build=l.build(g.manifest&&g.manifest.build,y.manifest&&y.manifest.build),g.manifest=S,g.rebuild=l.rebuild(g.rebuild,y.rebuild),b},l.build=function(c,u){return c&&u?function(h,f){return u(c(h,f),f)}:c||u},l.coerce=function(c,u){return c&&u?{from:c.from&&u.from?[...new Set([...c.from,...u.from])]:null,method(h,f){let b;if((!u.from||u.from.includes(typeof h))&&(b=u.method(h,f),b)){if(b.errors||b.value===void 0)return b;h=b.value}if(!c.from||c.from.includes(typeof h)){const g=c.method(h,f);if(g)return g}return b}}:c||u},l.prepare=function(c,u){return c&&u?function(h,f){const b=c(h,f);if(b){if(b.errors||b.value===void 0)return b;h=b.value}return u(h,f)||b}:c||u},l.rebuild=function(c,u){return c&&u?function(h){u(h),c(h)}:c||u},l.validate=function(c,u){return c&&u?function(h,f){const b=u(h,f);if(b){if(b.errors&&(!Array.isArray(b.errors)||b.errors.length))return b;h=b.value}return c(h,f)||b}:c||u}},5107:(r,n,o)=>{const a=o(375),p=o(8571),m=o(8652),d=o(8160),l=o(3292),c=o(6354),u=o(8901),h=o(9708),f=o(6133),b=o(3328),g=o(1152);let y;const v={types:{alternatives:o(4946),any:o(8068),array:o(546),boolean:o(4937),date:o(7500),function:o(390),link:o(8785),number:o(3832),object:o(8966),string:o(7417),symbol:o(8826)},aliases:{alt:"alternatives",bool:"boolean",func:"function"},root:function(){const _={_types:new Set(Object.keys(v.types))};for(const C of _._types)_[C]=function(...S){return a(!S.length||["alternatives","link","object"].includes(C),"The",C,"type does not allow arguments"),v.generate(this,v.types[C],S)};for(const C of["allow","custom","disallow","equal","exist","forbidden","invalid","not","only","optional","options","prefs","preferences","required","strip","valid","when"])_[C]=function(...S){return this.any()[C](...S)};Object.assign(_,v.methods);for(const C in v.aliases){const S=v.aliases[C];_[C]=_[S]}return _.x=_.expression,g.setup&&g.setup(_),_}};v.methods={ValidationError:c.ValidationError,version:d.version,cache:m.provider,assert(_,C,...S){v.assert(_,C,!0,S)},attempt:(_,C,...S)=>v.assert(_,C,!1,S),build(_){return a(typeof h.build=="function","Manifest functionality disabled"),h.build(this,_)},checkPreferences(_){d.checkPreferences(_)},compile(_,C){return l.compile(this,_,C)},defaults(_){a(typeof _=="function","modifier must be a function");const C=Object.assign({},this);for(const S of C._types){const T=_(C[S]());a(d.isSchema(T),"modifier must return a valid schema object"),C[S]=function(...w){return v.generate(this,T,w)}}return C},expression:(..._)=>new b(..._),extend(..._){d.verifyFlat(_,"extend"),y=y||o(3378),a(_.length,"You need to provide at least one extension"),this.assert(_,y.extensions);const C=Object.assign({},this);C._types=new Set(C._types);for(let S of _){typeof S=="function"&&(S=S(C)),this.assert(S,y.extension);const T=v.expandExtension(S,C);for(const w of T){a(C[w.type]===void 0||C._types.has(w.type),"Cannot override name",w.type);const x=w.base||this.any(),k=u.type(x,w);C._types.add(w.type),C[w.type]=function(...E){return v.generate(this,k,E)}}}return C},isError:c.ValidationError.isError,isExpression:b.isTemplate,isRef:f.isRef,isSchema:d.isSchema,in:(..._)=>f.in(..._),override:d.symbols.override,ref:(..._)=>f.create(..._),types(){const _={};for(const C of this._types)_[C]=this[C]();for(const C in v.aliases)_[C]=this[C]();return _}},v.assert=function(_,C,S,T){const w=T[0]instanceof Error||typeof T[0]=="string"?T[0]:null,x=w!==null?T[1]:T[0],k=C.validate(_,d.preferences({errors:{stack:!0}},x||{}));let E=k.error;if(!E)return k.value;if(w instanceof Error)throw w;const P=S&&typeof E.annotate=="function"?E.annotate():E.message;throw E instanceof c.ValidationError==0&&(E=p(E)),E.message=w?`${w} ${P}`:P,E},v.generate=function(_,C,S){return a(_,"Must be invoked on a Joi instance."),C.$_root=_,C._definition.args&&S.length?C._definition.args(C,...S):C},v.expandExtension=function(_,C){if(typeof _.type=="string")return[_];const S=[];for(const T of C._types)if(_.type.test(T)){const w=Object.assign({},_);w.type=T,w.base=C[T](),S.push(w)}return S},r.exports=v.root()},6914:(r,n,o)=>{const a=o(375),p=o(8571),m=o(3328);n.compile=function(d,l){if(typeof d=="string")return a(!l,"Cannot set single message string"),new m(d);if(m.isTemplate(d))return a(!l,"Cannot set single message template"),d;a(typeof d=="object"&&!Array.isArray(d),"Invalid message options"),l=l?p(l):{};for(let c in d){const u=d[c];if(c==="root"||m.isTemplate(u)){l[c]=u;continue}if(typeof u=="string"){l[c]=new m(u);continue}a(typeof u=="object"&&!Array.isArray(u),"Invalid message for",c);const h=c;for(c in l[h]=l[h]||{},u){const f=u[c];c==="root"||m.isTemplate(f)?l[h][c]=f:(a(typeof f=="string","Invalid message for",c,"in",h),l[h][c]=new m(f))}}return l},n.decompile=function(d){const l={};for(let c in d){const u=d[c];if(c==="root"){l.root=u;continue}if(m.isTemplate(u)){l[c]=u.describe({compact:!0});continue}const h=c;for(c in l[h]={},u){const f=u[c];c!=="root"?l[h][c]=f.describe({compact:!0}):l[h].root=f}}return l},n.merge=function(d,l){if(!d)return n.compile(l);if(!l)return d;if(typeof l=="string")return new m(l);if(m.isTemplate(l))return l;const c=p(d);for(let u in l){const h=l[u];if(u==="root"||m.isTemplate(h)){c[u]=h;continue}if(typeof h=="string"){c[u]=new m(h);continue}a(typeof h=="object"&&!Array.isArray(h),"Invalid message for",u);const f=u;for(u in c[f]=c[f]||{},h){const b=h[u];u==="root"||m.isTemplate(b)?c[f][u]=b:(a(typeof b=="string","Invalid message for",u,"in",f),c[f][u]=new m(b))}}return c}},2294:(r,n,o)=>{const a=o(375),p=o(8160),m=o(6133),d={};n.Ids=d.Ids=class{constructor(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}clone(){const l=new d.Ids;return l._byId=new Map(this._byId),l._byKey=new Map(this._byKey),l._schemaChain=this._schemaChain,l}concat(l){l._schemaChain&&(this._schemaChain=!0);for(const[c,u]of l._byId.entries())a(!this._byKey.has(c),"Schema id conflicts with existing key:",c),this._byId.set(c,u);for(const[c,u]of l._byKey.entries())a(!this._byId.has(c),"Schema key conflicts with existing id:",c),this._byKey.set(c,u)}fork(l,c,u){const h=this._collect(l);h.push({schema:u});const f=h.shift();let b={id:f.id,schema:c(f.schema)};a(p.isSchema(b.schema),"adjuster function failed to return a joi schema type");for(const g of h)b={id:g.id,schema:d.fork(g.schema,b.id,b.schema)};return b.schema}labels(l,c=[]){const u=l[0],h=this._get(u);if(!h)return[...c,...l].join(".");const f=l.slice(1);return c=[...c,h.schema._flags.label||u],f.length?h.schema._ids.labels(f,c):c.join(".")}reach(l,c=[]){const u=l[0],h=this._get(u);a(h,"Schema does not contain path",[...c,...l].join("."));const f=l.slice(1);return f.length?h.schema._ids.reach(f,[...c,u]):h.schema}register(l,{key:c}={}){if(!l||!p.isSchema(l))return;(l.$_property("schemaChain")||l._ids._schemaChain)&&(this._schemaChain=!0);const u=l._flags.id;if(u){const h=this._byId.get(u);a(!h||h.schema===l,"Cannot add different schemas with the same id:",u),a(!this._byKey.has(u),"Schema id conflicts with existing key:",u),this._byId.set(u,{schema:l,id:u})}c&&(a(!this._byKey.has(c),"Schema already contains key:",c),a(!this._byId.has(c),"Schema key conflicts with existing id:",c),this._byKey.set(c,{schema:l,id:c}))}reset(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}_collect(l,c=[],u=[]){const h=l[0],f=this._get(h);a(f,"Schema does not contain path",[...c,...l].join(".")),u=[f,...u];const b=l.slice(1);return b.length?f.schema._ids._collect(b,[...c,h],u):u}_get(l){return this._byId.get(l)||this._byKey.get(l)}},d.fork=function(l,c,u){const h=n.schema(l,{each:(f,{key:b})=>{if(c===(f._flags.id||b))return u},ref:!1});return h?h.$_mutateRebuild():l},n.schema=function(l,c){let u;for(const h in l._flags){if(h[0]==="_")continue;const f=d.scan(l._flags[h],{source:"flags",name:h},c);f!==void 0&&(u=u||l.clone(),u._flags[h]=f)}for(let h=0;h<l._rules.length;++h){const f=l._rules[h],b=d.scan(f.args,{source:"rules",name:f.name},c);if(b!==void 0){u=u||l.clone();const g=Object.assign({},f);g.args=b,u._rules[h]=g,u._singleRules.get(f.name)===f&&u._singleRules.set(f.name,g)}}for(const h in l.$_terms){if(h[0]==="_")continue;const f=d.scan(l.$_terms[h],{source:"terms",name:h},c);f!==void 0&&(u=u||l.clone(),u.$_terms[h]=f)}return u},d.scan=function(l,c,u,h,f){const b=h||[];if(l===null||typeof l!="object")return;let g;if(Array.isArray(l)){for(let y=0;y<l.length;++y){const v=c.source==="terms"&&c.name==="keys"&&l[y].key,_=d.scan(l[y],c,u,[y,...b],v);_!==void 0&&(g=g||l.slice(),g[y]=_)}return g}if(u.schema!==!1&&p.isSchema(l)||u.ref!==!1&&m.isRef(l)){const y=u.each(l,{...c,path:b,key:f});return y===l?void 0:y}for(const y in l){if(y[0]==="_")continue;const v=d.scan(l[y],c,u,[y,...b],f);v!==void 0&&(g=g||Object.assign({},l),g[y]=v)}return g}},6133:(r,n,o)=>{const a=o(375),p=o(8571),m=o(9621),d=o(8160);let l;const c={symbol:Symbol("ref"),defaults:{adjust:null,in:!1,iterables:null,map:null,separator:".",type:"value"}};n.create=function(u,h={}){a(typeof u=="string","Invalid reference key:",u),d.assertOptions(h,["adjust","ancestor","in","iterables","map","prefix","render","separator"]),a(!h.prefix||typeof h.prefix=="object","options.prefix must be of type object");const f=Object.assign({},c.defaults,h);delete f.prefix;const b=f.separator,g=c.context(u,b,h.prefix);if(f.type=g.type,u=g.key,f.type==="value")if(g.root&&(a(!b||u[0]!==b,"Cannot specify relative path with root prefix"),f.ancestor="root",u||(u=null)),b&&b===u)u=null,f.ancestor=0;else if(f.ancestor!==void 0)a(!b||!u||u[0]!==b,"Cannot combine prefix with ancestor option");else{const[y,v]=c.ancestor(u,b);v&&(u=u.slice(v))===""&&(u=null),f.ancestor=y}return f.path=b?u===null?[]:u.split(b):[u],new c.Ref(f)},n.in=function(u,h={}){return n.create(u,{...h,in:!0})},n.isRef=function(u){return!!u&&!!u[d.symbols.ref]},c.Ref=class{constructor(u){a(typeof u=="object","Invalid reference construction"),d.assertOptions(u,["adjust","ancestor","in","iterables","map","path","render","separator","type","depth","key","root","display"]),a([!1,void 0].includes(u.separator)||typeof u.separator=="string"&&u.separator.length===1,"Invalid separator"),a(!u.adjust||typeof u.adjust=="function","options.adjust must be a function"),a(!u.map||Array.isArray(u.map),"options.map must be an array"),a(!u.map||!u.adjust,"Cannot set both map and adjust options"),Object.assign(this,c.defaults,u),a(this.type==="value"||this.ancestor===void 0,"Non-value references cannot reference ancestors"),Array.isArray(this.map)&&(this.map=new Map(this.map)),this.depth=this.path.length,this.key=this.path.length?this.path.join(this.separator):null,this.root=this.path[0],this.updateDisplay()}resolve(u,h,f,b,g={}){return a(!this.in||g.in,"Invalid in() reference usage"),this.type==="global"?this._resolve(f.context,h,g):this.type==="local"?this._resolve(b,h,g):this.ancestor?this.ancestor==="root"?this._resolve(h.ancestors[h.ancestors.length-1],h,g):(a(this.ancestor<=h.ancestors.length,"Invalid reference exceeds the schema root:",this.display),this._resolve(h.ancestors[this.ancestor-1],h,g)):this._resolve(u,h,g)}_resolve(u,h,f){let b;if(this.type==="value"&&h.mainstay.shadow&&f.shadow!==!1&&(b=h.mainstay.shadow.get(this.absolute(h))),b===void 0&&(b=m(u,this.path,{iterables:this.iterables,functions:!0})),this.adjust&&(b=this.adjust(b)),this.map){const g=this.map.get(b);g!==void 0&&(b=g)}return h.mainstay&&h.mainstay.tracer.resolve(h,this,b),b}toString(){return this.display}absolute(u){return[...u.path.slice(0,-this.ancestor),...this.path]}clone(){return new c.Ref(this)}describe(){const u={path:this.path};this.type!=="value"&&(u.type=this.type),this.separator!=="."&&(u.separator=this.separator),this.type==="value"&&this.ancestor!==1&&(u.ancestor=this.ancestor),this.map&&(u.map=[...this.map]);for(const h of["adjust","iterables","render"])this[h]!==null&&this[h]!==void 0&&(u[h]=this[h]);return this.in!==!1&&(u.in=!0),{ref:u}}updateDisplay(){const u=this.key!==null?this.key:"";if(this.type!=="value")return void(this.display=`ref:${this.type}:${u}`);if(!this.separator)return void(this.display=`ref:${u}`);if(!this.ancestor)return void(this.display=`ref:${this.separator}${u}`);if(this.ancestor==="root")return void(this.display=`ref:root:${u}`);if(this.ancestor===1)return void(this.display=`ref:${u||".."}`);const h=new Array(this.ancestor+1).fill(this.separator).join("");this.display=`ref:${h}${u||""}`}},c.Ref.prototype[d.symbols.ref]=!0,n.build=function(u){return(u=Object.assign({},c.defaults,u)).type==="value"&&u.ancestor===void 0&&(u.ancestor=1),new c.Ref(u)},c.context=function(u,h,f={}){if(u=u.trim(),f){const b=f.global===void 0?"$":f.global;if(b!==h&&u.startsWith(b))return{key:u.slice(b.length),type:"global"};const g=f.local===void 0?"#":f.local;if(g!==h&&u.startsWith(g))return{key:u.slice(g.length),type:"local"};const y=f.root===void 0?"/":f.root;if(y!==h&&u.startsWith(y))return{key:u.slice(y.length),type:"value",root:!0}}return{key:u,type:"value"}},c.ancestor=function(u,h){if(!h)return[1,0];if(u[0]!==h)return[1,0];if(u[1]!==h)return[0,1];let f=2;for(;u[f]===h;)++f;return[f-1,f]},n.toSibling=0,n.toParent=1,n.Manager=class{constructor(){this.refs=[]}register(u,h){if(u)if(h=h===void 0?n.toParent:h,Array.isArray(u))for(const f of u)this.register(f,h);else if(d.isSchema(u))for(const f of u._refs.refs)f.ancestor-h>=0&&this.refs.push({ancestor:f.ancestor-h,root:f.root});else n.isRef(u)&&u.type==="value"&&u.ancestor-h>=0&&this.refs.push({ancestor:u.ancestor-h,root:u.root}),l=l||o(3328),l.isTemplate(u)&&this.register(u.refs(),h)}get length(){return this.refs.length}clone(){const u=new n.Manager;return u.refs=p(this.refs),u}reset(){this.refs=[]}roots(){return this.refs.filter(u=>!u.ancestor).map(u=>u.root)}}},3378:(r,n,o)=>{const a=o(5107),p={};p.wrap=a.string().min(1).max(2).allow(!1),n.preferences=a.object({allowUnknown:a.boolean(),abortEarly:a.boolean(),artifacts:a.boolean(),cache:a.boolean(),context:a.object(),convert:a.boolean(),dateFormat:a.valid("date","iso","string","time","utc"),debug:a.boolean(),errors:{escapeHtml:a.boolean(),label:a.valid("path","key",!1),language:[a.string(),a.object().ref()],render:a.boolean(),stack:a.boolean(),wrap:{label:p.wrap,array:p.wrap,string:p.wrap}},externals:a.boolean(),messages:a.object(),noDefaults:a.boolean(),nonEnumerables:a.boolean(),presence:a.valid("required","optional","forbidden"),skipFunctions:a.boolean(),stripUnknown:a.object({arrays:a.boolean(),objects:a.boolean()}).or("arrays","objects").allow(!0,!1),warnings:a.boolean()}).strict(),p.nameRx=/^[a-zA-Z0-9]\w*$/,p.rule=a.object({alias:a.array().items(a.string().pattern(p.nameRx)).single(),args:a.array().items(a.string(),a.object({name:a.string().pattern(p.nameRx).required(),ref:a.boolean(),assert:a.alternatives([a.function(),a.object().schema()]).conditional("ref",{is:!0,then:a.required()}),normalize:a.function(),message:a.string().when("assert",{is:a.function(),then:a.required()})})),convert:a.boolean(),manifest:a.boolean(),method:a.function().allow(!1),multi:a.boolean(),validate:a.function()}),n.extension=a.object({type:a.alternatives([a.string(),a.object().regex()]).required(),args:a.function(),cast:a.object().pattern(p.nameRx,a.object({from:a.function().maxArity(1).required(),to:a.function().minArity(1).maxArity(2).required()})),base:a.object().schema().when("type",{is:a.object().regex(),then:a.forbidden()}),coerce:[a.function().maxArity(3),a.object({method:a.function().maxArity(3).required(),from:a.array().items(a.string()).single()})],flags:a.object().pattern(p.nameRx,a.object({setter:a.string(),default:a.any()})),manifest:{build:a.function().arity(2)},messages:[a.object(),a.string()],modifiers:a.object().pattern(p.nameRx,a.function().minArity(1).maxArity(2)),overrides:a.object().pattern(p.nameRx,a.function()),prepare:a.function().maxArity(3),rebuild:a.function().arity(1),rules:a.object().pattern(p.nameRx,p.rule),terms:a.object().pattern(p.nameRx,a.object({init:a.array().allow(null).required(),manifest:a.object().pattern(/.+/,[a.valid("schema","single"),a.object({mapped:a.object({from:a.string().required(),to:a.string().required()}).required()})])})),validate:a.function().maxArity(3)}).strict(),n.extensions=a.array().items(a.object(),a.function().arity(1)).strict(),p.desc={buffer:a.object({buffer:a.string()}),func:a.object({function:a.function().required(),options:{literal:!0}}),override:a.object({override:!0}),ref:a.object({ref:a.object({type:a.valid("value","global","local"),path:a.array().required(),separator:a.string().length(1).allow(!1),ancestor:a.number().min(0).integer().allow("root"),map:a.array().items(a.array().length(2)).min(1),adjust:a.function(),iterables:a.boolean(),in:a.boolean(),render:a.boolean()}).required()}),regex:a.object({regex:a.string().min(3)}),special:a.object({special:a.valid("deep").required()}),template:a.object({template:a.string().required(),options:a.object()}),value:a.object({value:a.alternatives([a.object(),a.array()]).required()})},p.desc.entity=a.alternatives([a.array().items(a.link("...")),a.boolean(),a.function(),a.number(),a.string(),p.desc.buffer,p.desc.func,p.desc.ref,p.desc.regex,p.desc.special,p.desc.template,p.desc.value,a.link("/")]),p.desc.values=a.array().items(null,a.boolean(),a.function(),a.number().allow(1/0,-1/0),a.string().allow(""),a.symbol(),p.desc.buffer,p.desc.func,p.desc.override,p.desc.ref,p.desc.regex,p.desc.template,p.desc.value),p.desc.messages=a.object().pattern(/.+/,[a.string(),p.desc.template,a.object().pattern(/.+/,[a.string(),p.desc.template])]),n.description=a.object({type:a.string().required(),flags:a.object({cast:a.string(),default:a.any(),description:a.string(),empty:a.link("/"),failover:p.desc.entity,id:a.string(),label:a.string(),only:!0,presence:["optional","required","forbidden"],result:["raw","strip"],strip:a.boolean(),unit:a.string()}).unknown(),preferences:{allowUnknown:a.boolean(),abortEarly:a.boolean(),artifacts:a.boolean(),cache:a.boolean(),convert:a.boolean(),dateFormat:["date","iso","string","time","utc"],errors:{escapeHtml:a.boolean(),label:["path","key"],language:[a.string(),p.desc.ref],wrap:{label:p.wrap,array:p.wrap}},externals:a.boolean(),messages:p.desc.messages,noDefaults:a.boolean(),nonEnumerables:a.boolean(),presence:["required","optional","forbidden"],skipFunctions:a.boolean(),stripUnknown:a.object({arrays:a.boolean(),objects:a.boolean()}).or("arrays","objects").allow(!0,!1),warnings:a.boolean()},allow:p.desc.values,invalid:p.desc.values,rules:a.array().min(1).items({name:a.string().required(),args:a.object().min(1),keep:a.boolean(),message:[a.string(),p.desc.messages],warn:a.boolean()}),keys:a.object().pattern(/.*/,a.link("/")),link:p.desc.ref}).pattern(/^[a-z]\w*$/,a.any())},493:(r,n,o)=>{const a=o(8571),p=o(9621),m=o(8160),d={value:Symbol("value")};r.exports=d.State=class{constructor(l,c,u){this.path=l,this.ancestors=c,this.mainstay=u.mainstay,this.schemas=u.schemas,this.debug=null}localize(l,c=null,u=null){const h=new d.State(l,c,this);return u&&h.schemas&&(h.schemas=[d.schemas(u),...h.schemas]),h}nest(l,c){const u=new d.State(this.path,this.ancestors,this);return u.schemas=u.schemas&&[d.schemas(l),...u.schemas],u.debug=c,u}shadow(l,c){this.mainstay.shadow=this.mainstay.shadow||new d.Shadow,this.mainstay.shadow.set(this.path,l,c)}snapshot(){this.mainstay.shadow&&(this._snapshot=a(this.mainstay.shadow.node(this.path))),this.mainstay.snapshot()}restore(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.restore()}commit(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.commit()}},d.schemas=function(l){return m.isSchema(l)?{schema:l}:l},d.Shadow=class{constructor(){this._values=null}set(l,c,u){if(!l.length||u==="strip"&&typeof l[l.length-1]=="number")return;this._values=this._values||new Map;let h=this._values;for(let f=0;f<l.length;++f){const b=l[f];let g=h.get(b);g||(g=new Map,h.set(b,g)),h=g}h[d.value]=c}get(l){const c=this.node(l);if(c)return c[d.value]}node(l){if(this._values)return p(this._values,l,{iterables:!0})}override(l,c){if(!this._values)return;const u=l.slice(0,-1),h=l[l.length-1],f=p(this._values,u,{iterables:!0});c?f.set(h,c):f&&f.delete(h)}}},3328:(r,n,o)=>{const a=o(375),p=o(8571),m=o(5277),d=o(1447),l=o(8160),c=o(6354),u=o(6133),h={symbol:Symbol("template"),opens:new Array(1e3).join("\0"),closes:new Array(1e3).join(""),dateFormat:{date:Date.prototype.toDateString,iso:Date.prototype.toISOString,string:Date.prototype.toString,time:Date.prototype.toTimeString,utc:Date.prototype.toUTCString}};r.exports=h.Template=class{constructor(f,b){if(a(typeof f=="string","Template source must be a string"),a(!f.includes("\0")&&!f.includes(""),"Template source cannot contain reserved control characters"),this.source=f,this.rendered=f,this._template=null,b){const{functions:g,...y}=b;this._settings=Object.keys(y).length?p(y):void 0,this._functions=g,this._functions&&(a(Object.keys(this._functions).every(v=>typeof v=="string"),"Functions keys must be strings"),a(Object.values(this._functions).every(v=>typeof v=="function"),"Functions values must be functions"))}else this._settings=void 0,this._functions=void 0;this._parse()}_parse(){if(!this.source.includes("{"))return;const f=h.encode(this.source),b=h.split(f);let g=!1;const y=[],v=b.shift();v&&y.push(v);for(const _ of b){const C=_[0]!=="{",S=C?"}":"}}",T=_.indexOf(S);if(T===-1||_[1]==="{"){y.push(`{${h.decode(_)}`);continue}let w=_.slice(C?0:1,T);const x=w[0]===":";x&&(w=w.slice(1));const k=this._ref(h.decode(w),{raw:C,wrapped:x});y.push(k),typeof k!="string"&&(g=!0);const E=_.slice(T+S.length);E&&y.push(h.decode(E))}g?this._template=y:this.rendered=y.join("")}static date(f,b){return h.dateFormat[b.dateFormat].call(f)}describe(f={}){if(!this._settings&&f.compact)return this.source;const b={template:this.source};return this._settings&&(b.options=this._settings),this._functions&&(b.functions=this._functions),b}static build(f){return new h.Template(f.template,f.options||f.functions?{...f.options,functions:f.functions}:void 0)}isDynamic(){return!!this._template}static isTemplate(f){return!!f&&!!f[l.symbols.template]}refs(){if(!this._template)return;const f=[];for(const b of this._template)typeof b!="string"&&f.push(...b.refs);return f}resolve(f,b,g,y){return this._template&&this._template.length===1?this._part(this._template[0],f,b,g,y,{}):this.render(f,b,g,y)}_part(f,...b){return f.ref?f.ref.resolve(...b):f.formula.evaluate(b)}render(f,b,g,y,v={}){if(!this.isDynamic())return this.rendered;const _=[];for(const C of this._template)if(typeof C=="string")_.push(C);else{const S=this._part(C,f,b,g,y,v),T=h.stringify(S,f,b,g,y,v);if(T!==void 0){const w=C.raw||(v.errors&&v.errors.escapeHtml)===!1?T:m(T);_.push(h.wrap(w,C.wrapped&&g.errors.wrap.label))}}return _.join("")}_ref(f,{raw:b,wrapped:g}){const y=[],v=C=>{const S=u.create(C,this._settings);return y.push(S),T=>{const w=S.resolve(...T);return w!==void 0?w:null}};try{const C=this._functions?{...h.functions,...this._functions}:h.functions;var _=new d.Parser(f,{reference:v,functions:C,constants:h.constants})}catch(C){throw C.message=`Invalid template variable "${f}" fails due to: ${C.message}`,C}if(_.single){if(_.single.type==="reference"){const C=y[0];return{ref:C,raw:b,refs:y,wrapped:g||C.type==="local"&&C.key==="label"}}return h.stringify(_.single.value)}return{formula:_,raw:b,refs:y}}toString(){return this.source}},h.Template.prototype[l.symbols.template]=!0,h.Template.prototype.isImmutable=!0,h.encode=function(f){return f.replace(/\\(\{+)/g,(b,g)=>h.opens.slice(0,g.length)).replace(/\\(\}+)/g,(b,g)=>h.closes.slice(0,g.length))},h.decode=function(f){return f.replace(/\u0000/g,"{").replace(/\u0001/g,"}")},h.split=function(f){const b=[];let g="";for(let y=0;y<f.length;++y){const v=f[y];if(v==="{"){let _="";for(;y+1<f.length&&f[y+1]==="{";)_+="{",++y;b.push(g),g=_}else g+=v}return b.push(g),b},h.wrap=function(f,b){return b?b.length===1?`${b}${f}${b}`:`${b[0]}${f}${b[1]}`:f},h.stringify=function(f,b,g,y,v,_={}){const C=typeof f,S=y&&y.errors&&y.errors.wrap||{};let T=!1;if(u.isRef(f)&&f.render&&(T=f.in,f=f.resolve(b,g,y,v,{in:f.in,..._})),f===null)return"null";if(C==="string")return h.wrap(f,_.arrayItems&&S.string);if(C==="number"||C==="function"||C==="symbol")return f.toString();if(C!=="object")return JSON.stringify(f);if(f instanceof Date)return h.Template.date(f,y);if(f instanceof Map){const x=[];for(const[k,E]of f.entries())x.push(`${k.toString()} -> ${E.toString()}`);f=x}if(!Array.isArray(f))return f.toString();const w=[];for(const x of f)w.push(h.stringify(x,b,g,y,v,{arrayItems:!0,..._}));return h.wrap(w.join(", "),!T&&S.array)},h.constants={true:!0,false:!1,null:null,second:1e3,minute:6e4,hour:36e5,day:864e5},h.functions={if:(f,b,g)=>f?b:g,length:f=>typeof f=="string"?f.length:f&&typeof f=="object"?Array.isArray(f)?f.length:Object.keys(f).length:null,msg(f){const[b,g,y,v,_]=this,C=_.messages;if(!C)return"";const S=c.template(b,C[0],f,g,y)||c.template(b,C[1],f,g,y);return S?S.render(b,g,y,v,_):""},number:f=>typeof f=="number"?f:typeof f=="string"?parseFloat(f):typeof f=="boolean"?f?1:0:f instanceof Date?f.getTime():null}},4946:(r,n,o)=>{const a=o(375),p=o(1687),m=o(8068),d=o(8160),l=o(3292),c=o(6354),u=o(6133),h={};r.exports=m.extend({type:"alternatives",flags:{match:{default:"any"}},terms:{matches:{init:[],register:u.toSibling}},args:(f,...b)=>b.length===1&&Array.isArray(b[0])?f.try(...b[0]):f.try(...b),validate(f,b){const{schema:g,error:y,state:v,prefs:_}=b;if(g._flags.match){const S=[],T=[];for(let x=0;x<g.$_terms.matches.length;++x){const k=g.$_terms.matches[x],E=v.nest(k.schema,`match.${x}`);E.snapshot();const P=k.schema.$_validate(f,E,_);P.errors?(T.push(P.errors),E.restore()):(S.push(P.value),E.commit())}if(S.length===0)return{errors:y("alternatives.any",{details:T.map(x=>c.details(x,{override:!1}))})};if(g._flags.match==="one")return S.length===1?{value:S[0]}:{errors:y("alternatives.one")};if(S.length!==g.$_terms.matches.length)return{errors:y("alternatives.all",{details:T.map(x=>c.details(x,{override:!1}))})};const w=x=>x.$_terms.matches.some(k=>k.schema.type==="object"||k.schema.type==="alternatives"&&w(k.schema));return w(g)?{value:S.reduce((x,k)=>p(x,k,{mergeArrays:!1}))}:{value:S[S.length-1]}}const C=[];for(let S=0;S<g.$_terms.matches.length;++S){const T=g.$_terms.matches[S];if(T.schema){const k=v.nest(T.schema,`match.${S}`);k.snapshot();const E=T.schema.$_validate(f,k,_);if(!E.errors)return k.commit(),E;k.restore(),C.push({schema:T.schema,reports:E.errors});continue}const w=T.ref?T.ref.resolve(f,v,_):f,x=T.is?[T]:T.switch;for(let k=0;k<x.length;++k){const E=x[k],{is:P,then:O,otherwise:z}=E,I=`match.${S}${T.switch?"."+k:""}`;if(P.$_match(w,v.nest(P,`${I}.is`),_)){if(O)return O.$_validate(f,v.nest(O,`${I}.then`),_)}else if(z)return z.$_validate(f,v.nest(z,`${I}.otherwise`),_)}}return h.errors(C,b)},rules:{conditional:{method(f,b){a(!this._flags._endedSwitch,"Unreachable condition"),a(!this._flags.match,"Cannot combine match mode",this._flags.match,"with conditional rule"),a(b.break===void 0,"Cannot use break option with alternatives conditional");const g=this.clone(),y=l.when(g,f,b),v=y.is?[y]:y.switch;for(const _ of v)if(_.then&&_.otherwise){g.$_setFlag("_endedSwitch",!0,{clone:!1});break}return g.$_terms.matches.push(y),g.$_mutateRebuild()}},match:{method(f){if(a(["any","one","all"].includes(f),"Invalid alternatives match mode",f),f!=="any")for(const b of this.$_terms.matches)a(b.schema,"Cannot combine match mode",f,"with conditional rules");return this.$_setFlag("match",f)}},try:{method(...f){a(f.length,"Missing alternative schemas"),d.verifyFlat(f,"try"),a(!this._flags._endedSwitch,"Unreachable condition");const b=this.clone();for(const g of f)b.$_terms.matches.push({schema:b.$_compile(g)});return b.$_mutateRebuild()}}},overrides:{label(f){return this.$_parent("label",f).$_modify({each:(b,g)=>g.path[0]!=="is"&&typeof b._flags.label!="string"?b.label(f):void 0,ref:!1})}},rebuild(f){f.$_modify({each:b=>{d.isSchema(b)&&b.type==="array"&&f.$_setFlag("_arrayItems",!0,{clone:!1})}})},manifest:{build(f,b){if(b.matches)for(const g of b.matches){const{schema:y,ref:v,is:_,not:C,then:S,otherwise:T}=g;f=y?f.try(y):v?f.conditional(v,{is:_,then:S,not:C,otherwise:T,switch:g.switch}):f.conditional(_,{then:S,otherwise:T})}return f}},messages:{"alternatives.all":"{{#label}} does not match all of the required types","alternatives.any":"{{#label}} does not match any of the allowed types","alternatives.match":"{{#label}} does not match any of the allowed types","alternatives.one":"{{#label}} matches more than one allowed type","alternatives.types":"{{#label}} must be one of {{#types}}"}}),h.errors=function(f,{error:b,state:g}){if(!f.length)return{errors:b("alternatives.any")};if(f.length===1)return{errors:f[0].reports};const y=new Set,v=[];for(const{reports:_,schema:C}of f){if(_.length>1)return h.unmatched(f,b);const S=_[0];if(S instanceof c.Report==0)return h.unmatched(f,b);if(S.state.path.length!==g.path.length){v.push({type:C.type,report:S});continue}if(S.code==="any.only"){for(const x of S.local.valids)y.add(x);continue}const[T,w]=S.code.split(".");w!=="base"?v.push({type:C.type,report:S}):S.code==="object.base"?y.add(S.local.type):y.add(T)}return v.length?v.length===1?{errors:v[0].report}:h.unmatched(f,b):{errors:b("alternatives.types",{types:[...y]})}},h.unmatched=function(f,b){const g=[];for(const y of f)g.push(...y.reports);return{errors:b("alternatives.match",c.details(g,{override:!1}))}}},8068:(r,n,o)=>{const a=o(375),p=o(7629),m=o(8160),d=o(6914);r.exports=p.extend({type:"any",flags:{only:{default:!1}},terms:{alterations:{init:null},examples:{init:null},externals:{init:null},metas:{init:[]},notes:{init:[]},shared:{init:null},tags:{init:[]},whens:{init:null}},rules:{custom:{method(l,c){return a(typeof l=="function","Method must be a function"),a(c===void 0||c&&typeof c=="string","Description must be a non-empty string"),this.$_addRule({name:"custom",args:{method:l,description:c}})},validate(l,c,{method:u}){try{return u(l,c)}catch(h){return c.error("any.custom",{error:h})}},args:["method","description"],multi:!0},messages:{method(l){return this.prefs({messages:l})}},shared:{method(l){a(m.isSchema(l)&&l._flags.id,"Schema must be a schema with an id");const c=this.clone();return c.$_terms.shared=c.$_terms.shared||[],c.$_terms.shared.push(l),c.$_mutateRegister(l),c}},warning:{method(l,c){return a(l&&typeof l=="string","Invalid warning code"),this.$_addRule({name:"warning",args:{code:l,local:c},warn:!0})},validate:(l,c,{code:u,local:h})=>c.error(u,h),args:["code","local"],multi:!0}},modifiers:{keep(l,c=!0){l.keep=c},message(l,c){l.message=d.compile(c)},warn(l,c=!0){l.warn=c}},manifest:{build(l,c){for(const u in c){const h=c[u];if(["examples","externals","metas","notes","tags"].includes(u))for(const f of h)l=l[u.slice(0,-1)](f);else if(u!=="alterations")if(u!=="whens"){if(u==="shared")for(const f of h)l=l.shared(f)}else for(const f of h){const{ref:b,is:g,not:y,then:v,otherwise:_,concat:C}=f;l=C?l.concat(C):b?l.when(b,{is:g,not:y,then:v,otherwise:_,switch:f.switch,break:f.break}):l.when(g,{then:v,otherwise:_,break:f.break})}else{const f={};for(const{target:b,adjuster:g}of h)f[b]=g;l=l.alter(f)}}return l}},messages:{"any.custom":"{{#label}} failed custom validation because {{#error.message}}","any.default":"{{#label}} threw an error when running default method","any.failover":"{{#label}} threw an error when running failover method","any.invalid":"{{#label}} contains an invalid value","any.only":'{{#label}} must be {if(#valids.length == 1, "", "one of ")}{{#valids}}',"any.ref":"{{#label}} {{#arg}} references {{:#ref}} which {{#reason}}","any.required":"{{#label}} is required","any.unknown":"{{#label}} is not allowed"}})},546:(r,n,o)=>{const a=o(375),p=o(9474),m=o(9621),d=o(8068),l=o(8160),c=o(3292),u={};r.exports=d.extend({type:"array",flags:{single:{default:!1},sparse:{default:!1}},terms:{items:{init:[],manifest:"schema"},ordered:{init:[],manifest:"schema"},_exclusions:{init:[]},_inclusions:{init:[]},_requireds:{init:[]}},coerce:{from:"object",method(h,{schema:f,state:b,prefs:g}){if(!Array.isArray(h))return;const y=f.$_getRule("sort");return y?u.sort(f,h,y.args.options,b,g):void 0}},validate(h,{schema:f,error:b}){if(!Array.isArray(h)){if(f._flags.single){const g=[h];return g[l.symbols.arraySingle]=!0,{value:g}}return{errors:b("array.base")}}if(f.$_getRule("items")||f.$_terms.externals)return{value:h.slice()}},rules:{has:{method(h){h=this.$_compile(h,{appendPath:!0});const f=this.$_addRule({name:"has",args:{schema:h}});return f.$_mutateRegister(h),f},validate(h,{state:f,prefs:b,error:g},{schema:y}){const v=[h,...f.ancestors];for(let C=0;C<h.length;++C){const S=f.localize([...f.path,C],v,y);if(y.$_match(h[C],S,b))return h}const _=y._flags.label;return _?g("array.hasKnown",{patternLabel:_}):g("array.hasUnknown",null)},multi:!0},items:{method(...h){l.verifyFlat(h,"items");const f=this.$_addRule("items");for(let b=0;b<h.length;++b){const g=l.tryWithPath(()=>this.$_compile(h[b]),b,{append:!0});f.$_terms.items.push(g)}return f.$_mutateRebuild()},validate(h,{schema:f,error:b,state:g,prefs:y,errorsArray:v}){const _=f.$_terms._requireds.slice(),C=f.$_terms.ordered.slice(),S=[...f.$_terms._inclusions,..._],T=!h[l.symbols.arraySingle];delete h[l.symbols.arraySingle];const w=v();let x=h.length;for(let k=0;k<x;++k){const E=h[k];let P=!1,O=!1;const z=T?k:new Number(k),I=[...g.path,z];if(!f._flags.sparse&&E===void 0){if(w.push(b("array.sparse",{key:z,path:I,pos:k,value:void 0},g.localize(I))),y.abortEarly)return w;C.shift();continue}const L=[h,...g.ancestors];for(const X of f.$_terms._exclusions)if(X.$_match(E,g.localize(I,L,X),y,{presence:"ignore"})){if(w.push(b("array.excludes",{pos:k,value:E},g.localize(I))),y.abortEarly)return w;P=!0,C.shift();break}if(P)continue;if(f.$_terms.ordered.length){if(C.length){const X=C.shift(),Y=X.$_validate(E,g.localize(I,L,X),y);if(Y.errors){if(w.push(...Y.errors),y.abortEarly)return w}else if(X._flags.result==="strip")u.fastSplice(h,k),--k,--x;else{if(!f._flags.sparse&&Y.value===void 0){if(w.push(b("array.sparse",{key:z,path:I,pos:k,value:void 0},g.localize(I))),y.abortEarly)return w;continue}h[k]=Y.value}continue}if(!f.$_terms.items.length){if(w.push(b("array.orderedLength",{pos:k,limit:f.$_terms.ordered.length})),y.abortEarly)return w;break}}const F=[];let Z=_.length;for(let X=0;X<Z;++X){const Y=g.localize(I,L,_[X]);Y.snapshot();const se=_[X].$_validate(E,Y,y);if(F[X]=se,!se.errors){if(Y.commit(),h[k]=se.value,O=!0,u.fastSplice(_,X),--X,--Z,!f._flags.sparse&&se.value===void 0&&(w.push(b("array.sparse",{key:z,path:I,pos:k,value:void 0},g.localize(I))),y.abortEarly))return w;break}Y.restore()}if(O)continue;const Q=y.stripUnknown&&!!y.stripUnknown.arrays||!1;Z=S.length;for(const X of S){let Y;const se=_.indexOf(X);if(se!==-1)Y=F[se];else{const re=g.localize(I,L,X);if(re.snapshot(),Y=X.$_validate(E,re,y),!Y.errors){re.commit(),X._flags.result==="strip"?(u.fastSplice(h,k),--k,--x):f._flags.sparse||Y.value!==void 0?h[k]=Y.value:(w.push(b("array.sparse",{key:z,path:I,pos:k,value:void 0},g.localize(I))),P=!0),O=!0;break}re.restore()}if(Z===1){if(Q){u.fastSplice(h,k),--k,--x,O=!0;break}if(w.push(...Y.errors),y.abortEarly)return w;P=!0;break}}if(!P&&(f.$_terms._inclusions.length||f.$_terms._requireds.length)&&!O){if(Q){u.fastSplice(h,k),--k,--x;continue}if(w.push(b("array.includes",{pos:k,value:E},g.localize(I))),y.abortEarly)return w}}return _.length&&u.fillMissedErrors(f,w,_,h,g,y),C.length&&(u.fillOrderedErrors(f,w,C,h,g,y),w.length||u.fillDefault(C,h,g,y)),w.length?w:h},priority:!0,manifest:!1},length:{method(h){return this.$_addRule({name:"length",args:{limit:h},operator:"="})},validate:(h,f,{limit:b},{name:g,operator:y,args:v})=>l.compare(h.length,b,y)?h:f.error("array."+g,{limit:v.limit,value:h}),args:[{name:"limit",ref:!0,assert:l.limit,message:"must be a positive integer"}]},max:{method(h){return this.$_addRule({name:"max",method:"length",args:{limit:h},operator:"<="})}},min:{method(h){return this.$_addRule({name:"min",method:"length",args:{limit:h},operator:">="})}},ordered:{method(...h){l.verifyFlat(h,"ordered");const f=this.$_addRule("items");for(let b=0;b<h.length;++b){const g=l.tryWithPath(()=>this.$_compile(h[b]),b,{append:!0});u.validateSingle(g,f),f.$_mutateRegister(g),f.$_terms.ordered.push(g)}return f.$_mutateRebuild()}},single:{method(h){const f=h===void 0||!!h;return a(!f||!this._flags._arrayItems,"Cannot specify single rule when array has array items"),this.$_setFlag("single",f)}},sort:{method(h={}){l.assertOptions(h,["by","order"]);const f={order:h.order||"ascending"};return h.by&&(f.by=c.ref(h.by,{ancestor:0}),a(!f.by.ancestor,"Cannot sort by ancestor")),this.$_addRule({name:"sort",args:{options:f}})},validate(h,{error:f,state:b,prefs:g,schema:y},{options:v}){const{value:_,errors:C}=u.sort(y,h,v,b,g);if(C)return C;for(let S=0;S<h.length;++S)if(h[S]!==_[S])return f("array.sort",{order:v.order,by:v.by?v.by.key:"value"});return h},convert:!0},sparse:{method(h){const f=h===void 0||!!h;return this._flags.sparse===f?this:(f?this.clone():this.$_addRule("items")).$_setFlag("sparse",f,{clone:!1})}},unique:{method(h,f={}){a(!h||typeof h=="function"||typeof h=="string","comparator must be a function or a string"),l.assertOptions(f,["ignoreUndefined","separator"]);const b={name:"unique",args:{options:f,comparator:h}};if(h)if(typeof h=="string"){const g=l.default(f.separator,".");b.path=g?h.split(g):[h]}else b.comparator=h;return this.$_addRule(b)},validate(h,{state:f,error:b,schema:g},{comparator:y,options:v},{comparator:_,path:C}){const S={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),bigint:Object.create(null),object:new Map,function:new Map,custom:new Map},T=_||p,w=v.ignoreUndefined;for(let x=0;x<h.length;++x){const k=C?m(h[x],C):h[x],E=_?S.custom:S[typeof k];if(a(E,"Failed to find unique map container for type",typeof k),E instanceof Map){const P=E.entries();let O;for(;!(O=P.next()).done;)if(T(O.value[0],k)){const z=f.localize([...f.path,x],[h,...f.ancestors]),I={pos:x,value:h[x],dupePos:O.value[1],dupeValue:h[O.value[1]]};return C&&(I.path=y),b("array.unique",I,z)}E.set(k,x)}else{if((!w||k!==void 0)&&E[k]!==void 0){const P={pos:x,value:h[x],dupePos:E[k],dupeValue:h[E[k]]};return C&&(P.path=y),b("array.unique",P,f.localize([...f.path,x],[h,...f.ancestors]))}E[k]=x}}return h},args:["comparator","options"],multi:!0}},cast:{set:{from:Array.isArray,to:(h,f)=>new Set(h)}},rebuild(h){h.$_terms._inclusions=[],h.$_terms._exclusions=[],h.$_terms._requireds=[];for(const f of h.$_terms.items)u.validateSingle(f,h),f._flags.presence==="required"?h.$_terms._requireds.push(f):f._flags.presence==="forbidden"?h.$_terms._exclusions.push(f):h.$_terms._inclusions.push(f);for(const f of h.$_terms.ordered)u.validateSingle(f,h)},manifest:{build:(h,f)=>(f.items&&(h=h.items(...f.items)),f.ordered&&(h=h.ordered(...f.ordered)),h)},messages:{"array.base":"{{#label}} must be an array","array.excludes":"{{#label}} contains an excluded value","array.hasKnown":"{{#label}} does not contain at least one required match for type {:#patternLabel}","array.hasUnknown":"{{#label}} does not contain at least one required match","array.includes":"{{#label}} does not match any of the allowed types","array.includesRequiredBoth":"{{#label}} does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)","array.includesRequiredKnowns":"{{#label}} does not contain {{#knownMisses}}","array.includesRequiredUnknowns":"{{#label}} does not contain {{#unknownMisses}} required value(s)","array.length":"{{#label}} must contain {{#limit}} items","array.max":"{{#label}} must contain less than or equal to {{#limit}} items","array.min":"{{#label}} must contain at least {{#limit}} items","array.orderedLength":"{{#label}} must contain at most {{#limit}} items","array.sort":"{{#label}} must be sorted in {#order} order by {{#by}}","array.sort.mismatching":"{{#label}} cannot be sorted due to mismatching types","array.sort.unsupported":"{{#label}} cannot be sorted due to unsupported type {#type}","array.sparse":"{{#label}} must not be a sparse array item","array.unique":"{{#label}} contains a duplicate value"}}),u.fillMissedErrors=function(h,f,b,g,y,v){const _=[];let C=0;for(const S of b){const T=S._flags.label;T?_.push(T):++C}_.length?C?f.push(h.$_createError("array.includesRequiredBoth",g,{knownMisses:_,unknownMisses:C},y,v)):f.push(h.$_createError("array.includesRequiredKnowns",g,{knownMisses:_},y,v)):f.push(h.$_createError("array.includesRequiredUnknowns",g,{unknownMisses:C},y,v))},u.fillOrderedErrors=function(h,f,b,g,y,v){const _=[];for(const C of b)C._flags.presence==="required"&&_.push(C);_.length&&u.fillMissedErrors(h,f,_,g,y,v)},u.fillDefault=function(h,f,b,g){const y=[];let v=!0;for(let _=h.length-1;_>=0;--_){const C=h[_],S=[f,...b.ancestors],T=C.$_validate(void 0,b.localize(b.path,S,C),g).value;if(v){if(T===void 0)continue;v=!1}y.unshift(T)}y.length&&f.push(...y)},u.fastSplice=function(h,f){let b=f;for(;b<h.length;)h[b++]=h[b];--h.length},u.validateSingle=function(h,f){(h.type==="array"||h._flags._arrayItems)&&(a(!f._flags.single,"Cannot specify array item with single rule enabled"),f.$_setFlag("_arrayItems",!0,{clone:!1}))},u.sort=function(h,f,b,g,y){const v=b.order==="ascending"?1:-1,_=-1*v,C=v,S=(T,w)=>{let x=u.compare(T,w,_,C);if(x!==null||(b.by&&(T=b.by.resolve(T,g,y),w=b.by.resolve(w,g,y)),x=u.compare(T,w,_,C),x!==null))return x;const k=typeof T;if(k!==typeof w)throw h.$_createError("array.sort.mismatching",f,null,g,y);if(k!=="number"&&k!=="string")throw h.$_createError("array.sort.unsupported",f,{type:k},g,y);return k==="number"?(T-w)*v:T<w?_:C};try{return{value:f.slice().sort(S)}}catch(T){return{errors:T}}},u.compare=function(h,f,b,g){return h===f?0:h===void 0?1:f===void 0?-1:h===null?g:f===null?b:null}},4937:(r,n,o)=>{const a=o(375),p=o(8068),m=o(8160),d=o(2036),l={isBool:function(c){return typeof c=="boolean"}};r.exports=p.extend({type:"boolean",flags:{sensitive:{default:!1}},terms:{falsy:{init:null,manifest:"values"},truthy:{init:null,manifest:"values"}},coerce(c,{schema:u}){if(typeof c!="boolean"){if(typeof c=="string"){const h=u._flags.sensitive?c:c.toLowerCase();c=h==="true"||h!=="false"&&c}return typeof c!="boolean"&&(c=u.$_terms.truthy&&u.$_terms.truthy.has(c,null,null,!u._flags.sensitive)||(!u.$_terms.falsy||!u.$_terms.falsy.has(c,null,null,!u._flags.sensitive))&&c),{value:c}}},validate(c,{error:u}){if(typeof c!="boolean")return{value:c,errors:u("boolean.base")}},rules:{truthy:{method(...c){m.verifyFlat(c,"truthy");const u=this.clone();u.$_terms.truthy=u.$_terms.truthy||new d;for(let h=0;h<c.length;++h){const f=c[h];a(f!==void 0,"Cannot call truthy with undefined"),u.$_terms.truthy.add(f)}return u}},falsy:{method(...c){m.verifyFlat(c,"falsy");const u=this.clone();u.$_terms.falsy=u.$_terms.falsy||new d;for(let h=0;h<c.length;++h){const f=c[h];a(f!==void 0,"Cannot call falsy with undefined"),u.$_terms.falsy.add(f)}return u}},sensitive:{method(c=!0){return this.$_setFlag("sensitive",c)}}},cast:{number:{from:l.isBool,to:(c,u)=>c?1:0},string:{from:l.isBool,to:(c,u)=>c?"true":"false"}},manifest:{build:(c,u)=>(u.truthy&&(c=c.truthy(...u.truthy)),u.falsy&&(c=c.falsy(...u.falsy)),c)},messages:{"boolean.base":"{{#label}} must be a boolean"}})},7500:(r,n,o)=>{const a=o(375),p=o(8068),m=o(8160),d=o(3328),l={isDate:function(c){return c instanceof Date}};r.exports=p.extend({type:"date",coerce:{from:["number","string"],method:(c,{schema:u})=>({value:l.parse(c,u._flags.format)||c})},validate(c,{schema:u,error:h,prefs:f}){if(c instanceof Date&&!isNaN(c.getTime()))return;const b=u._flags.format;return f.convert&&b&&typeof c=="string"?{value:c,errors:h("date.format",{format:b})}:{value:c,errors:h("date.base")}},rules:{compare:{method:!1,validate(c,u,{date:h},{name:f,operator:b,args:g}){const y=h==="now"?Date.now():h.getTime();return m.compare(c.getTime(),y,b)?c:u.error("date."+f,{limit:g.date,value:c})},args:[{name:"date",ref:!0,normalize:c=>c==="now"?c:l.parse(c),assert:c=>c!==null,message:"must have a valid date format"}]},format:{method(c){return a(["iso","javascript","unix"].includes(c),"Unknown date format",c),this.$_setFlag("format",c)}},greater:{method(c){return this.$_addRule({name:"greater",method:"compare",args:{date:c},operator:">"})}},iso:{method(){return this.format("iso")}},less:{method(c){return this.$_addRule({name:"less",method:"compare",args:{date:c},operator:"<"})}},max:{method(c){return this.$_addRule({name:"max",method:"compare",args:{date:c},operator:"<="})}},min:{method(c){return this.$_addRule({name:"min",method:"compare",args:{date:c},operator:">="})}},timestamp:{method(c="javascript"){return a(["javascript","unix"].includes(c),'"type" must be one of "javascript, unix"'),this.format(c)}}},cast:{number:{from:l.isDate,to:(c,u)=>c.getTime()},string:{from:l.isDate,to:(c,{prefs:u})=>d.date(c,u)}},messages:{"date.base":"{{#label}} must be a valid date","date.format":'{{#label}} must be in {msg("date.format." + #format) || #format} format',"date.greater":"{{#label}} must be greater than {{:#limit}}","date.less":"{{#label}} must be less than {{:#limit}}","date.max":"{{#label}} must be less than or equal to {{:#limit}}","date.min":"{{#label}} must be greater than or equal to {{:#limit}}","date.format.iso":"ISO 8601 date","date.format.javascript":"timestamp or number of milliseconds","date.format.unix":"timestamp or number of seconds"}}),l.parse=function(c,u){if(c instanceof Date)return c;if(typeof c!="string"&&(isNaN(c)||!isFinite(c))||/^\s*$/.test(c))return null;if(u==="iso")return m.isIsoDate(c)?l.date(c.toString()):null;const h=c;if(typeof c=="string"&&/^[+-]?\d+(\.\d+)?$/.test(c)&&(c=parseFloat(c)),u){if(u==="javascript")return l.date(1*c);if(u==="unix")return l.date(1e3*c);if(typeof h=="string")return null}return l.date(c)},l.date=function(c){const u=new Date(c);return isNaN(u.getTime())?null:u}},390:(r,n,o)=>{const a=o(375),p=o(7824);r.exports=p.extend({type:"function",properties:{typeof:"function"},rules:{arity:{method(m){return a(Number.isSafeInteger(m)&&m>=0,"n must be a positive integer"),this.$_addRule({name:"arity",args:{n:m}})},validate:(m,d,{n:l})=>m.length===l?m:d.error("function.arity",{n:l})},class:{method(){return this.$_addRule("class")},validate:(m,d)=>/^\s*class\s/.test(m.toString())?m:d.error("function.class",{value:m})},minArity:{method(m){return a(Number.isSafeInteger(m)&&m>0,"n must be a strict positive integer"),this.$_addRule({name:"minArity",args:{n:m}})},validate:(m,d,{n:l})=>m.length>=l?m:d.error("function.minArity",{n:l})},maxArity:{method(m){return a(Number.isSafeInteger(m)&&m>=0,"n must be a positive integer"),this.$_addRule({name:"maxArity",args:{n:m}})},validate:(m,d,{n:l})=>m.length<=l?m:d.error("function.maxArity",{n:l})}},messages:{"function.arity":"{{#label}} must have an arity of {{#n}}","function.class":"{{#label}} must be a class","function.maxArity":"{{#label}} must have an arity lesser or equal to {{#n}}","function.minArity":"{{#label}} must have an arity greater or equal to {{#n}}"}})},7824:(r,n,o)=>{const a=o(978),p=o(375),m=o(8571),d=o(3652),l=o(8068),c=o(8160),u=o(3292),h=o(6354),f=o(6133),b=o(3328),g={renameDefaults:{alias:!1,multiple:!1,override:!1}};r.exports=l.extend({type:"_keys",properties:{typeof:"object"},flags:{unknown:{default:void 0}},terms:{dependencies:{init:null},keys:{init:null,manifest:{mapped:{from:"schema",to:"key"}}},patterns:{init:null},renames:{init:null}},args:(y,v)=>y.keys(v),validate(y,{schema:v,error:_,state:C,prefs:S}){if(!y||typeof y!==v.$_property("typeof")||Array.isArray(y))return{value:y,errors:_("object.base",{type:v.$_property("typeof")})};if(!(v.$_terms.renames||v.$_terms.dependencies||v.$_terms.keys||v.$_terms.patterns||v.$_terms.externals))return;y=g.clone(y,S);const T=[];if(v.$_terms.renames&&!g.rename(v,y,C,S,T))return{value:y,errors:T};if(!v.$_terms.keys&&!v.$_terms.patterns&&!v.$_terms.dependencies)return{value:y,errors:T};const w=new Set(Object.keys(y));if(v.$_terms.keys){const x=[y,...C.ancestors];for(const k of v.$_terms.keys){const E=k.key,P=y[E];w.delete(E);const O=C.localize([...C.path,E],x,k),z=k.schema.$_validate(P,O,S);if(z.errors){if(S.abortEarly)return{value:y,errors:z.errors};z.value!==void 0&&(y[E]=z.value),T.push(...z.errors)}else k.schema._flags.result==="strip"||z.value===void 0&&P!==void 0?delete y[E]:z.value!==void 0&&(y[E]=z.value)}}if(w.size||v._flags._hasPatternMatch){const x=g.unknown(v,y,w,T,C,S);if(x)return x}if(v.$_terms.dependencies)for(const x of v.$_terms.dependencies){if(x.key!==null&&g.isPresent(x.options)(x.key.resolve(y,C,S,null,{shadow:!1}))===!1)continue;const k=g.dependencies[x.rel](v,x,y,C,S);if(k){const E=v.$_createError(k.code,y,k.context,C,S);if(S.abortEarly)return{value:y,errors:E};T.push(E)}}return{value:y,errors:T}},rules:{and:{method(...y){return c.verifyFlat(y,"and"),g.dependency(this,"and",null,y)}},append:{method(y){return y==null||Object.keys(y).length===0?this:this.keys(y)}},assert:{method(y,v,_){b.isTemplate(y)||(y=u.ref(y)),p(_===void 0||typeof _=="string","Message must be a string"),v=this.$_compile(v,{appendPath:!0});const C=this.$_addRule({name:"assert",args:{subject:y,schema:v,message:_}});return C.$_mutateRegister(y),C.$_mutateRegister(v),C},validate(y,{error:v,prefs:_,state:C},{subject:S,schema:T,message:w}){const x=S.resolve(y,C,_),k=f.isRef(S)?S.absolute(C):[];return T.$_match(x,C.localize(k,[y,...C.ancestors],T),_)?y:v("object.assert",{subject:S,message:w})},args:["subject","schema","message"],multi:!0},instance:{method(y,v){return p(typeof y=="function","constructor must be a function"),v=v||y.name,this.$_addRule({name:"instance",args:{constructor:y,name:v}})},validate:(y,v,{constructor:_,name:C})=>y instanceof _?y:v.error("object.instance",{type:C,value:y}),args:["constructor","name"]},keys:{method(y){p(y===void 0||typeof y=="object","Object schema must be a valid object"),p(!c.isSchema(y),"Object schema cannot be a joi schema");const v=this.clone();if(y)if(Object.keys(y).length){v.$_terms.keys=v.$_terms.keys?v.$_terms.keys.filter(_=>!y.hasOwnProperty(_.key)):new g.Keys;for(const _ in y)c.tryWithPath(()=>v.$_terms.keys.push({key:_,schema:this.$_compile(y[_])}),_)}else v.$_terms.keys=new g.Keys;else v.$_terms.keys=null;return v.$_mutateRebuild()}},length:{method(y){return this.$_addRule({name:"length",args:{limit:y},operator:"="})},validate:(y,v,{limit:_},{name:C,operator:S,args:T})=>c.compare(Object.keys(y).length,_,S)?y:v.error("object."+C,{limit:T.limit,value:y}),args:[{name:"limit",ref:!0,assert:c.limit,message:"must be a positive integer"}]},max:{method(y){return this.$_addRule({name:"max",method:"length",args:{limit:y},operator:"<="})}},min:{method(y){return this.$_addRule({name:"min",method:"length",args:{limit:y},operator:">="})}},nand:{method(...y){return c.verifyFlat(y,"nand"),g.dependency(this,"nand",null,y)}},or:{method(...y){return c.verifyFlat(y,"or"),g.dependency(this,"or",null,y)}},oxor:{method(...y){return g.dependency(this,"oxor",null,y)}},pattern:{method(y,v,_={}){const C=y instanceof RegExp;C||(y=this.$_compile(y,{appendPath:!0})),p(v!==void 0,"Invalid rule"),c.assertOptions(_,["fallthrough","matches"]),C&&p(!y.flags.includes("g")&&!y.flags.includes("y"),"pattern should not use global or sticky mode"),v=this.$_compile(v,{appendPath:!0});const S=this.clone();S.$_terms.patterns=S.$_terms.patterns||[];const T={[C?"regex":"schema"]:y,rule:v};return _.matches&&(T.matches=this.$_compile(_.matches),T.matches.type!=="array"&&(T.matches=T.matches.$_root.array().items(T.matches)),S.$_mutateRegister(T.matches),S.$_setFlag("_hasPatternMatch",!0,{clone:!1})),_.fallthrough&&(T.fallthrough=!0),S.$_terms.patterns.push(T),S.$_mutateRegister(v),S}},ref:{method(){return this.$_addRule("ref")},validate:(y,v)=>f.isRef(y)?y:v.error("object.refType",{value:y})},regex:{method(){return this.$_addRule("regex")},validate:(y,v)=>y instanceof RegExp?y:v.error("object.regex",{value:y})},rename:{method(y,v,_={}){p(typeof y=="string"||y instanceof RegExp,"Rename missing the from argument"),p(typeof v=="string"||v instanceof b,"Invalid rename to argument"),p(v!==y,"Cannot rename key to same name:",y),c.assertOptions(_,["alias","ignoreUndefined","override","multiple"]);const C=this.clone();C.$_terms.renames=C.$_terms.renames||[];for(const S of C.$_terms.renames)p(S.from!==y,"Cannot rename the same key multiple times");return v instanceof b&&C.$_mutateRegister(v),C.$_terms.renames.push({from:y,to:v,options:a(g.renameDefaults,_)}),C}},schema:{method(y="any"){return this.$_addRule({name:"schema",args:{type:y}})},validate:(y,v,{type:_})=>!c.isSchema(y)||_!=="any"&&y.type!==_?v.error("object.schema",{type:_}):y},unknown:{method(y){return this.$_setFlag("unknown",y!==!1)}},with:{method(y,v,_={}){return g.dependency(this,"with",y,v,_)}},without:{method(y,v,_={}){return g.dependency(this,"without",y,v,_)}},xor:{method(...y){return c.verifyFlat(y,"xor"),g.dependency(this,"xor",null,y)}}},overrides:{default(y,v){return y===void 0&&(y=c.symbols.deepDefault),this.$_parent("default",y,v)}},rebuild(y){if(y.$_terms.keys){const v=new d.Sorter;for(const _ of y.$_terms.keys)c.tryWithPath(()=>v.add(_,{after:_.schema.$_rootReferences(),group:_.key}),_.key);y.$_terms.keys=new g.Keys(...v.nodes)}},manifest:{build(y,v){if(v.keys&&(y=y.keys(v.keys)),v.dependencies)for(const{rel:_,key:C=null,peers:S,options:T}of v.dependencies)y=g.dependency(y,_,C,S,T);if(v.patterns)for(const{regex:_,schema:C,rule:S,fallthrough:T,matches:w}of v.patterns)y=y.pattern(_||C,S,{fallthrough:T,matches:w});if(v.renames)for(const{from:_,to:C,options:S}of v.renames)y=y.rename(_,C,S);return y}},messages:{"object.and":"{{#label}} contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}","object.assert":'{{#label}} is invalid because {if(#subject.key, `"` + #subject.key + `" failed to ` + (#message || "pass the assertion test"), #message || "the assertion failed")}',"object.base":"{{#label}} must be of type {{#type}}","object.instance":"{{#label}} must be an instance of {{:#type}}","object.length":'{{#label}} must have {{#limit}} key{if(#limit == 1, "", "s")}',"object.max":'{{#label}} must have less than or equal to {{#limit}} key{if(#limit == 1, "", "s")}',"object.min":'{{#label}} must have at least {{#limit}} key{if(#limit == 1, "", "s")}',"object.missing":"{{#label}} must contain at least one of {{#peersWithLabels}}","object.nand":"{{:#mainWithLabel}} must not exist simultaneously with {{#peersWithLabels}}","object.oxor":"{{#label}} contains a conflict between optional exclusive peers {{#peersWithLabels}}","object.pattern.match":"{{#label}} keys failed to match pattern requirements","object.refType":"{{#label}} must be a Joi reference","object.regex":"{{#label}} must be a RegExp object","object.rename.multiple":"{{#label}} cannot rename {{:#from}} because multiple renames are disabled and another key was already renamed to {{:#to}}","object.rename.override":"{{#label}} cannot rename {{:#from}} because override is disabled and target {{:#to}} exists","object.schema":"{{#label}} must be a Joi schema of {{#type}} type","object.unknown":"{{#label}} is not allowed","object.with":"{{:#mainWithLabel}} missing required peer {{:#peerWithLabel}}","object.without":"{{:#mainWithLabel}} conflict with forbidden peer {{:#peerWithLabel}}","object.xor":"{{#label}} contains a conflict between exclusive peers {{#peersWithLabels}}"}}),g.clone=function(y,v){if(typeof y=="object"){if(v.nonEnumerables)return m(y,{shallow:!0});const C=Object.create(Object.getPrototypeOf(y));return Object.assign(C,y),C}const _=function(...C){return y.apply(this,C)};return _.prototype=m(y.prototype),Object.defineProperty(_,"name",{value:y.name,writable:!1}),Object.defineProperty(_,"length",{value:y.length,writable:!1}),Object.assign(_,y),_},g.dependency=function(y,v,_,C,S){p(_===null||typeof _=="string",v,"key must be a strings"),S||(S=C.length>1&&typeof C[C.length-1]=="object"?C.pop():{}),c.assertOptions(S,["separator","isPresent"]),C=[].concat(C);const T=c.default(S.separator,"."),w=[];for(const k of C)p(typeof k=="string",v,"peers must be strings"),w.push(u.ref(k,{separator:T,ancestor:0,prefix:!1}));_!==null&&(_=u.ref(_,{separator:T,ancestor:0,prefix:!1}));const x=y.clone();return x.$_terms.dependencies=x.$_terms.dependencies||[],x.$_terms.dependencies.push(new g.Dependency(v,_,w,C,S)),x},g.dependencies={and(y,v,_,C,S){const T=[],w=[],x=v.peers.length,k=g.isPresent(v.options);for(const E of v.peers)k(E.resolve(_,C,S,null,{shadow:!1}))===!1?T.push(E.key):w.push(E.key);if(T.length!==x&&w.length!==x)return{code:"object.and",context:{present:w,presentWithLabels:g.keysToLabels(y,w),missing:T,missingWithLabels:g.keysToLabels(y,T)}}},nand(y,v,_,C,S){const T=[],w=g.isPresent(v.options);for(const E of v.peers)w(E.resolve(_,C,S,null,{shadow:!1}))&&T.push(E.key);if(T.length!==v.peers.length)return;const x=v.paths[0],k=v.paths.slice(1);return{code:"object.nand",context:{main:x,mainWithLabel:g.keysToLabels(y,x),peers:k,peersWithLabels:g.keysToLabels(y,k)}}},or(y,v,_,C,S){const T=g.isPresent(v.options);for(const w of v.peers)if(T(w.resolve(_,C,S,null,{shadow:!1})))return;return{code:"object.missing",context:{peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)}}},oxor(y,v,_,C,S){const T=[],w=g.isPresent(v.options);for(const k of v.peers)w(k.resolve(_,C,S,null,{shadow:!1}))&&T.push(k.key);if(!T.length||T.length===1)return;const x={peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)};return x.present=T,x.presentWithLabels=g.keysToLabels(y,T),{code:"object.oxor",context:x}},with(y,v,_,C,S){const T=g.isPresent(v.options);for(const w of v.peers)if(T(w.resolve(_,C,S,null,{shadow:!1}))===!1)return{code:"object.with",context:{main:v.key.key,mainWithLabel:g.keysToLabels(y,v.key.key),peer:w.key,peerWithLabel:g.keysToLabels(y,w.key)}}},without(y,v,_,C,S){const T=g.isPresent(v.options);for(const w of v.peers)if(T(w.resolve(_,C,S,null,{shadow:!1})))return{code:"object.without",context:{main:v.key.key,mainWithLabel:g.keysToLabels(y,v.key.key),peer:w.key,peerWithLabel:g.keysToLabels(y,w.key)}}},xor(y,v,_,C,S){const T=[],w=g.isPresent(v.options);for(const k of v.peers)w(k.resolve(_,C,S,null,{shadow:!1}))&&T.push(k.key);if(T.length===1)return;const x={peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)};return T.length===0?{code:"object.missing",context:x}:(x.present=T,x.presentWithLabels=g.keysToLabels(y,T),{code:"object.xor",context:x})}},g.keysToLabels=function(y,v){return Array.isArray(v)?v.map(_=>y.$_mapLabels(_)):y.$_mapLabels(v)},g.isPresent=function(y){return typeof y.isPresent=="function"?y.isPresent:v=>v!==void 0},g.rename=function(y,v,_,C,S){const T={};for(const w of y.$_terms.renames){const x=[],k=typeof w.from!="string";if(k)for(const E in v){if(v[E]===void 0&&w.options.ignoreUndefined||E===w.to)continue;const P=w.from.exec(E);P&&x.push({from:E,to:w.to,match:P})}else!Object.prototype.hasOwnProperty.call(v,w.from)||v[w.from]===void 0&&w.options.ignoreUndefined||x.push(w);for(const E of x){const P=E.from;let O=E.to;if(O instanceof b&&(O=O.render(v,_,C,E.match)),P!==O){if(!w.options.multiple&&T[O]&&(S.push(y.$_createError("object.rename.multiple",v,{from:P,to:O,pattern:k},_,C)),C.abortEarly)||Object.prototype.hasOwnProperty.call(v,O)&&!w.options.override&&!T[O]&&(S.push(y.$_createError("object.rename.override",v,{from:P,to:O,pattern:k},_,C)),C.abortEarly))return!1;v[P]===void 0?delete v[O]:v[O]=v[P],T[O]=!0,w.options.alias||delete v[P]}}}return!0},g.unknown=function(y,v,_,C,S,T){if(y.$_terms.patterns){let w=!1;const x=y.$_terms.patterns.map(E=>{if(E.matches)return w=!0,[]}),k=[v,...S.ancestors];for(const E of _){const P=v[E],O=[...S.path,E];for(let z=0;z<y.$_terms.patterns.length;++z){const I=y.$_terms.patterns[z];if(I.regex){const Z=I.regex.test(E);if(S.mainstay.tracer.debug(S,"rule",`pattern.${z}`,Z?"pass":"error"),!Z)continue}else if(!I.schema.$_match(E,S.nest(I.schema,`pattern.${z}`),T))continue;_.delete(E);const L=S.localize(O,k,{schema:I.rule,key:E}),F=I.rule.$_validate(P,L,T);if(F.errors){if(T.abortEarly)return{value:v,errors:F.errors};C.push(...F.errors)}if(I.matches&&x[z].push(E),v[E]=F.value,!I.fallthrough)break}}if(w)for(let E=0;E<x.length;++E){const P=x[E];if(!P)continue;const O=y.$_terms.patterns[E].matches,z=S.localize(S.path,k,O),I=O.$_validate(P,z,T);if(I.errors){const L=h.details(I.errors,{override:!1});L.matches=P;const F=y.$_createError("object.pattern.match",v,L,S,T);if(T.abortEarly)return{value:v,errors:F};C.push(F)}}}if(_.size&&(y.$_terms.keys||y.$_terms.patterns)){if(T.stripUnknown&&y._flags.unknown===void 0||T.skipFunctions){const w=!(!T.stripUnknown||T.stripUnknown!==!0&&!T.stripUnknown.objects);for(const x of _)w?(delete v[x],_.delete(x)):typeof v[x]=="function"&&_.delete(x)}if(!c.default(y._flags.unknown,T.allowUnknown))for(const w of _){const x=S.localize([...S.path,w],[]),k=y.$_createError("object.unknown",v[w],{child:w},x,T,{flags:!1});if(T.abortEarly)return{value:v,errors:k};C.push(k)}}},g.Dependency=class{constructor(y,v,_,C,S){this.rel=y,this.key=v,this.peers=_,this.paths=C,this.options=S}describe(){const y={rel:this.rel,peers:this.paths};return this.key!==null&&(y.key=this.key.key),this.peers[0].separator!=="."&&(y.options={...y.options,separator:this.peers[0].separator}),this.options.isPresent&&(y.options={...y.options,isPresent:this.options.isPresent}),y}},g.Keys=class extends Array{concat(y){const v=this.slice(),_=new Map;for(let C=0;C<v.length;++C)_.set(v[C].key,C);for(const C of y){const S=C.key,T=_.get(S);T!==void 0?v[T]={key:S,schema:v[T].schema.concat(C.schema)}:v.push(C)}return v}}},8785:(r,n,o)=>{const a=o(375),p=o(8068),m=o(8160),d=o(3292),l=o(6354),c={};r.exports=p.extend({type:"link",properties:{schemaChain:!0},terms:{link:{init:null,manifest:"single",register:!1}},args:(u,h)=>u.ref(h),validate(u,{schema:h,state:f,prefs:b}){a(h.$_terms.link,"Uninitialized link schema");const g=c.generate(h,u,f,b),y=h.$_terms.link[0].ref;return g.$_validate(u,f.nest(g,`link:${y.display}:${g.type}`),b)},generate:(u,h,f,b)=>c.generate(u,h,f,b),rules:{ref:{method(u){a(!this.$_terms.link,"Cannot reinitialize schema"),u=d.ref(u),a(u.type==="value"||u.type==="local","Invalid reference type:",u.type),a(u.type==="local"||u.ancestor==="root"||u.ancestor>0,"Link cannot reference itself");const h=this.clone();return h.$_terms.link=[{ref:u}],h}},relative:{method(u=!0){return this.$_setFlag("relative",u)}}},overrides:{concat(u){a(this.$_terms.link,"Uninitialized link schema"),a(m.isSchema(u),"Invalid schema object"),a(u.type!=="link","Cannot merge type link with another link");const h=this.clone();return h.$_terms.whens||(h.$_terms.whens=[]),h.$_terms.whens.push({concat:u}),h.$_mutateRebuild()}},manifest:{build:(u,h)=>(a(h.link,"Invalid link description missing link"),u.ref(h.link))}}),c.generate=function(u,h,f,b){let g=f.mainstay.links.get(u);if(g)return g._generate(h,f,b).schema;const y=u.$_terms.link[0].ref,{perspective:v,path:_}=c.perspective(y,f);c.assert(v,"which is outside of schema boundaries",y,u,f,b);try{g=_.length?v.$_reach(_):v}catch{c.assert(!1,"to non-existing schema",y,u,f,b)}return c.assert(g.type!=="link","which is another link",y,u,f,b),u._flags.relative||f.mainstay.links.set(u,g),g._generate(h,f,b).schema},c.perspective=function(u,h){if(u.type==="local"){for(const{schema:f,key:b}of h.schemas){if((f._flags.id||b)===u.path[0])return{perspective:f,path:u.path.slice(1)};if(f.$_terms.shared){for(const g of f.$_terms.shared)if(g._flags.id===u.path[0])return{perspective:g,path:u.path.slice(1)}}}return{perspective:null,path:null}}return u.ancestor==="root"?{perspective:h.schemas[h.schemas.length-1].schema,path:u.path}:{perspective:h.schemas[u.ancestor]&&h.schemas[u.ancestor].schema,path:u.path}},c.assert=function(u,h,f,b,g,y){u||a(!1,`"${l.label(b._flags,g,y)}" contains link reference "${f.display}" ${h}`)}},3832:(r,n,o)=>{const a=o(375),p=o(8068),m=o(8160),d={numberRx:/^\s*[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:e([+-]?\d+))?\s*$/i,precisionRx:/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,exponentialPartRegex:/[eE][+-]?\d+$/,leadingSignAndZerosRegex:/^[+-]?(0*)?/,dotRegex:/\./,trailingZerosRegex:/0+$/,decimalPlaces(l){const c=l.toString(),u=c.indexOf("."),h=c.indexOf("e");return(u<0?0:(h<0?c.length:h)-u-1)+(h<0?0:Math.max(0,-parseInt(c.slice(h+1))))}};r.exports=p.extend({type:"number",flags:{unsafe:{default:!1}},coerce:{from:"string",method(l,{schema:c,error:u}){if(!l.match(d.numberRx))return;l=l.trim();const h={value:parseFloat(l)};if(h.value===0&&(h.value=0),!c._flags.unsafe)if(l.match(/e/i)){if(d.extractSignificantDigits(l)!==d.extractSignificantDigits(String(h.value)))return h.errors=u("number.unsafe"),h}else{const f=h.value.toString();if(f.match(/e/i))return h;if(f!==d.normalizeDecimal(l))return h.errors=u("number.unsafe"),h}return h}},validate(l,{schema:c,error:u,prefs:h}){if(l===1/0||l===-1/0)return{value:l,errors:u("number.infinity")};if(!m.isNumber(l))return{value:l,errors:u("number.base")};const f={value:l};if(h.convert){const b=c.$_getRule("precision");if(b){const g=Math.pow(10,b.args.limit);f.value=Math.round(f.value*g)/g}}return f.value===0&&(f.value=0),!c._flags.unsafe&&(l>Number.MAX_SAFE_INTEGER||l<Number.MIN_SAFE_INTEGER)&&(f.errors=u("number.unsafe")),f},rules:{compare:{method:!1,validate:(l,c,{limit:u},{name:h,operator:f,args:b})=>m.compare(l,u,f)?l:c.error("number."+h,{limit:b.limit,value:l}),args:[{name:"limit",ref:!0,assert:m.isNumber,message:"must be a number"}]},greater:{method(l){return this.$_addRule({name:"greater",method:"compare",args:{limit:l},operator:">"})}},integer:{method(){return this.$_addRule("integer")},validate:(l,c)=>Math.trunc(l)-l==0?l:c.error("number.integer")},less:{method(l){return this.$_addRule({name:"less",method:"compare",args:{limit:l},operator:"<"})}},max:{method(l){return this.$_addRule({name:"max",method:"compare",args:{limit:l},operator:"<="})}},min:{method(l){return this.$_addRule({name:"min",method:"compare",args:{limit:l},operator:">="})}},multiple:{method(l){const c=typeof l=="number"?d.decimalPlaces(l):null,u=Math.pow(10,c);return this.$_addRule({name:"multiple",args:{base:l,baseDecimalPlace:c,pfactor:u}})},validate:(l,c,{base:u,baseDecimalPlace:h,pfactor:f},b)=>d.decimalPlaces(l)>h?c.error("number.multiple",{multiple:b.args.base,value:l}):Math.round(f*l)%Math.round(f*u)==0?l:c.error("number.multiple",{multiple:b.args.base,value:l}),args:[{name:"base",ref:!0,assert:l=>typeof l=="number"&&isFinite(l)&&l>0,message:"must be a positive number"},"baseDecimalPlace","pfactor"],multi:!0},negative:{method(){return this.sign("negative")}},port:{method(){return this.$_addRule("port")},validate:(l,c)=>Number.isSafeInteger(l)&&l>=0&&l<=65535?l:c.error("number.port")},positive:{method(){return this.sign("positive")}},precision:{method(l){return a(Number.isSafeInteger(l),"limit must be an integer"),this.$_addRule({name:"precision",args:{limit:l}})},validate(l,c,{limit:u}){const h=l.toString().match(d.precisionRx);return Math.max((h[1]?h[1].length:0)-(h[2]?parseInt(h[2],10):0),0)<=u?l:c.error("number.precision",{limit:u,value:l})},convert:!0},sign:{method(l){return a(["negative","positive"].includes(l),"Invalid sign",l),this.$_addRule({name:"sign",args:{sign:l}})},validate:(l,c,{sign:u})=>u==="negative"&&l<0||u==="positive"&&l>0?l:c.error(`number.${u}`)},unsafe:{method(l=!0){return a(typeof l=="boolean","enabled must be a boolean"),this.$_setFlag("unsafe",l)}}},cast:{string:{from:l=>typeof l=="number",to:(l,c)=>l.toString()}},messages:{"number.base":"{{#label}} must be a number","number.greater":"{{#label}} must be greater than {{#limit}}","number.infinity":"{{#label}} cannot be infinity","number.integer":"{{#label}} must be an integer","number.less":"{{#label}} must be less than {{#limit}}","number.max":"{{#label}} must be less than or equal to {{#limit}}","number.min":"{{#label}} must be greater than or equal to {{#limit}}","number.multiple":"{{#label}} must be a multiple of {{#multiple}}","number.negative":"{{#label}} must be a negative number","number.port":"{{#label}} must be a valid port","number.positive":"{{#label}} must be a positive number","number.precision":"{{#label}} must have no more than {{#limit}} decimal places","number.unsafe":"{{#label}} must be a safe number"}}),d.extractSignificantDigits=function(l){return l.replace(d.exponentialPartRegex,"").replace(d.dotRegex,"").replace(d.trailingZerosRegex,"").replace(d.leadingSignAndZerosRegex,"")},d.normalizeDecimal=function(l){return(l=l.replace(/^\+/,"").replace(/\.0*$/,"").replace(/^(-?)\.([^\.]*)$/,"$10.$2").replace(/^(-?)0+([0-9])/,"$1$2")).includes(".")&&l.endsWith("0")&&(l=l.replace(/0+$/,"")),l==="-0"?"0":l}},8966:(r,n,o)=>{const a=o(7824);r.exports=a.extend({type:"object",cast:{map:{from:p=>p&&typeof p=="object",to:(p,m)=>new Map(Object.entries(p))}}})},7417:(r,n,o)=>{const a=o(375),p=o(5380),m=o(1745),d=o(9959),l=o(6064),c=o(9926),u=o(5752),h=o(8068),f=o(8160),b={tlds:c instanceof Set&&{tlds:{allow:c,deny:null}},base64Regex:{true:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}==|[\w\-]{3}=)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/},false:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}(==)?|[\w\-]{3}=?)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/}},dataUriRegex:/^data:[\w+.-]+\/[\w+.-]+;((charset=[\w-]+|base64),)?(.*)$/,hexRegex:{withPrefix:/^0x[0-9a-f]+$/i,withOptionalPrefix:/^(?:0x)?[0-9a-f]+$/i,withoutPrefix:/^[0-9a-f]+$/i},ipRegex:d.regex({cidr:"forbidden"}).regex,isoDurationRegex:/^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/,guidBrackets:{"{":"}","[":"]","(":")","":""},guidVersions:{uuidv1:"1",uuidv2:"2",uuidv3:"3",uuidv4:"4",uuidv5:"5",uuidv6:"6",uuidv7:"7",uuidv8:"8"},guidSeparators:new Set([void 0,!0,!1,"-",":"]),normalizationForms:["NFC","NFD","NFKC","NFKD"]};r.exports=h.extend({type:"string",flags:{insensitive:{default:!1},truncate:{default:!1}},terms:{replacements:{init:null}},coerce:{from:"string",method(g,{schema:y,state:v,prefs:_}){const C=y.$_getRule("normalize");C&&(g=g.normalize(C.args.form));const S=y.$_getRule("case");S&&(g=S.args.direction==="upper"?g.toLocaleUpperCase():g.toLocaleLowerCase());const T=y.$_getRule("trim");if(T&&T.args.enabled&&(g=g.trim()),y.$_terms.replacements)for(const x of y.$_terms.replacements)g=g.replace(x.pattern,x.replacement);const w=y.$_getRule("hex");if(w&&w.args.options.byteAligned&&g.length%2!=0&&(g=`0${g}`),y.$_getRule("isoDate")){const x=b.isoDate(g);x&&(g=x)}if(y._flags.truncate){const x=y.$_getRule("max");if(x){let k=x.args.limit;if(f.isResolvable(k)&&(k=k.resolve(g,v,_),!f.limit(k)))return{value:g,errors:y.$_createError("any.ref",k,{ref:x.args.limit,arg:"limit",reason:"must be a positive integer"},v,_)};g=g.slice(0,k)}}return{value:g}}},validate(g,{schema:y,error:v}){if(typeof g!="string")return{value:g,errors:v("string.base")};if(g===""){const _=y.$_getRule("min");return _&&_.args.limit===0?void 0:{value:g,errors:v("string.empty")}}},rules:{alphanum:{method(){return this.$_addRule("alphanum")},validate:(g,y)=>/^[a-zA-Z0-9]+$/.test(g)?g:y.error("string.alphanum")},base64:{method(g={}){return f.assertOptions(g,["paddingRequired","urlSafe"]),g={urlSafe:!1,paddingRequired:!0,...g},a(typeof g.paddingRequired=="boolean","paddingRequired must be boolean"),a(typeof g.urlSafe=="boolean","urlSafe must be boolean"),this.$_addRule({name:"base64",args:{options:g}})},validate:(g,y,{options:v})=>b.base64Regex[v.paddingRequired][v.urlSafe].test(g)?g:y.error("string.base64")},case:{method(g){return a(["lower","upper"].includes(g),"Invalid case:",g),this.$_addRule({name:"case",args:{direction:g}})},validate:(g,y,{direction:v})=>v==="lower"&&g===g.toLocaleLowerCase()||v==="upper"&&g===g.toLocaleUpperCase()?g:y.error(`string.${v}case`),convert:!0},creditCard:{method(){return this.$_addRule("creditCard")},validate(g,y){let v=g.length,_=0,C=1;for(;v--;){const S=g.charAt(v)*C;_+=S-9*(S>9),C^=3}return _>0&&_%10==0?g:y.error("string.creditCard")}},dataUri:{method(g={}){return f.assertOptions(g,["paddingRequired"]),g={paddingRequired:!0,...g},a(typeof g.paddingRequired=="boolean","paddingRequired must be boolean"),this.$_addRule({name:"dataUri",args:{options:g}})},validate(g,y,{options:v}){const _=g.match(b.dataUriRegex);return _&&(!_[2]||_[2]!=="base64"||b.base64Regex[v.paddingRequired].false.test(_[3]))?g:y.error("string.dataUri")}},domain:{method(g){g&&f.assertOptions(g,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const y=b.addressOptions(g);return this.$_addRule({name:"domain",args:{options:g},address:y})},validate:(g,y,v,{address:_})=>p.isValid(g,_)?g:y.error("string.domain")},email:{method(g={}){f.assertOptions(g,["allowFullyQualified","allowUnicode","ignoreLength","maxDomainSegments","minDomainSegments","multiple","separator","tlds"]),a(g.multiple===void 0||typeof g.multiple=="boolean","multiple option must be an boolean");const y=b.addressOptions(g),v=new RegExp(`\\s*[${g.separator?l(g.separator):","}]\\s*`);return this.$_addRule({name:"email",args:{options:g},regex:v,address:y})},validate(g,y,{options:v},{regex:_,address:C}){const S=v.multiple?g.split(_):[g],T=[];for(const w of S)m.isValid(w,C)||T.push(w);return T.length?y.error("string.email",{value:g,invalids:T}):g}},guid:{alias:"uuid",method(g={}){f.assertOptions(g,["version","separator"]);let y="";if(g.version){const C=[].concat(g.version);a(C.length>=1,"version must have at least 1 valid version specified");const S=new Set;for(let T=0;T<C.length;++T){const w=C[T];a(typeof w=="string","version at position "+T+" must be a string");const x=b.guidVersions[w.toLowerCase()];a(x,"version at position "+T+" must be one of "+Object.keys(b.guidVersions).join(", ")),a(!S.has(x),"version at position "+T+" must not be a duplicate"),y+=x,S.add(x)}}a(b.guidSeparators.has(g.separator),'separator must be one of true, false, "-", or ":"');const v=g.separator===void 0?"[:-]?":g.separator===!0?"[:-]":g.separator===!1?"[]?":`\\${g.separator}`,_=new RegExp(`^([\\[{\\(]?)[0-9A-F]{8}(${v})[0-9A-F]{4}\\2?[${y||"0-9A-F"}][0-9A-F]{3}\\2?[${y?"89AB":"0-9A-F"}][0-9A-F]{3}\\2?[0-9A-F]{12}([\\]}\\)]?)$`,"i");return this.$_addRule({name:"guid",args:{options:g},regex:_})},validate(g,y,v,{regex:_}){const C=_.exec(g);return C?b.guidBrackets[C[1]]!==C[C.length-1]?y.error("string.guid"):g:y.error("string.guid")}},hex:{method(g={}){return f.assertOptions(g,["byteAligned","prefix"]),g={byteAligned:!1,prefix:!1,...g},a(typeof g.byteAligned=="boolean","byteAligned must be boolean"),a(typeof g.prefix=="boolean"||g.prefix==="optional",'prefix must be boolean or "optional"'),this.$_addRule({name:"hex",args:{options:g}})},validate:(g,y,{options:v})=>(v.prefix==="optional"?b.hexRegex.withOptionalPrefix:v.prefix===!0?b.hexRegex.withPrefix:b.hexRegex.withoutPrefix).test(g)?v.byteAligned&&g.length%2!=0?y.error("string.hexAlign"):g:y.error("string.hex")},hostname:{method(){return this.$_addRule("hostname")},validate:(g,y)=>p.isValid(g,{minDomainSegments:1})||b.ipRegex.test(g)?g:y.error("string.hostname")},insensitive:{method(){return this.$_setFlag("insensitive",!0)}},ip:{method(g={}){f.assertOptions(g,["cidr","version"]);const{cidr:y,versions:v,regex:_}=d.regex(g),C=g.version?v:void 0;return this.$_addRule({name:"ip",args:{options:{cidr:y,version:C}},regex:_})},validate:(g,y,{options:v},{regex:_})=>_.test(g)?g:v.version?y.error("string.ipVersion",{value:g,cidr:v.cidr,version:v.version}):y.error("string.ip",{value:g,cidr:v.cidr})},isoDate:{method(){return this.$_addRule("isoDate")},validate:(g,{error:y})=>b.isoDate(g)?g:y("string.isoDate")},isoDuration:{method(){return this.$_addRule("isoDuration")},validate:(g,y)=>b.isoDurationRegex.test(g)?g:y.error("string.isoDuration")},length:{method(g,y){return b.length(this,"length",g,"=",y)},validate(g,y,{limit:v,encoding:_},{name:C,operator:S,args:T}){const w=!_&&g.length;return f.compare(w,v,S)?g:y.error("string."+C,{limit:T.limit,value:g,encoding:_})},args:[{name:"limit",ref:!0,assert:f.limit,message:"must be a positive integer"},"encoding"]},lowercase:{method(){return this.case("lower")}},max:{method(g,y){return b.length(this,"max",g,"<=",y)},args:["limit","encoding"]},min:{method(g,y){return b.length(this,"min",g,">=",y)},args:["limit","encoding"]},normalize:{method(g="NFC"){return a(b.normalizationForms.includes(g),"normalization form must be one of "+b.normalizationForms.join(", ")),this.$_addRule({name:"normalize",args:{form:g}})},validate:(g,{error:y},{form:v})=>g===g.normalize(v)?g:y("string.normalize",{value:g,form:v}),convert:!0},pattern:{alias:"regex",method(g,y={}){a(g instanceof RegExp,"regex must be a RegExp"),a(!g.flags.includes("g")&&!g.flags.includes("y"),"regex should not use global or sticky mode"),typeof y=="string"&&(y={name:y}),f.assertOptions(y,["invert","name"]);const v=["string.pattern",y.invert?".invert":"",y.name?".name":".base"].join("");return this.$_addRule({name:"pattern",args:{regex:g,options:y},errorCode:v})},validate:(g,y,{regex:v,options:_},{errorCode:C})=>v.test(g)^_.invert?g:y.error(C,{name:_.name,regex:v,value:g}),args:["regex","options"],multi:!0},replace:{method(g,y){typeof g=="string"&&(g=new RegExp(l(g),"g")),a(g instanceof RegExp,"pattern must be a RegExp"),a(typeof y=="string","replacement must be a String");const v=this.clone();return v.$_terms.replacements||(v.$_terms.replacements=[]),v.$_terms.replacements.push({pattern:g,replacement:y}),v}},token:{method(){return this.$_addRule("token")},validate:(g,y)=>/^\w+$/.test(g)?g:y.error("string.token")},trim:{method(g=!0){return a(typeof g=="boolean","enabled must be a boolean"),this.$_addRule({name:"trim",args:{enabled:g}})},validate:(g,y,{enabled:v})=>v&&g!==g.trim()?y.error("string.trim"):g,convert:!0},truncate:{method(g=!0){return a(typeof g=="boolean","enabled must be a boolean"),this.$_setFlag("truncate",g)}},uppercase:{method(){return this.case("upper")}},uri:{method(g={}){f.assertOptions(g,["allowRelative","allowQuerySquareBrackets","domain","relativeOnly","scheme","encodeUri"]),g.domain&&f.assertOptions(g.domain,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const{regex:y,scheme:v}=u.regex(g),_=g.domain?b.addressOptions(g.domain):null;return this.$_addRule({name:"uri",args:{options:g},regex:y,domain:_,scheme:v})},validate(g,y,{options:v},{regex:_,domain:C,scheme:S}){if(["http:/","https:/"].includes(g))return y.error("string.uri");let T=_.exec(g);if(!T&&y.prefs.convert&&v.encodeUri){const w=encodeURI(g);T=_.exec(w),T&&(g=w)}if(T){const w=T[1]||T[2];return!C||v.allowRelative&&!w||p.isValid(w,C)?g:y.error("string.domain",{value:w})}return v.relativeOnly?y.error("string.uriRelativeOnly"):v.scheme?y.error("string.uriCustomScheme",{scheme:S,value:g}):y.error("string.uri")}}},manifest:{build(g,y){if(y.replacements)for(const{pattern:v,replacement:_}of y.replacements)g=g.replace(v,_);return g}},messages:{"string.alphanum":"{{#label}} must only contain alpha-numeric characters","string.base":"{{#label}} must be a string","string.base64":"{{#label}} must be a valid base64 string","string.creditCard":"{{#label}} must be a credit card","string.dataUri":"{{#label}} must be a valid dataUri string","string.domain":"{{#label}} must contain a valid domain name","string.email":"{{#label}} must be a valid email","string.empty":"{{#label}} is not allowed to be empty","string.guid":"{{#label}} must be a valid GUID","string.hex":"{{#label}} must only contain hexadecimal characters","string.hexAlign":"{{#label}} hex decoded representation must be byte aligned","string.hostname":"{{#label}} must be a valid hostname","string.ip":"{{#label}} must be a valid ip address with a {{#cidr}} CIDR","string.ipVersion":"{{#label}} must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR","string.isoDate":"{{#label}} must be in iso format","string.isoDuration":"{{#label}} must be a valid ISO 8601 duration","string.length":"{{#label}} length must be {{#limit}} characters long","string.lowercase":"{{#label}} must only contain lowercase characters","string.max":"{{#label}} length must be less than or equal to {{#limit}} characters long","string.min":"{{#label}} length must be at least {{#limit}} characters long","string.normalize":"{{#label}} must be unicode normalized in the {{#form}} form","string.token":"{{#label}} must only contain alpha-numeric and underscore characters","string.pattern.base":"{{#label}} with value {:[.]} fails to match the required pattern: {{#regex}}","string.pattern.name":"{{#label}} with value {:[.]} fails to match the {{#name}} pattern","string.pattern.invert.base":"{{#label}} with value {:[.]} matches the inverted pattern: {{#regex}}","string.pattern.invert.name":"{{#label}} with value {:[.]} matches the inverted {{#name}} pattern","string.trim":"{{#label}} must not have leading or trailing whitespace","string.uri":"{{#label}} must be a valid uri","string.uriCustomScheme":"{{#label}} must be a valid uri with a scheme matching the {{#scheme}} pattern","string.uriRelativeOnly":"{{#label}} must be a valid relative uri","string.uppercase":"{{#label}} must only contain uppercase characters"}}),b.addressOptions=function(g){if(!g)return b.tlds||g;if(a(g.minDomainSegments===void 0||Number.isSafeInteger(g.minDomainSegments)&&g.minDomainSegments>0,"minDomainSegments must be a positive integer"),a(g.maxDomainSegments===void 0||Number.isSafeInteger(g.maxDomainSegments)&&g.maxDomainSegments>0,"maxDomainSegments must be a positive integer"),g.tlds===!1)return g;if(g.tlds===!0||g.tlds===void 0)return a(b.tlds,"Built-in TLD list disabled"),Object.assign({},g,b.tlds);a(typeof g.tlds=="object","tlds must be true, false, or an object");const y=g.tlds.deny;if(y)return Array.isArray(y)&&(g=Object.assign({},g,{tlds:{deny:new Set(y)}})),a(g.tlds.deny instanceof Set,"tlds.deny must be an array, Set, or boolean"),a(!g.tlds.allow,"Cannot specify both tlds.allow and tlds.deny lists"),b.validateTlds(g.tlds.deny,"tlds.deny"),g;const v=g.tlds.allow;return v?v===!0?(a(b.tlds,"Built-in TLD list disabled"),Object.assign({},g,b.tlds)):(Array.isArray(v)&&(g=Object.assign({},g,{tlds:{allow:new Set(v)}})),a(g.tlds.allow instanceof Set,"tlds.allow must be an array, Set, or boolean"),b.validateTlds(g.tlds.allow,"tlds.allow"),g):g},b.validateTlds=function(g,y){for(const v of g)a(p.isValid(v,{minDomainSegments:1,maxDomainSegments:1}),`${y} must contain valid top level domain names`)},b.isoDate=function(g){if(!f.isIsoDate(g))return null;/.*T.*[+-]\d\d$/.test(g)&&(g+="00");const y=new Date(g);return isNaN(y.getTime())?null:y.toISOString()},b.length=function(g,y,v,_,C){return a(!C||!1,"Invalid encoding:",C),g.$_addRule({name:y,method:"length",args:{limit:v,encoding:C},operator:_})}},8826:(r,n,o)=>{const a=o(375),p=o(8068),m={};m.Map=class extends Map{slice(){return new m.Map(this)}},r.exports=p.extend({type:"symbol",terms:{map:{init:new m.Map}},coerce:{method(d,{schema:l,error:c}){const u=l.$_terms.map.get(d);return u&&(d=u),l._flags.only&&typeof d!="symbol"?{value:d,errors:c("symbol.map",{map:l.$_terms.map})}:{value:d}}},validate(d,{error:l}){if(typeof d!="symbol")return{value:d,errors:l("symbol.base")}},rules:{map:{method(d){d&&!d[Symbol.iterator]&&typeof d=="object"&&(d=Object.entries(d)),a(d&&d[Symbol.iterator],"Iterable must be an iterable or object");const l=this.clone(),c=[];for(const u of d){a(u&&u[Symbol.iterator],"Entry must be an iterable");const[h,f]=u;a(typeof h!="object"&&typeof h!="function"&&typeof h!="symbol","Key must not be of type object, function, or Symbol"),a(typeof f=="symbol","Value must be a Symbol"),l.$_terms.map.set(h,f),c.push(f)}return l.valid(...c)}}},manifest:{build:(d,l)=>(l.map&&(d=d.map(l.map)),d)},messages:{"symbol.base":"{{#label}} must be a symbol","symbol.map":"{{#label}} must be one of {{#map}}"}})},8863:(r,n,o)=>{const a=o(375),p=o(8571),m=o(738),d=o(9621),l=o(8160),c=o(6354),u=o(493),h={result:Symbol("result")};n.entry=function(f,b,g){let y=l.defaults;g&&(a(g.warnings===void 0,"Cannot override warnings preference in synchronous validation"),a(g.artifacts===void 0,"Cannot override artifacts preference in synchronous validation"),y=l.preferences(l.defaults,g));const v=h.entry(f,b,y);a(!v.mainstay.externals.length,"Schema with external rules must use validateAsync()");const _={value:v.value};return v.error&&(_.error=v.error),v.mainstay.warnings.length&&(_.warning=c.details(v.mainstay.warnings)),v.mainstay.debug&&(_.debug=v.mainstay.debug),v.mainstay.artifacts&&(_.artifacts=v.mainstay.artifacts),_},n.entryAsync=async function(f,b,g){let y=l.defaults;g&&(y=l.preferences(l.defaults,g));const v=h.entry(f,b,y),_=v.mainstay;if(v.error)throw _.debug&&(v.error.debug=_.debug),v.error;if(_.externals.length){let S=v.value;const T=[];for(const w of _.externals){const x=w.state.path,k=w.schema.type==="link"?_.links.get(w.schema):null;let E,P,O=S;const z=x.length?[S]:[],I=x.length?d(f,x):f;if(x.length){E=x[x.length-1];let L=S;for(const F of x.slice(0,-1))L=L[F],z.unshift(L);P=z[0],O=P[E]}try{const L=(Z,Q)=>(k||w.schema).$_createError(Z,O,Q,w.state,y),F=await w.method(O,{schema:w.schema,linked:k,state:w.state,prefs:g,original:I,error:L,errorsArray:h.errorsArray,warn:(Z,Q)=>_.warnings.push((k||w.schema).$_createError(Z,O,Q,w.state,y)),message:(Z,Q)=>(k||w.schema).$_createError("external",O,Q,w.state,y,{messages:Z})});if(F===void 0||F===O)continue;if(F instanceof c.Report){if(_.tracer.log(w.schema,w.state,"rule","external","error"),T.push(F),y.abortEarly)break;continue}if(Array.isArray(F)&&F[l.symbols.errors]){if(_.tracer.log(w.schema,w.state,"rule","external","error"),T.push(...F),y.abortEarly)break;continue}P?(_.tracer.value(w.state,"rule",O,F,"external"),P[E]=F):(_.tracer.value(w.state,"rule",S,F,"external"),S=F)}catch(L){throw y.errors.label&&(L.message+=` (${w.label})`),L}}if(v.value=S,T.length)throw v.error=c.process(T,f,y),_.debug&&(v.error.debug=_.debug),v.error}if(!y.warnings&&!y.debug&&!y.artifacts)return v.value;const C={value:v.value};return _.warnings.length&&(C.warning=c.details(_.warnings)),_.debug&&(C.debug=_.debug),_.artifacts&&(C.artifacts=_.artifacts),C},h.Mainstay=class{constructor(f,b,g){this.externals=[],this.warnings=[],this.tracer=f,this.debug=b,this.links=g,this.shadow=null,this.artifacts=null,this._snapshots=[]}snapshot(){this._snapshots.push({externals:this.externals.slice(),warnings:this.warnings.slice()})}restore(){const f=this._snapshots.pop();this.externals=f.externals,this.warnings=f.warnings}commit(){this._snapshots.pop()}},h.entry=function(f,b,g){const{tracer:y,cleanup:v}=h.tracer(b,g),_=g.debug?[]:null,C=b._ids._schemaChain?new Map:null,S=new h.Mainstay(y,_,C),T=b._ids._schemaChain?[{schema:b}]:null,w=new u([],[],{mainstay:S,schemas:T}),x=n.validate(f,b,w,g);v&&b.$_root.untrace();const k=c.process(x.errors,f,g);return{value:x.value,error:k,mainstay:S}},h.tracer=function(f,b){return f.$_root._tracer?{tracer:f.$_root._tracer._register(f)}:b.debug?(a(f.$_root.trace,"Debug mode not supported"),{tracer:f.$_root.trace()._register(f),cleanup:!0}):{tracer:h.ignore}},n.validate=function(f,b,g,y,v={}){if(b.$_terms.whens&&(b=b._generate(f,g,y).schema),b._preferences&&(y=h.prefs(b,y)),b._cache&&y.cache){const k=b._cache.get(f);if(g.mainstay.tracer.debug(g,"validate","cached",!!k),k)return k}const _=(k,E,P)=>b.$_createError(k,f,E,P||g,y),C={original:f,prefs:y,schema:b,state:g,error:_,errorsArray:h.errorsArray,warn:(k,E,P)=>g.mainstay.warnings.push(_(k,E,P)),message:(k,E)=>b.$_createError("custom",f,E,g,y,{messages:k})};g.mainstay.tracer.entry(b,g);const S=b._definition;if(S.prepare&&f!==void 0&&y.convert){const k=S.prepare(f,C);if(k){if(g.mainstay.tracer.value(g,"prepare",f,k.value),k.errors)return h.finalize(k.value,[].concat(k.errors),C);f=k.value}}if(S.coerce&&f!==void 0&&y.convert&&(!S.coerce.from||S.coerce.from.includes(typeof f))){const k=S.coerce.method(f,C);if(k){if(g.mainstay.tracer.value(g,"coerced",f,k.value),k.errors)return h.finalize(k.value,[].concat(k.errors),C);f=k.value}}const T=b._flags.empty;T&&T.$_match(h.trim(f,b),g.nest(T),l.defaults)&&(g.mainstay.tracer.value(g,"empty",f,void 0),f=void 0);const w=v.presence||b._flags.presence||(b._flags._endedSwitch?null:y.presence);if(f===void 0){if(w==="forbidden")return h.finalize(f,null,C);if(w==="required")return h.finalize(f,[b.$_createError("any.required",f,null,g,y)],C);if(w==="optional"){if(b._flags.default!==l.symbols.deepDefault)return h.finalize(f,null,C);g.mainstay.tracer.value(g,"default",f,{}),f={}}}else if(w==="forbidden")return h.finalize(f,[b.$_createError("any.unknown",f,null,g,y)],C);const x=[];if(b._valids){const k=b._valids.get(f,g,y,b._flags.insensitive);if(k)return y.convert&&(g.mainstay.tracer.value(g,"valids",f,k.value),f=k.value),g.mainstay.tracer.filter(b,g,"valid",k),h.finalize(f,null,C);if(b._flags.only){const E=b.$_createError("any.only",f,{valids:b._valids.values({display:!0})},g,y);if(y.abortEarly)return h.finalize(f,[E],C);x.push(E)}}if(b._invalids){const k=b._invalids.get(f,g,y,b._flags.insensitive);if(k){g.mainstay.tracer.filter(b,g,"invalid",k);const E=b.$_createError("any.invalid",f,{invalids:b._invalids.values({display:!0})},g,y);if(y.abortEarly)return h.finalize(f,[E],C);x.push(E)}}if(S.validate){const k=S.validate(f,C);if(k&&(g.mainstay.tracer.value(g,"base",f,k.value),f=k.value,k.errors)){if(!Array.isArray(k.errors))return x.push(k.errors),h.finalize(f,x,C);if(k.errors.length)return x.push(...k.errors),h.finalize(f,x,C)}}return b._rules.length?h.rules(f,x,C):h.finalize(f,x,C)},h.rules=function(f,b,g){const{schema:y,state:v,prefs:_}=g;for(const C of y._rules){const S=y._definition.rules[C.method];if(S.convert&&_.convert){v.mainstay.tracer.log(y,v,"rule",C.name,"full");continue}let T,w=C.args;if(C._resolve.length){w=Object.assign({},w);for(const k of C._resolve){const E=S.argsByName.get(k),P=w[k].resolve(f,v,_),O=E.normalize?E.normalize(P):P,z=l.validateArg(O,null,E);if(z){T=y.$_createError("any.ref",P,{arg:k,ref:w[k],reason:z},v,_);break}w[k]=O}}T=T||S.validate(f,g,w,C);const x=h.rule(T,C);if(x.errors){if(v.mainstay.tracer.log(y,v,"rule",C.name,"error"),C.warn){v.mainstay.warnings.push(...x.errors);continue}if(_.abortEarly)return h.finalize(f,x.errors,g);b.push(...x.errors)}else v.mainstay.tracer.log(y,v,"rule",C.name,"pass"),v.mainstay.tracer.value(v,"rule",f,x.value,C.name),f=x.value}return h.finalize(f,b,g)},h.rule=function(f,b){return f instanceof c.Report?(h.error(f,b),{errors:[f],value:null}):Array.isArray(f)&&f[l.symbols.errors]?(f.forEach(g=>h.error(g,b)),{errors:f,value:null}):{errors:null,value:f}},h.error=function(f,b){return b.message&&f._setTemplate(b.message),f},h.finalize=function(f,b,g){b=b||[];const{schema:y,state:v,prefs:_}=g;if(b.length){const S=h.default("failover",void 0,b,g);S!==void 0&&(v.mainstay.tracer.value(v,"failover",f,S),f=S,b=[])}if(b.length&&y._flags.error)if(typeof y._flags.error=="function"){b=y._flags.error(b),Array.isArray(b)||(b=[b]);for(const S of b)a(S instanceof Error||S instanceof c.Report,"error() must return an Error object")}else b=[y._flags.error];if(f===void 0){const S=h.default("default",f,b,g);v.mainstay.tracer.value(v,"default",f,S),f=S}if(y._flags.cast&&f!==void 0){const S=y._definition.cast[y._flags.cast];if(S.from(f)){const T=S.to(f,g);v.mainstay.tracer.value(v,"cast",f,T,y._flags.cast),f=T}}if(y.$_terms.externals&&_.externals&&_._externals!==!1)for(const{method:S}of y.$_terms.externals)v.mainstay.externals.push({method:S,schema:y,state:v,label:c.label(y._flags,v,_)});const C={value:f,errors:b.length?b:null};return y._flags.result&&(C.value=y._flags.result==="strip"?void 0:g.original,v.mainstay.tracer.value(v,y._flags.result,f,C.value),v.shadow(f,y._flags.result)),y._cache&&_.cache!==!1&&!y._refs.length&&y._cache.set(g.original,C),f===void 0||C.errors||y._flags.artifact===void 0||(v.mainstay.artifacts=v.mainstay.artifacts||new Map,v.mainstay.artifacts.has(y._flags.artifact)||v.mainstay.artifacts.set(y._flags.artifact,[]),v.mainstay.artifacts.get(y._flags.artifact).push(v.path)),C},h.prefs=function(f,b){const g=b===l.defaults;return g&&f._preferences[l.symbols.prefs]?f._preferences[l.symbols.prefs]:(b=l.preferences(b,f._preferences),g&&(f._preferences[l.symbols.prefs]=b),b)},h.default=function(f,b,g,y){const{schema:v,state:_,prefs:C}=y,S=v._flags[f];if(C.noDefaults||S===void 0)return b;if(_.mainstay.tracer.log(v,_,"rule",f,"full"),!S)return S;if(typeof S=="function"){const T=S.length?[p(_.ancestors[0]),y]:[];try{return S(...T)}catch(w){return void g.push(v.$_createError(`any.${f}`,null,{error:w},_,C))}}return typeof S!="object"?S:S[l.symbols.literal]?S.literal:l.isResolvable(S)?S.resolve(b,_,C):p(S)},h.trim=function(f,b){if(typeof f!="string")return f;const g=b.$_getRule("trim");return g&&g.args.enabled?f.trim():f},h.ignore={active:!1,debug:m,entry:m,filter:m,log:m,resolve:m,value:m},h.errorsArray=function(){const f=[];return f[l.symbols.errors]=!0,f}},2036:(r,n,o)=>{const a=o(375),p=o(9474),m=o(8160),d={};r.exports=d.Values=class{constructor(l,c){this._values=new Set(l),this._refs=new Set(c),this._lowercase=d.lowercases(l),this._override=!1}get length(){return this._values.size+this._refs.size}add(l,c){m.isResolvable(l)?this._refs.has(l)||(this._refs.add(l),c&&c.register(l)):this.has(l,null,null,!1)||(this._values.add(l),typeof l=="string"&&this._lowercase.set(l.toLowerCase(),l))}static merge(l,c,u){if(l=l||new d.Values,c){if(c._override)return c.clone();for(const h of[...c._values,...c._refs])l.add(h)}if(u)for(const h of[...u._values,...u._refs])l.remove(h);return l.length?l:null}remove(l){m.isResolvable(l)?this._refs.delete(l):(this._values.delete(l),typeof l=="string"&&this._lowercase.delete(l.toLowerCase()))}has(l,c,u,h){return!!this.get(l,c,u,h)}get(l,c,u,h){if(!this.length)return!1;if(this._values.has(l))return{value:l};if(typeof l=="string"&&l&&h){const f=this._lowercase.get(l.toLowerCase());if(f)return{value:f}}if(!this._refs.size&&typeof l!="object")return!1;if(typeof l=="object"){for(const f of this._values)if(p(f,l))return{value:f}}if(c)for(const f of this._refs){const b=f.resolve(l,c,u,null,{in:!0});if(b===void 0)continue;const g=f.in&&typeof b=="object"?Array.isArray(b)?b:Object.keys(b):[b];for(const y of g)if(typeof y==typeof l){if(h&&l&&typeof l=="string"){if(y.toLowerCase()===l.toLowerCase())return{value:y,ref:f}}else if(p(y,l))return{value:y,ref:f}}}return!1}override(){this._override=!0}values(l){if(l&&l.display){const c=[];for(const u of[...this._values,...this._refs])u!==void 0&&c.push(u);return c}return Array.from([...this._values,...this._refs])}clone(){const l=new d.Values(this._values,this._refs);return l._override=this._override,l}concat(l){a(!l._override,"Cannot concat override set of values");const c=new d.Values([...this._values,...l._values],[...this._refs,...l._refs]);return c._override=this._override,c}describe(){const l=[];this._override&&l.push({override:!0});for(const c of this._values.values())l.push(c&&typeof c=="object"?{value:c}:c);for(const c of this._refs.values())l.push(c.describe());return l}},d.Values.prototype[m.symbols.values]=!0,d.Values.prototype.slice=d.Values.prototype.clone,d.lowercases=function(l){const c=new Map;if(l)for(const u of l)typeof u=="string"&&c.set(u.toLowerCase(),u);return c}},978:(r,n,o)=>{const a=o(375),p=o(8571),m=o(1687),d=o(9621),l={};r.exports=function(c,u,h={}){if(a(c&&typeof c=="object","Invalid defaults value: must be an object"),a(!u||u===!0||typeof u=="object","Invalid source value: must be true, falsy or an object"),a(typeof h=="object","Invalid options: must be an object"),!u)return null;if(h.shallow)return l.applyToDefaultsWithShallow(c,u,h);const f=p(c);if(u===!0)return f;const b=h.nullOverride!==void 0&&h.nullOverride;return m(f,u,{nullOverride:b,mergeArrays:!1})},l.applyToDefaultsWithShallow=function(c,u,h){const f=h.shallow;a(Array.isArray(f),"Invalid keys");const b=new Map,g=u===!0?null:new Set;for(let _ of f){_=Array.isArray(_)?_:_.split(".");const C=d(c,_);C&&typeof C=="object"?b.set(C,g&&d(u,_)||C):g&&g.add(_)}const y=p(c,{},b);if(!g)return y;for(const _ of g)l.reachCopy(y,u,_);const v=h.nullOverride!==void 0&&h.nullOverride;return m(y,u,{nullOverride:v,mergeArrays:!1})},l.reachCopy=function(c,u,h){for(const g of h){if(!(g in u))return;const y=u[g];if(typeof y!="object"||y===null)return;u=y}const f=u;let b=c;for(let g=0;g<h.length-1;++g){const y=h[g];typeof b[y]!="object"&&(b[y]={}),b=b[y]}b[h[h.length-1]]=f}},375:(r,n,o)=>{const a=o(7916);r.exports=function(p,...m){if(!p)throw m.length===1&&m[0]instanceof Error?m[0]:new a(m)}},8571:(r,n,o)=>{const a=o(9621),p=o(4277),m=o(7043),d={needsProtoHack:new Set([p.set,p.map,p.weakSet,p.weakMap])};r.exports=d.clone=function(l,c={},u=null){if(typeof l!="object"||l===null)return l;let h=d.clone,f=u;if(c.shallow){if(c.shallow!==!0)return d.cloneWithShallow(l,c);h=v=>v}else if(f){const v=f.get(l);if(v)return v}else f=new Map;const b=p.getInternalProto(l);if(b===p.buffer)return!1;if(b===p.date)return new Date(l.getTime());if(b===p.regex)return new RegExp(l);const g=d.base(l,b,c);if(g===l)return l;if(f&&f.set(l,g),b===p.set)for(const v of l)g.add(h(v,c,f));else if(b===p.map)for(const[v,_]of l)g.set(v,h(_,c,f));const y=m.keys(l,c);for(const v of y){if(v==="__proto__")continue;if(b===p.array&&v==="length"){g.length=l.length;continue}const _=Object.getOwnPropertyDescriptor(l,v);_?_.get||_.set?Object.defineProperty(g,v,_):_.enumerable?g[v]=h(l[v],c,f):Object.defineProperty(g,v,{enumerable:!1,writable:!0,configurable:!0,value:h(l[v],c,f)}):Object.defineProperty(g,v,{enumerable:!0,writable:!0,configurable:!0,value:h(l[v],c,f)})}return g},d.cloneWithShallow=function(l,c){const u=c.shallow;(c=Object.assign({},c)).shallow=!1;const h=new Map;for(const f of u){const b=a(l,f);typeof b!="object"&&typeof b!="function"||h.set(b,b)}return d.clone(l,c,h)},d.base=function(l,c,u){if(u.prototype===!1)return d.needsProtoHack.has(c)?new c.constructor:c===p.array?[]:{};const h=Object.getPrototypeOf(l);if(h&&h.isImmutable)return l;if(c===p.array){const f=[];return h!==c&&Object.setPrototypeOf(f,h),f}if(d.needsProtoHack.has(c)){const f=new h.constructor;return h!==c&&Object.setPrototypeOf(f,h),f}return Object.create(h)}},9474:(r,n,o)=>{const a=o(4277),p={mismatched:null};r.exports=function(m,d,l){return l=Object.assign({prototype:!0},l),!!p.isDeepEqual(m,d,l,[])},p.isDeepEqual=function(m,d,l,c){if(m===d)return m!==0||1/m==1/d;const u=typeof m;if(u!==typeof d||m===null||d===null)return!1;if(u==="function"){if(!l.deepFunction||m.toString()!==d.toString())return!1}else if(u!=="object")return m!=m&&d!=d;const h=p.getSharedType(m,d,!!l.prototype);switch(h){case a.buffer:return!1;case a.promise:return m===d;case a.regex:return m.toString()===d.toString();case p.mismatched:return!1}for(let f=c.length-1;f>=0;--f)if(c[f].isSame(m,d))return!0;c.push(new p.SeenEntry(m,d));try{return!!p.isDeepEqualObj(h,m,d,l,c)}finally{c.pop()}},p.getSharedType=function(m,d,l){if(l)return Object.getPrototypeOf(m)!==Object.getPrototypeOf(d)?p.mismatched:a.getInternalProto(m);const c=a.getInternalProto(m);return c!==a.getInternalProto(d)?p.mismatched:c},p.valueOf=function(m){const d=m.valueOf;if(d===void 0)return m;try{return d.call(m)}catch(l){return l}},p.hasOwnEnumerableProperty=function(m,d){return Object.prototype.propertyIsEnumerable.call(m,d)},p.isSetSimpleEqual=function(m,d){for(const l of Set.prototype.values.call(m))if(!Set.prototype.has.call(d,l))return!1;return!0},p.isDeepEqualObj=function(m,d,l,c,u){const{isDeepEqual:h,valueOf:f,hasOwnEnumerableProperty:b}=p,{keys:g,getOwnPropertySymbols:y}=Object;if(m===a.array){if(!c.part){if(d.length!==l.length)return!1;for(let T=0;T<d.length;++T)if(!h(d[T],l[T],c,u))return!1;return!0}for(const T of d)for(const w of l)if(h(T,w,c,u))return!0}else if(m===a.set){if(d.size!==l.size)return!1;if(!p.isSetSimpleEqual(d,l)){const T=new Set(Set.prototype.values.call(l));for(const w of Set.prototype.values.call(d)){if(T.delete(w))continue;let x=!1;for(const k of T)if(h(w,k,c,u)){T.delete(k),x=!0;break}if(!x)return!1}}}else if(m===a.map){if(d.size!==l.size)return!1;for(const[T,w]of Map.prototype.entries.call(d))if(w===void 0&&!Map.prototype.has.call(l,T)||!h(w,Map.prototype.get.call(l,T),c,u))return!1}else if(m===a.error&&(d.name!==l.name||d.message!==l.message))return!1;const v=f(d),_=f(l);if((d!==v||l!==_)&&!h(v,_,c,u))return!1;const C=g(d);if(!c.part&&C.length!==g(l).length&&!c.skip)return!1;let S=0;for(const T of C)if(c.skip&&c.skip.includes(T))l[T]===void 0&&++S;else if(!b(l,T)||!h(d[T],l[T],c,u))return!1;if(!c.part&&C.length-S!==g(l).length)return!1;if(c.symbols!==!1){const T=y(d),w=new Set(y(l));for(const x of T){if(!c.skip||!c.skip.includes(x)){if(b(d,x)){if(!b(l,x)||!h(d[x],l[x],c,u))return!1}else if(b(l,x))return!1}w.delete(x)}for(const x of w)if(b(l,x))return!1}return!0},p.SeenEntry=class{constructor(m,d){this.obj=m,this.ref=d}isSame(m,d){return this.obj===m&&this.ref===d}}},7916:(r,n,o)=>{const a=o(8761);r.exports=class extends Error{constructor(p){super(p.filter(m=>m!=="").map(m=>typeof m=="string"?m:m instanceof Error?m.message:a(m)).join(" ")||"Unknown error"),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,n.assert)}}},5277:r=>{const n={};r.exports=function(o){if(!o)return"";let a="";for(let p=0;p<o.length;++p){const m=o.charCodeAt(p);n.isSafe(m)?a+=o[p]:a+=n.escapeHtmlChar(m)}return a},n.escapeHtmlChar=function(o){return n.namedHtml.get(o)||(o>=256?"&#"+o+";":`&#x${o.toString(16).padStart(2,"0")};`)},n.isSafe=function(o){return n.safeCharCodes.has(o)},n.namedHtml=new Map([[38,"&amp;"],[60,"&lt;"],[62,"&gt;"],[34,"&quot;"],[160,"&nbsp;"],[162,"&cent;"],[163,"&pound;"],[164,"&curren;"],[169,"&copy;"],[174,"&reg;"]]),n.safeCharCodes=function(){const o=new Set;for(let a=32;a<123;++a)(a>=97||a>=65&&a<=90||a>=48&&a<=57||a===32||a===46||a===44||a===45||a===58||a===95)&&o.add(a);return o}()},6064:r=>{r.exports=function(n){return n.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g,"\\$&")}},738:r=>{r.exports=function(){}},1687:(r,n,o)=>{const a=o(375),p=o(8571),m=o(7043),d={};r.exports=d.merge=function(l,c,u){if(a(l&&typeof l=="object","Invalid target value: must be an object"),a(c==null||typeof c=="object","Invalid source value: must be null, undefined, or an object"),!c)return l;if(u=Object.assign({nullOverride:!0,mergeArrays:!0},u),Array.isArray(c)){a(Array.isArray(l),"Cannot merge array onto an object"),u.mergeArrays||(l.length=0);for(let f=0;f<c.length;++f)l.push(p(c[f],{symbols:u.symbols}));return l}const h=m.keys(c,u);for(let f=0;f<h.length;++f){const b=h[f];if(b==="__proto__"||!Object.prototype.propertyIsEnumerable.call(c,b))continue;const g=c[b];if(g&&typeof g=="object"){if(l[b]===g)continue;!l[b]||typeof l[b]!="object"||Array.isArray(l[b])!==Array.isArray(g)||g instanceof Date||g instanceof RegExp?l[b]=p(g,{symbols:u.symbols}):d.merge(l[b],g,u)}else(g!=null||u.nullOverride)&&(l[b]=g)}return l}},9621:(r,n,o)=>{const a=o(375),p={};r.exports=function(m,d,l){if(d===!1||d==null)return m;typeof(l=l||{})=="string"&&(l={separator:l});const c=Array.isArray(d);a(!c||!l.separator,"Separator option is not valid for array-based chain");const u=c?d:d.split(l.separator||".");let h=m;for(let f=0;f<u.length;++f){let b=u[f];const g=l.iterables&&p.iterables(h);if(Array.isArray(h)||g==="set"){const y=Number(b);Number.isInteger(y)&&(b=y<0?h.length+y:y)}if(!h||typeof h=="function"&&l.functions===!1||!g&&h[b]===void 0){a(!l.strict||f+1===u.length,"Missing segment",b,"in reach path ",d),a(typeof h=="object"||l.functions===!0||typeof h!="function","Invalid segment",b,"in reach path ",d),h=l.default;break}h=g?g==="set"?[...h][b]:h.get(b):h[b]}return h},p.iterables=function(m){return m instanceof Set?"set":m instanceof Map?"map":void 0}},8761:r=>{r.exports=function(...n){try{return JSON.stringify(...n)}catch(o){return"[Cannot display object: "+o.message+"]"}}},4277:(r,n)=>{const o={};n=r.exports={array:Array.prototype,buffer:!1,date:Date.prototype,error:Error.prototype,generic:Object.prototype,map:Map.prototype,promise:Promise.prototype,regex:RegExp.prototype,set:Set.prototype,weakMap:WeakMap.prototype,weakSet:WeakSet.prototype},o.typeMap=new Map([["[object Error]",n.error],["[object Map]",n.map],["[object Promise]",n.promise],["[object Set]",n.set],["[object WeakMap]",n.weakMap],["[object WeakSet]",n.weakSet]]),n.getInternalProto=function(a){if(Array.isArray(a))return n.array;if(a instanceof Date)return n.date;if(a instanceof RegExp)return n.regex;if(a instanceof Error)return n.error;const p=Object.prototype.toString.call(a);return o.typeMap.get(p)||n.generic}},7043:(r,n)=>{n.keys=function(o,a={}){return a.symbols!==!1?Reflect.ownKeys(o):Object.getOwnPropertyNames(o)}},3652:(r,n,o)=>{const a=o(375),p={};n.Sorter=class{constructor(){this._items=[],this.nodes=[]}add(m,d){const l=[].concat((d=d||{}).before||[]),c=[].concat(d.after||[]),u=d.group||"?",h=d.sort||0;a(!l.includes(u),`Item cannot come before itself: ${u}`),a(!l.includes("?"),"Item cannot come before unassociated items"),a(!c.includes(u),`Item cannot come after itself: ${u}`),a(!c.includes("?"),"Item cannot come after unassociated items"),Array.isArray(m)||(m=[m]);for(const f of m){const b={seq:this._items.length,sort:h,before:l,after:c,group:u,node:f};this._items.push(b)}if(!d.manual){const f=this._sort();a(f,"item",u!=="?"?`added into group ${u}`:"","created a dependencies error")}return this.nodes}merge(m){Array.isArray(m)||(m=[m]);for(const l of m)if(l)for(const c of l._items)this._items.push(Object.assign({},c));this._items.sort(p.mergeSort);for(let l=0;l<this._items.length;++l)this._items[l].seq=l;const d=this._sort();return a(d,"merge created a dependencies error"),this.nodes}sort(){const m=this._sort();return a(m,"sort created a dependencies error"),this.nodes}_sort(){const m={},d=Object.create(null),l=Object.create(null);for(const b of this._items){const g=b.seq,y=b.group;l[y]=l[y]||[],l[y].push(g),m[g]=b.before;for(const v of b.after)d[v]=d[v]||[],d[v].push(g)}for(const b in m){const g=[];for(const y in m[b]){const v=m[b][y];l[v]=l[v]||[],g.push(...l[v])}m[b]=g}for(const b in d)if(l[b])for(const g of l[b])m[g].push(...d[b]);const c={};for(const b in m){const g=m[b];for(const y of g)c[y]=c[y]||[],c[y].push(b)}const u={},h=[];for(let b=0;b<this._items.length;++b){let g=b;if(c[b]){g=null;for(let y=0;y<this._items.length;++y){if(u[y]===!0)continue;c[y]||(c[y]=[]);const v=c[y].length;let _=0;for(let C=0;C<v;++C)u[c[y][C]]&&++_;if(_===v){g=y;break}}}g!==null&&(u[g]=!0,h.push(g))}if(h.length!==this._items.length)return!1;const f={};for(const b of this._items)f[b.seq]=b;this._items=[],this.nodes=[];for(const b of h){const g=f[b];this.nodes.push(g.node),this._items.push(g)}return!0}},p.mergeSort=(m,d)=>m.sort===d.sort?0:m.sort<d.sort?-1:1},5380:(r,n,o)=>{const a=o(443),p=o(2178),m={minDomainSegments:2,nonAsciiRx:/[^\x00-\x7f]/,domainControlRx:/[\x00-\x20@\:\/\\#!\$&\'\(\)\*\+,;=\?]/,tldSegmentRx:/^[a-zA-Z](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,domainSegmentRx:/^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,URL:a.URL||URL};n.analyze=function(d,l={}){if(!d)return p.code("DOMAIN_NON_EMPTY_STRING");if(typeof d!="string")throw new Error("Invalid input: domain must be a string");if(d.length>256)return p.code("DOMAIN_TOO_LONG");if(m.nonAsciiRx.test(d)){if(l.allowUnicode===!1)return p.code("DOMAIN_INVALID_UNICODE_CHARS");d=d.normalize("NFC")}if(m.domainControlRx.test(d))return p.code("DOMAIN_INVALID_CHARS");d=m.punycode(d),l.allowFullyQualified&&d[d.length-1]==="."&&(d=d.slice(0,-1));const c=l.minDomainSegments||m.minDomainSegments,u=d.split(".");if(u.length<c)return p.code("DOMAIN_SEGMENTS_COUNT");if(l.maxDomainSegments&&u.length>l.maxDomainSegments)return p.code("DOMAIN_SEGMENTS_COUNT_MAX");const h=l.tlds;if(h){const f=u[u.length-1].toLowerCase();if(h.deny&&h.deny.has(f)||h.allow&&!h.allow.has(f))return p.code("DOMAIN_FORBIDDEN_TLDS")}for(let f=0;f<u.length;++f){const b=u[f];if(!b.length)return p.code("DOMAIN_EMPTY_SEGMENT");if(b.length>63)return p.code("DOMAIN_LONG_SEGMENT");if(f<u.length-1){if(!m.domainSegmentRx.test(b))return p.code("DOMAIN_INVALID_CHARS")}else if(!m.tldSegmentRx.test(b))return p.code("DOMAIN_INVALID_TLDS_CHARS")}return null},n.isValid=function(d,l){return!n.analyze(d,l)},m.punycode=function(d){d.includes("%")&&(d=d.replace(/%/g,"%25"));try{return new m.URL(`http://${d}`).host}catch{return d}}},1745:(r,n,o)=>{const a=o(9848),p=o(5380),m=o(2178),d={nonAsciiRx:/[^\x00-\x7f]/,encoder:new(a.TextEncoder||TextEncoder)};n.analyze=function(l,c){return d.email(l,c)},n.isValid=function(l,c){return!d.email(l,c)},d.email=function(l,c={}){if(typeof l!="string")throw new Error("Invalid input: email must be a string");if(!l)return m.code("EMPTY_STRING");const u=!d.nonAsciiRx.test(l);if(!u){if(c.allowUnicode===!1)return m.code("FORBIDDEN_UNICODE");l=l.normalize("NFC")}const h=l.split("@");if(h.length!==2)return h.length>2?m.code("MULTIPLE_AT_CHAR"):m.code("MISSING_AT_CHAR");const[f,b]=h;if(!f)return m.code("EMPTY_LOCAL");if(!c.ignoreLength){if(l.length>254)return m.code("ADDRESS_TOO_LONG");if(d.encoder.encode(f).length>64)return m.code("LOCAL_TOO_LONG")}return d.local(f,u)||p.analyze(b,c)},d.local=function(l,c){const u=l.split(".");for(const h of u){if(!h.length)return m.code("EMPTY_LOCAL_SEGMENT");if(c){if(!d.atextRx.test(h))return m.code("INVALID_LOCAL_CHARS")}else for(const f of h){if(d.atextRx.test(f))continue;const b=d.binary(f);if(!d.atomRx.test(b))return m.code("INVALID_LOCAL_CHARS")}}},d.binary=function(l){return Array.from(d.encoder.encode(l)).map(c=>String.fromCharCode(c)).join("")},d.atextRx=/^[\w!#\$%&'\*\+\-/=\?\^`\{\|\}~]+$/,d.atomRx=new RegExp(["(?:[\\xc2-\\xdf][\\x80-\\xbf])","(?:\\xe0[\\xa0-\\xbf][\\x80-\\xbf])|(?:[\\xe1-\\xec][\\x80-\\xbf]{2})|(?:\\xed[\\x80-\\x9f][\\x80-\\xbf])|(?:[\\xee-\\xef][\\x80-\\xbf]{2})","(?:\\xf0[\\x90-\\xbf][\\x80-\\xbf]{2})|(?:[\\xf1-\\xf3][\\x80-\\xbf]{3})|(?:\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})"].join("|"))},2178:(r,n)=>{n.codes={EMPTY_STRING:"Address must be a non-empty string",FORBIDDEN_UNICODE:"Address contains forbidden Unicode characters",MULTIPLE_AT_CHAR:"Address cannot contain more than one @ character",MISSING_AT_CHAR:"Address must contain one @ character",EMPTY_LOCAL:"Address local part cannot be empty",ADDRESS_TOO_LONG:"Address too long",LOCAL_TOO_LONG:"Address local part too long",EMPTY_LOCAL_SEGMENT:"Address local part contains empty dot-separated segment",INVALID_LOCAL_CHARS:"Address local part contains invalid character",DOMAIN_NON_EMPTY_STRING:"Domain must be a non-empty string",DOMAIN_TOO_LONG:"Domain too long",DOMAIN_INVALID_UNICODE_CHARS:"Domain contains forbidden Unicode characters",DOMAIN_INVALID_CHARS:"Domain contains invalid character",DOMAIN_INVALID_TLDS_CHARS:"Domain contains invalid tld character",DOMAIN_SEGMENTS_COUNT:"Domain lacks the minimum required number of segments",DOMAIN_SEGMENTS_COUNT_MAX:"Domain contains too many segments",DOMAIN_FORBIDDEN_TLDS:"Domain uses forbidden TLD",DOMAIN_EMPTY_SEGMENT:"Domain contains empty dot-separated segment",DOMAIN_LONG_SEGMENT:"Domain contains dot-separated segment that is too long"},n.code=function(o){return{code:o,error:n.codes[o]}}},9959:(r,n,o)=>{const a=o(375),p=o(5752);n.regex=function(m={}){a(m.cidr===void 0||typeof m.cidr=="string","options.cidr must be a string");const d=m.cidr?m.cidr.toLowerCase():"optional";a(["required","optional","forbidden"].includes(d),"options.cidr must be one of required, optional, forbidden"),a(m.version===void 0||typeof m.version=="string"||Array.isArray(m.version),"options.version must be a string or an array of string");let l=m.version||["ipv4","ipv6","ipvfuture"];Array.isArray(l)||(l=[l]),a(l.length>=1,"options.version must have at least 1 version specified");for(let h=0;h<l.length;++h)a(typeof l[h]=="string","options.version must only contain strings"),l[h]=l[h].toLowerCase(),a(["ipv4","ipv6","ipvfuture"].includes(l[h]),"options.version contains unknown version "+l[h]+" - must be one of ipv4, ipv6, ipvfuture");l=Array.from(new Set(l));const c=`(?:${l.map(h=>{if(d==="forbidden")return p.ip[h];const f=`\\/${h==="ipv4"?p.ip.v4Cidr:p.ip.v6Cidr}`;return d==="required"?`${p.ip[h]}${f}`:`${p.ip[h]}(?:${f})?`}).join("|")})`,u=new RegExp(`^${c}$`);return{cidr:d,versions:l,regex:u,raw:c}}},5752:(r,n,o)=>{const a=o(375),p=o(6064),m={generate:function(){const d={},l="\\dA-Fa-f",c="["+l+"]",u="\\w-\\.~",h="!\\$&'\\(\\)\\*\\+,;=",f="%"+l,b=u+f+h+":@",g="["+b+"]",y="(?:0{0,2}\\d|0?[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";d.ipv4address="(?:"+y+"\\.){3}"+y;const v=c+"{1,4}",_="(?:"+v+":"+v+"|"+d.ipv4address+")",C="(?:"+v+":){6}"+_,S="::(?:"+v+":){5}"+_,T="(?:"+v+")?::(?:"+v+":){4}"+_,w="(?:(?:"+v+":){0,1}"+v+")?::(?:"+v+":){3}"+_,x="(?:(?:"+v+":){0,2}"+v+")?::(?:"+v+":){2}"+_,k="(?:(?:"+v+":){0,3}"+v+")?::"+v+":"+_,E="(?:(?:"+v+":){0,4}"+v+")?::"+_,P="(?:(?:"+v+":){0,5}"+v+")?::"+v,O="(?:(?:"+v+":){0,6}"+v+")?::";d.ipv4Cidr="(?:\\d|[1-2]\\d|3[0-2])",d.ipv6Cidr="(?:0{0,2}\\d|0?[1-9]\\d|1[01]\\d|12[0-8])",d.ipv6address="(?:"+C+"|"+S+"|"+T+"|"+w+"|"+x+"|"+k+"|"+E+"|"+P+"|"+O+")",d.ipvFuture="v"+c+"+\\.["+u+h+":]+",d.scheme="[a-zA-Z][a-zA-Z\\d+-\\.]*",d.schemeRegex=new RegExp(d.scheme);const z="["+u+f+h+":]*",I="["+u+f+h+"]{1,255}",L="(?:\\[(?:"+d.ipv6address+"|"+d.ipvFuture+")\\]|"+d.ipv4address+"|"+I+")",F="(?:"+z+"@)?"+L+"(?::\\d*)?",Z="(?:"+z+"@)?("+L+")(?::\\d*)?",Q=g+"*",X=g+"+",Y="(?:\\/"+Q+")*",se="\\/(?:"+X+Y+")?",re=X+Y,Ce="["+u+f+h+"@]+"+Y,ve="(?:\\/\\/\\/"+Q+Y+")";return d.hierPart="(?:(?:\\/\\/"+F+Y+")|"+se+"|"+re+"|"+ve+")",d.hierPartCapture="(?:(?:\\/\\/"+Z+Y+")|"+se+"|"+re+")",d.relativeRef="(?:(?:\\/\\/"+F+Y+")|"+se+"|"+Ce+"|)",d.relativeRefCapture="(?:(?:\\/\\/"+Z+Y+")|"+se+"|"+Ce+"|)",d.query="["+b+"\\/\\?]*(?=#|$)",d.queryWithSquareBrackets="["+b+"\\[\\]\\/\\?]*(?=#|$)",d.fragment="["+b+"\\/\\?]*",d}};m.rfc3986=m.generate(),n.ip={v4Cidr:m.rfc3986.ipv4Cidr,v6Cidr:m.rfc3986.ipv6Cidr,ipv4:m.rfc3986.ipv4address,ipv6:m.rfc3986.ipv6address,ipvfuture:m.rfc3986.ipvFuture},m.createRegex=function(d){const l=m.rfc3986,c="(?:\\?"+(d.allowQuerySquareBrackets?l.queryWithSquareBrackets:l.query)+")?(?:#"+l.fragment+")?",u=d.domain?l.relativeRefCapture:l.relativeRef;if(d.relativeOnly)return m.wrap(u+c);let h="";if(d.scheme){a(d.scheme instanceof RegExp||typeof d.scheme=="string"||Array.isArray(d.scheme),"scheme must be a RegExp, String, or Array");const g=[].concat(d.scheme);a(g.length>=1,"scheme must have at least 1 scheme specified");const y=[];for(let v=0;v<g.length;++v){const _=g[v];a(_ instanceof RegExp||typeof _=="string","scheme at position "+v+" must be a RegExp or String"),_ instanceof RegExp?y.push(_.source.toString()):(a(l.schemeRegex.test(_),"scheme at position "+v+" must be a valid scheme"),y.push(p(_)))}h=y.join("|")}const f="(?:"+(h?"(?:"+h+")":l.scheme)+":"+(d.domain?l.hierPartCapture:l.hierPart)+")",b=d.allowRelative?"(?:"+f+"|"+u+")":f;return m.wrap(b+c,h)},m.wrap=function(d,l){return{raw:d=`(?=.)(?!https?:/(?:$|[^/]))(?!https?:///)(?!https?:[^/])${d}`,regex:new RegExp(`^${d}$`),scheme:l}},m.uriRegex=m.createRegex({}),n.regex=function(d={}){return d.scheme||d.allowRelative||d.relativeOnly||d.allowQuerySquareBrackets||d.domain?m.createRegex(d):m.uriRegex}},1447:(r,n)=>{const o={operators:["!","^","*","/","%","+","-","<","<=",">",">=","==","!=","&&","||","??"],operatorCharacters:["!","^","*","/","%","+","-","<","=",">","&","|","?"],operatorsOrder:[["^"],["*","/","%"],["+","-"],["<","<=",">",">="],["==","!="],["&&"],["||","??"]],operatorsPrefix:["!","n"],literals:{'"':'"',"`":"`","'":"'","[":"]"},numberRx:/^(?:[0-9]*(\.[0-9]*)?){1}$/,tokenRx:/^[\w\$\#\.\@\:\{\}]+$/,symbol:Symbol("formula"),settings:Symbol("settings")};n.Parser=class{constructor(a,p={}){if(!p[o.settings]&&p.constants)for(const m in p.constants){const d=p.constants[m];if(d!==null&&!["boolean","number","string"].includes(typeof d))throw new Error(`Formula constant ${m} contains invalid ${typeof d} value type`)}this.settings=p[o.settings]?p:Object.assign({[o.settings]:!0,constants:{},functions:{}},p),this.single=null,this._parts=null,this._parse(a)}_parse(a){let p=[],m="",d=0,l=!1;const c=h=>{if(d)throw new Error("Formula missing closing parenthesis");const f=p.length?p[p.length-1]:null;if(l||m||h){if(f&&f.type==="reference"&&h===")")return f.type="function",f.value=this._subFormula(m,f.value),void(m="");if(h===")"){const b=new n.Parser(m,this.settings);p.push({type:"segment",value:b})}else if(l){if(l==="]")return p.push({type:"reference",value:m}),void(m="");p.push({type:"literal",value:m})}else if(o.operatorCharacters.includes(m))f&&f.type==="operator"&&o.operators.includes(f.value+m)?f.value+=m:p.push({type:"operator",value:m});else if(m.match(o.numberRx))p.push({type:"constant",value:parseFloat(m)});else if(this.settings.constants[m]!==void 0)p.push({type:"constant",value:this.settings.constants[m]});else{if(!m.match(o.tokenRx))throw new Error(`Formula contains invalid token: ${m}`);p.push({type:"reference",value:m})}m=""}};for(const h of a)l?h===l?(c(),l=!1):m+=h:d?h==="("?(m+=h,++d):h===")"?(--d,d?m+=h:c(h)):m+=h:h in o.literals?l=o.literals[h]:h==="("?(c(),++d):o.operatorCharacters.includes(h)?(c(),m=h,c()):h!==" "?m+=h:c();c(),p=p.map((h,f)=>h.type!=="operator"||h.value!=="-"||f&&p[f-1].type!=="operator"?h:{type:"operator",value:"n"});let u=!1;for(const h of p){if(h.type==="operator"){if(o.operatorsPrefix.includes(h.value))continue;if(!u)throw new Error("Formula contains an operator in invalid position");if(!o.operators.includes(h.value))throw new Error(`Formula contains an unknown operator ${h.value}`)}else if(u)throw new Error("Formula missing expected operator");u=!u}if(!u)throw new Error("Formula contains invalid trailing operator");p.length===1&&["reference","literal","constant"].includes(p[0].type)&&(this.single={type:p[0].type==="reference"?"reference":"value",value:p[0].value}),this._parts=p.map(h=>{if(h.type==="operator")return o.operatorsPrefix.includes(h.value)?h:h.value;if(h.type!=="reference")return h.value;if(this.settings.tokenRx&&!this.settings.tokenRx.test(h.value))throw new Error(`Formula contains invalid reference ${h.value}`);return this.settings.reference?this.settings.reference(h.value):o.reference(h.value)})}_subFormula(a,p){const m=this.settings.functions[p];if(typeof m!="function")throw new Error(`Formula contains unknown function ${p}`);let d=[];if(a){let l="",c=0,u=!1;const h=()=>{if(!l)throw new Error(`Formula contains function ${p} with invalid arguments ${a}`);d.push(l),l=""};for(let f=0;f<a.length;++f){const b=a[f];u?(l+=b,b===u&&(u=!1)):b in o.literals&&!c?(l+=b,u=o.literals[b]):b!==","||c?(l+=b,b==="("?++c:b===")"&&--c):h()}h()}return d=d.map(l=>new n.Parser(l,this.settings)),function(l){const c=[];for(const u of d)c.push(u.evaluate(l));return m.call(l,...c)}}evaluate(a){const p=this._parts.slice();for(let m=p.length-2;m>=0;--m){const d=p[m];if(d&&d.type==="operator"){const l=p[m+1];p.splice(m+1,1);const c=o.evaluate(l,a);p[m]=o.single(d.value,c)}}return o.operatorsOrder.forEach(m=>{for(let d=1;d<p.length-1;)if(m.includes(p[d])){const l=p[d],c=o.evaluate(p[d-1],a),u=o.evaluate(p[d+1],a);p.splice(d,2);const h=o.calculate(l,c,u);p[d-1]=h===0?0:h}else d+=2}),o.evaluate(p[0],a)}},n.Parser.prototype[o.symbol]=!0,o.reference=function(a){return function(p){return p&&p[a]!==void 0?p[a]:null}},o.evaluate=function(a,p){return a===null?null:typeof a=="function"?a(p):a[o.symbol]?a.evaluate(p):a},o.single=function(a,p){if(a==="!")return!p;const m=-p;return m===0?0:m},o.calculate=function(a,p,m){if(a==="??")return o.exists(p)?p:m;if(typeof p=="string"||typeof m=="string"){if(a==="+")return(p=o.exists(p)?p:"")+(o.exists(m)?m:"")}else switch(a){case"^":return Math.pow(p,m);case"*":return p*m;case"/":return p/m;case"%":return p%m;case"+":return p+m;case"-":return p-m}switch(a){case"<":return p<m;case"<=":return p<=m;case">":return p>m;case">=":return p>=m;case"==":return p===m;case"!=":return p!==m;case"&&":return p&&m;case"||":return p||m}return null},o.exists=function(a){return a!=null}},9926:()=>{},5688:()=>{},9708:()=>{},1152:()=>{},443:()=>{},9848:()=>{},5934:r=>{r.exports=JSON.parse('{"version":"17.13.3"}')}},i={},function r(n){var o=i[n];if(o!==void 0)return o.exports;var a=i[n]={exports:{}};return t[n](a,a.exports,r),a.exports}(5107);var t,i})})(Js);var Ha=Js.exports;const N=Qs(Ha);var Na=Object.defineProperty,Ua=(s,e,t)=>e in s?Na(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,gt=(s,e,t)=>Ua(s,typeof e!="symbol"?e+"":e,t),be={DEFAULTS:{width:800,height:400,pixelRatio:2,fontFamily:"Roboto",fontSize:48,color:"#000000",textAlign:"left"},LIMITS:{minWidth:1,maxWidth:4096,minHeight:1,maxHeight:4096,minFontSize:1,maxFontSize:512,minDuration:.1,maxDuration:120,maxTextLength:1e4},ANIMATION_TYPES:["typewriter","fadeIn","slideIn","shift","ascend","movingLetters"]},Vt=/^#[A-Fa-f0-9]{6}$/,ja=N.object({type:N.string().valid("linear","radial").default("linear"),angle:N.number().min(0).max(360).default(0),stops:N.array().items(N.object({offset:N.number().min(0).max(1).required(),color:N.string().pattern(Vt).required()}).unknown(!1)).min(2).required()}).unknown(!1),Va=N.object({offsetX:N.number().default(0),offsetY:N.number().default(0),blur:N.number().min(0).default(0),color:N.string().pattern(Vt).default("#000000"),opacity:N.number().min(0).max(1).default(.5)}).unknown(!1),Wa=N.object({width:N.number().min(0).default(0),color:N.string().pattern(Vt).default("#000000"),opacity:N.number().min(0).max(1).default(1)}).unknown(!1),Ga=N.object({family:N.string().default(be.DEFAULTS.fontFamily),size:N.number().min(be.LIMITS.minFontSize).max(be.LIMITS.maxFontSize).default(be.DEFAULTS.fontSize),weight:N.alternatives().try(N.string(),N.number()).default("400"),style:N.string().valid("normal","italic","oblique").default("normal"),color:N.string().pattern(Vt).default(be.DEFAULTS.color),opacity:N.number().min(0).max(1).default(1)}).unknown(!1),Za=N.object({letterSpacing:N.number().default(0),lineHeight:N.number().min(0).max(10).default(1.2),textTransform:N.string().valid("none","uppercase","lowercase","capitalize").default("none"),textDecoration:N.string().valid("none","underline","line-through").default("none"),gradient:ja.optional()}).unknown(!1),Ka=N.object({horizontal:N.string().valid("left","center","right").default(be.DEFAULTS.textAlign),vertical:N.string().valid("top","middle","bottom").default("middle")}).unknown(!1),qa=N.object({preset:N.string().valid(...be.ANIMATION_TYPES),speed:N.number().min(.1).max(10).default(1),duration:N.number().min(be.LIMITS.minDuration).max(be.LIMITS.maxDuration).optional(),style:N.string().valid("character","word").optional().when("preset",{is:N.valid("typewriter","shift"),then:N.optional(),otherwise:N.forbidden()}),direction:N.string().optional().when("preset",{switch:[{is:"ascend",then:N.valid("up","down")},{is:"shift",then:N.valid("left","right","up","down")},{is:"slideIn",then:N.valid("left","right","up","down")},{is:"movingLetters",then:N.valid("left","right","up","down")}],otherwise:N.forbidden()})}).unknown(!1),Xa=N.object({color:N.string().pattern(Vt).optional(),opacity:N.number().min(0).max(1).default(1),borderRadius:N.number().min(0).default(0)}).unknown(!1),Ya=N.object({src:N.string().uri().required(),family:N.string().required(),weight:N.alternatives().try(N.string(),N.number()).optional(),style:N.string().optional(),originalFamily:N.string().optional()}).unknown(!1),Qa=N.object({type:N.string().valid("rich-text").required(),text:N.string().allow("").max(be.LIMITS.maxTextLength).default(""),width:N.number().min(be.LIMITS.minWidth).max(be.LIMITS.maxWidth).default(be.DEFAULTS.width).optional(),height:N.number().min(be.LIMITS.minHeight).max(be.LIMITS.maxHeight).default(be.DEFAULTS.height).optional(),font:Ga.optional(),style:Za.optional(),stroke:Wa.optional(),shadow:Va.optional(),background:Xa.optional(),align:Ka.optional(),animation:qa.optional(),customFonts:N.array().items(Ya).optional(),cacheEnabled:N.boolean().default(!0),pixelRatio:N.number().min(1).max(3).default(be.DEFAULTS.pixelRatio)}).unknown(!1),pi=null;async function Ja(s){if(pi)return pi;try{const t=(await Promise.resolve().then(()=>Yh)).default;let i;if(typeof t=="function"?i=await t():t&&typeof t.then=="function"?i=await t:i=t,!i||typeof i.createBuffer!="function"||typeof i.createFont!="function")throw new Error("Failed to initialize HarfBuzz: unexpected export shape from 'harfbuzzjs'.");return pi=i,pi}catch(e){throw new Error(`Failed to initialize HarfBuzz: ${e instanceof Error?e.message:String(e)}`)}}var er=class Ps{constructor(e){gt(this,"hb"),gt(this,"faces",new Map),gt(this,"fonts",new Map),gt(this,"blobs",new Map),gt(this,"wasmBaseURL"),gt(this,"initPromise"),this.wasmBaseURL=e}static setFallbackLoader(e){Ps.fallbackLoader=e}async init(){if(this.initPromise){await this.initPromise;return}if(!this.hb){this.initPromise=this._doInit();try{await this.initPromise}catch(e){throw new Error(`Failed to initialize FontRegistry: ${e instanceof Error?e.message:String(e)}`)}}}async _doInit(){try{this.hb=await Ja(this.wasmBaseURL)}catch(e){throw this.initPromise=void 0,e}}async getHB(){if(!this.hb)try{await this.init()}catch(e){throw new Error(`Failed to get HarfBuzz instance: ${e instanceof Error?e.message:String(e)}`)}return this.hb}key(e){return`${e.family}__${e.weight??"400"}__${e.style??"normal"}`}async registerFromBytes(e,t){try{this.hb||await this.init();const i=this.key(t);if(this.fonts.has(i))return;const r=this.hb.createBlob(e),n=this.hb.createFace(r,0),o=this.hb.createFont(n),a=n.upem||1e3;o.setScale(a,a),this.blobs.set(i,r),this.faces.set(i,n),this.fonts.set(i,o)}catch(i){throw new Error(`Failed to register font "${t.family}": ${i instanceof Error?i.message:String(i)}`)}}async tryFallbackInstall(e){const t=Ps.fallbackLoader;if(!t)return!1;try{const i=await t({family:e.family,weight:e.weight??"400",style:e.style??"normal"});return i?(await this.registerFromBytes(i,{family:e.family,weight:e.weight??"400",style:e.style??"normal"}),!0):!1}catch{return!1}}async getFont(e){try{this.hb||await this.init();const t=this.key(e);let i=this.fonts.get(t);if(i||(i=await this.tryFallbackInstall(e)?this.fonts.get(t):void 0),!i)throw new Error(`Font not registered for ${t}`);return i}catch(t){throw t instanceof Error&&t.message.includes("Font not registered")?t:new Error(`Failed to get font "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async getFace(e){try{this.hb||await this.init();const t=this.key(e);let i=this.faces.get(t);return i||(i=await this.tryFallbackInstall(e)?this.faces.get(t):void 0),i}catch(t){throw new Error(`Failed to get face for "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async getUnitsPerEm(e){try{return(await this.getFace(e))?.upem||1e3}catch(t){throw new Error(`Failed to get units per em for "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async glyphPath(e,t){try{const r=(await this.getFont(e)).glyphToPath(t);return r&&r!==""?r:"M 0 0"}catch(i){throw new Error(`Failed to get glyph path for glyph ${t} in font "${e.family}": ${i instanceof Error?i.message:String(i)}`)}}destroy(){try{for(const[,e]of this.fonts)try{e.destroy()}catch(t){console.error(`Error destroying font: ${t instanceof Error?t.message:String(t)}`)}for(const[,e]of this.faces)try{e.destroy()}catch(t){console.error(`Error destroying face: ${t instanceof Error?t.message:String(t)}`)}for(const[,e]of this.blobs)try{e.destroy()}catch(t){console.error(`Error destroying blob: ${t instanceof Error?t.message:String(t)}`)}this.fonts.clear(),this.faces.clear(),this.blobs.clear(),this.hb=void 0,this.initPromise=void 0}catch(e){console.error(`Error during FontRegistry cleanup: ${e instanceof Error?e.message:String(e)}`)}}};gt(er,"fallbackLoader");var tr=er,eo=class{constructor(s){this.fonts=s}transformText(s,e){switch(e){case"uppercase":return s.toUpperCase();case"lowercase":return s.toLowerCase();case"capitalize":return s.replace(/\b\w/g,t=>t.toUpperCase());default:return s}}async shapeFull(s,e){try{const t=await this.fonts.getHB(),i=t.createBuffer();try{i.addText(s),i.guessSegmentProperties();const r=await this.fonts.getFont(e),o=(await this.fonts.getFace(e))?.upem||1e3;return r.setScale(o,o),t.shape(r,i),i.json()}finally{try{i.destroy()}catch(r){console.error(`Error destroying HarfBuzz buffer: ${r instanceof Error?r.message:String(r)}`)}}}catch(t){throw new Error(`Failed to shape text with font "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async layout(s){try{const{textTransform:e,desc:t,fontSize:i,letterSpacing:r,width:n}=s,o=this.transformText(s.text,e);if(!o||o.length===0)return[];let a;try{a=await this.shapeFull(o,t)}catch(g){throw new Error(`Text shaping failed: ${g instanceof Error?g.message:String(g)}`)}let p;try{p=(await this.fonts.getFace(t))?.upem||1e3}catch(g){throw new Error(`Failed to get font metrics: ${g instanceof Error?g.message:String(g)}`)}const m=i/p,d=a.map(g=>{const y=g.cl;let v;return y>=0&&y<o.length&&(v=o[y]),{id:g.g,xAdvance:g.ax*m+r,xOffset:g.dx*m,yOffset:-g.dy*m,cluster:g.cl,char:v}}),l=[];let c=[],u=0;const h=new Set;for(let g=0;g<o.length;g++)o[g]===" "&&h.add(g);let f=-1;for(let g=0;g<d.length;g++){const y=d[g],v=y.xAdvance;if(y.char===`
183
- `){c.length>0&&l.push({glyphs:c,width:u,y:0}),c=[],u=0,f=g;continue}if(u+v>n&&c.length>0){if(f>-1){const _=f-(g-c.length)+1,C=c.splice(_),S=c.reduce((T,w)=>T+w.xAdvance,0);l.push({glyphs:c,width:S,y:0}),c=C,u=C.reduce((T,w)=>T+w.xAdvance,0)}else l.push({glyphs:c,width:u,y:0}),c=[],u=0;f=-1}c.push(y),u+=v,h.has(y.cluster)&&(f=g)}c.length>0&&l.push({glyphs:c,width:u,y:0});const b=s.lineHeight*i;for(let g=0;g<l.length;g++)l[g].y=(g+1)*b;return l}catch(e){throw e instanceof Error?e:new Error(`Layout failed: ${String(e)}`)}}};function to(s,e){return s.type==="linear"?{kind:"linear",angle:s.angle,stops:s.stops,opacity:e}:{kind:"radial",stops:s.stops,opacity:e}}function io(s,e){const t=Math.max(1,Math.round(e.fontSize*.05));let i=e.baselineY+Math.round(e.fontSize*.1);return s==="line-through"&&(i=e.baselineY-Math.round(e.fontSize*.3)),{x1:e.xStart,x2:e.xStart+e.lineWidth,y:i,width:t}}async function so(s){const e=[];if(e.push({op:"BeginFrame",width:s.canvas.width,height:s.canvas.height,pixelRatio:s.canvas.pixelRatio,clear:!0,bg:s.background?{color:s.background.color,opacity:s.background.opacity,radius:s.background.borderRadius}:void 0}),s.lines.length===0)return e;const t=Math.max(1,await s.getUnitsPerEm()),i=s.font.size/t,r=s.lines[s.lines.length-1].y;let n;switch(s.align.vertical){case"top":n=s.font.size;break;case"bottom":n=s.textRect.height-r+s.font.size;break;case"middle":default:n=(s.textRect.height-r)/2+s.font.size;break}const o=s.style.gradient?to(s.style.gradient,1):{kind:"solid",color:s.font.color,opacity:s.font.opacity},a=s.style.gradient?s.style.gradient.stops[s.style.gradient.stops.length-1]?.color??s.font.color:s.font.color;let p=1/0,m=1/0,d=-1/0,l=-1/0;for(const c of s.lines){let u;switch(s.align.horizontal){case"left":u=0;break;case"right":u=s.textRect.width-c.width;break;case"center":default:u=(s.textRect.width-c.width)/2;break}let h=u;const f=n+c.y-s.font.size;for(const b of c.glyphs){const g=await s.glyphPathProvider(b.id);if(!g||g==="M 0 0"){h+=b.xAdvance;continue}const y=h+b.xOffset,v=f+b.yOffset,_=no(g),C=y+i*_.x,S=y+i*(_.x+_.w),T=v-i*(_.y+_.h),w=v-i*_.y;C<p&&(p=C),T<m&&(m=T),S>d&&(d=S),w>l&&(l=w),s.shadow&&s.shadow.blur>0&&e.push({isShadow:!0,op:"FillPath",path:g,x:y+s.shadow.offsetX,y:v+s.shadow.offsetY,scale:i,fill:{kind:"solid",color:s.shadow.color,opacity:s.shadow.opacity}}),s.stroke&&s.stroke.width>0&&e.push({op:"StrokePath",path:g,x:y,y:v,scale:i,width:s.stroke.width,color:s.stroke.color,opacity:s.stroke.opacity}),e.push({op:"FillPath",path:g,x:y,y:v,scale:i,fill:o}),h+=b.xAdvance}if(s.style.textDecoration!=="none"){const b=io(s.style.textDecoration,{baselineY:f,fontSize:s.font.size,lineWidth:c.width,xStart:u});e.push({op:"DecorationLine",from:{x:b.x1,y:b.y},to:{x:b.x2,y:b.y},width:b.width,color:a,opacity:s.font.opacity})}}if(p!==1/0){const c={x:p,y:m,w:Math.max(1,d-p),h:Math.max(1,l-m)};for(const u of e)u.op==="FillPath"&&!u.isShadow&&(u.gradientBBox=c)}return e}function ro(s){return s.match(/[MLCQZ]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]}function no(s){const e=ro(s);let t=0,i=1/0,r=1/0,n=-1/0,o=-1/0;const a=(p,m)=>{p<i&&(i=p),m<r&&(r=m),p>n&&(n=p),m>o&&(o=m)};for(;t<e.length;)switch(e[t++]){case"M":case"L":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]);a(m,d);break}case"C":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]),l=parseFloat(e[t++]),c=parseFloat(e[t++]),u=parseFloat(e[t++]),h=parseFloat(e[t++]);a(m,d),a(l,c),a(u,h);break}case"Q":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]),l=parseFloat(e[t++]),c=parseFloat(e[t++]);a(m,d),a(l,c);break}}return i===1/0?{x:0,y:0,w:0,h:0}:{x:i,y:r,w:n-i,h:o-r}}var Vi=.999;function ao(s,e,t){if(!t.anim||!t.anim.preset)return s;const{preset:i}=t.anim,r=e.reduce((a,p)=>a+p.glyphs.length,0),n=t.anim.duration??Math.max(.3,r/30/t.anim.speed),o=Math.max(0,Math.min(1,t.t/n));switch(i){case"typewriter":return lo(s,e,o,t.anim.style,t.fontSize,t.t);case"fadeIn":return uo(s,o);case"slideIn":return fo(s,o,t.anim.direction??"left",t.fontSize);case"shift":return ho(s,e,o,t.anim.direction??"left",t.fontSize,t.anim.style,n);case"ascend":return co(s,e,o,t.anim.direction??"up",t.fontSize,n);case"movingLetters":return po(s,o,t.anim.direction??"up",t.fontSize);default:return s}}var mi=s=>s.op==="FillPath"&&s.isShadow===!0,ir=s=>s.op==="FillPath"&&!s.isShadow;function oo(s){for(const e of s)if(e.op==="FillPath"){const t=e.fill;if(t?.kind==="solid")return t.color;if((t?.kind==="linear"||t?.kind==="radial")&&Array.isArray(t.stops)&&t.stops.length)return t.stops[t.stops.length-1].color||"#000000"}return"#000000"}function lo(s,e,t,i,r,n,o){if(i==="word"){const p=Wi(e),m=p.length,d=Math.floor(t*m);if(d===0)return s.filter(h=>h.op==="BeginFrame");let l=0;for(let h=0;h<Math.min(d,p.length);h++)l+=p[h].glyphCount;const c=sr(s,l),u=t>=Vi?c:c.filter(h=>h.op!=="DecorationLine");return t<1&&l>0?rr(u,l,r,n):u}else{const p=e.reduce((c,u)=>c+u.glyphs.length,0),m=Math.floor(t*p);if(m===0)return s.filter(c=>c.op==="BeginFrame");const d=sr(s,m),l=t>=Vi?d:d.filter(c=>c.op!=="DecorationLine");return t<1&&m>0?rr(l,m,r,n):l}}function co(s,e,t,i,r,n){const o=Wi(e),a=o.length;if(a===0)return s;const p=[];let m=0;for(const d of s)if(d.op==="BeginFrame"){p.push(d);break}for(const d of s)if(d.op==="FillPath"||d.op==="StrokePath"){let l=-1,c=0;for(let u=0;u<o.length;u++){const h=o[u].glyphCount;if(m>=c&&m<c+h){l=u;break}c+=h}if(l>=0){const u=l/Math.max(1,a)*(n/n),h=Math.min(1,u+.3);if(t>=h)p.push(d);else if(t>u){const f=(t-u)/Math.max(1e-6,h-u),b=Gi(Math.min(1,f)),g=i==="up"?r*.4:-r*.4,y={...d,y:d.y+g*(1-b)};d.op==="FillPath"?y.fill.kind==="solid"?y.fill={...y.fill,opacity:y.fill.opacity*b}:y.fill={...y.fill,opacity:(y.fill.opacity??1)*b}:y.opacity=y.opacity*b,p.push(y)}}ir(d)&&m++}else d.op==="DecorationLine"&&t>=Vi&&p.push(d);return p}function ho(s,e,t,i,r,n,o){const a=n==="word",m={left:{x:r*.6,y:0},right:{x:-r*.6,y:0},up:{x:0,y:r*.6},down:{x:0,y:-r*.6}}[i],d=a?Wi(e):[],l=e.reduce((v,_)=>v+_.glyphs.length,0),c=a?d.length:l;if(c===0)return s;const u=[];for(const v of s)if(v.op==="BeginFrame"){u.push(v);break}const h=.3,b=o*.7/Math.max(1,c-1),g=v=>{const _=v*b,C=_/o,S=Math.min(1,(_+h)/o);return{startF:C,endF:S}};let y=0;for(const v of s){if(v.op!=="FillPath"&&v.op!=="StrokePath"){v.op==="DecorationLine"&&t>.8&&u.push(v);continue}let _;if(!a)_=y;else{let T=-1,w=0;for(let x=0;x<d.length;x++){const k=d[x].glyphCount;if(y>=w&&y<w+k){T=x;break}w+=k}_=Math.max(0,T)}const{startF:C,endF:S}=g(_);if(t<=C){const T={...v,x:v.x+m.x,y:v.y+m.y};v.op==="FillPath"?T.fill.kind==="solid"?T.fill={...T.fill,opacity:0}:T.fill={...T.fill,opacity:0}:T.opacity=0,u.push(T)}else if(t>=S)u.push(v);else{const T=(t-C)/Math.max(1e-6,S-C),w=Gi(Math.min(1,T)),x=m.x*(1-w),k=m.y*(1-w),E={...v,x:v.x+x,y:v.y+k};if(v.op==="FillPath"){const P=E.fill.kind==="solid"?E.fill.opacity:E.fill.opacity??1;E.fill.kind==="solid"?E.fill={...E.fill,opacity:P*w}:E.fill={...E.fill,opacity:P*w}}else E.opacity=E.opacity*w;u.push(E)}ir(v)&&y++}return u}function uo(s,e){const t=nr(e),i=.95+.05*t;return go(s,t,i)}function fo(s,e,t,i){const r=Gi(e),n=vo(1-r,t,i*2),o=nr(e);return yo(s,n.dx,n.dy,o)}function po(s,e,t,i){const r=i*.3;return bo(s,t,r,e)}function Wi(s){const e=[];let t=0;for(let i=0;i<s.length;i++){const r=s[i],n=mo(r);for(const o of n)o.length>0&&e.push({startGlyph:t,glyphCount:o.length,lineIndex:i}),t+=o.length}return e}function mo(s){const e=[];let t=[];for(const i of s.glyphs)i.char===" "||i.char===" "||i.char===`
184
- `?t.length&&(e.push([...t]),t=[]):t.push(i);return t.length&&e.push(t),e}function sr(s,e){const t=[];let i=0,r=!1;for(const n of s){if(n.op==="BeginFrame"){t.push(n);continue}if(n.op==="FillPath"&&!mi(n)){i<e&&(t.push(n),r=!0),i++;continue}if(n.op==="StrokePath"){i<e&&t.push(n);continue}if(n.op==="FillPath"&&mi(n)){i<e&&t.push(n);continue}if(n.op==="DecorationLine"&&r){t.push(n);continue}}return t}function rr(s,e,t,i){if(!(Math.floor(i*2*2)%2===0)||e===0)return s;let o=null,a=0;for(const p of s)if(p.op==="FillPath"&&!mi(p)&&(a++,a===e)){o=p;break}if(o&&o.op==="FillPath"){const p=oo(s),m=o.x+t*.5,d=o.y,l={op:"DecorationLine",from:{x:m,y:d-t*.7},to:{x:m,y:d+t*.1},width:Math.max(2,t/25),color:p,opacity:1};return[...s,l]}return s}function go(s,e,t){let i=0,r=0,n=0;return s.forEach(o=>{o.op==="FillPath"&&(i+=o.x,r+=o.y,n++)}),n>0&&(i/=n,r/=n),s.map(o=>{if(o.op==="FillPath"){const a={...o};if(a.fill.kind==="solid"?a.fill={...a.fill,opacity:a.fill.opacity*e}:a.fill={...a.fill,opacity:(a.fill.opacity??1)*e},t!==1&&n>0){const p=o.x-i,m=o.y-r;a.x=i+p*t,a.y=r+m*t}return a}if(o.op==="StrokePath"){const a={...o,opacity:o.opacity*e};if(t!==1&&n>0){const p=o.x-i,m=o.y-r;a.x=i+p*t,a.y=r+m*t}return a}return o.op==="DecorationLine"?{...o,opacity:o.opacity*e}:o})}function yo(s,e,t,i=1){return s.map(r=>{if(r.op==="FillPath"){const n={...r,x:r.x+e,y:r.y+t};return i<1&&(n.fill.kind==="solid"?n.fill={...n.fill,opacity:n.fill.opacity*i}:n.fill={...n.fill,opacity:(n.fill.opacity??1)*i}),n}return r.op==="StrokePath"?{...r,x:r.x+e,y:r.y+t,opacity:r.opacity*i}:r.op==="DecorationLine"?{...r,from:{x:r.from.x+e,y:r.from.y+t},to:{x:r.to.x+e,y:r.to.y+t},opacity:r.opacity*i}:r})}function bo(s,e,t,i){let r=0;return s.map(n=>{if(n.op==="FillPath"||n.op==="StrokePath"){const o=Math.sin(r/5*Math.PI+i*Math.PI*4),a=e==="left"||e==="right"?o*t*(e==="left"?-1:1):0,p=e==="up"||e==="down"?o*t*(e==="up"?-1:1):0,m=Math.min(1,i*2);if(n.op==="FillPath"){mi(n)||r++;const d={...n,x:n.x+a,y:n.y+p};return d.fill.kind==="solid"?d.fill={...d.fill,opacity:d.fill.opacity*m}:d.fill={...d.fill,opacity:(d.fill.opacity??1)*m},d}return{...n,x:n.x+a,y:n.y+p,opacity:n.opacity*m}}return n})}function vo(s,e,t){const i=s*t;switch(e){case"left":return{dx:-i,dy:0};case"right":return{dx:i,dy:0};case"up":return{dx:0,dy:-i};case"down":return{dx:0,dy:i}}}function nr(s){return s*(2-s)}function Gi(s){return 1-Math.pow(1-s,3)}function Wt(s,e=1){const t=/^#?([a-f0-9]{6})$/i.exec(s);if(!t)throw new Error(`Invalid color ${s}`);const i=parseInt(t[1],16),r=i>>16&255,n=i>>8&255,o=i&255;return{r,g:n,b:o,a:e}}function wo(s){const e=s.getContext("2d");if(!e)throw new Error("2D context unavailable");return{async render(t){const i=Co(t);for(const r of t){if(r.op==="BeginFrame"){const n=r.pixelRatio,o=r.width,a=r.height;if("width"in s&&"height"in s&&(s.width=Math.floor(o*n),s.height=Math.floor(a*n)),"style"in s&&(s.style.width=`${o}px`,s.style.height=`${a}px`),e.setTransform(n,0,0,n,0,0),r.clear&&e.clearRect(0,0,o,a),r.bg){const{color:p,opacity:m,radius:d}=r.bg;if(p){const l=Wt(p,m);e.fillStyle=`rgba(${l.r},${l.g},${l.b},${l.a})`,d&&d>0?(_o(e,0,0,o,a,d),e.fill()):e.fillRect(0,0,o,a)}}continue}if(r.op==="FillPath"){const n=r,o=new Path2D(n.path);e.save(),e.translate(n.x,n.y);const a=n.scale??1;e.scale(a,-a);const p=n.gradientBBox??i,m=xo(e,n.fill,p);e.fillStyle=m,e.fill(o),e.restore();continue}if(r.op==="StrokePath"){const n=r,o=new Path2D(n.path);e.save(),e.translate(n.x,n.y);const a=n.scale??1;e.scale(a,-a);const p=1/Math.abs(a),m=Wt(n.color,n.opacity);e.strokeStyle=`rgba(${m.r},${m.g},${m.b},${m.a})`,e.lineWidth=n.width*p,e.lineJoin="round",e.lineCap="round",e.stroke(o),e.restore();continue}if(r.op==="DecorationLine"){e.save();const n=Wt(r.color,r.opacity);e.strokeStyle=`rgba(${n.r},${n.g},${n.b},${n.a})`,e.lineWidth=r.width,e.beginPath(),e.moveTo(r.from.x,r.from.y),e.lineTo(r.to.x,r.to.y),e.stroke(),e.restore();continue}}}}}function _o(s,e,t,i,r,n){const o=new Path2D;o.moveTo(e+n,t),o.arcTo(e+i,t,e+i,t+r,n),o.arcTo(e+i,t+r,e,t+r,n),o.arcTo(e,t+r,e,t,n),o.arcTo(e,t,e+i,t,n),o.closePath(),s.save(),s.fill(o),s.restore()}function xo(s,e,t){if(e.kind==="solid"){const a=Wt(e.color,e.opacity);return`rgba(${a.r},${a.g},${a.b},${a.a})`}const i=t.x+t.w/2,r=t.y+t.h/2,n=Math.max(t.w,t.h)/2,o=a=>{const p=e.kind==="linear"||e.kind==="radial"?e.opacity:1,m=e.kind==="linear"||e.kind==="radial"?e.stops:[];for(const d of m){const l=Wt(d.color,p);a.addColorStop(d.offset,`rgba(${l.r},${l.g},${l.b},${l.a})`)}return a};if(e.kind==="linear"){const a=e.angle*Math.PI/180,p=i+Math.cos(a+Math.PI)*n,m=r+Math.sin(a+Math.PI)*n,d=i+Math.cos(a)*n,l=r+Math.sin(a)*n;return o(s.createLinearGradient(p,m,d,l))}else return o(s.createRadialGradient(i,r,0,i,r,n))}function Co(s){let e=1/0,t=1/0,i=-1/0,r=-1/0;for(const n of s){if(n.op!=="FillPath")continue;const o=n;if(o.isShadow)continue;const a=ko(o.path),p=o.scale??1,m=o.x+p*a.x,d=o.x+p*(a.x+a.w),l=o.y-p*(a.y+a.h),c=o.y-p*a.y;m<e&&(e=m),l<t&&(t=l),d>i&&(i=d),c>r&&(r=c)}return e===1/0?{x:0,y:0,w:1,h:1}:{x:e,y:t,w:Math.max(1,i-e),h:Math.max(1,r-t)}}function ko(s){const e=To(s);let t=0,i=1/0,r=1/0,n=-1/0,o=-1/0;const a=(p,m)=>{p<i&&(i=p),m<r&&(r=m),p>n&&(n=p),m>o&&(o=m)};for(;t<e.length;)switch(e[t++]){case"M":case"L":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]);a(m,d);break}case"C":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]),l=parseFloat(e[t++]),c=parseFloat(e[t++]),u=parseFloat(e[t++]),h=parseFloat(e[t++]);a(m,d),a(l,c),a(u,h);break}case"Q":{const m=parseFloat(e[t++]),d=parseFloat(e[t++]),l=parseFloat(e[t++]),c=parseFloat(e[t++]);a(m,d),a(l,c);break}}return i===1/0?{x:0,y:0,w:0,h:0}:{x:i,y:r,w:n-i,h:o-r}}function To(s){return s.match(/[MLCQZ]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]}async function Gt(s){try{const e=await fetch(s);if(!e.ok)throw new Error(`Failed to fetch ${s}: ${e.status} ${e.statusText}`);try{return await e.arrayBuffer()}catch(t){throw new Error(`Failed to read response body as ArrayBuffer from ${s}: ${t instanceof Error?t.message:String(t)}`)}}catch(e){throw e instanceof Error?e.message.includes("Failed to fetch")||e.message.includes("Failed to read")?e:new Error(`Failed to fetch ${s}: ${e.message}`):new Error(`Failed to fetch ${s}: ${String(e)}`)}}var ar="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxP.ttf";async function So(s={}){const e=s.width??be.DEFAULTS.width,t=s.height??be.DEFAULTS.height,i=s.pixelRatio??be.DEFAULTS.pixelRatio,r=s.wasmBaseURL,n=new tr(r),o=new eo(n);try{tr.setFallbackLoader(async p=>{const m=(p.family??"Roboto").toLowerCase(),d=`${p.weight??"400"}`,l=p.style??"normal";if(m==="roboto"&&d==="400"&&l==="normal")return Gt(ar)}),await n.init()}catch(p){throw new Error(`Failed to initialize font registry: ${p instanceof Error?p.message:String(p)}`)}async function a(p){try{if(p.customFonts)for(const c of p.customFonts)try{const u=await Gt(c.src);await n.registerFromBytes(u,{family:c.family,weight:c.weight??"400",style:c.style??"normal"})}catch(u){throw new Error(`Failed to load custom font "${c.family}" from ${c.src}: ${u instanceof Error?u.message:String(u)}`)}const m=p.font??{family:"Roboto",weight:"400",style:"normal",size:48,color:"#000000",opacity:1},d={family:m.family,weight:`${m.weight}`,style:m.style};return await(async()=>{try{await n.getFace(d)}catch{if((m.family||"Roboto").toLowerCase()==="roboto"&&`${m.weight}`=="400"&&m.style==="normal"){const u=await Gt(ar);await n.registerFromBytes(u,{family:"Roboto",weight:"400",style:"normal"})}else throw new Error(`Font not registered for ${d.family}__${d.weight}__${d.style}`)}})(),m}catch(m){throw m instanceof Error?m:new Error(`Failed to ensure fonts: ${String(m)}`)}}return{validate(p){try{const{value:m,error:d}=Qa.validate(p,{abortEarly:!1,convert:!0});if(d)throw d;return{value:m}}catch(m){throw m instanceof Error?new Error(`Validation failed: ${m.message}`):new Error(`Validation failed: ${String(m)}`)}},async registerFontFromUrl(p,m){try{const d=await Gt(p);await n.registerFromBytes(d,m)}catch(d){throw new Error(`Failed to register font "${m.family}" from URL ${p}: ${d instanceof Error?d.message:String(d)}`)}},async registerFontFromFile(p,m){try{let d;if(typeof p=="string")try{d=await Gt(p)}catch(l){throw new Error(`Failed to fetch font from ${p}: ${l instanceof Error?l.message:String(l)}`)}else try{d=await p.arrayBuffer()}catch(l){throw new Error(`Failed to read Blob as ArrayBuffer: ${l instanceof Error?l.message:String(l)}`)}await n.registerFromBytes(d,m)}catch(d){throw d instanceof Error?d:new Error(`Failed to register font "${m.family}" from ${typeof p=="string"?p:"Blob"}: ${String(d)}`)}},async renderFrame(p,m){try{const d=await a(p),l={family:d.family,weight:`${d.weight}`,style:d.style};let c;try{c=await o.layout({text:p.text,width:p.width??e,letterSpacing:p.style?.letterSpacing??0,fontSize:d.size,lineHeight:p.style?.lineHeight??1.2,desc:l,textTransform:p.style?.textTransform??"none"})}catch(y){throw new Error(`Failed to layout text: ${y instanceof Error?y.message:String(y)}`)}const u={x:0,y:0,width:p.width??e,height:p.height??t},h=p.width??e,f=p.height??t,b=p.pixelRatio??i;let g;try{g=await so({canvas:{width:h,height:f,pixelRatio:b},textRect:u,lines:c,font:{family:d.family,size:d.size,weight:`${d.weight}`,style:d.style,color:d.color,opacity:d.opacity},style:{lineHeight:p.style?.lineHeight??1.2,textDecoration:p.style?.textDecoration??"none",gradient:p.style?.gradient},stroke:p.stroke,shadow:p.shadow,align:p.align??{horizontal:"center",vertical:"middle"},background:p.background,glyphPathProvider:y=>n.glyphPath(l,y),getUnitsPerEm:()=>n.getUnitsPerEm(l)})}catch(y){throw new Error(`Failed to build draw operations: ${y instanceof Error?y.message:String(y)}`)}try{return ao(g,c,{t:m,fontSize:d.size,anim:p.animation?{preset:p.animation.preset,speed:p.animation.speed,duration:p.animation.duration,style:p.animation.style,direction:p.animation.direction}:void 0})}catch(y){throw new Error(`Failed to apply animation: ${y instanceof Error?y.message:String(y)}`)}}catch(d){throw d instanceof Error?d:new Error(`Failed to render frame at time ${m}s: ${String(d)}`)}},createRenderer(p){try{return wo(p)}catch(m){throw new Error(`Failed to create renderer: ${m instanceof Error?m.message:String(m)}`)}},destroy(){try{n.destroy()}catch(p){console.error(`Error during cleanup: ${p instanceof Error?p.message:String(p)}`)}}}}const or=s=>{const t=(s.split("/").pop()||"").replace(/\.(ttf|otf|woff|woff2)$/i,""),i=t.replace(/-(Bold|Light|Regular|Italic|Medium|SemiBold|Black|Thin|ExtraLight|ExtraBold|Heavy)$/i,"");return{full:t,base:i}};class Eo extends we{textEngine=null;renderer=null;canvas=null;texture=null;sprite=null;lastRenderedTime=-1;cachedFrames=new Map;isRendering=!1;targetFPS=30;validatedAsset=null;createFontMapping(){const e=new Map;return e.set("Arapey","/assets/fonts/Arapey-Regular.ttf"),e.set("ClearSans","/assets/fonts/ClearSans-Regular.ttf"),e.set("Clear Sans","/assets/fonts/ClearSans-Regular.ttf"),e.set("DidactGothic","/assets/fonts/DidactGothic-Regular.ttf"),e.set("Didact Gothic","/assets/fonts/DidactGothic-Regular.ttf"),e.set("Montserrat","/assets/fonts/Montserrat-SemiBold.ttf"),e.set("MovLette","/assets/fonts/MovLette.ttf"),e.set("OpenSans","/assets/fonts/OpenSans-Bold.ttf"),e.set("Open Sans","/assets/fonts/OpenSans-Bold.ttf"),e.set("PermanentMarker","/assets/fonts/PermanentMarker-Regular.ttf"),e.set("Permanent Marker","/assets/fonts/PermanentMarker-Regular.ttf"),e.set("Roboto","/assets/fonts/Roboto-BlackItalic.ttf"),e.set("SueEllenFrancisco","/assets/fonts/SueEllenFrancisco.ttf"),e.set("Sue Ellen Francisco","/assets/fonts/SueEllenFrancisco.ttf"),e.set("UniNeue","/assets/fonts/UniNeue-Bold.otf"),e.set("Uni Neue","/assets/fonts/UniNeue-Bold.otf"),e.set("WorkSans","/assets/fonts/WorkSans-Light.ttf"),e.set("Work Sans","/assets/fonts/WorkSans-Light.ttf"),e}async load(){await super.load();const e=this.clipConfiguration.asset;try{const t=this.edit.getEdit();if(this.targetFPS=t?.output?.fps||30,e.width=e.width||this.edit.size.width,e.height=e.height||this.edit.size.height,e.pixelRatio=e.pixelRatio||2,e.cacheEnabled=e.cacheEnabled??!0,Array.isArray(t?.timeline?.fonts)&&t.timeline.fonts.length>0){const a=e.font?.family;if(a){const p=t.timeline.fonts?.find(m=>{const{full:d,base:l}=or(m.src),c=a.toLowerCase();return d.toLowerCase()===c||l.toLowerCase()===c});p&&(e.customFonts=[{src:p.src,family:a,weight:e.font?.weight?.toString()||"400",style:e.font?.style||"normal"}])}}const i=fi.safeParse(e);if(!i.success){console.error("Rich-text asset validation failed:",i.error),this.createFallbackText(e);return}this.textEngine=await So({width:e.width,height:e.height,pixelRatio:e.pixelRatio,fps:this.targetFPS});const{value:r}=this.textEngine.validate(e);this.validatedAsset=r;const n=this.createFontMapping();this.canvas=document.createElement("canvas"),this.canvas.width=e.width*e.pixelRatio,this.canvas.height=e.height*e.pixelRatio,this.renderer=this.textEngine.createRenderer(this.canvas);const o=t?.timeline?.fonts||[];if(o.length>0){const a=e.font?.family;if(a){const p=o.find(m=>{const{full:d,base:l}=or(m.src),c=a.toLowerCase();return d.toLowerCase()===c||l.toLowerCase()===c});if(p)try{const m={family:a,weight:e.font?.weight?.toString()||"400",style:e.font?.style||"normal"};await this.textEngine.registerFontFromUrl(p.src,m)}catch(m){console.warn(`Failed to load font ${a}:`,m)}}}else if(e.font?.family){const a=e.font.family,p=n.get(a);if(p)try{const m={family:e.font.family,weight:e.font.weight||"400",style:e.font.style||"normal"};await this.textEngine.registerFontFromFile(p,m)}catch(m){console.warn(`Failed to load local font: ${a}`,m)}else console.warn(`Font ${a} not found in local assets. Available fonts:`,Array.from(n.keys()))}await this.renderFrame(0),this.configureKeyframes()}catch(t){console.error("Failed to initialize rich text player:",t),this.cleanupResources(),this.createFallbackText(e)}}cleanupResources(){if(this.textEngine){try{this.textEngine.destroy()}catch(e){console.warn("Error destroying text engine:",e)}this.textEngine=null}this.renderer=null,this.canvas=null,this.validatedAsset=null}async renderFrame(e){if(!this.textEngine||!this.renderer||!this.canvas||!this.validatedAsset)return;const t=Math.floor(e*this.targetFPS);if(this.validatedAsset.cacheEnabled&&this.cachedFrames.has(t)){const i=this.cachedFrames.get(t);this.sprite&&this.sprite.texture!==i&&(this.sprite.texture=i),this.lastRenderedTime=e;return}try{const i=await this.textEngine.renderFrame(this.validatedAsset,e),r=this.canvas.getContext("2d");r&&r.clearRect(0,0,this.canvas.width,this.canvas.height),await this.renderer.render(i);const n=R.Texture.from(this.canvas);this.sprite?(this.texture&&!this.cachedFrames.has(t)&&this.texture.destroy(),this.sprite.texture=n):(this.sprite=new R.Sprite(n),this.sprite.scale.set(1/this.validatedAsset.pixelRatio),this.contentContainer.addChild(this.sprite)),this.texture=n,this.validatedAsset.cacheEnabled&&this.cachedFrames.size<150&&this.cachedFrames.set(t,n),this.lastRenderedTime=e}catch(i){console.error("Failed to render rich text frame:",i)}}createFallbackText(e){const t=new R.TextStyle({fontFamily:e.font?.family||"Arial",fontSize:e.font?.size||48,fill:e.font?.color||"#ffffff",align:e.align?.horizontal||"center",wordWrap:!0,wordWrapWidth:e.width||this.edit.size.width}),i=new R.Text(e.text,t),r=e.width||this.edit.size.width,n=e.height||this.edit.size.height;switch(e.align?.horizontal){case"left":i.anchor.set(0,.5),i.x=0;break;case"right":i.anchor.set(1,.5),i.x=r;break;default:i.anchor.set(.5,.5),i.x=r/2}switch(e.align?.vertical){case"top":i.anchor.set(i.anchor.x,0),i.y=0;break;case"bottom":i.anchor.set(i.anchor.x,1),i.y=n;break;default:i.anchor.set(i.anchor.x,.5),i.y=n/2}this.contentContainer.addChild(i)}renderFrameSafe(e){this.isRendering||(this.isRendering=!0,this.renderFrame(e).catch(t=>console.error("Failed to render rich text frame:",t)).finally(()=>{this.isRendering=!1}))}update(e,t){if(super.update(e,t),this.textEngine&&this.renderer&&!this.isRendering){const i=this.getCurrentTime()/1e3,o=1/(this.edit.getEdit()?.output?.fps||30);Math.abs(i-this.lastRenderedTime)>o&&this.renderFrameSafe(i)}}dispose(){super.dispose();for(const e of this.cachedFrames.values())e.destroy();this.cachedFrames.clear(),this.texture&&!this.cachedFrames.has(Math.floor(this.lastRenderedTime*this.targetFPS))&&this.texture.destroy(),this.texture=null,this.sprite&&(this.sprite.destroy(),this.sprite=null),this.canvas&&(this.canvas=null),this.textEngine&&(this.textEngine.destroy(),this.textEngine=null),this.renderer=null,this.validatedAsset=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width||this.edit.size.width,height:e.height||this.edit.size.height}}getFitScale(){return 1}updateTextContent(e){const t=this.clipConfiguration.asset;if(t.text=e,this.textEngine){const{value:i}=this.textEngine.validate(t);this.validatedAsset=i}for(const i of this.cachedFrames.values())i.destroy();this.cachedFrames.clear(),this.lastRenderedTime=-1,this.textEngine&&this.renderer&&this.renderFrameSafe(this.getCurrentTime()/1e3)}getCurrentTime(){return this.edit.playbackTime}}class Ao extends we{shape;shapeBackground;constructor(e,t){super(e,t),this.shape=null,this.shapeBackground=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=new R.Graphics,i=e.width??this.edit.size.width,r=e.height??this.edit.size.height;t.fillStyle={color:"transparent"},t.rect(0,0,i,r),t.fill();const n=new R.Graphics;switch(e.shape){case"rectangle":{const o=e.rectangle,a=i/2-o.width/2,p=r/2-o.height/2;n.rect(a,p,o.width,o.height);break}case"circle":{const o=e.circle,a=i/2,p=r/2;n.circle(a,p,o.radius);break}case"line":{const o=e.line,a=i/2-o.length/2,p=r/2-o.thickness/2;n.rect(a,p,o.length,o.thickness);break}default:console.warn("Unsupported shape asset type.");break}if(n.fillStyle={color:e.fill?.color??"#ffffff",alpha:e.fill?.opacity??1},n.fill(),e.stroke){const o=new Fi({thickness:e.stroke.width,color:e.stroke.color});n.filters=[o]}this.shapeBackground=t,this.shape=n,this.contentContainer.addChild(t),t.addChild(n),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.shape?.destroy(),this.shape=null,this.shapeBackground?.destroy(),this.shapeBackground=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}}class Zt{static DEFAULT_BLINK_INTERVAL_MS=500;static DEFAULT_CURSOR_WIDTH_PX=2;static DEFAULT_CURSOR_COLOR=16777215;cursor=null;parent;textElement;clipConfig;textPosition=0;pixelX=0;pixelY=0;currentLine=0;isBlinking=!1;blinkInterval=null;blinkIntervalMs=500;width=2;color=16777215;isVisible=!0;constructor(e,t,i,r){this.parent=e,this.textElement=t,this.clipConfig=i,this.width=r?.width??Zt.DEFAULT_CURSOR_WIDTH_PX,this.color=r?.color??Zt.DEFAULT_CURSOR_COLOR,this.blinkIntervalMs=r?.blinkInterval??Zt.DEFAULT_BLINK_INTERVAL_MS,this.textPosition=0,this.isBlinking=!1,this.isVisible=!0,this.blinkInterval=null,this.createCursor()}updatePosition(e){if(!this.cursor||!this.textElement){console.warn("TextCursor: Cannot update position, cursor not initialized");return}this.textPosition=this.validateTextPosition(e),this.calculateAndApplyPixelPosition()}setPosition(e,t){if(!this.cursor){console.warn("TextCursor: Cannot set position, cursor not initialized");return}this.pixelX=e,this.pixelY=t,this.updateGraphicsPosition()}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}setVisible(e){this.isVisible=e,this.cursor&&!this.isBlinking&&(this.cursor.visible=e)}startBlinking(){if(!this.cursor){console.warn("TextCursor: Cannot start blinking, cursor not initialized");return}this.isBlinking||this.startBlinkingAnimation()}stopBlinking(){this.stopBlinkingAnimation()}setBlinkInterval(e){this.blinkIntervalMs=e,this.isBlinking&&(this.stopBlinking(),this.startBlinking())}dispose(){if(this.stopBlinkingAnimation(),this.cursor&&this.parent)try{this.parent.removeChild(this.cursor)}catch(e){console.warn("TextCursor: Error removing cursor from parent:",e)}if(this.cursor)try{this.cursor.destroy()}catch(e){console.warn("TextCursor: Error destroying cursor graphics:",e)}finally{this.cursor=null}this.textPosition=0,this.pixelX=0,this.pixelY=0,this.currentLine=0,this.isVisible=!0}createCursor(){if(!this.textElement)return;this.cursor=new R.Graphics,this.cursor.fillStyle={color:this.color};const e=this.textElement.style.fontSize;this.cursor.rect(0,0,this.width,e),this.cursor.fill(),this.parent.addChild(this.cursor),this.cursor.visible=this.isVisible}validateTextPosition(e){return this.textElement?Math.max(0,Math.min(e,this.textElement.text.length)):0}calculateAndApplyPixelPosition(){this.calculatePixelPositionFromText(),this.updateGraphicsPosition()}calculatePixelPositionFromText(){if(!this.textElement)return;const{text:e}=this.textElement,t=this.textElement.style,i=e.substring(0,this.textPosition),r=i.match(/\n/g);this.currentLine=r?r.length:0;const n=e.split(`
185
- `),o=this.currentLine<n.length?n[this.currentLine]:"",a=i.lastIndexOf(`
186
- `),p=a===-1?this.textPosition:this.textPosition-a-1,m=o.substring(0,p);let d;m.length>0&&m.endsWith(" ")?d=this.measureText(`${m}x`,t)-this.measureText("x",t):d=this.measureText(m,t);const l=t.lineHeight;this.pixelY=this.currentLine*l;const u=this.clipConfig.asset.alignment?.horizontal??"center";let h=d;if(u!=="left"){const f=this.measureText(o,t),b=this.textElement.width;let g=0;u==="center"?g=(b-f)/2:u==="right"&&(g=b-f),h=g+d}this.pixelX=h}updateGraphicsPosition(){this.cursor&&this.cursor.position.set(this.pixelX,this.pixelY)}startBlinkingAnimation(){!this.cursor||this.isBlinking||(this.isBlinking=!0,this.blinkInterval=window.setInterval(()=>{this.cursor&&this.isBlinking&&(this.cursor.visible=!this.cursor.visible)},this.blinkIntervalMs))}stopBlinkingAnimation(){this.blinkInterval!==null&&(window.clearInterval(this.blinkInterval),this.blinkInterval=null),this.isBlinking=!1,this.cursor&&(this.cursor.visible=this.isVisible)}measureText(e,t){const i=new R.Text(e,t),{width:r}=i;return i.destroy(),r}isInitialized(){return this.cursor!==null}getState(){return{isInitialized:this.isInitialized(),isBlinking:this.isBlinking,isVisible:this.isVisible,textPosition:this.textPosition,pixelPosition:{x:this.pixelX,y:this.pixelY},currentLine:this.currentLine}}}class gi{static DEFAULT_FOCUS_DELAY_MS=50;hiddenInput=null;isFocused=!1;focusRetryCount=0;maxFocusRetries=3;focusDelay=gi.DEFAULT_FOCUS_DELAY_MS;eventHandlers={};abortController=null;textChangeCallback=null;lastSyncedText="";isComposing=!1;setupInput(e,t){this.focusDelay=t?.focusDelay??gi.DEFAULT_FOCUS_DELAY_MS,this.createHiddenTextarea(),this.hiddenInput&&(this.hiddenInput.value=e,this.lastSyncedText=e),this.setupEventListeners(),t?.autoFocus!==!1&&this.focusInput()}updateInputValue(e){this.hiddenInput&&(this.hiddenInput.value=e,this.lastSyncedText=e)}focusInput(){this.hiddenInput&&setTimeout(()=>{this.hiddenInput&&!this.isFocused&&(this.hiddenInput.focus(),setTimeout(()=>{!this.isFocused&&this.focusRetryCount<this.maxFocusRetries&&(this.focusRetryCount+=1,this.focusInput())},10))},this.focusDelay)}blurInput(){this.hiddenInput&&this.hiddenInput.blur()}setSelectionRange(e,t){if(!this.hiddenInput)return;const i=this.hiddenInput.value.length,r=Math.max(0,Math.min(e,i)),n=Math.max(r,Math.min(t,i));this.hiddenInput.setSelectionRange(r,n)}getCursorPosition(){return this.hiddenInput?.selectionStart||0}getValue(){return this.hiddenInput?.value||""}setTextInputHandler(e){this.textChangeCallback=e}setEventHandlers(e){this.eventHandlers={...this.eventHandlers,...e}}isFocusedInput(){return this.isFocused}dispose(){this.removeAllEventListeners(),this.hiddenInput&&this.hiddenInput.parentNode&&this.hiddenInput.parentNode.removeChild(this.hiddenInput),this.hiddenInput=null,this.isFocused=!1,this.focusRetryCount=0,this.textChangeCallback=null,this.eventHandlers={}}createHiddenTextarea(){this.hiddenInput=document.createElement("textarea");const e={position:"absolute",opacity:"0.01",pointerEvents:"none",zIndex:"999",left:"0px",top:"0px",width:"1px",height:"1px",border:"none",outline:"none",resize:"none",backgroundColor:"transparent"};Object.assign(this.hiddenInput.style,e),this.hiddenInput.tabIndex=0,document.body.appendChild(this.hiddenInput)}setupEventListeners(){if(!this.hiddenInput)return;this.abortController=new AbortController;const{signal:e}=this.abortController;this.hiddenInput.addEventListener("input",this.handleTextInput,{signal:e}),this.hiddenInput.addEventListener("keydown",this.handleKeyDown,{signal:e}),this.hiddenInput.addEventListener("compositionstart",this.handleCompositionStart,{signal:e}),this.hiddenInput.addEventListener("compositionend",this.handleCompositionEnd,{signal:e}),this.hiddenInput.addEventListener("focus",this.handleFocus,{signal:e}),this.hiddenInput.addEventListener("blur",this.handleBlur,{signal:e}),this.hiddenInput.addEventListener("paste",this.handlePaste,{signal:e})}removeAllEventListeners(){this.abortController?.abort(),this.abortController=null}handleTextInput=e=>{if(!this.hiddenInput||this.isComposing)return;const t=this.hiddenInput.value,i=this.hiddenInput.selectionStart||0;this.lastSyncedText=t,this.textChangeCallback?.(t,i)};handleKeyDown=e=>{if(document.activeElement!==this.hiddenInput)return;let t=!1;if((e.ctrlKey||e.metaKey)&&(t=this.handleKeyboardShortcuts(e),t)){e.preventDefault();return}if(e.key==="Tab"){const i=e.shiftKey?"backward":"forward";this.eventHandlers.onTabNavigation?.(i),e.preventDefault();return}switch(e.key){case"Escape":this.eventHandlers.onEscape?.(e),t=!0;break;case"Enter":t=!1;break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":setTimeout(()=>{if(this.hiddenInput){const i=this.hiddenInput.value,r=this.hiddenInput.selectionStart||0;this.textChangeCallback?.(i,r)}},0),t=!1;break;case"Backspace":case"Delete":t=!1;break;default:t=this.eventHandlers.onCustomKey?.(e.key,e)||!1;break}t&&e.preventDefault()};handleKeyboardShortcuts(e){const{key:t}=e;switch(t.toLowerCase()){case"a":return this.selectAll(),!0;case"c":case"v":return!1;case"z":return this.eventHandlers.onCustomKey?.("undo",e),!0;case"y":return this.eventHandlers.onCustomKey?.("redo",e),!0;default:return!1}}handleCompositionStart=e=>{this.isComposing=!0};handleCompositionEnd=e=>{if(this.isComposing=!1,this.hiddenInput){const t=this.hiddenInput.value,i=this.hiddenInput.selectionStart||0;this.textChangeCallback?.(t,i)}};handleFocus=e=>{this.isFocused=!0,this.focusRetryCount=0,this.eventHandlers.onFocus?.(e)};handleBlur=e=>{this.isFocused=!1,this.eventHandlers.onBlur?.(e)};handlePaste=e=>{setTimeout(()=>{this.handleTextInput(e)},0)};selectAll(){this.hiddenInput&&this.hiddenInput.select()}}class De{static DOUBLE_CLICK_THRESHOLD_MS=300;static EDITING_BG_PADDING_PX=5;static EDITING_BG_ALPHA=.2;static CLICK_HANDLER_DELAY_MS=100;parent;targetText;clipConfig;isEditing=!1;lastClickTime=0;editingContainer=null;editableText=null;textCursor=null;textInputHandler=null;outsideClickHandler=null;constructor(e,t,i){this.parent=e,this.targetText=t,this.clipConfig=i,this.parent.getContainer().eventMode="static",this.parent.getContainer().on("click",this.checkForDoubleClick)}dispose(){this.parent.getContainer().off("click",this.checkForDoubleClick),this.stopEditing(),this.outsideClickHandler&&(window.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null)}startEditing(){if(this.isEditing||!this.targetText)return;const e=structuredClone(this.clipConfig);this.targetText.visible=!1,this.createEditingEnvironment(),this.setupOutsideClickHandler(e),this.isEditing=!0}stopEditing(e=!1,t){if(!this.isEditing)return;let i="";this.editableText&&(i=this.editableText.text),this.editingContainer&&(this.parent.getContainer().removeChild(this.editingContainer),this.editingContainer.destroy(),this.editingContainer=null),this.editableText=null,this.textCursor&&(this.textCursor.dispose(),this.textCursor=null),this.textInputHandler&&(this.textInputHandler.dispose(),this.textInputHandler=null),this.targetText.visible=!0,e&&t&&i!==""&&this.parent.updateTextContent(i,t),this.isEditing=!1}checkForDoubleClick=e=>{const t=Date.now();t-this.lastClickTime<De.DOUBLE_CLICK_THRESHOLD_MS&&this.startEditing(),this.lastClickTime=t};setupOutsideClickHandler(e){this.outsideClickHandler=t=>{const r=this.parent.getContainer().getBounds(),n=t.clientX,o=t.clientY;(n<r.x||n>r.x+r.width||o<r.y||o>r.y+r.height)&&(this.stopEditing(!0,e),this.outsideClickHandler&&(window.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null))},setTimeout(()=>{this.outsideClickHandler&&window.addEventListener("click",this.outsideClickHandler)},De.CLICK_HANDLER_DELAY_MS)}createEditingEnvironment(){this.setupEditingContainer(),this.editingContainer&&this.editableText&&(this.textCursor=new Zt(this.editingContainer,this.editableText,this.clipConfig),this.textCursor.updatePosition(this.targetText.text.length),this.textCursor.startBlinking()),this.setupTextInputHandler(),this.updateTextAlignment()}setupEditingContainer(){this.editingContainer=new R.Container,this.parent.getContainer().addChild(this.editingContainer);const e=new R.Graphics;e.fillStyle={color:0,alpha:De.EDITING_BG_ALPHA},e.rect(-5,-5,this.targetText.width+2*De.EDITING_BG_PADDING_PX,this.targetText.height+2*De.EDITING_BG_PADDING_PX),e.fill(),this.editingContainer.addChild(e),this.editableText=new R.Text(this.targetText.text,this.targetText.style),this.editableText.eventMode="static",this.editableText.cursor="text",this.editingContainer.addChild(this.editableText)}setupTextInputHandler(){this.textInputHandler=new gi,this.textInputHandler.setTextInputHandler((e,t)=>{this.editableText&&(this.editableText.text=e,this.updateTextAlignment()),this.textCursor?.updatePosition(t)}),this.textInputHandler.setEventHandlers({onEscape:e=>this.stopEditing(!1),onTabNavigation:e=>this.stopEditing(!0)}),this.textInputHandler.setupInput(this.targetText.text,{autoFocus:!0})}updateTextAlignment(){if(!this.editableText||!this.editingContainer)return;const e=this.getContainerDimensions(),t=this.getAlignmentSettings(),i=this.calculateHorizontalPosition({width:this.editableText.width},e,t.horizontal),r=this.calculateVerticalPosition({height:this.editableText.height},e,t.vertical);if(this.editingContainer.position.set(i,r),this.editingContainer.children.length>0){const n=this.editingContainer.getChildAt(0);n instanceof R.Graphics&&(n.clear(),n.fillStyle={color:0,alpha:De.EDITING_BG_ALPHA},n.rect(-5,-5,this.editableText.width+2*De.EDITING_BG_PADDING_PX,this.editableText.height+2*De.EDITING_BG_PADDING_PX),n.fill())}}calculateHorizontalPosition(e,t,i="center"){switch(i){case"center":return t.width/2-e.width/2;case"right":return t.width-e.width;case"left":default:return 0}}calculateVerticalPosition(e,t,i="center"){switch(i){case"center":return t.height/2-e.height/2;case"bottom":return t.height-e.height;case"top":default:return 0}}getContainerDimensions(){const e=this.clipConfig.asset;return{width:e.width??this.parent.getSize().width,height:e.height??this.parent.getSize().height}}getAlignmentSettings(){const e=this.clipConfig.asset;return{horizontal:e.alignment?.horizontal??"center",vertical:e.alignment?.vertical??"center"}}}class Io extends we{background=null;text=null;textEditor=null;async load(){await super.load();const e=this.clipConfiguration.asset;if(this.background=new R.Graphics,e.background&&(this.background.fillStyle={color:e.background.color,alpha:e.background.opacity},this.background.rect(0,0,e.width??this.edit.size.width,e.height??this.edit.size.height),this.background.fill()),this.text=new R.Text(e.text,this.createTextStyle(e)),this.positionText(e),e.stroke){const t=new Fi({thickness:e.stroke.width,color:e.stroke.color});this.text.filters=[t]}this.contentContainer.addChild(this.background),this.contentContainer.addChild(this.text),this.configureKeyframes(),this.textEditor=new De(this,this.text,this.clipConfiguration)}update(e,t){super.update(e,t)}dispose(){super.dispose(),this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null,this.textEditor?.dispose(),this.textEditor=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}createTextStyle(e){return new R.TextStyle({fontFamily:e.font?.family??"Open Sans",fontSize:e.font?.size??32,fill:e.font?.color??"#ffffff",fontWeight:(e.font?.weight??"400").toString(),wordWrap:!0,wordWrapWidth:e.width??this.edit.size.width,lineHeight:(e.font?.lineHeight??1)*(e.font?.size??32),align:e.alignment?.horizontal??"center"})}positionText(e){if(!this.text)return;const t=e.alignment?.horizontal??"center",i=e.alignment?.vertical??"center",r=e.width??this.edit.size.width,n=e.height??this.edit.size.height;let o=r/2-this.text.width/2,a=n/2-this.text.height/2;t==="left"?o=0:t==="right"&&(o=r-this.text.width),i==="top"?a=0:i==="bottom"&&(a=n-this.text.height),this.text.position.set(o,a)}updateTextContent(e,t){this.edit.updateTextContent(this,e,t)}}class Po extends we{texture;sprite;isPlaying;originalSize;volumeKeyframeBuilder;syncTimer;skipVideoUpdate;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.isPlaying=!1,this.originalSize=null;const i=this.clipConfiguration.asset;this.volumeKeyframeBuilder=new ke(i.volume??1,this.getLength()),this.syncTimer=0,this.skipVideoUpdate=!1}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src;if(t.endsWith(".mov")||t.endsWith(".webm"))throw new Error(`Video source '${e.src}' is not supported. .mov and .webm files are currently not supported.`);const i={src:t,data:{autoPlay:!1,muted:!1}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof R.VideoSource))throw new Error(`Invalid video source '${e.src}'.`);this.texture=this.createCroppedTexture(r),this.sprite=new R.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.configureKeyframes()}update(e,t){if(super.update(e,t),this.skipVideoUpdate)return;const{trim:i=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,!this.texture)return;const r=this.getPlaybackTime(),n=this.edit.isPlaying&&this.isActive();n&&(this.isPlaying||(this.isPlaying=!0,this.texture.source.resource.currentTime=r/1e3+i,this.texture.source.resource.play().catch(console.error)),this.texture.source.resource.volume!==this.getVolume()&&(this.texture.source.resource.volume=this.getVolume()),Math.abs((this.texture.source.resource.currentTime-i)*1e3-r)>100&&(this.texture.source.resource.currentTime=r/1e3+i)),!n&&this.isPlaying&&(this.isPlaying=!1,this.texture.source.resource.pause());const o=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&o&&(this.syncTimer=0,this.texture.source.resource.currentTime=r/1e3+i)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null,this.originalSize=null}getSize(){return this.clipConfiguration.width&&this.clipConfiguration.height?{width:this.clipConfiguration.width,height:this.clipConfiguration.height}:{width:this.sprite?.width??0,height:this.sprite?.height??0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}createCroppedTexture(e){const t=this.clipConfiguration.asset;if(!t.crop)return e;const i=e.width,r=e.height,n=Math.floor((t.crop?.left??0)*i),o=Math.floor((t.crop?.right??0)*i),a=Math.floor((t.crop?.top??0)*r),p=Math.floor((t.crop?.bottom??0)*r),m=n,d=a,l=i-n-o,c=r-a-p,u=new R.Rectangle(m,d,l,c);return new R.Texture({source:e.source,frame:u})}}const lr=_e(["linear","bezier","constant"]),cr=_e(["ease","easeIn","easeOut","easeInOut","easeInQuad","easeInCubic","easeInQuart","easeInQuint","easeInSine","easeInExpo","easeInCirc","easeInBack","easeOutQuad","easeOutCubic","easeOutQuart","easeOutQuint","easeOutSine","easeOutExpo","easeOutCirc","easeOutBack","easeInOutQuad","easeInOutCubic","easeInOutQuart","easeInOutQuint","easeInOutSine","easeInOutExpo","easeInOutCirc","easeInOutBack"]),at=te({from:D(),to:D(),start:D().min(0),length:D().positive(),interpolation:lr.optional(),easing:cr.optional()}),hr=pe().url("Invalid audio url format."),ur=at.extend({from:D().min(0).max(1),to:D().min(0).max(1)}).array().or(D().min(0).max(1)),Zi=te({type:nt("audio"),src:hr,trim:D().optional(),volume:ur.optional()}),Ro=_e(["top","topRight","right","bottomRight","bottom","bottomLeft","left","topLeft","center"]),Ki=te({type:nt("html"),html:pe(),css:pe(),width:D().positive().optional(),height:D().positive().optional(),position:Ro.optional()}),dr=pe().url("Invalid image url format."),fr=te({top:D().min(0).optional(),right:D().min(0).optional(),bottom:D().min(0).optional(),left:D().min(0).optional()}),qi=te({type:nt("image"),src:dr,crop:fr.optional()}),pr=pe().url("Invalid luma url format."),Xi=te({type:nt("luma"),src:pr}),Yi=pe().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/,"Invalid color format."),Qi=te({width:D().positive(),height:D().positive()}),Ji=te({radius:D().positive()}),es=te({length:D().positive(),thickness:D().positive()}),mr=te({color:Yi,opacity:D().min(0).max(1)}),gr=te({color:Yi,width:D().positive()}),ts=te({type:nt("shape"),width:D().positive().optional(),height:D().positive().optional(),shape:_e(["rectangle","circle","line"]),fill:mr.optional(),stroke:gr.optional(),rectangle:Qi.optional(),circle:Ji.optional(),line:es.optional()}).refine(s=>s.shape==="rectangle"?Qi.safeParse(s.rectangle):s.shape==="circle"?Ji.safeParse(s.circle):s.shape==="line"?es.safeParse(s.line):!1),yi=pe().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/,"Invalid color format."),yr=te({color:yi.optional(),family:pe().optional(),size:D().positive().optional(),weight:D().optional(),lineHeight:D().optional()}),br=te({horizontal:_e(["left","center","right"]).optional(),vertical:_e(["top","center","bottom"]).optional()}),vr=te({color:yi,opacity:D().min(0).max(1)}),wr=te({width:D().positive(),color:yi}),is=te({type:nt("text"),text:pe(),width:D().positive().optional(),height:D().positive().optional(),font:yr.optional(),alignment:br.optional(),background:vr.optional(),stroke:wr.optional()}),_r=pe().url("Invalid video url format."),xr=te({top:D().min(0).optional(),right:D().min(0).optional(),bottom:D().min(0).optional(),left:D().min(0).optional()}),Cr=at.extend({from:D().min(0).max(1),to:D().min(0).max(1)}).array().or(D().min(0).max(1)),ss=te({type:nt("video"),src:_r,trim:D().optional(),crop:xr.optional(),volume:Cr.optional()}),kr=ji([is,fi,ts,Ki,qi,ss,Xi,Zi]).refine(s=>s.type==="text"?is.safeParse(s):s.type==="rich-text"?fi.safeParse(s):s.type==="shape"?ts.safeParse(s):s.type==="html"?Ki.safeParse(s):s.type==="image"?qi.safeParse(s):s.type==="video"?ss.safeParse(s):s.type==="luma"?Xi.safeParse(s):s.type==="audio"?Zi.safeParse(s):!1),Oo=_e(["topLeft","top","topRight","left","center","right","bottomLeft","bottom","bottomRight"]),Fo=_e(["crop","cover","contain","none"]),Rt=D().min(-10).max(10).default(0),Mo=at.extend({from:Rt,to:Rt}).array().or(Rt),Lo=at.extend({from:Rt,to:Rt}).array().or(Rt),Bo=te({x:Mo.default(0),y:Lo.default(0)}),$o=at.extend({from:D().min(0).max(1),to:D().min(0).max(1)}).array().or(D().min(0).max(1)),Do=at.extend({from:D().min(0),to:D().min(0)}).array().or(D().min(0)),zo=te({angle:at.extend({from:D(),to:D()}).array().or(D())}),Ho=pe(),Tr=pe(),No=te({in:Tr.optional(),out:Tr.optional()}),Uo=te({rotate:zo.default({angle:0})}),rs=te({asset:kr,start:D().min(0),length:D().positive(),position:Oo.default("center").optional(),fit:Fo.optional(),offset:Bo.default({x:0,y:0}).optional(),opacity:$o.default(1).optional(),scale:Do.default(1).optional(),transform:Uo.default({rotate:{angle:0}}).optional(),effect:Ho.optional(),transition:No.optional(),width:D().min(1).max(3840).optional(),height:D().min(1).max(2160).optional()}).transform(s=>{if(s.fit!==void 0)return s;const e=s.asset.type==="rich-text"?"none":"crop";return{...s,fit:e}});class jo{constructor(e,t){this.trackIdx=e,this.clip=t}name="addClip";addedPlayer;async execute(e){if(!e)return;const t=rs.parse(this.clip),i=e.createPlayerFromAssetType(t);i.layer=this.trackIdx+1,await e.addPlayer(this.trackIdx,i),e.updateDuration(),this.addedPlayer=i}async undo(e){!e||!this.addedPlayer||(e.queueDisposeClip(this.addedPlayer),e.updateDuration())}}class Sr{constructor(e){this.trackIdx=e}name="addTrack";execute(e){if(!e)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,0,[]),i.forEach(r=>{if(r.layer>=this.trackIdx){const n=1e5-r.layer*100,o=e.getContainer().getChildByLabel(`shotstack-track-${n}`,!1);o&&o.removeChild(r.getContainer()),r.layer+=1;const a=1e5-r.layer*100;let p=e.getContainer().getChildByLabel(`shotstack-track-${a}`,!1);p||(p=new R.Container({label:`shotstack-track-${a}`,zIndex:a}),e.getContainer().addChild(p)),p.addChild(r.getContainer())}}),e.updateDuration(),e.emitEvent("track:added",{trackIndex:this.trackIdx,totalTracks:t.length})}undo(e){if(!e)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,1),i.forEach(r=>{r.layer>this.trackIdx&&(r.layer-=1)}),e.updateDuration()}}class Vo{name="ClearSelection";previousSelection=null;execute(e){const t=e.getSelectedClip();if(t){const i=e.findClipIndices(t);i&&(this.previousSelection={player:t,trackIndex:i.trackIndex,clipIndex:i.clipIndex})}e.setSelectedClip(null),e.emitEvent("selection:cleared",{})}undo(e){if(this.previousSelection){const t=e.getClipAt(this.previousSelection.trackIndex,this.previousSelection.clipIndex);t&&(e.setSelectedClip(t),e.emitEvent("clip:selected",{clip:t.clipConfiguration,trackIndex:this.previousSelection.trackIndex,clipIndex:this.previousSelection.clipIndex}))}}}class Wo{constructor(e,t){this.trackIdx=e,this.clipIdx=t}name="deleteClip";deletedClip;execute(e){if(!e)return;const i=e.getClips().filter(r=>r.layer===this.trackIdx+1);this.deletedClip=i[this.clipIdx],this.deletedClip&&(e.queueDisposeClip(this.deletedClip),e.updateDuration())}undo(e){!e||!this.deletedClip||e.undeleteClip(this.trackIdx,this.deletedClip)}}class Go{constructor(e){this.trackIdx=e}name="deleteTrack";deletedClips=[];execute(e){if(!e)return;const t=e.getClips(),i=e.getTracks();this.deletedClips=t.filter(o=>o.layer===this.trackIdx+1).map(o=>({config:structuredClone(o.clipConfiguration)})),t.forEach((o,a)=>{o.layer===this.trackIdx+1&&(t[a].shouldDispose=!0)}),e.disposeClips(),i.splice(this.trackIdx,1);const r=e.getClips(),n=e.getContainer();r.forEach((o,a)=>{if(o.layer>this.trackIdx+1){n.getChildByLabel(`shotstack-track-${1e5-o.layer*100}`,!1)?.removeChild(o.getContainer()),r[a].layer-=1;const m=1e5-r[a].layer*100;let d=n.getChildByLabel(`shotstack-track-${m}`,!1);d||(d=new R.Container({label:`shotstack-track-${m}`,zIndex:m}),n.addChild(d)),d.addChild(r[a].getContainer())}}),e.updateDuration()}async undo(e){if(!e||this.deletedClips.length===0)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,0,[]),i.forEach((r,n)=>{r.layer>=this.trackIdx+1&&(i[n].layer+=1)});for(const{config:r}of this.deletedClips){const n=e.createPlayerFromAssetType(r);n.layer=this.trackIdx+1,await e.addPlayer(this.trackIdx,n)}e.updateDuration()}}class Zo{constructor(e,t){this.trackIndex=e,this.clipIndex=t}name="SelectClip";previousSelection=null;execute(e){const t=e.getSelectedClip();if(t){const r=e.findClipIndices(t);r&&(this.previousSelection=r)}const i=e.getClipAt(this.trackIndex,this.clipIndex);i&&(e.setSelectedClip(i),e.emitEvent("clip:selected",{clip:i.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}))}undo(e){if(e.setSelectedClip(null),this.previousSelection){const t=e.getClipAt(this.previousSelection.trackIndex,this.previousSelection.clipIndex);t&&(e.setSelectedClip(t),e.emitEvent("clip:selected",{clip:t.clipConfiguration,trackIndex:this.previousSelection.trackIndex,clipIndex:this.previousSelection.clipIndex}))}else e.emitEvent("selection:cleared",{})}}class Ko{constructor(e,t,i){this.clip=e,this.initialClipConfig=t,this.finalClipConfig=i,this.storedInitialConfig=t?structuredClone(t):null,this.storedFinalConfig=i?structuredClone(i):structuredClone(this.clip.clipConfiguration)}name="setUpdatedClip";storedInitialConfig;storedFinalConfig;execute(e){if(!e)return;this.storedFinalConfig&&e.restoreClipConfiguration(this.clip,this.storedFinalConfig),e.setUpdatedClip(this.clip);const t=this.clip.layer-1,n=e.getClips().filter(o=>o.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.storedInitialConfig||this.initialClipConfig,trackIndex:t,clipIndex:n},current:{clip:this.storedFinalConfig||this.clip.clipConfiguration,trackIndex:t,clipIndex:n}})}undo(e){if(!e||!this.storedInitialConfig)return;e.restoreClipConfiguration(this.clip,this.storedInitialConfig),e.setUpdatedClip(this.clip);const t=this.clip.layer-1,n=e.getClips().filter(o=>o.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.storedFinalConfig,trackIndex:t,clipIndex:n},current:{clip:this.storedInitialConfig,trackIndex:t,clipIndex:n}})}}class qo{constructor(e,t,i){this.trackIndex=e,this.clipIndex=t,this.splitTime=i}name="SplitClip";originalClipConfig=null;rightClipPlayer=null;splitSuccessful=!1;execute(e){const t=e.getClipAt(this.trackIndex,this.clipIndex);if(!t||!t.clipConfiguration)throw new Error("Cannot split clip: invalid player or clip configuration");const i=t.clipConfiguration,r=i.start||0,n=i.length,o=.1,a=this.splitTime-r;if(a<=o||a>=n-o)throw new Error("Cannot split clip: split point too close to clip boundaries");this.originalClipConfig={...i};const p={...i,length:a},m={...i,start:r+a,length:n-a};if(i.asset&&(p.asset={...i.asset},m.asset={...i.asset}),i.asset&&(i.asset.type==="video"||i.asset.type==="audio")){const u=i.asset.trim||0;p.asset&&(p.asset.type==="video"||p.asset.type==="audio")&&(p.asset.trim=u),m.asset&&(m.asset.type==="video"||m.asset.type==="audio")&&(m.asset.trim=u+a)}if(Object.assign(t.clipConfiguration,p),t.reconfigureAfterRestore(),t.draw(),this.rightClipPlayer=e.createPlayerFromAssetType(m),!this.rightClipPlayer)throw Object.assign(t.clipConfiguration,this.originalClipConfig),t.reconfigureAfterRestore(),new Error("Failed to create right clip player");this.rightClipPlayer.layer=this.trackIndex+1;const d=e.getTrack(this.trackIndex);if(!d)throw new Error("Invalid track index");d.splice(this.clipIndex+1,0,this.rightClipPlayer);const l=e.getClips(),c=l.indexOf(t);c!==-1&&l.splice(c+1,0,this.rightClipPlayer),e.addPlayerToContainer(this.trackIndex,this.rightClipPlayer),this.rightClipPlayer.reconfigureAfterRestore(),this.rightClipPlayer.load().then(()=>{this.splitSuccessful=!0,this.rightClipPlayer&&this.rightClipPlayer.draw(),e.updateDuration(),e.emitEvent("timeline:updated",{current:e.getEditState()})}).catch(u=>{console.error("Failed to load split clip:",u)})}undo(e){if(!this.originalClipConfig)return;const t=e.getClipAt(this.trackIndex,this.clipIndex);if(t){if(Object.assign(t.clipConfiguration,this.originalClipConfig),t.reconfigureAfterRestore(),this.rightClipPlayer){const i=e.getTrack(this.trackIndex);if(i){const o=i.indexOf(this.rightClipPlayer);o!==-1&&i.splice(o,1)}const r=e.getClips(),n=r.indexOf(this.rightClipPlayer);n!==-1&&r.splice(n,1),e.queueDisposeClip(this.rightClipPlayer),this.rightClipPlayer=null}e.updateDuration(),e.emitEvent("timeline:updated",{current:e.getEditState()})}}}class Xo{constructor(e,t,i){this.clip=e,this.newText=t,this.initialConfig=i;const{asset:r}=this.clip.clipConfiguration;this.previousText=r&&"text"in r?r.text:""}name="updateTextContent";previousText;execute(e){if(e&&this.clip.clipConfiguration.asset&&"text"in this.clip.clipConfiguration.asset){this.clip.clipConfiguration.asset.text=this.newText;const t=this.clip.text;t&&(t.text=this.newText,this.clip.positionText(this.clip.clipConfiguration.asset)),e.setUpdatedClip(this.clip);const i=this.clip.layer-1,o=e.getClips().filter(a=>a.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.initialConfig,trackIndex:i,clipIndex:o},current:{clip:this.clip.clipConfiguration,trackIndex:i,clipIndex:o}})}}undo(e){if(e&&this.clip.clipConfiguration.asset&&"text"in this.clip.clipConfiguration.asset){this.clip.clipConfiguration.asset.text=this.previousText;const t=this.clip.text;t&&(t.text=this.previousText,this.clip.positionText(this.clip.clipConfiguration.asset)),e.setUpdatedClip(this.clip);const i=this.clip.layer-1,o=e.getClips().filter(a=>a.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.clip.clipConfiguration,trackIndex:i,clipIndex:o},current:{clip:this.initialConfig,trackIndex:i,clipIndex:o}})}}}class Kt{events;constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=new Set),this.events[e].add(t)}off(e,t){this.events[e]&&(this.events[e].delete(t),!(this.events[e].size>0)&&delete this.events[e])}clear(e){delete this.events[e]}emit(e,t){if(this.events[e])for(const i of this.events[e])i(t)}}class Yo extends Kt{registry;constructor(){super(),this.registry={}}}class bi{static VIDEO_EXTENSIONS=[".mp4",".m4v",".webm",".ogg",".ogv"];static VIDEO_MIME={".mp4":"video/mp4",".m4v":"video/mp4",".webm":"video/webm",".ogg":"video/ogg",".ogv":"video/ogg"};loadTracker=new Yo;async load(e,t){this.updateAssetLoadMetadata(e,"pending",0);try{if(await this.shouldUseSafariVideoLoader(t))return await this.loadVideoForSafari(e,t);const i=await R.Assets.load(t,r=>{this.updateAssetLoadMetadata(e,"loading",r)});return this.updateAssetLoadMetadata(e,"success",1),i}catch{return this.updateAssetLoadMetadata(e,"failed",1),null}}getProgress(){const e=Object.keys(this.loadTracker.registry);return e.length===0?0:e.reduce((i,r)=>i+this.loadTracker.registry[r].progress,0)/e.length}extractUrl(e){if(typeof e=="string")return e;const t=Array.isArray(e.src)?e.src[0]:e.src;return typeof t=="string"?t:t?.src}hasVideoExtension(e){const t=new URL(e,window.location.origin).pathname.toLowerCase();return bi.VIDEO_EXTENSIONS.some(i=>t.endsWith(i))}async getContentType(e){try{return(await fetch(e,{method:"HEAD"})).headers.get("content-type")}catch{return null}}canPlayVideo(e){const t=new URL(e,window.location.origin).pathname.toLowerCase(),i=t.slice(t.lastIndexOf(".")),r=bi.VIDEO_MIME[i];return r?document.createElement("video").canPlayType(r)!=="":!1}async isPlayableVideo(e){if(this.hasVideoExtension(e))return this.canPlayVideo(e);const t=await this.getContentType(e);return t?.startsWith("video/")?document.createElement("video").canPlayType(t)!=="":!1}async shouldUseSafariVideoLoader(e){const t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=this.extractUrl(e);return t&&i!==void 0&&await this.isPlayableVideo(i)}async loadVideoForSafari(e,t){const i=this.extractUrl(t),r=typeof t=="object"?t.data??{}:{},n=await new Promise((o,a)=>{const p=document.createElement("video");p.crossOrigin="anonymous",p.playsInline=!0,p.muted=!0,p.preload="metadata",p.addEventListener("loadedmetadata",()=>{try{const m=new R.VideoSource({resource:p,autoPlay:r.autoPlay??!1,...r});o(new R.Texture({source:m}))}catch(m){a(m)}},{once:!0}),p.addEventListener("error",()=>a(new Error("Video loading failed")),{once:!0}),this.updateAssetLoadMetadata(e,"loading",.5),p.src=i});return this.updateAssetLoadMetadata(e,"success",1),n}updateAssetLoadMetadata(e,t,i){this.loadTracker.registry[e]?(this.loadTracker.registry[e].progress=i,this.loadTracker.registry[e].status=t):this.loadTracker.registry[e]={progress:i,status:t};const r={...this.loadTracker.registry};this.loadTracker.emit("onAssetLoadInfoUpdated",{registry:r})}}class qt{static Name="FontLoadParser";id;name;extension;validFontExtensions;woff2Decompressor;constructor(){this.id=qt.Name,this.name=qt.Name,this.extension={type:[R.ExtensionType.LoadParser],priority:R.LoaderParserPriority.High,ref:null},this.validFontExtensions=["ttf","otf","woff","woff2"],this.woff2Decompressor=null}test(e){const t=e.split("?")[0]?.split(".").pop()?.toLowerCase()??"";return this.validFontExtensions.includes(t)}async load(e,t,i){const r=e.split("?")[0]?.split(".").pop()?.toLowerCase()??"",n=await fetch(e).then(c=>c.arrayBuffer());if(r!=="woff2"){const c=Rs.parse(new Uint8Array(n).buffer),u=c.names.fontFamily.en||c.names.fontFamily[Object.keys(c.names.fontFamily)[0]],h=new FontFace(u,`url(${e})`);return await h.load(),document.fonts.add(h),h}if(await this.loadWoff2Decompressor(),!this.woff2Decompressor)throw new Error("Cannot initialize Woff2 decompressor.");const o=this.woff2Decompressor.decompress(n),a=Rs.parse(new Uint8Array(o).buffer),p=a.names.fontFamily.en||a.names.fontFamily[Object.keys(a.names.fontFamily)[0]],m=new Blob([o],{type:"font/ttf"}),d=URL.createObjectURL(m),l=new FontFace(p,`url(${d})`);return await l.load(),document.fonts.add(l),l}async loadWoff2Decompressor(){if(this.woff2Decompressor)return;const t=`${await fetch("https://unpkg.com/wawoff2@2.0.1/build/decompress_binding.js").then(i=>i.text())}; return Module`;this.woff2Decompressor=new Function(t)(),await new Promise(i=>{this.woff2Decompressor.onRuntimeInitialized=i})}unload(e){e&&document.fonts.delete(e)}}const Er=te({clips:rs.array()}),Ar=pe().url("Invalid image url format."),Ir=te({src:Ar}),Pr=te({background:pe().optional(),fonts:Ir.array().optional(),tracks:Er.array()}),Rr=te({size:te({width:D().positive(),height:D().positive()}),fps:D().positive().optional(),format:pe()}),Or=te({timeline:Pr,output:Rr});class Ot extends Je{static ZIndexPadding=100;assetLoader;events;edit;tracks;clipsToDispose;clips;commandHistory=[];commandIndex=-1;playbackTime;size;backgroundColor;totalDuration;isPlaying;selectedClip;updatedClip;viewportMask;isExporting=!1;constructor(e,t="#ffffff"){super(),this.assetLoader=new bi,this.edit=null,this.tracks=[],this.clipsToDispose=[],this.clips=[],this.events=new Kt,this.size=e,this.playbackTime=0,this.totalDuration=0,this.isPlaying=!1,this.selectedClip=null,this.updatedClip=null,this.backgroundColor=t,this.setupIntentListeners()}async load(){const e=new R.Graphics;e.fillStyle={color:this.backgroundColor},e.rect(0,0,this.size.width,this.size.height),e.fill(),this.getContainer().addChild(e),this.viewportMask=new R.Graphics,this.viewportMask.rect(0,0,this.size.width,this.size.height),this.viewportMask.fill(16777215),this.getContainer().addChild(this.viewportMask),this.getContainer().setMask({mask:this.viewportMask})}update(e,t){for(const i of this.clips)i.shouldDispose&&this.queueDisposeClip(i),i.update(e,t);this.disposeClips(),this.isPlaying&&(this.playbackTime=Math.max(0,Math.min(this.playbackTime+t,this.totalDuration)),this.playbackTime===this.totalDuration&&this.pause())}draw(){for(const e of this.clips)e.draw()}dispose(){if(this.clearClips(),this.viewportMask){try{this.getContainer().setMask(null)}catch{}this.viewportMask.destroy(),this.viewportMask=void 0}}play(){this.isPlaying=!0,this.events.emit("playback:play",{})}pause(){this.isPlaying=!1,this.events.emit("playback:pause",{})}seek(e){this.playbackTime=Math.max(0,Math.min(e,this.totalDuration)),this.pause()}stop(){this.seek(0)}async loadEdit(e){this.clearClips(),this.edit=Or.parse(e),this.backgroundColor=this.edit.timeline.background||"#000000",await Promise.all((this.edit.timeline.fonts??[]).map(async t=>{const i=t.src,r={src:i,loadParser:qt.Name};return this.assetLoader.load(i,r)}));for(const[t,i]of this.edit.timeline.tracks.entries())for(const r of i.clips){const n=this.createPlayerFromAssetType(r);n.layer=t+1,await this.addPlayer(t,n)}this.updateTotalDuration()}getEdit(){const e=this.tracks.map((t,i)=>({clips:t.filter(n=>n&&!this.clipsToDispose.includes(n)).map(n=>n.clipConfiguration)}));return{timeline:{background:this.backgroundColor,tracks:e,fonts:this.edit?.timeline.fonts||[]},output:this.edit?.output||{size:this.size,format:"mp4"}}}addClip(e,t){const i=new jo(e,t);this.executeCommand(i)}getClip(e,t){const i=this.clips.filter(r=>r.layer===e+1);return t<0||t>=i.length?null:i[t].clipConfiguration}getPlayerClip(e,t){const i=this.clips.filter(r=>r.layer===e+1);return t<0||t>=i.length?null:i[t]}deleteClip(e,t){const i=new Wo(e,t);this.executeCommand(i)}splitClip(e,t,i){const r=new qo(e,t,i);this.executeCommand(r)}addTrack(e,t){const i=new Sr(e);this.executeCommand(i),t?.clips?.forEach(r=>this.addClip(e,r))}getTrack(e){const t=this.clips.filter(i=>i.layer===e+1);return t.length===0?null:{clips:t.map(i=>i.clipConfiguration)}}deleteTrack(e){const t=new Go(e);this.executeCommand(t)}getTotalDuration(){return this.totalDuration}undo(){if(this.commandIndex>=0){const e=this.commandHistory[this.commandIndex];if(e.undo){const t=this.createCommandContext();e.undo(t),this.commandIndex-=1,this.events.emit("edit:undo",{command:e.name})}}}redo(){if(this.commandIndex<this.commandHistory.length-1){this.commandIndex+=1;const e=this.commandHistory[this.commandIndex],t=this.createCommandContext();e.execute(t),this.events.emit("edit:redo",{command:e.name})}}setUpdatedClip(e,t=null,i=null){const r=new Ko(e,t,i);this.executeCommand(r)}updateTextContent(e,t,i){const r=new Xo(e,t,i);this.executeCommand(r)}executeEditCommand(e){return this.executeCommand(e)}executeCommand(e){const t=this.createCommandContext(),i=e.execute(t);return this.commandHistory=this.commandHistory.slice(0,this.commandIndex+1),this.commandHistory.push(e),this.commandIndex+=1,i}createCommandContext(){return{getClips:()=>this.clips,getTracks:()=>this.tracks,getTrack:e=>e>=0&&e<this.tracks.length?this.tracks[e]:null,getContainer:()=>this.getContainer(),addPlayer:(e,t)=>this.addPlayer(e,t),addPlayerToContainer:(e,t)=>{this.addPlayerToContainer(e,t)},createPlayerFromAssetType:e=>this.createPlayerFromAssetType(e),queueDisposeClip:e=>this.queueDisposeClip(e),disposeClips:()=>this.disposeClips(),undeleteClip:(e,t)=>{this.clips.push(t),this.updateTotalDuration()},setUpdatedClip:e=>{this.updatedClip=e},restoreClipConfiguration:(e,t)=>{Object.assign(e.clipConfiguration,structuredClone(t)),e.reconfigureAfterRestore(),e.draw()},updateDuration:()=>this.updateTotalDuration(),emitEvent:(e,t)=>this.events.emit(e,t),findClipIndices:e=>this.findClipIndices(e),getClipAt:(e,t)=>this.getClipAt(e,t),getSelectedClip:()=>this.selectedClip,setSelectedClip:e=>{this.selectedClip=e},movePlayerToTrackContainer:(e,t,i)=>this.movePlayerToTrackContainer(e,t,i),getEditState:()=>this.getEdit()}}queueDisposeClip(e){this.clipsToDispose.push(e)}disposeClips(){if(this.clipsToDispose.length!==0){for(const e of this.clipsToDispose)this.disposeClip(e);this.clips=this.clips.filter(e=>!this.clipsToDispose.includes(e)),this.clipsToDispose=[],this.updateTotalDuration()}}disposeClip(e){try{if(this.getContainer().children.includes(e.getContainer())){const t=this.getContainer().getChildIndex(e.getContainer());this.getContainer().removeChildAt(t)}else for(const t of this.getContainer().children)if(t instanceof R.Container&&t.label?.toString().startsWith("shotstack-track-")&&t.children.includes(e.getContainer())){t.removeChild(e.getContainer());break}}catch(t){console.warn(`Attempting to unmount an unmounted clip: ${t}`)}this.unloadClipAssets(e),e.dispose()}unloadClipAssets(e){const{asset:t}=e.clipConfiguration;if(t&&"src"in t&&typeof t.src=="string")try{R.Assets.unload(t.src)}catch(i){console.warn(`Failed to unload asset: ${t.src}`,i)}}clearClips(){for(const e of this.clips)this.disposeClip(e);this.clips=[],this.clipsToDispose=[],this.updateTotalDuration()}updateTotalDuration(){let e=0;for(const i of this.tracks)for(const r of i)e=Math.max(e,r.getEnd());const t=this.totalDuration;this.totalDuration=e,t!==this.totalDuration&&this.events.emit("duration:changed",{duration:this.totalDuration})}addPlayerToContainer(e,t){const i=1e5-(e+1)*Ot.ZIndexPadding,r=`shotstack-track-${i}`;let n=this.getContainer().getChildByLabel(r,!1);n||(n=new R.Container({label:r,zIndex:i}),this.getContainer().addChild(n)),n.addChild(t.getContainer())}movePlayerToTrackContainer(e,t,i){if(t===i)return;const r=1e5-(t+1)*Ot.ZIndexPadding,n=1e5-(i+1)*Ot.ZIndexPadding,o=`shotstack-track-${r}`,a=`shotstack-track-${n}`,p=this.getContainer().getChildByLabel(o,!1);let m=this.getContainer().getChildByLabel(a,!1);m||(m=new R.Container({label:a,zIndex:n}),this.getContainer().addChild(m)),p&&p.removeChild(e.getContainer()),m.addChild(e.getContainer())}createPlayerFromAssetType(e){if(!e.asset?.type)throw new Error("Invalid clip configuration: missing asset type");let t;switch(e.asset.type){case"text":{t=new Io(this,e);break}case"rich-text":{t=new Eo(this,e);break}case"shape":{t=new Ao(this,e);break}case"html":{t=new ea(this,e);break}case"image":{t=new ta(this,e);break}case"video":{t=new Po(this,e);break}case"audio":{t=new Os(this,e);break}case"luma":{t=new Fs(this,e);break}default:throw new Error(`Unsupported clip type: ${e.asset.type}`)}return t}async addPlayer(e,t){for(;this.tracks.length<=e;)this.tracks.push([]);this.tracks[e].push(t),this.clips.push(t);const i=1e5-(e+1)*Ot.ZIndexPadding,r=`shotstack-track-${i}`;let n=this.getContainer().getChildByLabel(r,!1);n||(n=new R.Container({label:r,zIndex:i}),this.getContainer().addChild(n)),n.addChild(t.getContainer());const o=t instanceof Fs;await t.load(),o&&n.setMask({mask:t.getMask(),inverse:!0}),this.updateTotalDuration()}selectClip(e,t){const i=new Zo(e,t);this.executeCommand(i)}clearSelection(){const e=new Vo;this.executeCommand(e)}isClipSelected(e,t){if(!this.selectedClip)return!1;const i=this.selectedClip.layer-1,r=this.tracks[i].indexOf(this.selectedClip);return e===i&&t===r}getSelectedClipInfo(){if(!this.selectedClip)return null;const e=this.selectedClip.layer-1,t=this.tracks[e].indexOf(this.selectedClip);return{trackIndex:e,clipIndex:t,player:this.selectedClip}}findClipIndices(e){for(let t=0;t<this.tracks.length;t+=1){const i=this.tracks[t].indexOf(e);if(i!==-1)return{trackIndex:t,clipIndex:i}}return null}getClipAt(e,t){return e>=0&&e<this.tracks.length&&t>=0&&t<this.tracks[e].length?this.tracks[e][t]:null}selectPlayer(e){const t=this.findClipIndices(e);t&&this.selectClip(t.trackIndex,t.clipIndex)}isPlayerSelected(e){return this.isExporting?!1:this.selectedClip===e}setExportMode(e){this.isExporting=e}isInExportMode(){return this.isExporting}setupIntentListeners(){this.events.on("timeline:clip:clicked",e=>{e.player?this.selectPlayer(e.player):this.selectClip(e.trackIndex,e.clipIndex)}),this.events.on("timeline:background:clicked",()=>{this.clearSelection()}),this.events.on("canvas:clip:clicked",e=>{this.selectPlayer(e.player)}),this.events.on("canvas:background:clicked",()=>{this.clearSelection()})}}class Xt extends Je{static Width=250;static Height=100;fps;playbackTime;playbackDuration;isPlaying;background;text;constructor(){super(),this.background=null,this.text=null,this.fps=0,this.playbackTime=0,this.playbackDuration=0,this.isPlaying=!1}async load(){const e=new R.Graphics;e.fillStyle={color:"#424242",alpha:.5},e.rect(0,0,Xt.Width,Xt.Height),e.fill(),this.getContainer().addChild(e),this.background=e;const t=new R.Text;t.text="",t.style={fontFamily:"monospace",fontSize:14,fill:"#ffffff",wordWrap:!0,wordWrapWidth:Xt.Width},this.getContainer().addChild(t),this.text=t}update(e,t){if(!this.text)return;const i=this.getMemoryInfo(),r=[`FPS: ${this.fps}`,`Playback: ${(this.playbackTime/1e3).toFixed(2)}/${(this.playbackDuration/1e3).toFixed(2)}`,`Playing: ${this.isPlaying}`,`Total Heap Size: ${i.totalHeapSize?`${this.bytesToMegabytes(i.totalHeapSize)}MB`:"N/A"}`,`Used Heap Size: ${i.usedHeapSize?`${this.bytesToMegabytes(i.usedHeapSize)}MB`:"N/A"}`,`Heap Size Limit: ${i.heapSizeLimit?`${this.bytesToMegabytes(i.heapSizeLimit)}MB`:"N/A"}`];this.text.text=r.join(`
187
- `)}draw(){}dispose(){this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null}getMemoryInfo(){const e={};return"memory"in performance&&(e.totalHeapSize=performance.memory.totalJSHeapSize,e.usedHeapSize=performance.memory.usedJSHeapSize,e.heapSizeLimit=performance.memory.jsHeapSizeLimit),e}bytesToMegabytes(e){return Math.round(e/1024/1024)}}class yt{static CanvasSelector="[data-shotstack-studio]";static extensionsRegistered=!1;size;application;edit;inspector;container;background;timeline;minZoom=.1;maxZoom=4;currentZoom=.8;onTickBound;constructor(e,t){this.size=e,this.application=new R.Application,this.edit=t,this.inspector=new Xt,this.onTickBound=this.onTick.bind(this)}async load(){const e=document.querySelector(yt.CanvasSelector);if(!e)throw new Error(`Shotstack canvas root element '${yt.CanvasSelector}' not found.`);this.registerExtensions(),this.container=new R.Container,this.background=new R.Graphics,this.background.fillStyle={color:"#424242"},this.background.rect(0,0,this.size.width,this.size.height),this.background.fill(),await this.configureApplication(),this.configureStage(),this.setupTouchHandling(e),this.edit.getContainer().scale=this.currentZoom,e.appendChild(this.application.canvas)}setupTouchHandling(e){const t=this.edit.getContainer();e.addEventListener("wheel",i=>{if(i.preventDefault(),i.stopPropagation(),i.ctrlKey){const r=Math.exp(-i.deltaY/100),n=this.currentZoom*r,o=this.currentZoom;this.currentZoom=Math.min(Math.max(n,this.minZoom),this.maxZoom);const a={x:this.application.canvas.width/2,y:this.application.canvas.height/2},p={x:t.position.x-a.x,y:t.position.y-a.y},m=this.currentZoom/o;t.position.x=a.x+p.x*m,t.position.y=a.y+p.y*m,t.scale.x=this.currentZoom,t.scale.y=this.currentZoom}},{passive:!1,capture:!0})}centerEdit(){if(!this.edit)return;const e=this.edit.getContainer();e.position={x:this.application.canvas.width/2-this.edit.size.width*this.currentZoom/2,y:this.application.canvas.height/2-this.edit.size.height*this.currentZoom/2}}zoomToFit(){if(!this.edit)return;const e=this.application.canvas.width/this.edit.size.width,t=this.application.canvas.height/this.edit.size.height,i=Math.min(e,t);this.currentZoom=Math.min(Math.max(i,this.minZoom),this.maxZoom);const r=this.edit.getContainer();r.scale.x=this.currentZoom,r.scale.y=this.currentZoom,this.centerEdit()}setZoom(e){this.currentZoom=Math.min(Math.max(e,this.minZoom),this.maxZoom);const t=this.edit.getContainer();t.scale.x=this.currentZoom,t.scale.y=this.currentZoom}registerTimeline(e){this.timeline=e}registerExtensions(){yt.extensionsRegistered||(R.extensions.add(new zt),R.extensions.add(new qt),yt.extensionsRegistered=!0)}async configureApplication(){const e={background:"#000000",width:this.size.width,height:this.size.height,antialias:!0};await this.application.init(e),this.application.ticker.add(this.onTickBound),this.application.ticker.minFPS=60,this.application.ticker.maxFPS=60}onTick(e){this.edit.update(e.deltaTime,e.deltaMS),this.edit.draw(),this.inspector.fps=Math.ceil(e.FPS),this.inspector.playbackTime=this.edit.playbackTime,this.inspector.playbackDuration=this.edit.totalDuration,this.inspector.isPlaying=this.edit.isPlaying,this.inspector.update(e.deltaTime,e.deltaMS),this.inspector.draw(),this.timeline&&(this.timeline.update(e.deltaTime,e.deltaMS),this.timeline.draw())}configureStage(){if(!this.container||!this.background)throw new Error("Shotstack canvas container not set up.");this.container.addChild(this.background),this.container.addChild(this.edit.getContainer()),this.container.addChild(this.inspector.getContainer()),this.application.stage.addChild(this.container),this.application.stage.eventMode="static",this.application.stage.hitArea=new R.Rectangle(0,0,this.size.width,this.size.height),this.background.eventMode="static",this.background.on("pointerdown",this.onBackgroundClick.bind(this)),this.application.stage.on("click",this.onClick.bind(this)),this.edit.getContainer().position={x:this.application.canvas.width/2-this.edit.size.width*this.currentZoom/2,y:this.application.canvas.height/2-this.edit.size.height*this.currentZoom/2}}onClick(){this.edit.pause()}onBackgroundClick(e){e.target===this.background&&this.edit.events.emit("canvas:background:clicked",{})}pauseTicker(){this.application.ticker.remove(this.onTickBound)}resumeTicker(){this.application.ticker.add(this.onTickBound)}dispose(){const e=document.querySelector(yt.CanvasSelector);e&&e.contains(this.application.canvas)&&e.removeChild(this.application.canvas),this.application.ticker.remove(this.onTickBound),this.application.stage.off("click",this.onClick,this),this.background?.off("pointerdown",this.onBackgroundClick,this),this.background?.destroy(),this.container?.destroy(),this.inspector.dispose(),this.application.destroy(!0,{children:!0,texture:!0})}}class Qo{edit;seekDistance=50;seekDistanceLarge=500;frameTime=16.67;constructor(e){this.edit=e}async load(){document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}dispose(){document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)}handleKeyDown=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.code){case"Space":{this.edit.isPlaying?this.edit.pause():this.edit.play();break}case"ArrowLeft":{if(e.metaKey)this.edit.seek(0);else{const t=e.shiftKey?this.seekDistanceLarge:this.seekDistance;this.edit.seek(this.edit.playbackTime-t)}break}case"ArrowRight":{if(e.metaKey)this.edit.seek(this.edit.getTotalDuration());else{const t=e.shiftKey?this.seekDistanceLarge:this.seekDistance;this.edit.seek(this.edit.playbackTime+t)}break}case"KeyJ":{this.edit.stop();break}case"KeyK":{this.edit.pause();break}case"KeyL":{this.edit.play();break}case"Comma":{this.edit.seek(this.edit.playbackTime-this.frameTime);break}case"Period":{this.edit.seek(this.edit.playbackTime+this.frameTime);break}case"KeyZ":{(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.shiftKey?this.edit.redo():this.edit.undo());break}case"Delete":case"Backspace":{const t=this.edit.getSelectedClipInfo();t&&(e.preventDefault(),this.edit.deleteClip(t.trackIndex,t.clipIndex));break}}};handleKeyUp=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.code){case"KeyI":console.log(this.edit.getEdit());break}}}class Jo{name="export";clips=[];tracks=[];execute(e){this.clips=e.getClips(),this.tracks=e.getTracks()}getClips(){return this.clips}getTracks(){return this.tracks}}/*!
182
+ const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,gh=Object.defineProperty,yh=(s,e,t)=>e in s?gh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Di=(s,e,t)=>(yh(s,typeof e!="symbol"?e+"":e,t),t);const bs=class er extends Rt.Filter{constructor(...e){let t=e[0]??{};typeof t=="number"&&(Rt.deprecation("6.0.0","OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }"),t={thickness:t},e[1]!==void 0&&(t.color=e[1]),e[2]!==void 0&&(t.quality=e[2]),e[3]!==void 0&&(t.alpha=e[3]),e[4]!==void 0&&(t.knockout=e[4])),t={...er.DEFAULT_OPTIONS,...t};const i=t.quality??.1,r=Rt.GpuProgram.from({vertex:{source:fh,entryPoint:"mainVertex"},fragment:{source:mh,entryPoint:"mainFragment"}}),n=Rt.GlProgram.from({vertex:dh,fragment:ph.replace(/\$\{ANGLE_STEP\}/,er.getAngleStep(i).toFixed(7)),name:"outline-filter"});super({gpuProgram:r,glProgram:n,resources:{outlineUniforms:{uThickness:{value:new Float32Array(2),type:"vec2<f32>"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:t.alpha,type:"f32"},uAngleStep:{value:0,type:"f32"},uKnockout:{value:t.knockout?1:0,type:"f32"}}}}),Di(this,"uniforms"),Di(this,"_thickness"),Di(this,"_quality"),Di(this,"_color"),this.uniforms=this.resources.outlineUniforms.uniforms,this.uniforms.uAngleStep=er.getAngleStep(i),this._color=new Rt.Color,this.color=t.color??0,Object.assign(this,t)}apply(e,t,i,r){this.uniforms.uThickness[0]=this.thickness/t.source.width,this.uniforms.uThickness[1]=this.thickness/t.source.height,e.applyFilter(this,t,i,r)}static getAngleStep(e){return parseFloat((Math.PI*2/Math.max(e*er.MAX_SAMPLES,er.MIN_SAMPLES)).toFixed(7))}get thickness(){return this._thickness}set thickness(e){this._thickness=this.padding=e}get color(){return this._color.value}set color(e){this._color.setValue(e);const[t,i,r]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=i,this.uniforms.uColor[2]=r}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get quality(){return this._quality}set quality(e){this._quality=e,this.uniforms.uAngleStep=er.getAngleStep(e)}get knockout(){return this.uniforms.uKnockout===1}set knockout(e){this.uniforms.uKnockout=e?1:0}};Di(bs,"DEFAULT_OPTIONS",{thickness:1,color:0,alpha:1,quality:.1,knockout:!1}),Di(bs,"MIN_SAMPLES",1),Di(bs,"MAX_SAMPLES",100);let Fn=bs;class bh extends Ye{background;text;constructor(e,t){super(e,t),this.background=null,this.text=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=await this.parseDocument();if(!t)return;const i=new L.Graphics;t.background.color&&(i.fillStyle={color:t.background.color,alpha:t.background.opacity??1},i.rect(0,0,e.width??this.edit.size.width,e.height??this.edit.size.height),i.fill());const r=new L.Text;r.text=t.text;const{horizontal:n,vertical:a}=t.alignment;r.style={fontFamily:t.font?.family??"Open Sans",fontSize:t.font?.size??32,fill:t.font?.color??"#ffffff",fontWeight:(t.font?.weight??"400").toString(),wordWrap:!0,wordWrapWidth:e.width??this.edit.size.width,lineHeight:(t.font?.lineHeight??1)*(t.font?.size??32),align:n};let o=(e.width??this.edit.size.width)/2-r.width/2,c=(e.height??this.edit.size.height)/2-r.height/2;if(n==="left"&&(o=0),n==="right"&&(o=(e.width??this.edit.size.width)-r.width),a==="top"&&(c=0),a==="bottom"&&(c=(e.height??this.edit.size.height)-r.height),r.position={x:o,y:c},t.stroke.color&&t.stroke.width){const u=new Fn({thickness:t.stroke.width,color:t.stroke.color});r.filters=[u]}this.background=i,this.text=r,this.contentContainer.addChild(i),this.contentContainer.addChild(r),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}async parseDocument(){const e=this.clipConfiguration.asset,{html:t,css:i,position:r}=e;if(!t.includes('data-html-type="text"'))return console.warn("Unsupported html format."),null;const a=new DOMParser().parseFromString(t,"text/html").body.textContent??"",c=(await new CSSStyleSheet().replace(i)).cssRules[0],u={text:a,font:{},alignment:{},background:{},stroke:{}};if(c?.constructor.name!=="CSSStyleRule"||!("style"in c))return console.warn("Unsupported css format."),u;const h=c.style,l=this.parseAlignment(r??"center");u.font={color:h.color.length?h.color:void 0,family:h.fontFamily.length?h.fontFamily:void 0,size:h.fontSize.length?parseInt(h.fontSize,10):void 0,weight:h.fontWeight.length?parseInt(h.fontWeight,10):void 0,lineHeight:h.lineHeight.length?parseInt(h.lineHeight,10):void 0},u.alignment=l;let d="";return h.background.length&&(d=h.background),h.backgroundColor.length&&(d=h.backgroundColor),u.background={color:d.length?d:void 0,opacity:h.opacity.length?parseInt(h.opacity,10):void 0},u.stroke={width:h.strokeWidth.length?parseInt(h.strokeWidth,10):void 0,color:h.stroke.length?h.stroke:void 0},u}parseAlignment(e){switch(e){case"topLeft":return{horizontal:"left",vertical:"top"};case"top":return{horizontal:"center",vertical:"top"};case"topRight":return{horizontal:"right",vertical:"top"};case"left":return{horizontal:"left",vertical:"center"};case"right":return{horizontal:"right",vertical:"center"};case"bottomLeft":return{horizontal:"left",vertical:"bottom"};case"bottom":return{horizontal:"center",vertical:"bottom"};case"bottomRight":return{horizontal:"right",vertical:"bottom"};case"center":default:return{horizontal:"center",vertical:"center"}}}}class vh extends Ye{texture;sprite;originalSize;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.originalSize=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,crossovern:"anonymous",data:{}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof L.ImageSource))throw new Error(`Invalid image source '${e.src}'.`);this.texture=this.createCroppedTexture(r),this.sprite=new L.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null,this.originalSize=null}getSize(){return this.clipConfiguration.width&&this.clipConfiguration.height?{width:this.clipConfiguration.width,height:this.clipConfiguration.height}:{width:this.sprite?.width??0,height:this.sprite?.height??0}}createCroppedTexture(e){const t=this.clipConfiguration.asset;if(!t.crop)return e;const i=e.width,r=e.height,n=Math.floor((t.crop?.left??0)*i),a=Math.floor((t.crop?.right??0)*i),o=Math.floor((t.crop?.top??0)*r),c=Math.floor((t.crop?.bottom??0)*r),u=n,h=o,l=i-n-a,d=r-o-c,f=new L.Rectangle(u,h,l,d);return new L.Texture({source:e.source,frame:f})}}class Mo extends Ye{texture;sprite;isPlaying;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.isPlaying=!1}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src,i={src:t,data:{autoPlay:!1,muted:!0}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof L.ImageSource||r?.source instanceof L.VideoSource))throw new Error(`Invalid luma source '${e.src}'.`);this.texture=r,this.sprite=new L.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.configureKeyframes()}update(e,t){if(super.update(e,t),!this.texture||!(this.texture.source instanceof L.VideoSource))return;const i=this.getPlaybackTime(),r=this.edit.isPlaying&&this.isActive();r&&(this.isPlaying||(this.isPlaying=!0,this.texture.source.resource.currentTime=i/1e3,this.texture.source.resource.play().catch(console.error)),this.texture.source.resource.volume!==this.getVolume()&&(this.texture.source.resource.volume=this.getVolume()),Math.abs(this.texture.source.resource.currentTime*1e3-i)>100&&(this.texture.source.resource.currentTime=i/1e3)),!r&&this.isPlaying&&(this.isPlaying=!1,this.texture.source.resource.pause()),!this.edit.isPlaying&&this.isActive()&&(this.texture.source.resource.currentTime=i/1e3)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null}getSize(){return{width:this.sprite?.width??0,height:this.sprite?.height??0}}getVolume(){return 0}getMask(){return this.sprite}}var Pe;(function(s){s.assertEqual=r=>{};function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const n={};for(const a of r)n[a]=a;return n},s.getValidEnumValues=r=>{const n=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),a={};for(const o of n)a[o]=r[o];return s.objectValues(a)},s.objectValues=r=>s.objectKeys(r).map(function(n){return r[n]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const n=[];for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.push(a);return n},s.find=(r,n)=>{for(const a of r)if(n(a))return a},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function i(r,n=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(n)}s.joinValues=i,s.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(Pe||(Pe={}));var Do;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Do||(Do={}));const te=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ui=s=>{switch(typeof s){case"undefined":return te.undefined;case"string":return te.string;case"number":return Number.isNaN(s)?te.nan:te.number;case"boolean":return te.boolean;case"function":return te.function;case"bigint":return te.bigint;case"symbol":return te.symbol;case"object":return Array.isArray(s)?te.array:s===null?te.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?te.promise:typeof Map<"u"&&s instanceof Map?te.map:typeof Set<"u"&&s instanceof Set?te.set:typeof Date<"u"&&s instanceof Date?te.date:te.object;default:return te.unknown}},N=Pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ti extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},i={_errors:[]},r=n=>{for(const a of n.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)i._errors.push(t(a));else{let o=i,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return r(this),i}static assert(e){if(!(e instanceof ti))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},i=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else i.push(e(r));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}ti.create=s=>new ti(s);const Rn=(s,e)=>{let t;switch(s.code){case N.invalid_type:s.received===te.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case N.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,Pe.jsonStringifyReplacer)}`;break;case N.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(s.keys,", ")}`;break;case N.invalid_union:t="Invalid input";break;case N.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(s.options)}`;break;case N.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(s.options)}, received '${s.received}'`;break;case N.invalid_arguments:t="Invalid function arguments";break;case N.invalid_return_type:t="Invalid function return type";break;case N.invalid_date:t="Invalid date";break;case N.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:Pe.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case N.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case N.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case N.custom:t="Invalid input";break;case N.invalid_intersection_types:t="Intersection results could not be merged";break;case N.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case N.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(s)}return{message:t}};let wh=Rn;function xh(){return wh}const Ch=s=>{const{data:e,path:t,errorMaps:i,issueData:r}=s,n=[...t,...r.path||[]],a={...r,path:n};if(r.message!==void 0)return{...r,path:n,message:r.message};let o="";const c=i.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...r,path:n,message:o}};function K(s,e){const t=xh(),i=Ch({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Rn?void 0:Rn].filter(r=>!!r)});s.common.issues.push(i)}class bt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const r of t){if(r.status==="aborted")return ye;r.status==="dirty"&&e.dirty(),i.push(r.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const r of t){const n=await r.key,a=await r.value;i.push({key:n,value:a})}return bt.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};for(const r of t){const{key:n,value:a}=r;if(n.status==="aborted"||a.status==="aborted")return ye;n.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof a.value<"u"||r.alwaysSet)&&(i[n.value]=a.value)}return{status:e.value,value:i}}}const ye=Object.freeze({status:"aborted"}),Pr=s=>({status:"dirty",value:s}),Ct=s=>({status:"valid",value:s}),Bo=s=>s.status==="aborted",Lo=s=>s.status==="dirty",tr=s=>s.status==="valid",vs=s=>typeof Promise<"u"&&s instanceof Promise;var ie;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message})(ie||(ie={}));class hi{constructor(e,t,i,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=i,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const zo=(s,e)=>{if(tr(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ti(s.common.issues);return this._error=t,this._error}}};function ke(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:i,description:r}=s;if(e&&(t||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,o)=>{const{message:c}=s;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??i??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:r}}class Ie{get description(){return this._def.description}_getType(e){return ui(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ui(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new bt,ctx:{common:e.parent.common,data:e.data,parsedType:ui(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(vs(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){const i={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ui(e)},r=this._parseSync({data:e,path:i.path,parent:i});return zo(i,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ui(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return tr(i)?{value:i.value}:{issues:t.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>tr(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ui(e)},r=this._parse({data:e,path:i.path,parent:i}),n=await(vs(r)?r:Promise.resolve(r));return zo(i,n)}refine(e,t){const i=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,n)=>{const a=e(r),o=()=>n.addIssue({code:N.custom,...i(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((i,r)=>e(i)?!0:(r.addIssue(typeof t=="function"?t(i,r):t),!1))}_refinement(e){return new nr({schema:this,typeName:be.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return pi.create(this,this._def)}nullable(){return ar.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Mt.create(this)}promise(){return ks.create(this,this._def)}or(e){return xs.create([this,e],this._def)}and(e){return Cs.create(this,e,this._def)}transform(e){return new nr({...ke(this._def),schema:this,typeName:be.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new zn({...ke(this._def),innerType:this,defaultValue:t,typeName:be.ZodDefault})}brand(){return new Wh({typeName:be.ZodBranded,type:this,...ke(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new $n({...ke(this._def),innerType:this,catchValue:t,typeName:be.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Nn.create(this,e)}readonly(){return Un.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const kh=/^c[^\s-]{8,}$/i,Sh=/^[0-9a-z]+$/,Th=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Eh=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,_h=/^[a-z0-9_-]{21}$/i,Ah=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ih=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ph=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-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}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bh=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lh=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,$o="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",zh=new RegExp(`^${$o}$`);function No(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function $h(s){return new RegExp(`^${No(s)}$`)}function Nh(s){let e=`${$o}T${No(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Uh(s,e){return!!((e==="v4"||!e)&&Fh.test(s)||(e==="v6"||!e)&&Mh.test(s))}function Vh(s,e){if(!Ah.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const i=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(i));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Hh(s,e){return!!((e==="v4"||!e)&&Rh.test(s)||(e==="v6"||!e)&&Dh.test(s))}class di extends Ie{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==te.string){const n=this._getOrReturnCtx(e);return K(n,{code:N.invalid_type,expected:te.string,received:n.parsedType}),ye}const i=new bt;let r;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),K(r,{code:N.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="max")e.data.length>n.value&&(r=this._getOrReturnCtx(e,r),K(r,{code:N.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,o=e.data.length<n.value;(a||o)&&(r=this._getOrReturnCtx(e,r),a?K(r,{code:N.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&K(r,{code:N.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),i.dirty())}else if(n.kind==="email")Ph.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"email",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="emoji")Mn||(Mn=new RegExp(Oh,"u")),Mn.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"emoji",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="uuid")Eh.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"uuid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="nanoid")_h.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"nanoid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid")kh.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"cuid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid2")Sh.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"cuid2",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="ulid")Th.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"ulid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),K(r,{validation:"url",code:N.invalid_string,message:n.message}),i.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"regex",code:N.invalid_string,message:n.message}),i.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(r=this._getOrReturnCtx(e,r),K(r,{code:N.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),i.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(r=this._getOrReturnCtx(e,r),K(r,{code:N.invalid_string,validation:{startsWith:n.value},message:n.message}),i.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),K(r,{code:N.invalid_string,validation:{endsWith:n.value},message:n.message}),i.dirty()):n.kind==="datetime"?Nh(n).test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{code:N.invalid_string,validation:"datetime",message:n.message}),i.dirty()):n.kind==="date"?zh.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{code:N.invalid_string,validation:"date",message:n.message}),i.dirty()):n.kind==="time"?$h(n).test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{code:N.invalid_string,validation:"time",message:n.message}),i.dirty()):n.kind==="duration"?Ih.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"duration",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="ip"?Uh(e.data,n.version)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"ip",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="jwt"?Vh(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"jwt",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="cidr"?Hh(e.data,n.version)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"cidr",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="base64"?Bh.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"base64",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="base64url"?Lh.test(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{validation:"base64url",code:N.invalid_string,message:n.message}),i.dirty()):Pe.assertNever(n);return{status:i.value,value:e.data}}_regex(e,t,i){return this.refinement(r=>e.test(r),{validation:t,code:N.invalid_string,...ie.errToObj(i)})}_addCheck(e){return new di({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ie.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ie.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ie.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ie.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ie.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ie.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ie.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ie.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ie.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ie.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ie.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ie.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ie.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ie.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...ie.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ie.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ie.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...ie.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ie.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ie.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ie.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ie.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ie.errToObj(t)})}nonempty(e){return this.min(1,ie.errToObj(e))}trim(){return new di({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new di({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new di({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}di.create=s=>new di({checks:[],typeName:be.ZodString,coerce:s?.coerce??!1,...ke(s)});function jh(s,e){const t=(s.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,r=t>i?t:i,n=Number.parseInt(s.toFixed(r).replace(".","")),a=Number.parseInt(e.toFixed(r).replace(".",""));return n%a/10**r}class ir extends Ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==te.number){const n=this._getOrReturnCtx(e);return K(n,{code:N.invalid_type,expected:te.number,received:n.parsedType}),ye}let i;const r=new bt;for(const n of this._def.checks)n.kind==="int"?Pe.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:N.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),K(i,{code:N.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),K(i,{code:N.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="multipleOf"?jh(e.data,n.value)!==0&&(i=this._getOrReturnCtx(e,i),K(i,{code:N.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:N.not_finite,message:n.message}),r.dirty()):Pe.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ie.toString(t))}setLimit(e,t,i,r){return new ir({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:ie.toString(r)}]})}_addCheck(e){return new ir({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ie.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ie.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ie.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ie.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ie.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Pe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(t===null||i.value>t)&&(t=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ir.create=s=>new ir({checks:[],typeName:be.ZodNumber,coerce:s?.coerce||!1,...ke(s)});class Or extends Ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==te.bigint)return this._getInvalidInput(e);let i;const r=new bt;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),K(i,{code:N.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),K(i,{code:N.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),K(i,{code:N.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):Pe.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return K(t,{code:N.invalid_type,expected:te.bigint,received:t.parsedType}),ye}gte(e,t){return this.setLimit("min",e,!0,ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ie.toString(t))}setLimit(e,t,i,r){return new Or({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:ie.toString(r)}]})}_addCheck(e){return new Or({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ie.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Or.create=s=>new Or({checks:[],typeName:be.ZodBigInt,coerce:s?.coerce??!1,...ke(s)});class Dn extends Ie{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==te.boolean){const i=this._getOrReturnCtx(e);return K(i,{code:N.invalid_type,expected:te.boolean,received:i.parsedType}),ye}return Ct(e.data)}}Dn.create=s=>new Dn({typeName:be.ZodBoolean,coerce:s?.coerce||!1,...ke(s)});class ws extends Ie{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==te.date){const n=this._getOrReturnCtx(e);return K(n,{code:N.invalid_type,expected:te.date,received:n.parsedType}),ye}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return K(n,{code:N.invalid_date}),ye}const i=new bt;let r;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),K(r,{code:N.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(r=this._getOrReturnCtx(e,r),K(r,{code:N.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):Pe.assertNever(n);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ws({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ie.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ie.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ws.create=s=>new ws({checks:[],coerce:s?.coerce||!1,typeName:be.ZodDate,...ke(s)});class Uo extends Ie{_parse(e){if(this._getType(e)!==te.symbol){const i=this._getOrReturnCtx(e);return K(i,{code:N.invalid_type,expected:te.symbol,received:i.parsedType}),ye}return Ct(e.data)}}Uo.create=s=>new Uo({typeName:be.ZodSymbol,...ke(s)});class Vo extends Ie{_parse(e){if(this._getType(e)!==te.undefined){const i=this._getOrReturnCtx(e);return K(i,{code:N.invalid_type,expected:te.undefined,received:i.parsedType}),ye}return Ct(e.data)}}Vo.create=s=>new Vo({typeName:be.ZodUndefined,...ke(s)});class Ho extends Ie{_parse(e){if(this._getType(e)!==te.null){const i=this._getOrReturnCtx(e);return K(i,{code:N.invalid_type,expected:te.null,received:i.parsedType}),ye}return Ct(e.data)}}Ho.create=s=>new Ho({typeName:be.ZodNull,...ke(s)});class jo extends Ie{constructor(){super(...arguments),this._any=!0}_parse(e){return Ct(e.data)}}jo.create=s=>new jo({typeName:be.ZodAny,...ke(s)});class Wo extends Ie{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ct(e.data)}}Wo.create=s=>new Wo({typeName:be.ZodUnknown,...ke(s)});class fi extends Ie{_parse(e){const t=this._getOrReturnCtx(e);return K(t,{code:N.invalid_type,expected:te.never,received:t.parsedType}),ye}}fi.create=s=>new fi({typeName:be.ZodNever,...ke(s)});class Go extends Ie{_parse(e){if(this._getType(e)!==te.undefined){const i=this._getOrReturnCtx(e);return K(i,{code:N.invalid_type,expected:te.void,received:i.parsedType}),ye}return Ct(e.data)}}Go.create=s=>new Go({typeName:be.ZodVoid,...ke(s)});class Mt extends Ie{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),r=this._def;if(t.parsedType!==te.array)return K(t,{code:N.invalid_type,expected:te.array,received:t.parsedType}),ye;if(r.exactLength!==null){const a=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(a||o)&&(K(t,{code:a?N.too_big:N.too_small,minimum:o?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),i.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(K(t,{code:N.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),i.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(K(t,{code:N.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>r.type._parseAsync(new hi(t,a,t.path,o)))).then(a=>bt.mergeArray(i,a));const n=[...t.data].map((a,o)=>r.type._parseSync(new hi(t,a,t.path,o)));return bt.mergeArray(i,n)}get element(){return this._def.type}min(e,t){return new Mt({...this._def,minLength:{value:e,message:ie.toString(t)}})}max(e,t){return new Mt({...this._def,maxLength:{value:e,message:ie.toString(t)}})}length(e,t){return new Mt({...this._def,exactLength:{value:e,message:ie.toString(t)}})}nonempty(e){return this.min(1,e)}}Mt.create=(s,e)=>new Mt({type:s,minLength:null,maxLength:null,exactLength:null,typeName:be.ZodArray,...ke(e)});function rr(s){if(s instanceof Ge){const e={};for(const t in s.shape){const i=s.shape[t];e[t]=pi.create(rr(i))}return new Ge({...s._def,shape:()=>e})}else return s instanceof Mt?new Mt({...s._def,type:rr(s.element)}):s instanceof pi?pi.create(rr(s.unwrap())):s instanceof ar?ar.create(rr(s.unwrap())):s instanceof Bi?Bi.create(s.items.map(e=>rr(e))):s}class Ge extends Ie{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Pe.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==te.object){const u=this._getOrReturnCtx(e);return K(u,{code:N.invalid_type,expected:te.object,received:u.parsedType}),ye}const{status:i,ctx:r}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof fi&&this._def.unknownKeys==="strip"))for(const u in r.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const h=n[u],l=r.data[u];c.push({key:{status:"valid",value:u},value:h._parse(new hi(r,l,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof fi){const u=this._def.unknownKeys;if(u==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(u==="strict")o.length>0&&(K(r,{code:N.unrecognized_keys,keys:o}),i.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const h of o){const l=r.data[h];c.push({key:{status:"valid",value:h},value:u._parse(new hi(r,l,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const u=[];for(const h of c){const l=await h.key,d=await h.value;u.push({key:l,value:d,alwaysSet:h.alwaysSet})}return u}).then(u=>bt.mergeObjectSync(i,u)):bt.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(e){return ie.errToObj,new Ge({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,i)=>{const r=this._def.errorMap?.(t,i).message??i.defaultError;return t.code==="unrecognized_keys"?{message:ie.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new Ge({...this._def,unknownKeys:"strip"})}passthrough(){return new Ge({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ge({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ge({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:be.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ge({...this._def,catchall:e})}pick(e){const t={};for(const i of Pe.objectKeys(e))e[i]&&this.shape[i]&&(t[i]=this.shape[i]);return new Ge({...this._def,shape:()=>t})}omit(e){const t={};for(const i of Pe.objectKeys(this.shape))e[i]||(t[i]=this.shape[i]);return new Ge({...this._def,shape:()=>t})}deepPartial(){return rr(this)}partial(e){const t={};for(const i of Pe.objectKeys(this.shape)){const r=this.shape[i];e&&!e[i]?t[i]=r:t[i]=r.optional()}return new Ge({...this._def,shape:()=>t})}required(e){const t={};for(const i of Pe.objectKeys(this.shape))if(e&&!e[i])t[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof pi;)n=n._def.innerType;t[i]=n}return new Ge({...this._def,shape:()=>t})}keyof(){return Zo(Pe.objectKeys(this.shape))}}Ge.create=(s,e)=>new Ge({shape:()=>s,unknownKeys:"strip",catchall:fi.create(),typeName:be.ZodObject,...ke(e)}),Ge.strictCreate=(s,e)=>new Ge({shape:()=>s,unknownKeys:"strict",catchall:fi.create(),typeName:be.ZodObject,...ke(e)}),Ge.lazycreate=(s,e)=>new Ge({shape:s,unknownKeys:"strip",catchall:fi.create(),typeName:be.ZodObject,...ke(e)});class xs extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.options;function r(n){for(const o of n)if(o.result.status==="valid")return o.result;for(const o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=n.map(o=>new ti(o.ctx.common.issues));return K(t,{code:N.invalid_union,unionErrors:a}),ye}if(t.common.async)return Promise.all(i.map(async n=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(r);{let n;const a=[];for(const c of i){const u={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!n&&(n={result:h,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=a.map(c=>new ti(c));return K(t,{code:N.invalid_union,unionErrors:o}),ye}}get options(){return this._def.options}}xs.create=(s,e)=>new xs({options:s,typeName:be.ZodUnion,...ke(e)});function Bn(s,e){const t=ui(s),i=ui(e);if(s===e)return{valid:!0,data:s};if(t===te.object&&i===te.object){const r=Pe.objectKeys(e),n=Pe.objectKeys(s).filter(o=>r.indexOf(o)!==-1),a={...s,...e};for(const o of n){const c=Bn(s[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===te.array&&i===te.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let n=0;n<s.length;n++){const a=s[n],o=e[n],c=Bn(a,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===te.date&&i===te.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class Cs extends Ie{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),r=(n,a)=>{if(Bo(n)||Bo(a))return ye;const o=Bn(n.value,a.value);return o.valid?((Lo(n)||Lo(a))&&t.dirty(),{status:t.value,value:o.data}):(K(i,{code:N.invalid_intersection_types}),ye)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,a])=>r(n,a)):r(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}Cs.create=(s,e,t)=>new Cs({left:s,right:e,typeName:be.ZodIntersection,...ke(t)});class Bi extends Ie{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==te.array)return K(i,{code:N.invalid_type,expected:te.array,received:i.parsedType}),ye;if(i.data.length<this._def.items.length)return K(i,{code:N.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ye;!this._def.rest&&i.data.length>this._def.items.length&&(K(i,{code:N.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...i.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new hi(i,a,i.path,o)):null}).filter(a=>!!a);return i.common.async?Promise.all(n).then(a=>bt.mergeArray(t,a)):bt.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Bi({...this._def,rest:e})}}Bi.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Bi({items:s,typeName:be.ZodTuple,rest:null,...ke(e)})};class qo extends Ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==te.map)return K(i,{code:N.invalid_type,expected:te.map,received:i.parsedType}),ye;const r=this._def.keyType,n=this._def.valueType,a=[...i.data.entries()].map(([o,c],u)=>({key:r._parse(new hi(i,o,i.path,[u,"key"])),value:n._parse(new hi(i,c,i.path,[u,"value"]))}));if(i.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,h=await c.value;if(u.status==="aborted"||h.status==="aborted")return ye;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(u.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,h=c.value;if(u.status==="aborted"||h.status==="aborted")return ye;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(u.value,h.value)}return{status:t.value,value:o}}}}qo.create=(s,e,t)=>new qo({valueType:e,keyType:s,typeName:be.ZodMap,...ke(t)});class Fr extends Ie{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==te.set)return K(i,{code:N.invalid_type,expected:te.set,received:i.parsedType}),ye;const r=this._def;r.minSize!==null&&i.data.size<r.minSize.value&&(K(i,{code:N.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&i.data.size>r.maxSize.value&&(K(i,{code:N.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const n=this._def.valueType;function a(c){const u=new Set;for(const h of c){if(h.status==="aborted")return ye;h.status==="dirty"&&t.dirty(),u.add(h.value)}return{status:t.value,value:u}}const o=[...i.data.values()].map((c,u)=>n._parse(new hi(i,c,i.path,u)));return i.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Fr({...this._def,minSize:{value:e,message:ie.toString(t)}})}max(e,t){return new Fr({...this._def,maxSize:{value:e,message:ie.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Fr.create=(s,e)=>new Fr({valueType:s,minSize:null,maxSize:null,typeName:be.ZodSet,...ke(e)});class Xo extends Ie{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Xo.create=(s,e)=>new Xo({getter:s,typeName:be.ZodLazy,...ke(e)});class Ln extends Ie{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return K(t,{received:t.data,code:N.invalid_literal,expected:this._def.value}),ye}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ln.create=(s,e)=>new Ln({value:s,typeName:be.ZodLiteral,...ke(e)});function Zo(s,e){return new sr({values:s,typeName:be.ZodEnum,...ke(e)})}class sr extends Ie{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),i=this._def.values;return K(t,{expected:Pe.joinValues(i),received:t.parsedType,code:N.invalid_type}),ye}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),i=this._def.values;return K(t,{received:t.data,code:N.invalid_enum_value,options:i}),ye}return Ct(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return sr.create(e,{...this._def,...t})}exclude(e,t=this._def){return sr.create(this.options.filter(i=>!e.includes(i)),{...this._def,...t})}}sr.create=Zo;class Ko extends Ie{_parse(e){const t=Pe.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==te.string&&i.parsedType!==te.number){const r=Pe.objectValues(t);return K(i,{expected:Pe.joinValues(r),received:i.parsedType,code:N.invalid_type}),ye}if(this._cache||(this._cache=new Set(Pe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=Pe.objectValues(t);return K(i,{received:i.data,code:N.invalid_enum_value,options:r}),ye}return Ct(e.data)}get enum(){return this._def.values}}Ko.create=(s,e)=>new Ko({values:s,typeName:be.ZodNativeEnum,...ke(e)});class ks extends Ie{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==te.promise&&t.common.async===!1)return K(t,{code:N.invalid_type,expected:te.promise,received:t.parsedType}),ye;const i=t.parsedType===te.promise?t.data:Promise.resolve(t.data);return Ct(i.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ks.create=(s,e)=>new ks({type:s,typeName:be.ZodPromise,...ke(e)});class nr extends Ie{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===be.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:i}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:a=>{K(i,a),a.fatal?t.abort():t.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),r.type==="preprocess"){const a=r.transform(i.data,n);if(i.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ye;const c=await this._def.schema._parseAsync({data:o,path:i.path,parent:i});return c.status==="aborted"?ye:c.status==="dirty"||t.value==="dirty"?Pr(c.value):c});{if(t.value==="aborted")return ye;const o=this._def.schema._parseSync({data:a,path:i.path,parent:i});return o.status==="aborted"?ye:o.status==="dirty"||t.value==="dirty"?Pr(o.value):o}}if(r.type==="refinement"){const a=o=>{const c=r.refinement(o,n);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!tr(a))return ye;const o=r.transform(a.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>tr(a)?Promise.resolve(r.transform(a.value,n)).then(o=>({status:t.value,value:o})):ye);Pe.assertNever(r)}}nr.create=(s,e,t)=>new nr({schema:s,typeName:be.ZodEffects,effect:e,...ke(t)}),nr.createWithPreprocess=(s,e,t)=>new nr({schema:e,effect:{type:"preprocess",transform:s},typeName:be.ZodEffects,...ke(t)});class pi extends Ie{_parse(e){return this._getType(e)===te.undefined?Ct(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}pi.create=(s,e)=>new pi({innerType:s,typeName:be.ZodOptional,...ke(e)});class ar extends Ie{_parse(e){return this._getType(e)===te.null?Ct(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ar.create=(s,e)=>new ar({innerType:s,typeName:be.ZodNullable,...ke(e)});class zn extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===te.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}zn.create=(s,e)=>new zn({innerType:s,typeName:be.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ke(e)});class $n extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),i={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return vs(r)?r.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ti(i.common.issues)},input:i.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ti(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}$n.create=(s,e)=>new $n({innerType:s,typeName:be.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ke(e)});class Yo extends Ie{_parse(e){if(this._getType(e)!==te.nan){const i=this._getOrReturnCtx(e);return K(i,{code:N.invalid_type,expected:te.nan,received:i.parsedType}),ye}return{status:"valid",value:e.data}}}Yo.create=s=>new Yo({typeName:be.ZodNaN,...ke(s)});class Wh extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class Nn extends Ie{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?ye:n.status==="dirty"?(t.dirty(),Pr(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const r=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return r.status==="aborted"?ye:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:i.path,parent:i})}}static create(e,t){return new Nn({in:e,out:t,typeName:be.ZodPipeline})}}class Un extends Ie{_parse(e){const t=this._def.innerType._parse(e),i=r=>(tr(r)&&(r.value=Object.freeze(r.value)),r);return vs(t)?t.then(r=>i(r)):i(t)}unwrap(){return this._def.innerType}}Un.create=(s,e)=>new Un({innerType:s,typeName:be.ZodReadonly,...ke(e)});var be;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(be||(be={}));const Ve=di.create,X=ir.create,Gh=Dn.create;fi.create;const Jo=Mt.create,ve=Ge.create,Vn=xs.create;Cs.create,Bi.create;const mi=Ln.create,Je=sr.create;ks.create,pi.create,ar.create;const Rr=Ve().regex(/^#[A-Fa-f0-9]{6}$/,"Invalid hex color format"),qh=ve({offset:X().min(0).max(1),color:Rr}).strict(),Xh=ve({type:Je(["linear","radial"]).default("linear"),angle:X().min(0).max(360).default(0),stops:Jo(qh).min(2)}).strict(),Zh=ve({family:Ve().default("Roboto"),size:X().min(8).max(500).default(48),weight:Vn([Ve(),X()]).default("400"),style:Je(["normal","italic","oblique"]).default("normal"),color:Rr.default("#000000"),opacity:X().min(0).max(1).default(1)}).strict(),Kh=ve({letterSpacing:X().default(0),lineHeight:X().min(.1).max(10).default(1.2),textTransform:Je(["none","uppercase","lowercase","capitalize"]).default("none"),textDecoration:Je(["none","underline","line-through"]).default("none"),gradient:Xh.optional()}).strict(),Yh=ve({width:X().min(0).default(0),color:Rr.default("#000000"),opacity:X().min(0).max(1).default(1)}).strict(),Jh=ve({offsetX:X().default(0),offsetY:X().default(0),blur:X().min(0).default(0),color:Rr.default("#000000"),opacity:X().min(0).max(1).default(.5)}).strict(),Qh=ve({color:Rr.optional(),opacity:X().min(0).max(1).default(1),borderRadius:X().min(0).default(0)}).strict(),ed=ve({horizontal:Je(["left","center","right"]).default("left"),vertical:Je(["top","middle","bottom"]).default("middle")}).strict(),td=ve({preset:Je(["fadeIn","slideIn","typewriter","shift","ascend","movingLetters","bounce","elastic","pulse"]),speed:X().min(.1).max(10).default(1),duration:X().min(.1).max(60).optional(),style:Je(["character","word"]).optional(),direction:Je(["left","right","up","down"]).optional()}).strict(),id=ve({src:Ve().url("Invalid font URL"),family:Ve(),weight:Vn([Ve(),X()]).default("400"),style:Je(["normal","italic","oblique"]).default("normal")}).strict(),Ss=ve({type:mi("rich-text"),text:Ve().max(1e4).default(""),width:X().min(1).max(8192).optional(),height:X().min(1).max(8192).optional(),font:Zh.optional(),style:Kh.optional(),stroke:Yh.optional(),shadow:Jh.optional(),background:Qh.optional(),align:ed.optional(),animation:td.optional(),cacheEnabled:Gh().default(!0),pixelRatio:X().min(1).max(4).default(2),customFonts:Jo(id).optional()}).strict();function Li(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Qo={exports:{}};(function(s,e){(function(t,i){s.exports=i()})(self,()=>{return t={7629:(r,n,a)=>{const o=a(375),c=a(8571),u=a(9474),h=a(1687),l=a(8652),d=a(8160),f=a(3292),p=a(6354),m=a(8901),b=a(9708),g=a(6914),y=a(2294),v=a(6133),k=a(1152),C=a(8863),_=a(2036),E={Base:class{constructor(x){this.type=x,this.$_root=null,this._definition={},this._reset()}_reset(){this._ids=new y.Ids,this._preferences=null,this._refs=new v.Manager,this._cache=null,this._valids=null,this._invalids=null,this._flags={},this._rules=[],this._singleRules=new Map,this.$_terms={},this.$_temp={ruleset:null,whens:{}}}describe(){return o(typeof b.describe=="function","Manifest functionality disabled"),b.describe(this)}allow(...x){return d.verifyFlat(x,"allow"),this._values(x,"_valids")}alter(x){o(x&&typeof x=="object"&&!Array.isArray(x),"Invalid targets argument"),o(!this._inRuleset(),"Cannot set alterations inside a ruleset");const S=this.clone();S.$_terms.alterations=S.$_terms.alterations||[];for(const T in x){const A=x[T];o(typeof A=="function","Alteration adjuster for",T,"must be a function"),S.$_terms.alterations.push({target:T,adjuster:A})}return S.$_temp.ruleset=!1,S}artifact(x){return o(x!==void 0,"Artifact cannot be undefined"),o(!this._cache,"Cannot set an artifact with a rule cache"),this.$_setFlag("artifact",x)}cast(x){return o(x===!1||typeof x=="string","Invalid to value"),o(x===!1||this._definition.cast[x],"Type",this.type,"does not support casting to",x),this.$_setFlag("cast",x===!1?void 0:x)}default(x,S){return this._default("default",x,S)}description(x){return o(x&&typeof x=="string","Description must be a non-empty string"),this.$_setFlag("description",x)}empty(x){const S=this.clone();return x!==void 0&&(x=S.$_compile(x,{override:!1})),S.$_setFlag("empty",x,{clone:!1})}error(x){return o(x,"Missing error"),o(x instanceof Error||typeof x=="function","Must provide a valid Error object or a function"),this.$_setFlag("error",x)}example(x,S={}){return o(x!==void 0,"Missing example"),d.assertOptions(S,["override"]),this._inner("examples",x,{single:!0,override:S.override})}external(x,S){return typeof x=="object"&&(o(!S,"Cannot combine options with description"),S=x.description,x=x.method),o(typeof x=="function","Method must be a function"),o(S===void 0||S&&typeof S=="string","Description must be a non-empty string"),this._inner("externals",{method:x,description:S},{single:!0})}failover(x,S){return this._default("failover",x,S)}forbidden(){return this.presence("forbidden")}id(x){return x?(o(typeof x=="string","id must be a non-empty string"),o(/^[^\.]+$/.test(x),"id cannot contain period character"),this.$_setFlag("id",x)):this.$_setFlag("id",void 0)}invalid(...x){return this._values(x,"_invalids")}label(x){return o(x&&typeof x=="string","Label name must be a non-empty string"),this.$_setFlag("label",x)}meta(x){return o(x!==void 0,"Meta cannot be undefined"),this._inner("metas",x,{single:!0})}note(...x){o(x.length,"Missing notes");for(const S of x)o(S&&typeof S=="string","Notes must be non-empty strings");return this._inner("notes",x)}only(x=!0){return o(typeof x=="boolean","Invalid mode:",x),this.$_setFlag("only",x)}optional(){return this.presence("optional")}prefs(x){o(x,"Missing preferences"),o(x.context===void 0,"Cannot override context"),o(x.externals===void 0,"Cannot override externals"),o(x.warnings===void 0,"Cannot override warnings"),o(x.debug===void 0,"Cannot override debug"),d.checkPreferences(x);const S=this.clone();return S._preferences=d.preferences(S._preferences,x),S}presence(x){return o(["optional","required","forbidden"].includes(x),"Unknown presence mode",x),this.$_setFlag("presence",x)}raw(x=!0){return this.$_setFlag("result",x?"raw":void 0)}result(x){return o(["raw","strip"].includes(x),"Unknown result mode",x),this.$_setFlag("result",x)}required(){return this.presence("required")}strict(x){const S=this.clone(),T=x!==void 0&&!x;return S._preferences=d.preferences(S._preferences,{convert:T}),S}strip(x=!0){return this.$_setFlag("result",x?"strip":void 0)}tag(...x){o(x.length,"Missing tags");for(const S of x)o(S&&typeof S=="string","Tags must be non-empty strings");return this._inner("tags",x)}unit(x){return o(x&&typeof x=="string","Unit name must be a non-empty string"),this.$_setFlag("unit",x)}valid(...x){d.verifyFlat(x,"valid");const S=this.allow(...x);return S.$_setFlag("only",!!S._valids,{clone:!1}),S}when(x,S){const T=this.clone();T.$_terms.whens||(T.$_terms.whens=[]);const A=f.when(T,x,S);if(!["any","link"].includes(T.type)){const R=A.is?[A]:A.switch;for(const M of R)o(!M.then||M.then.type==="any"||M.then.type===T.type,"Cannot combine",T.type,"with",M.then&&M.then.type),o(!M.otherwise||M.otherwise.type==="any"||M.otherwise.type===T.type,"Cannot combine",T.type,"with",M.otherwise&&M.otherwise.type)}return T.$_terms.whens.push(A),T.$_mutateRebuild()}cache(x){o(!this._inRuleset(),"Cannot set caching inside a ruleset"),o(!this._cache,"Cannot override schema cache"),o(this._flags.artifact===void 0,"Cannot cache a rule with an artifact");const S=this.clone();return S._cache=x||l.provider.provision(),S.$_temp.ruleset=!1,S}clone(){const x=Object.create(Object.getPrototypeOf(this));return this._assign(x)}concat(x){o(d.isSchema(x),"Invalid schema object"),o(this.type==="any"||x.type==="any"||x.type===this.type,"Cannot merge type",this.type,"with another type:",x.type),o(!this._inRuleset(),"Cannot concatenate onto a schema with open ruleset"),o(!x._inRuleset(),"Cannot concatenate a schema with open ruleset");let S=this.clone();if(this.type==="any"&&x.type!=="any"){const T=x.clone();for(const A of Object.keys(S))A!=="type"&&(T[A]=S[A]);S=T}S._ids.concat(x._ids),S._refs.register(x,v.toSibling),S._preferences=S._preferences?d.preferences(S._preferences,x._preferences):x._preferences,S._valids=_.merge(S._valids,x._valids,x._invalids),S._invalids=_.merge(S._invalids,x._invalids,x._valids);for(const T of x._singleRules.keys())S._singleRules.has(T)&&(S._rules=S._rules.filter(A=>A.keep||A.name!==T),S._singleRules.delete(T));for(const T of x._rules)x._definition.rules[T.method].multi||S._singleRules.set(T.name,T),S._rules.push(T);if(S._flags.empty&&x._flags.empty){S._flags.empty=S._flags.empty.concat(x._flags.empty);const T=Object.assign({},x._flags);delete T.empty,h(S._flags,T)}else if(x._flags.empty){S._flags.empty=x._flags.empty;const T=Object.assign({},x._flags);delete T.empty,h(S._flags,T)}else h(S._flags,x._flags);for(const T in x.$_terms){const A=x.$_terms[T];A?S.$_terms[T]?S.$_terms[T]=S.$_terms[T].concat(A):S.$_terms[T]=A.slice():S.$_terms[T]||(S.$_terms[T]=A)}return this.$_root._tracer&&this.$_root._tracer._combine(S,[this,x]),S.$_mutateRebuild()}extend(x){return o(!x.base,"Cannot extend type with another base"),m.type(this,x)}extract(x){return x=Array.isArray(x)?x:x.split("."),this._ids.reach(x)}fork(x,S){o(!this._inRuleset(),"Cannot fork inside a ruleset");let T=this;for(let A of[].concat(x))A=Array.isArray(A)?A:A.split("."),T=T._ids.fork(A,S,T);return T.$_temp.ruleset=!1,T}rule(x){const S=this._definition;d.assertOptions(x,Object.keys(S.modifiers)),o(this.$_temp.ruleset!==!1,"Cannot apply rules to empty ruleset or the last rule added does not support rule properties");const T=this.$_temp.ruleset===null?this._rules.length-1:this.$_temp.ruleset;o(T>=0&&T<this._rules.length,"Cannot apply rules to empty ruleset");const A=this.clone();for(let R=T;R<A._rules.length;++R){const M=A._rules[R],j=c(M);for(const W in x)S.modifiers[W](j,x[W]),o(j.name===M.name,"Cannot change rule name");A._rules[R]=j,A._singleRules.get(j.name)===M&&A._singleRules.set(j.name,j)}return A.$_temp.ruleset=!1,A.$_mutateRebuild()}get ruleset(){o(!this._inRuleset(),"Cannot start a new ruleset without closing the previous one");const x=this.clone();return x.$_temp.ruleset=x._rules.length,x}get $(){return this.ruleset}tailor(x){x=[].concat(x),o(!this._inRuleset(),"Cannot tailor inside a ruleset");let S=this;if(this.$_terms.alterations)for(const{target:T,adjuster:A}of this.$_terms.alterations)x.includes(T)&&(S=A(S),o(d.isSchema(S),"Alteration adjuster for",T,"failed to return a schema object"));return S=S.$_modify({each:T=>T.tailor(x),ref:!1}),S.$_temp.ruleset=!1,S.$_mutateRebuild()}tracer(){return k.location?k.location(this):this}validate(x,S){return C.entry(x,this,S)}validateAsync(x,S){return C.entryAsync(x,this,S)}$_addRule(x){typeof x=="string"&&(x={name:x}),o(x&&typeof x=="object","Invalid options"),o(x.name&&typeof x.name=="string","Invalid rule name");for(const M in x)o(M[0]!=="_","Cannot set private rule properties");const S=Object.assign({},x);S._resolve=[],S.method=S.method||S.name;const T=this._definition.rules[S.method],A=S.args;o(T,"Unknown rule",S.method);const R=this.clone();if(A){o(Object.keys(A).length===1||Object.keys(A).length===this._definition.rules[S.name].args.length,"Invalid rule definition for",this.type,S.name);for(const M in A){let j=A[M];if(T.argsByName){const W=T.argsByName.get(M);if(W.ref&&d.isResolvable(j))S._resolve.push(M),R.$_mutateRegister(j);else if(W.normalize&&(j=W.normalize(j),A[M]=j),W.assert){const se=d.validateArg(j,M,W);o(!se,se,"or reference")}}j!==void 0?A[M]=j:delete A[M]}}return T.multi||(R._ruleRemove(S.name,{clone:!1}),R._singleRules.set(S.name,S)),R.$_temp.ruleset===!1&&(R.$_temp.ruleset=null),T.priority?R._rules.unshift(S):R._rules.push(S),R}$_compile(x,S){return f.schema(this.$_root,x,S)}$_createError(x,S,T,A,R,M={}){const j=M.flags!==!1?this._flags:{},W=M.messages?g.merge(this._definition.messages,M.messages):this._definition.messages;return new p.Report(x,S,T,j,W,A,R)}$_getFlag(x){return this._flags[x]}$_getRule(x){return this._singleRules.get(x)}$_mapLabels(x){return x=Array.isArray(x)?x:x.split("."),this._ids.labels(x)}$_match(x,S,T,A){(T=Object.assign({},T)).abortEarly=!0,T._externals=!1,S.snapshot();const R=!C.validate(x,this,S,T,A).errors;return S.restore(),R}$_modify(x){return d.assertOptions(x,["each","once","ref","schema"]),y.schema(this,x)||this}$_mutateRebuild(){return o(!this._inRuleset(),"Cannot add this rule inside a ruleset"),this._refs.reset(),this._ids.reset(),this.$_modify({each:(x,{source:S,name:T,path:A,key:R})=>{const M=this._definition[S][T]&&this._definition[S][T].register;M!==!1&&this.$_mutateRegister(x,{family:M,key:R})}}),this._definition.rebuild&&this._definition.rebuild(this),this.$_temp.ruleset=!1,this}$_mutateRegister(x,{family:S,key:T}={}){this._refs.register(x,S),this._ids.register(x,{key:T})}$_property(x){return this._definition.properties[x]}$_reach(x){return this._ids.reach(x)}$_rootReferences(){return this._refs.roots()}$_setFlag(x,S,T={}){o(x[0]==="_"||!this._inRuleset(),"Cannot set flag inside a ruleset");const A=this._definition.flags[x]||{};if(u(S,A.default)&&(S=void 0),u(S,this._flags[x]))return this;const R=T.clone!==!1?this.clone():this;return S!==void 0?(R._flags[x]=S,R.$_mutateRegister(S)):delete R._flags[x],x[0]!=="_"&&(R.$_temp.ruleset=!1),R}$_parent(x,...S){return this[x][d.symbols.parent].call(this,...S)}$_validate(x,S,T){return C.validate(x,this,S,T)}_assign(x){x.type=this.type,x.$_root=this.$_root,x.$_temp=Object.assign({},this.$_temp),x.$_temp.whens={},x._ids=this._ids.clone(),x._preferences=this._preferences,x._valids=this._valids&&this._valids.clone(),x._invalids=this._invalids&&this._invalids.clone(),x._rules=this._rules.slice(),x._singleRules=c(this._singleRules,{shallow:!0}),x._refs=this._refs.clone(),x._flags=Object.assign({},this._flags),x._cache=null,x.$_terms={};for(const S in this.$_terms)x.$_terms[S]=this.$_terms[S]?this.$_terms[S].slice():null;x.$_super={};for(const S in this.$_super)x.$_super[S]=this._super[S].bind(x);return x}_bare(){const x=this.clone();x._reset();const S=x._definition.terms;for(const T in S){const A=S[T];x.$_terms[T]=A.init}return x.$_mutateRebuild()}_default(x,S,T={}){return d.assertOptions(T,"literal"),o(S!==void 0,"Missing",x,"value"),o(typeof S=="function"||!T.literal,"Only function value supports literal option"),typeof S=="function"&&T.literal&&(S={[d.symbols.literal]:!0,literal:S}),this.$_setFlag(x,S)}_generate(x,S,T){if(!this.$_terms.whens)return{schema:this};const A=[],R=[];for(let W=0;W<this.$_terms.whens.length;++W){const se=this.$_terms.whens[W];if(se.concat){A.push(se.concat),R.push(`${W}.concat`);continue}const Y=se.ref?se.ref.resolve(x,S,T):x,ae=se.is?[se]:se.switch,he=R.length;for(let Q=0;Q<ae.length;++Q){const{is:we,then:Le,otherwise:Ze}=ae[Q],st=`${W}${se.switch?"."+Q:""}`;if(we.$_match(Y,S.nest(we,`${st}.is`),T)){if(Le){const ht=S.localize([...S.path,`${st}.then`],S.ancestors,S.schemas),{schema:St,id:dt}=Le._generate(x,ht,T);A.push(St),R.push(`${st}.then${dt?`(${dt})`:""}`);break}}else if(Ze){const ht=S.localize([...S.path,`${st}.otherwise`],S.ancestors,S.schemas),{schema:St,id:dt}=Ze._generate(x,ht,T);A.push(St),R.push(`${st}.otherwise${dt?`(${dt})`:""}`);break}}if(se.break&&R.length>he)break}const M=R.join(", ");if(S.mainstay.tracer.debug(S,"rule","when",M),!M)return{schema:this};if(!S.mainstay.tracer.active&&this.$_temp.whens[M])return{schema:this.$_temp.whens[M],id:M};let j=this;this._definition.generate&&(j=this._definition.generate(this,x,S,T));for(const W of A)j=j.concat(W);return this.$_root._tracer&&this.$_root._tracer._combine(j,[this,...A]),this.$_temp.whens[M]=j,{schema:j,id:M}}_inner(x,S,T={}){o(!this._inRuleset(),`Cannot set ${x} inside a ruleset`);const A=this.clone();return A.$_terms[x]&&!T.override||(A.$_terms[x]=[]),T.single?A.$_terms[x].push(S):A.$_terms[x].push(...S),A.$_temp.ruleset=!1,A}_inRuleset(){return this.$_temp.ruleset!==null&&this.$_temp.ruleset!==!1}_ruleRemove(x,S={}){if(!this._singleRules.has(x))return this;const T=S.clone!==!1?this.clone():this;T._singleRules.delete(x);const A=[];for(let R=0;R<T._rules.length;++R){const M=T._rules[R];M.name!==x||M.keep?A.push(M):T._inRuleset()&&R<T.$_temp.ruleset&&--T.$_temp.ruleset}return T._rules=A,T}_values(x,S){d.verifyFlat(x,S.slice(1,-1));const T=this.clone(),A=x[0]===d.symbols.override;if(A&&(x=x.slice(1)),!T[S]&&x.length?T[S]=new _:A&&(T[S]=x.length?new _:null,T.$_mutateRebuild()),!T[S])return T;A&&T[S].override();for(const R of x){o(R!==void 0,"Cannot call allow/valid/invalid with undefined"),o(R!==d.symbols.override,"Override must be the first value");const M=S==="_invalids"?"_valids":"_invalids";T[M]&&(T[M].remove(R),T[M].length||(o(S==="_valids"||!T._flags.only,"Setting invalid value",R,"leaves schema rejecting all values due to previous valid rule"),T[M]=null)),T[S].add(R,T._refs)}return T}}};E.Base.prototype[d.symbols.any]={version:d.version,compile:f.compile,root:"$_root"},E.Base.prototype.isImmutable=!0,E.Base.prototype.deny=E.Base.prototype.invalid,E.Base.prototype.disallow=E.Base.prototype.invalid,E.Base.prototype.equal=E.Base.prototype.valid,E.Base.prototype.exist=E.Base.prototype.required,E.Base.prototype.not=E.Base.prototype.invalid,E.Base.prototype.options=E.Base.prototype.prefs,E.Base.prototype.preferences=E.Base.prototype.prefs,r.exports=new E.Base},8652:(r,n,a)=>{const o=a(375),c=a(8571),u=a(8160),h={max:1e3,supported:new Set(["undefined","boolean","number","string"])};n.provider={provision:l=>new h.Cache(l)},h.Cache=class{constructor(l={}){u.assertOptions(l,["max"]),o(l.max===void 0||l.max&&l.max>0&&isFinite(l.max),"Invalid max cache size"),this._max=l.max||h.max,this._map=new Map,this._list=new h.List}get length(){return this._map.size}set(l,d){if(l!==null&&!h.supported.has(typeof l))return;let f=this._map.get(l);if(f)return f.value=d,void this._list.first(f);f=this._list.unshift({key:l,value:d}),this._map.set(l,f),this._compact()}get(l){const d=this._map.get(l);if(d)return this._list.first(d),c(d.value)}_compact(){if(this._map.size>this._max){const l=this._list.pop();this._map.delete(l.key)}}},h.List=class{constructor(){this.tail=null,this.head=null}unshift(l){return l.next=null,l.prev=this.head,this.head&&(this.head.next=l),this.head=l,this.tail||(this.tail=l),l}first(l){l!==this.head&&(this._remove(l),this.unshift(l))}pop(){return this._remove(this.tail)}_remove(l){const{next:d,prev:f}=l;return d.prev=f,f&&(f.next=d),l===this.tail&&(this.tail=d),l.prev=null,l.next=null,l}}},8160:(r,n,a)=>{const o=a(375),c=a(7916),u=a(5934);let h,l;const d={isoDate:/^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/};n.version=u.version,n.defaults={abortEarly:!0,allowUnknown:!1,artifacts:!1,cache:!0,context:null,convert:!0,dateFormat:"iso",errors:{escapeHtml:!1,label:"path",language:null,render:!0,stack:!1,wrap:{label:'"',array:"[]"}},externals:!0,messages:{},nonEnumerables:!1,noDefaults:!1,presence:"optional",skipFunctions:!1,stripUnknown:!1,warnings:!1},n.symbols={any:Symbol.for("@hapi/joi/schema"),arraySingle:Symbol("arraySingle"),deepDefault:Symbol("deepDefault"),errors:Symbol("errors"),literal:Symbol("literal"),override:Symbol("override"),parent:Symbol("parent"),prefs:Symbol("prefs"),ref:Symbol("ref"),template:Symbol("template"),values:Symbol("values")},n.assertOptions=function(f,p,m="Options"){o(f&&typeof f=="object"&&!Array.isArray(f),"Options must be of type object");const b=Object.keys(f).filter(g=>!p.includes(g));o(b.length===0,`${m} contain unknown keys: ${b}`)},n.checkPreferences=function(f){l=l||a(3378);const p=l.preferences.validate(f);if(p.error)throw new c([p.error.details[0].message])},n.compare=function(f,p,m){switch(m){case"=":return f===p;case">":return f>p;case"<":return f<p;case">=":return f>=p;case"<=":return f<=p}},n.default=function(f,p){return f===void 0?p:f},n.isIsoDate=function(f){return d.isoDate.test(f)},n.isNumber=function(f){return typeof f=="number"&&!isNaN(f)},n.isResolvable=function(f){return!!f&&(f[n.symbols.ref]||f[n.symbols.template])},n.isSchema=function(f,p={}){const m=f&&f[n.symbols.any];return!!m&&(o(p.legacy||m.version===n.version,"Cannot mix different versions of joi schemas"),!0)},n.isValues=function(f){return f[n.symbols.values]},n.limit=function(f){return Number.isSafeInteger(f)&&f>=0},n.preferences=function(f,p){h=h||a(6914),f=f||{},p=p||{};const m=Object.assign({},f,p);return p.errors&&f.errors&&(m.errors=Object.assign({},f.errors,p.errors),m.errors.wrap=Object.assign({},f.errors.wrap,p.errors.wrap)),p.messages&&(m.messages=h.compile(p.messages,f.messages)),delete m[n.symbols.prefs],m},n.tryWithPath=function(f,p,m={}){try{return f()}catch(b){throw b.path!==void 0?b.path=p+"."+b.path:b.path=p,m.append&&(b.message=`${b.message} (${b.path})`),b}},n.validateArg=function(f,p,{assert:m,message:b}){if(n.isSchema(m)){const g=m.validate(f);return g.error?g.error.message:void 0}if(!m(f))return p?`${p} ${b}`:b},n.verifyFlat=function(f,p){for(const m of f)o(!Array.isArray(m),"Method no longer accepts array arguments:",p)}},3292:(r,n,a)=>{const o=a(375),c=a(8160),u=a(6133),h={};n.schema=function(l,d,f={}){c.assertOptions(f,["appendPath","override"]);try{return h.schema(l,d,f)}catch(p){throw f.appendPath&&p.path!==void 0&&(p.message=`${p.message} (${p.path})`),p}},h.schema=function(l,d,f){o(d!==void 0,"Invalid undefined schema"),Array.isArray(d)&&(o(d.length,"Invalid empty array schema"),d.length===1&&(d=d[0]));const p=(m,...b)=>f.override!==!1?m.valid(l.override,...b):m.valid(...b);if(h.simple(d))return p(l,d);if(typeof d=="function")return l.custom(d);if(o(typeof d=="object","Invalid schema content:",typeof d),c.isResolvable(d))return p(l,d);if(c.isSchema(d))return d;if(Array.isArray(d)){for(const m of d)if(!h.simple(m))return l.alternatives().try(...d);return p(l,...d)}return d instanceof RegExp?l.string().regex(d):d instanceof Date?p(l.date(),d):(o(Object.getPrototypeOf(d)===Object.getPrototypeOf({}),"Schema can only contain plain objects"),l.object().keys(d))},n.ref=function(l,d){return u.isRef(l)?l:u.create(l,d)},n.compile=function(l,d,f={}){c.assertOptions(f,["legacy"]);const p=d&&d[c.symbols.any];if(p)return o(f.legacy||p.version===c.version,"Cannot mix different versions of joi schemas:",p.version,c.version),d;if(typeof d!="object"||!f.legacy)return n.schema(l,d,{appendPath:!0});const m=h.walk(d);return m?m.compile(m.root,d):n.schema(l,d,{appendPath:!0})},h.walk=function(l){if(typeof l!="object")return null;if(Array.isArray(l)){for(const f of l){const p=h.walk(f);if(p)return p}return null}const d=l[c.symbols.any];if(d)return{root:l[d.root],compile:d.compile};o(Object.getPrototypeOf(l)===Object.getPrototypeOf({}),"Schema can only contain plain objects");for(const f in l){const p=h.walk(l[f]);if(p)return p}return null},h.simple=function(l){return l===null||["boolean","string","number"].includes(typeof l)},n.when=function(l,d,f){if(f===void 0&&(o(d&&typeof d=="object","Missing options"),f=d,d=u.create(".")),Array.isArray(f)&&(f={switch:f}),c.assertOptions(f,["is","not","then","otherwise","switch","break"]),c.isSchema(d))return o(f.is===void 0,'"is" can not be used with a schema condition'),o(f.not===void 0,'"not" can not be used with a schema condition'),o(f.switch===void 0,'"switch" can not be used with a schema condition'),h.condition(l,{is:d,then:f.then,otherwise:f.otherwise,break:f.break});if(o(u.isRef(d)||typeof d=="string","Invalid condition:",d),o(f.not===void 0||f.is===void 0,'Cannot combine "is" with "not"'),f.switch===void 0){let m=f;f.not!==void 0&&(m={is:f.not,then:f.otherwise,otherwise:f.then,break:f.break});let b=m.is!==void 0?l.$_compile(m.is):l.$_root.invalid(null,!1,0,"").required();return o(m.then!==void 0||m.otherwise!==void 0,'options must have at least one of "then", "otherwise", or "switch"'),o(m.break===void 0||m.then===void 0||m.otherwise===void 0,"Cannot specify then, otherwise, and break all together"),f.is===void 0||u.isRef(f.is)||c.isSchema(f.is)||(b=b.required()),h.condition(l,{ref:n.ref(d),is:b,then:m.then,otherwise:m.otherwise,break:m.break})}o(Array.isArray(f.switch),'"switch" must be an array'),o(f.is===void 0,'Cannot combine "switch" with "is"'),o(f.not===void 0,'Cannot combine "switch" with "not"'),o(f.then===void 0,'Cannot combine "switch" with "then"');const p={ref:n.ref(d),switch:[],break:f.break};for(let m=0;m<f.switch.length;++m){const b=f.switch[m],g=m===f.switch.length-1;c.assertOptions(b,g?["is","then","otherwise"]:["is","then"]),o(b.is!==void 0,'Switch statement missing "is"'),o(b.then!==void 0,'Switch statement missing "then"');const y={is:l.$_compile(b.is),then:l.$_compile(b.then)};if(u.isRef(b.is)||c.isSchema(b.is)||(y.is=y.is.required()),g){o(f.otherwise===void 0||b.otherwise===void 0,'Cannot specify "otherwise" inside and outside a "switch"');const v=f.otherwise!==void 0?f.otherwise:b.otherwise;v!==void 0&&(o(p.break===void 0,"Cannot specify both otherwise and break"),y.otherwise=l.$_compile(v))}p.switch.push(y)}return p},h.condition=function(l,d){for(const f of["then","otherwise"])d[f]===void 0?delete d[f]:d[f]=l.$_compile(d[f]);return d}},6354:(r,n,a)=>{const o=a(5688),c=a(8160),u=a(3328);n.Report=class{constructor(h,l,d,f,p,m,b){if(this.code=h,this.flags=f,this.messages=p,this.path=m.path,this.prefs=b,this.state=m,this.value=l,this.message=null,this.template=null,this.local=d||{},this.local.label=n.label(this.flags,this.state,this.prefs,this.messages),this.value===void 0||this.local.hasOwnProperty("value")||(this.local.value=this.value),this.path.length){const g=this.path[this.path.length-1];typeof g!="object"&&(this.local.key=g)}}_setTemplate(h){if(this.template=h,!this.flags.label&&this.path.length===0){const l=this._template(this.template,"root");l&&(this.local.label=l)}}toString(){if(this.message)return this.message;const h=this.code;if(!this.prefs.errors.render)return this.code;const l=this._template(this.template)||this._template(this.prefs.messages)||this._template(this.messages);return l===void 0?`Error code "${h}" is not defined, your custom type is missing the correct messages definition`:(this.message=l.render(this.value,this.state,this.prefs,this.local,{errors:this.prefs.errors,messages:[this.prefs.messages,this.messages]}),this.prefs.errors.label||(this.message=this.message.replace(/^"" /,"").trim()),this.message)}_template(h,l){return n.template(this.value,h,l||this.code,this.state,this.prefs)}},n.path=function(h){let l="";for(const d of h)typeof d!="object"&&(typeof d=="string"?(l&&(l+="."),l+=d):l+=`[${d}]`);return l},n.template=function(h,l,d,f,p){if(!l)return;if(u.isTemplate(l))return d!=="root"?l:null;let m=p.errors.language;if(c.isResolvable(m)&&(m=m.resolve(h,f,p)),m&&l[m]){if(l[m][d]!==void 0)return l[m][d];if(l[m]["*"]!==void 0)return l[m]["*"]}return l[d]?l[d]:l["*"]},n.label=function(h,l,d,f){if(!d.errors.label)return"";if(h.label)return h.label;let p=l.path;return d.errors.label==="key"&&l.path.length>1&&(p=l.path.slice(-1)),n.path(p)||n.template(null,d.messages,"root",l,d)||f&&n.template(null,f,"root",l,d)||"value"},n.process=function(h,l,d){if(!h)return null;const{override:f,message:p,details:m}=n.details(h);if(f)return f;if(d.errors.stack)return new n.ValidationError(p,m,l);const b=Error.stackTraceLimit;Error.stackTraceLimit=0;const g=new n.ValidationError(p,m,l);return Error.stackTraceLimit=b,g},n.details=function(h,l={}){let d=[];const f=[];for(const p of h){if(p instanceof Error){if(l.override!==!1)return{override:p};const b=p.toString();d.push(b),f.push({message:b,type:"override",context:{error:p}});continue}const m=p.toString();d.push(m),f.push({message:m,path:p.path.filter(b=>typeof b!="object"),type:p.code,context:p.local})}return d.length>1&&(d=[...new Set(d)]),{message:d.join(". "),details:f}},n.ValidationError=class extends Error{constructor(h,l,d){super(h),this._original=d,this.details=l}static isError(h){return h instanceof n.ValidationError}},n.ValidationError.prototype.isJoi=!0,n.ValidationError.prototype.name="ValidationError",n.ValidationError.prototype.annotate=o.error},8901:(r,n,a)=>{const o=a(375),c=a(8571),u=a(8160),h=a(6914),l={};n.type=function(d,f){const p=Object.getPrototypeOf(d),m=c(p),b=d._assign(Object.create(m)),g=Object.assign({},f);delete g.base,m._definition=g;const y=p._definition||{};g.messages=h.merge(y.messages,g.messages),g.properties=Object.assign({},y.properties,g.properties),b.type=g.type,g.flags=Object.assign({},y.flags,g.flags);const v=Object.assign({},y.terms);if(g.terms)for(const E in g.terms){const x=g.terms[E];o(b.$_terms[E]===void 0,"Invalid term override for",g.type,E),b.$_terms[E]=x.init,v[E]=x}g.terms=v,g.args||(g.args=y.args),g.prepare=l.prepare(g.prepare,y.prepare),g.coerce&&(typeof g.coerce=="function"&&(g.coerce={method:g.coerce}),g.coerce.from&&!Array.isArray(g.coerce.from)&&(g.coerce={method:g.coerce.method,from:[].concat(g.coerce.from)})),g.coerce=l.coerce(g.coerce,y.coerce),g.validate=l.validate(g.validate,y.validate);const k=Object.assign({},y.rules);if(g.rules)for(const E in g.rules){const x=g.rules[E];o(typeof x=="object","Invalid rule definition for",g.type,E);let S=x.method;if(S===void 0&&(S=function(){return this.$_addRule(E)}),S&&(o(!m[E],"Rule conflict in",g.type,E),m[E]=S),o(!k[E],"Rule conflict in",g.type,E),k[E]=x,x.alias){const T=[].concat(x.alias);for(const A of T)m[A]=x.method}x.args&&(x.argsByName=new Map,x.args=x.args.map(T=>(typeof T=="string"&&(T={name:T}),o(!x.argsByName.has(T.name),"Duplicated argument name",T.name),u.isSchema(T.assert)&&(T.assert=T.assert.strict().label(T.name)),x.argsByName.set(T.name,T),T)))}g.rules=k;const C=Object.assign({},y.modifiers);if(g.modifiers)for(const E in g.modifiers){o(!m[E],"Rule conflict in",g.type,E);const x=g.modifiers[E];o(typeof x=="function","Invalid modifier definition for",g.type,E);const S=function(T){return this.rule({[E]:T})};m[E]=S,C[E]=x}if(g.modifiers=C,g.overrides){m._super=p,b.$_super={};for(const E in g.overrides)o(p[E],"Cannot override missing",E),g.overrides[E][u.symbols.parent]=p[E],b.$_super[E]=p[E].bind(b);Object.assign(m,g.overrides)}g.cast=Object.assign({},y.cast,g.cast);const _=Object.assign({},y.manifest,g.manifest);return _.build=l.build(g.manifest&&g.manifest.build,y.manifest&&y.manifest.build),g.manifest=_,g.rebuild=l.rebuild(g.rebuild,y.rebuild),b},l.build=function(d,f){return d&&f?function(p,m){return f(d(p,m),m)}:d||f},l.coerce=function(d,f){return d&&f?{from:d.from&&f.from?[...new Set([...d.from,...f.from])]:null,method(p,m){let b;if((!f.from||f.from.includes(typeof p))&&(b=f.method(p,m),b)){if(b.errors||b.value===void 0)return b;p=b.value}if(!d.from||d.from.includes(typeof p)){const g=d.method(p,m);if(g)return g}return b}}:d||f},l.prepare=function(d,f){return d&&f?function(p,m){const b=d(p,m);if(b){if(b.errors||b.value===void 0)return b;p=b.value}return f(p,m)||b}:d||f},l.rebuild=function(d,f){return d&&f?function(p){f(p),d(p)}:d||f},l.validate=function(d,f){return d&&f?function(p,m){const b=f(p,m);if(b){if(b.errors&&(!Array.isArray(b.errors)||b.errors.length))return b;p=b.value}return d(p,m)||b}:d||f}},5107:(r,n,a)=>{const o=a(375),c=a(8571),u=a(8652),h=a(8160),l=a(3292),d=a(6354),f=a(8901),p=a(9708),m=a(6133),b=a(3328),g=a(1152);let y;const v={types:{alternatives:a(4946),any:a(8068),array:a(546),boolean:a(4937),date:a(7500),function:a(390),link:a(8785),number:a(3832),object:a(8966),string:a(7417),symbol:a(8826)},aliases:{alt:"alternatives",bool:"boolean",func:"function"},root:function(){const k={_types:new Set(Object.keys(v.types))};for(const C of k._types)k[C]=function(..._){return o(!_.length||["alternatives","link","object"].includes(C),"The",C,"type does not allow arguments"),v.generate(this,v.types[C],_)};for(const C of["allow","custom","disallow","equal","exist","forbidden","invalid","not","only","optional","options","prefs","preferences","required","strip","valid","when"])k[C]=function(..._){return this.any()[C](..._)};Object.assign(k,v.methods);for(const C in v.aliases){const _=v.aliases[C];k[C]=k[_]}return k.x=k.expression,g.setup&&g.setup(k),k}};v.methods={ValidationError:d.ValidationError,version:h.version,cache:u.provider,assert(k,C,..._){v.assert(k,C,!0,_)},attempt:(k,C,..._)=>v.assert(k,C,!1,_),build(k){return o(typeof p.build=="function","Manifest functionality disabled"),p.build(this,k)},checkPreferences(k){h.checkPreferences(k)},compile(k,C){return l.compile(this,k,C)},defaults(k){o(typeof k=="function","modifier must be a function");const C=Object.assign({},this);for(const _ of C._types){const E=k(C[_]());o(h.isSchema(E),"modifier must return a valid schema object"),C[_]=function(...x){return v.generate(this,E,x)}}return C},expression:(...k)=>new b(...k),extend(...k){h.verifyFlat(k,"extend"),y=y||a(3378),o(k.length,"You need to provide at least one extension"),this.assert(k,y.extensions);const C=Object.assign({},this);C._types=new Set(C._types);for(let _ of k){typeof _=="function"&&(_=_(C)),this.assert(_,y.extension);const E=v.expandExtension(_,C);for(const x of E){o(C[x.type]===void 0||C._types.has(x.type),"Cannot override name",x.type);const S=x.base||this.any(),T=f.type(S,x);C._types.add(x.type),C[x.type]=function(...A){return v.generate(this,T,A)}}}return C},isError:d.ValidationError.isError,isExpression:b.isTemplate,isRef:m.isRef,isSchema:h.isSchema,in:(...k)=>m.in(...k),override:h.symbols.override,ref:(...k)=>m.create(...k),types(){const k={};for(const C of this._types)k[C]=this[C]();for(const C in v.aliases)k[C]=this[C]();return k}},v.assert=function(k,C,_,E){const x=E[0]instanceof Error||typeof E[0]=="string"?E[0]:null,S=x!==null?E[1]:E[0],T=C.validate(k,h.preferences({errors:{stack:!0}},S||{}));let A=T.error;if(!A)return T.value;if(x instanceof Error)throw x;const R=_&&typeof A.annotate=="function"?A.annotate():A.message;throw A instanceof d.ValidationError==0&&(A=c(A)),A.message=x?`${x} ${R}`:R,A},v.generate=function(k,C,_){return o(k,"Must be invoked on a Joi instance."),C.$_root=k,C._definition.args&&_.length?C._definition.args(C,..._):C},v.expandExtension=function(k,C){if(typeof k.type=="string")return[k];const _=[];for(const E of C._types)if(k.type.test(E)){const x=Object.assign({},k);x.type=E,x.base=C[E](),_.push(x)}return _},r.exports=v.root()},6914:(r,n,a)=>{const o=a(375),c=a(8571),u=a(3328);n.compile=function(h,l){if(typeof h=="string")return o(!l,"Cannot set single message string"),new u(h);if(u.isTemplate(h))return o(!l,"Cannot set single message template"),h;o(typeof h=="object"&&!Array.isArray(h),"Invalid message options"),l=l?c(l):{};for(let d in h){const f=h[d];if(d==="root"||u.isTemplate(f)){l[d]=f;continue}if(typeof f=="string"){l[d]=new u(f);continue}o(typeof f=="object"&&!Array.isArray(f),"Invalid message for",d);const p=d;for(d in l[p]=l[p]||{},f){const m=f[d];d==="root"||u.isTemplate(m)?l[p][d]=m:(o(typeof m=="string","Invalid message for",d,"in",p),l[p][d]=new u(m))}}return l},n.decompile=function(h){const l={};for(let d in h){const f=h[d];if(d==="root"){l.root=f;continue}if(u.isTemplate(f)){l[d]=f.describe({compact:!0});continue}const p=d;for(d in l[p]={},f){const m=f[d];d!=="root"?l[p][d]=m.describe({compact:!0}):l[p].root=m}}return l},n.merge=function(h,l){if(!h)return n.compile(l);if(!l)return h;if(typeof l=="string")return new u(l);if(u.isTemplate(l))return l;const d=c(h);for(let f in l){const p=l[f];if(f==="root"||u.isTemplate(p)){d[f]=p;continue}if(typeof p=="string"){d[f]=new u(p);continue}o(typeof p=="object"&&!Array.isArray(p),"Invalid message for",f);const m=f;for(f in d[m]=d[m]||{},p){const b=p[f];f==="root"||u.isTemplate(b)?d[m][f]=b:(o(typeof b=="string","Invalid message for",f,"in",m),d[m][f]=new u(b))}}return d}},2294:(r,n,a)=>{const o=a(375),c=a(8160),u=a(6133),h={};n.Ids=h.Ids=class{constructor(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}clone(){const l=new h.Ids;return l._byId=new Map(this._byId),l._byKey=new Map(this._byKey),l._schemaChain=this._schemaChain,l}concat(l){l._schemaChain&&(this._schemaChain=!0);for(const[d,f]of l._byId.entries())o(!this._byKey.has(d),"Schema id conflicts with existing key:",d),this._byId.set(d,f);for(const[d,f]of l._byKey.entries())o(!this._byId.has(d),"Schema key conflicts with existing id:",d),this._byKey.set(d,f)}fork(l,d,f){const p=this._collect(l);p.push({schema:f});const m=p.shift();let b={id:m.id,schema:d(m.schema)};o(c.isSchema(b.schema),"adjuster function failed to return a joi schema type");for(const g of p)b={id:g.id,schema:h.fork(g.schema,b.id,b.schema)};return b.schema}labels(l,d=[]){const f=l[0],p=this._get(f);if(!p)return[...d,...l].join(".");const m=l.slice(1);return d=[...d,p.schema._flags.label||f],m.length?p.schema._ids.labels(m,d):d.join(".")}reach(l,d=[]){const f=l[0],p=this._get(f);o(p,"Schema does not contain path",[...d,...l].join("."));const m=l.slice(1);return m.length?p.schema._ids.reach(m,[...d,f]):p.schema}register(l,{key:d}={}){if(!l||!c.isSchema(l))return;(l.$_property("schemaChain")||l._ids._schemaChain)&&(this._schemaChain=!0);const f=l._flags.id;if(f){const p=this._byId.get(f);o(!p||p.schema===l,"Cannot add different schemas with the same id:",f),o(!this._byKey.has(f),"Schema id conflicts with existing key:",f),this._byId.set(f,{schema:l,id:f})}d&&(o(!this._byKey.has(d),"Schema already contains key:",d),o(!this._byId.has(d),"Schema key conflicts with existing id:",d),this._byKey.set(d,{schema:l,id:d}))}reset(){this._byId=new Map,this._byKey=new Map,this._schemaChain=!1}_collect(l,d=[],f=[]){const p=l[0],m=this._get(p);o(m,"Schema does not contain path",[...d,...l].join(".")),f=[m,...f];const b=l.slice(1);return b.length?m.schema._ids._collect(b,[...d,p],f):f}_get(l){return this._byId.get(l)||this._byKey.get(l)}},h.fork=function(l,d,f){const p=n.schema(l,{each:(m,{key:b})=>{if(d===(m._flags.id||b))return f},ref:!1});return p?p.$_mutateRebuild():l},n.schema=function(l,d){let f;for(const p in l._flags){if(p[0]==="_")continue;const m=h.scan(l._flags[p],{source:"flags",name:p},d);m!==void 0&&(f=f||l.clone(),f._flags[p]=m)}for(let p=0;p<l._rules.length;++p){const m=l._rules[p],b=h.scan(m.args,{source:"rules",name:m.name},d);if(b!==void 0){f=f||l.clone();const g=Object.assign({},m);g.args=b,f._rules[p]=g,f._singleRules.get(m.name)===m&&f._singleRules.set(m.name,g)}}for(const p in l.$_terms){if(p[0]==="_")continue;const m=h.scan(l.$_terms[p],{source:"terms",name:p},d);m!==void 0&&(f=f||l.clone(),f.$_terms[p]=m)}return f},h.scan=function(l,d,f,p,m){const b=p||[];if(l===null||typeof l!="object")return;let g;if(Array.isArray(l)){for(let y=0;y<l.length;++y){const v=d.source==="terms"&&d.name==="keys"&&l[y].key,k=h.scan(l[y],d,f,[y,...b],v);k!==void 0&&(g=g||l.slice(),g[y]=k)}return g}if(f.schema!==!1&&c.isSchema(l)||f.ref!==!1&&u.isRef(l)){const y=f.each(l,{...d,path:b,key:m});return y===l?void 0:y}for(const y in l){if(y[0]==="_")continue;const v=h.scan(l[y],d,f,[y,...b],m);v!==void 0&&(g=g||Object.assign({},l),g[y]=v)}return g}},6133:(r,n,a)=>{const o=a(375),c=a(8571),u=a(9621),h=a(8160);let l;const d={symbol:Symbol("ref"),defaults:{adjust:null,in:!1,iterables:null,map:null,separator:".",type:"value"}};n.create=function(f,p={}){o(typeof f=="string","Invalid reference key:",f),h.assertOptions(p,["adjust","ancestor","in","iterables","map","prefix","render","separator"]),o(!p.prefix||typeof p.prefix=="object","options.prefix must be of type object");const m=Object.assign({},d.defaults,p);delete m.prefix;const b=m.separator,g=d.context(f,b,p.prefix);if(m.type=g.type,f=g.key,m.type==="value")if(g.root&&(o(!b||f[0]!==b,"Cannot specify relative path with root prefix"),m.ancestor="root",f||(f=null)),b&&b===f)f=null,m.ancestor=0;else if(m.ancestor!==void 0)o(!b||!f||f[0]!==b,"Cannot combine prefix with ancestor option");else{const[y,v]=d.ancestor(f,b);v&&(f=f.slice(v))===""&&(f=null),m.ancestor=y}return m.path=b?f===null?[]:f.split(b):[f],new d.Ref(m)},n.in=function(f,p={}){return n.create(f,{...p,in:!0})},n.isRef=function(f){return!!f&&!!f[h.symbols.ref]},d.Ref=class{constructor(f){o(typeof f=="object","Invalid reference construction"),h.assertOptions(f,["adjust","ancestor","in","iterables","map","path","render","separator","type","depth","key","root","display"]),o([!1,void 0].includes(f.separator)||typeof f.separator=="string"&&f.separator.length===1,"Invalid separator"),o(!f.adjust||typeof f.adjust=="function","options.adjust must be a function"),o(!f.map||Array.isArray(f.map),"options.map must be an array"),o(!f.map||!f.adjust,"Cannot set both map and adjust options"),Object.assign(this,d.defaults,f),o(this.type==="value"||this.ancestor===void 0,"Non-value references cannot reference ancestors"),Array.isArray(this.map)&&(this.map=new Map(this.map)),this.depth=this.path.length,this.key=this.path.length?this.path.join(this.separator):null,this.root=this.path[0],this.updateDisplay()}resolve(f,p,m,b,g={}){return o(!this.in||g.in,"Invalid in() reference usage"),this.type==="global"?this._resolve(m.context,p,g):this.type==="local"?this._resolve(b,p,g):this.ancestor?this.ancestor==="root"?this._resolve(p.ancestors[p.ancestors.length-1],p,g):(o(this.ancestor<=p.ancestors.length,"Invalid reference exceeds the schema root:",this.display),this._resolve(p.ancestors[this.ancestor-1],p,g)):this._resolve(f,p,g)}_resolve(f,p,m){let b;if(this.type==="value"&&p.mainstay.shadow&&m.shadow!==!1&&(b=p.mainstay.shadow.get(this.absolute(p))),b===void 0&&(b=u(f,this.path,{iterables:this.iterables,functions:!0})),this.adjust&&(b=this.adjust(b)),this.map){const g=this.map.get(b);g!==void 0&&(b=g)}return p.mainstay&&p.mainstay.tracer.resolve(p,this,b),b}toString(){return this.display}absolute(f){return[...f.path.slice(0,-this.ancestor),...this.path]}clone(){return new d.Ref(this)}describe(){const f={path:this.path};this.type!=="value"&&(f.type=this.type),this.separator!=="."&&(f.separator=this.separator),this.type==="value"&&this.ancestor!==1&&(f.ancestor=this.ancestor),this.map&&(f.map=[...this.map]);for(const p of["adjust","iterables","render"])this[p]!==null&&this[p]!==void 0&&(f[p]=this[p]);return this.in!==!1&&(f.in=!0),{ref:f}}updateDisplay(){const f=this.key!==null?this.key:"";if(this.type!=="value")return void(this.display=`ref:${this.type}:${f}`);if(!this.separator)return void(this.display=`ref:${f}`);if(!this.ancestor)return void(this.display=`ref:${this.separator}${f}`);if(this.ancestor==="root")return void(this.display=`ref:root:${f}`);if(this.ancestor===1)return void(this.display=`ref:${f||".."}`);const p=new Array(this.ancestor+1).fill(this.separator).join("");this.display=`ref:${p}${f||""}`}},d.Ref.prototype[h.symbols.ref]=!0,n.build=function(f){return(f=Object.assign({},d.defaults,f)).type==="value"&&f.ancestor===void 0&&(f.ancestor=1),new d.Ref(f)},d.context=function(f,p,m={}){if(f=f.trim(),m){const b=m.global===void 0?"$":m.global;if(b!==p&&f.startsWith(b))return{key:f.slice(b.length),type:"global"};const g=m.local===void 0?"#":m.local;if(g!==p&&f.startsWith(g))return{key:f.slice(g.length),type:"local"};const y=m.root===void 0?"/":m.root;if(y!==p&&f.startsWith(y))return{key:f.slice(y.length),type:"value",root:!0}}return{key:f,type:"value"}},d.ancestor=function(f,p){if(!p)return[1,0];if(f[0]!==p)return[1,0];if(f[1]!==p)return[0,1];let m=2;for(;f[m]===p;)++m;return[m-1,m]},n.toSibling=0,n.toParent=1,n.Manager=class{constructor(){this.refs=[]}register(f,p){if(f)if(p=p===void 0?n.toParent:p,Array.isArray(f))for(const m of f)this.register(m,p);else if(h.isSchema(f))for(const m of f._refs.refs)m.ancestor-p>=0&&this.refs.push({ancestor:m.ancestor-p,root:m.root});else n.isRef(f)&&f.type==="value"&&f.ancestor-p>=0&&this.refs.push({ancestor:f.ancestor-p,root:f.root}),l=l||a(3328),l.isTemplate(f)&&this.register(f.refs(),p)}get length(){return this.refs.length}clone(){const f=new n.Manager;return f.refs=c(this.refs),f}reset(){this.refs=[]}roots(){return this.refs.filter(f=>!f.ancestor).map(f=>f.root)}}},3378:(r,n,a)=>{const o=a(5107),c={};c.wrap=o.string().min(1).max(2).allow(!1),n.preferences=o.object({allowUnknown:o.boolean(),abortEarly:o.boolean(),artifacts:o.boolean(),cache:o.boolean(),context:o.object(),convert:o.boolean(),dateFormat:o.valid("date","iso","string","time","utc"),debug:o.boolean(),errors:{escapeHtml:o.boolean(),label:o.valid("path","key",!1),language:[o.string(),o.object().ref()],render:o.boolean(),stack:o.boolean(),wrap:{label:c.wrap,array:c.wrap,string:c.wrap}},externals:o.boolean(),messages:o.object(),noDefaults:o.boolean(),nonEnumerables:o.boolean(),presence:o.valid("required","optional","forbidden"),skipFunctions:o.boolean(),stripUnknown:o.object({arrays:o.boolean(),objects:o.boolean()}).or("arrays","objects").allow(!0,!1),warnings:o.boolean()}).strict(),c.nameRx=/^[a-zA-Z0-9]\w*$/,c.rule=o.object({alias:o.array().items(o.string().pattern(c.nameRx)).single(),args:o.array().items(o.string(),o.object({name:o.string().pattern(c.nameRx).required(),ref:o.boolean(),assert:o.alternatives([o.function(),o.object().schema()]).conditional("ref",{is:!0,then:o.required()}),normalize:o.function(),message:o.string().when("assert",{is:o.function(),then:o.required()})})),convert:o.boolean(),manifest:o.boolean(),method:o.function().allow(!1),multi:o.boolean(),validate:o.function()}),n.extension=o.object({type:o.alternatives([o.string(),o.object().regex()]).required(),args:o.function(),cast:o.object().pattern(c.nameRx,o.object({from:o.function().maxArity(1).required(),to:o.function().minArity(1).maxArity(2).required()})),base:o.object().schema().when("type",{is:o.object().regex(),then:o.forbidden()}),coerce:[o.function().maxArity(3),o.object({method:o.function().maxArity(3).required(),from:o.array().items(o.string()).single()})],flags:o.object().pattern(c.nameRx,o.object({setter:o.string(),default:o.any()})),manifest:{build:o.function().arity(2)},messages:[o.object(),o.string()],modifiers:o.object().pattern(c.nameRx,o.function().minArity(1).maxArity(2)),overrides:o.object().pattern(c.nameRx,o.function()),prepare:o.function().maxArity(3),rebuild:o.function().arity(1),rules:o.object().pattern(c.nameRx,c.rule),terms:o.object().pattern(c.nameRx,o.object({init:o.array().allow(null).required(),manifest:o.object().pattern(/.+/,[o.valid("schema","single"),o.object({mapped:o.object({from:o.string().required(),to:o.string().required()}).required()})])})),validate:o.function().maxArity(3)}).strict(),n.extensions=o.array().items(o.object(),o.function().arity(1)).strict(),c.desc={buffer:o.object({buffer:o.string()}),func:o.object({function:o.function().required(),options:{literal:!0}}),override:o.object({override:!0}),ref:o.object({ref:o.object({type:o.valid("value","global","local"),path:o.array().required(),separator:o.string().length(1).allow(!1),ancestor:o.number().min(0).integer().allow("root"),map:o.array().items(o.array().length(2)).min(1),adjust:o.function(),iterables:o.boolean(),in:o.boolean(),render:o.boolean()}).required()}),regex:o.object({regex:o.string().min(3)}),special:o.object({special:o.valid("deep").required()}),template:o.object({template:o.string().required(),options:o.object()}),value:o.object({value:o.alternatives([o.object(),o.array()]).required()})},c.desc.entity=o.alternatives([o.array().items(o.link("...")),o.boolean(),o.function(),o.number(),o.string(),c.desc.buffer,c.desc.func,c.desc.ref,c.desc.regex,c.desc.special,c.desc.template,c.desc.value,o.link("/")]),c.desc.values=o.array().items(null,o.boolean(),o.function(),o.number().allow(1/0,-1/0),o.string().allow(""),o.symbol(),c.desc.buffer,c.desc.func,c.desc.override,c.desc.ref,c.desc.regex,c.desc.template,c.desc.value),c.desc.messages=o.object().pattern(/.+/,[o.string(),c.desc.template,o.object().pattern(/.+/,[o.string(),c.desc.template])]),n.description=o.object({type:o.string().required(),flags:o.object({cast:o.string(),default:o.any(),description:o.string(),empty:o.link("/"),failover:c.desc.entity,id:o.string(),label:o.string(),only:!0,presence:["optional","required","forbidden"],result:["raw","strip"],strip:o.boolean(),unit:o.string()}).unknown(),preferences:{allowUnknown:o.boolean(),abortEarly:o.boolean(),artifacts:o.boolean(),cache:o.boolean(),convert:o.boolean(),dateFormat:["date","iso","string","time","utc"],errors:{escapeHtml:o.boolean(),label:["path","key"],language:[o.string(),c.desc.ref],wrap:{label:c.wrap,array:c.wrap}},externals:o.boolean(),messages:c.desc.messages,noDefaults:o.boolean(),nonEnumerables:o.boolean(),presence:["required","optional","forbidden"],skipFunctions:o.boolean(),stripUnknown:o.object({arrays:o.boolean(),objects:o.boolean()}).or("arrays","objects").allow(!0,!1),warnings:o.boolean()},allow:c.desc.values,invalid:c.desc.values,rules:o.array().min(1).items({name:o.string().required(),args:o.object().min(1),keep:o.boolean(),message:[o.string(),c.desc.messages],warn:o.boolean()}),keys:o.object().pattern(/.*/,o.link("/")),link:c.desc.ref}).pattern(/^[a-z]\w*$/,o.any())},493:(r,n,a)=>{const o=a(8571),c=a(9621),u=a(8160),h={value:Symbol("value")};r.exports=h.State=class{constructor(l,d,f){this.path=l,this.ancestors=d,this.mainstay=f.mainstay,this.schemas=f.schemas,this.debug=null}localize(l,d=null,f=null){const p=new h.State(l,d,this);return f&&p.schemas&&(p.schemas=[h.schemas(f),...p.schemas]),p}nest(l,d){const f=new h.State(this.path,this.ancestors,this);return f.schemas=f.schemas&&[h.schemas(l),...f.schemas],f.debug=d,f}shadow(l,d){this.mainstay.shadow=this.mainstay.shadow||new h.Shadow,this.mainstay.shadow.set(this.path,l,d)}snapshot(){this.mainstay.shadow&&(this._snapshot=o(this.mainstay.shadow.node(this.path))),this.mainstay.snapshot()}restore(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.restore()}commit(){this.mainstay.shadow&&(this.mainstay.shadow.override(this.path,this._snapshot),this._snapshot=void 0),this.mainstay.commit()}},h.schemas=function(l){return u.isSchema(l)?{schema:l}:l},h.Shadow=class{constructor(){this._values=null}set(l,d,f){if(!l.length||f==="strip"&&typeof l[l.length-1]=="number")return;this._values=this._values||new Map;let p=this._values;for(let m=0;m<l.length;++m){const b=l[m];let g=p.get(b);g||(g=new Map,p.set(b,g)),p=g}p[h.value]=d}get(l){const d=this.node(l);if(d)return d[h.value]}node(l){if(this._values)return c(this._values,l,{iterables:!0})}override(l,d){if(!this._values)return;const f=l.slice(0,-1),p=l[l.length-1],m=c(this._values,f,{iterables:!0});d?m.set(p,d):m&&m.delete(p)}}},3328:(r,n,a)=>{const o=a(375),c=a(8571),u=a(5277),h=a(1447),l=a(8160),d=a(6354),f=a(6133),p={symbol:Symbol("template"),opens:new Array(1e3).join("\0"),closes:new Array(1e3).join(""),dateFormat:{date:Date.prototype.toDateString,iso:Date.prototype.toISOString,string:Date.prototype.toString,time:Date.prototype.toTimeString,utc:Date.prototype.toUTCString}};r.exports=p.Template=class{constructor(m,b){if(o(typeof m=="string","Template source must be a string"),o(!m.includes("\0")&&!m.includes(""),"Template source cannot contain reserved control characters"),this.source=m,this.rendered=m,this._template=null,b){const{functions:g,...y}=b;this._settings=Object.keys(y).length?c(y):void 0,this._functions=g,this._functions&&(o(Object.keys(this._functions).every(v=>typeof v=="string"),"Functions keys must be strings"),o(Object.values(this._functions).every(v=>typeof v=="function"),"Functions values must be functions"))}else this._settings=void 0,this._functions=void 0;this._parse()}_parse(){if(!this.source.includes("{"))return;const m=p.encode(this.source),b=p.split(m);let g=!1;const y=[],v=b.shift();v&&y.push(v);for(const k of b){const C=k[0]!=="{",_=C?"}":"}}",E=k.indexOf(_);if(E===-1||k[1]==="{"){y.push(`{${p.decode(k)}`);continue}let x=k.slice(C?0:1,E);const S=x[0]===":";S&&(x=x.slice(1));const T=this._ref(p.decode(x),{raw:C,wrapped:S});y.push(T),typeof T!="string"&&(g=!0);const A=k.slice(E+_.length);A&&y.push(p.decode(A))}g?this._template=y:this.rendered=y.join("")}static date(m,b){return p.dateFormat[b.dateFormat].call(m)}describe(m={}){if(!this._settings&&m.compact)return this.source;const b={template:this.source};return this._settings&&(b.options=this._settings),this._functions&&(b.functions=this._functions),b}static build(m){return new p.Template(m.template,m.options||m.functions?{...m.options,functions:m.functions}:void 0)}isDynamic(){return!!this._template}static isTemplate(m){return!!m&&!!m[l.symbols.template]}refs(){if(!this._template)return;const m=[];for(const b of this._template)typeof b!="string"&&m.push(...b.refs);return m}resolve(m,b,g,y){return this._template&&this._template.length===1?this._part(this._template[0],m,b,g,y,{}):this.render(m,b,g,y)}_part(m,...b){return m.ref?m.ref.resolve(...b):m.formula.evaluate(b)}render(m,b,g,y,v={}){if(!this.isDynamic())return this.rendered;const k=[];for(const C of this._template)if(typeof C=="string")k.push(C);else{const _=this._part(C,m,b,g,y,v),E=p.stringify(_,m,b,g,y,v);if(E!==void 0){const x=C.raw||(v.errors&&v.errors.escapeHtml)===!1?E:u(E);k.push(p.wrap(x,C.wrapped&&g.errors.wrap.label))}}return k.join("")}_ref(m,{raw:b,wrapped:g}){const y=[],v=C=>{const _=f.create(C,this._settings);return y.push(_),E=>{const x=_.resolve(...E);return x!==void 0?x:null}};try{const C=this._functions?{...p.functions,...this._functions}:p.functions;var k=new h.Parser(m,{reference:v,functions:C,constants:p.constants})}catch(C){throw C.message=`Invalid template variable "${m}" fails due to: ${C.message}`,C}if(k.single){if(k.single.type==="reference"){const C=y[0];return{ref:C,raw:b,refs:y,wrapped:g||C.type==="local"&&C.key==="label"}}return p.stringify(k.single.value)}return{formula:k,raw:b,refs:y}}toString(){return this.source}},p.Template.prototype[l.symbols.template]=!0,p.Template.prototype.isImmutable=!0,p.encode=function(m){return m.replace(/\\(\{+)/g,(b,g)=>p.opens.slice(0,g.length)).replace(/\\(\}+)/g,(b,g)=>p.closes.slice(0,g.length))},p.decode=function(m){return m.replace(/\u0000/g,"{").replace(/\u0001/g,"}")},p.split=function(m){const b=[];let g="";for(let y=0;y<m.length;++y){const v=m[y];if(v==="{"){let k="";for(;y+1<m.length&&m[y+1]==="{";)k+="{",++y;b.push(g),g=k}else g+=v}return b.push(g),b},p.wrap=function(m,b){return b?b.length===1?`${b}${m}${b}`:`${b[0]}${m}${b[1]}`:m},p.stringify=function(m,b,g,y,v,k={}){const C=typeof m,_=y&&y.errors&&y.errors.wrap||{};let E=!1;if(f.isRef(m)&&m.render&&(E=m.in,m=m.resolve(b,g,y,v,{in:m.in,...k})),m===null)return"null";if(C==="string")return p.wrap(m,k.arrayItems&&_.string);if(C==="number"||C==="function"||C==="symbol")return m.toString();if(C!=="object")return JSON.stringify(m);if(m instanceof Date)return p.Template.date(m,y);if(m instanceof Map){const S=[];for(const[T,A]of m.entries())S.push(`${T.toString()} -> ${A.toString()}`);m=S}if(!Array.isArray(m))return m.toString();const x=[];for(const S of m)x.push(p.stringify(S,b,g,y,v,{arrayItems:!0,...k}));return p.wrap(x.join(", "),!E&&_.array)},p.constants={true:!0,false:!1,null:null,second:1e3,minute:6e4,hour:36e5,day:864e5},p.functions={if:(m,b,g)=>m?b:g,length:m=>typeof m=="string"?m.length:m&&typeof m=="object"?Array.isArray(m)?m.length:Object.keys(m).length:null,msg(m){const[b,g,y,v,k]=this,C=k.messages;if(!C)return"";const _=d.template(b,C[0],m,g,y)||d.template(b,C[1],m,g,y);return _?_.render(b,g,y,v,k):""},number:m=>typeof m=="number"?m:typeof m=="string"?parseFloat(m):typeof m=="boolean"?m?1:0:m instanceof Date?m.getTime():null}},4946:(r,n,a)=>{const o=a(375),c=a(1687),u=a(8068),h=a(8160),l=a(3292),d=a(6354),f=a(6133),p={};r.exports=u.extend({type:"alternatives",flags:{match:{default:"any"}},terms:{matches:{init:[],register:f.toSibling}},args:(m,...b)=>b.length===1&&Array.isArray(b[0])?m.try(...b[0]):m.try(...b),validate(m,b){const{schema:g,error:y,state:v,prefs:k}=b;if(g._flags.match){const _=[],E=[];for(let S=0;S<g.$_terms.matches.length;++S){const T=g.$_terms.matches[S],A=v.nest(T.schema,`match.${S}`);A.snapshot();const R=T.schema.$_validate(m,A,k);R.errors?(E.push(R.errors),A.restore()):(_.push(R.value),A.commit())}if(_.length===0)return{errors:y("alternatives.any",{details:E.map(S=>d.details(S,{override:!1}))})};if(g._flags.match==="one")return _.length===1?{value:_[0]}:{errors:y("alternatives.one")};if(_.length!==g.$_terms.matches.length)return{errors:y("alternatives.all",{details:E.map(S=>d.details(S,{override:!1}))})};const x=S=>S.$_terms.matches.some(T=>T.schema.type==="object"||T.schema.type==="alternatives"&&x(T.schema));return x(g)?{value:_.reduce((S,T)=>c(S,T,{mergeArrays:!1}))}:{value:_[_.length-1]}}const C=[];for(let _=0;_<g.$_terms.matches.length;++_){const E=g.$_terms.matches[_];if(E.schema){const T=v.nest(E.schema,`match.${_}`);T.snapshot();const A=E.schema.$_validate(m,T,k);if(!A.errors)return T.commit(),A;T.restore(),C.push({schema:E.schema,reports:A.errors});continue}const x=E.ref?E.ref.resolve(m,v,k):m,S=E.is?[E]:E.switch;for(let T=0;T<S.length;++T){const A=S[T],{is:R,then:M,otherwise:j}=A,W=`match.${_}${E.switch?"."+T:""}`;if(R.$_match(x,v.nest(R,`${W}.is`),k)){if(M)return M.$_validate(m,v.nest(M,`${W}.then`),k)}else if(j)return j.$_validate(m,v.nest(j,`${W}.otherwise`),k)}}return p.errors(C,b)},rules:{conditional:{method(m,b){o(!this._flags._endedSwitch,"Unreachable condition"),o(!this._flags.match,"Cannot combine match mode",this._flags.match,"with conditional rule"),o(b.break===void 0,"Cannot use break option with alternatives conditional");const g=this.clone(),y=l.when(g,m,b),v=y.is?[y]:y.switch;for(const k of v)if(k.then&&k.otherwise){g.$_setFlag("_endedSwitch",!0,{clone:!1});break}return g.$_terms.matches.push(y),g.$_mutateRebuild()}},match:{method(m){if(o(["any","one","all"].includes(m),"Invalid alternatives match mode",m),m!=="any")for(const b of this.$_terms.matches)o(b.schema,"Cannot combine match mode",m,"with conditional rules");return this.$_setFlag("match",m)}},try:{method(...m){o(m.length,"Missing alternative schemas"),h.verifyFlat(m,"try"),o(!this._flags._endedSwitch,"Unreachable condition");const b=this.clone();for(const g of m)b.$_terms.matches.push({schema:b.$_compile(g)});return b.$_mutateRebuild()}}},overrides:{label(m){return this.$_parent("label",m).$_modify({each:(b,g)=>g.path[0]!=="is"&&typeof b._flags.label!="string"?b.label(m):void 0,ref:!1})}},rebuild(m){m.$_modify({each:b=>{h.isSchema(b)&&b.type==="array"&&m.$_setFlag("_arrayItems",!0,{clone:!1})}})},manifest:{build(m,b){if(b.matches)for(const g of b.matches){const{schema:y,ref:v,is:k,not:C,then:_,otherwise:E}=g;m=y?m.try(y):v?m.conditional(v,{is:k,then:_,not:C,otherwise:E,switch:g.switch}):m.conditional(k,{then:_,otherwise:E})}return m}},messages:{"alternatives.all":"{{#label}} does not match all of the required types","alternatives.any":"{{#label}} does not match any of the allowed types","alternatives.match":"{{#label}} does not match any of the allowed types","alternatives.one":"{{#label}} matches more than one allowed type","alternatives.types":"{{#label}} must be one of {{#types}}"}}),p.errors=function(m,{error:b,state:g}){if(!m.length)return{errors:b("alternatives.any")};if(m.length===1)return{errors:m[0].reports};const y=new Set,v=[];for(const{reports:k,schema:C}of m){if(k.length>1)return p.unmatched(m,b);const _=k[0];if(_ instanceof d.Report==0)return p.unmatched(m,b);if(_.state.path.length!==g.path.length){v.push({type:C.type,report:_});continue}if(_.code==="any.only"){for(const S of _.local.valids)y.add(S);continue}const[E,x]=_.code.split(".");x!=="base"?v.push({type:C.type,report:_}):_.code==="object.base"?y.add(_.local.type):y.add(E)}return v.length?v.length===1?{errors:v[0].report}:p.unmatched(m,b):{errors:b("alternatives.types",{types:[...y]})}},p.unmatched=function(m,b){const g=[];for(const y of m)g.push(...y.reports);return{errors:b("alternatives.match",d.details(g,{override:!1}))}}},8068:(r,n,a)=>{const o=a(375),c=a(7629),u=a(8160),h=a(6914);r.exports=c.extend({type:"any",flags:{only:{default:!1}},terms:{alterations:{init:null},examples:{init:null},externals:{init:null},metas:{init:[]},notes:{init:[]},shared:{init:null},tags:{init:[]},whens:{init:null}},rules:{custom:{method(l,d){return o(typeof l=="function","Method must be a function"),o(d===void 0||d&&typeof d=="string","Description must be a non-empty string"),this.$_addRule({name:"custom",args:{method:l,description:d}})},validate(l,d,{method:f}){try{return f(l,d)}catch(p){return d.error("any.custom",{error:p})}},args:["method","description"],multi:!0},messages:{method(l){return this.prefs({messages:l})}},shared:{method(l){o(u.isSchema(l)&&l._flags.id,"Schema must be a schema with an id");const d=this.clone();return d.$_terms.shared=d.$_terms.shared||[],d.$_terms.shared.push(l),d.$_mutateRegister(l),d}},warning:{method(l,d){return o(l&&typeof l=="string","Invalid warning code"),this.$_addRule({name:"warning",args:{code:l,local:d},warn:!0})},validate:(l,d,{code:f,local:p})=>d.error(f,p),args:["code","local"],multi:!0}},modifiers:{keep(l,d=!0){l.keep=d},message(l,d){l.message=h.compile(d)},warn(l,d=!0){l.warn=d}},manifest:{build(l,d){for(const f in d){const p=d[f];if(["examples","externals","metas","notes","tags"].includes(f))for(const m of p)l=l[f.slice(0,-1)](m);else if(f!=="alterations")if(f!=="whens"){if(f==="shared")for(const m of p)l=l.shared(m)}else for(const m of p){const{ref:b,is:g,not:y,then:v,otherwise:k,concat:C}=m;l=C?l.concat(C):b?l.when(b,{is:g,not:y,then:v,otherwise:k,switch:m.switch,break:m.break}):l.when(g,{then:v,otherwise:k,break:m.break})}else{const m={};for(const{target:b,adjuster:g}of p)m[b]=g;l=l.alter(m)}}return l}},messages:{"any.custom":"{{#label}} failed custom validation because {{#error.message}}","any.default":"{{#label}} threw an error when running default method","any.failover":"{{#label}} threw an error when running failover method","any.invalid":"{{#label}} contains an invalid value","any.only":'{{#label}} must be {if(#valids.length == 1, "", "one of ")}{{#valids}}',"any.ref":"{{#label}} {{#arg}} references {{:#ref}} which {{#reason}}","any.required":"{{#label}} is required","any.unknown":"{{#label}} is not allowed"}})},546:(r,n,a)=>{const o=a(375),c=a(9474),u=a(9621),h=a(8068),l=a(8160),d=a(3292),f={};r.exports=h.extend({type:"array",flags:{single:{default:!1},sparse:{default:!1}},terms:{items:{init:[],manifest:"schema"},ordered:{init:[],manifest:"schema"},_exclusions:{init:[]},_inclusions:{init:[]},_requireds:{init:[]}},coerce:{from:"object",method(p,{schema:m,state:b,prefs:g}){if(!Array.isArray(p))return;const y=m.$_getRule("sort");return y?f.sort(m,p,y.args.options,b,g):void 0}},validate(p,{schema:m,error:b}){if(!Array.isArray(p)){if(m._flags.single){const g=[p];return g[l.symbols.arraySingle]=!0,{value:g}}return{errors:b("array.base")}}if(m.$_getRule("items")||m.$_terms.externals)return{value:p.slice()}},rules:{has:{method(p){p=this.$_compile(p,{appendPath:!0});const m=this.$_addRule({name:"has",args:{schema:p}});return m.$_mutateRegister(p),m},validate(p,{state:m,prefs:b,error:g},{schema:y}){const v=[p,...m.ancestors];for(let C=0;C<p.length;++C){const _=m.localize([...m.path,C],v,y);if(y.$_match(p[C],_,b))return p}const k=y._flags.label;return k?g("array.hasKnown",{patternLabel:k}):g("array.hasUnknown",null)},multi:!0},items:{method(...p){l.verifyFlat(p,"items");const m=this.$_addRule("items");for(let b=0;b<p.length;++b){const g=l.tryWithPath(()=>this.$_compile(p[b]),b,{append:!0});m.$_terms.items.push(g)}return m.$_mutateRebuild()},validate(p,{schema:m,error:b,state:g,prefs:y,errorsArray:v}){const k=m.$_terms._requireds.slice(),C=m.$_terms.ordered.slice(),_=[...m.$_terms._inclusions,...k],E=!p[l.symbols.arraySingle];delete p[l.symbols.arraySingle];const x=v();let S=p.length;for(let T=0;T<S;++T){const A=p[T];let R=!1,M=!1;const j=E?T:new Number(T),W=[...g.path,j];if(!m._flags.sparse&&A===void 0){if(x.push(b("array.sparse",{key:j,path:W,pos:T,value:void 0},g.localize(W))),y.abortEarly)return x;C.shift();continue}const se=[p,...g.ancestors];for(const Q of m.$_terms._exclusions)if(Q.$_match(A,g.localize(W,se,Q),y,{presence:"ignore"})){if(x.push(b("array.excludes",{pos:T,value:A},g.localize(W))),y.abortEarly)return x;R=!0,C.shift();break}if(R)continue;if(m.$_terms.ordered.length){if(C.length){const Q=C.shift(),we=Q.$_validate(A,g.localize(W,se,Q),y);if(we.errors){if(x.push(...we.errors),y.abortEarly)return x}else if(Q._flags.result==="strip")f.fastSplice(p,T),--T,--S;else{if(!m._flags.sparse&&we.value===void 0){if(x.push(b("array.sparse",{key:j,path:W,pos:T,value:void 0},g.localize(W))),y.abortEarly)return x;continue}p[T]=we.value}continue}if(!m.$_terms.items.length){if(x.push(b("array.orderedLength",{pos:T,limit:m.$_terms.ordered.length})),y.abortEarly)return x;break}}const Y=[];let ae=k.length;for(let Q=0;Q<ae;++Q){const we=g.localize(W,se,k[Q]);we.snapshot();const Le=k[Q].$_validate(A,we,y);if(Y[Q]=Le,!Le.errors){if(we.commit(),p[T]=Le.value,M=!0,f.fastSplice(k,Q),--Q,--ae,!m._flags.sparse&&Le.value===void 0&&(x.push(b("array.sparse",{key:j,path:W,pos:T,value:void 0},g.localize(W))),y.abortEarly))return x;break}we.restore()}if(M)continue;const he=y.stripUnknown&&!!y.stripUnknown.arrays||!1;ae=_.length;for(const Q of _){let we;const Le=k.indexOf(Q);if(Le!==-1)we=Y[Le];else{const Ze=g.localize(W,se,Q);if(Ze.snapshot(),we=Q.$_validate(A,Ze,y),!we.errors){Ze.commit(),Q._flags.result==="strip"?(f.fastSplice(p,T),--T,--S):m._flags.sparse||we.value!==void 0?p[T]=we.value:(x.push(b("array.sparse",{key:j,path:W,pos:T,value:void 0},g.localize(W))),R=!0),M=!0;break}Ze.restore()}if(ae===1){if(he){f.fastSplice(p,T),--T,--S,M=!0;break}if(x.push(...we.errors),y.abortEarly)return x;R=!0;break}}if(!R&&(m.$_terms._inclusions.length||m.$_terms._requireds.length)&&!M){if(he){f.fastSplice(p,T),--T,--S;continue}if(x.push(b("array.includes",{pos:T,value:A},g.localize(W))),y.abortEarly)return x}}return k.length&&f.fillMissedErrors(m,x,k,p,g,y),C.length&&(f.fillOrderedErrors(m,x,C,p,g,y),x.length||f.fillDefault(C,p,g,y)),x.length?x:p},priority:!0,manifest:!1},length:{method(p){return this.$_addRule({name:"length",args:{limit:p},operator:"="})},validate:(p,m,{limit:b},{name:g,operator:y,args:v})=>l.compare(p.length,b,y)?p:m.error("array."+g,{limit:v.limit,value:p}),args:[{name:"limit",ref:!0,assert:l.limit,message:"must be a positive integer"}]},max:{method(p){return this.$_addRule({name:"max",method:"length",args:{limit:p},operator:"<="})}},min:{method(p){return this.$_addRule({name:"min",method:"length",args:{limit:p},operator:">="})}},ordered:{method(...p){l.verifyFlat(p,"ordered");const m=this.$_addRule("items");for(let b=0;b<p.length;++b){const g=l.tryWithPath(()=>this.$_compile(p[b]),b,{append:!0});f.validateSingle(g,m),m.$_mutateRegister(g),m.$_terms.ordered.push(g)}return m.$_mutateRebuild()}},single:{method(p){const m=p===void 0||!!p;return o(!m||!this._flags._arrayItems,"Cannot specify single rule when array has array items"),this.$_setFlag("single",m)}},sort:{method(p={}){l.assertOptions(p,["by","order"]);const m={order:p.order||"ascending"};return p.by&&(m.by=d.ref(p.by,{ancestor:0}),o(!m.by.ancestor,"Cannot sort by ancestor")),this.$_addRule({name:"sort",args:{options:m}})},validate(p,{error:m,state:b,prefs:g,schema:y},{options:v}){const{value:k,errors:C}=f.sort(y,p,v,b,g);if(C)return C;for(let _=0;_<p.length;++_)if(p[_]!==k[_])return m("array.sort",{order:v.order,by:v.by?v.by.key:"value"});return p},convert:!0},sparse:{method(p){const m=p===void 0||!!p;return this._flags.sparse===m?this:(m?this.clone():this.$_addRule("items")).$_setFlag("sparse",m,{clone:!1})}},unique:{method(p,m={}){o(!p||typeof p=="function"||typeof p=="string","comparator must be a function or a string"),l.assertOptions(m,["ignoreUndefined","separator"]);const b={name:"unique",args:{options:m,comparator:p}};if(p)if(typeof p=="string"){const g=l.default(m.separator,".");b.path=g?p.split(g):[p]}else b.comparator=p;return this.$_addRule(b)},validate(p,{state:m,error:b,schema:g},{comparator:y,options:v},{comparator:k,path:C}){const _={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),bigint:Object.create(null),object:new Map,function:new Map,custom:new Map},E=k||c,x=v.ignoreUndefined;for(let S=0;S<p.length;++S){const T=C?u(p[S],C):p[S],A=k?_.custom:_[typeof T];if(o(A,"Failed to find unique map container for type",typeof T),A instanceof Map){const R=A.entries();let M;for(;!(M=R.next()).done;)if(E(M.value[0],T)){const j=m.localize([...m.path,S],[p,...m.ancestors]),W={pos:S,value:p[S],dupePos:M.value[1],dupeValue:p[M.value[1]]};return C&&(W.path=y),b("array.unique",W,j)}A.set(T,S)}else{if((!x||T!==void 0)&&A[T]!==void 0){const R={pos:S,value:p[S],dupePos:A[T],dupeValue:p[A[T]]};return C&&(R.path=y),b("array.unique",R,m.localize([...m.path,S],[p,...m.ancestors]))}A[T]=S}}return p},args:["comparator","options"],multi:!0}},cast:{set:{from:Array.isArray,to:(p,m)=>new Set(p)}},rebuild(p){p.$_terms._inclusions=[],p.$_terms._exclusions=[],p.$_terms._requireds=[];for(const m of p.$_terms.items)f.validateSingle(m,p),m._flags.presence==="required"?p.$_terms._requireds.push(m):m._flags.presence==="forbidden"?p.$_terms._exclusions.push(m):p.$_terms._inclusions.push(m);for(const m of p.$_terms.ordered)f.validateSingle(m,p)},manifest:{build:(p,m)=>(m.items&&(p=p.items(...m.items)),m.ordered&&(p=p.ordered(...m.ordered)),p)},messages:{"array.base":"{{#label}} must be an array","array.excludes":"{{#label}} contains an excluded value","array.hasKnown":"{{#label}} does not contain at least one required match for type {:#patternLabel}","array.hasUnknown":"{{#label}} does not contain at least one required match","array.includes":"{{#label}} does not match any of the allowed types","array.includesRequiredBoth":"{{#label}} does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)","array.includesRequiredKnowns":"{{#label}} does not contain {{#knownMisses}}","array.includesRequiredUnknowns":"{{#label}} does not contain {{#unknownMisses}} required value(s)","array.length":"{{#label}} must contain {{#limit}} items","array.max":"{{#label}} must contain less than or equal to {{#limit}} items","array.min":"{{#label}} must contain at least {{#limit}} items","array.orderedLength":"{{#label}} must contain at most {{#limit}} items","array.sort":"{{#label}} must be sorted in {#order} order by {{#by}}","array.sort.mismatching":"{{#label}} cannot be sorted due to mismatching types","array.sort.unsupported":"{{#label}} cannot be sorted due to unsupported type {#type}","array.sparse":"{{#label}} must not be a sparse array item","array.unique":"{{#label}} contains a duplicate value"}}),f.fillMissedErrors=function(p,m,b,g,y,v){const k=[];let C=0;for(const _ of b){const E=_._flags.label;E?k.push(E):++C}k.length?C?m.push(p.$_createError("array.includesRequiredBoth",g,{knownMisses:k,unknownMisses:C},y,v)):m.push(p.$_createError("array.includesRequiredKnowns",g,{knownMisses:k},y,v)):m.push(p.$_createError("array.includesRequiredUnknowns",g,{unknownMisses:C},y,v))},f.fillOrderedErrors=function(p,m,b,g,y,v){const k=[];for(const C of b)C._flags.presence==="required"&&k.push(C);k.length&&f.fillMissedErrors(p,m,k,g,y,v)},f.fillDefault=function(p,m,b,g){const y=[];let v=!0;for(let k=p.length-1;k>=0;--k){const C=p[k],_=[m,...b.ancestors],E=C.$_validate(void 0,b.localize(b.path,_,C),g).value;if(v){if(E===void 0)continue;v=!1}y.unshift(E)}y.length&&m.push(...y)},f.fastSplice=function(p,m){let b=m;for(;b<p.length;)p[b++]=p[b];--p.length},f.validateSingle=function(p,m){(p.type==="array"||p._flags._arrayItems)&&(o(!m._flags.single,"Cannot specify array item with single rule enabled"),m.$_setFlag("_arrayItems",!0,{clone:!1}))},f.sort=function(p,m,b,g,y){const v=b.order==="ascending"?1:-1,k=-1*v,C=v,_=(E,x)=>{let S=f.compare(E,x,k,C);if(S!==null||(b.by&&(E=b.by.resolve(E,g,y),x=b.by.resolve(x,g,y)),S=f.compare(E,x,k,C),S!==null))return S;const T=typeof E;if(T!==typeof x)throw p.$_createError("array.sort.mismatching",m,null,g,y);if(T!=="number"&&T!=="string")throw p.$_createError("array.sort.unsupported",m,{type:T},g,y);return T==="number"?(E-x)*v:E<x?k:C};try{return{value:m.slice().sort(_)}}catch(E){return{errors:E}}},f.compare=function(p,m,b,g){return p===m?0:p===void 0?1:m===void 0?-1:p===null?g:m===null?b:null}},4937:(r,n,a)=>{const o=a(375),c=a(8068),u=a(8160),h=a(2036),l={isBool:function(d){return typeof d=="boolean"}};r.exports=c.extend({type:"boolean",flags:{sensitive:{default:!1}},terms:{falsy:{init:null,manifest:"values"},truthy:{init:null,manifest:"values"}},coerce(d,{schema:f}){if(typeof d!="boolean"){if(typeof d=="string"){const p=f._flags.sensitive?d:d.toLowerCase();d=p==="true"||p!=="false"&&d}return typeof d!="boolean"&&(d=f.$_terms.truthy&&f.$_terms.truthy.has(d,null,null,!f._flags.sensitive)||(!f.$_terms.falsy||!f.$_terms.falsy.has(d,null,null,!f._flags.sensitive))&&d),{value:d}}},validate(d,{error:f}){if(typeof d!="boolean")return{value:d,errors:f("boolean.base")}},rules:{truthy:{method(...d){u.verifyFlat(d,"truthy");const f=this.clone();f.$_terms.truthy=f.$_terms.truthy||new h;for(let p=0;p<d.length;++p){const m=d[p];o(m!==void 0,"Cannot call truthy with undefined"),f.$_terms.truthy.add(m)}return f}},falsy:{method(...d){u.verifyFlat(d,"falsy");const f=this.clone();f.$_terms.falsy=f.$_terms.falsy||new h;for(let p=0;p<d.length;++p){const m=d[p];o(m!==void 0,"Cannot call falsy with undefined"),f.$_terms.falsy.add(m)}return f}},sensitive:{method(d=!0){return this.$_setFlag("sensitive",d)}}},cast:{number:{from:l.isBool,to:(d,f)=>d?1:0},string:{from:l.isBool,to:(d,f)=>d?"true":"false"}},manifest:{build:(d,f)=>(f.truthy&&(d=d.truthy(...f.truthy)),f.falsy&&(d=d.falsy(...f.falsy)),d)},messages:{"boolean.base":"{{#label}} must be a boolean"}})},7500:(r,n,a)=>{const o=a(375),c=a(8068),u=a(8160),h=a(3328),l={isDate:function(d){return d instanceof Date}};r.exports=c.extend({type:"date",coerce:{from:["number","string"],method:(d,{schema:f})=>({value:l.parse(d,f._flags.format)||d})},validate(d,{schema:f,error:p,prefs:m}){if(d instanceof Date&&!isNaN(d.getTime()))return;const b=f._flags.format;return m.convert&&b&&typeof d=="string"?{value:d,errors:p("date.format",{format:b})}:{value:d,errors:p("date.base")}},rules:{compare:{method:!1,validate(d,f,{date:p},{name:m,operator:b,args:g}){const y=p==="now"?Date.now():p.getTime();return u.compare(d.getTime(),y,b)?d:f.error("date."+m,{limit:g.date,value:d})},args:[{name:"date",ref:!0,normalize:d=>d==="now"?d:l.parse(d),assert:d=>d!==null,message:"must have a valid date format"}]},format:{method(d){return o(["iso","javascript","unix"].includes(d),"Unknown date format",d),this.$_setFlag("format",d)}},greater:{method(d){return this.$_addRule({name:"greater",method:"compare",args:{date:d},operator:">"})}},iso:{method(){return this.format("iso")}},less:{method(d){return this.$_addRule({name:"less",method:"compare",args:{date:d},operator:"<"})}},max:{method(d){return this.$_addRule({name:"max",method:"compare",args:{date:d},operator:"<="})}},min:{method(d){return this.$_addRule({name:"min",method:"compare",args:{date:d},operator:">="})}},timestamp:{method(d="javascript"){return o(["javascript","unix"].includes(d),'"type" must be one of "javascript, unix"'),this.format(d)}}},cast:{number:{from:l.isDate,to:(d,f)=>d.getTime()},string:{from:l.isDate,to:(d,{prefs:f})=>h.date(d,f)}},messages:{"date.base":"{{#label}} must be a valid date","date.format":'{{#label}} must be in {msg("date.format." + #format) || #format} format',"date.greater":"{{#label}} must be greater than {{:#limit}}","date.less":"{{#label}} must be less than {{:#limit}}","date.max":"{{#label}} must be less than or equal to {{:#limit}}","date.min":"{{#label}} must be greater than or equal to {{:#limit}}","date.format.iso":"ISO 8601 date","date.format.javascript":"timestamp or number of milliseconds","date.format.unix":"timestamp or number of seconds"}}),l.parse=function(d,f){if(d instanceof Date)return d;if(typeof d!="string"&&(isNaN(d)||!isFinite(d))||/^\s*$/.test(d))return null;if(f==="iso")return u.isIsoDate(d)?l.date(d.toString()):null;const p=d;if(typeof d=="string"&&/^[+-]?\d+(\.\d+)?$/.test(d)&&(d=parseFloat(d)),f){if(f==="javascript")return l.date(1*d);if(f==="unix")return l.date(1e3*d);if(typeof p=="string")return null}return l.date(d)},l.date=function(d){const f=new Date(d);return isNaN(f.getTime())?null:f}},390:(r,n,a)=>{const o=a(375),c=a(7824);r.exports=c.extend({type:"function",properties:{typeof:"function"},rules:{arity:{method(u){return o(Number.isSafeInteger(u)&&u>=0,"n must be a positive integer"),this.$_addRule({name:"arity",args:{n:u}})},validate:(u,h,{n:l})=>u.length===l?u:h.error("function.arity",{n:l})},class:{method(){return this.$_addRule("class")},validate:(u,h)=>/^\s*class\s/.test(u.toString())?u:h.error("function.class",{value:u})},minArity:{method(u){return o(Number.isSafeInteger(u)&&u>0,"n must be a strict positive integer"),this.$_addRule({name:"minArity",args:{n:u}})},validate:(u,h,{n:l})=>u.length>=l?u:h.error("function.minArity",{n:l})},maxArity:{method(u){return o(Number.isSafeInteger(u)&&u>=0,"n must be a positive integer"),this.$_addRule({name:"maxArity",args:{n:u}})},validate:(u,h,{n:l})=>u.length<=l?u:h.error("function.maxArity",{n:l})}},messages:{"function.arity":"{{#label}} must have an arity of {{#n}}","function.class":"{{#label}} must be a class","function.maxArity":"{{#label}} must have an arity lesser or equal to {{#n}}","function.minArity":"{{#label}} must have an arity greater or equal to {{#n}}"}})},7824:(r,n,a)=>{const o=a(978),c=a(375),u=a(8571),h=a(3652),l=a(8068),d=a(8160),f=a(3292),p=a(6354),m=a(6133),b=a(3328),g={renameDefaults:{alias:!1,multiple:!1,override:!1}};r.exports=l.extend({type:"_keys",properties:{typeof:"object"},flags:{unknown:{default:void 0}},terms:{dependencies:{init:null},keys:{init:null,manifest:{mapped:{from:"schema",to:"key"}}},patterns:{init:null},renames:{init:null}},args:(y,v)=>y.keys(v),validate(y,{schema:v,error:k,state:C,prefs:_}){if(!y||typeof y!==v.$_property("typeof")||Array.isArray(y))return{value:y,errors:k("object.base",{type:v.$_property("typeof")})};if(!(v.$_terms.renames||v.$_terms.dependencies||v.$_terms.keys||v.$_terms.patterns||v.$_terms.externals))return;y=g.clone(y,_);const E=[];if(v.$_terms.renames&&!g.rename(v,y,C,_,E))return{value:y,errors:E};if(!v.$_terms.keys&&!v.$_terms.patterns&&!v.$_terms.dependencies)return{value:y,errors:E};const x=new Set(Object.keys(y));if(v.$_terms.keys){const S=[y,...C.ancestors];for(const T of v.$_terms.keys){const A=T.key,R=y[A];x.delete(A);const M=C.localize([...C.path,A],S,T),j=T.schema.$_validate(R,M,_);if(j.errors){if(_.abortEarly)return{value:y,errors:j.errors};j.value!==void 0&&(y[A]=j.value),E.push(...j.errors)}else T.schema._flags.result==="strip"||j.value===void 0&&R!==void 0?delete y[A]:j.value!==void 0&&(y[A]=j.value)}}if(x.size||v._flags._hasPatternMatch){const S=g.unknown(v,y,x,E,C,_);if(S)return S}if(v.$_terms.dependencies)for(const S of v.$_terms.dependencies){if(S.key!==null&&g.isPresent(S.options)(S.key.resolve(y,C,_,null,{shadow:!1}))===!1)continue;const T=g.dependencies[S.rel](v,S,y,C,_);if(T){const A=v.$_createError(T.code,y,T.context,C,_);if(_.abortEarly)return{value:y,errors:A};E.push(A)}}return{value:y,errors:E}},rules:{and:{method(...y){return d.verifyFlat(y,"and"),g.dependency(this,"and",null,y)}},append:{method(y){return y==null||Object.keys(y).length===0?this:this.keys(y)}},assert:{method(y,v,k){b.isTemplate(y)||(y=f.ref(y)),c(k===void 0||typeof k=="string","Message must be a string"),v=this.$_compile(v,{appendPath:!0});const C=this.$_addRule({name:"assert",args:{subject:y,schema:v,message:k}});return C.$_mutateRegister(y),C.$_mutateRegister(v),C},validate(y,{error:v,prefs:k,state:C},{subject:_,schema:E,message:x}){const S=_.resolve(y,C,k),T=m.isRef(_)?_.absolute(C):[];return E.$_match(S,C.localize(T,[y,...C.ancestors],E),k)?y:v("object.assert",{subject:_,message:x})},args:["subject","schema","message"],multi:!0},instance:{method(y,v){return c(typeof y=="function","constructor must be a function"),v=v||y.name,this.$_addRule({name:"instance",args:{constructor:y,name:v}})},validate:(y,v,{constructor:k,name:C})=>y instanceof k?y:v.error("object.instance",{type:C,value:y}),args:["constructor","name"]},keys:{method(y){c(y===void 0||typeof y=="object","Object schema must be a valid object"),c(!d.isSchema(y),"Object schema cannot be a joi schema");const v=this.clone();if(y)if(Object.keys(y).length){v.$_terms.keys=v.$_terms.keys?v.$_terms.keys.filter(k=>!y.hasOwnProperty(k.key)):new g.Keys;for(const k in y)d.tryWithPath(()=>v.$_terms.keys.push({key:k,schema:this.$_compile(y[k])}),k)}else v.$_terms.keys=new g.Keys;else v.$_terms.keys=null;return v.$_mutateRebuild()}},length:{method(y){return this.$_addRule({name:"length",args:{limit:y},operator:"="})},validate:(y,v,{limit:k},{name:C,operator:_,args:E})=>d.compare(Object.keys(y).length,k,_)?y:v.error("object."+C,{limit:E.limit,value:y}),args:[{name:"limit",ref:!0,assert:d.limit,message:"must be a positive integer"}]},max:{method(y){return this.$_addRule({name:"max",method:"length",args:{limit:y},operator:"<="})}},min:{method(y){return this.$_addRule({name:"min",method:"length",args:{limit:y},operator:">="})}},nand:{method(...y){return d.verifyFlat(y,"nand"),g.dependency(this,"nand",null,y)}},or:{method(...y){return d.verifyFlat(y,"or"),g.dependency(this,"or",null,y)}},oxor:{method(...y){return g.dependency(this,"oxor",null,y)}},pattern:{method(y,v,k={}){const C=y instanceof RegExp;C||(y=this.$_compile(y,{appendPath:!0})),c(v!==void 0,"Invalid rule"),d.assertOptions(k,["fallthrough","matches"]),C&&c(!y.flags.includes("g")&&!y.flags.includes("y"),"pattern should not use global or sticky mode"),v=this.$_compile(v,{appendPath:!0});const _=this.clone();_.$_terms.patterns=_.$_terms.patterns||[];const E={[C?"regex":"schema"]:y,rule:v};return k.matches&&(E.matches=this.$_compile(k.matches),E.matches.type!=="array"&&(E.matches=E.matches.$_root.array().items(E.matches)),_.$_mutateRegister(E.matches),_.$_setFlag("_hasPatternMatch",!0,{clone:!1})),k.fallthrough&&(E.fallthrough=!0),_.$_terms.patterns.push(E),_.$_mutateRegister(v),_}},ref:{method(){return this.$_addRule("ref")},validate:(y,v)=>m.isRef(y)?y:v.error("object.refType",{value:y})},regex:{method(){return this.$_addRule("regex")},validate:(y,v)=>y instanceof RegExp?y:v.error("object.regex",{value:y})},rename:{method(y,v,k={}){c(typeof y=="string"||y instanceof RegExp,"Rename missing the from argument"),c(typeof v=="string"||v instanceof b,"Invalid rename to argument"),c(v!==y,"Cannot rename key to same name:",y),d.assertOptions(k,["alias","ignoreUndefined","override","multiple"]);const C=this.clone();C.$_terms.renames=C.$_terms.renames||[];for(const _ of C.$_terms.renames)c(_.from!==y,"Cannot rename the same key multiple times");return v instanceof b&&C.$_mutateRegister(v),C.$_terms.renames.push({from:y,to:v,options:o(g.renameDefaults,k)}),C}},schema:{method(y="any"){return this.$_addRule({name:"schema",args:{type:y}})},validate:(y,v,{type:k})=>!d.isSchema(y)||k!=="any"&&y.type!==k?v.error("object.schema",{type:k}):y},unknown:{method(y){return this.$_setFlag("unknown",y!==!1)}},with:{method(y,v,k={}){return g.dependency(this,"with",y,v,k)}},without:{method(y,v,k={}){return g.dependency(this,"without",y,v,k)}},xor:{method(...y){return d.verifyFlat(y,"xor"),g.dependency(this,"xor",null,y)}}},overrides:{default(y,v){return y===void 0&&(y=d.symbols.deepDefault),this.$_parent("default",y,v)}},rebuild(y){if(y.$_terms.keys){const v=new h.Sorter;for(const k of y.$_terms.keys)d.tryWithPath(()=>v.add(k,{after:k.schema.$_rootReferences(),group:k.key}),k.key);y.$_terms.keys=new g.Keys(...v.nodes)}},manifest:{build(y,v){if(v.keys&&(y=y.keys(v.keys)),v.dependencies)for(const{rel:k,key:C=null,peers:_,options:E}of v.dependencies)y=g.dependency(y,k,C,_,E);if(v.patterns)for(const{regex:k,schema:C,rule:_,fallthrough:E,matches:x}of v.patterns)y=y.pattern(k||C,_,{fallthrough:E,matches:x});if(v.renames)for(const{from:k,to:C,options:_}of v.renames)y=y.rename(k,C,_);return y}},messages:{"object.and":"{{#label}} contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}","object.assert":'{{#label}} is invalid because {if(#subject.key, `"` + #subject.key + `" failed to ` + (#message || "pass the assertion test"), #message || "the assertion failed")}',"object.base":"{{#label}} must be of type {{#type}}","object.instance":"{{#label}} must be an instance of {{:#type}}","object.length":'{{#label}} must have {{#limit}} key{if(#limit == 1, "", "s")}',"object.max":'{{#label}} must have less than or equal to {{#limit}} key{if(#limit == 1, "", "s")}',"object.min":'{{#label}} must have at least {{#limit}} key{if(#limit == 1, "", "s")}',"object.missing":"{{#label}} must contain at least one of {{#peersWithLabels}}","object.nand":"{{:#mainWithLabel}} must not exist simultaneously with {{#peersWithLabels}}","object.oxor":"{{#label}} contains a conflict between optional exclusive peers {{#peersWithLabels}}","object.pattern.match":"{{#label}} keys failed to match pattern requirements","object.refType":"{{#label}} must be a Joi reference","object.regex":"{{#label}} must be a RegExp object","object.rename.multiple":"{{#label}} cannot rename {{:#from}} because multiple renames are disabled and another key was already renamed to {{:#to}}","object.rename.override":"{{#label}} cannot rename {{:#from}} because override is disabled and target {{:#to}} exists","object.schema":"{{#label}} must be a Joi schema of {{#type}} type","object.unknown":"{{#label}} is not allowed","object.with":"{{:#mainWithLabel}} missing required peer {{:#peerWithLabel}}","object.without":"{{:#mainWithLabel}} conflict with forbidden peer {{:#peerWithLabel}}","object.xor":"{{#label}} contains a conflict between exclusive peers {{#peersWithLabels}}"}}),g.clone=function(y,v){if(typeof y=="object"){if(v.nonEnumerables)return u(y,{shallow:!0});const C=Object.create(Object.getPrototypeOf(y));return Object.assign(C,y),C}const k=function(...C){return y.apply(this,C)};return k.prototype=u(y.prototype),Object.defineProperty(k,"name",{value:y.name,writable:!1}),Object.defineProperty(k,"length",{value:y.length,writable:!1}),Object.assign(k,y),k},g.dependency=function(y,v,k,C,_){c(k===null||typeof k=="string",v,"key must be a strings"),_||(_=C.length>1&&typeof C[C.length-1]=="object"?C.pop():{}),d.assertOptions(_,["separator","isPresent"]),C=[].concat(C);const E=d.default(_.separator,"."),x=[];for(const T of C)c(typeof T=="string",v,"peers must be strings"),x.push(f.ref(T,{separator:E,ancestor:0,prefix:!1}));k!==null&&(k=f.ref(k,{separator:E,ancestor:0,prefix:!1}));const S=y.clone();return S.$_terms.dependencies=S.$_terms.dependencies||[],S.$_terms.dependencies.push(new g.Dependency(v,k,x,C,_)),S},g.dependencies={and(y,v,k,C,_){const E=[],x=[],S=v.peers.length,T=g.isPresent(v.options);for(const A of v.peers)T(A.resolve(k,C,_,null,{shadow:!1}))===!1?E.push(A.key):x.push(A.key);if(E.length!==S&&x.length!==S)return{code:"object.and",context:{present:x,presentWithLabels:g.keysToLabels(y,x),missing:E,missingWithLabels:g.keysToLabels(y,E)}}},nand(y,v,k,C,_){const E=[],x=g.isPresent(v.options);for(const A of v.peers)x(A.resolve(k,C,_,null,{shadow:!1}))&&E.push(A.key);if(E.length!==v.peers.length)return;const S=v.paths[0],T=v.paths.slice(1);return{code:"object.nand",context:{main:S,mainWithLabel:g.keysToLabels(y,S),peers:T,peersWithLabels:g.keysToLabels(y,T)}}},or(y,v,k,C,_){const E=g.isPresent(v.options);for(const x of v.peers)if(E(x.resolve(k,C,_,null,{shadow:!1})))return;return{code:"object.missing",context:{peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)}}},oxor(y,v,k,C,_){const E=[],x=g.isPresent(v.options);for(const T of v.peers)x(T.resolve(k,C,_,null,{shadow:!1}))&&E.push(T.key);if(!E.length||E.length===1)return;const S={peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)};return S.present=E,S.presentWithLabels=g.keysToLabels(y,E),{code:"object.oxor",context:S}},with(y,v,k,C,_){const E=g.isPresent(v.options);for(const x of v.peers)if(E(x.resolve(k,C,_,null,{shadow:!1}))===!1)return{code:"object.with",context:{main:v.key.key,mainWithLabel:g.keysToLabels(y,v.key.key),peer:x.key,peerWithLabel:g.keysToLabels(y,x.key)}}},without(y,v,k,C,_){const E=g.isPresent(v.options);for(const x of v.peers)if(E(x.resolve(k,C,_,null,{shadow:!1})))return{code:"object.without",context:{main:v.key.key,mainWithLabel:g.keysToLabels(y,v.key.key),peer:x.key,peerWithLabel:g.keysToLabels(y,x.key)}}},xor(y,v,k,C,_){const E=[],x=g.isPresent(v.options);for(const T of v.peers)x(T.resolve(k,C,_,null,{shadow:!1}))&&E.push(T.key);if(E.length===1)return;const S={peers:v.paths,peersWithLabels:g.keysToLabels(y,v.paths)};return E.length===0?{code:"object.missing",context:S}:(S.present=E,S.presentWithLabels=g.keysToLabels(y,E),{code:"object.xor",context:S})}},g.keysToLabels=function(y,v){return Array.isArray(v)?v.map(k=>y.$_mapLabels(k)):y.$_mapLabels(v)},g.isPresent=function(y){return typeof y.isPresent=="function"?y.isPresent:v=>v!==void 0},g.rename=function(y,v,k,C,_){const E={};for(const x of y.$_terms.renames){const S=[],T=typeof x.from!="string";if(T)for(const A in v){if(v[A]===void 0&&x.options.ignoreUndefined||A===x.to)continue;const R=x.from.exec(A);R&&S.push({from:A,to:x.to,match:R})}else!Object.prototype.hasOwnProperty.call(v,x.from)||v[x.from]===void 0&&x.options.ignoreUndefined||S.push(x);for(const A of S){const R=A.from;let M=A.to;if(M instanceof b&&(M=M.render(v,k,C,A.match)),R!==M){if(!x.options.multiple&&E[M]&&(_.push(y.$_createError("object.rename.multiple",v,{from:R,to:M,pattern:T},k,C)),C.abortEarly)||Object.prototype.hasOwnProperty.call(v,M)&&!x.options.override&&!E[M]&&(_.push(y.$_createError("object.rename.override",v,{from:R,to:M,pattern:T},k,C)),C.abortEarly))return!1;v[R]===void 0?delete v[M]:v[M]=v[R],E[M]=!0,x.options.alias||delete v[R]}}}return!0},g.unknown=function(y,v,k,C,_,E){if(y.$_terms.patterns){let x=!1;const S=y.$_terms.patterns.map(A=>{if(A.matches)return x=!0,[]}),T=[v,..._.ancestors];for(const A of k){const R=v[A],M=[..._.path,A];for(let j=0;j<y.$_terms.patterns.length;++j){const W=y.$_terms.patterns[j];if(W.regex){const ae=W.regex.test(A);if(_.mainstay.tracer.debug(_,"rule",`pattern.${j}`,ae?"pass":"error"),!ae)continue}else if(!W.schema.$_match(A,_.nest(W.schema,`pattern.${j}`),E))continue;k.delete(A);const se=_.localize(M,T,{schema:W.rule,key:A}),Y=W.rule.$_validate(R,se,E);if(Y.errors){if(E.abortEarly)return{value:v,errors:Y.errors};C.push(...Y.errors)}if(W.matches&&S[j].push(A),v[A]=Y.value,!W.fallthrough)break}}if(x)for(let A=0;A<S.length;++A){const R=S[A];if(!R)continue;const M=y.$_terms.patterns[A].matches,j=_.localize(_.path,T,M),W=M.$_validate(R,j,E);if(W.errors){const se=p.details(W.errors,{override:!1});se.matches=R;const Y=y.$_createError("object.pattern.match",v,se,_,E);if(E.abortEarly)return{value:v,errors:Y};C.push(Y)}}}if(k.size&&(y.$_terms.keys||y.$_terms.patterns)){if(E.stripUnknown&&y._flags.unknown===void 0||E.skipFunctions){const x=!(!E.stripUnknown||E.stripUnknown!==!0&&!E.stripUnknown.objects);for(const S of k)x?(delete v[S],k.delete(S)):typeof v[S]=="function"&&k.delete(S)}if(!d.default(y._flags.unknown,E.allowUnknown))for(const x of k){const S=_.localize([..._.path,x],[]),T=y.$_createError("object.unknown",v[x],{child:x},S,E,{flags:!1});if(E.abortEarly)return{value:v,errors:T};C.push(T)}}},g.Dependency=class{constructor(y,v,k,C,_){this.rel=y,this.key=v,this.peers=k,this.paths=C,this.options=_}describe(){const y={rel:this.rel,peers:this.paths};return this.key!==null&&(y.key=this.key.key),this.peers[0].separator!=="."&&(y.options={...y.options,separator:this.peers[0].separator}),this.options.isPresent&&(y.options={...y.options,isPresent:this.options.isPresent}),y}},g.Keys=class extends Array{concat(y){const v=this.slice(),k=new Map;for(let C=0;C<v.length;++C)k.set(v[C].key,C);for(const C of y){const _=C.key,E=k.get(_);E!==void 0?v[E]={key:_,schema:v[E].schema.concat(C.schema)}:v.push(C)}return v}}},8785:(r,n,a)=>{const o=a(375),c=a(8068),u=a(8160),h=a(3292),l=a(6354),d={};r.exports=c.extend({type:"link",properties:{schemaChain:!0},terms:{link:{init:null,manifest:"single",register:!1}},args:(f,p)=>f.ref(p),validate(f,{schema:p,state:m,prefs:b}){o(p.$_terms.link,"Uninitialized link schema");const g=d.generate(p,f,m,b),y=p.$_terms.link[0].ref;return g.$_validate(f,m.nest(g,`link:${y.display}:${g.type}`),b)},generate:(f,p,m,b)=>d.generate(f,p,m,b),rules:{ref:{method(f){o(!this.$_terms.link,"Cannot reinitialize schema"),f=h.ref(f),o(f.type==="value"||f.type==="local","Invalid reference type:",f.type),o(f.type==="local"||f.ancestor==="root"||f.ancestor>0,"Link cannot reference itself");const p=this.clone();return p.$_terms.link=[{ref:f}],p}},relative:{method(f=!0){return this.$_setFlag("relative",f)}}},overrides:{concat(f){o(this.$_terms.link,"Uninitialized link schema"),o(u.isSchema(f),"Invalid schema object"),o(f.type!=="link","Cannot merge type link with another link");const p=this.clone();return p.$_terms.whens||(p.$_terms.whens=[]),p.$_terms.whens.push({concat:f}),p.$_mutateRebuild()}},manifest:{build:(f,p)=>(o(p.link,"Invalid link description missing link"),f.ref(p.link))}}),d.generate=function(f,p,m,b){let g=m.mainstay.links.get(f);if(g)return g._generate(p,m,b).schema;const y=f.$_terms.link[0].ref,{perspective:v,path:k}=d.perspective(y,m);d.assert(v,"which is outside of schema boundaries",y,f,m,b);try{g=k.length?v.$_reach(k):v}catch{d.assert(!1,"to non-existing schema",y,f,m,b)}return d.assert(g.type!=="link","which is another link",y,f,m,b),f._flags.relative||m.mainstay.links.set(f,g),g._generate(p,m,b).schema},d.perspective=function(f,p){if(f.type==="local"){for(const{schema:m,key:b}of p.schemas){if((m._flags.id||b)===f.path[0])return{perspective:m,path:f.path.slice(1)};if(m.$_terms.shared){for(const g of m.$_terms.shared)if(g._flags.id===f.path[0])return{perspective:g,path:f.path.slice(1)}}}return{perspective:null,path:null}}return f.ancestor==="root"?{perspective:p.schemas[p.schemas.length-1].schema,path:f.path}:{perspective:p.schemas[f.ancestor]&&p.schemas[f.ancestor].schema,path:f.path}},d.assert=function(f,p,m,b,g,y){f||o(!1,`"${l.label(b._flags,g,y)}" contains link reference "${m.display}" ${p}`)}},3832:(r,n,a)=>{const o=a(375),c=a(8068),u=a(8160),h={numberRx:/^\s*[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:e([+-]?\d+))?\s*$/i,precisionRx:/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,exponentialPartRegex:/[eE][+-]?\d+$/,leadingSignAndZerosRegex:/^[+-]?(0*)?/,dotRegex:/\./,trailingZerosRegex:/0+$/,decimalPlaces(l){const d=l.toString(),f=d.indexOf("."),p=d.indexOf("e");return(f<0?0:(p<0?d.length:p)-f-1)+(p<0?0:Math.max(0,-parseInt(d.slice(p+1))))}};r.exports=c.extend({type:"number",flags:{unsafe:{default:!1}},coerce:{from:"string",method(l,{schema:d,error:f}){if(!l.match(h.numberRx))return;l=l.trim();const p={value:parseFloat(l)};if(p.value===0&&(p.value=0),!d._flags.unsafe)if(l.match(/e/i)){if(h.extractSignificantDigits(l)!==h.extractSignificantDigits(String(p.value)))return p.errors=f("number.unsafe"),p}else{const m=p.value.toString();if(m.match(/e/i))return p;if(m!==h.normalizeDecimal(l))return p.errors=f("number.unsafe"),p}return p}},validate(l,{schema:d,error:f,prefs:p}){if(l===1/0||l===-1/0)return{value:l,errors:f("number.infinity")};if(!u.isNumber(l))return{value:l,errors:f("number.base")};const m={value:l};if(p.convert){const b=d.$_getRule("precision");if(b){const g=Math.pow(10,b.args.limit);m.value=Math.round(m.value*g)/g}}return m.value===0&&(m.value=0),!d._flags.unsafe&&(l>Number.MAX_SAFE_INTEGER||l<Number.MIN_SAFE_INTEGER)&&(m.errors=f("number.unsafe")),m},rules:{compare:{method:!1,validate:(l,d,{limit:f},{name:p,operator:m,args:b})=>u.compare(l,f,m)?l:d.error("number."+p,{limit:b.limit,value:l}),args:[{name:"limit",ref:!0,assert:u.isNumber,message:"must be a number"}]},greater:{method(l){return this.$_addRule({name:"greater",method:"compare",args:{limit:l},operator:">"})}},integer:{method(){return this.$_addRule("integer")},validate:(l,d)=>Math.trunc(l)-l==0?l:d.error("number.integer")},less:{method(l){return this.$_addRule({name:"less",method:"compare",args:{limit:l},operator:"<"})}},max:{method(l){return this.$_addRule({name:"max",method:"compare",args:{limit:l},operator:"<="})}},min:{method(l){return this.$_addRule({name:"min",method:"compare",args:{limit:l},operator:">="})}},multiple:{method(l){const d=typeof l=="number"?h.decimalPlaces(l):null,f=Math.pow(10,d);return this.$_addRule({name:"multiple",args:{base:l,baseDecimalPlace:d,pfactor:f}})},validate:(l,d,{base:f,baseDecimalPlace:p,pfactor:m},b)=>h.decimalPlaces(l)>p?d.error("number.multiple",{multiple:b.args.base,value:l}):Math.round(m*l)%Math.round(m*f)==0?l:d.error("number.multiple",{multiple:b.args.base,value:l}),args:[{name:"base",ref:!0,assert:l=>typeof l=="number"&&isFinite(l)&&l>0,message:"must be a positive number"},"baseDecimalPlace","pfactor"],multi:!0},negative:{method(){return this.sign("negative")}},port:{method(){return this.$_addRule("port")},validate:(l,d)=>Number.isSafeInteger(l)&&l>=0&&l<=65535?l:d.error("number.port")},positive:{method(){return this.sign("positive")}},precision:{method(l){return o(Number.isSafeInteger(l),"limit must be an integer"),this.$_addRule({name:"precision",args:{limit:l}})},validate(l,d,{limit:f}){const p=l.toString().match(h.precisionRx);return Math.max((p[1]?p[1].length:0)-(p[2]?parseInt(p[2],10):0),0)<=f?l:d.error("number.precision",{limit:f,value:l})},convert:!0},sign:{method(l){return o(["negative","positive"].includes(l),"Invalid sign",l),this.$_addRule({name:"sign",args:{sign:l}})},validate:(l,d,{sign:f})=>f==="negative"&&l<0||f==="positive"&&l>0?l:d.error(`number.${f}`)},unsafe:{method(l=!0){return o(typeof l=="boolean","enabled must be a boolean"),this.$_setFlag("unsafe",l)}}},cast:{string:{from:l=>typeof l=="number",to:(l,d)=>l.toString()}},messages:{"number.base":"{{#label}} must be a number","number.greater":"{{#label}} must be greater than {{#limit}}","number.infinity":"{{#label}} cannot be infinity","number.integer":"{{#label}} must be an integer","number.less":"{{#label}} must be less than {{#limit}}","number.max":"{{#label}} must be less than or equal to {{#limit}}","number.min":"{{#label}} must be greater than or equal to {{#limit}}","number.multiple":"{{#label}} must be a multiple of {{#multiple}}","number.negative":"{{#label}} must be a negative number","number.port":"{{#label}} must be a valid port","number.positive":"{{#label}} must be a positive number","number.precision":"{{#label}} must have no more than {{#limit}} decimal places","number.unsafe":"{{#label}} must be a safe number"}}),h.extractSignificantDigits=function(l){return l.replace(h.exponentialPartRegex,"").replace(h.dotRegex,"").replace(h.trailingZerosRegex,"").replace(h.leadingSignAndZerosRegex,"")},h.normalizeDecimal=function(l){return(l=l.replace(/^\+/,"").replace(/\.0*$/,"").replace(/^(-?)\.([^\.]*)$/,"$10.$2").replace(/^(-?)0+([0-9])/,"$1$2")).includes(".")&&l.endsWith("0")&&(l=l.replace(/0+$/,"")),l==="-0"?"0":l}},8966:(r,n,a)=>{const o=a(7824);r.exports=o.extend({type:"object",cast:{map:{from:c=>c&&typeof c=="object",to:(c,u)=>new Map(Object.entries(c))}}})},7417:(r,n,a)=>{const o=a(375),c=a(5380),u=a(1745),h=a(9959),l=a(6064),d=a(9926),f=a(5752),p=a(8068),m=a(8160),b={tlds:d instanceof Set&&{tlds:{allow:d,deny:null}},base64Regex:{true:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}==|[\w\-]{3}=)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/},false:{true:/^(?:[\w\-]{2}[\w\-]{2})*(?:[\w\-]{2}(==)?|[\w\-]{3}=?)?$/,false:/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/}},dataUriRegex:/^data:[\w+.-]+\/[\w+.-]+;((charset=[\w-]+|base64),)?(.*)$/,hexRegex:{withPrefix:/^0x[0-9a-f]+$/i,withOptionalPrefix:/^(?:0x)?[0-9a-f]+$/i,withoutPrefix:/^[0-9a-f]+$/i},ipRegex:h.regex({cidr:"forbidden"}).regex,isoDurationRegex:/^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/,guidBrackets:{"{":"}","[":"]","(":")","":""},guidVersions:{uuidv1:"1",uuidv2:"2",uuidv3:"3",uuidv4:"4",uuidv5:"5",uuidv6:"6",uuidv7:"7",uuidv8:"8"},guidSeparators:new Set([void 0,!0,!1,"-",":"]),normalizationForms:["NFC","NFD","NFKC","NFKD"]};r.exports=p.extend({type:"string",flags:{insensitive:{default:!1},truncate:{default:!1}},terms:{replacements:{init:null}},coerce:{from:"string",method(g,{schema:y,state:v,prefs:k}){const C=y.$_getRule("normalize");C&&(g=g.normalize(C.args.form));const _=y.$_getRule("case");_&&(g=_.args.direction==="upper"?g.toLocaleUpperCase():g.toLocaleLowerCase());const E=y.$_getRule("trim");if(E&&E.args.enabled&&(g=g.trim()),y.$_terms.replacements)for(const S of y.$_terms.replacements)g=g.replace(S.pattern,S.replacement);const x=y.$_getRule("hex");if(x&&x.args.options.byteAligned&&g.length%2!=0&&(g=`0${g}`),y.$_getRule("isoDate")){const S=b.isoDate(g);S&&(g=S)}if(y._flags.truncate){const S=y.$_getRule("max");if(S){let T=S.args.limit;if(m.isResolvable(T)&&(T=T.resolve(g,v,k),!m.limit(T)))return{value:g,errors:y.$_createError("any.ref",T,{ref:S.args.limit,arg:"limit",reason:"must be a positive integer"},v,k)};g=g.slice(0,T)}}return{value:g}}},validate(g,{schema:y,error:v}){if(typeof g!="string")return{value:g,errors:v("string.base")};if(g===""){const k=y.$_getRule("min");return k&&k.args.limit===0?void 0:{value:g,errors:v("string.empty")}}},rules:{alphanum:{method(){return this.$_addRule("alphanum")},validate:(g,y)=>/^[a-zA-Z0-9]+$/.test(g)?g:y.error("string.alphanum")},base64:{method(g={}){return m.assertOptions(g,["paddingRequired","urlSafe"]),g={urlSafe:!1,paddingRequired:!0,...g},o(typeof g.paddingRequired=="boolean","paddingRequired must be boolean"),o(typeof g.urlSafe=="boolean","urlSafe must be boolean"),this.$_addRule({name:"base64",args:{options:g}})},validate:(g,y,{options:v})=>b.base64Regex[v.paddingRequired][v.urlSafe].test(g)?g:y.error("string.base64")},case:{method(g){return o(["lower","upper"].includes(g),"Invalid case:",g),this.$_addRule({name:"case",args:{direction:g}})},validate:(g,y,{direction:v})=>v==="lower"&&g===g.toLocaleLowerCase()||v==="upper"&&g===g.toLocaleUpperCase()?g:y.error(`string.${v}case`),convert:!0},creditCard:{method(){return this.$_addRule("creditCard")},validate(g,y){let v=g.length,k=0,C=1;for(;v--;){const _=g.charAt(v)*C;k+=_-9*(_>9),C^=3}return k>0&&k%10==0?g:y.error("string.creditCard")}},dataUri:{method(g={}){return m.assertOptions(g,["paddingRequired"]),g={paddingRequired:!0,...g},o(typeof g.paddingRequired=="boolean","paddingRequired must be boolean"),this.$_addRule({name:"dataUri",args:{options:g}})},validate(g,y,{options:v}){const k=g.match(b.dataUriRegex);return k&&(!k[2]||k[2]!=="base64"||b.base64Regex[v.paddingRequired].false.test(k[3]))?g:y.error("string.dataUri")}},domain:{method(g){g&&m.assertOptions(g,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const y=b.addressOptions(g);return this.$_addRule({name:"domain",args:{options:g},address:y})},validate:(g,y,v,{address:k})=>c.isValid(g,k)?g:y.error("string.domain")},email:{method(g={}){m.assertOptions(g,["allowFullyQualified","allowUnicode","ignoreLength","maxDomainSegments","minDomainSegments","multiple","separator","tlds"]),o(g.multiple===void 0||typeof g.multiple=="boolean","multiple option must be an boolean");const y=b.addressOptions(g),v=new RegExp(`\\s*[${g.separator?l(g.separator):","}]\\s*`);return this.$_addRule({name:"email",args:{options:g},regex:v,address:y})},validate(g,y,{options:v},{regex:k,address:C}){const _=v.multiple?g.split(k):[g],E=[];for(const x of _)u.isValid(x,C)||E.push(x);return E.length?y.error("string.email",{value:g,invalids:E}):g}},guid:{alias:"uuid",method(g={}){m.assertOptions(g,["version","separator"]);let y="";if(g.version){const C=[].concat(g.version);o(C.length>=1,"version must have at least 1 valid version specified");const _=new Set;for(let E=0;E<C.length;++E){const x=C[E];o(typeof x=="string","version at position "+E+" must be a string");const S=b.guidVersions[x.toLowerCase()];o(S,"version at position "+E+" must be one of "+Object.keys(b.guidVersions).join(", ")),o(!_.has(S),"version at position "+E+" must not be a duplicate"),y+=S,_.add(S)}}o(b.guidSeparators.has(g.separator),'separator must be one of true, false, "-", or ":"');const v=g.separator===void 0?"[:-]?":g.separator===!0?"[:-]":g.separator===!1?"[]?":`\\${g.separator}`,k=new RegExp(`^([\\[{\\(]?)[0-9A-F]{8}(${v})[0-9A-F]{4}\\2?[${y||"0-9A-F"}][0-9A-F]{3}\\2?[${y?"89AB":"0-9A-F"}][0-9A-F]{3}\\2?[0-9A-F]{12}([\\]}\\)]?)$`,"i");return this.$_addRule({name:"guid",args:{options:g},regex:k})},validate(g,y,v,{regex:k}){const C=k.exec(g);return C?b.guidBrackets[C[1]]!==C[C.length-1]?y.error("string.guid"):g:y.error("string.guid")}},hex:{method(g={}){return m.assertOptions(g,["byteAligned","prefix"]),g={byteAligned:!1,prefix:!1,...g},o(typeof g.byteAligned=="boolean","byteAligned must be boolean"),o(typeof g.prefix=="boolean"||g.prefix==="optional",'prefix must be boolean or "optional"'),this.$_addRule({name:"hex",args:{options:g}})},validate:(g,y,{options:v})=>(v.prefix==="optional"?b.hexRegex.withOptionalPrefix:v.prefix===!0?b.hexRegex.withPrefix:b.hexRegex.withoutPrefix).test(g)?v.byteAligned&&g.length%2!=0?y.error("string.hexAlign"):g:y.error("string.hex")},hostname:{method(){return this.$_addRule("hostname")},validate:(g,y)=>c.isValid(g,{minDomainSegments:1})||b.ipRegex.test(g)?g:y.error("string.hostname")},insensitive:{method(){return this.$_setFlag("insensitive",!0)}},ip:{method(g={}){m.assertOptions(g,["cidr","version"]);const{cidr:y,versions:v,regex:k}=h.regex(g),C=g.version?v:void 0;return this.$_addRule({name:"ip",args:{options:{cidr:y,version:C}},regex:k})},validate:(g,y,{options:v},{regex:k})=>k.test(g)?g:v.version?y.error("string.ipVersion",{value:g,cidr:v.cidr,version:v.version}):y.error("string.ip",{value:g,cidr:v.cidr})},isoDate:{method(){return this.$_addRule("isoDate")},validate:(g,{error:y})=>b.isoDate(g)?g:y("string.isoDate")},isoDuration:{method(){return this.$_addRule("isoDuration")},validate:(g,y)=>b.isoDurationRegex.test(g)?g:y.error("string.isoDuration")},length:{method(g,y){return b.length(this,"length",g,"=",y)},validate(g,y,{limit:v,encoding:k},{name:C,operator:_,args:E}){const x=!k&&g.length;return m.compare(x,v,_)?g:y.error("string."+C,{limit:E.limit,value:g,encoding:k})},args:[{name:"limit",ref:!0,assert:m.limit,message:"must be a positive integer"},"encoding"]},lowercase:{method(){return this.case("lower")}},max:{method(g,y){return b.length(this,"max",g,"<=",y)},args:["limit","encoding"]},min:{method(g,y){return b.length(this,"min",g,">=",y)},args:["limit","encoding"]},normalize:{method(g="NFC"){return o(b.normalizationForms.includes(g),"normalization form must be one of "+b.normalizationForms.join(", ")),this.$_addRule({name:"normalize",args:{form:g}})},validate:(g,{error:y},{form:v})=>g===g.normalize(v)?g:y("string.normalize",{value:g,form:v}),convert:!0},pattern:{alias:"regex",method(g,y={}){o(g instanceof RegExp,"regex must be a RegExp"),o(!g.flags.includes("g")&&!g.flags.includes("y"),"regex should not use global or sticky mode"),typeof y=="string"&&(y={name:y}),m.assertOptions(y,["invert","name"]);const v=["string.pattern",y.invert?".invert":"",y.name?".name":".base"].join("");return this.$_addRule({name:"pattern",args:{regex:g,options:y},errorCode:v})},validate:(g,y,{regex:v,options:k},{errorCode:C})=>v.test(g)^k.invert?g:y.error(C,{name:k.name,regex:v,value:g}),args:["regex","options"],multi:!0},replace:{method(g,y){typeof g=="string"&&(g=new RegExp(l(g),"g")),o(g instanceof RegExp,"pattern must be a RegExp"),o(typeof y=="string","replacement must be a String");const v=this.clone();return v.$_terms.replacements||(v.$_terms.replacements=[]),v.$_terms.replacements.push({pattern:g,replacement:y}),v}},token:{method(){return this.$_addRule("token")},validate:(g,y)=>/^\w+$/.test(g)?g:y.error("string.token")},trim:{method(g=!0){return o(typeof g=="boolean","enabled must be a boolean"),this.$_addRule({name:"trim",args:{enabled:g}})},validate:(g,y,{enabled:v})=>v&&g!==g.trim()?y.error("string.trim"):g,convert:!0},truncate:{method(g=!0){return o(typeof g=="boolean","enabled must be a boolean"),this.$_setFlag("truncate",g)}},uppercase:{method(){return this.case("upper")}},uri:{method(g={}){m.assertOptions(g,["allowRelative","allowQuerySquareBrackets","domain","relativeOnly","scheme","encodeUri"]),g.domain&&m.assertOptions(g.domain,["allowFullyQualified","allowUnicode","maxDomainSegments","minDomainSegments","tlds"]);const{regex:y,scheme:v}=f.regex(g),k=g.domain?b.addressOptions(g.domain):null;return this.$_addRule({name:"uri",args:{options:g},regex:y,domain:k,scheme:v})},validate(g,y,{options:v},{regex:k,domain:C,scheme:_}){if(["http:/","https:/"].includes(g))return y.error("string.uri");let E=k.exec(g);if(!E&&y.prefs.convert&&v.encodeUri){const x=encodeURI(g);E=k.exec(x),E&&(g=x)}if(E){const x=E[1]||E[2];return!C||v.allowRelative&&!x||c.isValid(x,C)?g:y.error("string.domain",{value:x})}return v.relativeOnly?y.error("string.uriRelativeOnly"):v.scheme?y.error("string.uriCustomScheme",{scheme:_,value:g}):y.error("string.uri")}}},manifest:{build(g,y){if(y.replacements)for(const{pattern:v,replacement:k}of y.replacements)g=g.replace(v,k);return g}},messages:{"string.alphanum":"{{#label}} must only contain alpha-numeric characters","string.base":"{{#label}} must be a string","string.base64":"{{#label}} must be a valid base64 string","string.creditCard":"{{#label}} must be a credit card","string.dataUri":"{{#label}} must be a valid dataUri string","string.domain":"{{#label}} must contain a valid domain name","string.email":"{{#label}} must be a valid email","string.empty":"{{#label}} is not allowed to be empty","string.guid":"{{#label}} must be a valid GUID","string.hex":"{{#label}} must only contain hexadecimal characters","string.hexAlign":"{{#label}} hex decoded representation must be byte aligned","string.hostname":"{{#label}} must be a valid hostname","string.ip":"{{#label}} must be a valid ip address with a {{#cidr}} CIDR","string.ipVersion":"{{#label}} must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR","string.isoDate":"{{#label}} must be in iso format","string.isoDuration":"{{#label}} must be a valid ISO 8601 duration","string.length":"{{#label}} length must be {{#limit}} characters long","string.lowercase":"{{#label}} must only contain lowercase characters","string.max":"{{#label}} length must be less than or equal to {{#limit}} characters long","string.min":"{{#label}} length must be at least {{#limit}} characters long","string.normalize":"{{#label}} must be unicode normalized in the {{#form}} form","string.token":"{{#label}} must only contain alpha-numeric and underscore characters","string.pattern.base":"{{#label}} with value {:[.]} fails to match the required pattern: {{#regex}}","string.pattern.name":"{{#label}} with value {:[.]} fails to match the {{#name}} pattern","string.pattern.invert.base":"{{#label}} with value {:[.]} matches the inverted pattern: {{#regex}}","string.pattern.invert.name":"{{#label}} with value {:[.]} matches the inverted {{#name}} pattern","string.trim":"{{#label}} must not have leading or trailing whitespace","string.uri":"{{#label}} must be a valid uri","string.uriCustomScheme":"{{#label}} must be a valid uri with a scheme matching the {{#scheme}} pattern","string.uriRelativeOnly":"{{#label}} must be a valid relative uri","string.uppercase":"{{#label}} must only contain uppercase characters"}}),b.addressOptions=function(g){if(!g)return b.tlds||g;if(o(g.minDomainSegments===void 0||Number.isSafeInteger(g.minDomainSegments)&&g.minDomainSegments>0,"minDomainSegments must be a positive integer"),o(g.maxDomainSegments===void 0||Number.isSafeInteger(g.maxDomainSegments)&&g.maxDomainSegments>0,"maxDomainSegments must be a positive integer"),g.tlds===!1)return g;if(g.tlds===!0||g.tlds===void 0)return o(b.tlds,"Built-in TLD list disabled"),Object.assign({},g,b.tlds);o(typeof g.tlds=="object","tlds must be true, false, or an object");const y=g.tlds.deny;if(y)return Array.isArray(y)&&(g=Object.assign({},g,{tlds:{deny:new Set(y)}})),o(g.tlds.deny instanceof Set,"tlds.deny must be an array, Set, or boolean"),o(!g.tlds.allow,"Cannot specify both tlds.allow and tlds.deny lists"),b.validateTlds(g.tlds.deny,"tlds.deny"),g;const v=g.tlds.allow;return v?v===!0?(o(b.tlds,"Built-in TLD list disabled"),Object.assign({},g,b.tlds)):(Array.isArray(v)&&(g=Object.assign({},g,{tlds:{allow:new Set(v)}})),o(g.tlds.allow instanceof Set,"tlds.allow must be an array, Set, or boolean"),b.validateTlds(g.tlds.allow,"tlds.allow"),g):g},b.validateTlds=function(g,y){for(const v of g)o(c.isValid(v,{minDomainSegments:1,maxDomainSegments:1}),`${y} must contain valid top level domain names`)},b.isoDate=function(g){if(!m.isIsoDate(g))return null;/.*T.*[+-]\d\d$/.test(g)&&(g+="00");const y=new Date(g);return isNaN(y.getTime())?null:y.toISOString()},b.length=function(g,y,v,k,C){return o(!C||!1,"Invalid encoding:",C),g.$_addRule({name:y,method:"length",args:{limit:v,encoding:C},operator:k})}},8826:(r,n,a)=>{const o=a(375),c=a(8068),u={};u.Map=class extends Map{slice(){return new u.Map(this)}},r.exports=c.extend({type:"symbol",terms:{map:{init:new u.Map}},coerce:{method(h,{schema:l,error:d}){const f=l.$_terms.map.get(h);return f&&(h=f),l._flags.only&&typeof h!="symbol"?{value:h,errors:d("symbol.map",{map:l.$_terms.map})}:{value:h}}},validate(h,{error:l}){if(typeof h!="symbol")return{value:h,errors:l("symbol.base")}},rules:{map:{method(h){h&&!h[Symbol.iterator]&&typeof h=="object"&&(h=Object.entries(h)),o(h&&h[Symbol.iterator],"Iterable must be an iterable or object");const l=this.clone(),d=[];for(const f of h){o(f&&f[Symbol.iterator],"Entry must be an iterable");const[p,m]=f;o(typeof p!="object"&&typeof p!="function"&&typeof p!="symbol","Key must not be of type object, function, or Symbol"),o(typeof m=="symbol","Value must be a Symbol"),l.$_terms.map.set(p,m),d.push(m)}return l.valid(...d)}}},manifest:{build:(h,l)=>(l.map&&(h=h.map(l.map)),h)},messages:{"symbol.base":"{{#label}} must be a symbol","symbol.map":"{{#label}} must be one of {{#map}}"}})},8863:(r,n,a)=>{const o=a(375),c=a(8571),u=a(738),h=a(9621),l=a(8160),d=a(6354),f=a(493),p={result:Symbol("result")};n.entry=function(m,b,g){let y=l.defaults;g&&(o(g.warnings===void 0,"Cannot override warnings preference in synchronous validation"),o(g.artifacts===void 0,"Cannot override artifacts preference in synchronous validation"),y=l.preferences(l.defaults,g));const v=p.entry(m,b,y);o(!v.mainstay.externals.length,"Schema with external rules must use validateAsync()");const k={value:v.value};return v.error&&(k.error=v.error),v.mainstay.warnings.length&&(k.warning=d.details(v.mainstay.warnings)),v.mainstay.debug&&(k.debug=v.mainstay.debug),v.mainstay.artifacts&&(k.artifacts=v.mainstay.artifacts),k},n.entryAsync=async function(m,b,g){let y=l.defaults;g&&(y=l.preferences(l.defaults,g));const v=p.entry(m,b,y),k=v.mainstay;if(v.error)throw k.debug&&(v.error.debug=k.debug),v.error;if(k.externals.length){let _=v.value;const E=[];for(const x of k.externals){const S=x.state.path,T=x.schema.type==="link"?k.links.get(x.schema):null;let A,R,M=_;const j=S.length?[_]:[],W=S.length?h(m,S):m;if(S.length){A=S[S.length-1];let se=_;for(const Y of S.slice(0,-1))se=se[Y],j.unshift(se);R=j[0],M=R[A]}try{const se=(ae,he)=>(T||x.schema).$_createError(ae,M,he,x.state,y),Y=await x.method(M,{schema:x.schema,linked:T,state:x.state,prefs:g,original:W,error:se,errorsArray:p.errorsArray,warn:(ae,he)=>k.warnings.push((T||x.schema).$_createError(ae,M,he,x.state,y)),message:(ae,he)=>(T||x.schema).$_createError("external",M,he,x.state,y,{messages:ae})});if(Y===void 0||Y===M)continue;if(Y instanceof d.Report){if(k.tracer.log(x.schema,x.state,"rule","external","error"),E.push(Y),y.abortEarly)break;continue}if(Array.isArray(Y)&&Y[l.symbols.errors]){if(k.tracer.log(x.schema,x.state,"rule","external","error"),E.push(...Y),y.abortEarly)break;continue}R?(k.tracer.value(x.state,"rule",M,Y,"external"),R[A]=Y):(k.tracer.value(x.state,"rule",_,Y,"external"),_=Y)}catch(se){throw y.errors.label&&(se.message+=` (${x.label})`),se}}if(v.value=_,E.length)throw v.error=d.process(E,m,y),k.debug&&(v.error.debug=k.debug),v.error}if(!y.warnings&&!y.debug&&!y.artifacts)return v.value;const C={value:v.value};return k.warnings.length&&(C.warning=d.details(k.warnings)),k.debug&&(C.debug=k.debug),k.artifacts&&(C.artifacts=k.artifacts),C},p.Mainstay=class{constructor(m,b,g){this.externals=[],this.warnings=[],this.tracer=m,this.debug=b,this.links=g,this.shadow=null,this.artifacts=null,this._snapshots=[]}snapshot(){this._snapshots.push({externals:this.externals.slice(),warnings:this.warnings.slice()})}restore(){const m=this._snapshots.pop();this.externals=m.externals,this.warnings=m.warnings}commit(){this._snapshots.pop()}},p.entry=function(m,b,g){const{tracer:y,cleanup:v}=p.tracer(b,g),k=g.debug?[]:null,C=b._ids._schemaChain?new Map:null,_=new p.Mainstay(y,k,C),E=b._ids._schemaChain?[{schema:b}]:null,x=new f([],[],{mainstay:_,schemas:E}),S=n.validate(m,b,x,g);v&&b.$_root.untrace();const T=d.process(S.errors,m,g);return{value:S.value,error:T,mainstay:_}},p.tracer=function(m,b){return m.$_root._tracer?{tracer:m.$_root._tracer._register(m)}:b.debug?(o(m.$_root.trace,"Debug mode not supported"),{tracer:m.$_root.trace()._register(m),cleanup:!0}):{tracer:p.ignore}},n.validate=function(m,b,g,y,v={}){if(b.$_terms.whens&&(b=b._generate(m,g,y).schema),b._preferences&&(y=p.prefs(b,y)),b._cache&&y.cache){const T=b._cache.get(m);if(g.mainstay.tracer.debug(g,"validate","cached",!!T),T)return T}const k=(T,A,R)=>b.$_createError(T,m,A,R||g,y),C={original:m,prefs:y,schema:b,state:g,error:k,errorsArray:p.errorsArray,warn:(T,A,R)=>g.mainstay.warnings.push(k(T,A,R)),message:(T,A)=>b.$_createError("custom",m,A,g,y,{messages:T})};g.mainstay.tracer.entry(b,g);const _=b._definition;if(_.prepare&&m!==void 0&&y.convert){const T=_.prepare(m,C);if(T){if(g.mainstay.tracer.value(g,"prepare",m,T.value),T.errors)return p.finalize(T.value,[].concat(T.errors),C);m=T.value}}if(_.coerce&&m!==void 0&&y.convert&&(!_.coerce.from||_.coerce.from.includes(typeof m))){const T=_.coerce.method(m,C);if(T){if(g.mainstay.tracer.value(g,"coerced",m,T.value),T.errors)return p.finalize(T.value,[].concat(T.errors),C);m=T.value}}const E=b._flags.empty;E&&E.$_match(p.trim(m,b),g.nest(E),l.defaults)&&(g.mainstay.tracer.value(g,"empty",m,void 0),m=void 0);const x=v.presence||b._flags.presence||(b._flags._endedSwitch?null:y.presence);if(m===void 0){if(x==="forbidden")return p.finalize(m,null,C);if(x==="required")return p.finalize(m,[b.$_createError("any.required",m,null,g,y)],C);if(x==="optional"){if(b._flags.default!==l.symbols.deepDefault)return p.finalize(m,null,C);g.mainstay.tracer.value(g,"default",m,{}),m={}}}else if(x==="forbidden")return p.finalize(m,[b.$_createError("any.unknown",m,null,g,y)],C);const S=[];if(b._valids){const T=b._valids.get(m,g,y,b._flags.insensitive);if(T)return y.convert&&(g.mainstay.tracer.value(g,"valids",m,T.value),m=T.value),g.mainstay.tracer.filter(b,g,"valid",T),p.finalize(m,null,C);if(b._flags.only){const A=b.$_createError("any.only",m,{valids:b._valids.values({display:!0})},g,y);if(y.abortEarly)return p.finalize(m,[A],C);S.push(A)}}if(b._invalids){const T=b._invalids.get(m,g,y,b._flags.insensitive);if(T){g.mainstay.tracer.filter(b,g,"invalid",T);const A=b.$_createError("any.invalid",m,{invalids:b._invalids.values({display:!0})},g,y);if(y.abortEarly)return p.finalize(m,[A],C);S.push(A)}}if(_.validate){const T=_.validate(m,C);if(T&&(g.mainstay.tracer.value(g,"base",m,T.value),m=T.value,T.errors)){if(!Array.isArray(T.errors))return S.push(T.errors),p.finalize(m,S,C);if(T.errors.length)return S.push(...T.errors),p.finalize(m,S,C)}}return b._rules.length?p.rules(m,S,C):p.finalize(m,S,C)},p.rules=function(m,b,g){const{schema:y,state:v,prefs:k}=g;for(const C of y._rules){const _=y._definition.rules[C.method];if(_.convert&&k.convert){v.mainstay.tracer.log(y,v,"rule",C.name,"full");continue}let E,x=C.args;if(C._resolve.length){x=Object.assign({},x);for(const T of C._resolve){const A=_.argsByName.get(T),R=x[T].resolve(m,v,k),M=A.normalize?A.normalize(R):R,j=l.validateArg(M,null,A);if(j){E=y.$_createError("any.ref",R,{arg:T,ref:x[T],reason:j},v,k);break}x[T]=M}}E=E||_.validate(m,g,x,C);const S=p.rule(E,C);if(S.errors){if(v.mainstay.tracer.log(y,v,"rule",C.name,"error"),C.warn){v.mainstay.warnings.push(...S.errors);continue}if(k.abortEarly)return p.finalize(m,S.errors,g);b.push(...S.errors)}else v.mainstay.tracer.log(y,v,"rule",C.name,"pass"),v.mainstay.tracer.value(v,"rule",m,S.value,C.name),m=S.value}return p.finalize(m,b,g)},p.rule=function(m,b){return m instanceof d.Report?(p.error(m,b),{errors:[m],value:null}):Array.isArray(m)&&m[l.symbols.errors]?(m.forEach(g=>p.error(g,b)),{errors:m,value:null}):{errors:null,value:m}},p.error=function(m,b){return b.message&&m._setTemplate(b.message),m},p.finalize=function(m,b,g){b=b||[];const{schema:y,state:v,prefs:k}=g;if(b.length){const _=p.default("failover",void 0,b,g);_!==void 0&&(v.mainstay.tracer.value(v,"failover",m,_),m=_,b=[])}if(b.length&&y._flags.error)if(typeof y._flags.error=="function"){b=y._flags.error(b),Array.isArray(b)||(b=[b]);for(const _ of b)o(_ instanceof Error||_ instanceof d.Report,"error() must return an Error object")}else b=[y._flags.error];if(m===void 0){const _=p.default("default",m,b,g);v.mainstay.tracer.value(v,"default",m,_),m=_}if(y._flags.cast&&m!==void 0){const _=y._definition.cast[y._flags.cast];if(_.from(m)){const E=_.to(m,g);v.mainstay.tracer.value(v,"cast",m,E,y._flags.cast),m=E}}if(y.$_terms.externals&&k.externals&&k._externals!==!1)for(const{method:_}of y.$_terms.externals)v.mainstay.externals.push({method:_,schema:y,state:v,label:d.label(y._flags,v,k)});const C={value:m,errors:b.length?b:null};return y._flags.result&&(C.value=y._flags.result==="strip"?void 0:g.original,v.mainstay.tracer.value(v,y._flags.result,m,C.value),v.shadow(m,y._flags.result)),y._cache&&k.cache!==!1&&!y._refs.length&&y._cache.set(g.original,C),m===void 0||C.errors||y._flags.artifact===void 0||(v.mainstay.artifacts=v.mainstay.artifacts||new Map,v.mainstay.artifacts.has(y._flags.artifact)||v.mainstay.artifacts.set(y._flags.artifact,[]),v.mainstay.artifacts.get(y._flags.artifact).push(v.path)),C},p.prefs=function(m,b){const g=b===l.defaults;return g&&m._preferences[l.symbols.prefs]?m._preferences[l.symbols.prefs]:(b=l.preferences(b,m._preferences),g&&(m._preferences[l.symbols.prefs]=b),b)},p.default=function(m,b,g,y){const{schema:v,state:k,prefs:C}=y,_=v._flags[m];if(C.noDefaults||_===void 0)return b;if(k.mainstay.tracer.log(v,k,"rule",m,"full"),!_)return _;if(typeof _=="function"){const E=_.length?[c(k.ancestors[0]),y]:[];try{return _(...E)}catch(x){return void g.push(v.$_createError(`any.${m}`,null,{error:x},k,C))}}return typeof _!="object"?_:_[l.symbols.literal]?_.literal:l.isResolvable(_)?_.resolve(b,k,C):c(_)},p.trim=function(m,b){if(typeof m!="string")return m;const g=b.$_getRule("trim");return g&&g.args.enabled?m.trim():m},p.ignore={active:!1,debug:u,entry:u,filter:u,log:u,resolve:u,value:u},p.errorsArray=function(){const m=[];return m[l.symbols.errors]=!0,m}},2036:(r,n,a)=>{const o=a(375),c=a(9474),u=a(8160),h={};r.exports=h.Values=class{constructor(l,d){this._values=new Set(l),this._refs=new Set(d),this._lowercase=h.lowercases(l),this._override=!1}get length(){return this._values.size+this._refs.size}add(l,d){u.isResolvable(l)?this._refs.has(l)||(this._refs.add(l),d&&d.register(l)):this.has(l,null,null,!1)||(this._values.add(l),typeof l=="string"&&this._lowercase.set(l.toLowerCase(),l))}static merge(l,d,f){if(l=l||new h.Values,d){if(d._override)return d.clone();for(const p of[...d._values,...d._refs])l.add(p)}if(f)for(const p of[...f._values,...f._refs])l.remove(p);return l.length?l:null}remove(l){u.isResolvable(l)?this._refs.delete(l):(this._values.delete(l),typeof l=="string"&&this._lowercase.delete(l.toLowerCase()))}has(l,d,f,p){return!!this.get(l,d,f,p)}get(l,d,f,p){if(!this.length)return!1;if(this._values.has(l))return{value:l};if(typeof l=="string"&&l&&p){const m=this._lowercase.get(l.toLowerCase());if(m)return{value:m}}if(!this._refs.size&&typeof l!="object")return!1;if(typeof l=="object"){for(const m of this._values)if(c(m,l))return{value:m}}if(d)for(const m of this._refs){const b=m.resolve(l,d,f,null,{in:!0});if(b===void 0)continue;const g=m.in&&typeof b=="object"?Array.isArray(b)?b:Object.keys(b):[b];for(const y of g)if(typeof y==typeof l){if(p&&l&&typeof l=="string"){if(y.toLowerCase()===l.toLowerCase())return{value:y,ref:m}}else if(c(y,l))return{value:y,ref:m}}}return!1}override(){this._override=!0}values(l){if(l&&l.display){const d=[];for(const f of[...this._values,...this._refs])f!==void 0&&d.push(f);return d}return Array.from([...this._values,...this._refs])}clone(){const l=new h.Values(this._values,this._refs);return l._override=this._override,l}concat(l){o(!l._override,"Cannot concat override set of values");const d=new h.Values([...this._values,...l._values],[...this._refs,...l._refs]);return d._override=this._override,d}describe(){const l=[];this._override&&l.push({override:!0});for(const d of this._values.values())l.push(d&&typeof d=="object"?{value:d}:d);for(const d of this._refs.values())l.push(d.describe());return l}},h.Values.prototype[u.symbols.values]=!0,h.Values.prototype.slice=h.Values.prototype.clone,h.lowercases=function(l){const d=new Map;if(l)for(const f of l)typeof f=="string"&&d.set(f.toLowerCase(),f);return d}},978:(r,n,a)=>{const o=a(375),c=a(8571),u=a(1687),h=a(9621),l={};r.exports=function(d,f,p={}){if(o(d&&typeof d=="object","Invalid defaults value: must be an object"),o(!f||f===!0||typeof f=="object","Invalid source value: must be true, falsy or an object"),o(typeof p=="object","Invalid options: must be an object"),!f)return null;if(p.shallow)return l.applyToDefaultsWithShallow(d,f,p);const m=c(d);if(f===!0)return m;const b=p.nullOverride!==void 0&&p.nullOverride;return u(m,f,{nullOverride:b,mergeArrays:!1})},l.applyToDefaultsWithShallow=function(d,f,p){const m=p.shallow;o(Array.isArray(m),"Invalid keys");const b=new Map,g=f===!0?null:new Set;for(let k of m){k=Array.isArray(k)?k:k.split(".");const C=h(d,k);C&&typeof C=="object"?b.set(C,g&&h(f,k)||C):g&&g.add(k)}const y=c(d,{},b);if(!g)return y;for(const k of g)l.reachCopy(y,f,k);const v=p.nullOverride!==void 0&&p.nullOverride;return u(y,f,{nullOverride:v,mergeArrays:!1})},l.reachCopy=function(d,f,p){for(const g of p){if(!(g in f))return;const y=f[g];if(typeof y!="object"||y===null)return;f=y}const m=f;let b=d;for(let g=0;g<p.length-1;++g){const y=p[g];typeof b[y]!="object"&&(b[y]={}),b=b[y]}b[p[p.length-1]]=m}},375:(r,n,a)=>{const o=a(7916);r.exports=function(c,...u){if(!c)throw u.length===1&&u[0]instanceof Error?u[0]:new o(u)}},8571:(r,n,a)=>{const o=a(9621),c=a(4277),u=a(7043),h={needsProtoHack:new Set([c.set,c.map,c.weakSet,c.weakMap])};r.exports=h.clone=function(l,d={},f=null){if(typeof l!="object"||l===null)return l;let p=h.clone,m=f;if(d.shallow){if(d.shallow!==!0)return h.cloneWithShallow(l,d);p=v=>v}else if(m){const v=m.get(l);if(v)return v}else m=new Map;const b=c.getInternalProto(l);if(b===c.buffer)return!1;if(b===c.date)return new Date(l.getTime());if(b===c.regex)return new RegExp(l);const g=h.base(l,b,d);if(g===l)return l;if(m&&m.set(l,g),b===c.set)for(const v of l)g.add(p(v,d,m));else if(b===c.map)for(const[v,k]of l)g.set(v,p(k,d,m));const y=u.keys(l,d);for(const v of y){if(v==="__proto__")continue;if(b===c.array&&v==="length"){g.length=l.length;continue}const k=Object.getOwnPropertyDescriptor(l,v);k?k.get||k.set?Object.defineProperty(g,v,k):k.enumerable?g[v]=p(l[v],d,m):Object.defineProperty(g,v,{enumerable:!1,writable:!0,configurable:!0,value:p(l[v],d,m)}):Object.defineProperty(g,v,{enumerable:!0,writable:!0,configurable:!0,value:p(l[v],d,m)})}return g},h.cloneWithShallow=function(l,d){const f=d.shallow;(d=Object.assign({},d)).shallow=!1;const p=new Map;for(const m of f){const b=o(l,m);typeof b!="object"&&typeof b!="function"||p.set(b,b)}return h.clone(l,d,p)},h.base=function(l,d,f){if(f.prototype===!1)return h.needsProtoHack.has(d)?new d.constructor:d===c.array?[]:{};const p=Object.getPrototypeOf(l);if(p&&p.isImmutable)return l;if(d===c.array){const m=[];return p!==d&&Object.setPrototypeOf(m,p),m}if(h.needsProtoHack.has(d)){const m=new p.constructor;return p!==d&&Object.setPrototypeOf(m,p),m}return Object.create(p)}},9474:(r,n,a)=>{const o=a(4277),c={mismatched:null};r.exports=function(u,h,l){return l=Object.assign({prototype:!0},l),!!c.isDeepEqual(u,h,l,[])},c.isDeepEqual=function(u,h,l,d){if(u===h)return u!==0||1/u==1/h;const f=typeof u;if(f!==typeof h||u===null||h===null)return!1;if(f==="function"){if(!l.deepFunction||u.toString()!==h.toString())return!1}else if(f!=="object")return u!=u&&h!=h;const p=c.getSharedType(u,h,!!l.prototype);switch(p){case o.buffer:return!1;case o.promise:return u===h;case o.regex:return u.toString()===h.toString();case c.mismatched:return!1}for(let m=d.length-1;m>=0;--m)if(d[m].isSame(u,h))return!0;d.push(new c.SeenEntry(u,h));try{return!!c.isDeepEqualObj(p,u,h,l,d)}finally{d.pop()}},c.getSharedType=function(u,h,l){if(l)return Object.getPrototypeOf(u)!==Object.getPrototypeOf(h)?c.mismatched:o.getInternalProto(u);const d=o.getInternalProto(u);return d!==o.getInternalProto(h)?c.mismatched:d},c.valueOf=function(u){const h=u.valueOf;if(h===void 0)return u;try{return h.call(u)}catch(l){return l}},c.hasOwnEnumerableProperty=function(u,h){return Object.prototype.propertyIsEnumerable.call(u,h)},c.isSetSimpleEqual=function(u,h){for(const l of Set.prototype.values.call(u))if(!Set.prototype.has.call(h,l))return!1;return!0},c.isDeepEqualObj=function(u,h,l,d,f){const{isDeepEqual:p,valueOf:m,hasOwnEnumerableProperty:b}=c,{keys:g,getOwnPropertySymbols:y}=Object;if(u===o.array){if(!d.part){if(h.length!==l.length)return!1;for(let E=0;E<h.length;++E)if(!p(h[E],l[E],d,f))return!1;return!0}for(const E of h)for(const x of l)if(p(E,x,d,f))return!0}else if(u===o.set){if(h.size!==l.size)return!1;if(!c.isSetSimpleEqual(h,l)){const E=new Set(Set.prototype.values.call(l));for(const x of Set.prototype.values.call(h)){if(E.delete(x))continue;let S=!1;for(const T of E)if(p(x,T,d,f)){E.delete(T),S=!0;break}if(!S)return!1}}}else if(u===o.map){if(h.size!==l.size)return!1;for(const[E,x]of Map.prototype.entries.call(h))if(x===void 0&&!Map.prototype.has.call(l,E)||!p(x,Map.prototype.get.call(l,E),d,f))return!1}else if(u===o.error&&(h.name!==l.name||h.message!==l.message))return!1;const v=m(h),k=m(l);if((h!==v||l!==k)&&!p(v,k,d,f))return!1;const C=g(h);if(!d.part&&C.length!==g(l).length&&!d.skip)return!1;let _=0;for(const E of C)if(d.skip&&d.skip.includes(E))l[E]===void 0&&++_;else if(!b(l,E)||!p(h[E],l[E],d,f))return!1;if(!d.part&&C.length-_!==g(l).length)return!1;if(d.symbols!==!1){const E=y(h),x=new Set(y(l));for(const S of E){if(!d.skip||!d.skip.includes(S)){if(b(h,S)){if(!b(l,S)||!p(h[S],l[S],d,f))return!1}else if(b(l,S))return!1}x.delete(S)}for(const S of x)if(b(l,S))return!1}return!0},c.SeenEntry=class{constructor(u,h){this.obj=u,this.ref=h}isSame(u,h){return this.obj===u&&this.ref===h}}},7916:(r,n,a)=>{const o=a(8761);r.exports=class extends Error{constructor(c){super(c.filter(u=>u!=="").map(u=>typeof u=="string"?u:u instanceof Error?u.message:o(u)).join(" ")||"Unknown error"),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,n.assert)}}},5277:r=>{const n={};r.exports=function(a){if(!a)return"";let o="";for(let c=0;c<a.length;++c){const u=a.charCodeAt(c);n.isSafe(u)?o+=a[c]:o+=n.escapeHtmlChar(u)}return o},n.escapeHtmlChar=function(a){return n.namedHtml.get(a)||(a>=256?"&#"+a+";":`&#x${a.toString(16).padStart(2,"0")};`)},n.isSafe=function(a){return n.safeCharCodes.has(a)},n.namedHtml=new Map([[38,"&amp;"],[60,"&lt;"],[62,"&gt;"],[34,"&quot;"],[160,"&nbsp;"],[162,"&cent;"],[163,"&pound;"],[164,"&curren;"],[169,"&copy;"],[174,"&reg;"]]),n.safeCharCodes=function(){const a=new Set;for(let o=32;o<123;++o)(o>=97||o>=65&&o<=90||o>=48&&o<=57||o===32||o===46||o===44||o===45||o===58||o===95)&&a.add(o);return a}()},6064:r=>{r.exports=function(n){return n.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g,"\\$&")}},738:r=>{r.exports=function(){}},1687:(r,n,a)=>{const o=a(375),c=a(8571),u=a(7043),h={};r.exports=h.merge=function(l,d,f){if(o(l&&typeof l=="object","Invalid target value: must be an object"),o(d==null||typeof d=="object","Invalid source value: must be null, undefined, or an object"),!d)return l;if(f=Object.assign({nullOverride:!0,mergeArrays:!0},f),Array.isArray(d)){o(Array.isArray(l),"Cannot merge array onto an object"),f.mergeArrays||(l.length=0);for(let m=0;m<d.length;++m)l.push(c(d[m],{symbols:f.symbols}));return l}const p=u.keys(d,f);for(let m=0;m<p.length;++m){const b=p[m];if(b==="__proto__"||!Object.prototype.propertyIsEnumerable.call(d,b))continue;const g=d[b];if(g&&typeof g=="object"){if(l[b]===g)continue;!l[b]||typeof l[b]!="object"||Array.isArray(l[b])!==Array.isArray(g)||g instanceof Date||g instanceof RegExp?l[b]=c(g,{symbols:f.symbols}):h.merge(l[b],g,f)}else(g!=null||f.nullOverride)&&(l[b]=g)}return l}},9621:(r,n,a)=>{const o=a(375),c={};r.exports=function(u,h,l){if(h===!1||h==null)return u;typeof(l=l||{})=="string"&&(l={separator:l});const d=Array.isArray(h);o(!d||!l.separator,"Separator option is not valid for array-based chain");const f=d?h:h.split(l.separator||".");let p=u;for(let m=0;m<f.length;++m){let b=f[m];const g=l.iterables&&c.iterables(p);if(Array.isArray(p)||g==="set"){const y=Number(b);Number.isInteger(y)&&(b=y<0?p.length+y:y)}if(!p||typeof p=="function"&&l.functions===!1||!g&&p[b]===void 0){o(!l.strict||m+1===f.length,"Missing segment",b,"in reach path ",h),o(typeof p=="object"||l.functions===!0||typeof p!="function","Invalid segment",b,"in reach path ",h),p=l.default;break}p=g?g==="set"?[...p][b]:p.get(b):p[b]}return p},c.iterables=function(u){return u instanceof Set?"set":u instanceof Map?"map":void 0}},8761:r=>{r.exports=function(...n){try{return JSON.stringify(...n)}catch(a){return"[Cannot display object: "+a.message+"]"}}},4277:(r,n)=>{const a={};n=r.exports={array:Array.prototype,buffer:!1,date:Date.prototype,error:Error.prototype,generic:Object.prototype,map:Map.prototype,promise:Promise.prototype,regex:RegExp.prototype,set:Set.prototype,weakMap:WeakMap.prototype,weakSet:WeakSet.prototype},a.typeMap=new Map([["[object Error]",n.error],["[object Map]",n.map],["[object Promise]",n.promise],["[object Set]",n.set],["[object WeakMap]",n.weakMap],["[object WeakSet]",n.weakSet]]),n.getInternalProto=function(o){if(Array.isArray(o))return n.array;if(o instanceof Date)return n.date;if(o instanceof RegExp)return n.regex;if(o instanceof Error)return n.error;const c=Object.prototype.toString.call(o);return a.typeMap.get(c)||n.generic}},7043:(r,n)=>{n.keys=function(a,o={}){return o.symbols!==!1?Reflect.ownKeys(a):Object.getOwnPropertyNames(a)}},3652:(r,n,a)=>{const o=a(375),c={};n.Sorter=class{constructor(){this._items=[],this.nodes=[]}add(u,h){const l=[].concat((h=h||{}).before||[]),d=[].concat(h.after||[]),f=h.group||"?",p=h.sort||0;o(!l.includes(f),`Item cannot come before itself: ${f}`),o(!l.includes("?"),"Item cannot come before unassociated items"),o(!d.includes(f),`Item cannot come after itself: ${f}`),o(!d.includes("?"),"Item cannot come after unassociated items"),Array.isArray(u)||(u=[u]);for(const m of u){const b={seq:this._items.length,sort:p,before:l,after:d,group:f,node:m};this._items.push(b)}if(!h.manual){const m=this._sort();o(m,"item",f!=="?"?`added into group ${f}`:"","created a dependencies error")}return this.nodes}merge(u){Array.isArray(u)||(u=[u]);for(const l of u)if(l)for(const d of l._items)this._items.push(Object.assign({},d));this._items.sort(c.mergeSort);for(let l=0;l<this._items.length;++l)this._items[l].seq=l;const h=this._sort();return o(h,"merge created a dependencies error"),this.nodes}sort(){const u=this._sort();return o(u,"sort created a dependencies error"),this.nodes}_sort(){const u={},h=Object.create(null),l=Object.create(null);for(const b of this._items){const g=b.seq,y=b.group;l[y]=l[y]||[],l[y].push(g),u[g]=b.before;for(const v of b.after)h[v]=h[v]||[],h[v].push(g)}for(const b in u){const g=[];for(const y in u[b]){const v=u[b][y];l[v]=l[v]||[],g.push(...l[v])}u[b]=g}for(const b in h)if(l[b])for(const g of l[b])u[g].push(...h[b]);const d={};for(const b in u){const g=u[b];for(const y of g)d[y]=d[y]||[],d[y].push(b)}const f={},p=[];for(let b=0;b<this._items.length;++b){let g=b;if(d[b]){g=null;for(let y=0;y<this._items.length;++y){if(f[y]===!0)continue;d[y]||(d[y]=[]);const v=d[y].length;let k=0;for(let C=0;C<v;++C)f[d[y][C]]&&++k;if(k===v){g=y;break}}}g!==null&&(f[g]=!0,p.push(g))}if(p.length!==this._items.length)return!1;const m={};for(const b of this._items)m[b.seq]=b;this._items=[],this.nodes=[];for(const b of p){const g=m[b];this.nodes.push(g.node),this._items.push(g)}return!0}},c.mergeSort=(u,h)=>u.sort===h.sort?0:u.sort<h.sort?-1:1},5380:(r,n,a)=>{const o=a(443),c=a(2178),u={minDomainSegments:2,nonAsciiRx:/[^\x00-\x7f]/,domainControlRx:/[\x00-\x20@\:\/\\#!\$&\'\(\)\*\+,;=\?]/,tldSegmentRx:/^[a-zA-Z](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,domainSegmentRx:/^[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/,URL:o.URL||URL};n.analyze=function(h,l={}){if(!h)return c.code("DOMAIN_NON_EMPTY_STRING");if(typeof h!="string")throw new Error("Invalid input: domain must be a string");if(h.length>256)return c.code("DOMAIN_TOO_LONG");if(u.nonAsciiRx.test(h)){if(l.allowUnicode===!1)return c.code("DOMAIN_INVALID_UNICODE_CHARS");h=h.normalize("NFC")}if(u.domainControlRx.test(h))return c.code("DOMAIN_INVALID_CHARS");h=u.punycode(h),l.allowFullyQualified&&h[h.length-1]==="."&&(h=h.slice(0,-1));const d=l.minDomainSegments||u.minDomainSegments,f=h.split(".");if(f.length<d)return c.code("DOMAIN_SEGMENTS_COUNT");if(l.maxDomainSegments&&f.length>l.maxDomainSegments)return c.code("DOMAIN_SEGMENTS_COUNT_MAX");const p=l.tlds;if(p){const m=f[f.length-1].toLowerCase();if(p.deny&&p.deny.has(m)||p.allow&&!p.allow.has(m))return c.code("DOMAIN_FORBIDDEN_TLDS")}for(let m=0;m<f.length;++m){const b=f[m];if(!b.length)return c.code("DOMAIN_EMPTY_SEGMENT");if(b.length>63)return c.code("DOMAIN_LONG_SEGMENT");if(m<f.length-1){if(!u.domainSegmentRx.test(b))return c.code("DOMAIN_INVALID_CHARS")}else if(!u.tldSegmentRx.test(b))return c.code("DOMAIN_INVALID_TLDS_CHARS")}return null},n.isValid=function(h,l){return!n.analyze(h,l)},u.punycode=function(h){h.includes("%")&&(h=h.replace(/%/g,"%25"));try{return new u.URL(`http://${h}`).host}catch{return h}}},1745:(r,n,a)=>{const o=a(9848),c=a(5380),u=a(2178),h={nonAsciiRx:/[^\x00-\x7f]/,encoder:new(o.TextEncoder||TextEncoder)};n.analyze=function(l,d){return h.email(l,d)},n.isValid=function(l,d){return!h.email(l,d)},h.email=function(l,d={}){if(typeof l!="string")throw new Error("Invalid input: email must be a string");if(!l)return u.code("EMPTY_STRING");const f=!h.nonAsciiRx.test(l);if(!f){if(d.allowUnicode===!1)return u.code("FORBIDDEN_UNICODE");l=l.normalize("NFC")}const p=l.split("@");if(p.length!==2)return p.length>2?u.code("MULTIPLE_AT_CHAR"):u.code("MISSING_AT_CHAR");const[m,b]=p;if(!m)return u.code("EMPTY_LOCAL");if(!d.ignoreLength){if(l.length>254)return u.code("ADDRESS_TOO_LONG");if(h.encoder.encode(m).length>64)return u.code("LOCAL_TOO_LONG")}return h.local(m,f)||c.analyze(b,d)},h.local=function(l,d){const f=l.split(".");for(const p of f){if(!p.length)return u.code("EMPTY_LOCAL_SEGMENT");if(d){if(!h.atextRx.test(p))return u.code("INVALID_LOCAL_CHARS")}else for(const m of p){if(h.atextRx.test(m))continue;const b=h.binary(m);if(!h.atomRx.test(b))return u.code("INVALID_LOCAL_CHARS")}}},h.binary=function(l){return Array.from(h.encoder.encode(l)).map(d=>String.fromCharCode(d)).join("")},h.atextRx=/^[\w!#\$%&'\*\+\-/=\?\^`\{\|\}~]+$/,h.atomRx=new RegExp(["(?:[\\xc2-\\xdf][\\x80-\\xbf])","(?:\\xe0[\\xa0-\\xbf][\\x80-\\xbf])|(?:[\\xe1-\\xec][\\x80-\\xbf]{2})|(?:\\xed[\\x80-\\x9f][\\x80-\\xbf])|(?:[\\xee-\\xef][\\x80-\\xbf]{2})","(?:\\xf0[\\x90-\\xbf][\\x80-\\xbf]{2})|(?:[\\xf1-\\xf3][\\x80-\\xbf]{3})|(?:\\xf4[\\x80-\\x8f][\\x80-\\xbf]{2})"].join("|"))},2178:(r,n)=>{n.codes={EMPTY_STRING:"Address must be a non-empty string",FORBIDDEN_UNICODE:"Address contains forbidden Unicode characters",MULTIPLE_AT_CHAR:"Address cannot contain more than one @ character",MISSING_AT_CHAR:"Address must contain one @ character",EMPTY_LOCAL:"Address local part cannot be empty",ADDRESS_TOO_LONG:"Address too long",LOCAL_TOO_LONG:"Address local part too long",EMPTY_LOCAL_SEGMENT:"Address local part contains empty dot-separated segment",INVALID_LOCAL_CHARS:"Address local part contains invalid character",DOMAIN_NON_EMPTY_STRING:"Domain must be a non-empty string",DOMAIN_TOO_LONG:"Domain too long",DOMAIN_INVALID_UNICODE_CHARS:"Domain contains forbidden Unicode characters",DOMAIN_INVALID_CHARS:"Domain contains invalid character",DOMAIN_INVALID_TLDS_CHARS:"Domain contains invalid tld character",DOMAIN_SEGMENTS_COUNT:"Domain lacks the minimum required number of segments",DOMAIN_SEGMENTS_COUNT_MAX:"Domain contains too many segments",DOMAIN_FORBIDDEN_TLDS:"Domain uses forbidden TLD",DOMAIN_EMPTY_SEGMENT:"Domain contains empty dot-separated segment",DOMAIN_LONG_SEGMENT:"Domain contains dot-separated segment that is too long"},n.code=function(a){return{code:a,error:n.codes[a]}}},9959:(r,n,a)=>{const o=a(375),c=a(5752);n.regex=function(u={}){o(u.cidr===void 0||typeof u.cidr=="string","options.cidr must be a string");const h=u.cidr?u.cidr.toLowerCase():"optional";o(["required","optional","forbidden"].includes(h),"options.cidr must be one of required, optional, forbidden"),o(u.version===void 0||typeof u.version=="string"||Array.isArray(u.version),"options.version must be a string or an array of string");let l=u.version||["ipv4","ipv6","ipvfuture"];Array.isArray(l)||(l=[l]),o(l.length>=1,"options.version must have at least 1 version specified");for(let p=0;p<l.length;++p)o(typeof l[p]=="string","options.version must only contain strings"),l[p]=l[p].toLowerCase(),o(["ipv4","ipv6","ipvfuture"].includes(l[p]),"options.version contains unknown version "+l[p]+" - must be one of ipv4, ipv6, ipvfuture");l=Array.from(new Set(l));const d=`(?:${l.map(p=>{if(h==="forbidden")return c.ip[p];const m=`\\/${p==="ipv4"?c.ip.v4Cidr:c.ip.v6Cidr}`;return h==="required"?`${c.ip[p]}${m}`:`${c.ip[p]}(?:${m})?`}).join("|")})`,f=new RegExp(`^${d}$`);return{cidr:h,versions:l,regex:f,raw:d}}},5752:(r,n,a)=>{const o=a(375),c=a(6064),u={generate:function(){const h={},l="\\dA-Fa-f",d="["+l+"]",f="\\w-\\.~",p="!\\$&'\\(\\)\\*\\+,;=",m="%"+l,b=f+m+p+":@",g="["+b+"]",y="(?:0{0,2}\\d|0?[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";h.ipv4address="(?:"+y+"\\.){3}"+y;const v=d+"{1,4}",k="(?:"+v+":"+v+"|"+h.ipv4address+")",C="(?:"+v+":){6}"+k,_="::(?:"+v+":){5}"+k,E="(?:"+v+")?::(?:"+v+":){4}"+k,x="(?:(?:"+v+":){0,1}"+v+")?::(?:"+v+":){3}"+k,S="(?:(?:"+v+":){0,2}"+v+")?::(?:"+v+":){2}"+k,T="(?:(?:"+v+":){0,3}"+v+")?::"+v+":"+k,A="(?:(?:"+v+":){0,4}"+v+")?::"+k,R="(?:(?:"+v+":){0,5}"+v+")?::"+v,M="(?:(?:"+v+":){0,6}"+v+")?::";h.ipv4Cidr="(?:\\d|[1-2]\\d|3[0-2])",h.ipv6Cidr="(?:0{0,2}\\d|0?[1-9]\\d|1[01]\\d|12[0-8])",h.ipv6address="(?:"+C+"|"+_+"|"+E+"|"+x+"|"+S+"|"+T+"|"+A+"|"+R+"|"+M+")",h.ipvFuture="v"+d+"+\\.["+f+p+":]+",h.scheme="[a-zA-Z][a-zA-Z\\d+-\\.]*",h.schemeRegex=new RegExp(h.scheme);const j="["+f+m+p+":]*",W="["+f+m+p+"]{1,255}",se="(?:\\[(?:"+h.ipv6address+"|"+h.ipvFuture+")\\]|"+h.ipv4address+"|"+W+")",Y="(?:"+j+"@)?"+se+"(?::\\d*)?",ae="(?:"+j+"@)?("+se+")(?::\\d*)?",he=g+"*",Q=g+"+",we="(?:\\/"+he+")*",Le="\\/(?:"+Q+we+")?",Ze=Q+we,st="["+f+m+p+"@]+"+we,ht="(?:\\/\\/\\/"+he+we+")";return h.hierPart="(?:(?:\\/\\/"+Y+we+")|"+Le+"|"+Ze+"|"+ht+")",h.hierPartCapture="(?:(?:\\/\\/"+ae+we+")|"+Le+"|"+Ze+")",h.relativeRef="(?:(?:\\/\\/"+Y+we+")|"+Le+"|"+st+"|)",h.relativeRefCapture="(?:(?:\\/\\/"+ae+we+")|"+Le+"|"+st+"|)",h.query="["+b+"\\/\\?]*(?=#|$)",h.queryWithSquareBrackets="["+b+"\\[\\]\\/\\?]*(?=#|$)",h.fragment="["+b+"\\/\\?]*",h}};u.rfc3986=u.generate(),n.ip={v4Cidr:u.rfc3986.ipv4Cidr,v6Cidr:u.rfc3986.ipv6Cidr,ipv4:u.rfc3986.ipv4address,ipv6:u.rfc3986.ipv6address,ipvfuture:u.rfc3986.ipvFuture},u.createRegex=function(h){const l=u.rfc3986,d="(?:\\?"+(h.allowQuerySquareBrackets?l.queryWithSquareBrackets:l.query)+")?(?:#"+l.fragment+")?",f=h.domain?l.relativeRefCapture:l.relativeRef;if(h.relativeOnly)return u.wrap(f+d);let p="";if(h.scheme){o(h.scheme instanceof RegExp||typeof h.scheme=="string"||Array.isArray(h.scheme),"scheme must be a RegExp, String, or Array");const g=[].concat(h.scheme);o(g.length>=1,"scheme must have at least 1 scheme specified");const y=[];for(let v=0;v<g.length;++v){const k=g[v];o(k instanceof RegExp||typeof k=="string","scheme at position "+v+" must be a RegExp or String"),k instanceof RegExp?y.push(k.source.toString()):(o(l.schemeRegex.test(k),"scheme at position "+v+" must be a valid scheme"),y.push(c(k)))}p=y.join("|")}const m="(?:"+(p?"(?:"+p+")":l.scheme)+":"+(h.domain?l.hierPartCapture:l.hierPart)+")",b=h.allowRelative?"(?:"+m+"|"+f+")":m;return u.wrap(b+d,p)},u.wrap=function(h,l){return{raw:h=`(?=.)(?!https?:/(?:$|[^/]))(?!https?:///)(?!https?:[^/])${h}`,regex:new RegExp(`^${h}$`),scheme:l}},u.uriRegex=u.createRegex({}),n.regex=function(h={}){return h.scheme||h.allowRelative||h.relativeOnly||h.allowQuerySquareBrackets||h.domain?u.createRegex(h):u.uriRegex}},1447:(r,n)=>{const a={operators:["!","^","*","/","%","+","-","<","<=",">",">=","==","!=","&&","||","??"],operatorCharacters:["!","^","*","/","%","+","-","<","=",">","&","|","?"],operatorsOrder:[["^"],["*","/","%"],["+","-"],["<","<=",">",">="],["==","!="],["&&"],["||","??"]],operatorsPrefix:["!","n"],literals:{'"':'"',"`":"`","'":"'","[":"]"},numberRx:/^(?:[0-9]*(\.[0-9]*)?){1}$/,tokenRx:/^[\w\$\#\.\@\:\{\}]+$/,symbol:Symbol("formula"),settings:Symbol("settings")};n.Parser=class{constructor(o,c={}){if(!c[a.settings]&&c.constants)for(const u in c.constants){const h=c.constants[u];if(h!==null&&!["boolean","number","string"].includes(typeof h))throw new Error(`Formula constant ${u} contains invalid ${typeof h} value type`)}this.settings=c[a.settings]?c:Object.assign({[a.settings]:!0,constants:{},functions:{}},c),this.single=null,this._parts=null,this._parse(o)}_parse(o){let c=[],u="",h=0,l=!1;const d=p=>{if(h)throw new Error("Formula missing closing parenthesis");const m=c.length?c[c.length-1]:null;if(l||u||p){if(m&&m.type==="reference"&&p===")")return m.type="function",m.value=this._subFormula(u,m.value),void(u="");if(p===")"){const b=new n.Parser(u,this.settings);c.push({type:"segment",value:b})}else if(l){if(l==="]")return c.push({type:"reference",value:u}),void(u="");c.push({type:"literal",value:u})}else if(a.operatorCharacters.includes(u))m&&m.type==="operator"&&a.operators.includes(m.value+u)?m.value+=u:c.push({type:"operator",value:u});else if(u.match(a.numberRx))c.push({type:"constant",value:parseFloat(u)});else if(this.settings.constants[u]!==void 0)c.push({type:"constant",value:this.settings.constants[u]});else{if(!u.match(a.tokenRx))throw new Error(`Formula contains invalid token: ${u}`);c.push({type:"reference",value:u})}u=""}};for(const p of o)l?p===l?(d(),l=!1):u+=p:h?p==="("?(u+=p,++h):p===")"?(--h,h?u+=p:d(p)):u+=p:p in a.literals?l=a.literals[p]:p==="("?(d(),++h):a.operatorCharacters.includes(p)?(d(),u=p,d()):p!==" "?u+=p:d();d(),c=c.map((p,m)=>p.type!=="operator"||p.value!=="-"||m&&c[m-1].type!=="operator"?p:{type:"operator",value:"n"});let f=!1;for(const p of c){if(p.type==="operator"){if(a.operatorsPrefix.includes(p.value))continue;if(!f)throw new Error("Formula contains an operator in invalid position");if(!a.operators.includes(p.value))throw new Error(`Formula contains an unknown operator ${p.value}`)}else if(f)throw new Error("Formula missing expected operator");f=!f}if(!f)throw new Error("Formula contains invalid trailing operator");c.length===1&&["reference","literal","constant"].includes(c[0].type)&&(this.single={type:c[0].type==="reference"?"reference":"value",value:c[0].value}),this._parts=c.map(p=>{if(p.type==="operator")return a.operatorsPrefix.includes(p.value)?p:p.value;if(p.type!=="reference")return p.value;if(this.settings.tokenRx&&!this.settings.tokenRx.test(p.value))throw new Error(`Formula contains invalid reference ${p.value}`);return this.settings.reference?this.settings.reference(p.value):a.reference(p.value)})}_subFormula(o,c){const u=this.settings.functions[c];if(typeof u!="function")throw new Error(`Formula contains unknown function ${c}`);let h=[];if(o){let l="",d=0,f=!1;const p=()=>{if(!l)throw new Error(`Formula contains function ${c} with invalid arguments ${o}`);h.push(l),l=""};for(let m=0;m<o.length;++m){const b=o[m];f?(l+=b,b===f&&(f=!1)):b in a.literals&&!d?(l+=b,f=a.literals[b]):b!==","||d?(l+=b,b==="("?++d:b===")"&&--d):p()}p()}return h=h.map(l=>new n.Parser(l,this.settings)),function(l){const d=[];for(const f of h)d.push(f.evaluate(l));return u.call(l,...d)}}evaluate(o){const c=this._parts.slice();for(let u=c.length-2;u>=0;--u){const h=c[u];if(h&&h.type==="operator"){const l=c[u+1];c.splice(u+1,1);const d=a.evaluate(l,o);c[u]=a.single(h.value,d)}}return a.operatorsOrder.forEach(u=>{for(let h=1;h<c.length-1;)if(u.includes(c[h])){const l=c[h],d=a.evaluate(c[h-1],o),f=a.evaluate(c[h+1],o);c.splice(h,2);const p=a.calculate(l,d,f);c[h-1]=p===0?0:p}else h+=2}),a.evaluate(c[0],o)}},n.Parser.prototype[a.symbol]=!0,a.reference=function(o){return function(c){return c&&c[o]!==void 0?c[o]:null}},a.evaluate=function(o,c){return o===null?null:typeof o=="function"?o(c):o[a.symbol]?o.evaluate(c):o},a.single=function(o,c){if(o==="!")return!c;const u=-c;return u===0?0:u},a.calculate=function(o,c,u){if(o==="??")return a.exists(c)?c:u;if(typeof c=="string"||typeof u=="string"){if(o==="+")return(c=a.exists(c)?c:"")+(a.exists(u)?u:"")}else switch(o){case"^":return Math.pow(c,u);case"*":return c*u;case"/":return c/u;case"%":return c%u;case"+":return c+u;case"-":return c-u}switch(o){case"<":return c<u;case"<=":return c<=u;case">":return c>u;case">=":return c>=u;case"==":return c===u;case"!=":return c!==u;case"&&":return c&&u;case"||":return c||u}return null},a.exists=function(o){return o!=null}},9926:()=>{},5688:()=>{},9708:()=>{},1152:()=>{},443:()=>{},9848:()=>{},5934:r=>{r.exports=JSON.parse('{"version":"17.13.3"}')}},i={},function r(n){var a=i[n];if(a!==void 0)return a.exports;var o=i[n]={exports:{}};return t[n](o,o.exports,r),o.exports}(5107);var t,i})})(Qo);var rd=Qo.exports;const J=Li(rd),sd={utf16le:"utf-16le",ucs2:"utf-16le",utf16be:"utf-16be"};class tt{constructor(e){this.buffer=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.pos=0,this.length=this.buffer.length}readString(e,t="ascii"){t=sd[t]||t;let i=this.readBuffer(e);try{return new TextDecoder(t).decode(i)}catch{return i}}readBuffer(e){return this.buffer.slice(this.pos,this.pos+=e)}readUInt24BE(){return(this.readUInt16BE()<<8)+this.readUInt8()}readUInt24LE(){return this.readUInt16LE()+(this.readUInt8()<<16)}readInt24BE(){return(this.readInt16BE()<<8)+this.readUInt8()}readInt24LE(){return this.readUInt16LE()+(this.readInt8()<<16)}}tt.TYPES={UInt8:1,UInt16:2,UInt24:3,UInt32:4,Int8:1,Int16:2,Int24:3,Int32:4,Float:4,Double:8};for(let s of Object.getOwnPropertyNames(DataView.prototype))if(s.slice(0,3)==="get"){let e=s.slice(3).replace("Ui","UI");e==="Float32"?e="Float":e==="Float64"&&(e="Double");let t=tt.TYPES[e];tt.prototype["read"+e+(t===1?"":"BE")]=function(){const i=this.view[s](this.pos,!1);return this.pos+=t,i},t!==1&&(tt.prototype["read"+e+"LE"]=function(){const i=this.view[s](this.pos,!0);return this.pos+=t,i})}const nd=new TextEncoder,el=new Uint8Array(new Uint16Array([4660]).buffer)[0]==18;class Ts{constructor(e){this.buffer=e,this.view=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),this.pos=0}writeBuffer(e){this.buffer.set(e,this.pos),this.pos+=e.length}writeString(e,t="ascii"){let i;switch(t){case"utf16le":case"utf16-le":case"ucs2":i=tl(e,el);break;case"utf16be":case"utf16-be":i=tl(e,!el);break;case"utf8":i=nd.encode(e);break;case"ascii":i=ad(e);break;default:throw new Error(`Unsupported encoding: ${t}`)}this.writeBuffer(i)}writeUInt24BE(e){this.buffer[this.pos++]=e>>>16&255,this.buffer[this.pos++]=e>>>8&255,this.buffer[this.pos++]=e&255}writeUInt24LE(e){this.buffer[this.pos++]=e&255,this.buffer[this.pos++]=e>>>8&255,this.buffer[this.pos++]=e>>>16&255}writeInt24BE(e){e>=0?this.writeUInt24BE(e):this.writeUInt24BE(e+16777215+1)}writeInt24LE(e){e>=0?this.writeUInt24LE(e):this.writeUInt24LE(e+16777215+1)}fill(e,t){if(t<this.buffer.length)this.buffer.fill(e,this.pos,this.pos+t),this.pos+=t;else{const i=new Uint8Array(t);i.fill(e),this.writeBuffer(i)}}}function tl(s,e){let t=new Uint16Array(s.length);for(let i=0;i<s.length;i++){let r=s.charCodeAt(i);e&&(r=r>>8|(r&255)<<8),t[i]=r}return new Uint8Array(t.buffer)}function ad(s){let e=new Uint8Array(s.length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e}for(let s of Object.getOwnPropertyNames(DataView.prototype))if(s.slice(0,3)==="set"){let e=s.slice(3).replace("Ui","UI");e==="Float32"?e="Float":e==="Float64"&&(e="Double");let t=tt.TYPES[e];Ts.prototype["write"+e+(t===1?"":"BE")]=function(i){this.view[s](this.pos,i,!1),this.pos+=t},t!==1&&(Ts.prototype["write"+e+"LE"]=function(i){this.view[s](this.pos,i,!0),this.pos+=t})}class ii{fromBuffer(e){let t=new tt(e);return this.decode(t)}toBuffer(e){let t=this.size(e),i=new Uint8Array(t),r=new Ts(i);return this.encode(r,e),i}}class Re extends ii{constructor(e,t="BE"){super(),this.type=e,this.endian=t,this.fn=this.type,this.type[this.type.length-1]!=="8"&&(this.fn+=this.endian)}size(){return tt.TYPES[this.type]}decode(e){return e[`read${this.fn}`]()}encode(e,t){return e[`write${this.fn}`](t)}}const H=new Re("UInt8"),w=new Re("UInt16","BE");new Re("UInt16","LE");const gi=new Re("UInt24","BE");new Re("UInt24","LE");const O=new Re("UInt32","BE");new Re("UInt32","LE");const Xe=new Re("Int8"),z=new Re("Int16","BE");new Re("Int16","LE"),new Re("Int24","BE"),new Re("Int24","LE");const zi=new Re("Int32","BE");new Re("Int32","LE"),new Re("Float","BE"),new Re("Float","LE"),new Re("Double","BE"),new Re("Double","LE");class $i extends Re{constructor(e,t,i=e>>1){super(`Int${e}`,t),this._point=1<<i}decode(e){return super.decode(e)/this._point}encode(e,t){return super.encode(e,t*this._point|0)}}const od=new $i(16,"BE");new $i(16,"LE");const He=new $i(32,"BE");new $i(32,"LE");function Dt(s,e,t){let i;if(typeof s=="number"?i=s:typeof s=="function"?i=s.call(t,t):t&&typeof s=="string"?i=t[s]:e&&s instanceof Re&&(i=s.decode(e)),isNaN(i))throw new Error("Not a fixed size");return i}class Hn{constructor(e={}){this.enumerable=!0,this.configurable=!0;for(let t in e){const i=e[t];this[t]=i}}}class I extends ii{constructor(e,t,i="count"){super(),this.type=e,this.length=t,this.lengthType=i}decode(e,t){let i;const{pos:r}=e,n=[];let a=t;if(this.length!=null&&(i=Dt(this.length,e,t)),this.length instanceof Re&&(Object.defineProperties(n,{parent:{value:t},_startOffset:{value:r},_currentOffset:{value:0,writable:!0},_length:{value:i}}),a=n),i==null||this.lengthType==="bytes"){const o=i!=null?e.pos+i:t?._length?t._startOffset+t._length:e.length;for(;e.pos<o;)n.push(this.type.decode(e,a))}else for(let o=0,c=i;o<c;o++)n.push(this.type.decode(e,a));return n}size(e,t,i=!0){if(!e)return this.type.size(null,t)*Dt(this.length,null,t);let r=0;this.length instanceof Re&&(r+=this.length.size(),t={parent:t,pointerSize:0});for(let n of e)r+=this.type.size(n,t);return t&&i&&this.length instanceof Re&&(r+=t.pointerSize),r}encode(e,t,i){let r=i;this.length instanceof Re&&(r={pointers:[],startOffset:e.pos,parent:i},r.pointerOffset=e.pos+this.size(t,r,!1),this.length.encode(e,t.length));for(let n of t)this.type.encode(e,n,r);if(this.length instanceof Re){let n=0;for(;n<r.pointers.length;){const a=r.pointers[n++];a.type.encode(e,a.val,a.parent)}}}}class Be extends I{decode(e,t){const{pos:i}=e,r=Dt(this.length,e,t);this.length instanceof Re&&(t={parent:t,_startOffset:i,_currentOffset:0,_length:r});const n=new jn(this.type,r,e,t);return e.pos+=r*this.type.size(null,t),n}size(e,t){return e instanceof jn&&(e=e.toArray()),super.size(e,t)}encode(e,t,i){return t instanceof jn&&(t=t.toArray()),super.encode(e,t,i)}}class jn{constructor(e,t,i,r){this.type=e,this.length=t,this.stream=i,this.ctx=r,this.base=this.stream.pos,this.items=[]}get(e){if(!(e<0||e>=this.length)){if(this.items[e]==null){const{pos:t}=this.stream;this.stream.pos=this.base+this.type.size(null,this.ctx)*e,this.items[e]=this.type.decode(this.stream,this.ctx),this.stream.pos=t}return this.items[e]}}toArray(){const e=[];for(let t=0,i=this.length;t<i;t++)e.push(this.get(t));return e}}class Et extends ii{constructor(e,t=[]){super(),this.type=e,this.flags=t}decode(e){const t=this.type.decode(e),i={};for(let r=0;r<this.flags.length;r++){const n=this.flags[r];n!=null&&(i[n]=!!(t&1<<r))}return i}size(){return this.type.size()}encode(e,t){let i=0;for(let r=0;r<this.flags.length;r++){const n=this.flags[r];n!=null&&t[n]&&(i|=1<<r)}return this.type.encode(e,i)}}class Bt extends ii{constructor(e){super(),this.length=e}decode(e,t){const i=Dt(this.length,e,t);return e.readBuffer(i)}size(e,t){if(!e)return Dt(this.length,null,t);let i=e.length;return this.length instanceof Re&&(i+=this.length.size()),i}encode(e,t,i){return this.length instanceof Re&&this.length.encode(e,t.length),e.writeBuffer(t)}}class Es extends ii{constructor(e,t=!0){super(),this.type=e,this.condition=t}decode(e,t){let{condition:i}=this;if(typeof i=="function"&&(i=i.call(t,t)),i)return this.type.decode(e,t)}size(e,t){let{condition:i}=this;return typeof i=="function"&&(i=i.call(t,t)),i?this.type.size(e,t):0}encode(e,t,i){let{condition:r}=this;if(typeof r=="function"&&(r=r.call(i,i)),r)return this.type.encode(e,t,i)}}class $e extends ii{constructor(e,t=1){super(),this.type=e,this.count=t}decode(e,t){e.pos+=this.size(null,t)}size(e,t){const i=Dt(this.count,null,t);return this.type.size()*i}encode(e,t,i){return e.fill(0,this.size(t,i))}}class Me extends ii{constructor(e,t="ascii"){super(),this.length=e,this.encoding=t}decode(e,t){let i,r,{encoding:n}=this;typeof n=="function"&&(n=n.call(t,t)||"ascii");let a=Wn(n);if(this.length!=null)i=Dt(this.length,e,t);else{let c;for({buffer:c,length:i,pos:r}=e;r<i-a+1&&(c[r]!==0||a===2&&c[r+1]!==0);)r+=a;i=r-e.pos}const o=e.readString(i,n);return this.length==null&&e.pos<e.length&&(e.pos+=a),o}size(e,t){if(e==null)return Dt(this.length,null,t);let{encoding:i}=this;typeof i=="function"&&(i=i.call(t?.val,t?.val)||"ascii"),i==="utf16be"&&(i="utf16le");let r=il(e,i);return this.length instanceof Re&&(r+=this.length.size()),this.length==null&&(r+=Wn(i)),r}encode(e,t,i){let{encoding:r}=this;if(typeof r=="function"&&(r=r.call(i?.val,i?.val)||"ascii"),this.length instanceof Re&&this.length.encode(e,il(t,r)),e.writeString(t,r),this.length==null)return Wn(r)==2?e.writeUInt16LE(0):e.writeUInt8(0)}}function Wn(s){switch(s){case"ascii":case"utf8":return 1;case"utf16le":case"utf16-le":case"utf-16be":case"utf-16le":case"utf16be":case"utf16-be":case"ucs2":return 2;default:return 1}}function il(s,e){switch(e){case"ascii":return s.length;case"utf8":let t=0;for(let i=0;i<s.length;i++){let r=s.charCodeAt(i);if(r>=55296&&r<=56319&&i<s.length-1){let n=s.charCodeAt(++i);(n&64512)===56320?r=((r&1023)<<10)+(n&1023)+65536:i--}r&4294967168?r&4294965248?r&4294901760?r&4292870144||(t+=4):t+=3:t+=2:t++}return t;case"utf16le":case"utf16-le":case"utf16be":case"utf16-be":case"ucs2":return s.length*2;default:throw new Error("Unknown encoding "+e)}}class F extends ii{constructor(e={}){super(),this.fields=e}decode(e,t,i=0){const r=this._setup(e,t,i);return this._parseFields(e,r,this.fields),this.process!=null&&this.process.call(r,e),r}_setup(e,t,i){const r={};return Object.defineProperties(r,{parent:{value:t},_startOffset:{value:e.pos},_currentOffset:{value:0,writable:!0},_length:{value:i}}),r}_parseFields(e,t,i){for(let n in i){var r;const a=i[n];typeof a=="function"?r=a.call(t,t):r=a.decode(e,t),r!==void 0&&(r instanceof Hn?Object.defineProperty(t,n,r):t[n]=r),t._currentOffset=e.pos-t._startOffset}}size(e,t,i=!0){e==null&&(e={});const r={parent:t,val:e,pointerSize:0};this.preEncode!=null&&this.preEncode.call(e);let n=0;for(let a in this.fields){const o=this.fields[a];o.size!=null&&(n+=o.size(e[a],r))}return i&&(n+=r.pointerSize),n}encode(e,t,i){let r;this.preEncode!=null&&this.preEncode.call(t,e);const n={pointers:[],startOffset:e.pos,parent:i,val:t,pointerSize:0};n.pointerOffset=e.pos+this.size(t,n,!1);for(let o in this.fields)r=this.fields[o],r.encode!=null&&r.encode(e,t[o],n);let a=0;for(;a<n.pointers.length;){const o=n.pointers[a++];o.type.encode(e,o.val,o.parent)}}}const ld=(s,e)=>e.reduce((t,i)=>t&&t[i],s);class xe extends F{constructor(e,t={}){super(),this.type=e,this.versions=t,typeof e=="string"&&(this.versionPath=e.split("."))}decode(e,t,i=0){const r=this._setup(e,t,i);typeof this.type=="string"?r.version=ld(t,this.versionPath):r.version=this.type.decode(e),this.versions.header&&this._parseFields(e,r,this.versions.header);const n=this.versions[r.version];if(n==null)throw new Error(`Unknown version ${r.version}`);return n instanceof xe?n.decode(e,t):(this._parseFields(e,r,n),this.process!=null&&this.process.call(r,e),r)}size(e,t,i=!0){let r,n;if(!e)throw new Error("Not a fixed size");this.preEncode!=null&&this.preEncode.call(e);const a={parent:t,val:e,pointerSize:0};let o=0;if(typeof this.type!="string"&&(o+=this.type.size(e.version,a)),this.versions.header)for(r in this.versions.header)n=this.versions.header[r],n.size!=null&&(o+=n.size(e[r],a));const c=this.versions[e.version];if(c==null)throw new Error(`Unknown version ${e.version}`);for(r in c)n=c[r],n.size!=null&&(o+=n.size(e[r],a));return i&&(o+=a.pointerSize),o}encode(e,t,i){let r,n;this.preEncode!=null&&this.preEncode.call(t,e);const a={pointers:[],startOffset:e.pos,parent:i,val:t,pointerSize:0};if(a.pointerOffset=e.pos+this.size(t,a,!1),typeof this.type!="string"&&this.type.encode(e,t.version),this.versions.header)for(r in this.versions.header)n=this.versions.header[r],n.encode!=null&&n.encode(e,t[r],a);const o=this.versions[t.version];for(r in o)n=o[r],n.encode!=null&&n.encode(e,t[r],a);let c=0;for(;c<a.pointers.length;){const u=a.pointers[c++];u.type.encode(e,u.val,u.parent)}}}class P extends ii{constructor(e,t,i={}){if(super(),this.offsetType=e,this.type=t,this.options=i,this.type==="void"&&(this.type=null),this.options.type==null&&(this.options.type="local"),this.options.allowNull==null&&(this.options.allowNull=!0),this.options.nullValue==null&&(this.options.nullValue=0),this.options.lazy==null&&(this.options.lazy=!1),this.options.relativeTo){if(typeof this.options.relativeTo!="function")throw new Error("relativeTo option must be a function");this.relativeToGetter=i.relativeTo}}decode(e,t){const i=this.offsetType.decode(e,t);if(i===this.options.nullValue&&this.options.allowNull)return null;let r;switch(this.options.type){case"local":r=t._startOffset;break;case"immediate":r=e.pos-this.offsetType.size();break;case"parent":r=t.parent._startOffset;break;default:for(var n=t;n.parent;)n=n.parent;r=n._startOffset||0}this.options.relativeTo&&(r+=this.relativeToGetter(t));const a=i+r;if(this.type!=null){let o=null;const c=()=>{if(o!=null)return o;const{pos:u}=e;return e.pos=a,o=this.type.decode(e,t),e.pos=u,o};return this.options.lazy?new Hn({get:c}):c()}else return a}size(e,t){const i=t;switch(this.options.type){case"local":case"immediate":break;case"parent":t=t.parent;break;default:for(;t.parent;)t=t.parent}let{type:r}=this;if(r==null){if(!(e instanceof Gn))throw new Error("Must be a VoidPointer");({type:r}=e),e=e.value}if(e&&t){let n=r.size(e,i);t.pointerSize+=n}return this.offsetType.size()}encode(e,t,i){let r;const n=i;if(t==null){this.offsetType.encode(e,this.options.nullValue);return}switch(this.options.type){case"local":r=i.startOffset;break;case"immediate":r=e.pos+this.offsetType.size(t,n);break;case"parent":i=i.parent,r=i.startOffset;break;default:for(r=0;i.parent;)i=i.parent}this.options.relativeTo&&(r+=this.relativeToGetter(n.val)),this.offsetType.encode(e,i.pointerOffset-r);let{type:a}=this;if(a==null){if(!(t instanceof Gn))throw new Error("Must be a VoidPointer");({type:a}=t),t=t.value}return i.pointers.push({type:a,val:t,parent:n}),i.pointerOffset+=a.size(t,n)}}class Gn{constructor(e,t){this.type=e,this.value=t}}function ft(s,e,t){return e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function it(s,e,t,i){var r=arguments.length,n=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var o=s.length-1;o>=0;o--)(a=s[o])&&(n=(r<3?a(n):r>3?a(e,t,n):a(e,t))||n);return r>3&&n&&Object.defineProperty(e,t,n),n}typeof SuppressedError=="function"&&SuppressedError;var cd=function s(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var i,r,n;if(Array.isArray(e)){if(i=e.length,i!=t.length)return!1;for(r=i;r--!==0;)if(!s(e[r],t[r]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(n=Object.keys(e),i=n.length,i!==Object.keys(t).length)return!1;for(r=i;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,n[r]))return!1;for(r=i;r--!==0;){var a=n[r];if(!s(e[a],t[a]))return!1}return!0}return e!==e&&t!==t};const rl=Li(cd);var Mr={};Mr.byteLength=dd,Mr.toByteArray=pd,Mr.fromByteArray=yd;for(var Lt=[],kt=[],ud=typeof Uint8Array<"u"?Uint8Array:Array,qn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",or=0,hd=qn.length;or<hd;++or)Lt[or]=qn[or],kt[qn.charCodeAt(or)]=or;kt[45]=62,kt[95]=63;function sl(s){var e=s.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=s.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function dd(s){var e=sl(s),t=e[0],i=e[1];return(t+i)*3/4-i}function fd(s,e,t){return(e+t)*3/4-t}function pd(s){var e,t=sl(s),i=t[0],r=t[1],n=new ud(fd(s,i,r)),a=0,o=r>0?i-4:i,c;for(c=0;c<o;c+=4)e=kt[s.charCodeAt(c)]<<18|kt[s.charCodeAt(c+1)]<<12|kt[s.charCodeAt(c+2)]<<6|kt[s.charCodeAt(c+3)],n[a++]=e>>16&255,n[a++]=e>>8&255,n[a++]=e&255;return r===2&&(e=kt[s.charCodeAt(c)]<<2|kt[s.charCodeAt(c+1)]>>4,n[a++]=e&255),r===1&&(e=kt[s.charCodeAt(c)]<<10|kt[s.charCodeAt(c+1)]<<4|kt[s.charCodeAt(c+2)]>>2,n[a++]=e>>8&255,n[a++]=e&255),n}function md(s){return Lt[s>>18&63]+Lt[s>>12&63]+Lt[s>>6&63]+Lt[s&63]}function gd(s,e,t){for(var i,r=[],n=e;n<t;n+=3)i=(s[n]<<16&16711680)+(s[n+1]<<8&65280)+(s[n+2]&255),r.push(md(i));return r.join("")}function yd(s){for(var e,t=s.length,i=t%3,r=[],n=16383,a=0,o=t-i;a<o;a+=n)r.push(gd(s,a,a+n>o?o:a+n));return i===1?(e=s[t-1],r.push(Lt[e>>2]+Lt[e<<4&63]+"==")):i===2&&(e=(s[t-2]<<8)+s[t-1],r.push(Lt[e>>10]+Lt[e>>4&63]+Lt[e<<2&63]+"=")),r.join("")}var Xn=0,nl=-3;function Dr(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function bd(s,e){this.source=s,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new Dr,this.dtree=new Dr}var al=new Dr,ol=new Dr,Zn=new Uint8Array(30),Kn=new Uint16Array(30),ll=new Uint8Array(30),cl=new Uint16Array(30),vd=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ul=new Dr,zt=new Uint8Array(320);function hl(s,e,t,i){var r,n;for(r=0;r<t;++r)s[r]=0;for(r=0;r<30-t;++r)s[r+t]=r/t|0;for(n=i,r=0;r<30;++r)e[r]=n,n+=1<<s[r]}function wd(s,e){var t;for(t=0;t<7;++t)s.table[t]=0;for(s.table[7]=24,s.table[8]=152,s.table[9]=112,t=0;t<24;++t)s.trans[t]=256+t;for(t=0;t<144;++t)s.trans[24+t]=t;for(t=0;t<8;++t)s.trans[168+t]=280+t;for(t=0;t<112;++t)s.trans[176+t]=144+t;for(t=0;t<5;++t)e.table[t]=0;for(e.table[5]=32,t=0;t<32;++t)e.trans[t]=t}var dl=new Uint16Array(16);function Yn(s,e,t,i){var r,n;for(r=0;r<16;++r)s.table[r]=0;for(r=0;r<i;++r)s.table[e[t+r]]++;for(s.table[0]=0,n=0,r=0;r<16;++r)dl[r]=n,n+=s.table[r];for(r=0;r<i;++r)e[t+r]&&(s.trans[dl[e[t+r]]++]=r)}function xd(s){s.bitcount--||(s.tag=s.source[s.sourceIndex++],s.bitcount=7);var e=s.tag&1;return s.tag>>>=1,e}function $t(s,e,t){if(!e)return t;for(;s.bitcount<24;)s.tag|=s.source[s.sourceIndex++]<<s.bitcount,s.bitcount+=8;var i=s.tag&65535>>>16-e;return s.tag>>>=e,s.bitcount-=e,i+t}function Jn(s,e){for(;s.bitcount<24;)s.tag|=s.source[s.sourceIndex++]<<s.bitcount,s.bitcount+=8;var t=0,i=0,r=0,n=s.tag;do i=2*i+(n&1),n>>>=1,++r,t+=e.table[r],i-=e.table[r];while(i>=0);return s.tag=n,s.bitcount-=r,e.trans[t+i]}function Cd(s,e,t){var i,r,n,a,o,c;for(i=$t(s,5,257),r=$t(s,5,1),n=$t(s,4,4),a=0;a<19;++a)zt[a]=0;for(a=0;a<n;++a){var u=$t(s,3,0);zt[vd[a]]=u}for(Yn(ul,zt,0,19),o=0;o<i+r;){var h=Jn(s,ul);switch(h){case 16:var l=zt[o-1];for(c=$t(s,2,3);c;--c)zt[o++]=l;break;case 17:for(c=$t(s,3,3);c;--c)zt[o++]=0;break;case 18:for(c=$t(s,7,11);c;--c)zt[o++]=0;break;default:zt[o++]=h;break}}Yn(e,zt,0,i),Yn(t,zt,i,r)}function fl(s,e,t){for(;;){var i=Jn(s,e);if(i===256)return Xn;if(i<256)s.dest[s.destLen++]=i;else{var r,n,a,o;for(i-=257,r=$t(s,Zn[i],Kn[i]),n=Jn(s,t),a=s.destLen-$t(s,ll[n],cl[n]),o=a;o<a+r;++o)s.dest[s.destLen++]=s.dest[o]}}}function kd(s){for(var e,t,i;s.bitcount>8;)s.sourceIndex--,s.bitcount-=8;if(e=s.source[s.sourceIndex+1],e=256*e+s.source[s.sourceIndex],t=s.source[s.sourceIndex+3],t=256*t+s.source[s.sourceIndex+2],e!==(~t&65535))return nl;for(s.sourceIndex+=4,i=e;i;--i)s.dest[s.destLen++]=s.source[s.sourceIndex++];return s.bitcount=0,Xn}function Sd(s,e){var t=new bd(s,e),i,r,n;do{switch(i=xd(t),r=$t(t,2,0),r){case 0:n=kd(t);break;case 1:n=fl(t,al,ol);break;case 2:Cd(t,t.ltree,t.dtree),n=fl(t,t.ltree,t.dtree);break;default:n=nl}if(n!==Xn)throw new Error("Data error")}while(!i);return t.destLen<t.dest.length?typeof t.dest.slice=="function"?t.dest.slice(0,t.destLen):t.dest.subarray(0,t.destLen):t.dest}wd(al,ol),hl(Zn,Kn,4,3),hl(ll,cl,2,1),Zn[28]=0,Kn[28]=258;var pl=Sd;const Td=Li(pl),Ed=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,ml=(s,e,t)=>{let i=s[e];s[e]=s[t],s[t]=i},_d=s=>{const e=s.length;for(let t=0;t<e;t+=4)ml(s,t,t+3),ml(s,t+1,t+2)};var Ad={swap32LE:s=>{Ed&&_d(s)}};const gl=pl,{swap32LE:Id}=Ad,Qn=11,Ni=5,Pd=Qn-Ni,Od=65536>>Qn,Fd=(1<<Pd)-1,_s=2,ea=(1<<Ni)-1,yl=65536>>Ni,Rd=1024>>Ni,Md=yl+Rd+32,Dd=1<<_s;class Bd{constructor(e){const t=typeof e.readUInt32BE=="function"&&typeof e.slice=="function";if(t||e instanceof Uint8Array){let i;if(t)this.highStart=e.readUInt32LE(0),this.errorValue=e.readUInt32LE(4),i=e.readUInt32LE(8),e=e.slice(12);else{const r=new DataView(e.buffer);this.highStart=r.getUint32(0,!0),this.errorValue=r.getUint32(4,!0),i=r.getUint32(8,!0),e=e.subarray(12)}e=gl(e,new Uint8Array(i)),e=gl(e,new Uint8Array(i)),Id(e),this.data=new Uint32Array(e.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=e)}get(e){let t;return e<0||e>1114111?this.errorValue:e<55296||e>56319&&e<=65535?(t=(this.data[e>>Ni]<<_s)+(e&ea),this.data[t]):e<=65535?(t=(this.data[yl+(e-55296>>Ni)]<<_s)+(e&ea),this.data[t]):e<this.highStart?(t=this.data[Md-Od+(e>>Qn)],t=this.data[t+(e>>Ni&Fd)],t=(t<<_s)+(e&ea),this.data[t]):this.data[this.data.length-Dd]}}var Ld=Bd;const As=Li(Ld);function Ui(s){return s&&s.__esModule?s.default:s}var yi={};yi=JSON.parse('{"categories":["Cc","Zs","Po","Sc","Ps","Pe","Sm","Pd","Nd","Lu","Sk","Pc","Ll","So","Lo","Pi","Cf","No","Pf","Lt","Lm","Mn","Me","Mc","Nl","Zl","Zp","Cs","Co"],"combiningClasses":["Not_Reordered","Above","Above_Right","Below","Attached_Above_Right","Attached_Below","Overlay","Iota_Subscript","Double_Below","Double_Above","Below_Right","Above_Left","CCC10","CCC11","CCC12","CCC13","CCC14","CCC15","CCC16","CCC17","CCC18","CCC19","CCC20","CCC21","CCC22","CCC23","CCC24","CCC25","CCC30","CCC31","CCC32","CCC27","CCC28","CCC29","CCC33","CCC34","CCC35","CCC36","Nukta","Virama","CCC84","CCC91","CCC103","CCC107","CCC118","CCC122","CCC129","CCC130","CCC132","Attached_Above","Below_Left","Left","Kana_Voicing","CCC26","Right"],"scripts":["Common","Latin","Bopomofo","Inherited","Greek","Coptic","Cyrillic","Armenian","Hebrew","Arabic","Syriac","Thaana","Nko","Samaritan","Mandaic","Devanagari","Bengali","Gurmukhi","Gujarati","Oriya","Tamil","Telugu","Kannada","Malayalam","Sinhala","Thai","Lao","Tibetan","Myanmar","Georgian","Hangul","Ethiopic","Cherokee","Canadian_Aboriginal","Ogham","Runic","Tagalog","Hanunoo","Buhid","Tagbanwa","Khmer","Mongolian","Limbu","Tai_Le","New_Tai_Lue","Buginese","Tai_Tham","Balinese","Sundanese","Batak","Lepcha","Ol_Chiki","Braille","Glagolitic","Tifinagh","Han","Hiragana","Katakana","Yi","Lisu","Vai","Bamum","Syloti_Nagri","Phags_Pa","Saurashtra","Kayah_Li","Rejang","Javanese","Cham","Tai_Viet","Meetei_Mayek","null","Linear_B","Lycian","Carian","Old_Italic","Gothic","Old_Permic","Ugaritic","Old_Persian","Deseret","Shavian","Osmanya","Osage","Elbasan","Caucasian_Albanian","Linear_A","Cypriot","Imperial_Aramaic","Palmyrene","Nabataean","Hatran","Phoenician","Lydian","Meroitic_Hieroglyphs","Meroitic_Cursive","Kharoshthi","Old_South_Arabian","Old_North_Arabian","Manichaean","Avestan","Inscriptional_Parthian","Inscriptional_Pahlavi","Psalter_Pahlavi","Old_Turkic","Old_Hungarian","Hanifi_Rohingya","Old_Sogdian","Sogdian","Elymaic","Brahmi","Kaithi","Sora_Sompeng","Chakma","Mahajani","Sharada","Khojki","Multani","Khudawadi","Grantha","Newa","Tirhuta","Siddham","Modi","Takri","Ahom","Dogra","Warang_Citi","Nandinagari","Zanabazar_Square","Soyombo","Pau_Cin_Hau","Bhaiksuki","Marchen","Masaram_Gondi","Gunjala_Gondi","Makasar","Cuneiform","Egyptian_Hieroglyphs","Anatolian_Hieroglyphs","Mro","Bassa_Vah","Pahawh_Hmong","Medefaidrin","Miao","Tangut","Nushu","Duployan","SignWriting","Nyiakeng_Puachue_Hmong","Wancho","Mende_Kikakui","Adlam"],"eaw":["N","Na","A","W","H","F"]}');const ta=new As(Mr.toByteArray("AAARAAAAAADwfAEAZXl5ONRt+/5bPVFZimRfKoTQJNm37CGE7Iw0j3UsTWKsoyI7kwyyTiEUzSD7NiEzhWYijH0wMVkHE4Mx49fzfo+3nuP4/fdZjvv+XNd5n/d9nef1WZvmKhTxiZndzDQBSEYQqxqKwnsKvGQucFh+6t6cJ792ePQBZv5S9yXSwkyjf/P4T7mTNnIAv1dOVhMlR9lflbUL9JeJguqsjvG9NTj/wLb566VAURnLo2vvRi89S3gW/33ihh2eXpDn40BIW7REl/7coRKIhAFlAiOtbLDTt6mMb4GzMF1gNnvX/sBxtbsAIjfztCNcQjcNDtLThRvuXu5M5g/CBjaLBE4lJm4qy/oZD97+IJryApcXfgWYlkvWbhfXgujOJKVu8B+ozqTLbxyJ5kNiR75CxDqfBM9eOlDMmGeoZ0iQbbS5VUplIwI+ZNXEKQVJxlwqjhOY7w3XwPesbLK5JZE+Tt4X8q8km0dzInsPPzbscrjBMVjF5mOHSeRdJVgKUjLTHiHqXSPkep8N/zFk8167KLp75f6RndkvzdfB6Uz3MmqvRArzdCbs1/iRZjYPLLF3U8Qs+H+R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Q55dtRtulRq9emFDBxlQcqKCaD8NeTSE7FOHvcjf/+oKbbtRqz9gbofoc2EzQ3pL6W5JdfJzAWmOk8oeoECe90lVMruwl/ltM015P/zIPazqvdvFmLNVHMIZrwiQ2tIKtGh6PDVH+85ew3caqVt2BsDv5rOcu3G9srQWd7NmgtzCRUXLYknYRSwtH9oUtkqyN3CfP20xQ1faXQl4MEmjQehWR6GmGnkdpYNQYeIG408yAX7uCZmYUic9juOfb+Re28+OVOB+scYK4DaPcBe+5wmji9gymtkMpKo4UKqCz7yxzuN8VIlx9yNozpRJpNaWHtaZVEqP45n2JemTlYBSmNIK1FuSYAUQ1yBLnKxevrjayd+h2i8PjdB3YY6b0nr3JuOXGpPMyh4V2dslpR3DFEvgpsBLqhqLDOWP4yEvIL6f21PpA7/8B")),zd=Math.log2||(s=>Math.log(s)/Math.LN2),Is=s=>zd(s)+1|0,$d=Is(Ui(yi).categories.length-1),bl=Is(Ui(yi).combiningClasses.length-1),ia=Is(Ui(yi).scripts.length-1),ra=Is(Ui(yi).eaw.length-1),sa=10,Nd=bl+ia+ra+sa,Ud=ia+ra+sa,Vd=ra+sa,Hd=(1<<$d)-1,jd=(1<<bl)-1,Wd=(1<<ia)-1;function Ps(s){const e=ta.get(s);return Ui(yi).categories[e>>Nd&Hd]}function Gd(s){const e=ta.get(s);return Ui(yi).combiningClasses[e>>Ud&jd]}function vl(s){const e=ta.get(s);return Ui(yi).scripts[e>>Vd&Wd]}function wl(s){return Ps(s)==="Nd"}function xl(s){const e=Ps(s);return e==="Mn"||e==="Me"||e==="Mc"}var na=1,aa=0;class qd{constructor(e){this.stateTable=e.stateTable,this.accepting=e.accepting,this.tags=e.tags}match(e){var t=this;return{*[Symbol.iterator](){for(var i=na,r=null,n=null,a=null,o=0;o<e.length;o++){var c=e[o];a=i,i=t.stateTable[i][c],i===aa&&(r!=null&&n!=null&&n>=r&&(yield[r,n,t.tags[a]]),i=t.stateTable[na][c],r=null),i!==aa&&r==null&&(r=o),t.accepting[i]&&(n=o),i===aa&&(i=na)}r!=null&&n!=null&&n>=r&&(yield[r,n,t.tags[i]])}}}apply(e,t){for(var[i,r,n]of this.match(e))for(var a of n)typeof t[a]=="function"&&t[a](i,r,e.slice(i,r+1))}}var Xd=qd;const Cl=Li(Xd);var kl={exports:{}};(function(s){var e=function(){function t(d,f){return f!=null&&d instanceof f}var i;try{i=Map}catch{i=function(){}}var r;try{r=Set}catch{r=function(){}}var n;try{n=Promise}catch{n=function(){}}function a(d,f,p,m,b){typeof f=="object"&&(p=f.depth,m=f.prototype,b=f.includeNonEnumerable,f=f.circular);var g=[],y=[],v=typeof Buffer<"u";typeof f>"u"&&(f=!0),typeof p>"u"&&(p=1/0);function k(C,_){if(C===null)return null;if(_===0)return C;var E,x;if(typeof C!="object")return C;if(t(C,i))E=new i;else if(t(C,r))E=new r;else if(t(C,n))E=new n(function(Y,ae){C.then(function(he){Y(k(he,_-1))},function(he){ae(k(he,_-1))})});else if(a.__isArray(C))E=[];else if(a.__isRegExp(C))E=new RegExp(C.source,l(C)),C.lastIndex&&(E.lastIndex=C.lastIndex);else if(a.__isDate(C))E=new Date(C.getTime());else{if(v&&Buffer.isBuffer(C))return Buffer.allocUnsafe?E=Buffer.allocUnsafe(C.length):E=new Buffer(C.length),C.copy(E),E;t(C,Error)?E=Object.create(C):typeof m>"u"?(x=Object.getPrototypeOf(C),E=Object.create(x)):(E=Object.create(m),x=m)}if(f){var S=g.indexOf(C);if(S!=-1)return y[S];g.push(C),y.push(E)}t(C,i)&&C.forEach(function(Y,ae){var he=k(ae,_-1),Q=k(Y,_-1);E.set(he,Q)}),t(C,r)&&C.forEach(function(Y){var ae=k(Y,_-1);E.add(ae)});for(var T in C){var A;x&&(A=Object.getOwnPropertyDescriptor(x,T)),!(A&&A.set==null)&&(E[T]=k(C[T],_-1))}if(Object.getOwnPropertySymbols)for(var R=Object.getOwnPropertySymbols(C),T=0;T<R.length;T++){var M=R[T],j=Object.getOwnPropertyDescriptor(C,M);j&&!j.enumerable&&!b||(E[M]=k(C[M],_-1),j.enumerable||Object.defineProperty(E,M,{enumerable:!1}))}if(b)for(var W=Object.getOwnPropertyNames(C),T=0;T<W.length;T++){var se=W[T],j=Object.getOwnPropertyDescriptor(C,se);j&&j.enumerable||(E[se]=k(C[se],_-1),Object.defineProperty(E,se,{enumerable:!1}))}return E}return k(d,p)}a.clonePrototype=function(f){if(f===null)return null;var p=function(){};return p.prototype=f,new p};function o(d){return Object.prototype.toString.call(d)}a.__objToStr=o;function c(d){return typeof d=="object"&&o(d)==="[object Date]"}a.__isDate=c;function u(d){return typeof d=="object"&&o(d)==="[object Array]"}a.__isArray=u;function h(d){return typeof d=="object"&&o(d)==="[object RegExp]"}a.__isRegExp=h;function l(d){var f="";return d.global&&(f+="g"),d.ignoreCase&&(f+="i"),d.multiline&&(f+="m"),f}return a.__getRegExpFlags=l,a}();s.exports&&(s.exports=e)})(kl);var Zd=kl.exports;const oa=Li(Zd);var Br={},Os={};function Sl(s){this.buffer=s,this.pos=0}Sl.prototype.read=function(s,e,t){this.pos+t>this.buffer.length&&(t=this.buffer.length-this.pos);for(var i=0;i<t;i++)s[e+i]=this.buffer[this.pos+i];return this.pos+=t,t},Os.BrotliInput=Sl;function Tl(s){this.buffer=s,this.pos=0}Tl.prototype.write=function(s,e){if(this.pos+e>this.buffer.length)throw new Error("Output buffer is not large enough");return this.buffer.set(s.subarray(0,e),this.pos),this.pos+=e,e},Os.BrotliOutput=Tl;var Vi=4096,Kd=2*Vi+32,El=2*Vi-1,Yd=new Uint32Array([0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215]);function Hi(s){this.buf_=new Uint8Array(Kd),this.input_=s,this.reset()}Hi.READ_SIZE=Vi,Hi.IBUF_MASK=El,Hi.prototype.reset=function(){this.buf_ptr_=0,this.val_=0,this.pos_=0,this.bit_pos_=0,this.bit_end_pos_=0,this.eos_=0,this.readMoreInput();for(var s=0;s<4;s++)this.val_|=this.buf_[this.pos_]<<8*s,++this.pos_;return this.bit_end_pos_>0},Hi.prototype.readMoreInput=function(){if(!(this.bit_end_pos_>256))if(this.eos_){if(this.bit_pos_>this.bit_end_pos_)throw new Error("Unexpected end of input "+this.bit_pos_+" "+this.bit_end_pos_)}else{var s=this.buf_ptr_,e=this.input_.read(this.buf_,s,Vi);if(e<0)throw new Error("Unexpected end of input");if(e<Vi){this.eos_=1;for(var t=0;t<32;t++)this.buf_[s+e+t]=0}if(s===0){for(var t=0;t<32;t++)this.buf_[(Vi<<1)+t]=this.buf_[t];this.buf_ptr_=Vi}else this.buf_ptr_=0;this.bit_end_pos_+=e<<3}},Hi.prototype.fillBitWindow=function(){for(;this.bit_pos_>=8;)this.val_>>>=8,this.val_|=this.buf_[this.pos_&El]<<24,++this.pos_,this.bit_pos_=this.bit_pos_-8>>>0,this.bit_end_pos_=this.bit_end_pos_-8>>>0},Hi.prototype.readBits=function(s){32-this.bit_pos_<s&&this.fillBitWindow();var e=this.val_>>>this.bit_pos_&Yd[s];return this.bit_pos_+=s,e};var Jd=Hi,bi={},la={},ca,_l;function Qd(){return _l||(_l=1,ca="W5/fcQLn5gKf2XUbAiQ1XULX+TZz6ADToDsgqk6qVfeC0e4m6OO2wcQ1J76ZBVRV1fRkEsdu//62zQsFEZWSTCnMhcsQKlS2qOhuVYYMGCkV0fXWEoMFbESXrKEZ9wdUEsyw9g4bJlEt1Y6oVMxMRTEVbCIwZzJzboK5j8m4YH02qgXYhv1V+PM435sLVxyHJihaJREEhZGqL03txGFQLm76caGO/ovxKvzCby/3vMTtX/459f0igi7WutnKiMQ6wODSoRh/8Lx1V3Q99MvKtwB6bHdERYRY0hStJoMjNeTsNX7bn+Y7e4EQ3bf8xBc7L0BsyfFPK43dGSXpL6clYC/I328h54/VYrQ5i0648FgbGtl837svJ35L3Mot/+nPlNpWgKx1gGXQYqX6n+bbZ7wuyCHKcUok12Xjqub7NXZGzqBx0SD+uziNf87t7ve42jxSKQ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e0dqN9b35jtSpnYMXkU+vZq+IAHad3IHc2s/LYrnD1anfG46IFiMIr9oNbZDWvwthqYNqOigaKd/XlLU4XHfk/PXIjPsLy/9/kAtQ+/wKH+hI/IROWj5FPvTZAT9f7j4ZXQyG4M0TujMAFXYkKvEHv1xhySekgXGGqNxWeWKlf8dDAlLuB1cb/qOD+rk7cmwt+1yKpk9cudqBanTi6zTbXRtV8qylNtjyOVKy1HTz0GW9rjt6sSjAZcT5R+KdtyYb0zyqG9pSLuCw5WBwAn7fjBjKLLoxLXMI+52L9cLwIR2B6OllJZLHJ8vDxmWdtF+QJnmt1rsHPIWY20lftk8fYePkAIg6Hgn532QoIpegMxiWgAOfe5/U44APR8Ac0NeZrVh3gEhs12W+tVSiWiUQekf/YBECUy5fdYbA08dd7VzPAP9aiVcIB9k6tY7WdJ1wNV+bHeydNtmC6G5ICtFC1ZwmJU/j8hf0I8TRVKSiz5oYIa93EpUI78X8GYIAZabx47/n8LDAAJ0nNtP1rpROprqKMBRecShca6qXuTSI3jZBLOB3Vp381B5rCGhjSvh/NSVkYp2qIdP/Bg="),ca}var Al;function ef(){if(Al)return la;Al=1;var s=Mr;return la.init=function(){var e=Dl().BrotliDecompressBuffer,t=s.toByteArray(Qd());return e(t)},la}var Il;function Pl(){if(Il)return bi;Il=1;var s=ef();return bi.init=function(){bi.dictionary=s.init()},bi.offsetsByLength=new Uint32Array([0,0,0,0,0,4096,9216,21504,35840,44032,53248,63488,74752,87040,93696,100864,104704,106752,108928,113536,115968,118528,119872,121280,122016]),bi.sizeBitsByLength=new Uint8Array([0,0,0,0,10,10,11,11,10,10,10,10,10,9,9,8,7,7,8,7,7,6,6,5,5]),bi.minDictionaryWordLength=4,bi.maxDictionaryWordLength=24,bi}var Fs={};function lr(s,e){this.bits=s,this.value=e}Fs.HuffmanCode=lr;var cr=15;function Ol(s,e){for(var t=1<<e-1;s&t;)t>>=1;return(s&t-1)+t}function Fl(s,e,t,i,r){do i-=t,s[e+i]=new lr(r.bits,r.value);while(i>0)}function tf(s,e,t){for(var i=1<<e-t;e<cr&&(i-=s[e],!(i<=0));)++e,i<<=1;return e-t}Fs.BrotliBuildHuffmanTable=function(s,e,t,i,r){var n=e,a,o,c,u,h,l,d,f,p,m,b,g=new Int32Array(cr+1),y=new Int32Array(cr+1);for(b=new Int32Array(r),c=0;c<r;c++)g[i[c]]++;for(y[1]=0,o=1;o<cr;o++)y[o+1]=y[o]+g[o];for(c=0;c<r;c++)i[c]!==0&&(b[y[i[c]]++]=c);if(f=t,p=1<<f,m=p,y[cr]===1){for(u=0;u<m;++u)s[e+u]=new lr(0,b[0]&65535);return m}for(u=0,c=0,o=1,h=2;o<=t;++o,h<<=1)for(;g[o]>0;--g[o])a=new lr(o&255,b[c++]&65535),Fl(s,e+u,h,p,a),u=Ol(u,o);for(d=m-1,l=-1,o=t+1,h=2;o<=cr;++o,h<<=1)for(;g[o]>0;--g[o])(u&d)!==l&&(e+=p,f=tf(g,o,t),p=1<<f,m+=p,l=u&d,s[n+l]=new lr(f+t&255,e-n-l&65535)),a=new lr(o-t&255,b[c++]&65535),Fl(s,e+(u>>t),h,p,a),u=Ol(u,o);return m};var ua={};ua.lookup=new Uint8Array([0,0,0,0,0,0,0,0,0,4,4,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,12,16,12,12,20,12,16,24,28,12,12,32,12,36,12,44,44,44,44,44,44,44,44,44,44,32,32,24,40,28,12,12,48,52,52,52,48,52,52,52,48,52,52,52,52,52,48,52,52,52,52,52,48,52,52,52,52,52,24,12,28,12,12,12,56,60,60,60,56,60,60,60,56,60,60,60,60,60,56,60,60,60,60,60,56,60,60,60,60,60,24,12,28,12,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,2,3,2,3,2,3,2,3,2,3,2,3,2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,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,56,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29,30,30,30,30,31,31,31,31,32,32,32,32,33,33,33,33,34,34,34,34,35,35,35,35,36,36,36,36,37,37,37,37,38,38,38,38,39,39,39,39,40,40,40,40,41,41,41,41,42,42,42,42,43,43,43,43,44,44,44,44,45,45,45,45,46,46,46,46,47,47,47,47,48,48,48,48,49,49,49,49,50,50,50,50,51,51,51,51,52,52,52,52,53,53,53,53,54,54,54,54,55,55,55,55,56,56,56,56,57,57,57,57,58,58,58,58,59,59,59,59,60,60,60,60,61,61,61,61,62,62,62,62,63,63,63,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),ua.lookupOffsets=new Uint16Array([1024,1536,1280,1536,0,256,768,512]);var ur={};function Z(s,e){this.offset=s,this.nbits=e}ur.kBlockLengthPrefixCode=[new Z(1,2),new Z(5,2),new Z(9,2),new Z(13,2),new Z(17,3),new Z(25,3),new Z(33,3),new Z(41,3),new Z(49,4),new Z(65,4),new Z(81,4),new Z(97,4),new Z(113,5),new Z(145,5),new Z(177,5),new Z(209,5),new Z(241,6),new Z(305,6),new Z(369,7),new Z(497,8),new Z(753,9),new Z(1265,10),new Z(2289,11),new Z(4337,12),new Z(8433,13),new Z(16625,24)],ur.kInsertLengthPrefixCode=[new Z(0,0),new Z(1,0),new Z(2,0),new Z(3,0),new Z(4,0),new Z(5,0),new Z(6,1),new Z(8,1),new Z(10,2),new Z(14,2),new Z(18,3),new Z(26,3),new Z(34,4),new Z(50,4),new Z(66,5),new Z(98,5),new Z(130,6),new Z(194,7),new Z(322,8),new Z(578,9),new Z(1090,10),new Z(2114,12),new Z(6210,14),new Z(22594,24)],ur.kCopyLengthPrefixCode=[new Z(2,0),new Z(3,0),new Z(4,0),new Z(5,0),new Z(6,0),new Z(7,0),new Z(8,0),new Z(9,0),new Z(10,1),new Z(12,1),new Z(14,2),new Z(18,2),new Z(22,3),new Z(30,3),new Z(38,4),new Z(54,4),new Z(70,5),new Z(102,5),new Z(134,6),new Z(198,7),new Z(326,8),new Z(582,9),new Z(1094,10),new Z(2118,24)],ur.kInsertRangeLut=[0,0,8,8,0,16,8,16,16],ur.kCopyRangeLut=[0,8,0,8,16,0,16,8,16];var Lr={},Rl;function rf(){if(Rl)return Lr;Rl=1;var s=Pl(),e=0,t=1,i=2,r=3,n=4,a=5,o=6,c=7,u=8,h=9,l=10,d=11,f=12,p=13,m=14,b=15,g=16,y=17,v=18,k=20;function C(x,S,T){this.prefix=new Uint8Array(x.length),this.transform=S,this.suffix=new Uint8Array(T.length);for(var A=0;A<x.length;A++)this.prefix[A]=x.charCodeAt(A);for(var A=0;A<T.length;A++)this.suffix[A]=T.charCodeAt(A)}var _=[new C("",e,""),new C("",e," "),new C(" ",e," "),new C("",f,""),new C("",l," "),new C("",e," the "),new C(" ",e,""),new C("s ",e," "),new C("",e," of "),new C("",l,""),new C("",e," and "),new C("",p,""),new C("",t,""),new C(", ",e," "),new C("",e,", "),new C(" ",l," "),new C("",e," in "),new C("",e," to "),new C("e ",e," "),new C("",e,'"'),new C("",e,"."),new C("",e,'">'),new C("",e,`
183
+ `),new C("",r,""),new C("",e,"]"),new C("",e," for "),new C("",m,""),new C("",i,""),new C("",e," a "),new C("",e," that "),new C(" ",l,""),new C("",e,". "),new C(".",e,""),new C(" ",e,", "),new C("",b,""),new C("",e," with "),new C("",e,"'"),new C("",e," from "),new C("",e," by "),new C("",g,""),new C("",y,""),new C(" the ",e,""),new C("",n,""),new C("",e,". The "),new C("",d,""),new C("",e," on "),new C("",e," as "),new C("",e," is "),new C("",c,""),new C("",t,"ing "),new C("",e,`
184
+ `),new C("",e,":"),new C(" ",e,". "),new C("",e,"ed "),new C("",k,""),new C("",v,""),new C("",o,""),new C("",e,"("),new C("",l,", "),new C("",u,""),new C("",e," at "),new C("",e,"ly "),new C(" the ",e," of "),new C("",a,""),new C("",h,""),new C(" ",l,", "),new C("",l,'"'),new C(".",e,"("),new C("",d," "),new C("",l,'">'),new C("",e,'="'),new C(" ",e,"."),new C(".com/",e,""),new C(" the ",e," of the "),new C("",l,"'"),new C("",e,". This "),new C("",e,","),new C(".",e," "),new C("",l,"("),new C("",l,"."),new C("",e," not "),new C(" ",e,'="'),new C("",e,"er "),new C(" ",d," "),new C("",e,"al "),new C(" ",d,""),new C("",e,"='"),new C("",d,'"'),new C("",l,". "),new C(" ",e,"("),new C("",e,"ful "),new C(" ",l,". "),new C("",e,"ive "),new C("",e,"less "),new C("",d,"'"),new C("",e,"est "),new C(" ",l,"."),new C("",d,'">'),new C(" ",e,"='"),new C("",l,","),new C("",e,"ize "),new C("",d,"."),new C(" ",e,""),new C(" ",e,","),new C("",l,'="'),new C("",d,'="'),new C("",e,"ous "),new C("",d,", "),new C("",l,"='"),new C(" ",l,","),new C(" ",d,'="'),new C(" ",d,", "),new C("",d,","),new C("",d,"("),new C("",d,". "),new C(" ",d,"."),new C("",d,"='"),new C(" ",d,". "),new C(" ",l,'="'),new C(" ",d,"='"),new C(" ",l,"='")];Lr.kTransforms=_,Lr.kNumTransforms=_.length;function E(x,S){return x[S]<192?(x[S]>=97&&x[S]<=122&&(x[S]^=32),1):x[S]<224?(x[S+1]^=32,2):(x[S+2]^=5,3)}return Lr.transformDictionaryWord=function(x,S,T,A,R){var M=_[R].prefix,j=_[R].suffix,W=_[R].transform,se=W<f?0:W-(f-1),Y=0,ae=S,he;se>A&&(se=A);for(var Q=0;Q<M.length;)x[S++]=M[Q++];for(T+=se,A-=se,W<=h&&(A-=W),Y=0;Y<A;Y++)x[S++]=s.dictionary[T+Y];if(he=S-A,W===l)E(x,he);else if(W===d)for(;A>0;){var we=E(x,he);he+=we,A-=we}for(var Le=0;Le<j.length;)x[S++]=j[Le++];return S-ae},Lr}var Ml;function Dl(){if(Ml)return Br;Ml=1;var s=Os.BrotliInput,e=Os.BrotliOutput,t=Jd,i=Pl(),r=Fs.HuffmanCode,n=Fs.BrotliBuildHuffmanTable,a=ua,o=ur,c=rf(),u=8,h=16,l=256,d=704,f=26,p=6,m=2,b=8,g=255,y=1080,v=18,k=new Uint8Array([1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15]),C=16,_=new Uint8Array([3,2,1,0,3,3,3,3,3,3,2,2,2,2,2,2]),E=new Int8Array([0,0,0,0,-1,1,-2,2,-3,3,-1,1,-2,2,-3,3]),x=new Uint16Array([256,402,436,468,500,534,566,598,630,662,694,726,758,790,822,854,886,920,952,984,1016,1048,1080]);function S(G){var $;return G.readBits(1)===0?16:($=G.readBits(3),$>0?17+$:($=G.readBits(3),$>0?8+$:17))}function T(G){if(G.readBits(1)){var $=G.readBits(3);return $===0?1:G.readBits($)+(1<<$)}return 0}function A(){this.meta_block_length=0,this.input_end=0,this.is_uncompressed=0,this.is_metadata=!1}function R(G){var $=new A,B,D,ne;if($.input_end=G.readBits(1),$.input_end&&G.readBits(1))return $;if(B=G.readBits(2)+4,B===7){if($.is_metadata=!0,G.readBits(1)!==0)throw new Error("Invalid reserved bit");if(D=G.readBits(2),D===0)return $;for(ne=0;ne<D;ne++){var ce=G.readBits(8);if(ne+1===D&&D>1&&ce===0)throw new Error("Invalid size byte");$.meta_block_length|=ce<<ne*8}}else for(ne=0;ne<B;++ne){var oe=G.readBits(4);if(ne+1===B&&B>4&&oe===0)throw new Error("Invalid size nibble");$.meta_block_length|=oe<<ne*4}return++$.meta_block_length,!$.input_end&&!$.is_metadata&&($.is_uncompressed=G.readBits(1)),$}function M(G,$,B){var D;return B.fillBitWindow(),$+=B.val_>>>B.bit_pos_&g,D=G[$].bits-b,D>0&&(B.bit_pos_+=b,$+=G[$].value,$+=B.val_>>>B.bit_pos_&(1<<D)-1),B.bit_pos_+=G[$].bits,G[$].value}function j(G,$,B,D){for(var ne=0,ce=u,oe=0,ue=0,Te=32768,me=[],ee=0;ee<32;ee++)me.push(new r(0,0));for(n(me,0,5,G,v);ne<$&&Te>0;){var Fe=0,nt;if(D.readMoreInput(),D.fillBitWindow(),Fe+=D.val_>>>D.bit_pos_&31,D.bit_pos_+=me[Fe].bits,nt=me[Fe].value&255,nt<h)oe=0,B[ne++]=nt,nt!==0&&(ce=nt,Te-=32768>>nt);else{var wt=nt-14,Ue,et,Ke=0;if(nt===h&&(Ke=ce),ue!==Ke&&(oe=0,ue=Ke),Ue=oe,oe>0&&(oe-=2,oe<<=wt),oe+=D.readBits(wt)+3,et=oe-Ue,ne+et>$)throw new Error("[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols");for(var gt=0;gt<et;gt++)B[ne+gt]=ue;ne+=et,ue!==0&&(Te-=et<<15-ue)}}if(Te!==0)throw new Error("[ReadHuffmanCodeLengths] space = "+Te);for(;ne<$;ne++)B[ne]=0}function W(G,$,B,D){var ne=0,ce,oe=new Uint8Array(G);if(D.readMoreInput(),ce=D.readBits(2),ce===1){for(var ue,Te=G-1,me=0,ee=new Int32Array(4),Fe=D.readBits(2)+1;Te;)Te>>=1,++me;for(ue=0;ue<Fe;++ue)ee[ue]=D.readBits(me)%G,oe[ee[ue]]=2;switch(oe[ee[0]]=1,Fe){case 1:break;case 3:if(ee[0]===ee[1]||ee[0]===ee[2]||ee[1]===ee[2])throw new Error("[ReadHuffmanCode] invalid symbols");break;case 2:if(ee[0]===ee[1])throw new Error("[ReadHuffmanCode] invalid symbols");oe[ee[1]]=1;break;case 4:if(ee[0]===ee[1]||ee[0]===ee[2]||ee[0]===ee[3]||ee[1]===ee[2]||ee[1]===ee[3]||ee[2]===ee[3])throw new Error("[ReadHuffmanCode] invalid symbols");D.readBits(1)?(oe[ee[2]]=3,oe[ee[3]]=3):oe[ee[0]]=2;break}}else{var ue,nt=new Uint8Array(v),wt=32,Ue=0,et=[new r(2,0),new r(2,4),new r(2,3),new r(3,2),new r(2,0),new r(2,4),new r(2,3),new r(4,1),new r(2,0),new r(2,4),new r(2,3),new r(3,2),new r(2,0),new r(2,4),new r(2,3),new r(4,5)];for(ue=ce;ue<v&&wt>0;++ue){var Ke=k[ue],gt=0,Tt;D.fillBitWindow(),gt+=D.val_>>>D.bit_pos_&15,D.bit_pos_+=et[gt].bits,Tt=et[gt].value,nt[Ke]=Tt,Tt!==0&&(wt-=32>>Tt,++Ue)}if(!(Ue===1||wt===0))throw new Error("[ReadHuffmanCode] invalid num_codes or space");j(nt,G,oe,D)}if(ne=n($,B,b,oe,G),ne===0)throw new Error("[ReadHuffmanCode] BuildHuffmanTable failed: ");return ne}function se(G,$,B){var D,ne;return D=M(G,$,B),ne=o.kBlockLengthPrefixCode[D].nbits,o.kBlockLengthPrefixCode[D].offset+B.readBits(ne)}function Y(G,$,B){var D;return G<C?(B+=_[G],B&=3,D=$[B]+E[G]):D=G-C+1,D}function ae(G,$){for(var B=G[$],D=$;D;--D)G[D]=G[D-1];G[0]=B}function he(G,$){var B=new Uint8Array(256),D;for(D=0;D<256;++D)B[D]=D;for(D=0;D<$;++D){var ne=G[D];G[D]=B[ne],ne&&ae(B,ne)}}function Q(G,$){this.alphabet_size=G,this.num_htrees=$,this.codes=new Array($+$*x[G+31>>>5]),this.htrees=new Uint32Array($)}Q.prototype.decode=function(G){var $,B,D=0;for($=0;$<this.num_htrees;++$)this.htrees[$]=D,B=W(this.alphabet_size,this.codes,D,G),D+=B};function we(G,$){var B={num_htrees:null,context_map:null},D,ne=0,ce,oe;$.readMoreInput();var ue=B.num_htrees=T($)+1,Te=B.context_map=new Uint8Array(G);if(ue<=1)return B;for(D=$.readBits(1),D&&(ne=$.readBits(4)+1),ce=[],oe=0;oe<y;oe++)ce[oe]=new r(0,0);for(W(ue+ne,ce,0,$),oe=0;oe<G;){var me;if($.readMoreInput(),me=M(ce,0,$),me===0)Te[oe]=0,++oe;else if(me<=ne)for(var ee=1+(1<<me)+$.readBits(me);--ee;){if(oe>=G)throw new Error("[DecodeContextMap] i >= context_map_size");Te[oe]=0,++oe}else Te[oe]=me-ne,++oe}return $.readBits(1)&&he(Te,G),B}function Le(G,$,B,D,ne,ce,oe){var ue=B*2,Te=B,me=M($,B*y,oe),ee;me===0?ee=ne[ue+(ce[Te]&1)]:me===1?ee=ne[ue+(ce[Te]-1&1)]+1:ee=me-2,ee>=G&&(ee-=G),D[B]=ee,ne[ue+(ce[Te]&1)]=ee,++ce[Te]}function Ze(G,$,B,D,ne,ce){var oe=ne+1,ue=B&ne,Te=ce.pos_&t.IBUF_MASK,me;if($<8||ce.bit_pos_+($<<3)<ce.bit_end_pos_){for(;$-- >0;)ce.readMoreInput(),D[ue++]=ce.readBits(8),ue===oe&&(G.write(D,oe),ue=0);return}if(ce.bit_end_pos_<32)throw new Error("[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32");for(;ce.bit_pos_<32;)D[ue]=ce.val_>>>ce.bit_pos_,ce.bit_pos_+=8,++ue,--$;if(me=ce.bit_end_pos_-ce.bit_pos_>>3,Te+me>t.IBUF_MASK){for(var ee=t.IBUF_MASK+1-Te,Fe=0;Fe<ee;Fe++)D[ue+Fe]=ce.buf_[Te+Fe];me-=ee,ue+=ee,$-=ee,Te=0}for(var Fe=0;Fe<me;Fe++)D[ue+Fe]=ce.buf_[Te+Fe];if(ue+=me,$-=me,ue>=oe){G.write(D,oe),ue-=oe;for(var Fe=0;Fe<ue;Fe++)D[Fe]=D[oe+Fe]}for(;ue+$>=oe;){if(me=oe-ue,ce.input_.read(D,ue,me)<me)throw new Error("[CopyUncompressedBlockToOutput] not enough bytes");G.write(D,oe),$-=me,ue=0}if(ce.input_.read(D,ue,$)<$)throw new Error("[CopyUncompressedBlockToOutput] not enough bytes");ce.reset()}function st(G){var $=G.bit_pos_+7&-8,B=G.readBits($-G.bit_pos_);return B==0}function ht(G){var $=new s(G),B=new t($);S(B);var D=R(B);return D.meta_block_length}Br.BrotliDecompressedSize=ht;function St(G,$){var B=new s(G);$==null&&($=ht(G));var D=new Uint8Array($),ne=new e(D);return dt(B,ne),ne.pos<ne.buffer.length&&(ne.buffer=ne.buffer.subarray(0,ne.pos)),ne.buffer}Br.BrotliDecompressBuffer=St;function dt(G,$){var B,D=0,ne=0,ce=0,oe,ue=0,Te,me,ee,Fe,nt=[16,15,11,4],wt=0,Ue=0,et=0,Ke=[new Q(0,0),new Q(0,0),new Q(0,0)],gt,Tt,Ee,Qw=128+t.READ_SIZE;Ee=new t(G),ce=S(Ee),oe=(1<<ce)-16,Te=1<<ce,me=Te-1,ee=new Uint8Array(Te+Qw+i.maxDictionaryWordLength),Fe=Te,gt=[],Tt=[];for(var Sn=0;Sn<3*y;Sn++)gt[Sn]=new r(0,0),Tt[Sn]=new r(0,0);for(;!ne;){var at=0,N0,ei=[1<<28,1<<28,1<<28],Mi=[0],Ft=[1,1,1],wo=[0,1,0,1,0,1],Tn=[0],Er,fs,U0,V0,H0=null,En=null,j0,W0=null,G0,q0=0,xo=null,X0=0,Z0=0,Co=null,K0=0,ko=0,So=0,_r,To;for(B=0;B<3;++B)Ke[B].codes=null,Ke[B].htrees=null;Ee.readMoreInput();var _n=R(Ee);if(at=_n.meta_block_length,D+at>$.buffer.length){var Y0=new Uint8Array(D+at);Y0.set($.buffer),$.buffer=Y0}if(ne=_n.input_end,N0=_n.is_uncompressed,_n.is_metadata){for(st(Ee);at>0;--at)Ee.readMoreInput(),Ee.readBits(8);continue}if(at!==0){if(N0){Ee.bit_pos_=Ee.bit_pos_+7&-8,Ze($,at,D,ee,me,Ee),D+=at;continue}for(B=0;B<3;++B)Ft[B]=T(Ee)+1,Ft[B]>=2&&(W(Ft[B]+2,gt,B*y,Ee),W(f,Tt,B*y,Ee),ei[B]=se(Tt,B*y,Ee),Tn[B]=1);for(Ee.readMoreInput(),Er=Ee.readBits(2),fs=C+(Ee.readBits(4)<<Er),U0=(1<<Er)-1,V0=fs+(48<<Er),En=new Uint8Array(Ft[0]),B=0;B<Ft[0];++B)Ee.readMoreInput(),En[B]=Ee.readBits(2)<<1;var J0=we(Ft[0]<<p,Ee);j0=J0.num_htrees,H0=J0.context_map;var Q0=we(Ft[2]<<m,Ee);for(G0=Q0.num_htrees,W0=Q0.context_map,Ke[0]=new Q(l,j0),Ke[1]=new Q(d,Ft[1]),Ke[2]=new Q(V0,G0),B=0;B<3;++B)Ke[B].decode(Ee);for(xo=0,Co=0,_r=En[Mi[0]],ko=a.lookupOffsets[_r],So=a.lookupOffsets[_r+1],To=Ke[1].htrees[0];at>0;){var An,ps,Eo,_o,Ao,yt,xt,li,ms,Ar,gs;for(Ee.readMoreInput(),ei[1]===0&&(Le(Ft[1],gt,1,Mi,wo,Tn,Ee),ei[1]=se(Tt,y,Ee),To=Ke[1].htrees[Mi[1]]),--ei[1],An=M(Ke[1].codes,To,Ee),ps=An>>6,ps>=2?(ps-=2,xt=-1):xt=0,Eo=o.kInsertRangeLut[ps]+(An>>3&7),_o=o.kCopyRangeLut[ps]+(An&7),Ao=o.kInsertLengthPrefixCode[Eo].offset+Ee.readBits(o.kInsertLengthPrefixCode[Eo].nbits),yt=o.kCopyLengthPrefixCode[_o].offset+Ee.readBits(o.kCopyLengthPrefixCode[_o].nbits),Ue=ee[D-1&me],et=ee[D-2&me],Ar=0;Ar<Ao;++Ar)Ee.readMoreInput(),ei[0]===0&&(Le(Ft[0],gt,0,Mi,wo,Tn,Ee),ei[0]=se(Tt,0,Ee),q0=Mi[0]<<p,xo=q0,_r=En[Mi[0]],ko=a.lookupOffsets[_r],So=a.lookupOffsets[_r+1]),ms=a.lookup[ko+Ue]|a.lookup[So+et],X0=H0[xo+ms],--ei[0],et=Ue,Ue=M(Ke[0].codes,Ke[0].htrees[X0],Ee),ee[D&me]=Ue,(D&me)===me&&$.write(ee,Te),++D;if(at-=Ao,at<=0)break;if(xt<0){var ms;if(Ee.readMoreInput(),ei[2]===0&&(Le(Ft[2],gt,2,Mi,wo,Tn,Ee),ei[2]=se(Tt,2*y,Ee),Z0=Mi[2]<<m,Co=Z0),--ei[2],ms=(yt>4?3:yt-2)&255,K0=W0[Co+ms],xt=M(Ke[2].codes,Ke[2].htrees[K0],Ee),xt>=fs){var Io,eh,ys;xt-=fs,eh=xt&U0,xt>>=Er,Io=(xt>>1)+1,ys=(2+(xt&1)<<Io)-4,xt=fs+(ys+Ee.readBits(Io)<<Er)+eh}}if(li=Y(xt,nt,wt),li<0)throw new Error("[BrotliDecompress] invalid distance");if(D<oe&&ue!==oe?ue=D:ue=oe,gs=D&me,li>ue)if(yt>=i.minDictionaryWordLength&&yt<=i.maxDictionaryWordLength){var ys=i.offsetsByLength[yt],th=li-ue-1,ih=i.sizeBitsByLength[yt],ex=(1<<ih)-1,tx=th&ex,rh=th>>ih;if(ys+=tx*yt,rh<c.kNumTransforms){var Po=c.transformDictionaryWord(ee,gs,ys,yt,rh);if(gs+=Po,D+=Po,at-=Po,gs>=Fe){$.write(ee,Te);for(var In=0;In<gs-Fe;In++)ee[In]=ee[Fe+In]}}else throw new Error("Invalid backward reference. pos: "+D+" distance: "+li+" len: "+yt+" bytes left: "+at)}else throw new Error("Invalid backward reference. pos: "+D+" distance: "+li+" len: "+yt+" bytes left: "+at);else{if(xt>0&&(nt[wt&3]=li,++wt),yt>at)throw new Error("Invalid backward reference. pos: "+D+" distance: "+li+" len: "+yt+" bytes left: "+at);for(Ar=0;Ar<yt;++Ar)ee[D&me]=ee[D-li&me],(D&me)===me&&$.write(ee,Te),++D,--at}Ue=ee[D-1&me],et=ee[D-2&me]}D&=1073741823}}$.write(ee,D&me)}return Br.BrotliDecompress=dt,i.init(),Br}var sf=Dl().BrotliDecompressBuffer;const nf=Li(sf);function zr(s,e,t,i){Object.defineProperty(s,e,{get:t,set:i,enumerable:!0,configurable:!0})}function Rs(s){return s&&s.__esModule?s.default:s}var $r={};zr($r,"logErrors",()=>af),zr($r,"registerFormat",()=>hr),zr($r,"create",()=>Bl),zr($r,"defaultLanguage",()=>Ms),zr($r,"setDefaultLanguage",()=>of);let af=!1,ha=[];function hr(s){ha.push(s)}function Bl(s,e){for(let t=0;t<ha.length;t++){let i=ha[t];if(i.probe(s)){let r=new i(new tt(s));return e?r.getFont(e):r}}throw new Error("Unknown font format")}let Ms="en";function of(s="en"){Ms=s}function rt(s,e,t){if(t.get){let i=t.get;t.get=function(){let r=i.call(this);return Object.defineProperty(this,e,{value:r}),r}}else if(typeof t.value=="function"){let i=t.value;return{get(){let r=new Map;function n(...a){let o=a.length>0?a[0]:"value";if(r.has(o))return r.get(o);let c=i.apply(this,a);return r.set(o,c),c}return Object.defineProperty(this,e,{value:n}),n}}}}let lf=new F({firstCode:w,entryCount:w,idDelta:z,idRangeOffset:w}),da=new F({startCharCode:O,endCharCode:O,glyphID:O}),cf=new F({startUnicodeValue:gi,additionalCount:H}),uf=new F({unicodeValue:gi,glyphID:w}),hf=new I(cf,O),df=new I(uf,O),ff=new F({varSelector:gi,defaultUVS:new P(O,hf,{type:"parent"}),nonDefaultUVS:new P(O,df,{type:"parent"})}),pf=new xe(w,{0:{length:w,language:w,codeMap:new Be(H,256)},2:{length:w,language:w,subHeaderKeys:new I(w,256),subHeaderCount:s=>Math.max.apply(Math,s.subHeaderKeys),subHeaders:new Be(lf,"subHeaderCount"),glyphIndexArray:new Be(w,"subHeaderCount")},4:{length:w,language:w,segCountX2:w,segCount:s=>s.segCountX2>>1,searchRange:w,entrySelector:w,rangeShift:w,endCode:new Be(w,"segCount"),reservedPad:new $e(w),startCode:new Be(w,"segCount"),idDelta:new Be(z,"segCount"),idRangeOffset:new Be(w,"segCount"),glyphIndexArray:new Be(w,s=>(s.length-s._currentOffset)/2)},6:{length:w,language:w,firstCode:w,entryCount:w,glyphIndices:new Be(w,"entryCount")},8:{reserved:new $e(w),length:O,language:w,is32:new Be(H,8192),nGroups:O,groups:new Be(da,"nGroups")},10:{reserved:new $e(w),length:O,language:O,firstCode:O,entryCount:O,glyphIndices:new Be(w,"numChars")},12:{reserved:new $e(w),length:O,language:O,nGroups:O,groups:new Be(da,"nGroups")},13:{reserved:new $e(w),length:O,language:O,nGroups:O,groups:new Be(da,"nGroups")},14:{length:O,numRecords:O,varSelectors:new Be(ff,"numRecords")}}),mf=new F({platformID:w,encodingID:w,table:new P(O,pf,{type:"parent",lazy:!0})});var gf=new F({version:w,numSubtables:w,tables:new I(mf,"numSubtables")}),yf=new F({version:zi,revision:zi,checkSumAdjustment:O,magicNumber:O,flags:w,unitsPerEm:w,created:new I(zi,2),modified:new I(zi,2),xMin:z,yMin:z,xMax:z,yMax:z,macStyle:new Et(w,["bold","italic","underline","outline","shadow","condensed","extended"]),lowestRecPPEM:w,fontDirectionHint:z,indexToLocFormat:z,glyphDataFormat:z}),bf=new F({version:zi,ascent:z,descent:z,lineGap:z,advanceWidthMax:w,minLeftSideBearing:z,minRightSideBearing:z,xMaxExtent:z,caretSlopeRise:z,caretSlopeRun:z,caretOffset:z,reserved:new $e(z,4),metricDataFormat:z,numberOfMetrics:w});let vf=new F({advance:w,bearing:z});var wf=new F({metrics:new Be(vf,s=>s.parent.hhea.numberOfMetrics),bearings:new Be(z,s=>s.parent.maxp.numGlyphs-s.parent.hhea.numberOfMetrics)}),xf=new F({version:zi,numGlyphs:w,maxPoints:w,maxContours:w,maxComponentPoints:w,maxComponentContours:w,maxZones:w,maxTwilightPoints:w,maxStorage:w,maxFunctionDefs:w,maxInstructionDefs:w,maxStackElements:w,maxSizeOfInstructions:w,maxComponentElements:w,maxComponentDepth:w});function Ll(s,e,t=0){return s===1&&zl[t]?zl[t]:Tf[s][e]}const Cf=new Set(["x-mac-roman","x-mac-cyrillic","iso-8859-6","iso-8859-8"]),kf={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"},fa=new Map;function Sf(s){let e=fa.get(s);if(e)return e;let t=kf[s];if(t){let i=new Map;for(let r=0;r<t.length;r++)i.set(t.charCodeAt(r),128+r);return fa.set(s,i),i}if(Cf.has(s)){let i=new TextDecoder(s),r=new Uint8Array(128);for(let o=0;o<128;o++)r[o]=128+o;let n=new Map,a=i.decode(r);for(let o=0;o<128;o++)n.set(a.charCodeAt(o),128+o);return fa.set(s,n),n}}const Tf=[["utf-16be","utf-16be","utf-16be","utf-16be","utf-16be","utf-16be","utf-16be"],["x-mac-roman","shift-jis","big5","euc-kr","iso-8859-6","iso-8859-8","x-mac-greek","x-mac-cyrillic","x-mac-symbol","x-mac-devanagari","x-mac-gurmukhi","x-mac-gujarati","Oriya","Bengali","Tamil","Telugu","Kannada","Malayalam","Sinhalese","Burmese","Khmer","iso-8859-11","Laotian","Georgian","Armenian","gbk","Tibetan","Mongolian","Geez","x-mac-ce","Vietnamese","Sindhi"],["ascii",null,"iso-8859-1"],["symbol","utf-16be","shift-jis","gb18030","big5","euc-kr","johab",null,null,null,"utf-16be"]],zl={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"},Ef=[[],{0:"en",30:"fo",60:"ks",90:"rw",1:"fr",31:"fa",61:"ku",91:"rn",2:"de",32:"ru",62:"sd",92:"ny",3:"it",33:"zh",63:"bo",93:"mg",4:"nl",34:"nl-BE",64:"ne",94:"eo",5:"sv",35:"ga",65:"sa",128:"cy",6:"es",36:"sq",66:"mr",129:"eu",7:"da",37:"ro",67:"bn",130:"ca",8:"pt",38:"cz",68:"as",131:"la",9:"no",39:"sk",69:"gu",132:"qu",10:"he",40:"si",70:"pa",133:"gn",11:"ja",41:"yi",71:"or",134:"ay",12:"ar",42:"sr",72:"ml",135:"tt",13:"fi",43:"mk",73:"kn",136:"ug",14:"el",44:"bg",74:"ta",137:"dz",15:"is",45:"uk",75:"te",138:"jv",16:"mt",46:"be",76:"si",139:"su",17:"tr",47:"uz",77:"my",140:"gl",18:"hr",48:"kk",78:"km",141:"af",19:"zh-Hant",49:"az-Cyrl",79:"lo",142:"br",20:"ur",50:"az-Arab",80:"vi",143:"iu",21:"hi",51:"hy",81:"id",144:"gd",22:"th",52:"ka",82:"tl",145:"gv",23:"ko",53:"mo",83:"ms",146:"ga",24:"lt",54:"ky",84:"ms-Arab",147:"to",25:"pl",55:"tg",85:"am",148:"el-polyton",26:"hu",56:"tk",86:"ti",149:"kl",27:"es",57:"mn-CN",87:"om",150:"az",28:"lv",58:"mn",88:"so",151:"nn",29:"se",59:"ps",89:"sw"},[],{1078:"af",16393:"en-IN",1159:"rw",1074:"tn",1052:"sq",6153:"en-IE",1089:"sw",1115:"si",1156:"gsw",8201:"en-JM",1111:"kok",1051:"sk",1118:"am",17417:"en-MY",1042:"ko",1060:"sl",5121:"ar-DZ",5129:"en-NZ",1088:"ky",11274:"es-AR",15361:"ar-BH",13321:"en-PH",1108:"lo",16394:"es-BO",3073:"ar",18441:"en-SG",1062:"lv",13322:"es-CL",2049:"ar-IQ",7177:"en-ZA",1063:"lt",9226:"es-CO",11265:"ar-JO",11273:"en-TT",2094:"dsb",5130:"es-CR",13313:"ar-KW",2057:"en-GB",1134:"lb",7178:"es-DO",12289:"ar-LB",1033:"en",1071:"mk",12298:"es-EC",4097:"ar-LY",12297:"en-ZW",2110:"ms-BN",17418:"es-SV",6145:"ary",1061:"et",1086:"ms",4106:"es-GT",8193:"ar-OM",1080:"fo",1100:"ml",18442:"es-HN",16385:"ar-QA",1124:"fil",1082:"mt",2058:"es-MX",1025:"ar-SA",1035:"fi",1153:"mi",19466:"es-NI",10241:"ar-SY",2060:"fr-BE",1146:"arn",6154:"es-PA",7169:"aeb",3084:"fr-CA",1102:"mr",15370:"es-PY",14337:"ar-AE",1036:"fr",1148:"moh",10250:"es-PE",9217:"ar-YE",5132:"fr-LU",1104:"mn",20490:"es-PR",1067:"hy",6156:"fr-MC",2128:"mn-CN",3082:"es",1101:"as",4108:"fr-CH",1121:"ne",1034:"es",2092:"az-Cyrl",1122:"fy",1044:"nb",21514:"es-US",1068:"az",1110:"gl",2068:"nn",14346:"es-UY",1133:"ba",1079:"ka",1154:"oc",8202:"es-VE",1069:"eu",3079:"de-AT",1096:"or",2077:"sv-FI",1059:"be",1031:"de",1123:"ps",1053:"sv",2117:"bn",5127:"de-LI",1045:"pl",1114:"syr",1093:"bn-IN",4103:"de-LU",1046:"pt",1064:"tg",8218:"bs-Cyrl",2055:"de-CH",2070:"pt-PT",2143:"tzm",5146:"bs",1032:"el",1094:"pa",1097:"ta",1150:"br",1135:"kl",1131:"qu-BO",1092:"tt",1026:"bg",1095:"gu",2155:"qu-EC",1098:"te",1027:"ca",1128:"ha",3179:"qu",1054:"th",3076:"zh-HK",1037:"he",1048:"ro",1105:"bo",5124:"zh-MO",1081:"hi",1047:"rm",1055:"tr",2052:"zh",1038:"hu",1049:"ru",1090:"tk",4100:"zh-SG",1039:"is",9275:"smn",1152:"ug",1028:"zh-TW",1136:"ig",4155:"smj-NO",1058:"uk",1155:"co",1057:"id",5179:"smj",1070:"hsb",1050:"hr",1117:"iu",3131:"se-FI",1056:"ur",4122:"hr-BA",2141:"iu-Latn",1083:"se",2115:"uz-Cyrl",1029:"cs",2108:"ga",2107:"se-SE",1091:"uz",1030:"da",1076:"xh",8251:"sms",1066:"vi",1164:"prs",1077:"zu",6203:"sma-NO",1106:"cy",1125:"dv",1040:"it",7227:"sms",1160:"wo",2067:"nl-BE",2064:"it-CH",1103:"sa",1157:"sah",1043:"nl",1041:"ja",7194:"sr-Cyrl-BA",1144:"ii",3081:"en-AU",1099:"kn",3098:"sr",1130:"yo",10249:"en-BZ",1087:"kk",6170:"sr-Latn-BA",4105:"en-CA",1107:"km",2074:"sr-Latn",9225:"en-029",1158:"quc",1132:"nso"}];let $l=new F({platformID:w,encodingID:w,languageID:w,nameID:w,length:w,string:new P(w,new Me("length",s=>Ll(s.platformID,s.encodingID,s.languageID)),{type:"parent",relativeTo:s=>s.parent.stringOffset,allowNull:!1})}),_f=new F({length:w,tag:new P(w,new Me("length","utf16be"),{type:"parent",relativeTo:s=>s.stringOffset})});var Ds=new xe(w,{0:{count:w,stringOffset:w,records:new I($l,"count")},1:{count:w,stringOffset:w,records:new I($l,"count"),langTagCount:w,langTags:new I(_f,"langTagCount")}}),Af=Ds;const pa=["copyright","fontFamily","fontSubfamily","uniqueSubfamily","fullName","version","postscriptName","trademark","manufacturer","designer","description","vendorURL","designerURL","license","licenseURL",null,"preferredFamily","preferredSubfamily","compatibleFull","sampleText","postscriptCIDFontName","wwsFamilyName","wwsSubfamilyName"];Ds.process=function(s){var e={};for(let t of this.records){let i=Ef[t.platformID][t.languageID];i==null&&this.langTags!=null&&t.languageID>=32768&&(i=this.langTags[t.languageID-32768].tag),i==null&&(i=t.platformID+"-"+t.languageID);let r=t.nameID>=256?"fontFeatures":pa[t.nameID]||t.nameID;e[r]==null&&(e[r]={});let n=e[r];t.nameID>=256&&(n=n[t.nameID]||(n[t.nameID]={})),(typeof t.string=="string"||typeof n[i]!="string")&&(n[i]=t.string)}this.records=e},Ds.preEncode=function(){if(Array.isArray(this.records))return;this.version=0;let s=[];for(let e in this.records){let t=this.records[e];e!=="fontFeatures"&&(s.push({platformID:3,encodingID:1,languageID:1033,nameID:pa.indexOf(e),length:t.en.length*2,string:t.en}),e==="postscriptName"&&s.push({platformID:1,encodingID:0,languageID:0,nameID:pa.indexOf(e),length:t.en.length,string:t.en}))}this.records=s,this.count=s.length,this.stringOffset=Ds.size(this,null,!1)};var Nl=new xe(w,{header:{xAvgCharWidth:z,usWeightClass:w,usWidthClass:w,fsType:new Et(w,[null,"noEmbedding","viewOnly","editable",null,null,null,null,"noSubsetting","bitmapOnly"]),ySubscriptXSize:z,ySubscriptYSize:z,ySubscriptXOffset:z,ySubscriptYOffset:z,ySuperscriptXSize:z,ySuperscriptYSize:z,ySuperscriptXOffset:z,ySuperscriptYOffset:z,yStrikeoutSize:z,yStrikeoutPosition:z,sFamilyClass:z,panose:new I(H,10),ulCharRange:new I(O,4),vendorID:new Me(4),fsSelection:new Et(w,["italic","underscore","negative","outlined","strikeout","bold","regular","useTypoMetrics","wws","oblique"]),usFirstCharIndex:w,usLastCharIndex:w},0:{},1:{typoAscender:z,typoDescender:z,typoLineGap:z,winAscent:w,winDescent:w,codePageRange:new I(O,2)},2:{typoAscender:z,typoDescender:z,typoLineGap:z,winAscent:w,winDescent:w,codePageRange:new I(O,2),xHeight:z,capHeight:z,defaultChar:w,breakChar:w,maxContent:w},5:{typoAscender:z,typoDescender:z,typoLineGap:z,winAscent:w,winDescent:w,codePageRange:new I(O,2),xHeight:z,capHeight:z,defaultChar:w,breakChar:w,maxContent:w,usLowerOpticalPointSize:w,usUpperOpticalPointSize:w}});let ma=Nl.versions;ma[3]=ma[4]=ma[2];var If=Nl,Pf=new xe(He,{header:{italicAngle:He,underlinePosition:z,underlineThickness:z,isFixedPitch:O,minMemType42:O,maxMemType42:O,minMemType1:O,maxMemType1:O},1:{},2:{numberOfGlyphs:w,glyphNameIndex:new I(w,"numberOfGlyphs"),names:new I(new Me(H))},2.5:{numberOfGlyphs:w,offsets:new I(H,"numberOfGlyphs")},3:{},4:{map:new I(O,s=>s.parent.maxp.numGlyphs)}}),Of=new F({controlValues:new I(z)}),Ff=new F({instructions:new I(H)});let ga=new xe("head.indexToLocFormat",{0:{offsets:new I(w)},1:{offsets:new I(O)}});ga.process=function(){if(this.version===0&&!this._processed){for(let s=0;s<this.offsets.length;s++)this.offsets[s]<<=1;this._processed=!0}},ga.preEncode=function(){if(this.version===0&&this._processed!==!1){for(let s=0;s<this.offsets.length;s++)this.offsets[s]>>>=1;this._processed=!1}};var Rf=ga,Mf=new F({controlValueProgram:new I(H)}),Df=new I(new Bt);class Nt{getCFFVersion(e){for(;e&&!e.hdrSize;)e=e.parent;return e?e.version:-1}decode(e,t){let r=this.getCFFVersion(t)>=2?e.readUInt32BE():e.readUInt16BE();if(r===0)return[];let n=e.readUInt8(),a;if(n===1)a=H;else if(n===2)a=w;else if(n===3)a=gi;else if(n===4)a=O;else throw new Error(`Bad offset size in CFFIndex: ${n} ${e.pos}`);let o=[],c=e.pos+(r+1)*n-1,u=a.decode(e);for(let h=0;h<r;h++){let l=a.decode(e);if(this.type!=null){let d=e.pos;e.pos=c+u,t.length=l-u,o.push(this.type.decode(e,t)),e.pos=d}else o.push({offset:c+u,length:l-u});u=l}return e.pos=c+u,o}size(e,t){let i=2;if(e.length===0)return i;let r=this.type||new Bt,n=1;for(let o=0;o<e.length;o++){let c=e[o];n+=r.size(c,t)}let a;if(n<=255)a=H;else if(n<=65535)a=w;else if(n<=16777215)a=gi;else if(n<=4294967295)a=O;else throw new Error("Bad offset in CFFIndex");return i+=1+a.size()*(e.length+1),i+=n-1,i}encode(e,t,i){if(e.writeUInt16BE(t.length),t.length===0)return;let r=this.type||new Bt,n=[],a=1;for(let c of t){let u=r.size(c,i);n.push(u),a+=u}let o;if(a<=255)o=H;else if(a<=65535)o=w;else if(a<=16777215)o=gi;else if(a<=4294967295)o=O;else throw new Error("Bad offset in CFFIndex");e.writeUInt8(o.size()),a=1,o.encode(e,a);for(let c of n)a+=c,o.encode(e,a);for(let c of t)r.encode(e,c,i)}constructor(e){this.type=e}}const Nr=15,Ul=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"],Vl={".":10,E:11,"E-":12,"-":14};class ya{static decode(e,t){if(32<=t&&t<=246)return t-139;if(247<=t&&t<=250)return(t-247)*256+e.readUInt8()+108;if(251<=t&&t<=254)return-(t-251)*256-e.readUInt8()-108;if(t===28)return e.readInt16BE();if(t===29)return e.readInt32BE();if(t===30){let i="";for(;;){let r=e.readUInt8(),n=r>>4;if(n===Nr)break;i+=Ul[n];let a=r&15;if(a===Nr)break;i+=Ul[a]}return parseFloat(i)}return null}static size(e){if(e.forceLarge&&(e=32768),(e|0)!==e){let t=""+e;return 1+Math.ceil((t.length+1)/2)}else return-107<=e&&e<=107?1:108<=e&&e<=1131||-1131<=e&&e<=-108?2:-32768<=e&&e<=32767?3:5}static encode(e,t){let i=Number(t);if(t.forceLarge)return e.writeUInt8(29),e.writeInt32BE(i);if((i|0)!==i){e.writeUInt8(30);let n=""+i;for(let a=0;a<n.length;a+=2){let o=n[a],c=Vl[o]||+o;if(a===n.length-1)var r=Nr;else{let u=n[a+1];var r=Vl[u]||+u}e.writeUInt8(c<<4|r&15)}if(r!==Nr)return e.writeUInt8(Nr<<4)}else return-107<=i&&i<=107?e.writeUInt8(i+139):108<=i&&i<=1131?(i-=108,e.writeUInt8((i>>8)+247),e.writeUInt8(i&255)):-1131<=i&&i<=-108?(i=-i-108,e.writeUInt8((i>>8)+251),e.writeUInt8(i&255)):-32768<=i&&i<=32767?(e.writeUInt8(28),e.writeInt16BE(i)):(e.writeUInt8(29),e.writeInt32BE(i))}}class Bs{decodeOperands(e,t,i,r){if(Array.isArray(e))return r.map((n,a)=>this.decodeOperands(e[a],t,i,[n]));if(e.decode!=null)return e.decode(t,i,r);switch(e){case"number":case"offset":case"sid":return r[0];case"boolean":return!!r[0];default:return r}}encodeOperands(e,t,i,r){return Array.isArray(e)?r.map((n,a)=>this.encodeOperands(e[a],t,i,n)[0]):e.encode!=null?e.encode(t,r,i):typeof r=="number"?[r]:typeof r=="boolean"?[+r]:Array.isArray(r)?r:[r]}decode(e,t){let i=e.pos+t.length,r={},n=[];Object.defineProperties(r,{parent:{value:t},_startOffset:{value:e.pos}});for(let a in this.fields){let o=this.fields[a];r[o[1]]=o[3]}for(;e.pos<i;){let a=e.readUInt8();if(a<28){a===12&&(a=a<<8|e.readUInt8());let o=this.fields[a];if(!o)throw new Error(`Unknown operator ${a}`);let c=this.decodeOperands(o[2],e,r,n);c!=null&&(c instanceof Hn?Object.defineProperty(r,o[1],c):r[o[1]]=c),n=[]}else n.push(ya.decode(e,a))}return r}size(e,t,i=!0){let r={parent:t,val:e,pointerSize:0,startOffset:t.startOffset||0},n=0;for(let a in this.fields){let o=this.fields[a],c=e[o[1]];if(c==null||rl(c,o[3]))continue;let u=this.encodeOperands(o[2],null,r,c);for(let l of u)n+=ya.size(l);let h=Array.isArray(o[0])?o[0]:[o[0]];n+=h.length}return i&&(n+=r.pointerSize),n}encode(e,t,i){let r={pointers:[],startOffset:e.pos,parent:i,val:t,pointerSize:0};r.pointerOffset=e.pos+this.size(t,r,!1);for(let a of this.ops){let o=t[a[1]];if(o==null||rl(o,a[3]))continue;let c=this.encodeOperands(a[2],e,r,o);for(let h of c)ya.encode(e,h);let u=Array.isArray(a[0])?a[0]:[a[0]];for(let h of u)e.writeUInt8(h)}let n=0;for(;n<r.pointers.length;){let a=r.pointers[n++];a.type.encode(e,a.val,a.parent)}}constructor(e=[]){this.ops=e,this.fields={};for(let t of e){let i=Array.isArray(t[0])?t[0][0]<<8|t[0][1]:t[0];this.fields[i]=t}}}class _t extends P{decode(e,t,i){return this.offsetType={decode:()=>i[0]},super.decode(e,t,i)}encode(e,t,i){if(!e)return this.offsetType={size:()=>0},this.size(t,i),[new Hl(0)];let r=null;return this.offsetType={encode:(n,a)=>r=a},super.encode(e,t,i),[new Hl(r)]}constructor(e,t={}){t.type==null&&(t.type="global"),super(null,e,t)}}class Hl{valueOf(){return this.val}constructor(e){this.val=e,this.forceLarge=!0}}class Bf{static decode(e,t,i){let r=i.pop();for(;i.length>r;)i.pop()}}var ba=new Bs([[6,"BlueValues","delta",null],[7,"OtherBlues","delta",null],[8,"FamilyBlues","delta",null],[9,"FamilyOtherBlues","delta",null],[[12,9],"BlueScale","number",.039625],[[12,10],"BlueShift","number",7],[[12,11],"BlueFuzz","number",1],[10,"StdHW","number",null],[11,"StdVW","number",null],[[12,12],"StemSnapH","delta",null],[[12,13],"StemSnapV","delta",null],[[12,14],"ForceBold","boolean",!1],[[12,17],"LanguageGroup","number",0],[[12,18],"ExpansionFactor","number",.06],[[12,19],"initialRandomSeed","number",0],[20,"defaultWidthX","number",0],[21,"nominalWidthX","number",0],[22,"vsindex","number",0],[23,"blend",Bf,null],[19,"Subrs",new _t(new Nt,{type:"local"}),null]]),Ls=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"];let jl=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Lf=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Wl=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],zf=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],$f=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],Gl=new F({reserved:new $e(w),reqFeatureIndex:w,featureCount:w,featureIndexes:new I(w,"featureCount")}),Nf=new F({tag:new Me(4),langSys:new P(w,Gl,{type:"parent"})}),Uf=new F({defaultLangSys:new P(w,Gl),count:w,langSysRecords:new I(Nf,"count")}),Vf=new F({tag:new Me(4),script:new P(w,Uf,{type:"parent"})}),ql=new I(Vf,w),Hf=new F({version:w,nameID:w}),Xl=new F({featureParams:new P(w,Hf),lookupCount:w,lookupListIndexes:new I(w,"lookupCount")}),jf=new F({tag:new Me(4),feature:new P(w,Xl,{type:"parent"})}),Zl=new I(jf,w),Wf=new F({markAttachmentType:H,flags:new Et(H,["rightToLeft","ignoreBaseGlyphs","ignoreLigatures","ignoreMarks","useMarkFilteringSet"])});function zs(s){let e=new F({lookupType:w,flags:Wf,subTableCount:w,subTables:new I(new P(w,s),"subTableCount"),markFilteringSet:new Es(w,t=>t.flags.flags.useMarkFilteringSet)});return new Be(new P(w,e),w)}let Gf=new F({start:w,end:w,startCoverageIndex:w}),De=new xe(w,{1:{glyphCount:w,glyphs:new I(w,"glyphCount")},2:{rangeCount:w,rangeRecords:new I(Gf,"rangeCount")}}),qf=new F({start:w,end:w,class:w}),vi=new xe(w,{1:{startGlyph:w,glyphCount:w,classValueArray:new I(w,"glyphCount")},2:{classRangeCount:w,classRangeRecord:new I(qf,"classRangeCount")}}),wi=new F({a:w,b:w,deltaFormat:w}),Ur=new F({sequenceIndex:w,lookupListIndex:w}),Xf=new F({glyphCount:w,lookupCount:w,input:new I(w,s=>s.glyphCount-1),lookupRecords:new I(Ur,"lookupCount")}),Zf=new I(new P(w,Xf),w),Kf=new F({glyphCount:w,lookupCount:w,classes:new I(w,s=>s.glyphCount-1),lookupRecords:new I(Ur,"lookupCount")}),Yf=new I(new P(w,Kf),w),Kl=new xe(w,{1:{coverage:new P(w,De),ruleSetCount:w,ruleSets:new I(new P(w,Zf),"ruleSetCount")},2:{coverage:new P(w,De),classDef:new P(w,vi),classSetCnt:w,classSet:new I(new P(w,Yf),"classSetCnt")},3:{glyphCount:w,lookupCount:w,coverages:new I(new P(w,De),"glyphCount"),lookupRecords:new I(Ur,"lookupCount")}}),Jf=new F({backtrackGlyphCount:w,backtrack:new I(w,"backtrackGlyphCount"),inputGlyphCount:w,input:new I(w,s=>s.inputGlyphCount-1),lookaheadGlyphCount:w,lookahead:new I(w,"lookaheadGlyphCount"),lookupCount:w,lookupRecords:new I(Ur,"lookupCount")}),Yl=new I(new P(w,Jf),w),Jl=new xe(w,{1:{coverage:new P(w,De),chainCount:w,chainRuleSets:new I(new P(w,Yl),"chainCount")},2:{coverage:new P(w,De),backtrackClassDef:new P(w,vi),inputClassDef:new P(w,vi),lookaheadClassDef:new P(w,vi),chainCount:w,chainClassSet:new I(new P(w,Yl),"chainCount")},3:{backtrackGlyphCount:w,backtrackCoverage:new I(new P(w,De),"backtrackGlyphCount"),inputGlyphCount:w,inputCoverage:new I(new P(w,De),"inputGlyphCount"),lookaheadGlyphCount:w,lookaheadCoverage:new I(new P(w,De),"lookaheadGlyphCount"),lookupCount:w,lookupRecords:new I(Ur,"lookupCount")}}),Vr=new $i(16,"BE",14),Qf=new F({startCoord:Vr,peakCoord:Vr,endCoord:Vr}),ep=new F({axisCount:w,regionCount:w,variationRegions:new I(new I(Qf,"axisCount"),"regionCount")}),tp=new F({shortDeltas:new I(z,s=>s.parent.shortDeltaCount),regionDeltas:new I(Xe,s=>s.parent.regionIndexCount-s.parent.shortDeltaCount),deltas:s=>s.shortDeltas.concat(s.regionDeltas)}),ip=new F({itemCount:w,shortDeltaCount:w,regionIndexCount:w,regionIndexes:new I(w,"regionIndexCount"),deltaSets:new I(tp,"itemCount")}),$s=new F({format:w,variationRegionList:new P(O,ep),variationDataCount:w,itemVariationData:new I(new P(O,ip),"variationDataCount")}),rp=new xe(w,{1:{axisIndex:w,axisIndex:w,filterRangeMinValue:Vr,filterRangeMaxValue:Vr}}),sp=new F({conditionCount:w,conditionTable:new I(new P(O,rp),"conditionCount")}),np=new F({featureIndex:w,alternateFeatureTable:new P(O,Xl,{type:"parent"})}),ap=new F({version:He,substitutionCount:w,substitutions:new I(np,"substitutionCount")}),op=new F({conditionSet:new P(O,sp,{type:"parent"}),featureTableSubstitution:new P(O,ap,{type:"parent"})}),Ql=new F({majorVersion:w,minorVersion:w,featureVariationRecordCount:O,featureVariationRecords:new I(op,"featureVariationRecordCount")});class ec{decode(e,t,i){return this.predefinedOps[i[0]]?this.predefinedOps[i[0]]:this.type.decode(e,t,i)}size(e,t){return this.type.size(e,t)}encode(e,t,i){let r=this.predefinedOps.indexOf(t);return r!==-1?r:this.type.encode(e,t,i)}constructor(e,t){this.predefinedOps=e,this.type=t}}class lp extends Re{decode(e){return H.decode(e)&127}constructor(){super("UInt8")}}let tc=new F({first:w,nLeft:H}),cp=new F({first:w,nLeft:w}),up=new xe(new lp,{0:{nCodes:H,codes:new I(H,"nCodes")},1:{nRanges:H,ranges:new I(tc,"nRanges")}}),hp=new ec([jl,Lf],new _t(up,{lazy:!0}));class ic extends I{decode(e,t){let i=Dt(this.length,e,t),r=0,n=[];for(;r<i;){let a=this.type.decode(e,t);a.offset=r,r+=a.nLeft+1,n.push(a)}return n}}let dp=new xe(H,{0:{glyphs:new I(w,s=>s.parent.CharStrings.length-1)},1:{ranges:new ic(tc,s=>s.parent.CharStrings.length-1)},2:{ranges:new ic(cp,s=>s.parent.CharStrings.length-1)}}),fp=new ec([Wl,zf,$f],new _t(dp,{lazy:!0})),pp=new F({first:w,fd:H}),mp=new F({first:O,fd:w}),rc=new xe(H,{0:{fds:new I(H,s=>s.parent.CharStrings.length)},3:{nRanges:w,ranges:new I(pp,"nRanges"),sentinel:w},4:{nRanges:O,ranges:new I(mp,"nRanges"),sentinel:O}}),va=new _t(ba);class sc{decode(e,t,i){return t.length=i[0],va.decode(e,t,[i[1]])}size(e,t){return[ba.size(e,t,!1),va.size(e,t)[0]]}encode(e,t,i){return[ba.size(t,i,!1),va.encode(e,t,i)[0]]}}let nc=new Bs([[18,"Private",new sc,null],[[12,38],"FontName","sid",null],[[12,7],"FontMatrix","array",[.001,0,0,.001,0,0]],[[12,5],"PaintType","number",0]]),gp=new Bs([[[12,30],"ROS",["sid","sid","number"],null],[0,"version","sid",null],[1,"Notice","sid",null],[[12,0],"Copyright","sid",null],[2,"FullName","sid",null],[3,"FamilyName","sid",null],[4,"Weight","sid",null],[[12,1],"isFixedPitch","boolean",!1],[[12,2],"ItalicAngle","number",0],[[12,3],"UnderlinePosition","number",-100],[[12,4],"UnderlineThickness","number",50],[[12,5],"PaintType","number",0],[[12,6],"CharstringType","number",2],[[12,7],"FontMatrix","array",[.001,0,0,.001,0,0]],[13,"UniqueID","number",null],[5,"FontBBox","array",[0,0,0,0]],[[12,8],"StrokeWidth","number",0],[14,"XUID","array",null],[15,"charset",fp,Wl],[16,"Encoding",hp,jl],[17,"CharStrings",new _t(new Nt),null],[18,"Private",new sc,null],[[12,20],"SyntheticBase","number",null],[[12,21],"PostScript","sid",null],[[12,22],"BaseFontName","sid",null],[[12,23],"BaseFontBlend","delta",null],[[12,31],"CIDFontVersion","number",0],[[12,32],"CIDFontRevision","number",0],[[12,33],"CIDFontType","number",0],[[12,34],"CIDCount","number",8720],[[12,35],"UIDBase","number",null],[[12,37],"FDSelect",new _t(rc),null],[[12,36],"FDArray",new _t(new Nt(nc)),null],[[12,38],"FontName","sid",null]]),yp=new F({length:w,itemVariationStore:$s}),bp=new Bs([[[12,7],"FontMatrix","array",[.001,0,0,.001,0,0]],[17,"CharStrings",new _t(new Nt),null],[[12,37],"FDSelect",new _t(rc),null],[[12,36],"FDArray",new _t(new Nt(nc)),null],[24,"vstore",new _t(yp),null],[25,"maxstack","number",193]]);var ac=new xe(od,{1:{hdrSize:H,offSize:H,nameIndex:new Nt(new Me("length")),topDictIndex:new Nt(gp),stringIndex:new Nt(new Me("length")),globalSubrIndex:new Nt},2:{hdrSize:H,length:w,topDict:bp,globalSubrIndex:new Nt}});class wa{static decode(e){return new wa(e)}decode(){this.stream.pos;let e=ac.decode(this.stream);for(let t in e){let i=e[t];this[t]=i}if(this.version<2){if(this.topDictIndex.length!==1)throw new Error("Only a single font is allowed in CFF");this.topDict=this.topDictIndex[0]}return this.isCIDFont=this.topDict.ROS!=null,this}string(e){return this.version>=2?null:e<Ls.length?Ls[e]:this.stringIndex[e-Ls.length]}get postscriptName(){return this.version<2?this.nameIndex[0]:null}get fullName(){return this.string(this.topDict.FullName)}get familyName(){return this.string(this.topDict.FamilyName)}getCharString(e){return this.stream.pos=this.topDict.CharStrings[e].offset,this.stream.readBuffer(this.topDict.CharStrings[e].length)}getGlyphName(e){if(this.version>=2||this.isCIDFont)return null;let{charset:t}=this.topDict;if(Array.isArray(t))return t[e];if(e===0)return".notdef";switch(e-=1,t.version){case 0:return this.string(t.glyphs[e]);case 1:case 2:for(let i=0;i<t.ranges.length;i++){let r=t.ranges[i];if(r.offset<=e&&e<=r.offset+r.nLeft)return this.string(r.first+(e-r.offset))}break}return null}fdForGlyph(e){if(!this.topDict.FDSelect)return null;switch(this.topDict.FDSelect.version){case 0:return this.topDict.FDSelect.fds[e];case 3:case 4:let{ranges:t}=this.topDict.FDSelect,i=0,r=t.length-1;for(;i<=r;){let n=i+r>>1;if(e<t[n].first)r=n-1;else if(n<r&&e>=t[n+1].first)i=n+1;else return t[n].fd}default:throw new Error(`Unknown FDSelect version: ${this.topDict.FDSelect.version}`)}}privateDictForGlyph(e){if(this.topDict.FDSelect){let t=this.fdForGlyph(e);return this.topDict.FDArray[t]?this.topDict.FDArray[t].Private:null}return this.version<2?this.topDict.Private:this.topDict.FDArray[0].Private}constructor(e){this.stream=e,this.decode()}}var oc=wa;let vp=new F({glyphIndex:w,vertOriginY:z});var wp=new F({majorVersion:w,minorVersion:w,defaultVertOriginY:z,numVertOriginYMetrics:w,metrics:new I(vp,"numVertOriginYMetrics")});let dr=new F({height:H,width:H,horiBearingX:Xe,horiBearingY:Xe,horiAdvance:H,vertBearingX:Xe,vertBearingY:Xe,vertAdvance:H}),Ns=new F({height:H,width:H,bearingX:Xe,bearingY:Xe,advance:H}),lc=new F({glyph:w,xOffset:Xe,yOffset:Xe});class cc{}class xa{}new xe("version",{1:{metrics:Ns,data:cc},2:{metrics:Ns,data:xa},5:{data:xa},6:{metrics:dr,data:cc},7:{metrics:dr,data:xa},8:{metrics:Ns,pad:new $e(H),numComponents:w,components:new I(lc,"numComponents")},9:{metrics:dr,pad:new $e(H),numComponents:w,components:new I(lc,"numComponents")},17:{metrics:Ns,dataLen:O,data:new Bt("dataLen")},18:{metrics:dr,dataLen:O,data:new Bt("dataLen")},19:{dataLen:O,data:new Bt("dataLen")}});let uc=new F({ascender:Xe,descender:Xe,widthMax:H,caretSlopeNumerator:Xe,caretSlopeDenominator:Xe,caretOffset:Xe,minOriginSB:Xe,minAdvanceSB:Xe,maxBeforeBL:Xe,minAfterBL:Xe,pad:new $e(Xe,2)}),xp=new F({glyphCode:w,offset:w}),Cp=new xe(w,{header:{imageFormat:w,imageDataOffset:O},1:{offsetArray:new I(O,s=>s.parent.lastGlyphIndex-s.parent.firstGlyphIndex+1)},2:{imageSize:O,bigMetrics:dr},3:{offsetArray:new I(w,s=>s.parent.lastGlyphIndex-s.parent.firstGlyphIndex+1)},4:{numGlyphs:O,glyphArray:new I(xp,s=>s.numGlyphs+1)},5:{imageSize:O,bigMetrics:dr,numGlyphs:O,glyphCodeArray:new I(w,"numGlyphs")}}),kp=new F({firstGlyphIndex:w,lastGlyphIndex:w,subtable:new P(O,Cp)}),Sp=new F({indexSubTableArray:new P(O,new I(kp,1),{type:"parent"}),indexTablesSize:O,numberOfIndexSubTables:O,colorRef:O,hori:uc,vert:uc,startGlyphIndex:w,endGlyphIndex:w,ppemX:H,ppemY:H,bitDepth:H,flags:new Et(H,["horizontal","vertical"])});var Tp=new F({version:O,numSizes:O,sizes:new I(Sp,"numSizes")});let Ep=new F({ppem:w,resolution:w,imageOffsets:new I(new P(O,"void"),s=>s.parent.parent.maxp.numGlyphs+1)});var _p=new F({version:w,flags:new Et(w,["renderOutlines"]),numImgTables:O,imageTables:new I(new P(O,Ep),"numImgTables")});let Ap=new F({gid:w,paletteIndex:w}),Ip=new F({gid:w,firstLayerIndex:w,numLayers:w});var Pp=new F({version:w,numBaseGlyphRecords:w,baseGlyphRecord:new P(O,new I(Ip,"numBaseGlyphRecords")),layerRecords:new P(O,new I(Ap,"numLayerRecords"),{lazy:!0}),numLayerRecords:w});let Op=new F({blue:H,green:H,red:H,alpha:H});var Fp=new xe(w,{header:{numPaletteEntries:w,numPalettes:w,numColorRecords:w,colorRecords:new P(O,new I(Op,"numColorRecords")),colorRecordIndices:new I(w,"numPalettes")},0:{},1:{offsetPaletteTypeArray:new P(O,new I(O,"numPalettes")),offsetPaletteLabelArray:new P(O,new I(w,"numPalettes")),offsetPaletteEntryLabelArray:new P(O,new I(w,"numPaletteEntries"))}});let Hr=new xe(w,{1:{coordinate:z},2:{coordinate:z,referenceGlyph:w,baseCoordPoint:w},3:{coordinate:z,deviceTable:new P(w,wi)}}),Rp=new F({defaultIndex:w,baseCoordCount:w,baseCoords:new I(new P(w,Hr),"baseCoordCount")}),Mp=new F({tag:new Me(4),minCoord:new P(w,Hr,{type:"parent"}),maxCoord:new P(w,Hr,{type:"parent"})}),hc=new F({minCoord:new P(w,Hr),maxCoord:new P(w,Hr),featMinMaxCount:w,featMinMaxRecords:new I(Mp,"featMinMaxCount")}),Dp=new F({tag:new Me(4),minMax:new P(w,hc,{type:"parent"})}),Bp=new F({baseValues:new P(w,Rp),defaultMinMax:new P(w,hc),baseLangSysCount:w,baseLangSysRecords:new I(Dp,"baseLangSysCount")}),Lp=new F({tag:new Me(4),script:new P(w,Bp,{type:"parent"})}),zp=new I(Lp,w),$p=new I(new Me(4),w),dc=new F({baseTagList:new P(w,$p),baseScriptList:new P(w,zp)});var Np=new xe(O,{header:{horizAxis:new P(w,dc),vertAxis:new P(w,dc)},65536:{},65537:{itemVariationStore:new P(O,$s)}});let Up=new I(w,w),Vp=new F({coverage:new P(w,De),glyphCount:w,attachPoints:new I(new P(w,Up),"glyphCount")}),Hp=new xe(w,{1:{coordinate:z},2:{caretValuePoint:w},3:{coordinate:z,deviceTable:new P(w,wi)}}),jp=new I(new P(w,Hp),w),Wp=new F({coverage:new P(w,De),ligGlyphCount:w,ligGlyphs:new I(new P(w,jp),"ligGlyphCount")}),fc=new F({markSetTableFormat:w,markSetCount:w,coverage:new I(new P(O,De),"markSetCount")});var Gp=new xe(O,{header:{glyphClassDef:new P(w,vi),attachList:new P(w,Vp),ligCaretList:new P(w,Wp),markAttachClassDef:new P(w,vi)},65536:{},65538:{markGlyphSetsDef:new P(w,fc)},65539:{markGlyphSetsDef:new P(w,fc),itemVariationStore:new P(O,$s)}});let fr=new Et(w,["xPlacement","yPlacement","xAdvance","yAdvance","xPlaDevice","yPlaDevice","xAdvDevice","yAdvDevice"]),qp={xPlacement:z,yPlacement:z,xAdvance:z,yAdvance:z,xPlaDevice:new P(w,wi,{type:"global",relativeTo:s=>s.rel}),yPlaDevice:new P(w,wi,{type:"global",relativeTo:s=>s.rel}),xAdvDevice:new P(w,wi,{type:"global",relativeTo:s=>s.rel}),yAdvDevice:new P(w,wi,{type:"global",relativeTo:s=>s.rel})};class pr{buildStruct(e){let t=e;for(;!t[this.key]&&t.parent;)t=t.parent;if(!t[this.key])return;let i={};i.rel=()=>t._startOffset;let r=t[this.key];for(let n in r)r[n]&&(i[n]=qp[n]);return new F(i)}size(e,t){return this.buildStruct(t).size(e,t)}decode(e,t){let i=this.buildStruct(t).decode(e,t);return delete i.rel,i}constructor(e="valueFormat"){this.key=e}}let Xp=new F({secondGlyph:w,value1:new pr("valueFormat1"),value2:new pr("valueFormat2")}),Zp=new I(Xp,w),Kp=new F({value1:new pr("valueFormat1"),value2:new pr("valueFormat2")}),jr=new xe(w,{1:{xCoordinate:z,yCoordinate:z},2:{xCoordinate:z,yCoordinate:z,anchorPoint:w},3:{xCoordinate:z,yCoordinate:z,xDeviceTable:new P(w,wi),yDeviceTable:new P(w,wi)}}),Yp=new F({entryAnchor:new P(w,jr,{type:"parent"}),exitAnchor:new P(w,jr,{type:"parent"})}),Jp=new F({class:w,markAnchor:new P(w,jr,{type:"parent"})}),Ca=new I(Jp,w),Qp=new I(new P(w,jr),s=>s.parent.classCount),pc=new I(Qp,w),em=new I(new P(w,jr),s=>s.parent.parent.classCount),tm=new I(em,w),im=new I(new P(w,tm),w),Wr=new xe("lookupType",{1:new xe(w,{1:{coverage:new P(w,De),valueFormat:fr,value:new pr},2:{coverage:new P(w,De),valueFormat:fr,valueCount:w,values:new Be(new pr,"valueCount")}}),2:new xe(w,{1:{coverage:new P(w,De),valueFormat1:fr,valueFormat2:fr,pairSetCount:w,pairSets:new Be(new P(w,Zp),"pairSetCount")},2:{coverage:new P(w,De),valueFormat1:fr,valueFormat2:fr,classDef1:new P(w,vi),classDef2:new P(w,vi),class1Count:w,class2Count:w,classRecords:new Be(new Be(Kp,"class2Count"),"class1Count")}}),3:{format:w,coverage:new P(w,De),entryExitCount:w,entryExitRecords:new I(Yp,"entryExitCount")},4:{format:w,markCoverage:new P(w,De),baseCoverage:new P(w,De),classCount:w,markArray:new P(w,Ca),baseArray:new P(w,pc)},5:{format:w,markCoverage:new P(w,De),ligatureCoverage:new P(w,De),classCount:w,markArray:new P(w,Ca),ligatureArray:new P(w,im)},6:{format:w,mark1Coverage:new P(w,De),mark2Coverage:new P(w,De),classCount:w,mark1Array:new P(w,Ca),mark2Array:new P(w,pc)},7:Kl,8:Jl,9:{posFormat:w,lookupType:w,extension:new P(O,null)}});Wr.versions[9].extension.type=Wr;var rm=new xe(O,{header:{scriptList:new P(w,ql),featureList:new P(w,Zl),lookupList:new P(w,new zs(Wr))},65536:{},65537:{featureVariations:new P(O,Ql)}});let mc=new I(w,w),sm=mc,nm=new F({glyph:w,compCount:w,components:new I(w,s=>s.compCount-1)}),am=new I(new P(w,nm),w),ka=new xe("lookupType",{1:new xe(w,{1:{coverage:new P(w,De),deltaGlyphID:z},2:{coverage:new P(w,De),glyphCount:w,substitute:new Be(w,"glyphCount")}}),2:{substFormat:w,coverage:new P(w,De),count:w,sequences:new Be(new P(w,mc),"count")},3:{substFormat:w,coverage:new P(w,De),count:w,alternateSet:new Be(new P(w,sm),"count")},4:{substFormat:w,coverage:new P(w,De),count:w,ligatureSets:new Be(new P(w,am),"count")},5:Kl,6:Jl,7:{substFormat:w,lookupType:w,extension:new P(O,null)},8:{substFormat:w,coverage:new P(w,De),backtrackCoverage:new I(new P(w,De),"backtrackGlyphCount"),lookaheadGlyphCount:w,lookaheadCoverage:new I(new P(w,De),"lookaheadGlyphCount"),glyphCount:w,substitutes:new I(w,"glyphCount")}});ka.versions[7].extension.type=ka;var om=new xe(O,{header:{scriptList:new P(w,ql),featureList:new P(w,Zl),lookupList:new P(w,new zs(ka))},65536:{},65537:{featureVariations:new P(O,Ql)}});let xi=new I(w,w),lm=new F({shrinkageEnableGSUB:new P(w,xi),shrinkageDisableGSUB:new P(w,xi),shrinkageEnableGPOS:new P(w,xi),shrinkageDisableGPOS:new P(w,xi),shrinkageJstfMax:new P(w,new zs(Wr)),extensionEnableGSUB:new P(w,xi),extensionDisableGSUB:new P(w,xi),extensionEnableGPOS:new P(w,xi),extensionDisableGPOS:new P(w,xi),extensionJstfMax:new P(w,new zs(Wr))}),gc=new I(new P(w,lm),w),cm=new F({tag:new Me(4),jstfLangSys:new P(w,gc)}),um=new F({extenderGlyphs:new P(w,new I(w,w)),defaultLangSys:new P(w,gc),langSysCount:w,langSysRecords:new I(cm,"langSysCount")}),hm=new F({tag:new Me(4),script:new P(w,um,{type:"parent"})});var dm=new F({version:O,scriptCount:w,scriptList:new I(hm,"scriptCount")});class fm{decode(e,t){switch(this.size(0,t)){case 1:return e.readUInt8();case 2:return e.readUInt16BE();case 3:return e.readUInt24BE();case 4:return e.readUInt32BE()}}size(e,t){return Dt(this._size,null,t)}constructor(e){this._size=e}}let pm=new F({entry:new fm(s=>((s.parent.entryFormat&48)>>4)+1),outerIndex:s=>s.entry>>(s.parent.entryFormat&15)+1,innerIndex:s=>s.entry&(1<<(s.parent.entryFormat&15)+1)-1}),Sa=new F({entryFormat:w,mapCount:w,mapData:new I(pm,"mapCount")});var mm=new F({majorVersion:w,minorVersion:w,itemVariationStore:new P(O,$s),advanceWidthMapping:new P(O,Sa),LSBMapping:new P(O,Sa),RSBMapping:new P(O,Sa)});let gm=new F({format:O,length:O,offset:O}),ym=new F({reserved:new $e(w,2),cbSignature:O,signature:new Bt("cbSignature")});var bm=new F({ulVersion:O,usNumSigs:w,usFlag:w,signatures:new I(gm,"usNumSigs"),signatureBlocks:new I(ym,"usNumSigs")});let vm=new F({rangeMaxPPEM:w,rangeGaspBehavior:new Et(w,["grayscale","gridfit","symmetricSmoothing","symmetricGridfit"])});var wm=new F({version:w,numRanges:w,gaspRanges:new I(vm,"numRanges")});let xm=new F({pixelSize:H,maximumWidth:H,widths:new I(H,s=>s.parent.parent.maxp.numGlyphs)});var Cm=new F({version:w,numRecords:z,sizeDeviceRecord:zi,records:new I(xm,"numRecords")});let km=new F({left:w,right:w,value:z}),yc=new F({firstGlyph:w,nGlyphs:w,offsets:new I(w,"nGlyphs"),max:s=>s.offsets.length&&Math.max.apply(Math,s.offsets)}),Sm=new F({off:s=>s._startOffset-s.parent.parent._startOffset,len:s=>((s.parent.leftTable.max-s.off)/s.parent.rowWidth+1)*(s.parent.rowWidth/2),values:new Be(z,"len")}),bc=new xe("format",{0:{nPairs:w,searchRange:w,entrySelector:w,rangeShift:w,pairs:new I(km,"nPairs")},2:{rowWidth:w,leftTable:new P(w,yc,{type:"parent"}),rightTable:new P(w,yc,{type:"parent"}),array:new P(w,Sm,{type:"parent"})},3:{glyphCount:w,kernValueCount:H,leftClassCount:H,rightClassCount:H,flags:H,kernValue:new I(z,"kernValueCount"),leftClass:new I(H,"glyphCount"),rightClass:new I(H,"glyphCount"),kernIndex:new I(H,s=>s.leftClassCount*s.rightClassCount)}}),vc=new xe("version",{0:{subVersion:w,length:w,format:H,coverage:new Et(H,["horizontal","minimum","crossStream","override"]),subtable:bc,padding:new $e(H,s=>s.length-s._currentOffset)},1:{length:O,coverage:new Et(H,[null,null,null,null,null,"variation","crossStream","vertical"]),format:H,tupleIndex:w,subtable:bc,padding:new $e(H,s=>s.length-s._currentOffset)}});var Tm=new xe(w,{0:{nTables:w,tables:new I(vc,"nTables")},1:{reserved:new $e(w),nTables:O,tables:new I(vc,"nTables")}}),Em=new F({version:w,numGlyphs:w,yPels:new I(H,"numGlyphs")}),_m=new F({version:w,fontNumber:O,pitch:w,xHeight:w,style:w,typeFamily:w,capHeight:w,symbolSet:w,typeface:new Me(16),characterComplement:new Me(8),fileName:new Me(6),strokeWeight:new Me(1),widthType:new Me(1),serifStyle:H,reserved:new $e(H)});let Am=new F({bCharSet:H,xRatio:H,yStartRatio:H,yEndRatio:H}),Im=new F({yPelHeight:w,yMax:z,yMin:z}),Pm=new F({recs:w,startsz:H,endsz:H,entries:new I(Im,"recs")});var Om=new F({version:w,numRecs:w,numRatios:w,ratioRanges:new I(Am,"numRatios"),offsets:new I(w,"numRatios"),groups:new I(Pm,"numRecs")}),Fm=new F({version:w,ascent:z,descent:z,lineGap:z,advanceHeightMax:z,minTopSideBearing:z,minBottomSideBearing:z,yMaxExtent:z,caretSlopeRise:z,caretSlopeRun:z,caretOffset:z,reserved:new $e(z,4),metricDataFormat:z,numberOfMetrics:w});let Rm=new F({advance:w,bearing:z});var Mm=new F({metrics:new Be(Rm,s=>s.parent.vhea.numberOfMetrics),bearings:new Be(z,s=>s.parent.maxp.numGlyphs-s.parent.vhea.numberOfMetrics)});let wc=new $i(16,"BE",14),Dm=new F({fromCoord:wc,toCoord:wc}),Bm=new F({pairCount:w,correspondence:new I(Dm,"pairCount")});var Lm=new F({version:He,axisCount:O,segment:new I(Bm,"axisCount")});class zm{getItem(e){if(this._items[e]==null){let t=this.stream.pos;this.stream.pos=this.base+this.type.size(null,this.parent)*e,this._items[e]=this.type.decode(this.stream,this.parent),this.stream.pos=t}return this._items[e]}inspect(){return`[UnboundedArray ${this.type.constructor.name}]`}constructor(e,t,i){this.type=e,this.stream=t,this.parent=i,this.base=this.stream.pos,this._items=[]}}class Ut extends I{decode(e,t){return new zm(this.type,e,t)}constructor(e){super(e,0)}}let Ci=function(s=w){class e{decode(o,c){return c=c.parent.parent,this.type.decode(o,c)}size(o,c){return c=c.parent.parent,this.type.size(o,c)}encode(o,c,u){return u=u.parent.parent,this.type.encode(o,c,u)}constructor(o){this.type=o}}s=new e(s);let t=new F({unitSize:w,nUnits:w,searchRange:w,entrySelector:w,rangeShift:w}),i=new F({lastGlyph:w,firstGlyph:w,value:s}),r=new F({lastGlyph:w,firstGlyph:w,values:new P(w,new I(s,a=>a.lastGlyph-a.firstGlyph+1),{type:"parent"})}),n=new F({glyph:w,value:s});return new xe(w,{0:{values:new Ut(s)},2:{binarySearchHeader:t,segments:new I(i,a=>a.binarySearchHeader.nUnits)},4:{binarySearchHeader:t,segments:new I(r,a=>a.binarySearchHeader.nUnits)},6:{binarySearchHeader:t,segments:new I(n,a=>a.binarySearchHeader.nUnits)},8:{firstGlyph:w,count:w,values:new I(s,"count")}})};function Us(s={},e=w){let t=Object.assign({newState:w,flags:w},s),i=new F(t),r=new Ut(new I(w,a=>a.nClasses));return new F({nClasses:O,classTable:new P(O,new Ci(e)),stateArray:new P(O,r),entryTable:new P(O,new Ut(i))})}function $m(s={},e=w){let t=new F({version(){return 8},firstGlyph:w,values:new I(H,w)}),i=Object.assign({newStateOffset:w,newState:o=>(o.newStateOffset-(o.parent.stateArray.base-o.parent._startOffset))/o.parent.nClasses,flags:w},s),r=new F(i),n=new Ut(new I(H,o=>o.nClasses));return new F({nClasses:w,classTable:new P(w,t),stateArray:new P(w,n),entryTable:new P(w,new Ut(r))})}let Nm=new xe("format",{0:{deltas:new I(z,32)},1:{deltas:new I(z,32),mappingData:new Ci(w)},2:{standardGlyph:w,controlPoints:new I(w,32)},3:{standardGlyph:w,controlPoints:new I(w,32),mappingData:new Ci(w)}});var Um=new F({version:He,format:w,defaultBaseline:w,subtable:Nm});let Vm=new F({setting:w,nameIndex:z,name:s=>s.parent.parent.parent.name.records.fontFeatures[s.nameIndex]}),Hm=new F({feature:w,nSettings:w,settingTable:new P(O,new I(Vm,"nSettings"),{type:"parent"}),featureFlags:new Et(H,[null,null,null,null,null,null,"hasDefault","exclusive"]),defaultSetting:H,nameIndex:z,name:s=>s.parent.parent.name.records.fontFeatures[s.nameIndex]});var jm=new F({version:He,featureNameCount:w,reserved1:new $e(w),reserved2:new $e(O),featureNames:new I(Hm,"featureNameCount")});let Wm=new F({axisTag:new Me(4),minValue:He,defaultValue:He,maxValue:He,flags:w,nameID:w,name:s=>s.parent.parent.name.records.fontFeatures[s.nameID]}),Gm=new F({nameID:w,name:s=>s.parent.parent.name.records.fontFeatures[s.nameID],flags:w,coord:new I(He,s=>s.parent.axisCount),postscriptNameID:new Es(w,s=>s.parent.instanceSize-s._currentOffset>0)});var qm=new F({version:He,offsetToData:w,countSizePairs:w,axisCount:w,axisSize:w,instanceCount:w,instanceSize:w,axis:new I(Wm,"axisCount"),instance:new I(Gm,"instanceCount")});let Xm=new $i(16,"BE",14);class Zm{static decode(e,t){return t.flags?e.readUInt32BE():e.readUInt16BE()*2}}var Km=new F({version:w,reserved:new $e(w),axisCount:w,globalCoordCount:w,globalCoords:new P(O,new I(new I(Xm,"axisCount"),"globalCoordCount")),glyphCount:w,flags:w,offsetToData:O,offsets:new I(new P(Zm,"void",{relativeTo:s=>s.offsetToData,allowNull:!1}),s=>s.glyphCount+1)});let Ym=new F({length:w,coverage:w,subFeatureFlags:O,stateTable:new $m}),Jm=new F({justClass:O,beforeGrowLimit:He,beforeShrinkLimit:He,afterGrowLimit:He,afterShrinkLimit:He,growFlags:w,shrinkFlags:w}),Qm=new I(Jm,O),eg=new xe("actionType",{0:{lowerLimit:He,upperLimit:He,order:w,glyphs:new I(w,w)},1:{addGlyph:w},2:{substThreshold:He,addGlyph:w,substGlyph:w},3:{},4:{variationAxis:O,minimumLimit:He,noStretchValue:He,maximumLimit:He},5:{flags:w,glyph:w}}),tg=new F({actionClass:w,actionType:w,actionLength:O,actionData:eg,padding:new $e(H,s=>s.actionLength-s._currentOffset)}),ig=new I(tg,O),rg=new F({lookupTable:new Ci(new P(w,ig))}),xc=new F({classTable:new P(w,Ym,{type:"parent"}),wdcOffset:w,postCompensationTable:new P(w,rg,{type:"parent"}),widthDeltaClusters:new Ci(new P(w,Qm,{type:"parent",relativeTo:s=>s.wdcOffset}))});var sg=new F({version:O,format:w,horizontal:new P(w,xc),vertical:new P(w,xc)});let ng={action:w},ag={markIndex:w,currentIndex:w},og={currentInsertIndex:w,markedInsertIndex:w},lg=new F({items:new Ut(new P(O,new Ci))}),cg=new xe("type",{0:{stateTable:new Us},1:{stateTable:new Us(ag),substitutionTable:new P(O,lg)},2:{stateTable:new Us(ng),ligatureActions:new P(O,new Ut(O)),components:new P(O,new Ut(w)),ligatureList:new P(O,new Ut(w))},4:{lookupTable:new Ci},5:{stateTable:new Us(og),insertionActions:new P(O,new Ut(w))}}),ug=new F({length:O,coverage:gi,type:H,subFeatureFlags:O,table:cg,padding:new $e(H,s=>s.length-s._currentOffset)}),hg=new F({featureType:w,featureSetting:w,enableFlags:O,disableFlags:O}),dg=new F({defaultFlags:O,chainLength:O,nFeatureEntries:O,nSubtables:O,features:new I(hg,"nFeatureEntries"),subtables:new I(ug,"nSubtables")});var fg=new F({version:w,unused:new $e(w),nChains:O,chains:new I(dg,"nChains")});let pg=new F({left:z,top:z,right:z,bottom:z});var mg=new F({version:He,format:w,lookupTable:new Ci(pg)});let ge={};var Vs=ge;ge.cmap=gf,ge.head=yf,ge.hhea=bf,ge.hmtx=wf,ge.maxp=xf,ge.name=Af,ge["OS/2"]=If,ge.post=Pf,ge.fpgm=Ff,ge.loca=Rf,ge.prep=Mf,ge["cvt "]=Of,ge.glyf=Df,ge["CFF "]=oc,ge.CFF2=oc,ge.VORG=wp,ge.EBLC=Tp,ge.CBLC=ge.EBLC,ge.sbix=_p,ge.COLR=Pp,ge.CPAL=Fp,ge.BASE=Np,ge.GDEF=Gp,ge.GPOS=rm,ge.GSUB=om,ge.JSTF=dm,ge.HVAR=mm,ge.DSIG=bm,ge.gasp=wm,ge.hdmx=Cm,ge.kern=Tm,ge.LTSH=Em,ge.PCLT=_m,ge.VDMX=Om,ge.vhea=Fm,ge.vmtx=Mm,ge.avar=Lm,ge.bsln=Um,ge.feat=jm,ge.fvar=qm,ge.gvar=Km,ge.just=sg,ge.morx=fg,ge.opbd=mg;let gg=new F({tag:new Me(4),checkSum:O,offset:new P(O,"void",{type:"global"}),length:O}),Ta=new F({tag:new Me(4),numTables:w,searchRange:w,entrySelector:w,rangeShift:w,tables:new I(gg,"numTables")});Ta.process=function(){let s={};for(let e of this.tables)s[e.tag]=e;this.tables=s},Ta.preEncode=function(){if(!Array.isArray(this.tables)){let t=[];for(let i in this.tables){let r=this.tables[i];r&&t.push({tag:i,checkSum:0,offset:new Gn(Vs[i],r),length:Vs[i].size(r)})}this.tables=t}this.tag="true",this.numTables=this.tables.length;let s=Math.floor(Math.log(this.numTables)/Math.LN2),e=Math.pow(2,s);this.searchRange=e*16,this.entrySelector=Math.log(e)/Math.LN2,this.rangeShift=this.numTables*16-this.searchRange};var Cc=Ta;function Hs(s,e){let t=0,i=s.length-1;for(;t<=i;){let r=t+i>>1,n=e(s[r]);if(n<0)i=r-1;else if(n>0)t=r+1;else return r}return-1}function mr(s,e){let t=[];for(;s<e;)t.push(s++);return t}const js=new TextDecoder("ascii"),kc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gr=new Uint8Array(256);for(let s=0;s<kc.length;s++)Gr[kc.charCodeAt(s)]=s;function Ea(s){let e=s.length*.75;s[s.length-1]==="="&&(e--,s[s.length-2]==="="&&e--);let t=new Uint8Array(e),i=0;for(let r=0,n=s.length;r<n;r+=4){let a=Gr[s.charCodeAt(r)],o=Gr[s.charCodeAt(r+1)],c=Gr[s.charCodeAt(r+2)],u=Gr[s.charCodeAt(r+3)];t[i++]=a<<2|o>>4,t[i++]=(o&15)<<4|c>>2,t[i++]=(c&3)<<6|u&63}return t}class _a{findSubtable(e,t){for(let[i,r]of t)for(let n of e.tables)if(n.platformID===i&&n.encodingID===r)return n.table;return null}lookup(e,t){if(this.encoding)e=this.encoding.get(e)||e;else if(t){let r=this.getVariationSelector(e,t);if(r)return r}let i=this.cmap;switch(i.version){case 0:return i.codeMap.get(e)||0;case 4:{let r=0,n=i.segCount-1;for(;r<=n;){let a=r+n>>1;if(e<i.startCode.get(a))n=a-1;else if(e>i.endCode.get(a))r=a+1;else{let o=i.idRangeOffset.get(a),c;if(o===0)c=e+i.idDelta.get(a);else{let u=o/2+(e-i.startCode.get(a))-(i.segCount-a);c=i.glyphIndexArray.get(u)||0,c!==0&&(c+=i.idDelta.get(a))}return c&65535}}return 0}case 8:throw new Error("TODO: cmap format 8");case 6:case 10:return i.glyphIndices.get(e-i.firstCode)||0;case 12:case 13:{let r=0,n=i.nGroups-1;for(;r<=n;){let a=r+n>>1,o=i.groups.get(a);if(e<o.startCharCode)n=a-1;else if(e>o.endCharCode)r=a+1;else return i.version===12?o.glyphID+(e-o.startCharCode):o.glyphID}return 0}case 14:throw new Error("TODO: cmap format 14");default:throw new Error(`Unknown cmap format ${i.version}`)}}getVariationSelector(e,t){if(!this.uvs)return 0;let i=this.uvs.varSelectors.toArray(),r=Hs(i,a=>t-a.varSelector),n=i[r];return r!==-1&&n.defaultUVS&&(r=Hs(n.defaultUVS,a=>e<a.startUnicodeValue?-1:e>a.startUnicodeValue+a.additionalCount?1:0)),r!==-1&&n.nonDefaultUVS&&(r=Hs(n.nonDefaultUVS,a=>e-a.unicodeValue),r!==-1)?n.nonDefaultUVS[r].glyphID:0}getCharacterSet(){let e=this.cmap;switch(e.version){case 0:return mr(0,e.codeMap.length);case 4:{let t=[],i=e.endCode.toArray();for(let r=0;r<i.length;r++){let n=i[r]+1,a=e.startCode.get(r);t.push(...mr(a,n))}return t}case 8:throw new Error("TODO: cmap format 8");case 6:case 10:return mr(e.firstCode,e.firstCode+e.glyphIndices.length);case 12:case 13:{let t=[];for(let i of e.groups.toArray())t.push(...mr(i.startCharCode,i.endCharCode+1));return t}case 14:throw new Error("TODO: cmap format 14");default:throw new Error(`Unknown cmap format ${e.version}`)}}codePointsForGlyph(e){let t=this.cmap;switch(t.version){case 0:{let r=[];for(let n=0;n<256;n++)t.codeMap.get(n)===e&&r.push(n);return r}case 4:{let r=[];for(let n=0;n<t.segCount;n++){let a=t.endCode.get(n),o=t.startCode.get(n),c=t.idRangeOffset.get(n),u=t.idDelta.get(n);for(var i=o;i<=a;i++){let h=0;if(c===0)h=i+u;else{let l=c/2+(i-o)-(t.segCount-n);h=t.glyphIndexArray.get(l)||0,h!==0&&(h+=u)}h===e&&r.push(i)}}return r}case 12:{let r=[];for(let n of t.groups.toArray())e>=n.glyphID&&e<=n.glyphID+(n.endCharCode-n.startCharCode)&&r.push(n.startCharCode+(e-n.glyphID));return r}case 13:{let r=[];for(let n of t.groups.toArray())e===n.glyphID&&r.push(...mr(n.startCharCode,n.endCharCode+1));return r}default:throw new Error(`Unknown cmap format ${t.version}`)}}constructor(e){if(this.encoding=null,this.cmap=this.findSubtable(e,[[3,10],[0,6],[0,4],[3,1],[0,3],[0,2],[0,1],[0,0]]),!this.cmap)for(let t of e.tables){let i=Ll(t.platformID,t.encodingID,t.table.language-1),r=Sf(i);r&&(this.cmap=t.table,this.encoding=r)}if(!this.cmap)throw new Error("Could not find a supported cmap table");this.uvs=this.findSubtable(e,[[0,5]]),this.uvs&&this.uvs.version!==14&&(this.uvs=null)}}it([rt],_a.prototype,"getCharacterSet",null),it([rt],_a.prototype,"codePointsForGlyph",null);class yg{process(e,t){for(let i=0;i<e.length-1;i++){let r=e[i].id,n=e[i+1].id;t[i].xAdvance+=this.getKerning(r,n)}}getKerning(e,t){let i=0;for(let r of this.kern.tables){if(r.coverage.crossStream)continue;switch(r.version){case 0:if(!r.coverage.horizontal)continue;break;case 1:if(r.coverage.vertical||r.coverage.variation)continue;break;default:throw new Error(`Unsupported kerning table version ${r.version}`)}let n=0,a=r.subtable;switch(r.format){case 0:let o=Hs(a.pairs,function(l){return e-l.left||t-l.right});o>=0&&(n=a.pairs[o].value);break;case 2:let c=0,u=0;e>=a.leftTable.firstGlyph&&e<a.leftTable.firstGlyph+a.leftTable.nGlyphs?c=a.leftTable.offsets[e-a.leftTable.firstGlyph]:c=a.array.off,t>=a.rightTable.firstGlyph&&t<a.rightTable.firstGlyph+a.rightTable.nGlyphs&&(u=a.rightTable.offsets[t-a.rightTable.firstGlyph]);let h=(c+u-a.array.off)/2;n=a.array.values.get(h);break;case 3:if(e>=a.glyphCount||t>=a.glyphCount)return 0;n=a.kernValue[a.kernIndex[a.leftClass[e]*a.rightClassCount+a.rightClass[t]]];break;default:throw new Error(`Unsupported kerning sub-table format ${r.format}`)}r.coverage.override?i=n:i+=n}return i}constructor(e){this.kern=e.kern}}class bg{positionGlyphs(e,t){let i=0,r=0;for(let n=0;n<e.length;n++)e[n].isMark?r=n:(i!==r&&this.positionCluster(e,t,i,r),i=r=n);return i!==r&&this.positionCluster(e,t,i,r),t}positionCluster(e,t,i,r){let n=e[i],a=n.cbox.copy();n.codePoints.length>1&&(a.minX+=(n.codePoints.length-1)*a.width/n.codePoints.length);let o=-t[i].xAdvance,c=0,u=this.font.unitsPerEm/16;for(let h=i+1;h<=r;h++){let l=e[h],d=l.cbox,f=t[h],p=this.getCombiningClass(l.codePoints[0]);if(p!=="Not_Reordered"){switch(f.xOffset=f.yOffset=0,p){case"Double_Above":case"Double_Below":f.xOffset+=a.minX-d.width/2-d.minX;break;case"Attached_Below_Left":case"Below_Left":case"Above_Left":f.xOffset+=a.minX-d.minX;break;case"Attached_Above_Right":case"Below_Right":case"Above_Right":f.xOffset+=a.maxX-d.width-d.minX;break;default:f.xOffset+=a.minX+(a.width-d.width)/2-d.minX}switch(p){case"Double_Below":case"Below_Left":case"Below":case"Below_Right":case"Attached_Below_Left":case"Attached_Below":(p==="Attached_Below_Left"||p==="Attached_Below")&&(a.minY+=u),f.yOffset=-a.minY-d.maxY,a.minY+=d.height;break;case"Double_Above":case"Above_Left":case"Above":case"Above_Right":case"Attached_Above":case"Attached_Above_Right":(p==="Attached_Above"||p==="Attached_Above_Right")&&(a.maxY+=u),f.yOffset=a.maxY-d.minY,a.maxY+=d.height;break}f.xAdvance=f.yAdvance=0,f.xOffset+=o,f.yOffset+=c}else o-=f.xAdvance,c-=f.yAdvance}}getCombiningClass(e){let t=Gd(e);if((e&-256)===3584){if(t==="Not_Reordered")switch(e){case 3633:case 3636:case 3637:case 3638:case 3639:case 3655:case 3660:case 3645:case 3662:return"Above_Right";case 3761:case 3764:case 3765:case 3766:case 3767:case 3771:case 3788:case 3789:return"Above";case 3772:return"Below"}else if(e===3642)return"Below_Right"}switch(t){case"CCC10":case"CCC11":case"CCC12":case"CCC13":case"CCC14":case"CCC15":case"CCC16":case"CCC17":case"CCC18":case"CCC20":case"CCC22":return"Below";case"CCC23":return"Attached_Above";case"CCC24":return"Above_Right";case"CCC25":case"CCC19":return"Above_Left";case"CCC26":return"Above";case"CCC21":break;case"CCC27":case"CCC28":case"CCC30":case"CCC31":case"CCC33":case"CCC34":case"CCC35":case"CCC36":return"Above";case"CCC29":case"CCC32":return"Below";case"CCC103":return"Below_Right";case"CCC107":return"Above_Right";case"CCC118":return"Below";case"CCC122":return"Above";case"CCC129":case"CCC132":return"Below";case"CCC130":return"Above"}return t}constructor(e){this.font=e}}class ki{get width(){return this.maxX-this.minX}get height(){return this.maxY-this.minY}addPoint(e,t){Math.abs(e)!==1/0&&(e<this.minX&&(this.minX=e),e>this.maxX&&(this.maxX=e)),Math.abs(t)!==1/0&&(t<this.minY&&(this.minY=t),t>this.maxY&&(this.maxY=t))}copy(){return new ki(this.minX,this.minY,this.maxX,this.maxY)}constructor(e=1/0,t=1/0,i=-1/0,r=-1/0){this.minX=e,this.minY=t,this.maxX=i,this.maxY=r}}const gr={Caucasian_Albanian:"aghb",Arabic:"arab",Imperial_Aramaic:"armi",Armenian:"armn",Avestan:"avst",Balinese:"bali",Bamum:"bamu",Bassa_Vah:"bass",Batak:"batk",Bengali:["bng2","beng"],Bopomofo:"bopo",Brahmi:"brah",Braille:"brai",Buginese:"bugi",Buhid:"buhd",Chakma:"cakm",Canadian_Aboriginal:"cans",Carian:"cari",Cham:"cham",Cherokee:"cher",Coptic:"copt",Cypriot:"cprt",Cyrillic:"cyrl",Devanagari:["dev2","deva"],Deseret:"dsrt",Duployan:"dupl",Egyptian_Hieroglyphs:"egyp",Elbasan:"elba",Ethiopic:"ethi",Georgian:"geor",Glagolitic:"glag",Gothic:"goth",Grantha:"gran",Greek:"grek",Gujarati:["gjr2","gujr"],Gurmukhi:["gur2","guru"],Hangul:"hang",Han:"hani",Hanunoo:"hano",Hebrew:"hebr",Hiragana:"hira",Pahawh_Hmong:"hmng",Katakana_Or_Hiragana:"hrkt",Old_Italic:"ital",Javanese:"java",Kayah_Li:"kali",Katakana:"kana",Kharoshthi:"khar",Khmer:"khmr",Khojki:"khoj",Kannada:["knd2","knda"],Kaithi:"kthi",Tai_Tham:"lana",Lao:"lao ",Latin:"latn",Lepcha:"lepc",Limbu:"limb",Linear_A:"lina",Linear_B:"linb",Lisu:"lisu",Lycian:"lyci",Lydian:"lydi",Mahajani:"mahj",Mandaic:"mand",Manichaean:"mani",Mende_Kikakui:"mend",Meroitic_Cursive:"merc",Meroitic_Hieroglyphs:"mero",Malayalam:["mlm2","mlym"],Modi:"modi",Mongolian:"mong",Mro:"mroo",Meetei_Mayek:"mtei",Myanmar:["mym2","mymr"],Old_North_Arabian:"narb",Nabataean:"nbat",Nko:"nko ",Ogham:"ogam",Ol_Chiki:"olck",Old_Turkic:"orkh",Oriya:["ory2","orya"],Osmanya:"osma",Palmyrene:"palm",Pau_Cin_Hau:"pauc",Old_Permic:"perm",Phags_Pa:"phag",Inscriptional_Pahlavi:"phli",Psalter_Pahlavi:"phlp",Phoenician:"phnx",Miao:"plrd",Inscriptional_Parthian:"prti",Rejang:"rjng",Runic:"runr",Samaritan:"samr",Old_South_Arabian:"sarb",Saurashtra:"saur",Shavian:"shaw",Sharada:"shrd",Siddham:"sidd",Khudawadi:"sind",Sinhala:"sinh",Sora_Sompeng:"sora",Sundanese:"sund",Syloti_Nagri:"sylo",Syriac:"syrc",Tagbanwa:"tagb",Takri:"takr",Tai_Le:"tale",New_Tai_Lue:"talu",Tamil:["tml2","taml"],Tai_Viet:"tavt",Telugu:["tel2","telu"],Tifinagh:"tfng",Tagalog:"tglg",Thaana:"thaa",Thai:"thai",Tibetan:"tibt",Tirhuta:"tirh",Ugaritic:"ugar",Vai:"vai ",Warang_Citi:"wara",Old_Persian:"xpeo",Cuneiform:"xsux",Yi:"yi ",Inherited:"zinh",Common:"zyyy",Unknown:"zzzz"},Aa={};for(let s in gr){let e=gr[s];if(Array.isArray(e))for(let t of e)Aa[t]=s;else Aa[e]=s}function vg(s){return Aa[s]}function wg(s){let e=s.length,t=0;for(;t<e;){let i=s.charCodeAt(t++);if(55296<=i&&i<=56319&&t<e){let n=s.charCodeAt(t);56320<=n&&n<=57343&&(t++,i=((i&1023)<<10)+(n&1023)+65536)}let r=vl(i);if(r!=="Common"&&r!=="Inherited"&&r!=="Unknown")return gr[r]}return gr.Unknown}function xg(s){for(let e=0;e<s.length;e++){let t=s[e],i=vl(t);if(i!=="Common"&&i!=="Inherited"&&i!=="Unknown")return gr[i]}return gr.Unknown}const Cg={arab:!0,hebr:!0,syrc:!0,thaa:!0,cprt:!0,khar:!0,phnx:!0,"nko ":!0,lydi:!0,avst:!0,armi:!0,phli:!0,prti:!0,sarb:!0,orkh:!0,samr:!0,mand:!0,merc:!0,mero:!0,mani:!0,mend:!0,nbat:!0,narb:!0,palm:!0,phlp:!0};function Sc(s){return Cg[s]?"rtl":"ltr"}class kg{get advanceWidth(){let e=0;for(let t of this.positions)e+=t.xAdvance;return e}get advanceHeight(){let e=0;for(let t of this.positions)e+=t.yAdvance;return e}get bbox(){let e=new ki,t=0,i=0;for(let r=0;r<this.glyphs.length;r++){let n=this.glyphs[r],a=this.positions[r],o=n.bbox;e.addPoint(o.minX+t+a.xOffset,o.minY+i+a.yOffset),e.addPoint(o.maxX+t+a.xOffset,o.maxY+i+a.yOffset),t+=a.xAdvance,i+=a.yAdvance}return e}constructor(e,t,i,r,n){if(this.glyphs=e,this.positions=null,this.script=i,this.language=r||null,this.direction=n||Sc(i),this.features={},Array.isArray(t))for(let a of t)this.features[a]=!0;else typeof t=="object"&&(this.features=t)}}class Sg{constructor(e=0,t=0,i=0,r=0){this.xAdvance=e,this.yAdvance=t,this.xOffset=i,this.yOffset=r}}const ji={allTypographicFeatures:{code:0,exclusive:!1,allTypeFeatures:0},ligatures:{code:1,exclusive:!1,requiredLigatures:0,commonLigatures:2,rareLigatures:4,rebusPictures:8,diphthongLigatures:10,squaredLigatures:12,abbrevSquaredLigatures:14,symbolLigatures:16,contextualLigatures:18,historicalLigatures:20},cursiveConnection:{code:2,exclusive:!0,unconnected:0,partiallyConnected:1,cursive:2},letterCase:{code:3,exclusive:!0},verticalSubstitution:{code:4,exclusive:!1,substituteVerticalForms:0},linguisticRearrangement:{code:5,exclusive:!1,linguisticRearrangement:0},numberSpacing:{code:6,exclusive:!0,monospacedNumbers:0,proportionalNumbers:1,thirdWidthNumbers:2,quarterWidthNumbers:3},smartSwash:{code:8,exclusive:!1,wordInitialSwashes:0,wordFinalSwashes:2,nonFinalSwashes:8},diacritics:{code:9,exclusive:!0,showDiacritics:0,hideDiacritics:1,decomposeDiacritics:2},verticalPosition:{code:10,exclusive:!0,normalPosition:0,superiors:1,inferiors:2,ordinals:3,scientificInferiors:4},fractions:{code:11,exclusive:!0,noFractions:0,verticalFractions:1,diagonalFractions:2},overlappingCharacters:{code:13,exclusive:!1,preventOverlap:0},typographicExtras:{code:14,exclusive:!1,slashedZero:4},mathematicalExtras:{code:15,exclusive:!1,mathematicalGreek:10},ornamentSets:{code:16,exclusive:!0,noOrnaments:0,dingbats:1,piCharacters:2,fleurons:3,decorativeBorders:4,internationalSymbols:5,mathSymbols:6},characterAlternatives:{code:17,exclusive:!0,noAlternates:0},designComplexity:{code:18,exclusive:!0,designLevel1:0,designLevel2:1,designLevel3:2,designLevel4:3,designLevel5:4},styleOptions:{code:19,exclusive:!0,noStyleOptions:0,displayText:1,engravedText:2,illuminatedCaps:3,titlingCaps:4,tallCaps:5},characterShape:{code:20,exclusive:!0,traditionalCharacters:0,simplifiedCharacters:1,JIS1978Characters:2,JIS1983Characters:3,JIS1990Characters:4,traditionalAltOne:5,traditionalAltTwo:6,traditionalAltThree:7,traditionalAltFour:8,traditionalAltFive:9,expertCharacters:10,JIS2004Characters:11,hojoCharacters:12,NLCCharacters:13,traditionalNamesCharacters:14},numberCase:{code:21,exclusive:!0,lowerCaseNumbers:0,upperCaseNumbers:1},textSpacing:{code:22,exclusive:!0,proportionalText:0,monospacedText:1,halfWidthText:2,thirdWidthText:3,quarterWidthText:4,altProportionalText:5,altHalfWidthText:6},transliteration:{code:23,exclusive:!0,noTransliteration:0},annotation:{code:24,exclusive:!0,noAnnotation:0,boxAnnotation:1,roundedBoxAnnotation:2,circleAnnotation:3,invertedCircleAnnotation:4,parenthesisAnnotation:5,periodAnnotation:6,romanNumeralAnnotation:7,diamondAnnotation:8,invertedBoxAnnotation:9,invertedRoundedBoxAnnotation:10},kanaSpacing:{code:25,exclusive:!0,fullWidthKana:0,proportionalKana:1},ideographicSpacing:{code:26,exclusive:!0,fullWidthIdeographs:0,proportionalIdeographs:1,halfWidthIdeographs:2},unicodeDecomposition:{code:27,exclusive:!1,canonicalComposition:0,compatibilityComposition:2,transcodingComposition:4},rubyKana:{code:28,exclusive:!1,rubyKana:2},CJKSymbolAlternatives:{code:29,exclusive:!0,noCJKSymbolAlternatives:0,CJKSymbolAltOne:1,CJKSymbolAltTwo:2,CJKSymbolAltThree:3,CJKSymbolAltFour:4,CJKSymbolAltFive:5},ideographicAlternatives:{code:30,exclusive:!0,noIdeographicAlternatives:0,ideographicAltOne:1,ideographicAltTwo:2,ideographicAltThree:3,ideographicAltFour:4,ideographicAltFive:5},CJKVerticalRomanPlacement:{code:31,exclusive:!0,CJKVerticalRomanCentered:0,CJKVerticalRomanHBaseline:1},italicCJKRoman:{code:32,exclusive:!1,CJKItalicRoman:2},caseSensitiveLayout:{code:33,exclusive:!1,caseSensitiveLayout:0,caseSensitiveSpacing:2},alternateKana:{code:34,exclusive:!1,alternateHorizKana:0,alternateVertKana:2},stylisticAlternatives:{code:35,exclusive:!1,noStylisticAlternates:0,stylisticAltOne:2,stylisticAltTwo:4,stylisticAltThree:6,stylisticAltFour:8,stylisticAltFive:10,stylisticAltSix:12,stylisticAltSeven:14,stylisticAltEight:16,stylisticAltNine:18,stylisticAltTen:20,stylisticAltEleven:22,stylisticAltTwelve:24,stylisticAltThirteen:26,stylisticAltFourteen:28,stylisticAltFifteen:30,stylisticAltSixteen:32,stylisticAltSeventeen:34,stylisticAltEighteen:36,stylisticAltNineteen:38,stylisticAltTwenty:40},contextualAlternates:{code:36,exclusive:!1,contextualAlternates:0,swashAlternates:2,contextualSwashAlternates:4},lowerCase:{code:37,exclusive:!0,defaultLowerCase:0,lowerCaseSmallCaps:1,lowerCasePetiteCaps:2},upperCase:{code:38,exclusive:!0,defaultUpperCase:0,upperCaseSmallCaps:1,upperCasePetiteCaps:2},languageTag:{code:39,exclusive:!0},CJKRomanSpacing:{code:103,exclusive:!0,halfWidthCJKRoman:0,proportionalCJKRoman:1,defaultCJKRoman:2,fullWidthCJKRoman:3}},V=(s,e)=>[ji[s].code,ji[s][e]],Ws={rlig:V("ligatures","requiredLigatures"),clig:V("ligatures","contextualLigatures"),dlig:V("ligatures","rareLigatures"),hlig:V("ligatures","historicalLigatures"),liga:V("ligatures","commonLigatures"),hist:V("ligatures","historicalLigatures"),smcp:V("lowerCase","lowerCaseSmallCaps"),pcap:V("lowerCase","lowerCasePetiteCaps"),frac:V("fractions","diagonalFractions"),dnom:V("fractions","diagonalFractions"),numr:V("fractions","diagonalFractions"),afrc:V("fractions","verticalFractions"),case:V("caseSensitiveLayout","caseSensitiveLayout"),ccmp:V("unicodeDecomposition","canonicalComposition"),cpct:V("CJKVerticalRomanPlacement","CJKVerticalRomanCentered"),valt:V("CJKVerticalRomanPlacement","CJKVerticalRomanCentered"),swsh:V("contextualAlternates","swashAlternates"),cswh:V("contextualAlternates","contextualSwashAlternates"),curs:V("cursiveConnection","cursive"),c2pc:V("upperCase","upperCasePetiteCaps"),c2sc:V("upperCase","upperCaseSmallCaps"),init:V("smartSwash","wordInitialSwashes"),fin2:V("smartSwash","wordFinalSwashes"),medi:V("smartSwash","nonFinalSwashes"),med2:V("smartSwash","nonFinalSwashes"),fin3:V("smartSwash","wordFinalSwashes"),fina:V("smartSwash","wordFinalSwashes"),pkna:V("kanaSpacing","proportionalKana"),half:V("textSpacing","halfWidthText"),halt:V("textSpacing","altHalfWidthText"),hkna:V("alternateKana","alternateHorizKana"),vkna:V("alternateKana","alternateVertKana"),ital:V("italicCJKRoman","CJKItalicRoman"),lnum:V("numberCase","upperCaseNumbers"),onum:V("numberCase","lowerCaseNumbers"),mgrk:V("mathematicalExtras","mathematicalGreek"),calt:V("contextualAlternates","contextualAlternates"),vrt2:V("verticalSubstitution","substituteVerticalForms"),vert:V("verticalSubstitution","substituteVerticalForms"),tnum:V("numberSpacing","monospacedNumbers"),pnum:V("numberSpacing","proportionalNumbers"),sups:V("verticalPosition","superiors"),subs:V("verticalPosition","inferiors"),ordn:V("verticalPosition","ordinals"),pwid:V("textSpacing","proportionalText"),hwid:V("textSpacing","halfWidthText"),qwid:V("textSpacing","quarterWidthText"),twid:V("textSpacing","thirdWidthText"),fwid:V("textSpacing","proportionalText"),palt:V("textSpacing","altProportionalText"),trad:V("characterShape","traditionalCharacters"),smpl:V("characterShape","simplifiedCharacters"),jp78:V("characterShape","JIS1978Characters"),jp83:V("characterShape","JIS1983Characters"),jp90:V("characterShape","JIS1990Characters"),jp04:V("characterShape","JIS2004Characters"),expt:V("characterShape","expertCharacters"),hojo:V("characterShape","hojoCharacters"),nlck:V("characterShape","NLCCharacters"),tnam:V("characterShape","traditionalNamesCharacters"),ruby:V("rubyKana","rubyKana"),titl:V("styleOptions","titlingCaps"),zero:V("typographicExtras","slashedZero"),ss01:V("stylisticAlternatives","stylisticAltOne"),ss02:V("stylisticAlternatives","stylisticAltTwo"),ss03:V("stylisticAlternatives","stylisticAltThree"),ss04:V("stylisticAlternatives","stylisticAltFour"),ss05:V("stylisticAlternatives","stylisticAltFive"),ss06:V("stylisticAlternatives","stylisticAltSix"),ss07:V("stylisticAlternatives","stylisticAltSeven"),ss08:V("stylisticAlternatives","stylisticAltEight"),ss09:V("stylisticAlternatives","stylisticAltNine"),ss10:V("stylisticAlternatives","stylisticAltTen"),ss11:V("stylisticAlternatives","stylisticAltEleven"),ss12:V("stylisticAlternatives","stylisticAltTwelve"),ss13:V("stylisticAlternatives","stylisticAltThirteen"),ss14:V("stylisticAlternatives","stylisticAltFourteen"),ss15:V("stylisticAlternatives","stylisticAltFifteen"),ss16:V("stylisticAlternatives","stylisticAltSixteen"),ss17:V("stylisticAlternatives","stylisticAltSeventeen"),ss18:V("stylisticAlternatives","stylisticAltEighteen"),ss19:V("stylisticAlternatives","stylisticAltNineteen"),ss20:V("stylisticAlternatives","stylisticAltTwenty")};for(let s=1;s<=99;s++)Ws[`cv${`00${s}`.slice(-2)}`]=[ji.characterAlternatives.code,s];let Wi={};for(let s in Ws){let e=Ws[s];Wi[e[0]]==null&&(Wi[e[0]]={}),Wi[e[0]][e[1]]=s}function Tg(s){let e={};for(let t in s){let i;(i=Ws[t])&&(e[i[0]]==null&&(e[i[0]]={}),e[i[0]][i[1]]=s[t])}return e}function Tc(s){let[e,t]=s;if(isNaN(e))var i=ji[e]&&ji[e].code;else var i=e;if(isNaN(t))var r=ji[e]&&ji[e][t];else var r=t;return[i,r]}function Eg(s){let e={};if(Array.isArray(s))for(let t=0;t<s.length;t++){let i,r=Tc(s[t]);(i=Wi[r[0]]&&Wi[r[0]][r[1]])&&(e[i]=!0)}else if(typeof s=="object")for(let t in s){let i=s[t];for(let r in i){let n,a=Tc([t,r]);i[r]&&(n=Wi[a[0]]&&Wi[a[0]][a[1]])&&(e[n]=!0)}}return Object.keys(e)}class qr{lookup(e){switch(this.table.version){case 0:return this.table.values.getItem(e);case 2:case 4:{let r=0,n=this.table.binarySearchHeader.nUnits-1;for(;r<=n;){var t=r+n>>1,i=this.table.segments[t];if(i.firstGlyph===65535)return null;if(e<i.firstGlyph)n=t-1;else if(e>i.lastGlyph)r=t+1;else return this.table.version===2?i.value:i.values[e-i.firstGlyph]}return null}case 6:{let r=0,n=this.table.binarySearchHeader.nUnits-1;for(;r<=n;){var t=r+n>>1,i=this.table.segments[t];if(i.glyph===65535)return null;if(e<i.glyph)n=t-1;else if(e>i.glyph)r=t+1;else return i.value}return null}case 8:return this.table.values[e-this.table.firstGlyph];default:throw new Error(`Unknown lookup table format: ${this.table.version}`)}}glyphsForValue(e){let t=[];switch(this.table.version){case 2:case 4:for(let i of this.table.segments)if(this.table.version===2&&i.value===e)t.push(...mr(i.firstGlyph,i.lastGlyph+1));else for(let r=0;r<i.values.length;r++)i.values[r]===e&&t.push(i.firstGlyph+r);break;case 6:for(let i of this.table.segments)i.value===e&&t.push(i.glyph);break;case 8:for(let i=0;i<this.table.values.length;i++)this.table.values[i]===e&&t.push(this.table.firstGlyph+i);break;default:throw new Error(`Unknown lookup table format: ${this.table.version}`)}return t}constructor(e){this.table=e}}it([rt],qr.prototype,"glyphsForValue",null);const _g=0,Ec=0,_c=1,Ac=2,Ag=16384;class Ig{process(e,t,i){let r=_g,n=t?e.length-1:0,a=t?-1:1;for(;a===1&&n<=e.length||a===-1&&n>=-1;){let o=null,c=_c,u=!0;n===e.length||n===-1?c=Ec:(o=e[n],o.id===65535?c=Ac:(c=this.lookupTable.lookup(o.id),c==null&&(c=_c)));let l=this.stateTable.stateArray.getItem(r)[c],d=this.stateTable.entryTable.getItem(l);c!==Ec&&c!==Ac&&(i(o,d,n),u=!(d.flags&Ag)),r=d.newState,u&&(n+=a)}return e}traverse(e,t=0,i=new Set){if(i.has(t))return;i.add(t);let{nClasses:r,stateArray:n,entryTable:a}=this.stateTable,o=n.getItem(t);for(let c=4;c<r;c++){let u=o[c],h=a.getItem(u);for(let l of this.lookupTable.glyphsForValue(c))e.enter&&e.enter(l,h),h.newState!==0&&this.traverse(e,h.newState,i),e.exit&&e.exit(l,h)}}constructor(e){this.stateTable=e,this.lookupTable=new qr(e.classTable)}}const Pg=32768,Og=8192,Fg=15,Ic=32768,Rg=32768,Mg=8192,Dg=2147483648,Bg=1073741824,Lg=1073741823,Pc=4194304,zg=2048,$g=1024,Ng=992,Ug=31;class Oc{process(e,t={}){for(let r of this.morx.chains){let n=r.defaultFlags;for(let a of r.features){let o;(o=t[a.featureType])&&(o[a.featureSetting]?(n&=a.disableFlags,n|=a.enableFlags):o[a.featureSetting]===!1&&(n|=~a.disableFlags,n&=~a.enableFlags))}for(let a of r.subtables)a.subFeatureFlags&n&&this.processSubtable(a,e)}let i=e.length-1;for(;i>=0;)e[i].id===65535&&e.splice(i,1),i--;return e}processSubtable(e,t){if(this.subtable=e,this.glyphs=t,this.subtable.type===4){this.processNoncontextualSubstitutions(this.subtable,this.glyphs);return}this.ligatureStack=[],this.markedGlyph=null,this.firstGlyph=null,this.lastGlyph=null,this.markedIndex=null;let i=this.getStateMachine(e),r=this.getProcessor(),n=!!(this.subtable.coverage&Pc);return i.process(this.glyphs,n,r)}getStateMachine(e){return new Ig(e.table.stateTable)}getProcessor(){switch(this.subtable.type){case 0:return this.processIndicRearragement;case 1:return this.processContextualSubstitution;case 2:return this.processLigature;case 4:return this.processNoncontextualSubstitutions;case 5:return this.processGlyphInsertion;default:throw new Error(`Invalid morx subtable type: ${this.subtable.type}`)}}processIndicRearragement(e,t,i){t.flags&Pg&&(this.firstGlyph=i),t.flags&Og&&(this.lastGlyph=i),Vg(this.glyphs,t.flags&Fg,this.firstGlyph,this.lastGlyph)}processContextualSubstitution(e,t,i){let r=this.subtable.table.substitutionTable.items;if(t.markIndex!==65535){let a=r.getItem(t.markIndex),o=new qr(a);e=this.glyphs[this.markedGlyph];var n=o.lookup(e.id);n&&(this.glyphs[this.markedGlyph]=this.font.getGlyph(n,e.codePoints))}if(t.currentIndex!==65535){let a=r.getItem(t.currentIndex),o=new qr(a);e=this.glyphs[i];var n=o.lookup(e.id);n&&(this.glyphs[i]=this.font.getGlyph(n,e.codePoints))}t.flags&Ic&&(this.markedGlyph=i)}processLigature(e,t,i){if(t.flags&Rg&&this.ligatureStack.push(i),t.flags&Mg){let r=this.subtable.table.ligatureActions,n=this.subtable.table.components,a=this.subtable.table.ligatureList,o=t.action,c=!1,u=0,h=[],l=[];for(;!c;){let d=this.ligatureStack.pop();h.unshift(...this.glyphs[d].codePoints);let f=r.getItem(o++);c=!!(f&Dg);let p=!!(f&Bg),m=(f&Lg)<<2>>2;m+=this.glyphs[d].id;let b=n.getItem(m);if(u+=b,c||p){let g=a.getItem(u);this.glyphs[d]=this.font.getGlyph(g,h),l.push(d),u=0,h=[]}else this.glyphs[d]=this.font.getGlyph(65535)}this.ligatureStack.push(...l)}}processNoncontextualSubstitutions(e,t,i){let r=new qr(e.table.lookupTable);for(i=0;i<t.length;i++){let n=t[i];if(n.id!==65535){let a=r.lookup(n.id);a&&(t[i]=this.font.getGlyph(a,n.codePoints))}}}_insertGlyphs(e,t,i,r){let n=[];for(;i--;){let a=this.subtable.table.insertionActions.getItem(t++);n.push(this.font.getGlyph(a))}r||e++,this.glyphs.splice(e,0,...n)}processGlyphInsertion(e,t,i){if(t.flags&Ic&&(this.markedIndex=i),t.markedInsertIndex!==65535){let r=(t.flags&Ug)>>>5,n=!!(t.flags&$g);this._insertGlyphs(this.markedIndex,t.markedInsertIndex,r,n)}if(t.currentInsertIndex!==65535){let r=(t.flags&Ng)>>>5,n=!!(t.flags&zg);this._insertGlyphs(i,t.currentInsertIndex,r,n)}}getSupportedFeatures(){let e=[];for(let t of this.morx.chains)for(let i of t.features)e.push([i.featureType,i.featureSetting]);return e}generateInputs(e){return this.inputCache||this.generateInputCache(),this.inputCache[e]||[]}generateInputCache(){this.inputCache={};for(let e of this.morx.chains){let t=e.defaultFlags;for(let i of e.subtables)i.subFeatureFlags&t&&this.generateInputsForSubtable(i)}}generateInputsForSubtable(e){if(e.type!==2)return;if(!!(e.coverage&Pc))throw new Error("Reverse subtable, not supported.");this.subtable=e,this.ligatureStack=[];let i=this.getStateMachine(e),r=this.getProcessor(),n=[],a=[];this.glyphs=[],i.traverse({enter:(o,c)=>{let u=this.glyphs;a.push({glyphs:u.slice(),ligatureStack:this.ligatureStack.slice()});let h=this.font.getGlyph(o);n.push(h),u.push(n[n.length-1]),r(u[u.length-1],c,u.length-1);let l=0,d=0;for(let f=0;f<u.length&&l<=1;f++)u[f].id!==65535&&(l++,d=u[f].id);if(l===1){let f=n.map(m=>m.id),p=this.inputCache[d];p?p.push(f):this.inputCache[d]=[f]}},exit:()=>{({glyphs:this.glyphs,ligatureStack:this.ligatureStack}=a.pop()),n.pop()}})}constructor(e){this.processIndicRearragement=this.processIndicRearragement.bind(this),this.processContextualSubstitution=this.processContextualSubstitution.bind(this),this.processLigature=this.processLigature.bind(this),this.processNoncontextualSubstitutions=this.processNoncontextualSubstitutions.bind(this),this.processGlyphInsertion=this.processGlyphInsertion.bind(this),this.font=e,this.morx=e.morx,this.inputCache=null}}it([rt],Oc.prototype,"getStateMachine",null);function ut(s,e,t,i=!1,r=!1){let n=s.splice(t[0]-(t[1]-1),t[1]);r&&n.reverse();let a=s.splice(e[0],e[1],...n);return i&&a.reverse(),s.splice(t[0]-(e[1]-1),0,...a),s}function Vg(s,e,t,i){switch(e){case 0:return s;case 1:return ut(s,[t,1],[i,0]);case 2:return ut(s,[t,0],[i,1]);case 3:return ut(s,[t,1],[i,1]);case 4:return ut(s,[t,2],[i,0]);case 5:return ut(s,[t,2],[i,0],!0,!1);case 6:return ut(s,[t,0],[i,2]);case 7:return ut(s,[t,0],[i,2],!1,!0);case 8:return ut(s,[t,1],[i,2]);case 9:return ut(s,[t,1],[i,2],!1,!0);case 10:return ut(s,[t,2],[i,1]);case 11:return ut(s,[t,2],[i,1],!0,!1);case 12:return ut(s,[t,2],[i,2]);case 13:return ut(s,[t,2],[i,2],!0,!1);case 14:return ut(s,[t,2],[i,2],!1,!0);case 15:return ut(s,[t,2],[i,2],!0,!0);default:throw new Error(`Unknown verb: ${e}`)}}class Hg{substitute(e){e.direction==="rtl"&&e.glyphs.reverse(),this.morxProcessor.process(e.glyphs,Tg(e.features))}getAvailableFeatures(e,t){return Eg(this.morxProcessor.getSupportedFeatures())}stringsForGlyph(e){let t=this.morxProcessor.generateInputs(e),i=new Set;for(let r of t)this._addStrings(r,0,i,"");return i}_addStrings(e,t,i,r){let n=this.font._cmapProcessor.codePointsForGlyph(e[t]);for(let a of n){let o=r+String.fromCodePoint(a);t<e.length-1?this._addStrings(e,t+1,i,o):i.add(o)}}constructor(e){this.font=e,this.morxProcessor=new Oc(e),this.fallbackPosition=!1}}class jg{_addFeatures(e,t){let i=this.stages.length-1,r=this.stages[i];for(let n of e)this.allFeatures[n]==null&&(r.push(n),this.allFeatures[n]=i,t&&(this.globalFeatures[n]=!0))}add(e,t=!0){if(this.stages.length===0&&this.stages.push([]),typeof e=="string"&&(e=[e]),Array.isArray(e))this._addFeatures(e,t);else if(typeof e=="object")this._addFeatures(e.global||[],!0),this._addFeatures(e.local||[],!1);else throw new Error("Unsupported argument to ShapingPlan#add")}addStage(e,t){typeof e=="function"?this.stages.push(e,[]):(this.stages.push([]),this.add(e,t))}setFeatureOverrides(e){if(Array.isArray(e))this.add(e);else if(typeof e=="object"){for(let t in e)if(e[t])this.add(t);else if(this.allFeatures[t]!=null){let i=this.stages[this.allFeatures[t]];i.splice(i.indexOf(t),1),delete this.allFeatures[t],delete this.globalFeatures[t]}}}assignGlobalFeatures(e){for(let t of e)for(let i in this.globalFeatures)t.features[i]=!0}process(e,t,i){for(let r of this.stages)typeof r=="function"?i||r(this.font,t,this):r.length>0&&e.applyFeatures(r,t,i)}constructor(e,t,i){this.font=e,this.script=t,this.direction=i,this.stages=[],this.globalFeatures={},this.allFeatures={}}}const Wg=["rvrn"],Gg=["ccmp","locl","rlig","mark","mkmk"],qg=["frac","numr","dnom"],Xg=["calt","clig","liga","rclt","curs","kern"],Zg={ltr:["ltra","ltrm"],rtl:["rtla","rtlm"]};class Si{static plan(e,t,i){this.planPreprocessing(e),this.planFeatures(e),this.planPostprocessing(e,i),e.assignGlobalFeatures(t),this.assignFeatures(e,t)}static planPreprocessing(e){e.add({global:[...Wg,...Zg[e.direction]],local:qg})}static planFeatures(e){}static planPostprocessing(e,t){e.add([...Gg,...Xg]),e.setFeatureOverrides(t)}static assignFeatures(e,t){for(let i=0;i<t.length;i++){let r=t[i];if(r.codePoints[0]===8260){let n=i,a=i+1;for(;n>0&&wl(t[n-1].codePoints[0]);)t[n-1].features.numr=!0,t[n-1].features.frac=!0,n--;for(;a<t.length&&wl(t[a].codePoints[0]);)t[a].features.dnom=!0,t[a].features.frac=!0,a++;r.features.frac=!0,i=a-1}}}}ft(Si,"zeroMarkWidths","AFTER_GPOS");const Kg=new As(Ea("APABAAAAAAAAOAAAAf0BAv7tmi1MxDAUx7vtvjhAgcDgkEgEAnmXEBIMCYaEcygEiqBQ4FAkCE4ikUgMiiBJSAgSiUQSDMn9L9eSl6bddddug9t7yS/trevre+3r27pcNxZiG+yCfdCVv/9LeQxOwRm4AJegD27ALbgD9+ABPJF+z+BN/h7yDj5k/VOWX6SdmU5+wLWknggxDxaS8u0qiiX4uiz9XamQ3wzDMAzDMAzDMAzDVI/h959V/v7BMAzDMAzDMLlyNTNiMSdewVxbiA44B4/guz1qW58VYlMI0WsJ0W+N6kXw0spvPtdwhtkwnGM6uLaV4Xyzg3v3PM9DPfQ/sOg4xPWjipy31P8LTqbU304c/cLCUmWJLNB2Uz2U1KTeRKNmKHVMfbJC+/0loTZRH/W5cvEvBJPMbREkWt3FD1NcqXZBSpuE2Ad0PBehPtNrPtIEdYP+hiRt/V1jIiE69X4NT/uVZI3PUHE9bm5M7ePGdZWy951v7Nn6j8v1WWKP3mt6ttnsigx6VN7Vc0VomSSGqW2mGNP1muZPl7LfjNUaKNFtDGVf2fvE9O7VlBS5j333c5p/eeoOqcs1R/hIqDWLJ7TTlksirVT1SI7l8k4Yp+g3jafGcrU1RM6l9th80XOpnlN97bDNY4i4s61B0Si/ipa0uHMl6zqEjlFfCZm/TM8KmzQDjmuTAQ==")),Fc=["isol","fina","fin2","fin3","medi","med2","init"],Ia={Non_Joining:0,Transparent:6},ze="isol",Ti="fina",Pa="fin2",Yg="fin3",Gs="medi",qs="med2",Xs="init",_e=null,Jg=[[[_e,_e,0],[_e,ze,2],[_e,ze,1],[_e,ze,2],[_e,ze,1],[_e,ze,6]],[[_e,_e,0],[_e,ze,2],[_e,ze,1],[_e,ze,2],[_e,Pa,5],[_e,ze,6]],[[_e,_e,0],[_e,ze,2],[Xs,Ti,1],[Xs,Ti,3],[Xs,Ti,4],[Xs,Ti,6]],[[_e,_e,0],[_e,ze,2],[Gs,Ti,1],[Gs,Ti,3],[Gs,Ti,4],[Gs,Ti,6]],[[_e,_e,0],[_e,ze,2],[qs,ze,1],[qs,ze,2],[qs,Pa,5],[qs,ze,6]],[[_e,_e,0],[_e,ze,2],[ze,ze,1],[ze,ze,2],[ze,Pa,5],[ze,ze,6]],[[_e,_e,0],[_e,ze,2],[_e,ze,1],[_e,ze,2],[_e,Yg,5],[_e,ze,6]]];class Ei extends Si{static planFeatures(e){e.add(["ccmp","locl"]);for(let t=0;t<Fc.length;t++){let i=Fc[t];e.addStage(i,!1)}e.addStage("mset")}static assignFeatures(e,t){super.assignFeatures(e,t);let i=-1,r=0,n=[];for(let o=0;o<t.length;o++){let c,u;var a=t[o];let h=Qg(a.codePoints[0]);if(h===Ia.Transparent){n[o]=_e;continue}[u,c,r]=Jg[r][h],u!==_e&&i!==-1&&(n[i]=u),n[o]=c,i=o}for(let o=0;o<t.length;o++){let c;var a=t[o];(c=n[o])&&(a.features[c]=!0)}}}function Qg(s){let e=Kg.get(s);if(e)return e-1;let t=Ps(s);return t==="Mn"||t==="Me"||t==="Cf"?Ia.Transparent:Ia.Non_Joining}class ey{reset(e={},t=0){this.options=e,this.flags=e.flags||{},this.markAttachmentType=e.markAttachmentType||0,this.index=t}get cur(){return this.glyphs[this.index]||null}shouldIgnore(e){return this.flags.ignoreMarks&&e.isMark||this.flags.ignoreBaseGlyphs&&e.isBase||this.flags.ignoreLigatures&&e.isLigature||this.markAttachmentType&&e.isMark&&e.markAttachmentType!==this.markAttachmentType}move(e){for(this.index+=e;0<=this.index&&this.index<this.glyphs.length&&this.shouldIgnore(this.glyphs[this.index]);)this.index+=e;return 0>this.index||this.index>=this.glyphs.length?null:this.glyphs[this.index]}next(){return this.move(1)}prev(){return this.move(-1)}peek(e=1){let t=this.index,i=this.increment(e);return this.index=t,i}peekIndex(e=1){let t=this.index;this.increment(e);let i=this.index;return this.index=t,i}increment(e=1){let t=e<0?-1:1;for(e=Math.abs(e);e--;)this.move(t);return this.glyphs[this.index]}constructor(e,t){this.glyphs=e,this.reset(t)}}const ty=["DFLT","dflt","latn"];class Zs{findScript(e){if(this.table.scriptList==null)return null;Array.isArray(e)||(e=[e]);for(let t of e)for(let i of this.table.scriptList)if(i.tag===t)return i;return null}selectScript(e,t,i){let r=!1,n;if(!this.script||e!==this.scriptTag){if(n=this.findScript(e),n||(n=this.findScript(ty)),!n)return this.scriptTag;this.scriptTag=n.tag,this.script=n.script,this.language=null,this.languageTag=null,r=!0}if((!i||i!==this.direction)&&(this.direction=i||Sc(e)),t&&t.length<4&&(t+=" ".repeat(4-t.length)),!t||t!==this.languageTag){this.language=null;for(let a of this.script.langSysRecords)if(a.tag===t){this.language=a.langSys,this.languageTag=a.tag;break}this.language||(this.language=this.script.defaultLangSys,this.languageTag=null),r=!0}if(r&&(this.features={},this.language))for(let a of this.language.featureIndexes){let o=this.table.featureList[a],c=this.substituteFeatureForVariations(a);this.features[o.tag]=c||o.feature}return this.scriptTag}lookupsForFeatures(e=[],t){let i=[];for(let r of e){let n=this.features[r];if(n)for(let a of n.lookupListIndexes)t&&t.indexOf(a)!==-1||i.push({feature:r,index:a,lookup:this.table.lookupList.get(a)})}return i.sort((r,n)=>r.index-n.index),i}substituteFeatureForVariations(e){if(this.variationsIndex===-1)return null;let i=this.table.featureVariations.featureVariationRecords[this.variationsIndex].featureTableSubstitution.substitutions;for(let r of i)if(r.featureIndex===e)return r.alternateFeatureTable;return null}findVariationsIndex(e){let t=this.table.featureVariations;if(!t)return-1;let i=t.featureVariationRecords;for(let r=0;r<i.length;r++){let n=i[r].conditionSet.conditionTable;if(this.variationConditionsMatch(n,e))return r}return-1}variationConditionsMatch(e,t){return e.every(i=>{let r=i.axisIndex<t.length?t[i.axisIndex]:0;return i.filterRangeMinValue<=r&&r<=i.filterRangeMaxValue})}applyFeatures(e,t,i){let r=this.lookupsForFeatures(e);this.applyLookups(r,t,i)}applyLookups(e,t,i){this.glyphs=t,this.positions=i,this.glyphIterator=new ey(t);for(let{feature:r,lookup:n}of e)for(this.currentFeature=r,this.glyphIterator.reset(n.flags);this.glyphIterator.index<t.length;){if(!(r in this.glyphIterator.cur.features)){this.glyphIterator.next();continue}for(let a of n.subTables)if(this.applyLookup(n.lookupType,a))break;this.glyphIterator.next()}}applyLookup(e,t){throw new Error("applyLookup must be implemented by subclasses")}applyLookupList(e){let t=this.glyphIterator.options,i=this.glyphIterator.index;for(let r of e){this.glyphIterator.reset(t,i),this.glyphIterator.increment(r.sequenceIndex);let n=this.table.lookupList.get(r.lookupListIndex);this.glyphIterator.reset(n.flags,this.glyphIterator.index);for(let a of n.subTables)if(this.applyLookup(n.lookupType,a))break}return this.glyphIterator.reset(t,i),!0}coverageIndex(e,t){switch(t==null&&(t=this.glyphIterator.cur.id),e.version){case 1:return e.glyphs.indexOf(t);case 2:for(let i of e.rangeRecords)if(i.start<=t&&t<=i.end)return i.startCoverageIndex+t-i.start;break}return-1}match(e,t,i,r){let n=this.glyphIterator.index,a=this.glyphIterator.increment(e),o=0;for(;o<t.length&&a&&i(t[o],a);)r&&r.push(this.glyphIterator.index),o++,a=this.glyphIterator.next();return this.glyphIterator.index=n,o<t.length?!1:r||!0}sequenceMatches(e,t){return this.match(e,t,(i,r)=>i===r.id)}sequenceMatchIndices(e,t){return this.match(e,t,(i,r)=>this.currentFeature in r.features?i===r.id:!1,[])}coverageSequenceMatches(e,t){return this.match(e,t,(i,r)=>this.coverageIndex(i,r.id)>=0)}getClassID(e,t){switch(t.version){case 1:let i=e-t.startGlyph;if(i>=0&&i<t.classValueArray.length)return t.classValueArray[i];break;case 2:for(let r of t.classRangeRecord)if(r.start<=e&&e<=r.end)return r.class;break}return 0}classSequenceMatches(e,t,i){return this.match(e,t,(r,n)=>r===this.getClassID(n.id,i))}applyContext(e){let t,i;switch(e.version){case 1:if(t=this.coverageIndex(e.coverage),t===-1)return!1;i=e.ruleSets[t];for(let r of i)if(this.sequenceMatches(1,r.input))return this.applyLookupList(r.lookupRecords);break;case 2:if(this.coverageIndex(e.coverage)===-1||(t=this.getClassID(this.glyphIterator.cur.id,e.classDef),t===-1))return!1;i=e.classSet[t];for(let r of i)if(this.classSequenceMatches(1,r.classes,e.classDef))return this.applyLookupList(r.lookupRecords);break;case 3:if(this.coverageSequenceMatches(0,e.coverages))return this.applyLookupList(e.lookupRecords);break}return!1}applyChainingContext(e){let t;switch(e.version){case 1:if(t=this.coverageIndex(e.coverage),t===-1)return!1;let i=e.chainRuleSets[t];for(let n of i)if(this.sequenceMatches(-n.backtrack.length,n.backtrack)&&this.sequenceMatches(1,n.input)&&this.sequenceMatches(1+n.input.length,n.lookahead))return this.applyLookupList(n.lookupRecords);break;case 2:if(this.coverageIndex(e.coverage)===-1)return!1;t=this.getClassID(this.glyphIterator.cur.id,e.inputClassDef);let r=e.chainClassSet[t];if(!r)return!1;for(let n of r)if(this.classSequenceMatches(-n.backtrack.length,n.backtrack,e.backtrackClassDef)&&this.classSequenceMatches(1,n.input,e.inputClassDef)&&this.classSequenceMatches(1+n.input.length,n.lookahead,e.lookaheadClassDef))return this.applyLookupList(n.lookupRecords);break;case 3:if(this.coverageSequenceMatches(-e.backtrackGlyphCount,e.backtrackCoverage)&&this.coverageSequenceMatches(0,e.inputCoverage)&&this.coverageSequenceMatches(e.inputGlyphCount,e.lookaheadCoverage))return this.applyLookupList(e.lookupRecords);break}return!1}constructor(e,t){this.font=e,this.table=t,this.script=null,this.scriptTag=null,this.language=null,this.languageTag=null,this.features={},this.lookups={},this.variationsIndex=e._variationProcessor?this.findVariationsIndex(e._variationProcessor.normalizedCoords):-1,this.selectScript(),this.glyphs=[],this.positions=[],this.ligatureID=1,this.currentFeature=null}}class At{get id(){return this._id}set id(e){this._id=e,this.substituted=!0;let t=this._font.GDEF;if(t&&t.glyphClassDef){let i=Zs.prototype.getClassID(e,t.glyphClassDef);this.isBase=i===1,this.isLigature=i===2,this.isMark=i===3,this.markAttachmentType=t.markAttachClassDef?Zs.prototype.getClassID(e,t.markAttachClassDef):0}else this.isMark=this.codePoints.length>0&&this.codePoints.every(xl),this.isBase=!this.isMark,this.isLigature=this.codePoints.length>1,this.markAttachmentType=0}copy(){return new At(this._font,this.id,this.codePoints,this.features)}constructor(e,t,i=[],r){if(this._font=e,this.codePoints=i,this.id=t,this.features={},Array.isArray(r))for(let n=0;n<r.length;n++){let a=r[n];this.features[a]=!0}else typeof r=="object"&&Object.assign(this.features,r);this.ligatureID=null,this.ligatureComponent=null,this.isLigated=!1,this.cursiveAttachment=null,this.markAttachment=null,this.shaperInfo=null,this.substituted=!1,this.isMultiplied=!1}}class Rc extends Si{static planFeatures(e){e.add(["ljmo","vjmo","tjmo"],!1)}static assignFeatures(e,t){let i=0,r=0;for(;r<t.length;){let n,o=t[r].codePoints[0],c=tn(o);switch([n,i]=vy[i][c],n){case ri:e.font.hasGlyphForCodePoint(o)||(r=Lc(t,r,e.font));break;case Fa:r=wy(t,r,e.font);break;case Ra:Cy(t,r,e.font);break;case Ma:r=ky(t,r,e.font);break}r++}}}ft(Rc,"zeroMarkWidths","NONE");const yr=44032,Mc=55204,iy=Mc-yr+1,Ks=4352,Ys=4449,Gi=4519,ry=19,Js=21,Xr=28,sy=Ks+ry-1,ny=Ys+Js-1,ay=Gi+Xr-1,Dc=9676,oy=s=>4352<=s&&s<=4447||43360<=s&&s<=43388,ly=s=>4448<=s&&s<=4519||55216<=s&&s<=55238,cy=s=>4520<=s&&s<=4607||55243<=s&&s<=55291,uy=s=>12334<=s&&s<=12335,hy=s=>yr<=s&&s<=Mc,dy=s=>s-yr<iy&&(s-yr)%Xr===0,fy=s=>Ks<=s&&s<=sy,py=s=>Ys<=s&&s<=ny,my=s=>1<=s&&s<=ay,gy=0,yy=1,Qs=2,Oa=3,en=4,Bc=5,by=6;function tn(s){return oy(s)?yy:ly(s)?Qs:cy(s)?Oa:dy(s)?en:hy(s)?Bc:uy(s)?by:gy}const pt=0,ri=1,Fa=2,Ra=4,Ma=5,vy=[[[pt,0],[pt,1],[pt,0],[pt,0],[ri,2],[ri,3],[Ma,0]],[[pt,0],[pt,1],[Fa,2],[pt,0],[ri,2],[ri,3],[Ma,0]],[[pt,0],[pt,1],[pt,0],[Fa,3],[ri,2],[ri,3],[Ra,0]],[[pt,0],[pt,1],[pt,0],[pt,0],[ri,2],[ri,3],[Ra,0]]];function Zr(s,e,t){return new At(s,s.glyphForCodePoint(e).id,[e],t)}function Lc(s,e,t){let i=s[e],n=i.codePoints[0]-yr,a=Gi+n%Xr;n=n/Xr|0;let o=Ks+n/Js|0,c=Ys+n%Js;if(!t.hasGlyphForCodePoint(o)||!t.hasGlyphForCodePoint(c)||a!==Gi&&!t.hasGlyphForCodePoint(a))return e;let u=Zr(t,o,i.features);u.features.ljmo=!0;let h=Zr(t,c,i.features);h.features.vjmo=!0;let l=[u,h];if(a>Gi){let d=Zr(t,a,i.features);d.features.tjmo=!0,l.push(d)}return s.splice(e,1,...l),e+l.length-1}function wy(s,e,t){let i=s[e],r=s[e].codePoints[0],n=tn(r),a=s[e-1].codePoints[0],o=tn(a),c,u,h,l;if(o===en&&n===Oa)c=a,l=i;else{n===Qs?(u=s[e-1],h=i):(u=s[e-2],h=s[e-1],l=i);let f=u.codePoints[0],p=h.codePoints[0];fy(f)&&py(p)&&(c=yr+((f-Ks)*Js+(p-Ys))*Xr)}let d=l&&l.codePoints[0]||Gi;if(c!=null&&(d===Gi||my(d))){let f=c+(d-Gi);if(t.hasGlyphForCodePoint(f)){let p=o===Qs?3:2;return s.splice(e-p+1,p,Zr(t,f,i.features)),e-p+1}}return u&&(u.features.ljmo=!0),h&&(h.features.vjmo=!0),l&&(l.features.tjmo=!0),o===en?(Lc(s,e-1,t),e+1):e}function xy(s){switch(tn(s)){case en:case Bc:return 1;case Qs:return 2;case Oa:return 3}}function Cy(s,e,t){let i=s[e],r=s[e].codePoints[0];if(t.glyphForCodePoint(r).advanceWidth===0)return;let n=s[e-1].codePoints[0],a=xy(n);return s.splice(e,1),s.splice(e-a,0,i)}function ky(s,e,t){let i=s[e],r=s[e].codePoints[0];if(t.hasGlyphForCodePoint(Dc)){let n=Zr(t,Dc,i.features),a=t.glyphForCodePoint(r).advanceWidth===0?e:e+1;s.splice(a,0,n),e++}return e}var zc={};zc=JSON.parse('{"stateTable":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,2,3,4,5,6,7,8,9,0,10,11,11,12,13,14,15,16,17],[0,0,0,18,19,20,21,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,28,29,30,31,32,33,0,34,0,0,35,36,0,0,37,0],[0,0,0,38,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,39,0,0,0,40,41,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,43,44,44,8,9,0,0,0,0,12,43,0,0,0,0],[0,0,0,0,43,44,44,8,9,0,0,0,0,0,43,0,0,0,0],[0,0,0,45,46,47,48,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,50,0,0,51,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,52,0,0,0,0,0,0,0,0],[0,0,0,53,54,55,56,57,58,0,59,0,0,60,61,0,0,62,0],[0,0,0,4,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,63,64,0,0,40,41,0,9,0,10,0,0,0,42,0,63,0,0],[0,2,3,4,5,6,7,8,9,0,10,11,11,12,13,0,2,16,0],[0,0,0,18,65,20,21,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,0,66,67,67,8,9,0,10,0,0,0,68,0,0,0,0],[0,0,0,69,0,70,70,0,71,0,72,0,0,0,0,0,0,0,0],[0,0,0,73,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,75,0,0,0,76,77,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,79,80,80,22,23,0,0,0,0,25,79,0,0,0,0],[0,0,0,18,19,20,74,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,81,82,83,84,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,86,0,0,87,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,88,0,0,0,0,0,0,0,0],[0,0,0,18,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,89,90,0,0,76,77,0,23,0,24,0,0,0,78,0,89,0,0],[0,0,0,0,91,92,92,22,23,0,24,0,0,0,93,0,0,0,0],[0,0,0,94,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,96,0,0,0,97,98,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,35,100,0,0,0,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,0,100,0,0,0,0],[0,0,0,102,103,104,105,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,107,0,0,108,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,109,0,0,0,0,0,0,0,0],[0,0,0,28,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,110,111,0,0,97,98,0,33,0,34,0,0,0,99,0,110,0,0],[0,0,0,0,112,113,113,32,33,0,34,0,0,0,114,0,0,0,0],[0,0,0,0,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,0,0,115,116,117,118,8,9,0,10,0,0,119,120,0,0,16,0],[0,0,0,0,0,121,121,0,9,0,10,0,0,0,42,0,0,0,0],[0,39,0,122,0,123,123,8,9,0,10,0,0,0,42,0,39,0,0],[0,124,64,0,0,0,0,0,0,0,0,0,0,0,0,0,124,0,0],[0,39,0,0,0,121,125,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,126,126,8,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,46,47,48,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,47,47,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,127,127,49,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,128,127,127,49,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,129,130,131,132,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,50,0,0,0,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,134,0,0,0,0,0,0,0,0],[0,0,0,135,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,136,0,0,0,137,138,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,140,141,141,57,58,0,0,0,0,60,140,0,0,0,0],[0,0,0,0,140,141,141,57,58,0,0,0,0,0,140,0,0,0,0],[0,0,0,142,143,144,145,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,147,0,0,148,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,149,0,0,0,0,0,0,0,0],[0,0,0,53,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,150,151,0,0,137,138,0,58,0,59,0,0,0,139,0,150,0,0],[0,0,0,0,152,153,153,57,58,0,59,0,0,0,154,0,0,0,0],[0,0,0,155,116,156,157,8,9,0,10,0,0,158,120,0,0,16,0],[0,0,0,0,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,75,3,4,5,159,160,8,161,0,162,0,11,12,163,0,75,16,0],[0,0,0,0,0,40,164,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,0,165,0,0,0,0],[0,124,64,0,0,40,164,0,9,0,10,0,0,0,42,0,124,0,0],[0,0,0,0,0,70,70,0,71,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,166,0,0,167,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,168,0,0,0,0,0,0,0,0],[0,0,0,0,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,0,0,0,79,80,80,22,23,0,0,0,0,0,79,0,0,0,0],[0,0,0,169,170,171,172,22,23,0,24,0,0,173,174,0,0,27,0],[0,0,0,0,0,175,175,0,23,0,24,0,0,0,78,0,0,0,0],[0,75,0,176,0,177,177,22,23,0,24,0,0,0,78,0,75,0,0],[0,178,90,0,0,0,0,0,0,0,0,0,0,0,0,0,178,0,0],[0,75,0,0,0,175,179,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,180,180,22,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,82,83,84,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,83,83,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,181,181,85,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,182,181,181,85,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,183,184,185,186,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,86,0,0,0,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,188,0,0,0,0,0,0,0,0],[0,0,0,189,170,190,191,22,23,0,24,0,0,192,174,0,0,27,0],[0,0,0,0,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,76,193,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,0,194,0,0,0,0],[0,178,90,0,0,76,193,0,23,0,24,0,0,0,78,0,178,0,0],[0,0,0,0,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,0,100,0,0,0,0],[0,0,0,195,196,197,198,32,33,0,34,0,0,199,200,0,0,37,0],[0,0,0,0,0,201,201,0,33,0,34,0,0,0,99,0,0,0,0],[0,96,0,202,0,203,203,32,33,0,34,0,0,0,99,0,96,0,0],[0,204,111,0,0,0,0,0,0,0,0,0,0,0,0,0,204,0,0],[0,96,0,0,0,201,205,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,206,206,32,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,103,104,105,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,104,104,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,207,207,106,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,208,207,207,106,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,209,210,211,212,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,107,0,0,0,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,214,0,0,0,0,0,0,0,0],[0,0,0,215,196,216,217,32,33,0,34,0,0,218,200,0,0,37,0],[0,0,0,0,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,97,219,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,0,220,0,0,0,0],[0,204,111,0,0,97,219,0,33,0,34,0,0,0,99,0,204,0,0],[0,0,0,221,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,223,0,0,0,40,224,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,119,225,0,0,0,0],[0,0,0,115,116,117,222,8,9,0,10,0,0,119,120,0,0,16,0],[0,0,0,115,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,226,64,0,0,40,224,0,9,0,10,0,0,0,42,0,226,0,0],[0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0],[0,39,0,0,0,121,121,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,44,44,8,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,227,0,228,229,0,9,0,10,0,0,230,0,0,0,0,0],[0,39,0,122,0,121,121,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,231,231,49,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,232,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,130,131,132,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,131,131,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,233,233,133,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,234,233,233,133,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,235,236,237,238,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,0,0,240,241,242,243,57,58,0,59,0,0,244,245,0,0,62,0],[0,0,0,0,0,246,246,0,58,0,59,0,0,0,139,0,0,0,0],[0,136,0,247,0,248,248,57,58,0,59,0,0,0,139,0,136,0,0],[0,249,151,0,0,0,0,0,0,0,0,0,0,0,0,0,249,0,0],[0,136,0,0,0,246,250,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,251,251,57,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,143,144,145,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,144,144,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,252,252,146,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,253,252,252,146,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,254,255,256,257,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,147,0,0,0,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,259,0,0,0,0,0,0,0,0],[0,0,0,260,241,261,262,57,58,0,59,0,0,263,245,0,0,62,0],[0,0,0,0,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,137,264,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,0,265,0,0,0,0],[0,249,151,0,0,137,264,0,58,0,59,0,0,0,139,0,249,0,0],[0,0,0,221,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,158,225,0,0,0,0],[0,0,0,155,116,156,222,8,9,0,10,0,0,158,120,0,0,16,0],[0,0,0,155,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,43,266,266,8,161,0,24,0,0,12,267,0,0,0,0],[0,75,0,176,43,268,268,269,161,0,24,0,0,0,267,0,75,0,0],[0,0,0,0,0,270,0,0,271,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,272,0,0,0,0,0,0,0,0],[0,273,274,0,0,40,41,0,9,0,10,0,0,0,42,0,273,0,0],[0,0,0,40,0,123,123,8,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,121,275,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,166,0,0,0,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,276,0,0,0,0,0,0,0,0],[0,0,0,277,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,279,0,0,0,76,280,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,173,281,0,0,0,0],[0,0,0,169,170,171,278,22,23,0,24,0,0,173,174,0,0,27,0],[0,0,0,169,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,282,90,0,0,76,280,0,23,0,24,0,0,0,78,0,282,0,0],[0,0,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,0,0],[0,75,0,0,0,175,175,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,80,80,22,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,283,0,284,285,0,23,0,24,0,0,286,0,0,0,0,0],[0,75,0,176,0,175,175,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,0,0,22,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,287,287,85,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,288,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,184,185,186,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,185,185,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,289,289,187,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,290,289,289,187,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,291,292,293,294,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,277,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,192,281,0,0,0,0],[0,0,0,189,170,190,278,22,23,0,24,0,0,192,174,0,0,27,0],[0,0,0,189,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,76,0,177,177,22,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,175,296,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,297,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,299,0,0,0,97,300,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,199,301,0,0,0,0],[0,0,0,195,196,197,298,32,33,0,34,0,0,199,200,0,0,37,0],[0,0,0,195,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,302,111,0,0,97,300,0,33,0,34,0,0,0,99,0,302,0,0],[0,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,0,0],[0,96,0,0,0,201,201,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,101,101,32,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,303,0,304,305,0,33,0,34,0,0,306,0,0,0,0,0],[0,96,0,202,0,201,201,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,307,307,106,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,308,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,210,211,212,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,211,211,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,309,309,213,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,310,309,309,213,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,311,312,313,314,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,297,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,218,301,0,0,0,0],[0,0,0,215,196,216,298,32,33,0,34,0,0,218,200,0,0,37,0],[0,0,0,215,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,97,0,203,203,32,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,201,316,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,0,225,0,0,0,0],[0,0,0,317,318,319,320,8,9,0,10,0,0,321,322,0,0,16,0],[0,223,0,323,0,123,123,8,9,0,10,0,0,0,42,0,223,0,0],[0,223,0,0,0,121,324,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,325,318,326,327,8,9,0,10,0,0,328,322,0,0,16,0],[0,0,0,64,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,9,0,0,0,0,230,0,0,0,0,0],[0,0,0,227,0,228,121,0,9,0,10,0,0,230,0,0,0,0,0],[0,0,0,227,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,49,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,46,0,0],[0,0,0,0,0,329,329,133,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,330,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,236,237,238,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,237,237,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,331,331,239,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,332,331,331,239,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,333,40,121,334,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,335,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,337,0,0,0,137,338,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,244,339,0,0,0,0],[0,0,0,240,241,242,336,57,58,0,59,0,0,244,245,0,0,62,0],[0,0,0,240,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,340,151,0,0,137,338,0,58,0,59,0,0,0,139,0,340,0,0],[0,0,0,0,0,0,0,0,58,0,0,0,0,0,0,0,0,0,0],[0,136,0,0,0,246,246,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,141,141,57,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,341,0,342,343,0,58,0,59,0,0,344,0,0,0,0,0],[0,136,0,247,0,246,246,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,0,0,57,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,345,345,146,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,346,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,255,256,257,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,256,256,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,347,347,258,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,348,347,347,258,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,349,350,351,352,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,335,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,263,339,0,0,0,0],[0,0,0,260,241,261,336,57,58,0,59,0,0,263,245,0,0,62,0],[0,0,0,260,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,137,0,248,248,57,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,246,354,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,126,126,8,23,0,0,0,0,0,0,0,0,0,0],[0,355,90,0,0,121,125,0,9,0,10,0,0,0,42,0,355,0,0],[0,0,0,0,0,356,356,269,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,357,358,359,360,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,270,0,0,0,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,363,0,0,0,0,0,0,0,0],[0,0,0,364,116,365,366,8,161,0,162,0,0,367,120,0,0,16,0],[0,0,0,0,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,40,0,121,121,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,0,281,0,0,0,0],[0,0,0,369,370,371,372,22,23,0,24,0,0,373,374,0,0,27,0],[0,279,0,375,0,177,177,22,23,0,24,0,0,0,78,0,279,0,0],[0,279,0,0,0,175,376,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,377,370,378,379,22,23,0,24,0,0,380,374,0,0,27,0],[0,0,0,90,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,23,0,0,0,0,286,0,0,0,0,0],[0,0,0,283,0,284,175,0,23,0,24,0,0,286,0,0,0,0,0],[0,0,0,283,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,85,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82,0,0],[0,0,0,0,0,381,381,187,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,382,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,292,293,294,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,293,293,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,383,383,295,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,384,383,383,295,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,385,76,175,386,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,76,0,175,175,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,0,301,0,0,0,0],[0,0,0,387,388,389,390,32,33,0,34,0,0,391,392,0,0,37,0],[0,299,0,393,0,203,203,32,33,0,34,0,0,0,99,0,299,0,0],[0,299,0,0,0,201,394,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,395,388,396,397,32,33,0,34,0,0,398,392,0,0,37,0],[0,0,0,111,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,33,0,0,0,0,306,0,0,0,0,0],[0,0,0,303,0,304,201,0,33,0,34,0,0,306,0,0,0,0,0],[0,0,0,303,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,106,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,103,0,0],[0,0,0,0,0,399,399,213,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,400,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,312,313,314,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,313,313,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,401,401,315,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,402,401,401,315,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,403,97,201,404,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,97,0,201,201,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,405,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,407,0,0,0,40,408,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,321,409,0,0,0,0],[0,0,0,317,318,319,406,8,9,0,10,0,0,321,322,0,0,16,0],[0,0,0,317,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,410,64,0,0,40,408,0,9,0,10,0,0,0,42,0,410,0,0],[0,223,0,0,0,121,121,0,9,0,10,0,0,0,42,0,223,0,0],[0,223,0,323,0,121,121,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,405,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,328,409,0,0,0,0],[0,0,0,325,318,326,406,8,9,0,10,0,0,328,322,0,0,16,0],[0,0,0,325,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,0,0,0,133,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,0,0],[0,0,0,0,0,411,411,239,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,40,121,334,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,413,0,0,0,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,0,339,0,0,0,0],[0,0,0,414,415,416,417,57,58,0,59,0,0,418,419,0,0,62,0],[0,337,0,420,0,248,248,57,58,0,59,0,0,0,139,0,337,0,0],[0,337,0,0,0,246,421,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,422,415,423,424,57,58,0,59,0,0,425,419,0,0,62,0],[0,0,0,151,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,58,0,0,0,0,344,0,0,0,0,0],[0,0,0,341,0,342,246,0,58,0,59,0,0,344,0,0,0,0,0],[0,0,0,341,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,146,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,143,0,0],[0,0,0,0,0,426,426,258,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,427,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,350,351,352,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,351,351,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,428,428,353,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,429,428,428,353,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,430,137,246,431,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,137,0,246,246,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,432,116,433,434,8,161,0,162,0,0,435,120,0,0,16,0],[0,0,0,0,0,180,180,269,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,358,359,360,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,359,359,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,436,436,361,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,437,436,436,361,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,438,439,440,441,442,161,0,162,0,0,0,362,0,0,0,0],[0,443,274,0,0,0,0,0,0,0,0,0,0,0,0,0,443,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,444,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,367,225,0,0,0,0],[0,0,0,364,116,365,445,8,161,0,162,0,0,367,120,0,0,16,0],[0,0,0,364,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,446,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,448,0,0,0,76,449,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,373,450,0,0,0,0],[0,0,0,369,370,371,447,22,23,0,24,0,0,373,374,0,0,27,0],[0,0,0,369,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,451,90,0,0,76,449,0,23,0,24,0,0,0,78,0,451,0,0],[0,279,0,0,0,175,175,0,23,0,24,0,0,0,78,0,279,0,0],[0,279,0,375,0,175,175,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,446,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,380,450,0,0,0,0],[0,0,0,377,370,378,447,22,23,0,24,0,0,380,374,0,0,27,0],[0,0,0,377,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,0,0,0,187,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,0,0],[0,0,0,0,0,452,452,295,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,453,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,76,175,386,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,454,0,0,0,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,455,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,457,0,0,0,97,458,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,391,459,0,0,0,0],[0,0,0,387,388,389,456,32,33,0,34,0,0,391,392,0,0,37,0],[0,0,0,387,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,460,111,0,0,97,458,0,33,0,34,0,0,0,99,0,460,0,0],[0,299,0,0,0,201,201,0,33,0,34,0,0,0,99,0,299,0,0],[0,299,0,393,0,201,201,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,455,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,398,459,0,0,0,0],[0,0,0,395,388,396,456,32,33,0,34,0,0,398,392,0,0,37,0],[0,0,0,395,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,0,0,0,213,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,210,0,0],[0,0,0,0,0,461,461,315,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,462,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,97,201,404,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,463,0,0,0,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,0,409,0,0,0,0],[0,0,0,464,465,466,467,8,9,0,10,0,0,468,469,0,0,16,0],[0,407,0,470,0,123,123,8,9,0,10,0,0,0,42,0,407,0,0],[0,407,0,0,0,121,471,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,472,465,473,474,8,9,0,10,0,0,475,469,0,0,16,0],[0,0,0,0,0,0,0,239,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,236,0,0],[0,0,0,0,0,0,476,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,477,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,479,0,0,0,137,480,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,418,481,0,0,0,0],[0,0,0,414,415,416,478,57,58,0,59,0,0,418,419,0,0,62,0],[0,0,0,414,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,482,151,0,0,137,480,0,58,0,59,0,0,0,139,0,482,0,0],[0,337,0,0,0,246,246,0,58,0,59,0,0,0,139,0,337,0,0],[0,337,0,420,0,246,246,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,477,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,425,481,0,0,0,0],[0,0,0,422,415,423,478,57,58,0,59,0,0,425,419,0,0,62,0],[0,0,0,422,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,0,0,0,258,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0],[0,0,0,0,0,483,483,353,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,484,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,137,246,431,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,485,0,0,0,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,444,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,435,225,0,0,0,0],[0,0,0,432,116,433,445,8,161,0,162,0,0,435,120,0,0,16,0],[0,0,0,432,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,0,486,486,361,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,487,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,439,440,441,442,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,440,440,442,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,488,488,442,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,489,488,488,442,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,490,491,492,493,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,495,0,496,497,0,161,0,162,0,0,498,0,0,0,0,0],[0,0,0,0,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,0,225,0,0,0,0],[0,0,0,0,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,0,450,0,0,0,0],[0,0,0,499,500,501,502,22,23,0,24,0,0,503,504,0,0,27,0],[0,448,0,505,0,177,177,22,23,0,24,0,0,0,78,0,448,0,0],[0,448,0,0,0,175,506,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,507,500,508,509,22,23,0,24,0,0,510,504,0,0,27,0],[0,0,0,0,0,0,0,295,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,292,0,0],[0,0,0,0,0,0,511,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,0,459,0,0,0,0],[0,0,0,512,513,514,515,32,33,0,34,0,0,516,517,0,0,37,0],[0,457,0,518,0,203,203,32,33,0,34,0,0,0,99,0,457,0,0],[0,457,0,0,0,201,519,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,520,513,521,522,32,33,0,34,0,0,523,517,0,0,37,0],[0,0,0,0,0,0,0,315,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,312,0,0],[0,0,0,0,0,0,524,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,525,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,527,0,0,0,40,528,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,468,529,0,0,0,0],[0,0,0,464,465,466,526,8,9,0,10,0,0,468,469,0,0,16,0],[0,0,0,464,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,530,64,0,0,40,528,0,9,0,10,0,0,0,42,0,530,0,0],[0,407,0,0,0,121,121,0,9,0,10,0,0,0,42,0,407,0,0],[0,407,0,470,0,121,121,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,525,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,475,529,0,0,0,0],[0,0,0,472,465,473,526,8,9,0,10,0,0,475,469,0,0,16,0],[0,0,0,472,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,0,0],[0,0,0,0,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,0,481,0,0,0,0],[0,0,0,531,532,533,534,57,58,0,59,0,0,535,536,0,0,62,0],[0,479,0,537,0,248,248,57,58,0,59,0,0,0,139,0,479,0,0],[0,479,0,0,0,246,538,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,539,532,540,541,57,58,0,59,0,0,542,536,0,0,62,0],[0,0,0,0,0,0,0,353,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,350,0,0],[0,0,0,0,0,0,543,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,361,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,358,0,0],[0,0,0,0,0,544,544,442,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,545,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,491,492,493,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,492,492,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,546,546,494,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,547,546,546,494,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,548,549,368,550,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,274,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,161,0,0,0,0,498,0,0,0,0,0],[0,0,0,495,0,496,368,0,161,0,162,0,0,498,0,0,0,0,0],[0,0,0,495,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,551,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,553,0,0,0,76,554,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,503,555,0,0,0,0],[0,0,0,499,500,501,552,22,23,0,24,0,0,503,504,0,0,27,0],[0,0,0,499,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,556,90,0,0,76,554,0,23,0,24,0,0,0,78,0,556,0,0],[0,448,0,0,0,175,175,0,23,0,24,0,0,0,78,0,448,0,0],[0,448,0,505,0,175,175,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,551,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,510,555,0,0,0,0],[0,0,0,507,500,508,552,22,23,0,24,0,0,510,504,0,0,27,0],[0,0,0,507,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76,0,0],[0,0,0,557,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,559,0,0,0,97,560,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,516,561,0,0,0,0],[0,0,0,512,513,514,558,32,33,0,34,0,0,516,517,0,0,37,0],[0,0,0,512,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,562,111,0,0,97,560,0,33,0,34,0,0,0,99,0,562,0,0],[0,457,0,0,0,201,201,0,33,0,34,0,0,0,99,0,457,0,0],[0,457,0,518,0,201,201,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,557,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,523,561,0,0,0,0],[0,0,0,520,513,521,558,32,33,0,34,0,0,523,517,0,0,37,0],[0,0,0,520,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,97,0,0],[0,0,0,0,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,0,529,0,0,0,0],[0,0,0,563,66,564,565,8,9,0,10,0,0,566,68,0,0,16,0],[0,527,0,567,0,123,123,8,9,0,10,0,0,0,42,0,527,0,0],[0,527,0,0,0,121,568,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,569,66,570,571,8,9,0,10,0,0,572,68,0,0,16,0],[0,0,0,573,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,575,0,0,0,137,576,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,535,577,0,0,0,0],[0,0,0,531,532,533,574,57,58,0,59,0,0,535,536,0,0,62,0],[0,0,0,531,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,578,151,0,0,137,576,0,58,0,59,0,0,0,139,0,578,0,0],[0,479,0,0,0,246,246,0,58,0,59,0,0,0,139,0,479,0,0],[0,479,0,537,0,246,246,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,573,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,542,577,0,0,0,0],[0,0,0,539,532,540,574,57,58,0,59,0,0,542,536,0,0,62,0],[0,0,0,539,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,137,0,0],[0,0,0,0,0,0,0,442,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,439,0,0],[0,0,0,0,0,579,579,494,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,580,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,549,368,550,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,368,368,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,581,0,0,0,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,0,555,0,0,0,0],[0,0,0,582,91,583,584,22,23,0,24,0,0,585,93,0,0,27,0],[0,553,0,586,0,177,177,22,23,0,24,0,0,0,78,0,553,0,0],[0,553,0,0,0,175,587,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,588,91,589,590,22,23,0,24,0,0,591,93,0,0,27,0],[0,0,0,0,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,0,561,0,0,0,0],[0,0,0,592,112,593,594,32,33,0,34,0,0,595,114,0,0,37,0],[0,559,0,596,0,203,203,32,33,0,34,0,0,0,99,0,559,0,0],[0,559,0,0,0,201,597,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,598,112,599,600,32,33,0,34,0,0,601,114,0,0,37,0],[0,0,0,602,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,566,165,0,0,0,0],[0,0,0,563,66,564,67,8,9,0,10,0,0,566,68,0,0,16,0],[0,0,0,563,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,527,0,0,0,121,121,0,9,0,10,0,0,0,42,0,527,0,0],[0,527,0,567,0,121,121,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,602,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,572,165,0,0,0,0],[0,0,0,569,66,570,67,8,9,0,10,0,0,572,68,0,0,16,0],[0,0,0,569,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,0,577,0,0,0,0],[0,0,0,603,152,604,605,57,58,0,59,0,0,606,154,0,0,62,0],[0,575,0,607,0,248,248,57,58,0,59,0,0,0,139,0,575,0,0],[0,575,0,0,0,246,608,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,609,152,610,611,57,58,0,59,0,0,612,154,0,0,62,0],[0,0,0,0,0,0,0,494,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,491,0,0],[0,0,0,0,0,0,613,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,614,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,585,194,0,0,0,0],[0,0,0,582,91,583,92,22,23,0,24,0,0,585,93,0,0,27,0],[0,0,0,582,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,553,0,0,0,175,175,0,23,0,24,0,0,0,78,0,553,0,0],[0,553,0,586,0,175,175,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,614,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,591,194,0,0,0,0],[0,0,0,588,91,589,92,22,23,0,24,0,0,591,93,0,0,27,0],[0,0,0,588,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,615,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,595,220,0,0,0,0],[0,0,0,592,112,593,113,32,33,0,34,0,0,595,114,0,0,37,0],[0,0,0,592,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,559,0,0,0,201,201,0,33,0,34,0,0,0,99,0,559,0,0],[0,559,0,596,0,201,201,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,615,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,601,220,0,0,0,0],[0,0,0,598,112,599,113,32,33,0,34,0,0,601,114,0,0,37,0],[0,0,0,598,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,616,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,606,265,0,0,0,0],[0,0,0,603,152,604,153,57,58,0,59,0,0,606,154,0,0,62,0],[0,0,0,603,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,575,0,0,0,246,246,0,58,0,59,0,0,0,139,0,575,0,0],[0,575,0,607,0,246,246,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,616,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,612,265,0,0,0,0],[0,0,0,609,152,610,153,57,58,0,59,0,0,612,154,0,0,62,0],[0,0,0,609,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,549,0,0],[0,0,0,0,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0]],"accepting":[false,true,true,true,true,true,false,false,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,false,false,true,true,true,true,true,true,true,true,true,true,false,true,true,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,false,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,false,true,false,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,false,false,true,false,true,true,false,true,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,true,true,false,false,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,false,false,true,true,false,false,true,true,true,false,true,false,true,true,true,true,false,false,false,true,false,true,true,true,true,false,false,false,true,true,false,true,true,true,true,true,true,false,true,true,false,true,false,true,true,true,true,false,false,false,false,false,false,false,true,true,false,false,true,true,false,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,true,false,true,true,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,false,true,true,false,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,true,false,true,true,true,true,false,false,false,true,false,true,true,true,true,true,false,true,true,true,false,true,true,true,true,true,false,true,true,true,true,false,true,true,true,true,true,false,true,true,false,true,true,true],"tags":[[],["broken_cluster"],["consonant_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["consonant_syllable"],["broken_cluster"],["symbol_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["broken_cluster"],["broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],[],["broken_cluster"],["symbol_cluster"],[],["symbol_cluster"],["symbol_cluster"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["symbol_cluster"],["symbol_cluster"],["symbol_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],["symbol_cluster"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],[],["broken_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],[],["consonant_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],[],["vowel_syllable"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],[],[],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],["standalone_cluster"],[],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],[],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],[],[],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],[],[],[],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],["consonant_syllable"],["vowel_syllable"],["standalone_cluster"]]}');var rn={};rn=JSON.parse('{"categories":["O","IND","S","GB","B","FM","CGJ","VMAbv","VMPst","VAbv","VPst","CMBlw","VPre","VBlw","H","VMBlw","CMAbv","MBlw","CS","R","SUB","MPst","MPre","FAbv","FPst","FBlw","null","SMAbv","SMBlw","VMPre","ZWNJ","ZWJ","WJ","M","VS","N","HN","MAbv"],"decompositions":{"2507":[2503,2494],"2508":[2503,2519],"2888":[2887,2902],"2891":[2887,2878],"2892":[2887,2903],"3018":[3014,3006],"3019":[3015,3006],"3020":[3014,3031],"3144":[3142,3158],"3264":[3263,3285],"3271":[3270,3285],"3272":[3270,3286],"3274":[3270,3266],"3275":[3270,3266,3285],"3402":[3398,3390],"3403":[3399,3390],"3404":[3398,3415],"3546":[3545,3530],"3548":[3545,3535],"3549":[3545,3535,3530],"3550":[3545,3551],"3635":[3661,3634],"3763":[3789,3762],"3955":[3953,3954],"3957":[3953,3956],"3958":[4018,3968],"3959":[4018,3953,3968],"3960":[4019,3968],"3961":[4019,3953,3968],"3969":[3953,3968],"6971":[6970,6965],"6973":[6972,6965],"6976":[6974,6965],"6977":[6975,6965],"6979":[6978,6965],"69934":[69937,69927],"69935":[69938,69927],"70475":[70471,70462],"70476":[70471,70487],"70843":[70841,70842],"70844":[70841,70832],"70846":[70841,70845],"71098":[71096,71087],"71099":[71097,71087]},"stateTable":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,2,3,4,4,5,0,6,7,8,9,10,11,12,13,14,15,16,0,17,18,11,19,20,21,22,0,0,0,23,0,0,2,0,0,24,0,25],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,28,0,0,0,0,0,27,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,34,35,36,37,38,39,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,39,0,0,47],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,0,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,0,0,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,9,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,10,11,12,13,14,0,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,9,0,0,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,7,0,0,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,10,11,12,13,14,15,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,0,0,0,0,11,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,4,4,5,0,6,7,8,9,10,11,12,13,14,15,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,48,11,12,13,14,48,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,49,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,16,0,0,0,11,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0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0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,33,0,0,36,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,31,0,0,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,34,35,36,37,38,39,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,0,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,52,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,53,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,40,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,0,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,40,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,48,11,12,13,14,0,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,48,11,12,13,14,48,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,51,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,54,0,0],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,0,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,52,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,0,51,0]],"accepting":[false,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],"tags":[[],["broken_cluster"],["independent_cluster"],["symbol_cluster"],["standard_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["numeral_cluster"],["broken_cluster"],["independent_cluster"],["symbol_cluster"],["symbol_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["virama_terminated_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["broken_cluster"],["broken_cluster"],["numeral_cluster"],["number_joiner_terminated_cluster"],["standard_cluster"],["standard_cluster"],["numeral_cluster"]]}');const Se={X:1,C:2,V:4,N:8,H:16,ZWNJ:32,ZWJ:64,M:128,Placeholder:2048,Dotted_Circle:4096,RS:8192,Coeng:16384,Repha:32768,Ra:65536,CM:131072},de={Start:1,Ra_To_Become_Reph:2,Pre_M:4,Pre_C:8,Base_C:16,After_Main:32,Before_Sub:128,Below_C:256,After_Sub:512,Before_Post:1024,Post_C:2048,After_Post:4096,Final_C:8192,SMVD:16384,End:32768},Sy=Se.C|Se.Ra|Se.CM|Se.V|Se.Placeholder|Se.Dotted_Circle,$c=Se.ZWJ|Se.ZWNJ,Kr=Se.H|Se.Coeng,Nc={Default:{hasOldSpec:!1,virama:0,basePos:"Last",rephPos:de.Before_Post,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Devanagari:{hasOldSpec:!0,virama:2381,basePos:"Last",rephPos:de.Before_Post,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Bengali:{hasOldSpec:!0,virama:2509,basePos:"Last",rephPos:de.After_Sub,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Gurmukhi:{hasOldSpec:!0,virama:2637,basePos:"Last",rephPos:de.Before_Sub,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Gujarati:{hasOldSpec:!0,virama:2765,basePos:"Last",rephPos:de.Before_Post,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Oriya:{hasOldSpec:!0,virama:2893,basePos:"Last",rephPos:de.After_Main,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Tamil:{hasOldSpec:!0,virama:3021,basePos:"Last",rephPos:de.After_Post,rephMode:"Implicit",blwfMode:"Pre_And_Post"},Telugu:{hasOldSpec:!0,virama:3149,basePos:"Last",rephPos:de.After_Post,rephMode:"Explicit",blwfMode:"Post_Only"},Kannada:{hasOldSpec:!0,virama:3277,basePos:"Last",rephPos:de.After_Post,rephMode:"Implicit",blwfMode:"Post_Only"},Malayalam:{hasOldSpec:!0,virama:3405,basePos:"Last",rephPos:de.After_Main,rephMode:"Log_Repha",blwfMode:"Pre_And_Post"},Khmer:{hasOldSpec:!1,virama:6098,basePos:"First",rephPos:de.Ra_To_Become_Reph,rephMode:"Vis_Repha",blwfMode:"Pre_And_Post"}},Ty={6078:[6081,6078],6079:[6081,6079],6080:[6081,6080],6084:[6081,6084],6085:[6081,6085]},{decompositions:Ey}=Rs(rn),Uc=new As(Ea("AAARAAAAAABg2AAAAWYPmfDtnXuMXFUdx+/uzs7M7szudAtECGJRIMRQbUAithQWkGAKiVhNpFVRRAmIQVCDkDYICGotIA9BTCz8IeUviv7BQ2PBtBIRLBBQIWAUsKg1BKxRAqIgfs/cc+aeOXPej3tnZX7JJ/dxzj3nd36/8753Z5fUsuxgsAwcAU4Gp4BPgM+Cd4P3RjieDs4GXwLrHJ5bDy4DG8A14LvgZrAZbAF3gns0z18ALgY/B78C94NHwBPgabAE/AX8DbwM5sF/QX0yD5vFcU/wVnAgWAoOAyvAceBE8CGwBpwGzgJfAF8BXwXfAFeC68EmsBlsAXeCreA+8CB4DDwF/gh2gd3gFfAGmKxn2QzYC+wHDgRLweFgJTgWrKrnuq/GcQ04jV6fheN54EJwEbgcXAG+Q8O/j+Mt4DZwB9haz8t9Hz3a8iCN/xiOvwRP0evH6fE68AzOH+Ke2eWYhw3PcGnuxvkr4A3QaGRZB7wFLAEHg2XgiEZ/fHKcp/ceBh/A+cngFPCpRm6vM3E8l8a5gN67GMdvgqsbeX2ap9yI601gM7gN3AG20mfuo8cdOP6GpvdUg9oKxz839GV90RDO2/glxN1B790NXsN1rZll7WYRdw+c70uvTwIHNAfTO0RyL5TDmnnbc3lmRQI9UnM0dD5eovfz4FpJ/BNpXNYWV+N6Lfg0hY97JK1vn+Pur9DoQur2F7m436bHDUK8C5t5/8vruo4+97WmXG+GLmzE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a+pvhli0wn8Zq/72Mzm2d90o5VN1x9ZKuzbTgvqWwUIin8FSpl1CXXvFRxU0iozVPYJDRtF3uFphn6XAyJUUdD7SjTJ8v6n9fVbVObkKWp001lc9VRlqdOf5v0ZM+bymdbfp1NfG0bq27Y5JMyfxeJkU6o/inKH8O2Zfgidb6h/g3VJ7QcVbWL0Pxt6rlrPqa4KfQ25a2zl4/E8GdM/4fK/wA=")),_y=new Cl(Rs(zc));class We extends Si{static planFeatures(e){e.addStage(Ay),e.addStage(["locl","ccmp"]),e.addStage(Py),e.addStage("nukt"),e.addStage("akhn"),e.addStage("rphf",!1),e.addStage("rkrf"),e.addStage("pref",!1),e.addStage("blwf",!1),e.addStage("abvf",!1),e.addStage("half",!1),e.addStage("pstf",!1),e.addStage("vatu"),e.addStage("cjct"),e.addStage("cfar",!1),e.addStage(Oy),e.addStage({local:["init"],global:["pres","abvs","blws","psts","haln","dist","abvm","blwm","calt","clig"]}),e.unicodeScript=vg(e.script),e.indicConfig=Nc[e.unicodeScript]||Nc.Default,e.isOldSpec=e.indicConfig.hasOldSpec&&e.script[e.script.length-1]!=="2"}static assignFeatures(e,t){for(let i=t.length-1;i>=0;i--){let r=t[i].codePoints[0],n=Ty[r]||Ey[r];if(n){let a=n.map(o=>{let c=e.font.glyphForCodePoint(o);return new At(e.font,c.id,[o],t[i].features)});t.splice(i,1,...a)}}}}ft(We,"zeroMarkWidths","NONE");function Da(s){return Uc.get(s.codePoints[0])>>8}function Vc(s){return 1<<(Uc.get(s.codePoints[0])&255)}class sn{constructor(e,t,i,r){this.category=e,this.position=t,this.syllableType=i,this.syllable=r}}function Ay(s,e){let t=0,i=0;for(let[r,n,a]of _y.match(e.map(Da))){if(r>i){++t;for(let o=i;o<r;o++)e[o].shaperInfo=new sn(Se.X,de.End,"non_indic_cluster",t)}++t;for(let o=r;o<=n;o++)e[o].shaperInfo=new sn(1<<Da(e[o]),Vc(e[o]),a[0],t);i=n+1}if(i<e.length){++t;for(let r=i;r<e.length;r++)e[r].shaperInfo=new sn(Se.X,de.End,"non_indic_cluster",t)}}function qi(s){return s.shaperInfo.category&Sy}function Vt(s){return s.shaperInfo.category&$c}function si(s){return s.shaperInfo.category&Kr}function ni(s,e){for(let i of s)i.features={[e]:!0};return s[0]._font._layoutEngine.engine.GSUBProcessor.applyFeatures([e],s),s.length===1}function Iy(s,e,t){let i=[t,e,t];return ni(i.slice(0,2),"blwf")||ni(i.slice(1,3),"blwf")?de.Below_C:ni(i.slice(0,2),"pstf")||ni(i.slice(1,3),"pstf")||ni(i.slice(0,2),"pref")||ni(i.slice(1,3),"pref")?de.Post_C:de.Base_C}function Py(s,e,t){let i=t.indicConfig,r=s._layoutEngine.engine.GSUBProcessor.features,n=s.glyphForCodePoint(9676).id,a=s.glyphForCodePoint(i.virama).id;if(a){let o=new At(s,a,[i.virama]);for(let c=0;c<e.length;c++)e[c].shaperInfo.position===de.Base_C&&(e[c].shaperInfo.position=Iy(s,e[c].copy(),o))}for(let o=0,c=nn(e,0);o<e.length;o=c,c=nn(e,o)){let{category:u,syllableType:h}=e[o].shaperInfo;if(h==="symbol_cluster"||h==="non_indic_cluster")continue;if(h==="broken_cluster"&&n){let v=new At(s,n,[9676]);v.shaperInfo=new sn(1<<Da(v),Vc(v),e[o].shaperInfo.syllableType,e[o].shaperInfo.syllable);let k=o;for(;k<c&&e[k].shaperInfo.category===Se.Repha;)k++;e.splice(k++,0,v),c++}let l=c,d=o,f=!1;if(i.rephPos!==de.Ra_To_Become_Reph&&r.rphf&&o+3<=c&&(i.rephMode==="Implicit"&&!Vt(e[o+2])||i.rephMode==="Explicit"&&e[o+2].shaperInfo.category===Se.ZWJ)){let v=[e[o].copy(),e[o+1].copy(),e[o+2].copy()];if(ni(v.slice(0,2),"rphf")||i.rephMode==="Explicit"&&ni(v,"rphf")){for(d+=2;d<c&&Vt(e[d]);)d++;l=o,f=!0}}else if(i.rephMode==="Log_Repha"&&e[o].shaperInfo.category===Se.Repha){for(d++;d<c&&Vt(e[d]);)d++;l=o,f=!0}switch(i.basePos){case"Last":{let v=c,k=!1;do{let C=e[--v].shaperInfo;if(qi(e[v])){if(C.position!==de.Below_C&&(C.position!==de.Post_C||k)){l=v;break}C.position===de.Below_C&&(k=!0),l=v}else if(o<v&&C.category===Se.ZWJ&&e[v-1].shaperInfo.category===Se.H)break}while(v>d);break}case"First":l=o;for(let v=l+1;v<c;v++)qi(e[v])&&(e[v].shaperInfo.position=de.Below_C)}f&&l===o&&d-l<=2&&(f=!1);for(let v=o;v<l;v++){let k=e[v].shaperInfo;k.position=Math.min(de.Pre_C,k.position)}l<c&&(e[l].shaperInfo.position=de.Base_C);for(let v=l+1;v<c;v++)if(e[v].shaperInfo.category===Se.M){for(let k=v+1;k<c;k++)if(qi(e[k])){e[k].shaperInfo.position=de.Final_C;break}break}if(f&&(e[o].shaperInfo.position=de.Ra_To_Become_Reph),t.isOldSpec){let v=t.unicodeScript!=="Malayalam";for(let k=l+1;k<c;k++)if(e[k].shaperInfo.category===Se.H){let C;for(C=c-1;C>k&&!(qi(e[C])||v&&e[C].shaperInfo.category===Se.H);C--);if(e[C].shaperInfo.category!==Se.H&&C>k){let _=e[k];e.splice(k,0,...e.splice(k+1,C-k)),e[C]=_}break}}let p=de.Start;for(let v=o;v<c;v++){let k=e[v].shaperInfo;if(k.category&($c|Se.N|Se.RS|Se.CM|Kr&k.category)){if(k.position=p,k.category===Se.H&&k.position===de.Pre_M){for(let C=v;C>o;C--)if(e[C-1].shaperInfo.position!==de.Pre_M){k.position=e[C-1].shaperInfo.position;break}}}else k.position!==de.SMVD&&(p=k.position)}let m=l;for(let v=l+1;v<c;v++)if(qi(e[v])){for(let k=m+1;k<v;k++)e[k].shaperInfo.position<de.SMVD&&(e[k].shaperInfo.position=e[v].shaperInfo.position);m=v}else e[v].shaperInfo.category===Se.M&&(m=v);let b=e.slice(o,c);b.sort((v,k)=>v.shaperInfo.position-k.shaperInfo.position),e.splice(o,b.length,...b);for(let v=o;v<c;v++)if(e[v].shaperInfo.position===de.Base_C){l=v;break}for(let v=o;v<c&&e[v].shaperInfo.position===de.Ra_To_Become_Reph;v++)e[v].features.rphf=!0;let g=!t.isOldSpec&&i.blwfMode==="Pre_And_Post";for(let v=o;v<l;v++)e[v].features.half=!0,g&&(e[v].features.blwf=!0);for(let v=l+1;v<c;v++)e[v].features.abvf=!0,e[v].features.pstf=!0,e[v].features.blwf=!0;if(t.isOldSpec&&t.unicodeScript==="Devanagari")for(let v=o;v+1<l;v++)e[v].shaperInfo.category===Se.Ra&&e[v+1].shaperInfo.category===Se.H&&(v+1===l||e[v+2].shaperInfo.category===Se.ZWJ)&&(e[v].features.blwf=!0,e[v+1].features.blwf=!0);let y=2;if(r.pref&&l+y<c)for(let v=l+1;v+y-1<c;v++){let k=[e[v].copy(),e[v+1].copy()];if(ni(k,"pref")){for(let C=0;C<y;C++)e[v++].features.pref=!0;if(r.cfar)for(;v<c;v++)e[v].features.cfar=!0;break}}for(let v=o+1;v<c;v++)if(Vt(e[v])){let k=e[v].shaperInfo.category===Se.ZWNJ,C=v;do C--,k&&delete e[C].features.half;while(C>o&&!qi(e[C]))}}}function Oy(s,e,t){let i=t.indicConfig,r=s._layoutEngine.engine.GSUBProcessor.features;for(let n=0,a=nn(e,0);n<e.length;n=a,a=nn(e,n)){let o=!!r.pref,c=n;for(;c<a;c++)if(e[c].shaperInfo.position>=de.Base_C){if(o&&c+1<a){for(let u=c+1;u<a;u++)if(e[u].features.pref){if(!(e[u].substituted&&e[u].isLigated&&!e[u].isMultiplied)){for(c=u;c<a&&si(e[c]);)c++;e[c].shaperInfo.position=de.BASE_C,o=!1}break}}if(t.unicodeScript==="Malayalam")for(let u=c+1;u<a;u++){for(;u<a&&Vt(e[u]);)u++;if(u===a||!si(e[u]))break;for(u++;u<a&&Vt(e[u]);)u++;u<a&&qi(e[u])&&e[u].shaperInfo.position===de.Below_C&&(c=u,e[c].shaperInfo.position=de.Base_C)}n<c&&e[c].shaperInfo.position>de.Base_C&&c--;break}if(c===a&&n<c&&e[c-1].shaperInfo.category===Se.ZWJ&&c--,c<a)for(;n<c&&e[c].shaperInfo.category&(Se.N|Kr);)c--;if(n+1<a&&n<c){let u=c===a?c-2:c-1;if(t.unicodeScript!=="Malayalam"&&t.unicodeScript!=="Tamil"){for(;u>n&&!(e[u].shaperInfo.category&(Se.M|Kr));)u--;si(e[u])&&e[u].shaperInfo.position!==de.Pre_M?u+1<a&&Vt(e[u+1])&&u++:u=n}if(n<u&&e[u].shaperInfo.position!==de.Pre_M){for(let h=u;h>n;h--)if(e[h-1].shaperInfo.position===de.Pre_M){let l=h-1;l<c&&c<=u&&c--;let d=e[l];e.splice(l,0,...e.splice(l+1,u-l)),e[u]=d,u--}}}if(n+1<a&&e[n].shaperInfo.position===de.Ra_To_Become_Reph&&e[n].shaperInfo.category===Se.Repha!==(e[n].isLigated&&!e[n].isMultiplied)){let u,h=i.rephPos,l=!1;if(h!==de.After_Post){for(u=n+1;u<c&&!si(e[u]);)u++;if(u<c&&si(e[u])&&(u+1<c&&Vt(e[u+1])&&u++,l=!0),!l&&h===de.After_Main){for(u=c;u+1<a&&e[u+1].shaperInfo.position<=de.After_Main;)u++;l=u<a}if(!l&&h===de.After_Sub){for(u=c;u+1<a&&!(e[u+1].shaperInfo.position&(de.Post_C|de.After_Post|de.SMVD));)u++;l=u<a}}if(!l){for(u=n+1;u<c&&!si(e[u]);)u++;u<c&&si(e[u])&&(u+1<c&&Vt(e[u+1])&&u++,l=!0)}if(!l){for(u=a-1;u>n&&e[u].shaperInfo.position===de.SMVD;)u--;if(si(e[u]))for(let f=c+1;f<u;f++)e[f].shaperInfo.category===Se.M&&u--}let d=e[n];e.splice(n,0,...e.splice(n+1,u-n)),e[u]=d,n<c&&c<=u&&c--}if(o&&c+1<a){for(let u=c+1;u<a;u++)if(e[u].features.pref){if(e[u].isLigated&&!e[u].isMultiplied){let h=c;if(t.unicodeScript!=="Malayalam"&&t.unicodeScript!=="Tamil"){for(;h>n&&!(e[h-1].shaperInfo.category&(Se.M|Kr));)h--;if(h>n&&e[h-1].shaperInfo.category===Se.M){let f=u;for(let p=c+1;p<f;p++)if(e[p].shaperInfo.category===Se.M){h--;break}}}h>n&&si(e[h-1])&&h<a&&Vt(e[h])&&h++;let l=u,d=e[l];e.splice(h+1,0,...e.splice(h,l-h)),e[h]=d,h<=c&&c<l&&c++}break}}e[n].shaperInfo.position===de.Pre_M&&(!n||!/Cf|Mn/.test(Ps(e[n-1].codePoints[0])))&&(e[n].features.init=!0)}}function nn(s,e){if(e>=s.length)return e;let t=s[e].shaperInfo.syllable;for(;++e<s.length&&s[e].shaperInfo.syllable===t;);return e}const{categories:Fy,decompositions:Hc}=Rs(rn),Ry=new As(Ea("AAACAAAAAAAQugAAAQUO+vHtnHuMX0UVx2d3u/t7bXe7FlqgvB+mpQhFmhikMRAg0ZQmakMU+cPWBzZisEGNjUpoiIYCEgmGUGOEGqOVNPUZUGNA+QNIBU2KREEFFSMBUYRISMXE+B3vnPzOzp553tcWfif5ZO5jnufMzJ2ZO/eumlDqFLAWnAMuBBvBZnC5uXZeBe4WsA1sBzs8/naCXcL1G8GtYDfYA74NvgfuAfcZHmT+fwEeBb8DTwvxPQWeAavACyZvq8z9VYxXwCGglijVBcvACnA8eCM4E6wHG8BF4BLwbvA+8AHwUbAd7AA7wS5wC9gN7gR7wX5wN7gXPAAeBr8Gvwd/Ac+CF8EhoCaV6oBZsBKcAE4FZ0wWeV8P9zxwoTnfCHczuBxsAdvAx8Gnzf1r4X4B3AxuA1+bHJb9m5PzdVGW/Yjv+xXHyfmxFfd9OH8Q/Ar8Bjw1WZT3GfACeAX8N5CfqSmlZsAKsGqqCH8K3DXgbHCuuXYB3HeAd4HLpgrdarbi+EPgY+CT4HPg8ybMTcb9MtyvghtYut/A+b4pf95+ELgfw08Qx/3gADgInjDl0veehPtX8A/wsrn2KtzxDuogWNoJx38k/BzXKeI8Ee5qcBZYD9aZtDbg+AwT19uMX83F7JizCdcvBZdZ97c6/BMfMWmfzfTm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nldkOg5ykAt3GunJbR3NGYsUfWafd3ts853C4dLHppOM6WcfM5C+xSbaC/2HMa1H9v1vXdoXm/LKSVpYh5wqmr/X67SfwHtPc9a97p/k8bt0hpbW0j1Svr2m+7Rd98qIQ1pvSF273dKOjHYNmk6fd8/JX3tWIddblBqoU5p7zrZKnd9TppjVq0DSitWqkwz12b2exb7vwjaRvS/TFd/S+8AYvIo+Suri5TwvvZRdV1IQevQ1/8SA+UeH5eto7n/X1Oe86ptaafl8kPjcF7P7W93eD9d5n+oSvn7fFe7I/G9q1IBfylSR71N6fft94ZU18hOXKR+JqUO8f4+5dvLsmWlMQb/Vov+CUDlpTGUndeQlG3fdZWdRPoPgl3mmDlsLnaey/4X3tVuU+o6L3/Pym+qlLV/jk6rlBRd8394hZ6JdnuqIv2ykOh3pfq96Wkq/E8qu2xl88/tOJ4R3tfmpbGi3c5T859bzqr7MbsN03iI5itUNj5eaEKWqIX/KJCQ/iFWNZMmHXs8ovWk53JzFq5vPul6zDjLV36pX7bzvNzB0YlQOZephWtRS5T7eeSq8030R77/HvC1d7tN83Zt9yltrDdwSR0XxsZd5l+MvvvU1/M9jSnj+Nh6FPJbBld/w6XHXH5MZeXrOfS/65g9RTl1JCa8chzX2RZ9/3lXSh4/VqWfEBNq4b82Ytp6m+9Qqxir1jX+rfPdT1vvsWhM6bPbmON6E1LnPCZW7L0qqXswmtqf0MQelZj4myrzYtzvIYmURlvtqapyx+gzRfd0XPfahVSOquMoG+dibBdl46iyfdbV1qvUW9m8+KTudMvkzZe/pqTJ+pWTflX5zw1fVfox6ZTVc8hvHflOSb+OuG1JsZ0kufXAJf8D")),My=new Cl(Rs(rn));class Ce extends Si{static planFeatures(e){e.addStage(By),e.addStage(["locl","ccmp","nukt","akhn"]),e.addStage(Wc),e.addStage(["rphf"],!1),e.addStage(Ly),e.addStage(Wc),e.addStage(["pref"]),e.addStage(zy),e.addStage(["rkrf","abvf","blwf","half","pstf","vatu","cjct"]),e.addStage($y),e.addStage(["abvs","blws","pres","psts","dist","abvm","blwm"])}static assignFeatures(e,t){for(let i=t.length-1;i>=0;i--){let r=t[i].codePoints[0];if(Hc[r]){let n=Hc[r].map(a=>{let o=e.font.glyphForCodePoint(a);return new At(e.font,o.id,[a],t[i].features)});t.splice(i,1,...n)}}}}ft(Ce,"zeroMarkWidths","BEFORE_GPOS");function jc(s){return Ry.get(s.codePoints[0])}class Dy{constructor(e,t,i){this.category=e,this.syllableType=t,this.syllable=i}}function By(s,e){let t=0;for(let[i,r,n]of My.match(e.map(jc))){++t;for(let o=i;o<=r;o++)e[o].shaperInfo=new Dy(Fy[jc(e[o])],n[0],t);let a=e[i].shaperInfo.category==="R"?1:Math.min(3,r-i);for(let o=i;o<i+a;o++)e[o].features.rphf=!0}}function Wc(s,e){for(let t of e)t.substituted=!1}function Ly(s,e){for(let t of e)t.substituted&&t.features.rphf&&(t.shaperInfo.category="R")}function zy(s,e){for(let t of e)t.substituted&&(t.shaperInfo.category="VPre")}function $y(s,e){let t=s.glyphForCodePoint(9676).id;for(let i=0,r=Gc(e,0);i<e.length;i=r,r=Gc(e,i)){let n,a,o=e[i].shaperInfo,c=o.syllableType;if(!(c!=="virama_terminated_cluster"&&c!=="standard_cluster"&&c!=="broken_cluster")){if(c==="broken_cluster"&&t){let u=new At(s,t,[9676]);for(u.shaperInfo=o,n=i;n<r&&e[n].shaperInfo.category==="R";n++);e.splice(++n,0,u),r++}if(o.category==="R"&&r-i>1){for(n=i+1;n<r;n++)if(o=e[n].shaperInfo,qc(o)||an(e[n])){an(e[n])&&n--,e.splice(i,0,...e.splice(i+1,n-i),e[n]);break}}for(n=i,a=r;n<r;n++)o=e[n].shaperInfo,qc(o)||an(e[n])?a=an(e[n])?n+1:n:(o.category==="VPre"||o.category==="VMPre")&&a<n&&e.splice(a,1,e[n],...e.splice(a,n-a))}}}function Gc(s,e){if(e>=s.length)return e;let t=s[e].shaperInfo.syllable;for(;++e<s.length&&s[e].shaperInfo.syllable===t;);return e}function an(s){return s.shaperInfo.category==="H"&&!s.isLigated}function qc(s){return s.category==="B"||s.category==="GB"}const Ny={arab:Ei,mong:Ei,syrc:Ei,"nko ":Ei,phag:Ei,mand:Ei,mani:Ei,phlp:Ei,hang:Rc,bng2:We,beng:We,dev2:We,deva:We,gjr2:We,gujr:We,guru:We,gur2:We,knda:We,knd2:We,mlm2:We,mlym:We,ory2:We,orya:We,taml:We,tml2:We,telu:We,tel2:We,khmr:We,bali:Ce,batk:Ce,brah:Ce,bugi:Ce,buhd:Ce,cakm:Ce,cham:Ce,dupl:Ce,egyp:Ce,gran:Ce,hano:Ce,java:Ce,kthi:Ce,kali:Ce,khar:Ce,khoj:Ce,sind:Ce,lepc:Ce,limb:Ce,mahj:Ce,mtei:Ce,modi:Ce,hmng:Ce,rjng:Ce,saur:Ce,shrd:Ce,sidd:Ce,sinh:We,sund:Ce,sylo:Ce,tglg:Ce,tagb:Ce,tale:Ce,lana:Ce,tavt:Ce,takr:Ce,tibt:Ce,tfng:Ce,tirh:Ce,latn:Si,DFLT:Si};function Uy(s){Array.isArray(s)||(s=[s]);for(let e of s){let t=Ny[e];if(t)return t}return Si}class Vy extends Zs{applyLookup(e,t){switch(e){case 1:{let r=this.coverageIndex(t.coverage);if(r===-1)return!1;let n=this.glyphIterator.cur;switch(t.version){case 1:n.id=n.id+t.deltaGlyphID&65535;break;case 2:n.id=t.substitute.get(r);break}return!0}case 2:{let r=this.coverageIndex(t.coverage);if(r!==-1){let n=t.sequences.get(r);if(n.length===0)return this.glyphs.splice(this.glyphIterator.index,1),!0;this.glyphIterator.cur.id=n[0],this.glyphIterator.cur.ligatureComponent=0;let a=this.glyphIterator.cur.features,o=this.glyphIterator.cur,c=n.slice(1).map((u,h)=>{let l=new At(this.font,u,void 0,a);return l.shaperInfo=o.shaperInfo,l.isLigated=o.isLigated,l.ligatureComponent=h+1,l.substituted=!0,l.isMultiplied=!0,l});return this.glyphs.splice(this.glyphIterator.index+1,0,...c),!0}return!1}case 3:{let r=this.coverageIndex(t.coverage);if(r!==-1){let n=0;return this.glyphIterator.cur.id=t.alternateSet.get(r)[n],!0}return!1}case 4:{let r=this.coverageIndex(t.coverage);if(r===-1)return!1;for(let n of t.ligatureSets.get(r)){let a=this.sequenceMatchIndices(1,n.components);if(!a)continue;let o=this.glyphIterator.cur,c=o.codePoints.slice();for(let m of a)c.push(...this.glyphs[m].codePoints);let u=new At(this.font,n.glyph,c,o.features);u.shaperInfo=o.shaperInfo,u.isLigated=!0,u.substituted=!0;let h=o.isMark;for(let m=0;m<a.length&&h;m++)h=this.glyphs[a[m]].isMark;u.ligatureID=h?null:this.ligatureID++;let l=o.ligatureID,d=o.codePoints.length,f=d,p=this.glyphIterator.index+1;for(let m of a){if(h)p=m;else for(;p<m;){var i=f-d+Math.min(this.glyphs[p].ligatureComponent||1,d);this.glyphs[p].ligatureID=u.ligatureID,this.glyphs[p].ligatureComponent=i,p++}l=this.glyphs[p].ligatureID,d=this.glyphs[p].codePoints.length,f+=d,p++}if(l&&!h)for(let m=p;m<this.glyphs.length&&this.glyphs[m].ligatureID===l;m++){var i=f-d+Math.min(this.glyphs[m].ligatureComponent||1,d);this.glyphs[m].ligatureComponent=i}for(let m=a.length-1;m>=0;m--)this.glyphs.splice(a[m],1);return this.glyphs[this.glyphIterator.index]=u,!0}return!1}case 5:return this.applyContext(t);case 6:return this.applyChainingContext(t);case 7:return this.applyLookup(t.lookupType,t.extension);default:throw new Error(`GSUB lookupType ${e} is not supported`)}}}class Hy extends Zs{applyPositionValue(e,t){let i=this.positions[this.glyphIterator.peekIndex(e)];t.xAdvance!=null&&(i.xAdvance+=t.xAdvance),t.yAdvance!=null&&(i.yAdvance+=t.yAdvance),t.xPlacement!=null&&(i.xOffset+=t.xPlacement),t.yPlacement!=null&&(i.yOffset+=t.yPlacement);let r=this.font._variationProcessor,n=this.font.GDEF&&this.font.GDEF.itemVariationStore;r&&n&&(t.xPlaDevice&&(i.xOffset+=r.getDelta(n,t.xPlaDevice.a,t.xPlaDevice.b)),t.yPlaDevice&&(i.yOffset+=r.getDelta(n,t.yPlaDevice.a,t.yPlaDevice.b)),t.xAdvDevice&&(i.xAdvance+=r.getDelta(n,t.xAdvDevice.a,t.xAdvDevice.b)),t.yAdvDevice&&(i.yAdvance+=r.getDelta(n,t.yAdvDevice.a,t.yAdvDevice.b)))}applyLookup(e,t){switch(e){case 1:{let r=this.coverageIndex(t.coverage);if(r===-1)return!1;switch(t.version){case 1:this.applyPositionValue(0,t.value);break;case 2:this.applyPositionValue(0,t.values.get(r));break}return!0}case 2:{let r=this.glyphIterator.peek();if(!r)return!1;let n=this.coverageIndex(t.coverage);if(n===-1)return!1;switch(t.version){case 1:let a=t.pairSets.get(n);for(let u of a)if(u.secondGlyph===r.id)return this.applyPositionValue(0,u.value1),this.applyPositionValue(1,u.value2),!0;return!1;case 2:let o=this.getClassID(this.glyphIterator.cur.id,t.classDef1),c=this.getClassID(r.id,t.classDef2);if(o===-1||c===-1)return!1;var i=t.classRecords.get(o).get(c);return this.applyPositionValue(0,i.value1),this.applyPositionValue(1,i.value2),!0}}case 3:{let r=this.glyphIterator.peekIndex(),n=this.glyphs[r];if(!n)return!1;let a=t.entryExitRecords[this.coverageIndex(t.coverage)];if(!a||!a.exitAnchor)return!1;let o=t.entryExitRecords[this.coverageIndex(t.coverage,n.id)];if(!o||!o.entryAnchor)return!1;let c=this.getAnchor(o.entryAnchor),u=this.getAnchor(a.exitAnchor),h=this.positions[this.glyphIterator.index],l=this.positions[r],d;switch(this.direction){case"ltr":h.xAdvance=u.x+h.xOffset,d=c.x+l.xOffset,l.xAdvance-=d,l.xOffset-=d;break;case"rtl":d=u.x+h.xOffset,h.xAdvance-=d,h.xOffset-=d,l.xAdvance=c.x+l.xOffset;break}return this.glyphIterator.flags.rightToLeft?(this.glyphIterator.cur.cursiveAttachment=r,h.yOffset=c.y-u.y):(n.cursiveAttachment=this.glyphIterator.index,h.yOffset=u.y-c.y),!0}case 4:{let r=this.coverageIndex(t.markCoverage);if(r===-1)return!1;let n=this.glyphIterator.index;for(;--n>=0&&(this.glyphs[n].isMark||this.glyphs[n].ligatureComponent>0););if(n<0)return!1;let a=this.coverageIndex(t.baseCoverage,this.glyphs[n].id);if(a===-1)return!1;let o=t.markArray[r],c=t.baseArray[a][o.class];return this.applyAnchor(o,c,n),!0}case 5:{let r=this.coverageIndex(t.markCoverage);if(r===-1)return!1;let n=this.glyphIterator.index;for(;--n>=0&&this.glyphs[n].isMark;);if(n<0)return!1;let a=this.coverageIndex(t.ligatureCoverage,this.glyphs[n].id);if(a===-1)return!1;let o=t.ligatureArray[a],c=this.glyphIterator.cur,u=this.glyphs[n],h=u.ligatureID&&u.ligatureID===c.ligatureID&&c.ligatureComponent>0?Math.min(c.ligatureComponent,u.codePoints.length)-1:u.codePoints.length-1,l=t.markArray[r],d=o[h][l.class];return this.applyAnchor(l,d,n),!0}case 6:{let r=this.coverageIndex(t.mark1Coverage);if(r===-1)return!1;let n=this.glyphIterator.peekIndex(-1),a=this.glyphs[n];if(!a||!a.isMark)return!1;let o=this.glyphIterator.cur,c=!1;if(o.ligatureID===a.ligatureID?o.ligatureID?o.ligatureComponent===a.ligatureComponent&&(c=!0):c=!0:(o.ligatureID&&!o.ligatureComponent||a.ligatureID&&!a.ligatureComponent)&&(c=!0),!c)return!1;let u=this.coverageIndex(t.mark2Coverage,a.id);if(u===-1)return!1;let h=t.mark1Array[r],l=t.mark2Array[u][h.class];return this.applyAnchor(h,l,n),!0}case 7:return this.applyContext(t);case 8:return this.applyChainingContext(t);case 9:return this.applyLookup(t.lookupType,t.extension);default:throw new Error(`Unsupported GPOS table: ${e}`)}}applyAnchor(e,t,i){let r=this.getAnchor(t),n=this.getAnchor(e.markAnchor);this.positions[i];let a=this.positions[this.glyphIterator.index];a.xOffset=r.x-n.x,a.yOffset=r.y-n.y,this.glyphIterator.cur.markAttachment=i}getAnchor(e){let t=e.xCoordinate,i=e.yCoordinate,r=this.font._variationProcessor,n=this.font.GDEF&&this.font.GDEF.itemVariationStore;return r&&n&&(e.xDeviceTable&&(t+=r.getDelta(n,e.xDeviceTable.a,e.xDeviceTable.b)),e.yDeviceTable&&(i+=r.getDelta(n,e.yDeviceTable.a,e.yDeviceTable.b))),{x:t,y:i}}applyFeatures(e,t,i){super.applyFeatures(e,t,i);for(var r=0;r<this.glyphs.length;r++)this.fixCursiveAttachment(r);this.fixMarkAttachment()}fixCursiveAttachment(e){let t=this.glyphs[e];if(t.cursiveAttachment!=null){let i=t.cursiveAttachment;t.cursiveAttachment=null,this.fixCursiveAttachment(i),this.positions[e].yOffset+=this.positions[i].yOffset}}fixMarkAttachment(){for(let e=0;e<this.glyphs.length;e++){let t=this.glyphs[e];if(t.markAttachment!=null){let i=t.markAttachment;if(this.positions[e].xOffset+=this.positions[i].xOffset,this.positions[e].yOffset+=this.positions[i].yOffset,this.direction==="ltr")for(let r=i;r<e;r++)this.positions[e].xOffset-=this.positions[r].xAdvance,this.positions[e].yOffset-=this.positions[r].yAdvance;else for(let r=i+1;r<e+1;r++)this.positions[e].xOffset+=this.positions[r].xAdvance,this.positions[e].yOffset+=this.positions[r].yAdvance}}}}class jy{setup(e){this.glyphInfos=e.glyphs.map(i=>new At(this.font,i.id,[...i.codePoints]));let t=null;this.GPOSProcessor&&(t=this.GPOSProcessor.selectScript(e.script,e.language,e.direction)),this.GSUBProcessor&&(t=this.GSUBProcessor.selectScript(e.script,e.language,e.direction)),this.shaper=Uy(t),this.plan=new jg(this.font,t,e.direction),this.shaper.plan(this.plan,this.glyphInfos,e.features);for(let i in this.plan.allFeatures)e.features[i]=!0}substitute(e){this.GSUBProcessor&&(this.plan.process(this.GSUBProcessor,this.glyphInfos),e.glyphs=this.glyphInfos.map(t=>this.font.getGlyph(t.id,t.codePoints)))}position(e){return this.shaper.zeroMarkWidths==="BEFORE_GPOS"&&this.zeroMarkAdvances(e.positions),this.GPOSProcessor&&this.plan.process(this.GPOSProcessor,this.glyphInfos,e.positions),this.shaper.zeroMarkWidths==="AFTER_GPOS"&&this.zeroMarkAdvances(e.positions),e.direction==="rtl"&&(e.glyphs.reverse(),e.positions.reverse()),this.GPOSProcessor&&this.GPOSProcessor.features}zeroMarkAdvances(e){for(let t=0;t<this.glyphInfos.length;t++)this.glyphInfos[t].isMark&&(e[t].xAdvance=0,e[t].yAdvance=0)}cleanup(){this.glyphInfos=null,this.plan=null,this.shaper=null}getAvailableFeatures(e,t){let i=[];return this.GSUBProcessor&&(this.GSUBProcessor.selectScript(e,t),i.push(...Object.keys(this.GSUBProcessor.features))),this.GPOSProcessor&&(this.GPOSProcessor.selectScript(e,t),i.push(...Object.keys(this.GPOSProcessor.features))),i}constructor(e){this.font=e,this.glyphInfos=null,this.plan=null,this.GSUBProcessor=null,this.GPOSProcessor=null,this.fallbackPosition=!0,e.GSUB&&(this.GSUBProcessor=new Vy(e,e.GSUB)),e.GPOS&&(this.GPOSProcessor=new Hy(e,e.GPOS))}}class Wy{layout(e,t,i,r,n){if(typeof t=="string"&&(n=r,r=i,i=t,t=[]),typeof e=="string"){i==null&&(i=wg(e));var a=this.font.glyphsForString(e)}else{if(i==null){let u=[];for(let h of e)u.push(...h.codePoints);i=xg(u)}var a=e}let o=new kg(a,t,i,r,n);return a.length===0?(o.positions=[],o):(this.engine&&this.engine.setup&&this.engine.setup(o),this.substitute(o),this.position(o),this.hideDefaultIgnorables(o.glyphs,o.positions),this.engine&&this.engine.cleanup&&this.engine.cleanup(),o)}substitute(e){this.engine&&this.engine.substitute&&this.engine.substitute(e)}position(e){e.positions=e.glyphs.map(i=>new Sg(i.advanceWidth));let t=null;this.engine&&this.engine.position&&(t=this.engine.position(e)),!t&&(!this.engine||this.engine.fallbackPosition)&&(this.unicodeLayoutEngine||(this.unicodeLayoutEngine=new bg(this.font)),this.unicodeLayoutEngine.positionGlyphs(e.glyphs,e.positions)),(!t||!t.kern)&&e.features.kern!==!1&&this.font.kern&&(this.kernProcessor||(this.kernProcessor=new yg(this.font)),this.kernProcessor.process(e.glyphs,e.positions),e.features.kern=!0)}hideDefaultIgnorables(e,t){let i=this.font.glyphForCodePoint(32);for(let r=0;r<e.length;r++)this.isDefaultIgnorable(e[r].codePoints[0])&&(e[r]=i,t[r].xAdvance=0,t[r].yAdvance=0)}isDefaultIgnorable(e){let t=e>>16;if(t===0)switch(e>>8){case 0:return e===173;case 3:return e===847;case 6:return e===1564;case 23:return 6068<=e&&e<=6069;case 24:return 6155<=e&&e<=6158;case 32:return 8203<=e&&e<=8207||8234<=e&&e<=8238||8288<=e&&e<=8303;case 254:return 65024<=e&&e<=65039||e===65279;case 255:return 65520<=e&&e<=65528;default:return!1}else switch(t){case 1:return 113824<=e&&e<=113827||119155<=e&&e<=119162;case 14:return 917504<=e&&e<=921599;default:return!1}}getAvailableFeatures(e,t){let i=[];return this.engine&&i.push(...this.engine.getAvailableFeatures(e,t)),this.font.kern&&i.indexOf("kern")===-1&&i.push("kern"),i}stringsForGlyph(e){let t=new Set,i=this.font._cmapProcessor.codePointsForGlyph(e);for(let r of i)t.add(String.fromCodePoint(r));if(this.engine&&this.engine.stringsForGlyph)for(let r of this.engine.stringsForGlyph(e))t.add(r);return Array.from(t)}constructor(e){this.font=e,this.unicodeLayoutEngine=null,this.kernProcessor=null,this.font.morx?this.engine=new Hg(this.font):(this.font.GSUB||this.font.GPOS)&&(this.engine=new jy(this.font))}}const Gy={moveTo:"M",lineTo:"L",quadraticCurveTo:"Q",bezierCurveTo:"C",closePath:"Z"};class br{toFunction(){return e=>{this.commands.forEach(t=>e[t.command].apply(e,t.args))}}toSVG(){return this.commands.map(t=>{let i=t.args.map(r=>Math.round(r*100)/100);return`${Gy[t.command]}${i.join(" ")}`}).join("")}get cbox(){if(!this._cbox){let e=new ki;for(let t of this.commands)for(let i=0;i<t.args.length;i+=2)e.addPoint(t.args[i],t.args[i+1]);this._cbox=Object.freeze(e)}return this._cbox}get bbox(){if(this._bbox)return this._bbox;let e=new ki,t=0,i=0,r=y=>Math.pow(1-y,3)*f[g]+3*Math.pow(1-y,2)*y*p[g]+3*(1-y)*Math.pow(y,2)*m[g]+Math.pow(y,3)*b[g];for(let y of this.commands)switch(y.command){case"moveTo":case"lineTo":let[v,k]=y.args;e.addPoint(v,k),t=v,i=k;break;case"quadraticCurveTo":case"bezierCurveTo":if(y.command==="quadraticCurveTo")var[n,a,l,d]=y.args,o=t+2/3*(n-t),c=i+2/3*(a-i),u=l+2/3*(n-l),h=d+2/3*(a-d);else var[o,c,u,h,l,d]=y.args;e.addPoint(l,d);for(var f=[t,i],p=[o,c],m=[u,h],b=[l,d],g=0;g<=1;g++){let C=6*f[g]-12*p[g]+6*m[g],_=-3*f[g]+9*p[g]-9*m[g]+3*b[g];if(y=3*p[g]-3*f[g],_===0){if(C===0)continue;let T=-y/C;0<T&&T<1&&(g===0?e.addPoint(r(T),e.maxY):g===1&&e.addPoint(e.maxX,r(T)));continue}let E=Math.pow(C,2)-4*y*_;if(E<0)continue;let x=(-C+Math.sqrt(E))/(2*_);0<x&&x<1&&(g===0?e.addPoint(r(x),e.maxY):g===1&&e.addPoint(e.maxX,r(x)));let S=(-C-Math.sqrt(E))/(2*_);0<S&&S<1&&(g===0?e.addPoint(r(S),e.maxY):g===1&&e.addPoint(e.maxX,r(S)))}t=l,i=d;break}return this._bbox=Object.freeze(e)}mapPoints(e){let t=new br;for(let i of this.commands){let r=[];for(let n=0;n<i.args.length;n+=2){let[a,o]=e(i.args[n],i.args[n+1]);r.push(a,o)}t[i.command](...r)}return t}transform(e,t,i,r,n,a){return this.mapPoints((o,c)=>{const u=e*o+i*c+n,h=t*o+r*c+a;return[u,h]})}translate(e,t){return this.transform(1,0,0,1,e,t)}rotate(e){let t=Math.cos(e),i=Math.sin(e);return this.transform(t,i,-i,t,0,0)}scale(e,t=e){return this.transform(e,0,0,t,0,0)}constructor(){this.commands=[],this._bbox=null,this._cbox=null}}for(let s of["moveTo","lineTo","quadraticCurveTo","bezierCurveTo","closePath"])br.prototype[s]=function(...e){return this._bbox=this._cbox=null,this.commands.push({command:s,args:e}),this};var Yr=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];class Ht{_getPath(){return new br}_getCBox(){return this.path.cbox}_getBBox(){return this.path.bbox}_getTableMetrics(e){if(this.id<e.metrics.length)return e.metrics.get(this.id);let t=e.metrics.get(e.metrics.length-1);return{advance:t?t.advance:0,bearing:e.bearings.get(this.id-e.metrics.length)||0}}_getMetrics(e){if(this._metrics)return this._metrics;let{advance:t,bearing:i}=this._getTableMetrics(this._font.hmtx);if(this._font.vmtx)var{advance:r,bearing:n}=this._getTableMetrics(this._font.vmtx);else{let a;if((typeof e>"u"||e===null)&&({cbox:e}=this),(a=this._font["OS/2"])&&a.version>0)var r=Math.abs(a.typoAscender-a.typoDescender),n=a.typoAscender-e.maxY;else{let{hhea:o}=this._font;var r=Math.abs(o.ascent-o.descent),n=o.ascent-e.maxY}}return this._font._variationProcessor&&this._font.HVAR&&(t+=this._font._variationProcessor.getAdvanceAdjustment(this.id,this._font.HVAR)),this._metrics={advanceWidth:t,advanceHeight:r,leftBearing:i,topBearing:n}}get cbox(){return this._getCBox()}get bbox(){return this._getBBox()}get path(){return this._getPath()}getScaledPath(e){let t=1/this._font.unitsPerEm*e;return this.path.scale(t)}get advanceWidth(){return this._getMetrics().advanceWidth}get advanceHeight(){return this._getMetrics().advanceHeight}get ligatureCaretPositions(){}_getName(){let{post:e}=this._font;if(!e)return null;switch(e.version){case 1:return Yr[this.id];case 2:let t=e.glyphNameIndex[this.id];return t<Yr.length?Yr[t]:e.names[t-Yr.length];case 2.5:return Yr[this.id+e.offsets[this.id]];case 4:return String.fromCharCode(e.map[this.id])}}get name(){return this._getName()}render(e,t){e.save();let i=1/this._font.head.unitsPerEm*t;e.scale(i,i),this.path.toFunction()(e),e.fill(),e.restore()}constructor(e,t,i){this.id=e,this.codePoints=t,this._font=i,this.isMark=this.codePoints.length>0&&this.codePoints.every(xl),this.isLigature=this.codePoints.length>1}}it([rt],Ht.prototype,"cbox",null),it([rt],Ht.prototype,"bbox",null),it([rt],Ht.prototype,"path",null),it([rt],Ht.prototype,"advanceWidth",null),it([rt],Ht.prototype,"advanceHeight",null),it([rt],Ht.prototype,"name",null);let Xc=new F({numberOfContours:z,xMin:z,yMin:z,xMax:z,yMax:z});const qy=1,Xy=2,Zy=4,Ky=8,Yy=16,Jy=32,Qy=1,eb=8,Zc=32,tb=64,ib=128,rb=256;class It{copy(){return new It(this.onCurve,this.endContour,this.x,this.y)}constructor(e,t,i=0,r=0){this.onCurve=e,this.endContour=t,this.x=i,this.y=r}}class sb{constructor(e,t,i){this.glyphID=e,this.dx=t,this.dy=i,this.pos=0,this.scaleX=this.scaleY=1,this.scale01=this.scale10=0}}class on extends Ht{_getCBox(e){if(this._font._variationProcessor&&!e)return this.path.cbox;let t=this._font._getTableStream("glyf");t.pos+=this._font.loca.offsets[this.id];let i=Xc.decode(t),r=new ki(i.xMin,i.yMin,i.xMax,i.yMax);return Object.freeze(r)}_parseGlyphCoord(e,t,i,r){if(i){var n=e.readUInt8();r||(n=-n),n+=t}else if(r)var n=t;else var n=t+e.readInt16BE();return n}_decode(){let e=this._font.loca.offsets[this.id],t=this._font.loca.offsets[this.id+1];if(e===t)return null;let i=this._font._getTableStream("glyf");i.pos+=e;let r=i.pos,n=Xc.decode(i);return n.numberOfContours>0?this._decodeSimple(n,i):n.numberOfContours<0&&this._decodeComposite(n,i,r),n}_decodeSimple(e,t){e.points=[];let i=new I(w,e.numberOfContours).decode(t);e.instructions=new I(H,w).decode(t);let r=[],n=i[i.length-1]+1;for(;r.length<n;){var a=t.readUInt8();if(r.push(a),a&Ky){let h=t.readUInt8();for(let l=0;l<h;l++)r.push(a)}}for(var o=0;o<r.length;o++){var a=r[o];let l=new It(!!(a&qy),i.indexOf(o)>=0,0,0);e.points.push(l)}let c=0;for(var o=0;o<r.length;o++){var a=r[o];e.points[o].x=c=this._parseGlyphCoord(t,c,a&Xy,a&Yy)}let u=0;for(var o=0;o<r.length;o++){var a=r[o];e.points[o].y=u=this._parseGlyphCoord(t,u,a&Zy,a&Jy)}if(this._font._variationProcessor){let h=e.points.slice();h.push(...this._getPhantomPoints(e)),this._font._variationProcessor.transformPoints(this.id,h),e.phantomPoints=h.slice(-4)}}_decodeComposite(e,t,i=0){e.components=[];let r=!1,n=Zc;for(;n&Zc;){n=t.readUInt16BE();let u=t.pos-i,h=t.readUInt16BE();if(r||(r=(n&rb)!==0),n&Qy)var a=t.readInt16BE(),o=t.readInt16BE();else var a=t.readInt8(),o=t.readInt8();var c=new sb(h,a,o);c.pos=u,n&eb?c.scaleX=c.scaleY=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824:n&tb?(c.scaleX=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824,c.scaleY=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824):n&ib&&(c.scaleX=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824,c.scale01=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824,c.scale10=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824,c.scaleY=(t.readUInt8()<<24|t.readUInt8()<<16)/1073741824),e.components.push(c)}if(this._font._variationProcessor){let u=[];for(let h=0;h<e.components.length;h++){var c=e.components[h];u.push(new It(!0,!0,c.dx,c.dy))}u.push(...this._getPhantomPoints(e)),this._font._variationProcessor.transformPoints(this.id,u),e.phantomPoints=u.splice(-4,4);for(let h=0;h<u.length;h++){let l=u[h];e.components[h].dx=l.x,e.components[h].dy=l.y}}return r}_getPhantomPoints(e){let t=this._getCBox(!0);this._metrics==null&&(this._metrics=Ht.prototype._getMetrics.call(this,t));let{advanceWidth:i,advanceHeight:r,leftBearing:n,topBearing:a}=this._metrics;return[new It(!1,!0,e.xMin-n,0),new It(!1,!0,e.xMin-n+i,0),new It(!1,!0,0,e.yMax+a),new It(!1,!0,0,e.yMax+a+r)]}_getContours(){let e=this._decode();if(!e)return[];let t=[];if(e.numberOfContours<0)for(let a of e.components){let o=this._font.getGlyph(a.glyphID)._getContours();for(let c=0;c<o.length;c++){let u=o[c];for(let h=0;h<u.length;h++){let l=u[h],d=l.x*a.scaleX+l.y*a.scale01+a.dx,f=l.y*a.scaleY+l.x*a.scale10+a.dy;t.push(new It(l.onCurve,l.endContour,d,f))}}}else t=e.points||[];e.phantomPoints&&!this._font.directory.tables.HVAR&&(this._metrics.advanceWidth=e.phantomPoints[1].x-e.phantomPoints[0].x,this._metrics.advanceHeight=e.phantomPoints[3].y-e.phantomPoints[2].y,this._metrics.leftBearing=e.xMin-e.phantomPoints[0].x,this._metrics.topBearing=e.phantomPoints[2].y-e.yMax);let i=[],r=[];for(let a=0;a<t.length;a++){var n=t[a];r.push(n),n.endContour&&(i.push(r),r=[])}return i}_getMetrics(){if(this._metrics)return this._metrics;let e=this._getCBox(!0);return super._getMetrics(e),this._font._variationProcessor&&!this._font.HVAR&&this.path,this._metrics}_getPath(){let e=this._getContours(),t=new br;for(let r=0;r<e.length;r++){let n=e[r],a=n[0],o=n[n.length-1],c=0;if(a.onCurve){var i=null;c=1}else{o.onCurve?a=o:a=new It(!1,!1,(a.x+o.x)/2,(a.y+o.y)/2);var i=a}t.moveTo(a.x,a.y);for(let u=c;u<n.length;u++){let h=n[u],l=u===0?a:n[u-1];if(l.onCurve&&h.onCurve)t.lineTo(h.x,h.y);else if(l.onCurve&&!h.onCurve)var i=h;else if(!l.onCurve&&!h.onCurve){let f=(l.x+h.x)/2,p=(l.y+h.y)/2;t.quadraticCurveTo(l.x,l.y,f,p);var i=h}else if(!l.onCurve&&h.onCurve){t.quadraticCurveTo(i.x,i.y,h.x,h.y);var i=null}else throw new Error("Unknown TTF path state")}i&&t.quadraticCurveTo(i.x,i.y,a.x,a.y),t.closePath()}return t}constructor(...e){super(...e),ft(this,"type","TTF")}}class nb extends Ht{_getName(){return this._font.CFF2?super._getName():this._font["CFF "].getGlyphName(this.id)}bias(e){return e.length<1240?107:e.length<33900?1131:32768}_getPath(){let e=this._font.CFF2||this._font["CFF "],{stream:t}=e,i=e.topDict.CharStrings[this.id],r=i.offset+i.length;t.pos=i.offset;let n=new br,a=[],o=[],c=null,u=0,h=0,l=0,d,f,p=!1;this._usedGsubrs=d={},this._usedSubrs=f={};let m=e.globalSubrIndex||[],b=this.bias(m),g=e.privateDictForGlyph(this.id)||{},y=g.Subrs||[],v=this.bias(y),k=e.topDict.vstore&&e.topDict.vstore.itemVariationStore,C=g.vsindex,_=this._font._variationProcessor;function E(){c==null&&(c=a.shift()+g.nominalWidthX)}function x(){return a.length%2!==0&&E(),u+=a.length>>1,a.length=0}function S(A,R){p&&n.closePath(),n.moveTo(A,R),p=!0}let T=function(){for(;t.pos<r;){let M=t.readUInt8();if(M<32){let j,W,se,Y,ae,he,Q,we,Le,Ze,st,ht,St,dt,G,$;switch(M){case 1:case 3:case 18:case 23:x();break;case 4:a.length>1&&E(),l+=a.shift(),S(h,l);break;case 5:for(;a.length>=2;)h+=a.shift(),l+=a.shift(),n.lineTo(h,l);break;case 6:case 7:for(se=M===6;a.length>=1;)se?h+=a.shift():l+=a.shift(),n.lineTo(h,l),se=!se;break;case 8:for(;a.length>0;)Y=h+a.shift(),ae=l+a.shift(),he=Y+a.shift(),Q=ae+a.shift(),h=he+a.shift(),l=Q+a.shift(),n.bezierCurveTo(Y,ae,he,Q,h,l);break;case 10:if(j=a.pop()+v,W=y[j],W){f[j]=!0;let B=t.pos,D=r;t.pos=W.offset,r=W.offset+W.length,T(),t.pos=B,r=D}break;case 11:if(e.version>=2)break;return;case 14:if(e.version>=2)break;a.length>0&&E(),p&&(n.closePath(),p=!1);break;case 15:if(e.version<2)throw new Error("vsindex operator not supported in CFF v1");C=a.pop();break;case 16:{if(e.version<2)throw new Error("blend operator not supported in CFF v1");if(!_)throw new Error("blend operator in non-variation font");let B=_.getBlendVector(k,C),D=a.pop(),ne=D*B.length,ce=a.length-ne,oe=ce-D;for(let ue=0;ue<D;ue++){let Te=a[oe+ue];for(let me=0;me<B.length;me++)Te+=B[me]*a[ce++];a[oe+ue]=Te}for(;ne--;)a.pop();break}case 19:case 20:x(),t.pos+=u+7>>3;break;case 21:a.length>2&&E(),h+=a.shift(),l+=a.shift(),S(h,l);break;case 22:a.length>1&&E(),h+=a.shift(),S(h,l);break;case 24:for(;a.length>=8;)Y=h+a.shift(),ae=l+a.shift(),he=Y+a.shift(),Q=ae+a.shift(),h=he+a.shift(),l=Q+a.shift(),n.bezierCurveTo(Y,ae,he,Q,h,l);h+=a.shift(),l+=a.shift(),n.lineTo(h,l);break;case 25:for(;a.length>=8;)h+=a.shift(),l+=a.shift(),n.lineTo(h,l);Y=h+a.shift(),ae=l+a.shift(),he=Y+a.shift(),Q=ae+a.shift(),h=he+a.shift(),l=Q+a.shift(),n.bezierCurveTo(Y,ae,he,Q,h,l);break;case 26:for(a.length%2&&(h+=a.shift());a.length>=4;)Y=h,ae=l+a.shift(),he=Y+a.shift(),Q=ae+a.shift(),h=he,l=Q+a.shift(),n.bezierCurveTo(Y,ae,he,Q,h,l);break;case 27:for(a.length%2&&(l+=a.shift());a.length>=4;)Y=h+a.shift(),ae=l,he=Y+a.shift(),Q=ae+a.shift(),h=he+a.shift(),l=Q,n.bezierCurveTo(Y,ae,he,Q,h,l);break;case 28:a.push(t.readInt16BE());break;case 29:if(j=a.pop()+b,W=m[j],W){d[j]=!0;let B=t.pos,D=r;t.pos=W.offset,r=W.offset+W.length,T(),t.pos=B,r=D}break;case 30:case 31:for(se=M===31;a.length>=4;)se?(Y=h+a.shift(),ae=l,he=Y+a.shift(),Q=ae+a.shift(),l=Q+a.shift(),h=he+(a.length===1?a.shift():0)):(Y=h,ae=l+a.shift(),he=Y+a.shift(),Q=ae+a.shift(),h=he+a.shift(),l=Q+(a.length===1?a.shift():0)),n.bezierCurveTo(Y,ae,he,Q,h,l),se=!se;break;case 12:switch(M=t.readUInt8(),M){case 3:let B=a.pop(),D=a.pop();a.push(B&&D?1:0);break;case 4:B=a.pop(),D=a.pop(),a.push(B||D?1:0);break;case 5:B=a.pop(),a.push(B?0:1);break;case 9:B=a.pop(),a.push(Math.abs(B));break;case 10:B=a.pop(),D=a.pop(),a.push(B+D);break;case 11:B=a.pop(),D=a.pop(),a.push(B-D);break;case 12:B=a.pop(),D=a.pop(),a.push(B/D);break;case 14:B=a.pop(),a.push(-B);break;case 15:B=a.pop(),D=a.pop(),a.push(B===D?1:0);break;case 18:a.pop();break;case 20:let ne=a.pop(),ce=a.pop();o[ce]=ne;break;case 21:ce=a.pop(),a.push(o[ce]||0);break;case 22:let oe=a.pop(),ue=a.pop(),Te=a.pop(),me=a.pop();a.push(Te<=me?oe:ue);break;case 23:a.push(Math.random());break;case 24:B=a.pop(),D=a.pop(),a.push(B*D);break;case 26:B=a.pop(),a.push(Math.sqrt(B));break;case 27:B=a.pop(),a.push(B,B);break;case 28:B=a.pop(),D=a.pop(),a.push(D,B);break;case 29:ce=a.pop(),ce<0?ce=0:ce>a.length-1&&(ce=a.length-1),a.push(a[ce]);break;case 30:let ee=a.pop(),Fe=a.pop();if(Fe>=0)for(;Fe>0;){var A=a[ee-1];for(let Ue=ee-2;Ue>=0;Ue--)a[Ue+1]=a[Ue];a[0]=A,Fe--}else for(;Fe<0;){var A=a[0];for(let et=0;et<=ee;et++)a[et]=a[et+1];a[ee-1]=A,Fe++}break;case 34:Y=h+a.shift(),ae=l,he=Y+a.shift(),Q=ae+a.shift(),we=he+a.shift(),Le=Q,Ze=we+a.shift(),st=Le,ht=Ze+a.shift(),St=st,dt=ht+a.shift(),G=St,h=dt,l=G,n.bezierCurveTo(Y,ae,he,Q,we,Le),n.bezierCurveTo(Ze,st,ht,St,dt,G);break;case 35:$=[];for(let Ue=0;Ue<=5;Ue++)h+=a.shift(),l+=a.shift(),$.push(h,l);n.bezierCurveTo(...$.slice(0,6)),n.bezierCurveTo(...$.slice(6)),a.shift();break;case 36:Y=h+a.shift(),ae=l+a.shift(),he=Y+a.shift(),Q=ae+a.shift(),we=he+a.shift(),Le=Q,Ze=we+a.shift(),st=Le,ht=Ze+a.shift(),St=st+a.shift(),dt=ht+a.shift(),G=St,h=dt,l=G,n.bezierCurveTo(Y,ae,he,Q,we,Le),n.bezierCurveTo(Ze,st,ht,St,dt,G);break;case 37:let nt=h,wt=l;$=[];for(let Ue=0;Ue<=4;Ue++)h+=a.shift(),l+=a.shift(),$.push(h,l);Math.abs(h-nt)>Math.abs(l-wt)?(h+=a.shift(),l=wt):(h=nt,l+=a.shift()),$.push(h,l),n.bezierCurveTo(...$.slice(0,6)),n.bezierCurveTo(...$.slice(6));break;default:throw new Error(`Unknown op: 12 ${M}`)}break;default:throw new Error(`Unknown op: ${M}`)}}else if(M<247)a.push(M-139);else if(M<251){var R=t.readUInt8();a.push((M-247)*256+R+108)}else if(M<255){var R=t.readUInt8();a.push(-(M-251)*256-R-108)}else a.push(t.readInt32BE()/65536)}};return T(),p&&n.closePath(),n}constructor(...e){super(...e),ft(this,"type","CFF")}}let ab=new F({originX:w,originY:w,type:new Me(4),data:new Bt(s=>s.parent.buflen-s._currentOffset)});class ob extends on{getImageForSize(e){for(let a=0;a<this._font.sbix.imageTables.length;a++){var t=this._font.sbix.imageTables[a];if(t.ppem>=e)break}let i=t.imageOffsets,r=i[this.id],n=i[this.id+1];return r===n?null:(this._font.stream.pos=r,ab.decode(this._font.stream,{buflen:n-r}))}render(e,t){let i=this.getImageForSize(t);if(i!=null){let r=t/this._font.unitsPerEm;e.image(i.data,{height:t,x:i.originX,y:(this.bbox.minY-i.originY)*r})}this._font.sbix.flags.renderOutlines&&super.render(e,t)}constructor(...e){super(...e),ft(this,"type","SBIX")}}class Kc{constructor(e,t){this.glyph=e,this.color=t}}class lb extends Ht{_getBBox(){let e=new ki;for(let t=0;t<this.layers.length;t++){let r=this.layers[t].glyph.bbox;e.addPoint(r.minX,r.minY),e.addPoint(r.maxX,r.maxY)}return e}get layers(){let e=this._font.CPAL,t=this._font.COLR,i=0,r=t.baseGlyphRecord.length-1;for(;i<=r;){let h=i+r>>1;var n=t.baseGlyphRecord[h];if(this.id<n.gid)r=h-1;else if(this.id>n.gid)i=h+1;else{var a=n;break}}if(a==null){var o=this._font._getBaseGlyph(this.id),c={red:0,green:0,blue:0,alpha:255};return[new Kc(o,c)]}let u=[];for(let h=a.firstLayerIndex;h<a.firstLayerIndex+a.numLayers;h++){var n=t.layerRecords[h],c=e.colorRecords[n.paletteIndex],o=this._font._getBaseGlyph(n.gid);u.push(new Kc(o,c))}return u}render(e,t){for(let{glyph:i,color:r}of this.layers)e.fillColor([r.red,r.green,r.blue],r.alpha/255*100),i.render(e,t)}constructor(...e){super(...e),ft(this,"type","COLR")}}const cb=32768,ub=4095,hb=32768,Yc=16384,db=8192,Jc=4095,Qc=128,eu=127,fb=128,pb=64,mb=63;class gb{normalizeCoords(e){let t=[];for(var i=0;i<this.font.fvar.axis.length;i++){let r=this.font.fvar.axis[i];e[i]<r.defaultValue?t.push((e[i]-r.defaultValue+Number.EPSILON)/(r.defaultValue-r.minValue+Number.EPSILON)):t.push((e[i]-r.defaultValue+Number.EPSILON)/(r.maxValue-r.defaultValue+Number.EPSILON))}if(this.font.avar)for(var i=0;i<this.font.avar.segment.length;i++){let n=this.font.avar.segment[i];for(let a=0;a<n.correspondence.length;a++){let o=n.correspondence[a];if(a>=1&&t[i]<o.fromCoord){let c=n.correspondence[a-1];t[i]=((t[i]-c.fromCoord)*(o.toCoord-c.toCoord)+Number.EPSILON)/(o.fromCoord-c.fromCoord+Number.EPSILON)+c.toCoord;break}}}return t}transformPoints(e,t){if(!this.font.fvar||!this.font.gvar)return;let{gvar:i}=this.font;if(e>=i.glyphCount)return;let r=i.offsets[e];if(r===i.offsets[e+1])return;let{stream:n}=this.font;if(n.pos=r,n.pos>=n.length)return;let a=n.readUInt16BE(),o=r+n.readUInt16BE();if(a&cb){var c=n.pos;n.pos=o;var u=this.decodePoints();o=n.pos,n.pos=c}let h=t.map(b=>b.copy());a&=ub;for(let b=0;b<a;b++){let g=n.readUInt16BE(),y=n.readUInt16BE();if(y&hb){var l=[];for(let x=0;x<i.axisCount;x++)l.push(n.readInt16BE()/16384)}else{if((y&Jc)>=i.globalCoordCount)throw new Error("Invalid gvar table");var l=i.globalCoords[y&Jc]}if(y&Yc){var d=[];for(let x=0;x<i.axisCount;x++)d.push(n.readInt16BE()/16384);var f=[];for(let x=0;x<i.axisCount;x++)f.push(n.readInt16BE()/16384)}let v=this.tupleFactor(y,l,d,f);if(v===0){o+=g;continue}var c=n.pos;if(n.pos=o,y&db)var p=this.decodePoints();else var p=u;let C=p.length===0?t.length:p.length,_=this.decodeDeltas(C),E=this.decodeDeltas(C);if(p.length===0)for(let x=0;x<t.length;x++){var m=t[x];m.x+=Math.round(_[x]*v),m.y+=Math.round(E[x]*v)}else{let x=h.map(T=>T.copy()),S=t.map(()=>!1);for(let T=0;T<p.length;T++){let A=p[T];if(A<t.length){let R=x[A];S[A]=!0,R.x+=_[T]*v,R.y+=E[T]*v}}this.interpolateMissingDeltas(x,h,S);for(let T=0;T<t.length;T++){let A=x[T].x-h[T].x,R=x[T].y-h[T].y;t[T].x=Math.round(t[T].x+A),t[T].y=Math.round(t[T].y+R)}}o+=g,n.pos=c}}decodePoints(){let e=this.font.stream,t=e.readUInt8();t&Qc&&(t=(t&eu)<<8|e.readUInt8());let i=new Uint16Array(t),r=0,n=0;for(;r<t;){let a=e.readUInt8(),o=(a&eu)+1,c=a&Qc?e.readUInt16:e.readUInt8;for(let u=0;u<o&&r<t;u++)n+=c.call(e),i[r++]=n}return i}decodeDeltas(e){let t=this.font.stream,i=0,r=new Int16Array(e);for(;i<e;){let n=t.readUInt8(),a=(n&mb)+1;if(n&fb)i+=a;else{let o=n&pb?t.readInt16BE:t.readInt8;for(let c=0;c<a&&i<e;c++)r[i++]=o.call(t)}}return r}tupleFactor(e,t,i,r){let n=this.normalizedCoords,{gvar:a}=this.font,o=1;for(let c=0;c<a.axisCount;c++)if(t[c]!==0){if(n[c]===0)return 0;if(e&Yc){if(n[c]<i[c]||n[c]>r[c])return 0;n[c]<t[c]?o=o*(n[c]-i[c]+Number.EPSILON)/(t[c]-i[c]+Number.EPSILON):o=o*(r[c]-n[c]+Number.EPSILON)/(r[c]-t[c]+Number.EPSILON)}else{if(n[c]<Math.min(0,t[c])||n[c]>Math.max(0,t[c]))return 0;o=(o*n[c]+Number.EPSILON)/(t[c]+Number.EPSILON)}}return o}interpolateMissingDeltas(e,t,i){if(e.length===0)return;let r=0;for(;r<e.length;){let n=r,a=r,o=e[a];for(;!o.endContour;)o=e[++a];for(;r<=a&&!i[r];)r++;if(r>a)continue;let c=r,u=r;for(r++;r<=a;)i[r]&&(this.deltaInterpolate(u+1,r-1,u,r,t,e),u=r),r++;u===c?this.deltaShift(n,a,u,t,e):(this.deltaInterpolate(u+1,a,u,c,t,e),c>0&&this.deltaInterpolate(n,c-1,u,c,t,e)),r=a+1}}deltaInterpolate(e,t,i,r,n,a){if(e>t)return;let o=["x","y"];for(let u=0;u<o.length;u++){let h=o[u];if(n[i][h]>n[r][h]){var c=i;i=r,r=c}let l=n[i][h],d=n[r][h],f=a[i][h],p=a[r][h];if(l!==d||f===p){let m=l===d?0:(p-f)/(d-l);for(let b=e;b<=t;b++){let g=n[b][h];g<=l?g+=f-l:g>=d?g+=p-d:g=f+(g-l)*m,a[b][h]=g}}}}deltaShift(e,t,i,r,n){let a=n[i].x-r[i].x,o=n[i].y-r[i].y;if(!(a===0&&o===0))for(let c=e;c<=t;c++)c!==i&&(n[c].x+=a,n[c].y+=o)}getAdvanceAdjustment(e,t){let i,r;if(t.advanceWidthMapping){let n=e;n>=t.advanceWidthMapping.mapCount&&(n=t.advanceWidthMapping.mapCount-1),t.advanceWidthMapping.entryFormat,{outerIndex:i,innerIndex:r}=t.advanceWidthMapping.mapData[n]}else i=0,r=e;return this.getDelta(t.itemVariationStore,i,r)}getDelta(e,t,i){if(t>=e.itemVariationData.length)return 0;let r=e.itemVariationData[t];if(i>=r.deltaSets.length)return 0;let n=r.deltaSets[i],a=this.getBlendVector(e,t),o=0;for(let c=0;c<r.regionIndexCount;c++)o+=n.deltas[c]*a[c];return o}getBlendVector(e,t){let i=e.itemVariationData[t];if(this.blendVectors.has(i))return this.blendVectors.get(i);let r=this.normalizedCoords,n=[];for(let a=0;a<i.regionIndexCount;a++){let o=1,c=i.regionIndexes[a],u=e.variationRegionList.variationRegions[c];for(let h=0;h<u.length;h++){let l=u[h],d;l.startCoord>l.peakCoord||l.peakCoord>l.endCoord||l.startCoord<0&&l.endCoord>0&&l.peakCoord!==0||l.peakCoord===0?d=1:r[h]<l.startCoord||r[h]>l.endCoord?d=0:r[h]===l.peakCoord?d=1:r[h]<l.peakCoord?d=(r[h]-l.startCoord+Number.EPSILON)/(l.peakCoord-l.startCoord+Number.EPSILON):d=(l.endCoord-r[h]+Number.EPSILON)/(l.endCoord-l.peakCoord+Number.EPSILON),o*=d}n[a]=o}return this.blendVectors.set(i,n),n}constructor(e,t){this.font=e,this.normalizedCoords=this.normalizeCoords(t),this.blendVectors=new Map}}Promise.resolve();class tu{includeGlyph(e){return typeof e=="object"&&(e=e.id),this.mapping[e]==null&&(this.glyphs.push(e),this.mapping[e]=this.glyphs.length-1),this.mapping[e]}constructor(e){this.font=e,this.glyphs=[],this.mapping={},this.includeGlyph(0)}}const yb=1,bb=2,vb=4,wb=8,xb=16,Cb=32;class iu{static size(e){return e>=0&&e<=255?1:2}static encode(e,t){t>=0&&t<=255?e.writeUInt8(t):e.writeInt16BE(t)}}let ru=new F({numberOfContours:z,xMin:z,yMin:z,xMax:z,yMax:z,endPtsOfContours:new I(w,"numberOfContours"),instructions:new I(H,w),flags:new I(H,0),xPoints:new I(iu,0),yPoints:new I(iu,0)});class kb{encodeSimple(e,t=[]){let i=[],r=[],n=[],a=[],o=0,c=0,u=0,h=0,l=0;for(let g=0;g<e.commands.length;g++){let y=e.commands[g];for(let v=0;v<y.args.length;v+=2){let k=y.args[v],C=y.args[v+1],_=0;if(y.command==="quadraticCurveTo"&&v===2){let E=e.commands[g+1];if(E&&E.command==="quadraticCurveTo"){let x=(c+E.args[0])/2,S=(u+E.args[1])/2;if(k===x&&C===S)continue}}y.command==="quadraticCurveTo"&&v===0||(_|=yb),_=this._encodePoint(k,c,r,_,bb,xb),_=this._encodePoint(C,u,n,_,vb,Cb),_===h&&o<255?(a[a.length-1]|=wb,o++):(o>0&&(a.push(o),o=0),a.push(_),h=_),c=k,u=C,l++}y.command==="closePath"&&i.push(l-1)}e.commands.length>1&&e.commands[e.commands.length-1].command!=="closePath"&&i.push(l-1);let d=e.bbox,f={numberOfContours:i.length,xMin:d.minX,yMin:d.minY,xMax:d.maxX,yMax:d.maxY,endPtsOfContours:i,instructions:t,flags:a,xPoints:r,yPoints:n},p=ru.size(f),m=4-p%4,b=new Ts(p+m);return ru.encode(b,f),m!==0&&b.fill(0,m),b.buffer}_encodePoint(e,t,i,r,n,a){let o=e-t;return e===t?r|=a:(-255<=o&&o<=255&&(r|=n,o<0?o=-o:r|=a),i.push(o)),r}}class Sb extends tu{_addGlyph(e){let t=this.font.getGlyph(e),i=t._decode(),r=this.font.loca.offsets[e],n=this.font.loca.offsets[e+1],a=this.font._getTableStream("glyf");a.pos+=r;let o=a.readBuffer(n-r);if(i&&i.numberOfContours<0){o=new Uint8Array(o);let c=new DataView(o.buffer);for(let u of i.components)e=this.includeGlyph(u.glyphID),c.setUint16(u.pos,e)}else i&&this.font._variationProcessor&&(o=this.glyphEncoder.encodeSimple(t.path,i.instructions));return this.glyf.push(o),this.loca.offsets.push(this.offset),this.hmtx.metrics.push({advance:t.advanceWidth,bearing:t._getMetrics().leftBearing}),this.offset+=o.length,this.glyf.length-1}encode(){this.glyf=[],this.offset=0,this.loca={offsets:[],version:this.font.loca.version},this.hmtx={metrics:[],bearings:[]};let e=0;for(;e<this.glyphs.length;)this._addGlyph(this.glyphs[e++]);let t=oa(this.font.maxp);t.numGlyphs=this.glyf.length,this.loca.offsets.push(this.offset);let i=oa(this.font.head);i.indexToLocFormat=this.loca.version;let r=oa(this.font.hhea);return r.numberOfMetrics=this.hmtx.metrics.length,Cc.toBuffer({tables:{head:i,hhea:r,loca:this.loca,maxp:t,"cvt ":this.font["cvt "],prep:this.font.prep,glyf:this.glyf,hmtx:this.hmtx,fpgm:this.font.fpgm}})}constructor(e){super(e),this.glyphEncoder=new kb}}class Tb extends tu{subsetCharstrings(){this.charstrings=[];let e={};for(let t of this.glyphs){this.charstrings.push(this.cff.getCharString(t));let i=this.font.getGlyph(t);i.path;for(let r in i._usedGsubrs)e[r]=!0}this.gsubrs=this.subsetSubrs(this.cff.globalSubrIndex,e)}subsetSubrs(e,t){let i=[];for(let r=0;r<e.length;r++){let n=e[r];t[r]?(this.cff.stream.pos=n.offset,i.push(this.cff.stream.readBuffer(n.length))):i.push(new Uint8Array([11]))}return i}subsetFontdict(e){e.FDArray=[],e.FDSelect={version:0,fds:[]};let t={},i=[],r={};for(let n of this.glyphs){let a=this.cff.fdForGlyph(n);if(a==null)continue;t[a]||(e.FDArray.push(Object.assign({},this.cff.topDict.FDArray[a])),i.push({}),r[a]=e.FDArray.length-1),t[a]=!0,e.FDSelect.fds.push(r[a]);let o=this.font.getGlyph(n);o.path;for(let c in o._usedSubrs)i[r[a]][c]=!0}for(let n=0;n<e.FDArray.length;n++){let a=e.FDArray[n];delete a.FontName,a.Private&&a.Private.Subrs&&(a.Private=Object.assign({},a.Private),a.Private.Subrs=this.subsetSubrs(a.Private.Subrs,i[n]))}}createCIDFontdict(e){let t={};for(let r of this.glyphs){let n=this.font.getGlyph(r);n.path;for(let a in n._usedSubrs)t[a]=!0}let i=Object.assign({},this.cff.topDict.Private);return this.cff.topDict.Private&&this.cff.topDict.Private.Subrs&&(i.Subrs=this.subsetSubrs(this.cff.topDict.Private.Subrs,t)),e.FDArray=[{Private:i}],e.FDSelect={version:3,nRanges:1,ranges:[{first:0,fd:0}],sentinel:this.charstrings.length}}addString(e){return e?(this.strings||(this.strings=[]),this.strings.push(e),Ls.length+this.strings.length-1):null}encode(){this.subsetCharstrings();let e={version:this.charstrings.length>255?2:1,ranges:[{first:1,nLeft:this.charstrings.length-2}]},t=Object.assign({},this.cff.topDict);t.Private=null,t.charset=e,t.Encoding=null,t.CharStrings=this.charstrings;for(let r of["version","Notice","Copyright","FullName","FamilyName","Weight","PostScript","BaseFontName","FontName"])t[r]=this.addString(this.cff.string(t[r]));t.ROS=[this.addString("Adobe"),this.addString("Identity"),0],t.CIDCount=this.charstrings.length,this.cff.isCIDFont?this.subsetFontdict(t):this.createCIDFontdict(t);let i={version:1,hdrSize:this.cff.hdrSize,offSize:4,header:this.cff.header,nameIndex:[this.cff.postscriptName],topDictIndex:[t],stringIndex:this.strings,globalSubrIndex:this.gsubrs};return ac.toBuffer(i)}constructor(e){if(super(e),this.cff=this.font["CFF "],!this.cff)throw new Error("Not a CFF Font")}}class lt{static probe(e){let t=js.decode(e.slice(0,4));return t==="true"||t==="OTTO"||t==="\0\0\0"}setDefaultLanguage(e=null){this.defaultLanguage=e}_getTable(e){if(!(e.tag in this._tables))try{this._tables[e.tag]=this._decodeTable(e)}catch{}return this._tables[e.tag]}_getTableStream(e){let t=this.directory.tables[e];return t?(this.stream.pos=t.offset,this.stream):null}_decodeDirectory(){return this.directory=Cc.decode(this.stream,{_startOffset:0})}_decodeTable(e){let t=this.stream.pos,i=this._getTableStream(e.tag),r=Vs[e.tag].decode(i,this,e.length);return this.stream.pos=t,r}getName(e,t=this.defaultLanguage||Ms){let i=this.name&&this.name.records[e];return i&&(i[t]||i[this.defaultLanguage]||i[Ms]||i.en||i[Object.keys(i)[0]])||null}get postscriptName(){return this.getName("postscriptName")}get fullName(){return this.getName("fullName")}get familyName(){return this.getName("fontFamily")}get subfamilyName(){return this.getName("fontSubfamily")}get copyright(){return this.getName("copyright")}get version(){return this.getName("version")}get ascent(){return this.hhea.ascent}get descent(){return this.hhea.descent}get lineGap(){return this.hhea.lineGap}get underlinePosition(){return this.post.underlinePosition}get underlineThickness(){return this.post.underlineThickness}get italicAngle(){return this.post.italicAngle}get capHeight(){let e=this["OS/2"];return e?e.capHeight:this.ascent}get xHeight(){let e=this["OS/2"];return e?e.xHeight:0}get numGlyphs(){return this.maxp.numGlyphs}get unitsPerEm(){return this.head.unitsPerEm}get bbox(){return Object.freeze(new ki(this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax))}get _cmapProcessor(){return new _a(this.cmap)}get characterSet(){return this._cmapProcessor.getCharacterSet()}hasGlyphForCodePoint(e){return!!this._cmapProcessor.lookup(e)}glyphForCodePoint(e){return this.getGlyph(this._cmapProcessor.lookup(e),[e])}glyphsForString(e){let t=[],i=e.length,r=0,n=-1,a=-1;for(;r<=i;){let o=0,c=0;if(r<i){if(o=e.charCodeAt(r++),55296<=o&&o<=56319&&r<i){let u=e.charCodeAt(r);56320<=u&&u<=57343&&(r++,o=((o&1023)<<10)+(u&1023)+65536)}c=65024<=o&&o<=65039||917760<=o&&o<=917999?1:0}else r++;a===0&&c===1?t.push(this.getGlyph(this._cmapProcessor.lookup(n,o),[n,o])):a===0&&c===0&&t.push(this.glyphForCodePoint(n)),n=o,a=c}return t}get _layoutEngine(){return new Wy(this)}layout(e,t,i,r,n){return this._layoutEngine.layout(e,t,i,r,n)}stringsForGlyph(e){return this._layoutEngine.stringsForGlyph(e)}get availableFeatures(){return this._layoutEngine.getAvailableFeatures()}getAvailableFeatures(e,t){return this._layoutEngine.getAvailableFeatures(e,t)}_getBaseGlyph(e,t=[]){return this._glyphs[e]||(this.directory.tables.glyf?this._glyphs[e]=new on(e,t,this):(this.directory.tables["CFF "]||this.directory.tables.CFF2)&&(this._glyphs[e]=new nb(e,t,this))),this._glyphs[e]||null}getGlyph(e,t=[]){return this._glyphs[e]||(this.directory.tables.sbix?this._glyphs[e]=new ob(e,t,this):this.directory.tables.COLR&&this.directory.tables.CPAL?this._glyphs[e]=new lb(e,t,this):this._getBaseGlyph(e,t)),this._glyphs[e]||null}createSubset(){return this.directory.tables["CFF "]?new Tb(this):new Sb(this)}get variationAxes(){let e={};if(!this.fvar)return e;for(let t of this.fvar.axis)e[t.axisTag.trim()]={name:t.name.en,min:t.minValue,default:t.defaultValue,max:t.maxValue};return e}get namedVariations(){let e={};if(!this.fvar)return e;for(let t of this.fvar.instance){let i={};for(let r=0;r<this.fvar.axis.length;r++){let n=this.fvar.axis[r];i[n.axisTag.trim()]=t.coord[r]}e[t.name.en]=i}return e}getVariation(e){if(!(this.directory.tables.fvar&&(this.directory.tables.gvar&&this.directory.tables.glyf||this.directory.tables.CFF2)))throw new Error("Variations require a font with the fvar, gvar and glyf, or CFF2 tables.");if(typeof e=="string"&&(e=this.namedVariations[e]),typeof e!="object")throw new Error("Variation settings must be either a variation name or settings object.");let t=this.fvar.axis.map((n,a)=>{let o=n.axisTag.trim();return o in e?Math.max(n.minValue,Math.min(n.maxValue,e[o])):n.defaultValue}),i=new tt(this.stream.buffer);i.pos=this._directoryPos;let r=new lt(i,t);return r._tables=this._tables,r}get _variationProcessor(){if(!this.fvar)return null;let e=this.variationCoords;return!e&&!this.CFF2?null:(e||(e=this.fvar.axis.map(t=>t.defaultValue)),new gb(this,e))}getFont(e){return this.getVariation(e)}constructor(e,t=null){ft(this,"type","TTF"),this.defaultLanguage=null,this.stream=e,this.variationCoords=t,this._directoryPos=this.stream.pos,this._tables={},this._glyphs={},this._decodeDirectory();for(let i in this.directory.tables){let r=this.directory.tables[i];Vs[i]&&r.length>0&&Object.defineProperty(this,i,{get:this._getTable.bind(this,r)})}}}it([rt],lt.prototype,"bbox",null),it([rt],lt.prototype,"_cmapProcessor",null),it([rt],lt.prototype,"characterSet",null),it([rt],lt.prototype,"_layoutEngine",null),it([rt],lt.prototype,"variationAxes",null),it([rt],lt.prototype,"namedVariations",null),it([rt],lt.prototype,"_variationProcessor",null);let Eb=new F({tag:new Me(4),offset:new P(O,"void",{type:"global"}),compLength:O,length:O,origChecksum:O}),su=new F({tag:new Me(4),flavor:O,length:O,numTables:w,reserved:new $e(w),totalSfntSize:O,majorVersion:w,minorVersion:w,metaOffset:O,metaLength:O,metaOrigLength:O,privOffset:O,privLength:O,tables:new I(Eb,"numTables")});su.process=function(){let s={};for(let e of this.tables)s[e.tag]=e;this.tables=s};var _b=su;class Ab extends lt{static probe(e){return js.decode(e.slice(0,4))==="wOFF"}_decodeDirectory(){this.directory=_b.decode(this.stream,{_startOffset:0})}_getTableStream(e){let t=this.directory.tables[e];if(t)if(this.stream.pos=t.offset,t.compLength<t.length){this.stream.pos+=2;let i=new Uint8Array(t.length),r=Td(this.stream.readBuffer(t.compLength-2),i);return new tt(r)}else return this.stream;return null}constructor(...e){super(...e),ft(this,"type","WOFF")}}class Ib extends on{_decode(){return this._font._transformedGlyphs[this.id]}_getCBox(){return this.path.bbox}constructor(...e){super(...e),ft(this,"type","WOFF2")}}const nu={decode(s){let e=0,t=[0,1,2,3,4];for(let i=0;i<t.length;i++){let r=s.readUInt8();if(e&3758096384)throw new Error("Overflow");if(e=e<<7|r&127,!(r&128))return e}throw new Error("Bad base 128 number")}};let Pb=["cmap","head","hhea","hmtx","maxp","name","OS/2","post","cvt ","fpgm","glyf","loca","prep","CFF ","VORG","EBDT","EBLC","gasp","hdmx","kern","LTSH","PCLT","VDMX","vhea","vmtx","BASE","GDEF","GPOS","GSUB","EBSC","JSTF","MATH","CBDT","CBLC","COLR","CPAL","SVG ","sbix","acnt","avar","bdat","bloc","bsln","cvar","fdsc","feat","fmtx","fvar","gvar","hsty","just","lcar","mort","morx","opbd","prop","trak","Zapf","Silf","Glat","Gloc","Feat","Sill"],Ob=new F({flags:H,customTag:new Es(new Me(4),s=>(s.flags&63)===63),tag:s=>s.customTag||Pb[s.flags&63],length:nu,transformVersion:s=>s.flags>>>6&3,transformed:s=>s.tag==="glyf"||s.tag==="loca"?s.transformVersion===0:s.transformVersion!==0,transformLength:new Es(nu,s=>s.transformed)}),au=new F({tag:new Me(4),flavor:O,length:O,numTables:w,reserved:new $e(w),totalSfntSize:O,totalCompressedSize:O,majorVersion:w,minorVersion:w,metaOffset:O,metaLength:O,metaOrigLength:O,privOffset:O,privLength:O,tables:new I(Ob,"numTables")});au.process=function(){let s={};for(let e=0;e<this.tables.length;e++){let t=this.tables[e];s[t.tag]=t}return this.tables=s};var Fb=au;class Rb extends lt{static probe(e){return js.decode(e.slice(0,4))==="wOF2"}_decodeDirectory(){this.directory=Fb.decode(this.stream),this._dataPos=this.stream.pos}_decompress(){if(!this._decompressed){this.stream.pos=this._dataPos;let e=this.stream.readBuffer(this.directory.totalCompressedSize),t=0;for(let r in this.directory.tables){let n=this.directory.tables[r];n.offset=t,t+=n.transformLength!=null?n.transformLength:n.length}let i=nf(e,t);if(!i)throw new Error("Error decoding compressed data in WOFF2");this.stream=new tt(i),this._decompressed=!0}}_decodeTable(e){return this._decompress(),super._decodeTable(e)}_getBaseGlyph(e,t=[]){if(!this._glyphs[e])return this.directory.tables.glyf&&this.directory.tables.glyf.transformed?(this._transformedGlyphs||this._transformGlyfTable(),this._glyphs[e]=new Ib(e,t,this)):super._getBaseGlyph(e,t)}_transformGlyfTable(){this._decompress(),this.stream.pos=this.directory.tables.glyf.offset;let e=Mb.decode(this.stream),t=[];for(let r=0;r<e.numGlyphs;r++){let n={},a=e.nContours.readInt16BE();if(n.numberOfContours=a,a>0){let o=[],c=0;for(let u=0;u<a;u++){let h=Ba(e.nPoints);c+=h,o.push(c)}n.points=zb(e.flags,e.glyphs,c);for(let u=0;u<a;u++)n.points[o[u]-1].endContour=!0;var i=Ba(e.glyphs)}else if(a<0&&on.prototype._decodeComposite.call({_font:this},n,e.composites))var i=Ba(e.glyphs);t.push(n)}this._transformedGlyphs=t}constructor(...e){super(...e),ft(this,"type","WOFF2")}}class Xi{decode(e,t){return new tt(this._buf.decode(e,t))}constructor(e){this.length=e,this._buf=new Bt(e)}}let Mb=new F({version:O,numGlyphs:w,indexFormat:w,nContourStreamSize:O,nPointsStreamSize:O,flagStreamSize:O,glyphStreamSize:O,compositeStreamSize:O,bboxStreamSize:O,instructionStreamSize:O,nContours:new Xi("nContourStreamSize"),nPoints:new Xi("nPointsStreamSize"),flags:new Xi("flagStreamSize"),glyphs:new Xi("glyphStreamSize"),composites:new Xi("compositeStreamSize"),bboxes:new Xi("bboxStreamSize"),instructions:new Xi("instructionStreamSize")});const Db=253,Bb=254,Lb=255,ou=253;function Ba(s){let e=s.readUInt8();return e===Db?s.readUInt16BE():e===Lb?s.readUInt8()+ou:e===Bb?s.readUInt8()+ou*2:e}function jt(s,e){return s&1?e:-e}function zb(s,e,t){let i,r=i=0,n=[];for(let c=0;c<t;c++){let u=0,h=0,l=s.readUInt8(),d=!(l>>7);if(l&=127,l<10)u=0,h=jt(l,((l&14)<<7)+e.readUInt8());else if(l<20)u=jt(l,((l-10&14)<<7)+e.readUInt8()),h=0;else if(l<84){var a=l-20,o=e.readUInt8();u=jt(l,1+(a&48)+(o>>4)),h=jt(l>>1,1+((a&12)<<2)+(o&15))}else if(l<120){var a=l-84;u=jt(l,1+(a/12<<8)+e.readUInt8()),h=jt(l>>1,1+(a%12>>2<<8)+e.readUInt8())}else if(l<124){var o=e.readUInt8();let p=e.readUInt8();u=jt(l,(o<<4)+(p>>4)),h=jt(l>>1,((p&15)<<8)+e.readUInt8())}else u=jt(l,e.readUInt16BE()),h=jt(l>>1,e.readUInt16BE());r+=u,i+=h,n.push(new It(d,!1,r,i))}return n}let $b=new xe(O,{65536:{numFonts:O,offsets:new I(O,"numFonts")},131072:{numFonts:O,offsets:new I(O,"numFonts"),dsigTag:O,dsigLength:O,dsigOffset:O}});class Nb{static probe(e){return js.decode(e.slice(0,4))==="ttcf"}getFont(e){for(let t of this.header.offsets){let i=new tt(this.stream.buffer);i.pos=t;let r=new lt(i);if(r.postscriptName===e||r.postscriptName instanceof Uint8Array&&e instanceof Uint8Array&&r.postscriptName.every((n,a)=>e[a]===n))return r}return null}get fonts(){let e=[];for(let t of this.header.offsets){let i=new tt(this.stream.buffer);i.pos=t,e.push(new lt(i))}return e}constructor(e){if(ft(this,"type","TTC"),this.stream=e,e.readString(4)!=="ttcf")throw new Error("Not a TrueType collection");this.header=$b.decode(e)}}let Ub=new Me(H);new F({len:O,buf:new Bt("len")});let Vb=new F({id:w,nameOffset:z,attr:H,dataOffset:gi,handle:O}),Hb=new F({name:new Me(4),maxTypeIndex:w,refList:new P(w,new I(Vb,s=>s.maxTypeIndex+1),{type:"parent"})}),jb=new F({length:w,types:new I(Hb,s=>s.length+1)}),Wb=new F({reserved:new $e(H,24),typeList:new P(w,jb),nameListOffset:new P(w,"void")}),lu=new F({dataOffset:O,map:new P(O,Wb),dataLength:O,mapLength:O});class Gb{static probe(e){let t=new tt(e);try{var i=lu.decode(t)}catch{return!1}for(let r of i.map.typeList.types)if(r.name==="sfnt")return!0;return!1}getFont(e){if(!this.sfnt)return null;for(let t of this.sfnt.refList){let i=this.header.dataOffset+t.dataOffset+4,r=new tt(this.stream.buffer.slice(i)),n=new lt(r);if(n.postscriptName===e||n.postscriptName instanceof Uint8Array&&e instanceof Uint8Array&&n.postscriptName.every((a,o)=>e[o]===a))return n}return null}get fonts(){let e=[];for(let t of this.sfnt.refList){let i=this.header.dataOffset+t.dataOffset+4,r=new tt(this.stream.buffer.slice(i));e.push(new lt(r))}return e}constructor(e){ft(this,"type","DFont"),this.stream=e,this.header=lu.decode(this.stream);for(let t of this.header.map.typeList.types){for(let i of t.refList)i.nameOffset>=0?(this.stream.pos=i.nameOffset+this.header.map.nameListOffset,i.name=Ub.decode(this.stream)):i.name=null;t.name==="sfnt"&&(this.sfnt=t)}}}hr(lt),hr(Ab),hr(Rb),hr(Nb),hr(Gb);var qb=Object.defineProperty,Xb=(s,e,t)=>e in s?qb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,_i=(s,e,t)=>Xb(s,typeof e!="symbol"?e+"":e,t),qe={DEFAULTS:{width:800,height:400,pixelRatio:2,fontFamily:"Roboto",fontSize:48,color:"#000000",textAlign:"left"},LIMITS:{minWidth:1,maxWidth:4096,minHeight:1,maxHeight:4096,minFontSize:1,maxFontSize:512,minDuration:.1,maxDuration:120,maxTextLength:1e4},ANIMATION_TYPES:["typewriter","fadeIn","slideIn","shift","ascend","movingLetters"]},Jr=/^#[A-Fa-f0-9]{6}$/,Zb=J.object({type:J.string().valid("linear","radial").default("linear"),angle:J.number().min(0).max(360).default(0),stops:J.array().items(J.object({offset:J.number().min(0).max(1).required(),color:J.string().pattern(Jr).required()}).unknown(!1)).min(2).required()}).unknown(!1),Kb=J.object({offsetX:J.number().default(0),offsetY:J.number().default(0),blur:J.number().min(0).default(0),color:J.string().pattern(Jr).default("#000000"),opacity:J.number().min(0).max(1).default(.5)}).unknown(!1),Yb=J.object({width:J.number().min(0).default(0),color:J.string().pattern(Jr).default("#000000"),opacity:J.number().min(0).max(1).default(1)}).unknown(!1),Jb=J.object({family:J.string().default(qe.DEFAULTS.fontFamily),size:J.number().min(qe.LIMITS.minFontSize).max(qe.LIMITS.maxFontSize).default(qe.DEFAULTS.fontSize),weight:J.alternatives().try(J.string(),J.number()).default("400"),style:J.string().valid("normal","italic","oblique").default("normal"),color:J.string().pattern(Jr).default(qe.DEFAULTS.color),opacity:J.number().min(0).max(1).default(1)}).unknown(!1),Qb=J.object({letterSpacing:J.number().default(0),lineHeight:J.number().min(0).max(10).default(1.2),textTransform:J.string().valid("none","uppercase","lowercase","capitalize").default("none"),textDecoration:J.string().valid("none","underline","line-through").default("none"),gradient:Zb.optional()}).unknown(!1),e1=J.object({horizontal:J.string().valid("left","center","right").default(qe.DEFAULTS.textAlign),vertical:J.string().valid("top","middle","bottom").default("middle")}).unknown(!1),t1=J.object({preset:J.string().valid(...qe.ANIMATION_TYPES),speed:J.number().min(.1).max(10).default(1),duration:J.number().min(qe.LIMITS.minDuration).max(qe.LIMITS.maxDuration).optional(),style:J.string().valid("character","word").optional().when("preset",{is:J.valid("typewriter","shift"),then:J.optional(),otherwise:J.forbidden()}),direction:J.string().optional().when("preset",{switch:[{is:"ascend",then:J.valid("up","down")},{is:"shift",then:J.valid("left","right","up","down")},{is:"slideIn",then:J.valid("left","right","up","down")},{is:"movingLetters",then:J.valid("left","right","up","down")}],otherwise:J.forbidden()})}).unknown(!1),i1=J.object({color:J.string().pattern(Jr).optional(),opacity:J.number().min(0).max(1).default(1),borderRadius:J.number().min(0).default(0)}).unknown(!1),r1=J.object({src:J.string().uri().required(),family:J.string().required(),weight:J.alternatives().try(J.string(),J.number()).optional(),style:J.string().optional(),originalFamily:J.string().optional()}).unknown(!1),s1=J.object({type:J.string().valid("rich-text").required(),text:J.string().allow("").max(qe.LIMITS.maxTextLength).default(""),width:J.number().min(qe.LIMITS.minWidth).max(qe.LIMITS.maxWidth).default(qe.DEFAULTS.width).optional(),height:J.number().min(qe.LIMITS.minHeight).max(qe.LIMITS.maxHeight).default(qe.DEFAULTS.height).optional(),font:Jb.optional(),style:Qb.optional(),stroke:Yb.optional(),shadow:Kb.optional(),background:i1.optional(),align:e1.optional(),animation:t1.optional(),customFonts:J.array().items(r1).optional(),cacheEnabled:J.boolean().default(!0),pixelRatio:J.number().min(1).max(3).default(qe.DEFAULTS.pixelRatio)}).unknown(!1),ln=null;function cu(){return typeof process<"u"&&process.versions!=null&&process.versions.node!=null}function n1(s){if(s.buffer instanceof ArrayBuffer)return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);const e=new ArrayBuffer(s.byteLength),t=new Uint8Array(e);for(let i=0;i<s.byteLength;i++)t[i]=s[i];return e}async function a1(){try{const{readFile:s}=await Promise.resolve().then(()=>oo),{fileURLToPath:e}=await Promise.resolve().then(()=>oo),t=await Promise.resolve().then(()=>oo),i=t.dirname(e(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Pn&&Pn.tagName.toUpperCase()==="SCRIPT"&&Pn.src||new URL("shotstack-studio.umd.js",document.baseURI).href)),r=[t.join(i,"../../dist/hb.wasm"),t.join(i,"../dist/hb.wasm"),t.join(i,"../../assets/wasm/hb.wasm"),t.join(i,"../assets/wasm/hb.wasm"),t.join(i,"./hb.wasm"),t.join(i,"../hb.wasm")];for(const n of r)try{const a=await s(n);return n1(a)}catch{continue}return}catch{return}}async function o1(s){try{if(s){const e=s.endsWith(".wasm")?s:s.endsWith("/")?`${s}hb.wasm`:`${s}/hb.wasm`;console.log(`Fetching WASM from: ${e}`);const t=await fetch(e);if(t.ok){const i=await t.arrayBuffer(),r=new Uint8Array(i);if(r.length>=4&&r[0]===0&&r[1]===97&&r[2]===115&&r[3]===109)return console.log(`✅ Valid WASM binary loaded (${r.length} bytes)`),i}}return}catch(e){console.error("Error in loadWasmWeb:",e);return}}function l1(s){const e=window.fetch;window.fetch=function(i,r){const n=typeof i=="string"?i:i instanceof URL?i.href:i.url;return n.includes("hb.wasm")||n.endsWith(".wasm")&&!n.includes("source.wasm")?(console.log(`🔄 Intercepted fetch for: ${n}`),Promise.resolve(new Response(s.slice(0),{status:200,statusText:"OK",headers:{"Content-Type":"application/wasm","Content-Length":s.byteLength.toString()}}))):e.apply(this,[i,r])};const t=WebAssembly.instantiateStreaming;t&&(WebAssembly.instantiateStreaming=async function(i,r){try{const n=await i,a=n.url||"";if(a.includes("hb.wasm")||a.endsWith(".wasm")&&!a.includes("source.wasm")){console.log(`🔄 Intercepted instantiateStreaming for: ${a}`);const o=await WebAssembly.compile(s),c=await WebAssembly.instantiate(o,r);return{module:o,instance:c}}return t.call(WebAssembly,n,r)}catch{console.log("🔄 instantiateStreaming failed, using pre-loaded binary");const a=await WebAssembly.compile(s),o=await WebAssembly.instantiate(a,r);return{module:a,instance:o}}})}async function c1(s){if(ln)return ln;try{let e;if(cu()?e=await a1():e=await o1(s),!e)throw new Error("Failed to load WASM binary from any source");console.log(`✅ WASM binary loaded successfully (${e.byteLength} bytes)`),cu()||l1(e);const t=await import("harfbuzzjs");let i;const r=t.default||t;if(typeof r=="function")i=await r({wasmBinary:e});else if(r&&typeof r.then=="function")i=await r;else if(r&&typeof r.createBuffer=="function")i=r;else throw new Error(`Unexpected harfbuzzjs export type: ${typeof r}`);if(!i||typeof i.createBuffer!="function"||typeof i.createFont!="function")throw new Error("Failed to initialize HarfBuzz: unexpected export shape from 'harfbuzzjs'.");return ln=i,console.log("✅ HarfBuzz initialized successfully"),ln}catch(e){throw console.error("Failed to initialize HarfBuzz:",e),new Error(`Failed to initialize HarfBuzz: ${e instanceof Error?e.message:String(e)}`)}}var uu=class Oo{constructor(e){_i(this,"hb"),_i(this,"faces",new Map),_i(this,"fonts",new Map),_i(this,"blobs",new Map),_i(this,"fontkitFonts",new Map),_i(this,"wasmBaseURL"),_i(this,"initPromise"),this.wasmBaseURL=e}static setFallbackLoader(e){Oo.fallbackLoader=e}async init(){if(this.initPromise){await this.initPromise;return}if(!this.hb){this.initPromise=this._doInit();try{await this.initPromise}catch(e){throw new Error(`Failed to initialize FontRegistry: ${e instanceof Error?e.message:String(e)}`)}}}async _doInit(){try{this.hb=await c1("https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm")}catch(e){throw this.initPromise=void 0,e}}async getHB(){if(!this.hb)try{await this.init()}catch(e){throw new Error(`Failed to get HarfBuzz instance: ${e instanceof Error?e.message:String(e)}`)}return this.hb}key(e){return`${e.family}__${e.weight??"400"}__${e.style??"normal"}`}async registerFromBytes(e,t){try{this.hb||await this.init();const i=this.key(t);if(this.fonts.has(i))return;const r=this.hb.createBlob(e),n=this.hb.createFace(r,0),a=this.hb.createFont(n),o=n.upem||1e3;a.setScale(o,o);const c=t.weight??"400",u=typeof c=="string"?parseInt(c,10):c;if(u!==400&&typeof a.setVariations=="function")try{a.setVariations(`wght=${u}`)}catch{}this.blobs.set(i,r),this.faces.set(i,n),this.fonts.set(i,a);try{const h=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e),l=Bl(h);if(l.variationAxes&&Object.keys(l.variationAxes).length>0){const d=l.getVariation({wght:u});this.fontkitFonts.set(i,d),console.log(`✅ Registered variable font: ${t.family} weight=${u}`)}else this.fontkitFonts.set(i,l),console.log(`✅ Registered static font: ${t.family}`)}catch(h){console.warn(`⚠️ Fontkit failed for ${t.family}:`,h)}}catch(i){throw new Error(`Failed to register font "${t.family}": ${i instanceof Error?i.message:String(i)}`)}}async tryFallbackInstall(e){const t=Oo.fallbackLoader;if(!t)return!1;try{const i=await t({family:e.family,weight:e.weight??"400",style:e.style??"normal"});return i?(await this.registerFromBytes(i,{family:e.family,weight:e.weight??"400",style:e.style??"normal"}),!0):!1}catch{return!1}}async getFont(e){try{this.hb||await this.init();const t=this.key(e);let i=this.fonts.get(t);if(i||(i=await this.tryFallbackInstall(e)?this.fonts.get(t):void 0),!i)throw new Error(`Font not registered for ${t}`);return i}catch(t){throw t instanceof Error&&t.message.includes("Font not registered")?t:new Error(`Failed to get font "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async getFace(e){try{this.hb||await this.init();const t=this.key(e);let i=this.faces.get(t);return i||(i=await this.tryFallbackInstall(e)?this.faces.get(t):void 0),i}catch(t){throw new Error(`Failed to get face for "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async getUnitsPerEm(e){try{return(await this.getFace(e))?.upem||1e3}catch(t){throw new Error(`Failed to get units per em for "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async glyphPath(e,t){const i=this.key(e);try{const r=this.fontkitFonts.get(i);if(r){const o=r.getGlyph(t);if(o&&o.path)return o.path.toSVG()}const a=(await this.getFont(e)).glyphToPath(t);return a&&a!==""?a:"M 0 0"}catch(r){throw new Error(`Failed to get glyph path for glyph ${t} in font "${e.family}": ${r instanceof Error?r.message:String(r)}`)}}destroy(){try{for(const[,e]of this.fonts)try{e.destroy()}catch(t){console.error(`Error destroying font: ${t instanceof Error?t.message:String(t)}`)}for(const[,e]of this.faces)try{e.destroy()}catch(t){console.error(`Error destroying face: ${t instanceof Error?t.message:String(t)}`)}for(const[,e]of this.blobs)try{e.destroy()}catch(t){console.error(`Error destroying blob: ${t instanceof Error?t.message:String(t)}`)}this.fonts.clear(),this.faces.clear(),this.blobs.clear(),this.fontkitFonts.clear(),this.hb=void 0,this.initPromise=void 0}catch(e){console.error(`Error during FontRegistry cleanup: ${e instanceof Error?e.message:String(e)}`)}}};_i(uu,"fallbackLoader");var hu=uu,u1=class{constructor(s){this.fonts=s}transformText(s,e){switch(e){case"uppercase":return s.toUpperCase();case"lowercase":return s.toLowerCase();case"capitalize":return s.replace(/\b\w/g,t=>t.toUpperCase());default:return s}}async shapeFull(s,e){try{const t=await this.fonts.getHB(),i=t.createBuffer();try{i.addText(s),i.guessSegmentProperties();const r=await this.fonts.getFont(e),a=(await this.fonts.getFace(e))?.upem||1e3;return r.setScale(a,a),t.shape(r,i),i.json()}finally{try{i.destroy()}catch(r){console.error(`Error destroying HarfBuzz buffer: ${r instanceof Error?r.message:String(r)}`)}}}catch(t){throw new Error(`Failed to shape text with font "${e.family}": ${t instanceof Error?t.message:String(t)}`)}}async layout(s){try{const{textTransform:e,desc:t,fontSize:i,letterSpacing:r,width:n}=s,a=this.transformText(s.text,e);if(!a||a.length===0)return[];let o;try{o=await this.shapeFull(a,t)}catch(g){throw new Error(`Text shaping failed: ${g instanceof Error?g.message:String(g)}`)}let c;try{c=(await this.fonts.getFace(t))?.upem||1e3}catch(g){throw new Error(`Failed to get font metrics: ${g instanceof Error?g.message:String(g)}`)}const u=i/c,h=o.map(g=>{const y=g.cl;let v;return y>=0&&y<a.length&&(v=a[y]),{id:g.g,xAdvance:g.ax*u+r,xOffset:g.dx*u,yOffset:-g.dy*u,cluster:g.cl,char:v}}),l=[];let d=[],f=0;const p=new Set;for(let g=0;g<a.length;g++)a[g]===" "&&p.add(g);let m=-1;for(let g=0;g<h.length;g++){const y=h[g],v=y.xAdvance;if(y.char===`
185
+ `){d.length>0&&l.push({glyphs:d,width:f,y:0}),d=[],f=0,m=g;continue}if(f+v>n&&d.length>0){if(m>-1){const k=m-(g-d.length)+1,C=d.splice(k),_=d.reduce((E,x)=>E+x.xAdvance,0);l.push({glyphs:d,width:_,y:0}),d=C,f=C.reduce((E,x)=>E+x.xAdvance,0)}else l.push({glyphs:d,width:f,y:0}),d=[],f=0;m=-1}d.push(y),f+=v,p.has(y.cluster)&&(m=g)}d.length>0&&l.push({glyphs:d,width:f,y:0});const b=s.lineHeight*i;for(let g=0;g<l.length;g++)l[g].y=(g+1)*b;return l}catch(e){throw e instanceof Error?e:new Error(`Layout failed: ${String(e)}`)}}};function h1(s,e){return s.type==="linear"?{kind:"linear",angle:s.angle,stops:s.stops,opacity:e}:{kind:"radial",stops:s.stops,opacity:e}}function d1(s,e){const t=Math.max(1,Math.round(e.fontSize*.05));let i=e.baselineY+Math.round(e.fontSize*.1);return s==="line-through"&&(i=e.baselineY-Math.round(e.fontSize*.3)),{x1:e.xStart,x2:e.xStart+e.lineWidth,y:i,width:t}}async function f1(s){const e=[];if(e.push({op:"BeginFrame",width:s.canvas.width,height:s.canvas.height,pixelRatio:s.canvas.pixelRatio,clear:!0,bg:s.background&&s.background.color?{color:s.background.color,opacity:s.background.opacity,radius:s.background.borderRadius}:void 0}),s.lines.length===0)return e;const t=Math.max(1,await s.getUnitsPerEm()),i=s.font.size/t,r=s.lines[s.lines.length-1].y;let n;switch(s.align.vertical){case"top":n=s.font.size;break;case"bottom":n=s.textRect.height-r+s.font.size;break;case"middle":default:n=(s.textRect.height-r)/2+s.font.size;break}const a=s.style.gradient?h1(s.style.gradient,1):{kind:"solid",color:s.font.color,opacity:s.font.opacity},o=s.style.gradient?s.style.gradient.stops[s.style.gradient.stops.length-1]?.color??s.font.color:s.font.color;let c=1/0,u=1/0,h=-1/0,l=-1/0;for(const d of s.lines){let f;switch(s.align.horizontal){case"left":f=0;break;case"right":f=s.textRect.width-d.width;break;case"center":default:f=(s.textRect.width-d.width)/2;break}let p=f;const m=n+d.y-s.font.size;for(const b of d.glyphs){const g=await s.glyphPathProvider(b.id);if(!g||g==="M 0 0"){p+=b.xAdvance;continue}const y=p+b.xOffset,v=m+b.yOffset,k=m1(g),C=y+i*k.x,_=y+i*(k.x+k.w),E=v-i*(k.y+k.h),x=v-i*k.y;C<c&&(c=C),E<u&&(u=E),_>h&&(h=_),x>l&&(l=x),s.shadow&&s.shadow.blur>0&&e.push({isShadow:!0,op:"FillPath",path:g,x:y+s.shadow.offsetX,y:v+s.shadow.offsetY,scale:i,fill:{kind:"solid",color:s.shadow.color,opacity:s.shadow.opacity}}),s.stroke&&s.stroke.width>0&&e.push({op:"StrokePath",path:g,x:y,y:v,scale:i,width:s.stroke.width,color:s.stroke.color,opacity:s.stroke.opacity}),e.push({op:"FillPath",path:g,x:y,y:v,scale:i,fill:a}),p+=b.xAdvance}if(s.style.textDecoration!=="none"){const b=d1(s.style.textDecoration,{baselineY:m,fontSize:s.font.size,lineWidth:d.width,xStart:f});e.push({op:"DecorationLine",from:{x:b.x1,y:b.y},to:{x:b.x2,y:b.y},width:b.width,color:o,opacity:s.font.opacity})}}if(c!==1/0){const d={x:c,y:u,w:Math.max(1,h-c),h:Math.max(1,l-u)};for(const f of e)f.op==="FillPath"&&!f.isShadow&&(f.gradientBBox=d)}return e}function p1(s){return s.match(/[MLCQZ]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]}function m1(s){const e=p1(s);let t=0,i=1/0,r=1/0,n=-1/0,a=-1/0;const o=(c,u)=>{c<i&&(i=c),u<r&&(r=u),c>n&&(n=c),u>a&&(a=u)};for(;t<e.length;)switch(e[t++]){case"M":case"L":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]);o(u,h);break}case"C":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]),l=parseFloat(e[t++]),d=parseFloat(e[t++]),f=parseFloat(e[t++]),p=parseFloat(e[t++]);o(u,h),o(l,d),o(f,p);break}case"Q":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]),l=parseFloat(e[t++]),d=parseFloat(e[t++]);o(u,h),o(l,d);break}}return i===1/0?{x:0,y:0,w:0,h:0}:{x:i,y:r,w:n-i,h:a-r}}var La=.999;function g1(s,e,t){if(!t.anim||!t.anim.preset)return s;const{preset:i}=t.anim,r=e.reduce((o,c)=>o+c.glyphs.length,0),n=t.anim.duration??Math.max(.3,r/30/t.anim.speed),a=Math.max(0,Math.min(1,t.t/n));switch(i){case"typewriter":return b1(s,e,a,t.anim.style,t.fontSize,t.t);case"fadeIn":return x1(s,a);case"slideIn":return C1(s,a,t.anim.direction??"left",t.fontSize);case"shift":return w1(s,e,a,t.anim.direction??"left",t.fontSize,t.anim.style,n);case"ascend":return v1(s,e,a,t.anim.direction??"up",t.fontSize,n);case"movingLetters":return k1(s,a,t.anim.direction??"up",t.fontSize);default:return s}}var cn=s=>s.op==="FillPath"&&s.isShadow===!0,du=s=>s.op==="FillPath"&&!s.isShadow;function y1(s){for(const e of s)if(e.op==="FillPath"){const t=e.fill;if(t?.kind==="solid")return t.color;if((t?.kind==="linear"||t?.kind==="radial")&&Array.isArray(t.stops)&&t.stops.length)return t.stops[t.stops.length-1].color||"#000000"}return"#000000"}function b1(s,e,t,i,r,n,a){if(i==="word"){const c=za(e),u=c.length,h=Math.floor(t*u);if(h===0)return s.filter(p=>p.op==="BeginFrame");let l=0;for(let p=0;p<Math.min(h,c.length);p++)l+=c[p].glyphCount;const d=fu(s,l),f=t>=La?d:d.filter(p=>p.op!=="DecorationLine");return t<1&&l>0?pu(f,l,r,n):f}else{const c=e.reduce((d,f)=>d+f.glyphs.length,0),u=Math.floor(t*c);if(u===0)return s.filter(d=>d.op==="BeginFrame");const h=fu(s,u),l=t>=La?h:h.filter(d=>d.op!=="DecorationLine");return t<1&&u>0?pu(l,u,r,n):l}}function v1(s,e,t,i,r,n){const a=za(e),o=a.length;if(o===0)return s;const c=[];let u=0;for(const h of s)if(h.op==="BeginFrame"){c.push(h);break}for(const h of s)if(h.op==="FillPath"||h.op==="StrokePath"){let l=-1,d=0;for(let f=0;f<a.length;f++){const p=a[f].glyphCount;if(u>=d&&u<d+p){l=f;break}d+=p}if(l>=0){const f=l/Math.max(1,o)*(n/n),p=Math.min(1,f+.3);if(t>=p)c.push(h);else if(t>f){const m=(t-f)/Math.max(1e-6,p-f),b=$a(Math.min(1,m)),g=i==="up"?r*.4:-r*.4,y={...h,y:h.y+g*(1-b)};h.op==="FillPath"?y.fill.kind==="solid"?y.fill={...y.fill,opacity:y.fill.opacity*b}:y.fill={...y.fill,opacity:(y.fill.opacity??1)*b}:y.opacity=y.opacity*b,c.push(y)}}du(h)&&u++}else h.op==="DecorationLine"&&t>=La&&c.push(h);return c}function w1(s,e,t,i,r,n,a){const o=n==="word",u={left:{x:r*.6,y:0},right:{x:-r*.6,y:0},up:{x:0,y:r*.6},down:{x:0,y:-r*.6}}[i],h=o?za(e):[],l=e.reduce((v,k)=>v+k.glyphs.length,0),d=o?h.length:l;if(d===0)return s;const f=[];for(const v of s)if(v.op==="BeginFrame"){f.push(v);break}const p=.3,b=a*.7/Math.max(1,d-1),g=v=>{const k=v*b,C=k/a,_=Math.min(1,(k+p)/a);return{startF:C,endF:_}};let y=0;for(const v of s){if(v.op!=="FillPath"&&v.op!=="StrokePath"){v.op==="DecorationLine"&&t>.8&&f.push(v);continue}let k;if(!o)k=y;else{let E=-1,x=0;for(let S=0;S<h.length;S++){const T=h[S].glyphCount;if(y>=x&&y<x+T){E=S;break}x+=T}k=Math.max(0,E)}const{startF:C,endF:_}=g(k);if(t<=C){const E={...v,x:v.x+u.x,y:v.y+u.y};v.op==="FillPath"?E.fill.kind==="solid"?E.fill={...E.fill,opacity:0}:E.fill={...E.fill,opacity:0}:E.opacity=0,f.push(E)}else if(t>=_)f.push(v);else{const E=(t-C)/Math.max(1e-6,_-C),x=$a(Math.min(1,E)),S=u.x*(1-x),T=u.y*(1-x),A={...v,x:v.x+S,y:v.y+T};if(v.op==="FillPath"){const R=A.fill.kind==="solid"?A.fill.opacity:A.fill.opacity??1;A.fill.kind==="solid"?A.fill={...A.fill,opacity:R*x}:A.fill={...A.fill,opacity:R*x}}else A.opacity=A.opacity*x;f.push(A)}du(v)&&y++}return f}function x1(s,e){const t=mu(e),i=.95+.05*t;return T1(s,t,i)}function C1(s,e,t,i){const r=$a(e),n=A1(1-r,t,i*2),a=mu(e);return E1(s,n.dx,n.dy,a)}function k1(s,e,t,i){const r=i*.3;return _1(s,t,r,e)}function za(s){const e=[];let t=0;for(let i=0;i<s.length;i++){const r=s[i],n=S1(r);for(const a of n)a.length>0&&e.push({startGlyph:t,glyphCount:a.length,lineIndex:i}),t+=a.length}return e}function S1(s){const e=[];let t=[];for(const i of s.glyphs)i.char===" "||i.char===" "||i.char===`
186
+ `?t.length&&(e.push([...t]),t=[]):t.push(i);return t.length&&e.push(t),e}function fu(s,e){const t=[];let i=0,r=!1;for(const n of s){if(n.op==="BeginFrame"){t.push(n);continue}if(n.op==="FillPath"&&!cn(n)){i<e&&(t.push(n),r=!0),i++;continue}if(n.op==="StrokePath"){i<e&&t.push(n);continue}if(n.op==="FillPath"&&cn(n)){i<e&&t.push(n);continue}if(n.op==="DecorationLine"&&r){t.push(n);continue}}return t}function pu(s,e,t,i){if(!(Math.floor(i*2*2)%2===0)||e===0)return s;let a=null,o=0;for(const c of s)if(c.op==="FillPath"&&!cn(c)&&(o++,o===e)){a=c;break}if(a&&a.op==="FillPath"){const c=y1(s),u=a.x+t*.5,h=a.y,l={op:"DecorationLine",from:{x:u,y:h-t*.7},to:{x:u,y:h+t*.1},width:Math.max(2,t/25),color:c,opacity:1};return[...s,l]}return s}function T1(s,e,t){let i=0,r=0,n=0;return s.forEach(a=>{a.op==="FillPath"&&(i+=a.x,r+=a.y,n++)}),n>0&&(i/=n,r/=n),s.map(a=>{if(a.op==="FillPath"){const o={...a};if(o.fill.kind==="solid"?o.fill={...o.fill,opacity:o.fill.opacity*e}:o.fill={...o.fill,opacity:(o.fill.opacity??1)*e},t!==1&&n>0){const c=a.x-i,u=a.y-r;o.x=i+c*t,o.y=r+u*t}return o}if(a.op==="StrokePath"){const o={...a,opacity:a.opacity*e};if(t!==1&&n>0){const c=a.x-i,u=a.y-r;o.x=i+c*t,o.y=r+u*t}return o}return a.op==="DecorationLine"?{...a,opacity:a.opacity*e}:a})}function E1(s,e,t,i=1){return s.map(r=>{if(r.op==="FillPath"){const n={...r,x:r.x+e,y:r.y+t};return i<1&&(n.fill.kind==="solid"?n.fill={...n.fill,opacity:n.fill.opacity*i}:n.fill={...n.fill,opacity:(n.fill.opacity??1)*i}),n}return r.op==="StrokePath"?{...r,x:r.x+e,y:r.y+t,opacity:r.opacity*i}:r.op==="DecorationLine"?{...r,from:{x:r.from.x+e,y:r.from.y+t},to:{x:r.to.x+e,y:r.to.y+t},opacity:r.opacity*i}:r})}function _1(s,e,t,i){let r=0;return s.map(n=>{if(n.op==="FillPath"||n.op==="StrokePath"){const a=Math.sin(r/5*Math.PI+i*Math.PI*4),o=e==="left"||e==="right"?a*t*(e==="left"?-1:1):0,c=e==="up"||e==="down"?a*t*(e==="up"?-1:1):0,u=Math.min(1,i*2);if(n.op==="FillPath"){cn(n)||r++;const h={...n,x:n.x+o,y:n.y+c};return h.fill.kind==="solid"?h.fill={...h.fill,opacity:h.fill.opacity*u}:h.fill={...h.fill,opacity:(h.fill.opacity??1)*u},h}return{...n,x:n.x+o,y:n.y+c,opacity:n.opacity*u}}return n})}function A1(s,e,t){const i=s*t;switch(e){case"left":return{dx:-i,dy:0};case"right":return{dx:i,dy:0};case"up":return{dx:0,dy:-i};case"down":return{dx:0,dy:i}}}function mu(s){return s*(2-s)}function $a(s){return 1-Math.pow(1-s,3)}function Qr(s,e=1){const t=/^#?([a-f0-9]{6})$/i.exec(s);if(!t)throw new Error(`Invalid color ${s}`);const i=parseInt(t[1],16),r=i>>16&255,n=i>>8&255,a=i&255;return{r,g:n,b:a,a:e}}function I1(s){const e=s.getContext("2d");if(!e)throw new Error("2D context unavailable");return{async render(t){const i=F1(t),r=new Map;for(const n of t){if(n.op==="BeginFrame"){const a=n.pixelRatio,o=n.width,c=n.height;if("width"in s&&"height"in s&&(s.width=Math.floor(o*a),s.height=Math.floor(c*a)),"style"in s&&(s.style.width=`${o}px`,s.style.height=`${c}px`),e.setTransform(a,0,0,a,0,0),n.clear&&e.clearRect(0,0,o,c),n.bg&&n.bg.color){const{color:u,opacity:h,radius:l}=n.bg;if(u){const d=Qr(u,h);e.fillStyle=`rgba(${d.r},${d.g},${d.b},${d.a})`,l&&l>0?(P1(e,0,0,o,c,l),e.fill()):e.fillRect(0,0,o,c)}}continue}if(n.op==="FillPath"){const a=n,o=new Path2D(a.path);e.save(),e.translate(a.x,a.y);const c=a.scale??1;e.scale(c,-c);const u=a.gradientBBox??i,h={x:(u.x-a.x)/c,y:-(u.y-a.y)/c,w:u.w/c,h:u.h/c},l=JSON.stringify({fill:a.fill,bbox:h});let d=r.get(l);d||(d=O1(e,a.fill,h),r.set(l,d)),e.fillStyle=d,e.fill(o),e.restore();continue}if(n.op==="StrokePath"){const a=n,o=new Path2D(a.path);e.save(),e.translate(a.x,a.y);const c=a.scale??1;e.scale(c,-c);const u=1/Math.abs(c),h=Qr(a.color,a.opacity);e.strokeStyle=`rgba(${h.r},${h.g},${h.b},${h.a})`,e.lineWidth=a.width*u,e.lineJoin="round",e.lineCap="round",e.stroke(o),e.restore();continue}if(n.op==="DecorationLine"){e.save();const a=Qr(n.color,n.opacity);e.strokeStyle=`rgba(${a.r},${a.g},${a.b},${a.a})`,e.lineWidth=n.width,e.beginPath(),e.moveTo(n.from.x,n.from.y),e.lineTo(n.to.x,n.to.y),e.stroke(),e.restore();continue}}}}}function P1(s,e,t,i,r,n){const a=new Path2D;a.moveTo(e+n,t),a.arcTo(e+i,t,e+i,t+r,n),a.arcTo(e+i,t+r,e,t+r,n),a.arcTo(e,t+r,e,t,n),a.arcTo(e,t,e+i,t,n),a.closePath(),s.save(),s.fill(a),s.restore()}function O1(s,e,t){if(e.kind==="solid"){const o=Qr(e.color,e.opacity);return`rgba(${o.r},${o.g},${o.b},${o.a})`}const i=t.x+t.w/2,r=t.y+t.h/2,n=Math.max(t.w,t.h)/2,a=o=>{const c=e.kind==="linear"||e.kind==="radial"?e.opacity:1,u=e.kind==="linear"||e.kind==="radial"?e.stops:[];for(const h of u){const l=Qr(h.color,c);o.addColorStop(h.offset,`rgba(${l.r},${l.g},${l.b},${l.a})`)}return o};if(e.kind==="linear"){const o=e.angle*Math.PI/180,c=i+Math.cos(o+Math.PI)*n,u=r+Math.sin(o+Math.PI)*n,h=i+Math.cos(o)*n,l=r+Math.sin(o)*n;return a(s.createLinearGradient(c,u,h,l))}else return a(s.createRadialGradient(i,r,0,i,r,n))}function F1(s){let e=1/0,t=1/0,i=-1/0,r=-1/0;for(const n of s){if(n.op!=="FillPath")continue;const a=n;if(a.isShadow)continue;const o=R1(a.path),c=a.scale??1,u=a.x+c*o.x,h=a.x+c*(o.x+o.w),l=a.y-c*(o.y+o.h),d=a.y-c*o.y;u<e&&(e=u),l<t&&(t=l),h>i&&(i=h),d>r&&(r=d)}return e===1/0?{x:0,y:0,w:1,h:1}:{x:e,y:t,w:Math.max(1,i-e),h:Math.max(1,r-t)}}function R1(s){const e=M1(s);let t=0,i=1/0,r=1/0,n=-1/0,a=-1/0;const o=(c,u)=>{c<i&&(i=c),u<r&&(r=u),c>n&&(n=c),u>a&&(a=u)};for(;t<e.length;)switch(e[t++]){case"M":case"L":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]);o(u,h);break}case"C":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]),l=parseFloat(e[t++]),d=parseFloat(e[t++]),f=parseFloat(e[t++]),p=parseFloat(e[t++]);o(u,h),o(l,d),o(f,p);break}case"Q":{const u=parseFloat(e[t++]),h=parseFloat(e[t++]),l=parseFloat(e[t++]),d=parseFloat(e[t++]);o(u,h),o(l,d);break}}return i===1/0?{x:0,y:0,w:0,h:0}:{x:i,y:r,w:n-i,h:a-r}}function M1(s){return s.match(/[MLCQZ]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]}async function es(s){try{const e=await fetch(s);if(!e.ok)throw new Error(`Failed to fetch ${s}: ${e.status} ${e.statusText}`);try{return await e.arrayBuffer()}catch(t){throw new Error(`Failed to read response body as ArrayBuffer from ${s}: ${t instanceof Error?t.message:String(t)}`)}}catch(e){throw e instanceof Error?e.message.includes("Failed to fetch")||e.message.includes("Failed to read")?e:new Error(`Failed to fetch ${s}: ${e.message}`):new Error(`Failed to fetch ${s}: ${String(e)}`)}}var gu="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxP.ttf";async function D1(s={}){const e=s.width??qe.DEFAULTS.width,t=s.height??qe.DEFAULTS.height,i=s.pixelRatio??qe.DEFAULTS.pixelRatio,r="https://shotstack-ingest-api-dev-sources.s3.ap-southeast-2.amazonaws.com/euo5r93oyr/zzz01k9h-yycyx-2x2y6-qx9bj-7n567b/source.wasm",n=new hu(r),a=new u1(n);try{hu.setFallbackLoader(async c=>{const u=(c.family??"Roboto").toLowerCase(),h=`${c.weight??"400"}`,l=c.style??"normal";if(u==="roboto"&&h==="400"&&l==="normal")return es(gu)}),await n.init()}catch(c){throw new Error(`Failed to initialize font registry: ${c instanceof Error?c.message:String(c)}`)}async function o(c){try{if(c.customFonts)for(const d of c.customFonts)try{const f=await es(d.src);await n.registerFromBytes(f,{family:d.family,weight:d.weight??"400",style:d.style??"normal"})}catch(f){throw new Error(`Failed to load custom font "${d.family}" from ${d.src}: ${f instanceof Error?f.message:String(f)}`)}const u=c.font??{family:"Roboto",weight:"400",style:"normal",size:48,color:"#000000",opacity:1},h={family:u.family,weight:`${u.weight}`,style:u.style};return await(async()=>{try{await n.getFace(h)}catch{if((u.family||"Roboto").toLowerCase()==="roboto"&&`${u.weight}`=="400"&&u.style==="normal"){const f=await es(gu);await n.registerFromBytes(f,{family:"Roboto",weight:"400",style:"normal"})}else throw new Error(`Font not registered for ${h.family}__${h.weight}__${h.style}`)}})(),u}catch(u){throw u instanceof Error?u:new Error(`Failed to ensure fonts: ${String(u)}`)}}return{validate(c){try{const{value:u,error:h}=s1.validate(c,{abortEarly:!1,convert:!0});if(h)throw h;return{value:u}}catch(u){throw u instanceof Error?new Error(`Validation failed: ${u.message}`):new Error(`Validation failed: ${String(u)}`)}},async registerFontFromUrl(c,u){try{const h=await es(c);await n.registerFromBytes(h,u)}catch(h){throw new Error(`Failed to register font "${u.family}" from URL ${c}: ${h instanceof Error?h.message:String(h)}`)}},async registerFontFromFile(c,u){try{let h;if(typeof c=="string")try{h=await es(c)}catch(l){throw new Error(`Failed to fetch font from ${c}: ${l instanceof Error?l.message:String(l)}`)}else try{h=await c.arrayBuffer()}catch(l){throw new Error(`Failed to read Blob as ArrayBuffer: ${l instanceof Error?l.message:String(l)}`)}await n.registerFromBytes(h,u)}catch(h){throw h instanceof Error?h:new Error(`Failed to register font "${u.family}" from ${typeof c=="string"?c:"Blob"}: ${String(h)}`)}},async renderFrame(c,u){try{const h=await o(c),l={family:h.family,weight:`${h.weight}`,style:h.style};let d;try{d=await a.layout({text:c.text,width:c.width??e,letterSpacing:c.style?.letterSpacing??0,fontSize:h.size,lineHeight:c.style?.lineHeight??1.2,desc:l,textTransform:c.style?.textTransform??"none"})}catch(y){throw new Error(`Failed to layout text: ${y instanceof Error?y.message:String(y)}`)}const f={x:0,y:0,width:c.width??e,height:c.height??t},p=c.width??e,m=c.height??t,b=c.pixelRatio??i;let g;try{g=await f1({canvas:{width:p,height:m,pixelRatio:b},textRect:f,lines:d,font:{family:h.family,size:h.size,weight:`${h.weight}`,style:h.style,color:h.color,opacity:h.opacity},style:{lineHeight:c.style?.lineHeight??1.2,textDecoration:c.style?.textDecoration??"none",gradient:c.style?.gradient},stroke:c.stroke,shadow:c.shadow,align:c.align??{horizontal:"center",vertical:"middle"},background:c.background,glyphPathProvider:y=>n.glyphPath(l,y),getUnitsPerEm:()=>n.getUnitsPerEm(l)})}catch(y){throw new Error(`Failed to build draw operations: ${y instanceof Error?y.message:String(y)}`)}try{return g1(g,d,{t:u,fontSize:h.size,anim:c.animation?{preset:c.animation.preset,speed:c.animation.speed,duration:c.animation.duration,style:c.animation.style,direction:c.animation.direction}:void 0})}catch(y){throw new Error(`Failed to apply animation: ${y instanceof Error?y.message:String(y)}`)}}catch(h){throw h instanceof Error?h:new Error(`Failed to render frame at time ${u}s: ${String(h)}`)}},createRenderer(c){try{return I1(c)}catch(u){throw new Error(`Failed to create renderer: ${u instanceof Error?u.message:String(u)}`)}},destroy(){try{n.destroy()}catch(c){console.error(`Error during cleanup: ${c instanceof Error?c.message:String(c)}`)}}}}const yu=s=>{const t=(s.split("/").pop()||"").replace(/\.(ttf|otf|woff|woff2)$/i,""),i=t.replace(/-(Bold|Light|Regular|Italic|Medium|SemiBold|Black|Thin|ExtraLight|ExtraBold|Heavy)$/i,"");return{full:t,base:i}};class B1 extends Ye{textEngine=null;renderer=null;canvas=null;texture=null;sprite=null;lastRenderedTime=-1;cachedFrames=new Map;isRendering=!1;targetFPS=30;validatedAsset=null;createFontMapping(){const e=new Map;return e.set("Arapey","/assets/fonts/Arapey-Regular.ttf"),e.set("ClearSans","/assets/fonts/ClearSans-Regular.ttf"),e.set("Clear Sans","/assets/fonts/ClearSans-Regular.ttf"),e.set("DidactGothic","/assets/fonts/DidactGothic-Regular.ttf"),e.set("Didact Gothic","/assets/fonts/DidactGothic-Regular.ttf"),e.set("Montserrat","/assets/fonts/Montserrat-SemiBold.ttf"),e.set("MovLette","/assets/fonts/MovLette.ttf"),e.set("OpenSans","/assets/fonts/OpenSans-Bold.ttf"),e.set("Open Sans","/assets/fonts/OpenSans-Bold.ttf"),e.set("PermanentMarker","/assets/fonts/PermanentMarker-Regular.ttf"),e.set("Permanent Marker","/assets/fonts/PermanentMarker-Regular.ttf"),e.set("Roboto","/assets/fonts/Roboto-BlackItalic.ttf"),e.set("SueEllenFrancisco","/assets/fonts/SueEllenFrancisco.ttf"),e.set("Sue Ellen Francisco","/assets/fonts/SueEllenFrancisco.ttf"),e.set("UniNeue","/assets/fonts/UniNeue-Bold.otf"),e.set("Uni Neue","/assets/fonts/UniNeue-Bold.otf"),e.set("WorkSans","/assets/fonts/WorkSans-Light.ttf"),e.set("Work Sans","/assets/fonts/WorkSans-Light.ttf"),e}async load(){await super.load();const e=this.clipConfiguration.asset;try{const t=this.edit.getEdit();if(this.targetFPS=t?.output?.fps||30,e.width=e.width||this.edit.size.width,e.height=e.height||this.edit.size.height,e.pixelRatio=e.pixelRatio||2,e.cacheEnabled=e.cacheEnabled??!0,Array.isArray(t?.timeline?.fonts)&&t.timeline.fonts.length>0){const o=e.font?.family;if(o){const c=t.timeline.fonts?.find(u=>{const{full:h,base:l}=yu(u.src),d=o.toLowerCase();return h.toLowerCase()===d||l.toLowerCase()===d});c&&(e.customFonts=[{src:c.src,family:o,weight:e.font?.weight?.toString()||"400",style:e.font?.style||"normal"}])}}const i=Ss.safeParse(e);if(!i.success){console.error("Rich-text asset validation failed:",i.error),this.createFallbackText(e);return}this.textEngine=await D1({width:e.width,height:e.height,pixelRatio:e.pixelRatio,fps:this.targetFPS});const{value:r}=this.textEngine.validate(e);this.validatedAsset=r;const n=this.createFontMapping();this.canvas=document.createElement("canvas"),this.canvas.width=e.width*e.pixelRatio,this.canvas.height=e.height*e.pixelRatio,this.renderer=this.textEngine.createRenderer(this.canvas);const a=t?.timeline?.fonts||[];if(a.length>0){const o=e.font?.family;if(o){const c=a.find(u=>{const{full:h,base:l}=yu(u.src),d=o.toLowerCase();return h.toLowerCase()===d||l.toLowerCase()===d});if(c)try{const u={family:o,weight:e.font?.weight?.toString()||"400",style:e.font?.style||"normal"};await this.textEngine.registerFontFromUrl(c.src,u)}catch(u){console.warn(`Failed to load font ${o}:`,u)}}}else if(e.font?.family){const o=e.font.family,c=n.get(o);if(c)try{const u={family:e.font.family,weight:e.font.weight||"400",style:e.font.style||"normal"};await this.textEngine.registerFontFromFile(c,u)}catch(u){console.warn(`Failed to load local font: ${o}`,u)}else console.warn(`Font ${o} not found in local assets. Available fonts:`,Array.from(n.keys()))}await this.renderFrame(0),this.configureKeyframes()}catch(t){console.error("Failed to initialize rich text player:",t),this.cleanupResources(),this.createFallbackText(e)}}cleanupResources(){if(this.textEngine){try{this.textEngine.destroy()}catch(e){console.warn("Error destroying text engine:",e)}this.textEngine=null}this.renderer=null,this.canvas=null,this.validatedAsset=null}async renderFrame(e){if(!this.textEngine||!this.renderer||!this.canvas||!this.validatedAsset)return;const t=Math.floor(e*this.targetFPS);if(this.validatedAsset.cacheEnabled&&this.cachedFrames.has(t)){const i=this.cachedFrames.get(t);this.sprite&&this.sprite.texture!==i&&(this.sprite.texture=i),this.lastRenderedTime=e;return}try{const i=await this.textEngine.renderFrame(this.validatedAsset,e),r=this.canvas.getContext("2d");r&&r.clearRect(0,0,this.canvas.width,this.canvas.height),await this.renderer.render(i);const n=L.Texture.from(this.canvas);this.sprite?(this.texture&&!this.cachedFrames.has(t)&&this.texture.destroy(),this.sprite.texture=n):(this.sprite=new L.Sprite(n),this.sprite.scale.set(1/this.validatedAsset.pixelRatio),this.contentContainer.addChild(this.sprite)),this.texture=n,this.validatedAsset.cacheEnabled&&this.cachedFrames.size<150&&this.cachedFrames.set(t,n),this.lastRenderedTime=e}catch(i){console.error("Failed to render rich text frame:",i)}}createFallbackText(e){const t=new L.TextStyle({fontFamily:e.font?.family||"Arial",fontSize:e.font?.size||48,fill:e.font?.color||"#ffffff",align:e.align?.horizontal||"center",wordWrap:!0,wordWrapWidth:e.width||this.edit.size.width}),i=new L.Text(e.text,t),r=e.width||this.edit.size.width,n=e.height||this.edit.size.height;switch(e.align?.horizontal){case"left":i.anchor.set(0,.5),i.x=0;break;case"right":i.anchor.set(1,.5),i.x=r;break;default:i.anchor.set(.5,.5),i.x=r/2}switch(e.align?.vertical){case"top":i.anchor.set(i.anchor.x,0),i.y=0;break;case"bottom":i.anchor.set(i.anchor.x,1),i.y=n;break;default:i.anchor.set(i.anchor.x,.5),i.y=n/2}this.contentContainer.addChild(i)}renderFrameSafe(e){this.isRendering||(this.isRendering=!0,this.renderFrame(e).catch(t=>console.error("Failed to render rich text frame:",t)).finally(()=>{this.isRendering=!1}))}update(e,t){if(super.update(e,t),this.textEngine&&this.renderer&&!this.isRendering){const i=this.getCurrentTime()/1e3,a=1/(this.edit.getEdit()?.output?.fps||30);Math.abs(i-this.lastRenderedTime)>a&&this.renderFrameSafe(i)}}dispose(){super.dispose();for(const e of this.cachedFrames.values())e.destroy();this.cachedFrames.clear(),this.texture&&!this.cachedFrames.has(Math.floor(this.lastRenderedTime*this.targetFPS))&&this.texture.destroy(),this.texture=null,this.sprite&&(this.sprite.destroy(),this.sprite=null),this.canvas&&(this.canvas=null),this.textEngine&&(this.textEngine.destroy(),this.textEngine=null),this.renderer=null,this.validatedAsset=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width||this.edit.size.width,height:e.height||this.edit.size.height}}getFitScale(){return 1}updateTextContent(e){const t=this.clipConfiguration.asset;if(t.text=e,this.textEngine){const{value:i}=this.textEngine.validate(t);this.validatedAsset=i}for(const i of this.cachedFrames.values())i.destroy();this.cachedFrames.clear(),this.lastRenderedTime=-1,this.textEngine&&this.renderer&&this.renderFrameSafe(this.getCurrentTime()/1e3)}getCurrentTime(){return this.edit.playbackTime}}class L1 extends Ye{shape;shapeBackground;constructor(e,t){super(e,t),this.shape=null,this.shapeBackground=null}async load(){await super.load();const e=this.clipConfiguration.asset,t=new L.Graphics,i=e.width??this.edit.size.width,r=e.height??this.edit.size.height;t.fillStyle={color:"transparent"},t.rect(0,0,i,r),t.fill();const n=new L.Graphics;switch(e.shape){case"rectangle":{const a=e.rectangle,o=i/2-a.width/2,c=r/2-a.height/2;n.rect(o,c,a.width,a.height);break}case"circle":{const a=e.circle,o=i/2,c=r/2;n.circle(o,c,a.radius);break}case"line":{const a=e.line,o=i/2-a.length/2,c=r/2-a.thickness/2;n.rect(o,c,a.length,a.thickness);break}default:console.warn("Unsupported shape asset type.");break}if(n.fillStyle={color:e.fill?.color??"#ffffff",alpha:e.fill?.opacity??1},n.fill(),e.stroke){const a=new Fn({thickness:e.stroke.width,color:e.stroke.color});n.filters=[a]}this.shapeBackground=t,this.shape=n,this.contentContainer.addChild(t),t.addChild(n),this.configureKeyframes()}update(e,t){super.update(e,t)}draw(){super.draw()}dispose(){super.dispose(),this.shape?.destroy(),this.shape=null,this.shapeBackground?.destroy(),this.shapeBackground=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}}class ts{static DEFAULT_BLINK_INTERVAL_MS=500;static DEFAULT_CURSOR_WIDTH_PX=2;static DEFAULT_CURSOR_COLOR=16777215;cursor=null;parent;textElement;clipConfig;textPosition=0;pixelX=0;pixelY=0;currentLine=0;isBlinking=!1;blinkInterval=null;blinkIntervalMs=500;width=2;color=16777215;isVisible=!0;constructor(e,t,i,r){this.parent=e,this.textElement=t,this.clipConfig=i,this.width=r?.width??ts.DEFAULT_CURSOR_WIDTH_PX,this.color=r?.color??ts.DEFAULT_CURSOR_COLOR,this.blinkIntervalMs=r?.blinkInterval??ts.DEFAULT_BLINK_INTERVAL_MS,this.textPosition=0,this.isBlinking=!1,this.isVisible=!0,this.blinkInterval=null,this.createCursor()}updatePosition(e){if(!this.cursor||!this.textElement){console.warn("TextCursor: Cannot update position, cursor not initialized");return}this.textPosition=this.validateTextPosition(e),this.calculateAndApplyPixelPosition()}setPosition(e,t){if(!this.cursor){console.warn("TextCursor: Cannot set position, cursor not initialized");return}this.pixelX=e,this.pixelY=t,this.updateGraphicsPosition()}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}setVisible(e){this.isVisible=e,this.cursor&&!this.isBlinking&&(this.cursor.visible=e)}startBlinking(){if(!this.cursor){console.warn("TextCursor: Cannot start blinking, cursor not initialized");return}this.isBlinking||this.startBlinkingAnimation()}stopBlinking(){this.stopBlinkingAnimation()}setBlinkInterval(e){this.blinkIntervalMs=e,this.isBlinking&&(this.stopBlinking(),this.startBlinking())}dispose(){if(this.stopBlinkingAnimation(),this.cursor&&this.parent)try{this.parent.removeChild(this.cursor)}catch(e){console.warn("TextCursor: Error removing cursor from parent:",e)}if(this.cursor)try{this.cursor.destroy()}catch(e){console.warn("TextCursor: Error destroying cursor graphics:",e)}finally{this.cursor=null}this.textPosition=0,this.pixelX=0,this.pixelY=0,this.currentLine=0,this.isVisible=!0}createCursor(){if(!this.textElement)return;this.cursor=new L.Graphics,this.cursor.fillStyle={color:this.color};const e=this.textElement.style.fontSize;this.cursor.rect(0,0,this.width,e),this.cursor.fill(),this.parent.addChild(this.cursor),this.cursor.visible=this.isVisible}validateTextPosition(e){return this.textElement?Math.max(0,Math.min(e,this.textElement.text.length)):0}calculateAndApplyPixelPosition(){this.calculatePixelPositionFromText(),this.updateGraphicsPosition()}calculatePixelPositionFromText(){if(!this.textElement)return;const{text:e}=this.textElement,t=this.textElement.style,i=e.substring(0,this.textPosition),r=i.match(/\n/g);this.currentLine=r?r.length:0;const n=e.split(`
187
+ `),a=this.currentLine<n.length?n[this.currentLine]:"",o=i.lastIndexOf(`
188
+ `),c=o===-1?this.textPosition:this.textPosition-o-1,u=a.substring(0,c);let h;u.length>0&&u.endsWith(" ")?h=this.measureText(`${u}x`,t)-this.measureText("x",t):h=this.measureText(u,t);const l=t.lineHeight;this.pixelY=this.currentLine*l;const f=this.clipConfig.asset.alignment?.horizontal??"center";let p=h;if(f!=="left"){const m=this.measureText(a,t),b=this.textElement.width;let g=0;f==="center"?g=(b-m)/2:f==="right"&&(g=b-m),p=g+h}this.pixelX=p}updateGraphicsPosition(){this.cursor&&this.cursor.position.set(this.pixelX,this.pixelY)}startBlinkingAnimation(){!this.cursor||this.isBlinking||(this.isBlinking=!0,this.blinkInterval=window.setInterval(()=>{this.cursor&&this.isBlinking&&(this.cursor.visible=!this.cursor.visible)},this.blinkIntervalMs))}stopBlinkingAnimation(){this.blinkInterval!==null&&(window.clearInterval(this.blinkInterval),this.blinkInterval=null),this.isBlinking=!1,this.cursor&&(this.cursor.visible=this.isVisible)}measureText(e,t){const i=new L.Text(e,t),{width:r}=i;return i.destroy(),r}isInitialized(){return this.cursor!==null}getState(){return{isInitialized:this.isInitialized(),isBlinking:this.isBlinking,isVisible:this.isVisible,textPosition:this.textPosition,pixelPosition:{x:this.pixelX,y:this.pixelY},currentLine:this.currentLine}}}class un{static DEFAULT_FOCUS_DELAY_MS=50;hiddenInput=null;isFocused=!1;focusRetryCount=0;maxFocusRetries=3;focusDelay=un.DEFAULT_FOCUS_DELAY_MS;eventHandlers={};abortController=null;textChangeCallback=null;lastSyncedText="";isComposing=!1;setupInput(e,t){this.focusDelay=t?.focusDelay??un.DEFAULT_FOCUS_DELAY_MS,this.createHiddenTextarea(),this.hiddenInput&&(this.hiddenInput.value=e,this.lastSyncedText=e),this.setupEventListeners(),t?.autoFocus!==!1&&this.focusInput()}updateInputValue(e){this.hiddenInput&&(this.hiddenInput.value=e,this.lastSyncedText=e)}focusInput(){this.hiddenInput&&setTimeout(()=>{this.hiddenInput&&!this.isFocused&&(this.hiddenInput.focus(),setTimeout(()=>{!this.isFocused&&this.focusRetryCount<this.maxFocusRetries&&(this.focusRetryCount+=1,this.focusInput())},10))},this.focusDelay)}blurInput(){this.hiddenInput&&this.hiddenInput.blur()}setSelectionRange(e,t){if(!this.hiddenInput)return;const i=this.hiddenInput.value.length,r=Math.max(0,Math.min(e,i)),n=Math.max(r,Math.min(t,i));this.hiddenInput.setSelectionRange(r,n)}getCursorPosition(){return this.hiddenInput?.selectionStart||0}getValue(){return this.hiddenInput?.value||""}setTextInputHandler(e){this.textChangeCallback=e}setEventHandlers(e){this.eventHandlers={...this.eventHandlers,...e}}isFocusedInput(){return this.isFocused}dispose(){this.removeAllEventListeners(),this.hiddenInput&&this.hiddenInput.parentNode&&this.hiddenInput.parentNode.removeChild(this.hiddenInput),this.hiddenInput=null,this.isFocused=!1,this.focusRetryCount=0,this.textChangeCallback=null,this.eventHandlers={}}createHiddenTextarea(){this.hiddenInput=document.createElement("textarea");const e={position:"absolute",opacity:"0.01",pointerEvents:"none",zIndex:"999",left:"0px",top:"0px",width:"1px",height:"1px",border:"none",outline:"none",resize:"none",backgroundColor:"transparent"};Object.assign(this.hiddenInput.style,e),this.hiddenInput.tabIndex=0,document.body.appendChild(this.hiddenInput)}setupEventListeners(){if(!this.hiddenInput)return;this.abortController=new AbortController;const{signal:e}=this.abortController;this.hiddenInput.addEventListener("input",this.handleTextInput,{signal:e}),this.hiddenInput.addEventListener("keydown",this.handleKeyDown,{signal:e}),this.hiddenInput.addEventListener("compositionstart",this.handleCompositionStart,{signal:e}),this.hiddenInput.addEventListener("compositionend",this.handleCompositionEnd,{signal:e}),this.hiddenInput.addEventListener("focus",this.handleFocus,{signal:e}),this.hiddenInput.addEventListener("blur",this.handleBlur,{signal:e}),this.hiddenInput.addEventListener("paste",this.handlePaste,{signal:e})}removeAllEventListeners(){this.abortController?.abort(),this.abortController=null}handleTextInput=e=>{if(!this.hiddenInput||this.isComposing)return;const t=this.hiddenInput.value,i=this.hiddenInput.selectionStart||0;this.lastSyncedText=t,this.textChangeCallback?.(t,i)};handleKeyDown=e=>{if(document.activeElement!==this.hiddenInput)return;let t=!1;if((e.ctrlKey||e.metaKey)&&(t=this.handleKeyboardShortcuts(e),t)){e.preventDefault();return}if(e.key==="Tab"){const i=e.shiftKey?"backward":"forward";this.eventHandlers.onTabNavigation?.(i),e.preventDefault();return}switch(e.key){case"Escape":this.eventHandlers.onEscape?.(e),t=!0;break;case"Enter":t=!1;break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":setTimeout(()=>{if(this.hiddenInput){const i=this.hiddenInput.value,r=this.hiddenInput.selectionStart||0;this.textChangeCallback?.(i,r)}},0),t=!1;break;case"Backspace":case"Delete":t=!1;break;default:t=this.eventHandlers.onCustomKey?.(e.key,e)||!1;break}t&&e.preventDefault()};handleKeyboardShortcuts(e){const{key:t}=e;switch(t.toLowerCase()){case"a":return this.selectAll(),!0;case"c":case"v":return!1;case"z":return this.eventHandlers.onCustomKey?.("undo",e),!0;case"y":return this.eventHandlers.onCustomKey?.("redo",e),!0;default:return!1}}handleCompositionStart=e=>{this.isComposing=!0};handleCompositionEnd=e=>{if(this.isComposing=!1,this.hiddenInput){const t=this.hiddenInput.value,i=this.hiddenInput.selectionStart||0;this.textChangeCallback?.(t,i)}};handleFocus=e=>{this.isFocused=!0,this.focusRetryCount=0,this.eventHandlers.onFocus?.(e)};handleBlur=e=>{this.isFocused=!1,this.eventHandlers.onBlur?.(e)};handlePaste=e=>{setTimeout(()=>{this.handleTextInput(e)},0)};selectAll(){this.hiddenInput&&this.hiddenInput.select()}}class Wt{static DOUBLE_CLICK_THRESHOLD_MS=300;static EDITING_BG_PADDING_PX=5;static EDITING_BG_ALPHA=.2;static CLICK_HANDLER_DELAY_MS=100;parent;targetText;clipConfig;isEditing=!1;lastClickTime=0;editingContainer=null;editableText=null;textCursor=null;textInputHandler=null;outsideClickHandler=null;constructor(e,t,i){this.parent=e,this.targetText=t,this.clipConfig=i,this.parent.getContainer().eventMode="static",this.parent.getContainer().on("click",this.checkForDoubleClick)}dispose(){this.parent.getContainer().off("click",this.checkForDoubleClick),this.stopEditing(),this.outsideClickHandler&&(window.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null)}startEditing(){if(this.isEditing||!this.targetText)return;const e=structuredClone(this.clipConfig);this.targetText.visible=!1,this.createEditingEnvironment(),this.setupOutsideClickHandler(e),this.isEditing=!0}stopEditing(e=!1,t){if(!this.isEditing)return;let i="";this.editableText&&(i=this.editableText.text),this.editingContainer&&(this.parent.getContainer().removeChild(this.editingContainer),this.editingContainer.destroy(),this.editingContainer=null),this.editableText=null,this.textCursor&&(this.textCursor.dispose(),this.textCursor=null),this.textInputHandler&&(this.textInputHandler.dispose(),this.textInputHandler=null),this.targetText.visible=!0,e&&t&&i!==""&&this.parent.updateTextContent(i,t),this.isEditing=!1}checkForDoubleClick=e=>{const t=Date.now();t-this.lastClickTime<Wt.DOUBLE_CLICK_THRESHOLD_MS&&this.startEditing(),this.lastClickTime=t};setupOutsideClickHandler(e){this.outsideClickHandler=t=>{const r=this.parent.getContainer().getBounds(),n=t.clientX,a=t.clientY;(n<r.x||n>r.x+r.width||a<r.y||a>r.y+r.height)&&(this.stopEditing(!0,e),this.outsideClickHandler&&(window.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null))},setTimeout(()=>{this.outsideClickHandler&&window.addEventListener("click",this.outsideClickHandler)},Wt.CLICK_HANDLER_DELAY_MS)}createEditingEnvironment(){this.setupEditingContainer(),this.editingContainer&&this.editableText&&(this.textCursor=new ts(this.editingContainer,this.editableText,this.clipConfig),this.textCursor.updatePosition(this.targetText.text.length),this.textCursor.startBlinking()),this.setupTextInputHandler(),this.updateTextAlignment()}setupEditingContainer(){this.editingContainer=new L.Container,this.parent.getContainer().addChild(this.editingContainer);const e=new L.Graphics;e.fillStyle={color:0,alpha:Wt.EDITING_BG_ALPHA},e.rect(-5,-5,this.targetText.width+2*Wt.EDITING_BG_PADDING_PX,this.targetText.height+2*Wt.EDITING_BG_PADDING_PX),e.fill(),this.editingContainer.addChild(e),this.editableText=new L.Text(this.targetText.text,this.targetText.style),this.editableText.eventMode="static",this.editableText.cursor="text",this.editingContainer.addChild(this.editableText)}setupTextInputHandler(){this.textInputHandler=new un,this.textInputHandler.setTextInputHandler((e,t)=>{this.editableText&&(this.editableText.text=e,this.updateTextAlignment()),this.textCursor?.updatePosition(t)}),this.textInputHandler.setEventHandlers({onEscape:e=>this.stopEditing(!1),onTabNavigation:e=>this.stopEditing(!0)}),this.textInputHandler.setupInput(this.targetText.text,{autoFocus:!0})}updateTextAlignment(){if(!this.editableText||!this.editingContainer)return;const e=this.getContainerDimensions(),t=this.getAlignmentSettings(),i=this.calculateHorizontalPosition({width:this.editableText.width},e,t.horizontal),r=this.calculateVerticalPosition({height:this.editableText.height},e,t.vertical);if(this.editingContainer.position.set(i,r),this.editingContainer.children.length>0){const n=this.editingContainer.getChildAt(0);n instanceof L.Graphics&&(n.clear(),n.fillStyle={color:0,alpha:Wt.EDITING_BG_ALPHA},n.rect(-5,-5,this.editableText.width+2*Wt.EDITING_BG_PADDING_PX,this.editableText.height+2*Wt.EDITING_BG_PADDING_PX),n.fill())}}calculateHorizontalPosition(e,t,i="center"){switch(i){case"center":return t.width/2-e.width/2;case"right":return t.width-e.width;case"left":default:return 0}}calculateVerticalPosition(e,t,i="center"){switch(i){case"center":return t.height/2-e.height/2;case"bottom":return t.height-e.height;case"top":default:return 0}}getContainerDimensions(){const e=this.clipConfig.asset;return{width:e.width??this.parent.getSize().width,height:e.height??this.parent.getSize().height}}getAlignmentSettings(){const e=this.clipConfig.asset;return{horizontal:e.alignment?.horizontal??"center",vertical:e.alignment?.vertical??"center"}}}class z1 extends Ye{background=null;text=null;textEditor=null;async load(){await super.load();const e=this.clipConfiguration.asset;if(this.background=new L.Graphics,e.background&&(this.background.fillStyle={color:e.background.color,alpha:e.background.opacity},this.background.rect(0,0,e.width??this.edit.size.width,e.height??this.edit.size.height),this.background.fill()),this.text=new L.Text(e.text,this.createTextStyle(e)),this.positionText(e),e.stroke){const t=new Fn({thickness:e.stroke.width,color:e.stroke.color});this.text.filters=[t]}this.contentContainer.addChild(this.background),this.contentContainer.addChild(this.text),this.configureKeyframes(),this.textEditor=new Wt(this,this.text,this.clipConfiguration)}update(e,t){super.update(e,t)}dispose(){super.dispose(),this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null,this.textEditor?.dispose(),this.textEditor=null}getSize(){const e=this.clipConfiguration.asset;return{width:e.width??this.edit.size.width,height:e.height??this.edit.size.height}}getFitScale(){return 1}createTextStyle(e){return new L.TextStyle({fontFamily:e.font?.family??"Open Sans",fontSize:e.font?.size??32,fill:e.font?.color??"#ffffff",fontWeight:(e.font?.weight??"400").toString(),wordWrap:!0,wordWrapWidth:e.width??this.edit.size.width,lineHeight:(e.font?.lineHeight??1)*(e.font?.size??32),align:e.alignment?.horizontal??"center"})}positionText(e){if(!this.text)return;const t=e.alignment?.horizontal??"center",i=e.alignment?.vertical??"center",r=e.width??this.edit.size.width,n=e.height??this.edit.size.height;let a=r/2-this.text.width/2,o=n/2-this.text.height/2;t==="left"?a=0:t==="right"&&(a=r-this.text.width),i==="top"?o=0:i==="bottom"&&(o=n-this.text.height),this.text.position.set(a,o)}updateTextContent(e,t){this.edit.updateTextContent(this,e,t)}}class $1 extends Ye{texture;sprite;isPlaying;originalSize;volumeKeyframeBuilder;syncTimer;skipVideoUpdate;constructor(e,t){super(e,t),this.texture=null,this.sprite=null,this.isPlaying=!1,this.originalSize=null;const i=this.clipConfiguration.asset;this.volumeKeyframeBuilder=new ot(i.volume??1,this.getLength()),this.syncTimer=0,this.skipVideoUpdate=!1}async load(){await super.load();const e=this.clipConfiguration.asset,t=e.src;if(t.endsWith(".mov")||t.endsWith(".webm"))throw new Error(`Video source '${e.src}' is not supported. .mov and .webm files are currently not supported.`);const i={src:t,data:{autoPlay:!1,muted:!1}},r=await this.edit.assetLoader.load(t,i);if(!(r?.source instanceof L.VideoSource))throw new Error(`Invalid video source '${e.src}'.`);this.texture=this.createCroppedTexture(r),this.sprite=new L.Sprite(this.texture),this.contentContainer.addChild(this.sprite),this.clipConfiguration.width&&this.clipConfiguration.height&&this.applyFixedDimensions(),this.configureKeyframes()}update(e,t){if(super.update(e,t),this.skipVideoUpdate)return;const{trim:i=0}=this.clipConfiguration.asset;if(this.syncTimer+=t,!this.texture)return;const r=this.getPlaybackTime(),n=this.edit.isPlaying&&this.isActive();n&&(this.isPlaying||(this.isPlaying=!0,this.texture.source.resource.currentTime=r/1e3+i,this.texture.source.resource.play().catch(console.error)),this.texture.source.resource.volume!==this.getVolume()&&(this.texture.source.resource.volume=this.getVolume()),Math.abs((this.texture.source.resource.currentTime-i)*1e3-r)>100&&(this.texture.source.resource.currentTime=r/1e3+i)),!n&&this.isPlaying&&(this.isPlaying=!1,this.texture.source.resource.pause());const a=this.syncTimer>100;!this.edit.isPlaying&&this.isActive()&&a&&(this.syncTimer=0,this.texture.source.resource.currentTime=r/1e3+i)}draw(){super.draw()}dispose(){super.dispose(),this.sprite?.destroy(),this.sprite=null,this.texture?.destroy(),this.texture=null,this.originalSize=null}getSize(){return this.clipConfiguration.width&&this.clipConfiguration.height?{width:this.clipConfiguration.width,height:this.clipConfiguration.height}:{width:this.sprite?.width??0,height:this.sprite?.height??0}}getVolume(){return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime())}createCroppedTexture(e){const t=this.clipConfiguration.asset;if(!t.crop)return e;const i=e.width,r=e.height,n=Math.floor((t.crop?.left??0)*i),a=Math.floor((t.crop?.right??0)*i),o=Math.floor((t.crop?.top??0)*r),c=Math.floor((t.crop?.bottom??0)*r),u=n,h=o,l=i-n-a,d=r-o-c,f=new L.Rectangle(u,h,l,d);return new L.Texture({source:e.source,frame:f})}}const bu=Je(["linear","bezier","constant"]),vu=Je(["ease","easeIn","easeOut","easeInOut","easeInQuad","easeInCubic","easeInQuart","easeInQuint","easeInSine","easeInExpo","easeInCirc","easeInBack","easeOutQuad","easeOutCubic","easeOutQuart","easeOutQuint","easeOutSine","easeOutExpo","easeOutCirc","easeOutBack","easeInOutQuad","easeInOutCubic","easeInOutQuart","easeInOutQuint","easeInOutSine","easeInOutExpo","easeInOutCirc","easeInOutBack"]),Ai=ve({from:X(),to:X(),start:X().min(0),length:X().positive(),interpolation:bu.optional(),easing:vu.optional()}),wu=Ve().url("Invalid audio url format."),xu=Ai.extend({from:X().min(0).max(1),to:X().min(0).max(1)}).array().or(X().min(0).max(1)),Na=ve({type:mi("audio"),src:wu,trim:X().optional(),volume:xu.optional()}),N1=Je(["top","topRight","right","bottomRight","bottom","bottomLeft","left","topLeft","center"]),Ua=ve({type:mi("html"),html:Ve(),css:Ve(),width:X().positive().optional(),height:X().positive().optional(),position:N1.optional()}),Cu=Ve().url("Invalid image url format."),ku=ve({top:X().min(0).optional(),right:X().min(0).optional(),bottom:X().min(0).optional(),left:X().min(0).optional()}),Va=ve({type:mi("image"),src:Cu,crop:ku.optional()}),Su=Ve().url("Invalid luma url format."),Ha=ve({type:mi("luma"),src:Su}),ja=Ve().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/,"Invalid color format."),Wa=ve({width:X().positive(),height:X().positive()}),Ga=ve({radius:X().positive()}),qa=ve({length:X().positive(),thickness:X().positive()}),Tu=ve({color:ja,opacity:X().min(0).max(1)}),Eu=ve({color:ja,width:X().positive()}),Xa=ve({type:mi("shape"),width:X().positive().optional(),height:X().positive().optional(),shape:Je(["rectangle","circle","line"]),fill:Tu.optional(),stroke:Eu.optional(),rectangle:Wa.optional(),circle:Ga.optional(),line:qa.optional()}).refine(s=>s.shape==="rectangle"?Wa.safeParse(s.rectangle):s.shape==="circle"?Ga.safeParse(s.circle):s.shape==="line"?qa.safeParse(s.line):!1),hn=Ve().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/,"Invalid color format."),_u=ve({color:hn.optional(),family:Ve().optional(),size:X().positive().optional(),weight:X().optional(),lineHeight:X().optional()}),Au=ve({horizontal:Je(["left","center","right"]).optional(),vertical:Je(["top","center","bottom"]).optional()}),Iu=ve({color:hn,opacity:X().min(0).max(1)}),Pu=ve({width:X().positive(),color:hn}),Za=ve({type:mi("text"),text:Ve(),width:X().positive().optional(),height:X().positive().optional(),font:_u.optional(),alignment:Au.optional(),background:Iu.optional(),stroke:Pu.optional()}),Ou=Ve().url("Invalid video url format."),Fu=ve({top:X().min(0).optional(),right:X().min(0).optional(),bottom:X().min(0).optional(),left:X().min(0).optional()}),Ru=Ai.extend({from:X().min(0).max(1),to:X().min(0).max(1)}).array().or(X().min(0).max(1)),Ka=ve({type:mi("video"),src:Ou,trim:X().optional(),crop:Fu.optional(),volume:Ru.optional()}),Mu=Vn([Za,Ss,Xa,Ua,Va,Ka,Ha,Na]).refine(s=>s.type==="text"?Za.safeParse(s):s.type==="rich-text"?Ss.safeParse(s):s.type==="shape"?Xa.safeParse(s):s.type==="html"?Ua.safeParse(s):s.type==="image"?Va.safeParse(s):s.type==="video"?Ka.safeParse(s):s.type==="luma"?Ha.safeParse(s):s.type==="audio"?Na.safeParse(s):!1),U1=Je(["topLeft","top","topRight","left","center","right","bottomLeft","bottom","bottomRight"]),V1=Je(["crop","cover","contain","none"]),vr=X().min(-10).max(10).default(0),H1=Ai.extend({from:vr,to:vr}).array().or(vr),j1=Ai.extend({from:vr,to:vr}).array().or(vr),W1=ve({x:H1.default(0),y:j1.default(0)}),G1=Ai.extend({from:X().min(0).max(1),to:X().min(0).max(1)}).array().or(X().min(0).max(1)),q1=Ai.extend({from:X().min(0),to:X().min(0)}).array().or(X().min(0)),X1=ve({angle:Ai.extend({from:X(),to:X()}).array().or(X())}),Z1=Ve(),Du=Ve(),K1=ve({in:Du.optional(),out:Du.optional()}),Y1=ve({rotate:X1.default({angle:0})}),Ya=ve({asset:Mu,start:X().min(0),length:X().positive(),position:U1.default("center").optional(),fit:V1.optional(),offset:W1.default({x:0,y:0}).optional(),opacity:G1.default(1).optional(),scale:q1.default(1).optional(),transform:Y1.default({rotate:{angle:0}}).optional(),effect:Z1.optional(),transition:K1.optional(),width:X().min(1).max(3840).optional(),height:X().min(1).max(2160).optional()}).transform(s=>{if(s.fit!==void 0)return s;const e=s.asset.type==="rich-text"?"none":"crop";return{...s,fit:e}});class J1{constructor(e,t){this.trackIdx=e,this.clip=t}name="addClip";addedPlayer;async execute(e){if(!e)return;const t=Ya.parse(this.clip),i=e.createPlayerFromAssetType(t);i.layer=this.trackIdx+1,await e.addPlayer(this.trackIdx,i),e.updateDuration(),this.addedPlayer=i}async undo(e){!e||!this.addedPlayer||(e.queueDisposeClip(this.addedPlayer),e.updateDuration())}}class Bu{constructor(e){this.trackIdx=e}name="addTrack";execute(e){if(!e)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,0,[]),i.forEach(r=>{if(r.layer>=this.trackIdx){const n=1e5-r.layer*100,a=e.getContainer().getChildByLabel(`shotstack-track-${n}`,!1);a&&a.removeChild(r.getContainer()),r.layer+=1;const o=1e5-r.layer*100;let c=e.getContainer().getChildByLabel(`shotstack-track-${o}`,!1);c||(c=new L.Container({label:`shotstack-track-${o}`,zIndex:o}),e.getContainer().addChild(c)),c.addChild(r.getContainer())}}),e.updateDuration(),e.emitEvent("track:added",{trackIndex:this.trackIdx,totalTracks:t.length})}undo(e){if(!e)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,1),i.forEach(r=>{r.layer>this.trackIdx&&(r.layer-=1)}),e.updateDuration()}}class Q1{name="ClearSelection";previousSelection=null;execute(e){const t=e.getSelectedClip();if(t){const i=e.findClipIndices(t);i&&(this.previousSelection={player:t,trackIndex:i.trackIndex,clipIndex:i.clipIndex})}e.setSelectedClip(null),e.emitEvent("selection:cleared",{})}undo(e){if(this.previousSelection){const t=e.getClipAt(this.previousSelection.trackIndex,this.previousSelection.clipIndex);t&&(e.setSelectedClip(t),e.emitEvent("clip:selected",{clip:t.clipConfiguration,trackIndex:this.previousSelection.trackIndex,clipIndex:this.previousSelection.clipIndex}))}}}class ev{constructor(e,t){this.trackIdx=e,this.clipIdx=t}name="deleteClip";deletedClip;execute(e){if(!e)return;const i=e.getClips().filter(r=>r.layer===this.trackIdx+1);this.deletedClip=i[this.clipIdx],this.deletedClip&&(e.queueDisposeClip(this.deletedClip),e.updateDuration())}undo(e){!e||!this.deletedClip||e.undeleteClip(this.trackIdx,this.deletedClip)}}class tv{constructor(e){this.trackIdx=e}name="deleteTrack";deletedClips=[];execute(e){if(!e)return;const t=e.getClips(),i=e.getTracks();this.deletedClips=t.filter(a=>a.layer===this.trackIdx+1).map(a=>({config:structuredClone(a.clipConfiguration)})),t.forEach((a,o)=>{a.layer===this.trackIdx+1&&(t[o].shouldDispose=!0)}),e.disposeClips(),i.splice(this.trackIdx,1);const r=e.getClips(),n=e.getContainer();r.forEach((a,o)=>{if(a.layer>this.trackIdx+1){n.getChildByLabel(`shotstack-track-${1e5-a.layer*100}`,!1)?.removeChild(a.getContainer()),r[o].layer-=1;const u=1e5-r[o].layer*100;let h=n.getChildByLabel(`shotstack-track-${u}`,!1);h||(h=new L.Container({label:`shotstack-track-${u}`,zIndex:u}),n.addChild(h)),h.addChild(r[o].getContainer())}}),e.updateDuration()}async undo(e){if(!e||this.deletedClips.length===0)return;const t=e.getTracks(),i=e.getClips();t.splice(this.trackIdx,0,[]),i.forEach((r,n)=>{r.layer>=this.trackIdx+1&&(i[n].layer+=1)});for(const{config:r}of this.deletedClips){const n=e.createPlayerFromAssetType(r);n.layer=this.trackIdx+1,await e.addPlayer(this.trackIdx,n)}e.updateDuration()}}class iv{constructor(e,t){this.trackIndex=e,this.clipIndex=t}name="SelectClip";previousSelection=null;execute(e){const t=e.getSelectedClip();if(t){const r=e.findClipIndices(t);r&&(this.previousSelection=r)}const i=e.getClipAt(this.trackIndex,this.clipIndex);i&&(e.setSelectedClip(i),e.emitEvent("clip:selected",{clip:i.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}))}undo(e){if(e.setSelectedClip(null),this.previousSelection){const t=e.getClipAt(this.previousSelection.trackIndex,this.previousSelection.clipIndex);t&&(e.setSelectedClip(t),e.emitEvent("clip:selected",{clip:t.clipConfiguration,trackIndex:this.previousSelection.trackIndex,clipIndex:this.previousSelection.clipIndex}))}else e.emitEvent("selection:cleared",{})}}class rv{constructor(e,t,i){this.clip=e,this.initialClipConfig=t,this.finalClipConfig=i,this.storedInitialConfig=t?structuredClone(t):null,this.storedFinalConfig=i?structuredClone(i):structuredClone(this.clip.clipConfiguration)}name="setUpdatedClip";storedInitialConfig;storedFinalConfig;execute(e){if(!e)return;this.storedFinalConfig&&e.restoreClipConfiguration(this.clip,this.storedFinalConfig),e.setUpdatedClip(this.clip);const t=this.clip.layer-1,n=e.getClips().filter(a=>a.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.storedInitialConfig||this.initialClipConfig,trackIndex:t,clipIndex:n},current:{clip:this.storedFinalConfig||this.clip.clipConfiguration,trackIndex:t,clipIndex:n}})}undo(e){if(!e||!this.storedInitialConfig)return;e.restoreClipConfiguration(this.clip,this.storedInitialConfig),e.setUpdatedClip(this.clip);const t=this.clip.layer-1,n=e.getClips().filter(a=>a.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.storedFinalConfig,trackIndex:t,clipIndex:n},current:{clip:this.storedInitialConfig,trackIndex:t,clipIndex:n}})}}class sv{constructor(e,t,i){this.trackIndex=e,this.clipIndex=t,this.splitTime=i}name="SplitClip";originalClipConfig=null;rightClipPlayer=null;splitSuccessful=!1;execute(e){const t=e.getClipAt(this.trackIndex,this.clipIndex);if(!t||!t.clipConfiguration)throw new Error("Cannot split clip: invalid player or clip configuration");const i=t.clipConfiguration,r=i.start||0,n=i.length,a=.1,o=this.splitTime-r;if(o<=a||o>=n-a)throw new Error("Cannot split clip: split point too close to clip boundaries");this.originalClipConfig={...i};const c={...i,length:o},u={...i,start:r+o,length:n-o};if(i.asset&&(c.asset={...i.asset},u.asset={...i.asset}),i.asset&&(i.asset.type==="video"||i.asset.type==="audio")){const f=i.asset.trim||0;c.asset&&(c.asset.type==="video"||c.asset.type==="audio")&&(c.asset.trim=f),u.asset&&(u.asset.type==="video"||u.asset.type==="audio")&&(u.asset.trim=f+o)}if(Object.assign(t.clipConfiguration,c),t.reconfigureAfterRestore(),t.draw(),this.rightClipPlayer=e.createPlayerFromAssetType(u),!this.rightClipPlayer)throw Object.assign(t.clipConfiguration,this.originalClipConfig),t.reconfigureAfterRestore(),new Error("Failed to create right clip player");this.rightClipPlayer.layer=this.trackIndex+1;const h=e.getTrack(this.trackIndex);if(!h)throw new Error("Invalid track index");h.splice(this.clipIndex+1,0,this.rightClipPlayer);const l=e.getClips(),d=l.indexOf(t);d!==-1&&l.splice(d+1,0,this.rightClipPlayer),e.addPlayerToContainer(this.trackIndex,this.rightClipPlayer),this.rightClipPlayer.reconfigureAfterRestore(),this.rightClipPlayer.load().then(()=>{this.splitSuccessful=!0,this.rightClipPlayer&&this.rightClipPlayer.draw(),e.updateDuration(),e.emitEvent("timeline:updated",{current:e.getEditState()})}).catch(f=>{console.error("Failed to load split clip:",f)})}undo(e){if(!this.originalClipConfig)return;const t=e.getClipAt(this.trackIndex,this.clipIndex);if(t){if(Object.assign(t.clipConfiguration,this.originalClipConfig),t.reconfigureAfterRestore(),this.rightClipPlayer){const i=e.getTrack(this.trackIndex);if(i){const a=i.indexOf(this.rightClipPlayer);a!==-1&&i.splice(a,1)}const r=e.getClips(),n=r.indexOf(this.rightClipPlayer);n!==-1&&r.splice(n,1),e.queueDisposeClip(this.rightClipPlayer),this.rightClipPlayer=null}e.updateDuration(),e.emitEvent("timeline:updated",{current:e.getEditState()})}}}class nv{constructor(e,t,i){this.clip=e,this.newText=t,this.initialConfig=i;const{asset:r}=this.clip.clipConfiguration;this.previousText=r&&"text"in r?r.text:""}name="updateTextContent";previousText;execute(e){if(e&&this.clip.clipConfiguration.asset&&"text"in this.clip.clipConfiguration.asset){this.clip.clipConfiguration.asset.text=this.newText;const t=this.clip.text;t&&(t.text=this.newText,this.clip.positionText(this.clip.clipConfiguration.asset)),e.setUpdatedClip(this.clip);const i=this.clip.layer-1,a=e.getClips().filter(o=>o.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.initialConfig,trackIndex:i,clipIndex:a},current:{clip:this.clip.clipConfiguration,trackIndex:i,clipIndex:a}})}}undo(e){if(e&&this.clip.clipConfiguration.asset&&"text"in this.clip.clipConfiguration.asset){this.clip.clipConfiguration.asset.text=this.previousText;const t=this.clip.text;t&&(t.text=this.previousText,this.clip.positionText(this.clip.clipConfiguration.asset)),e.setUpdatedClip(this.clip);const i=this.clip.layer-1,a=e.getClips().filter(o=>o.layer===this.clip.layer).indexOf(this.clip);e.emitEvent("clip:updated",{previous:{clip:this.clip.clipConfiguration,trackIndex:i,clipIndex:a},current:{clip:this.initialConfig,trackIndex:i,clipIndex:a}})}}}class is{events;constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=new Set),this.events[e].add(t)}off(e,t){this.events[e]&&(this.events[e].delete(t),!(this.events[e].size>0)&&delete this.events[e])}clear(e){delete this.events[e]}emit(e,t){if(this.events[e])for(const i of this.events[e])i(t)}}class av extends is{registry;constructor(){super(),this.registry={}}}class dn{static VIDEO_EXTENSIONS=[".mp4",".m4v",".webm",".ogg",".ogv"];static VIDEO_MIME={".mp4":"video/mp4",".m4v":"video/mp4",".webm":"video/webm",".ogg":"video/ogg",".ogv":"video/ogg"};loadTracker=new av;async load(e,t){this.updateAssetLoadMetadata(e,"pending",0);try{if(await this.shouldUseSafariVideoLoader(t))return await this.loadVideoForSafari(e,t);const i=await L.Assets.load(t,r=>{this.updateAssetLoadMetadata(e,"loading",r)});return this.updateAssetLoadMetadata(e,"success",1),i}catch{return this.updateAssetLoadMetadata(e,"failed",1),null}}getProgress(){const e=Object.keys(this.loadTracker.registry);return e.length===0?0:e.reduce((i,r)=>i+this.loadTracker.registry[r].progress,0)/e.length}extractUrl(e){if(typeof e=="string")return e;const t=Array.isArray(e.src)?e.src[0]:e.src;return typeof t=="string"?t:t?.src}hasVideoExtension(e){const t=new URL(e,window.location.origin).pathname.toLowerCase();return dn.VIDEO_EXTENSIONS.some(i=>t.endsWith(i))}async getContentType(e){try{return(await fetch(e,{method:"HEAD"})).headers.get("content-type")}catch{return null}}canPlayVideo(e){const t=new URL(e,window.location.origin).pathname.toLowerCase(),i=t.slice(t.lastIndexOf(".")),r=dn.VIDEO_MIME[i];return r?document.createElement("video").canPlayType(r)!=="":!1}async isPlayableVideo(e){if(this.hasVideoExtension(e))return this.canPlayVideo(e);const t=await this.getContentType(e);return t?.startsWith("video/")?document.createElement("video").canPlayType(t)!=="":!1}async shouldUseSafariVideoLoader(e){const t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=this.extractUrl(e);return t&&i!==void 0&&await this.isPlayableVideo(i)}async loadVideoForSafari(e,t){const i=this.extractUrl(t),r=typeof t=="object"?t.data??{}:{},n=await new Promise((a,o)=>{const c=document.createElement("video");c.crossOrigin="anonymous",c.playsInline=!0,c.muted=!0,c.preload="metadata",c.addEventListener("loadedmetadata",()=>{try{const u=new L.VideoSource({resource:c,autoPlay:r.autoPlay??!1,...r});a(new L.Texture({source:u}))}catch(u){o(u)}},{once:!0}),c.addEventListener("error",()=>o(new Error("Video loading failed")),{once:!0}),this.updateAssetLoadMetadata(e,"loading",.5),c.src=i});return this.updateAssetLoadMetadata(e,"success",1),n}updateAssetLoadMetadata(e,t,i){this.loadTracker.registry[e]?(this.loadTracker.registry[e].progress=i,this.loadTracker.registry[e].status=t):this.loadTracker.registry[e]={progress:i,status:t};const r={...this.loadTracker.registry};this.loadTracker.emit("onAssetLoadInfoUpdated",{registry:r})}}class rs{static Name="FontLoadParser";id;name;extension;validFontExtensions;woff2Decompressor;constructor(){this.id=rs.Name,this.name=rs.Name,this.extension={type:[L.ExtensionType.LoadParser],priority:L.LoaderParserPriority.High,ref:null},this.validFontExtensions=["ttf","otf","woff","woff2"],this.woff2Decompressor=null}test(e){const t=e.split("?")[0]?.split(".").pop()?.toLowerCase()??"";return this.validFontExtensions.includes(t)}async load(e,t,i){const r=e.split("?")[0]?.split(".").pop()?.toLowerCase()??"",n=await fetch(e).then(d=>d.arrayBuffer());if(r!=="woff2"){const d=Fo.parse(new Uint8Array(n).buffer),f=d.names.fontFamily.en||d.names.fontFamily[Object.keys(d.names.fontFamily)[0]],p=new FontFace(f,`url(${e})`);return await p.load(),document.fonts.add(p),p}if(await this.loadWoff2Decompressor(),!this.woff2Decompressor)throw new Error("Cannot initialize Woff2 decompressor.");const a=this.woff2Decompressor.decompress(n),o=Fo.parse(new Uint8Array(a).buffer),c=o.names.fontFamily.en||o.names.fontFamily[Object.keys(o.names.fontFamily)[0]],u=new Blob([a],{type:"font/ttf"}),h=URL.createObjectURL(u),l=new FontFace(c,`url(${h})`);return await l.load(),document.fonts.add(l),l}async loadWoff2Decompressor(){if(this.woff2Decompressor)return;const t=`${await fetch("https://unpkg.com/wawoff2@2.0.1/build/decompress_binding.js").then(i=>i.text())}; return Module`;this.woff2Decompressor=new Function(t)(),await new Promise(i=>{this.woff2Decompressor.onRuntimeInitialized=i})}unload(e){e&&document.fonts.delete(e)}}const Lu=ve({clips:Ya.array()}),zu=Ve().url("Invalid image url format."),$u=ve({src:zu}),Nu=ve({background:Ve().optional(),fonts:$u.array().optional(),tracks:Lu.array()}),Uu=ve({size:ve({width:X().positive(),height:X().positive()}),fps:X().positive().optional(),format:Ve()}),Vu=ve({timeline:Nu,output:Uu});class wr extends ci{static ZIndexPadding=100;assetLoader;events;edit;tracks;clipsToDispose;clips;commandHistory=[];commandIndex=-1;playbackTime;size;backgroundColor;totalDuration;isPlaying;selectedClip;updatedClip;viewportMask;isExporting=!1;constructor(e,t="#ffffff"){super(),this.assetLoader=new dn,this.edit=null,this.tracks=[],this.clipsToDispose=[],this.clips=[],this.events=new is,this.size=e,this.playbackTime=0,this.totalDuration=0,this.isPlaying=!1,this.selectedClip=null,this.updatedClip=null,this.backgroundColor=t,this.setupIntentListeners()}async load(){const e=new L.Graphics;e.fillStyle={color:this.backgroundColor},e.rect(0,0,this.size.width,this.size.height),e.fill(),this.getContainer().addChild(e),this.viewportMask=new L.Graphics,this.viewportMask.rect(0,0,this.size.width,this.size.height),this.viewportMask.fill(16777215),this.getContainer().addChild(this.viewportMask),this.getContainer().setMask({mask:this.viewportMask})}update(e,t){for(const i of this.clips)i.shouldDispose&&this.queueDisposeClip(i),i.update(e,t);this.disposeClips(),this.isPlaying&&(this.playbackTime=Math.max(0,Math.min(this.playbackTime+t,this.totalDuration)),this.playbackTime===this.totalDuration&&this.pause())}draw(){for(const e of this.clips)e.draw()}dispose(){if(this.clearClips(),this.viewportMask){try{this.getContainer().setMask(null)}catch{}this.viewportMask.destroy(),this.viewportMask=void 0}}play(){this.isPlaying=!0,this.events.emit("playback:play",{})}pause(){this.isPlaying=!1,this.events.emit("playback:pause",{})}seek(e){this.playbackTime=Math.max(0,Math.min(e,this.totalDuration)),this.pause()}stop(){this.seek(0)}async loadEdit(e){this.clearClips(),this.edit=Vu.parse(e),this.backgroundColor=this.edit.timeline.background||"#000000",await Promise.all((this.edit.timeline.fonts??[]).map(async t=>{const i=t.src,r={src:i,loadParser:rs.Name};return this.assetLoader.load(i,r)}));for(const[t,i]of this.edit.timeline.tracks.entries())for(const r of i.clips){const n=this.createPlayerFromAssetType(r);n.layer=t+1,await this.addPlayer(t,n)}this.updateTotalDuration()}getEdit(){const e=this.tracks.map((t,i)=>({clips:t.filter(n=>n&&!this.clipsToDispose.includes(n)).map(n=>n.clipConfiguration)}));return{timeline:{background:this.backgroundColor,tracks:e,fonts:this.edit?.timeline.fonts||[]},output:this.edit?.output||{size:this.size,format:"mp4"}}}addClip(e,t){const i=new J1(e,t);this.executeCommand(i)}getClip(e,t){const i=this.clips.filter(r=>r.layer===e+1);return t<0||t>=i.length?null:i[t].clipConfiguration}getPlayerClip(e,t){const i=this.clips.filter(r=>r.layer===e+1);return t<0||t>=i.length?null:i[t]}deleteClip(e,t){const i=new ev(e,t);this.executeCommand(i)}splitClip(e,t,i){const r=new sv(e,t,i);this.executeCommand(r)}addTrack(e,t){const i=new Bu(e);this.executeCommand(i),t?.clips?.forEach(r=>this.addClip(e,r))}getTrack(e){const t=this.clips.filter(i=>i.layer===e+1);return t.length===0?null:{clips:t.map(i=>i.clipConfiguration)}}deleteTrack(e){const t=new tv(e);this.executeCommand(t)}getTotalDuration(){return this.totalDuration}undo(){if(this.commandIndex>=0){const e=this.commandHistory[this.commandIndex];if(e.undo){const t=this.createCommandContext();e.undo(t),this.commandIndex-=1,this.events.emit("edit:undo",{command:e.name})}}}redo(){if(this.commandIndex<this.commandHistory.length-1){this.commandIndex+=1;const e=this.commandHistory[this.commandIndex],t=this.createCommandContext();e.execute(t),this.events.emit("edit:redo",{command:e.name})}}setUpdatedClip(e,t=null,i=null){const r=new rv(e,t,i);this.executeCommand(r)}updateTextContent(e,t,i){const r=new nv(e,t,i);this.executeCommand(r)}executeEditCommand(e){return this.executeCommand(e)}executeCommand(e){const t=this.createCommandContext(),i=e.execute(t);return this.commandHistory=this.commandHistory.slice(0,this.commandIndex+1),this.commandHistory.push(e),this.commandIndex+=1,i}createCommandContext(){return{getClips:()=>this.clips,getTracks:()=>this.tracks,getTrack:e=>e>=0&&e<this.tracks.length?this.tracks[e]:null,getContainer:()=>this.getContainer(),addPlayer:(e,t)=>this.addPlayer(e,t),addPlayerToContainer:(e,t)=>{this.addPlayerToContainer(e,t)},createPlayerFromAssetType:e=>this.createPlayerFromAssetType(e),queueDisposeClip:e=>this.queueDisposeClip(e),disposeClips:()=>this.disposeClips(),undeleteClip:(e,t)=>{this.clips.push(t),this.updateTotalDuration()},setUpdatedClip:e=>{this.updatedClip=e},restoreClipConfiguration:(e,t)=>{Object.assign(e.clipConfiguration,structuredClone(t)),e.reconfigureAfterRestore(),e.draw()},updateDuration:()=>this.updateTotalDuration(),emitEvent:(e,t)=>this.events.emit(e,t),findClipIndices:e=>this.findClipIndices(e),getClipAt:(e,t)=>this.getClipAt(e,t),getSelectedClip:()=>this.selectedClip,setSelectedClip:e=>{this.selectedClip=e},movePlayerToTrackContainer:(e,t,i)=>this.movePlayerToTrackContainer(e,t,i),getEditState:()=>this.getEdit()}}queueDisposeClip(e){this.clipsToDispose.push(e)}disposeClips(){if(this.clipsToDispose.length!==0){for(const e of this.clipsToDispose)this.disposeClip(e);this.clips=this.clips.filter(e=>!this.clipsToDispose.includes(e)),this.clipsToDispose=[],this.updateTotalDuration()}}disposeClip(e){try{if(this.getContainer().children.includes(e.getContainer())){const t=this.getContainer().getChildIndex(e.getContainer());this.getContainer().removeChildAt(t)}else for(const t of this.getContainer().children)if(t instanceof L.Container&&t.label?.toString().startsWith("shotstack-track-")&&t.children.includes(e.getContainer())){t.removeChild(e.getContainer());break}}catch(t){console.warn(`Attempting to unmount an unmounted clip: ${t}`)}this.unloadClipAssets(e),e.dispose()}unloadClipAssets(e){const{asset:t}=e.clipConfiguration;if(t&&"src"in t&&typeof t.src=="string")try{L.Assets.unload(t.src)}catch(i){console.warn(`Failed to unload asset: ${t.src}`,i)}}clearClips(){for(const e of this.clips)this.disposeClip(e);this.clips=[],this.clipsToDispose=[],this.updateTotalDuration()}updateTotalDuration(){let e=0;for(const i of this.tracks)for(const r of i)e=Math.max(e,r.getEnd());const t=this.totalDuration;this.totalDuration=e,t!==this.totalDuration&&this.events.emit("duration:changed",{duration:this.totalDuration})}addPlayerToContainer(e,t){const i=1e5-(e+1)*wr.ZIndexPadding,r=`shotstack-track-${i}`;let n=this.getContainer().getChildByLabel(r,!1);n||(n=new L.Container({label:r,zIndex:i}),this.getContainer().addChild(n)),n.addChild(t.getContainer())}movePlayerToTrackContainer(e,t,i){if(t===i)return;const r=1e5-(t+1)*wr.ZIndexPadding,n=1e5-(i+1)*wr.ZIndexPadding,a=`shotstack-track-${r}`,o=`shotstack-track-${n}`,c=this.getContainer().getChildByLabel(a,!1);let u=this.getContainer().getChildByLabel(o,!1);u||(u=new L.Container({label:o,zIndex:n}),this.getContainer().addChild(u)),c&&c.removeChild(e.getContainer()),u.addChild(e.getContainer())}createPlayerFromAssetType(e){if(!e.asset?.type)throw new Error("Invalid clip configuration: missing asset type");let t;switch(e.asset.type){case"text":{t=new z1(this,e);break}case"rich-text":{t=new B1(this,e);break}case"shape":{t=new L1(this,e);break}case"html":{t=new bh(this,e);break}case"image":{t=new vh(this,e);break}case"video":{t=new $1(this,e);break}case"audio":{t=new Ro(this,e);break}case"luma":{t=new Mo(this,e);break}default:throw new Error(`Unsupported clip type: ${e.asset.type}`)}return t}async addPlayer(e,t){for(;this.tracks.length<=e;)this.tracks.push([]);this.tracks[e].push(t),this.clips.push(t);const i=1e5-(e+1)*wr.ZIndexPadding,r=`shotstack-track-${i}`;let n=this.getContainer().getChildByLabel(r,!1);n||(n=new L.Container({label:r,zIndex:i}),this.getContainer().addChild(n)),n.addChild(t.getContainer());const a=t instanceof Mo;await t.load(),a&&n.setMask({mask:t.getMask(),inverse:!0}),this.updateTotalDuration()}selectClip(e,t){const i=new iv(e,t);this.executeCommand(i)}clearSelection(){const e=new Q1;this.executeCommand(e)}isClipSelected(e,t){if(!this.selectedClip)return!1;const i=this.selectedClip.layer-1,r=this.tracks[i].indexOf(this.selectedClip);return e===i&&t===r}getSelectedClipInfo(){if(!this.selectedClip)return null;const e=this.selectedClip.layer-1,t=this.tracks[e].indexOf(this.selectedClip);return{trackIndex:e,clipIndex:t,player:this.selectedClip}}findClipIndices(e){for(let t=0;t<this.tracks.length;t+=1){const i=this.tracks[t].indexOf(e);if(i!==-1)return{trackIndex:t,clipIndex:i}}return null}getClipAt(e,t){return e>=0&&e<this.tracks.length&&t>=0&&t<this.tracks[e].length?this.tracks[e][t]:null}selectPlayer(e){const t=this.findClipIndices(e);t&&this.selectClip(t.trackIndex,t.clipIndex)}isPlayerSelected(e){return this.isExporting?!1:this.selectedClip===e}setExportMode(e){this.isExporting=e}isInExportMode(){return this.isExporting}setupIntentListeners(){this.events.on("timeline:clip:clicked",e=>{e.player?this.selectPlayer(e.player):this.selectClip(e.trackIndex,e.clipIndex)}),this.events.on("timeline:background:clicked",()=>{this.clearSelection()}),this.events.on("canvas:clip:clicked",e=>{this.selectPlayer(e.player)}),this.events.on("canvas:background:clicked",()=>{this.clearSelection()})}}class ss extends ci{static Width=250;static Height=100;fps;playbackTime;playbackDuration;isPlaying;background;text;constructor(){super(),this.background=null,this.text=null,this.fps=0,this.playbackTime=0,this.playbackDuration=0,this.isPlaying=!1}async load(){const e=new L.Graphics;e.fillStyle={color:"#424242",alpha:.5},e.rect(0,0,ss.Width,ss.Height),e.fill(),this.getContainer().addChild(e),this.background=e;const t=new L.Text;t.text="",t.style={fontFamily:"monospace",fontSize:14,fill:"#ffffff",wordWrap:!0,wordWrapWidth:ss.Width},this.getContainer().addChild(t),this.text=t}update(e,t){if(!this.text)return;const i=this.getMemoryInfo(),r=[`FPS: ${this.fps}`,`Playback: ${(this.playbackTime/1e3).toFixed(2)}/${(this.playbackDuration/1e3).toFixed(2)}`,`Playing: ${this.isPlaying}`,`Total Heap Size: ${i.totalHeapSize?`${this.bytesToMegabytes(i.totalHeapSize)}MB`:"N/A"}`,`Used Heap Size: ${i.usedHeapSize?`${this.bytesToMegabytes(i.usedHeapSize)}MB`:"N/A"}`,`Heap Size Limit: ${i.heapSizeLimit?`${this.bytesToMegabytes(i.heapSizeLimit)}MB`:"N/A"}`];this.text.text=r.join(`
189
+ `)}draw(){}dispose(){this.background?.destroy(),this.background=null,this.text?.destroy(),this.text=null}getMemoryInfo(){const e={};return"memory"in performance&&(e.totalHeapSize=performance.memory.totalJSHeapSize,e.usedHeapSize=performance.memory.usedJSHeapSize,e.heapSizeLimit=performance.memory.jsHeapSizeLimit),e}bytesToMegabytes(e){return Math.round(e/1024/1024)}}class Zi{static CanvasSelector="[data-shotstack-studio]";static extensionsRegistered=!1;size;application;edit;inspector;container;background;timeline;minZoom=.1;maxZoom=4;currentZoom=.8;onTickBound;constructor(e,t){this.size=e,this.application=new L.Application,this.edit=t,this.inspector=new ss,this.onTickBound=this.onTick.bind(this)}async load(){const e=document.querySelector(Zi.CanvasSelector);if(!e)throw new Error(`Shotstack canvas root element '${Zi.CanvasSelector}' not found.`);this.registerExtensions(),this.container=new L.Container,this.background=new L.Graphics,this.background.fillStyle={color:"#424242"},this.background.rect(0,0,this.size.width,this.size.height),this.background.fill(),await this.configureApplication(),this.configureStage(),this.setupTouchHandling(e),this.edit.getContainer().scale=this.currentZoom,e.appendChild(this.application.canvas)}setupTouchHandling(e){const t=this.edit.getContainer();e.addEventListener("wheel",i=>{if(i.preventDefault(),i.stopPropagation(),i.ctrlKey){const r=Math.exp(-i.deltaY/100),n=this.currentZoom*r,a=this.currentZoom;this.currentZoom=Math.min(Math.max(n,this.minZoom),this.maxZoom);const o={x:this.application.canvas.width/2,y:this.application.canvas.height/2},c={x:t.position.x-o.x,y:t.position.y-o.y},u=this.currentZoom/a;t.position.x=o.x+c.x*u,t.position.y=o.y+c.y*u,t.scale.x=this.currentZoom,t.scale.y=this.currentZoom}},{passive:!1,capture:!0})}centerEdit(){if(!this.edit)return;const e=this.edit.getContainer();e.position={x:this.application.canvas.width/2-this.edit.size.width*this.currentZoom/2,y:this.application.canvas.height/2-this.edit.size.height*this.currentZoom/2}}zoomToFit(){if(!this.edit)return;const e=this.application.canvas.width/this.edit.size.width,t=this.application.canvas.height/this.edit.size.height,i=Math.min(e,t);this.currentZoom=Math.min(Math.max(i,this.minZoom),this.maxZoom);const r=this.edit.getContainer();r.scale.x=this.currentZoom,r.scale.y=this.currentZoom,this.centerEdit()}setZoom(e){this.currentZoom=Math.min(Math.max(e,this.minZoom),this.maxZoom);const t=this.edit.getContainer();t.scale.x=this.currentZoom,t.scale.y=this.currentZoom}registerTimeline(e){this.timeline=e}registerExtensions(){Zi.extensionsRegistered||(L.extensions.add(new Ir),L.extensions.add(new rs),Zi.extensionsRegistered=!0)}async configureApplication(){const e={background:"#000000",width:this.size.width,height:this.size.height,antialias:!0};await this.application.init(e),this.application.ticker.add(this.onTickBound),this.application.ticker.minFPS=60,this.application.ticker.maxFPS=60}onTick(e){this.edit.update(e.deltaTime,e.deltaMS),this.edit.draw(),this.inspector.fps=Math.ceil(e.FPS),this.inspector.playbackTime=this.edit.playbackTime,this.inspector.playbackDuration=this.edit.totalDuration,this.inspector.isPlaying=this.edit.isPlaying,this.inspector.update(e.deltaTime,e.deltaMS),this.inspector.draw(),this.timeline&&(this.timeline.update(e.deltaTime,e.deltaMS),this.timeline.draw())}configureStage(){if(!this.container||!this.background)throw new Error("Shotstack canvas container not set up.");this.container.addChild(this.background),this.container.addChild(this.edit.getContainer()),this.container.addChild(this.inspector.getContainer()),this.application.stage.addChild(this.container),this.application.stage.eventMode="static",this.application.stage.hitArea=new L.Rectangle(0,0,this.size.width,this.size.height),this.background.eventMode="static",this.background.on("pointerdown",this.onBackgroundClick.bind(this)),this.application.stage.on("click",this.onClick.bind(this)),this.edit.getContainer().position={x:this.application.canvas.width/2-this.edit.size.width*this.currentZoom/2,y:this.application.canvas.height/2-this.edit.size.height*this.currentZoom/2}}onClick(){this.edit.pause()}onBackgroundClick(e){e.target===this.background&&this.edit.events.emit("canvas:background:clicked",{})}pauseTicker(){this.application.ticker.remove(this.onTickBound)}resumeTicker(){this.application.ticker.add(this.onTickBound)}dispose(){const e=document.querySelector(Zi.CanvasSelector);e&&e.contains(this.application.canvas)&&e.removeChild(this.application.canvas),this.application.ticker.remove(this.onTickBound),this.application.stage.off("click",this.onClick,this),this.background?.off("pointerdown",this.onBackgroundClick,this),this.background?.destroy(),this.container?.destroy(),this.inspector.dispose(),this.application.destroy(!0,{children:!0,texture:!0})}}class ov{edit;seekDistance=50;seekDistanceLarge=500;frameTime=16.67;constructor(e){this.edit=e}async load(){document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}dispose(){document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)}handleKeyDown=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.code){case"Space":{this.edit.isPlaying?this.edit.pause():this.edit.play();break}case"ArrowLeft":{if(e.metaKey)this.edit.seek(0);else{const t=e.shiftKey?this.seekDistanceLarge:this.seekDistance;this.edit.seek(this.edit.playbackTime-t)}break}case"ArrowRight":{if(e.metaKey)this.edit.seek(this.edit.getTotalDuration());else{const t=e.shiftKey?this.seekDistanceLarge:this.seekDistance;this.edit.seek(this.edit.playbackTime+t)}break}case"KeyJ":{this.edit.stop();break}case"KeyK":{this.edit.pause();break}case"KeyL":{this.edit.play();break}case"Comma":{this.edit.seek(this.edit.playbackTime-this.frameTime);break}case"Period":{this.edit.seek(this.edit.playbackTime+this.frameTime);break}case"KeyZ":{(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.shiftKey?this.edit.redo():this.edit.undo());break}case"Delete":case"Backspace":{const t=this.edit.getSelectedClipInfo();t&&(e.preventDefault(),this.edit.deleteClip(t.trackIndex,t.clipIndex));break}}};handleKeyUp=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.code){case"KeyI":console.log(this.edit.getEdit());break}}}class lv{name="export";clips=[];tracks=[];execute(e){this.clips=e.getClips(),this.tracks=e.getTracks()}getClips(){return this.clips}getTracks(){return this.tracks}}/*!
188
190
  * Copyright (c) 2025-present, Vanilagy and contributors
189
191
  *
190
192
  * This Source Code Form is subject to the terms of the Mozilla Public
191
193
  * License, v. 2.0. If a copy of the MPL was not distributed with this
192
194
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
193
- */function $(s){if(!s)throw new Error("Assertion failed.")}const ze=s=>s&&s[s.length-1],Ft=s=>s>=0&&s<2**32;class Yt{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){const e=Math.floor(this.pos/8),t=this.bytes[e]??0,i=7-(this.pos&7),r=(t&1<<i)>>i;return this.pos++,r}readBits(e){if(e===1)return this.readBit();let t=0;for(let i=0;i<e;i++)t<<=1,t|=this.readBit();return t}writeBits(e,t){const i=this.pos+e;for(let r=this.pos;r<i;r++){const n=Math.floor(r/8);let o=this.bytes[n];const a=7-(r&7);o&=~(1<<a),o|=(t&1<<i-r-1)>>i-r-1<<a,this.bytes[n]=o}this.pos=i}readAlignedByte(){if(this.pos%8!==0)throw new Error("Bitstream is not byte-aligned.");const 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(){const e=new Yt(this.bytes);return e.pos=this.pos,e}}const W=s=>{let e=0;for(;s.readBits(1)===0&&e<32;)e++;if(e>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<e)-1+s.readBits(e)},Qt=s=>{const e=W(s);return e&1?e+1>>1:-(e>>1)},ot=s=>s.constructor===Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength),Fr=s=>s.constructor===DataView?s:s instanceof ArrayBuffer?new DataView(s):new DataView(s.buffer,s.byteOffset,s.byteLength);new TextDecoder;const He=new TextEncoder,ns=s=>Object.fromEntries(Object.entries(s).map(([e,t])=>[t,e])),vi={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12};ns(vi);const wi={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pg:16,hlg:18};ns(wi);const _i={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9};ns(_i);const el=s=>!!s&&!!s.primaries&&!!s.transfer&&!!s.matrix&&s.fullRange!==void 0,xi=s=>s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer||ArrayBuffer.isView(s);class Mr{constructor(){this.currentPromise=Promise.resolve()}async acquire(){let e;const t=new Promise(r=>{e=r}),i=this.currentPromise;return this.currentPromise=t,await i,e}}const tl=()=>{let s,e;return{promise:new Promise((i,r)=>{s=i,e=r}),resolve:s,reject:e}},as=s=>{throw new Error(`Unexpected value: ${s}`)},Lr=(s,e,t,i)=>{t=t>>>0,t=t&16777215,i?(s.setUint8(e,t&255),s.setUint8(e+1,t>>>8&255),s.setUint8(e+2,t>>>16&255)):(s.setUint8(e,t>>>16&255),s.setUint8(e+1,t>>>8&255),s.setUint8(e+2,t&255))},il=(s,e,t,i)=>{t=Se(t,-8388608,8388607),t<0&&(t=t+16777216&16777215),Lr(s,e,t,i)},Se=(s,e,t)=>Math.max(e,Math.min(t,s)),sl="und",rl=/^[a-z]{3}$/,nl=s=>rl.test(s),lt=1e6*(1+Number.EPSILON),al=(s,e)=>{const t=s<0?-1:1;s=Math.abs(s);let i=0,r=1,n=1,o=0,a=s;for(;;){const p=Math.floor(a),m=p*n+i,d=p*o+r;if(d>e)return{numerator:t*n,denominator:o};if(i=n,r=o,n=m,o=d,a=1/(a-p),!isFinite(a))break}return{numerator:t*n,denominator:o}};class Br{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}}let os=null;const ls=()=>os!==null?os:os=typeof navigator<"u"&&navigator.userAgent?.includes("Firefox"),$r=function*(s){for(const e in s){const t=s[e];t!==void 0&&(yield{key:e,value:t})}},ol=()=>{Symbol.dispose??=Symbol("Symbol.dispose")};/*!
195
+ */function q(s){if(!s)throw new Error("Assertion failed.")}const Gt=s=>s&&s[s.length-1],xr=s=>s>=0&&s<2**32;class ns{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){const e=Math.floor(this.pos/8),t=this.bytes[e]??0,i=7-(this.pos&7),r=(t&1<<i)>>i;return this.pos++,r}readBits(e){if(e===1)return this.readBit();let t=0;for(let i=0;i<e;i++)t<<=1,t|=this.readBit();return t}writeBits(e,t){const i=this.pos+e;for(let r=this.pos;r<i;r++){const n=Math.floor(r/8);let a=this.bytes[n];const o=7-(r&7);a&=~(1<<o),a|=(t&1<<i-r-1)>>i-r-1<<o,this.bytes[n]=a}this.pos=i}readAlignedByte(){if(this.pos%8!==0)throw new Error("Bitstream is not byte-aligned.");const 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(){const e=new ns(this.bytes);return e.pos=this.pos,e}}const re=s=>{let e=0;for(;s.readBits(1)===0&&e<32;)e++;if(e>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<e)-1+s.readBits(e)},as=s=>{const e=re(s);return e&1?e+1>>1:-(e>>1)},Ii=s=>s.constructor===Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength),Hu=s=>s.constructor===DataView?s:s instanceof ArrayBuffer?new DataView(s):new DataView(s.buffer,s.byteOffset,s.byteLength);new TextDecoder;const qt=new TextEncoder,Ja=s=>Object.fromEntries(Object.entries(s).map(([e,t])=>[t,e])),fn={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12};Ja(fn);const pn={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pg:16,hlg:18};Ja(pn);const mn={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9};Ja(mn);const cv=s=>!!s&&!!s.primaries&&!!s.transfer&&!!s.matrix&&s.fullRange!==void 0,gn=s=>s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer||ArrayBuffer.isView(s);class ju{constructor(){this.currentPromise=Promise.resolve()}async acquire(){let e;const t=new Promise(r=>{e=r}),i=this.currentPromise;return this.currentPromise=t,await i,e}}const uv=()=>{let s,e;return{promise:new Promise((i,r)=>{s=i,e=r}),resolve:s,reject:e}},Qa=s=>{throw new Error(`Unexpected value: ${s}`)},Wu=(s,e,t,i)=>{t=t>>>0,t=t&16777215,i?(s.setUint8(e,t&255),s.setUint8(e+1,t>>>8&255),s.setUint8(e+2,t>>>16&255)):(s.setUint8(e,t>>>16&255),s.setUint8(e+1,t>>>8&255),s.setUint8(e+2,t&255))},hv=(s,e,t,i)=>{t=mt(t,-8388608,8388607),t<0&&(t=t+16777216&16777215),Wu(s,e,t,i)},mt=(s,e,t)=>Math.max(e,Math.min(t,s)),dv="und",fv=/^[a-z]{3}$/,pv=s=>fv.test(s),Pi=1e6*(1+Number.EPSILON),mv=(s,e)=>{const t=s<0?-1:1;s=Math.abs(s);let i=0,r=1,n=1,a=0,o=s;for(;;){const c=Math.floor(o),u=c*n+i,h=c*a+r;if(h>e)return{numerator:t*n,denominator:a};if(i=n,r=a,n=u,a=h,o=1/(o-c),!isFinite(o))break}return{numerator:t*n,denominator:a}};class Gu{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}}let eo=null;const to=()=>eo!==null?eo:eo=typeof navigator<"u"&&navigator.userAgent?.includes("Firefox"),qu=function*(s){for(const e in s){const t=s[e];t!==void 0&&(yield{key:e,value:t})}},gv=()=>{Symbol.dispose??=Symbol("Symbol.dispose")};/*!
194
196
  * Copyright (c) 2025-present, Vanilagy and contributors
195
197
  *
196
198
  * This Source Code Form is subject to the terms of the Mozilla Public
197
199
  * License, v. 2.0. If a copy of the MPL was not distributed with this
198
200
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
199
- */class Dr{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(typeof t!="string")throw new TypeError("mimeType must be a string.")}}class ll{constructor(e,t,i,r){if(this.data=e,this.mimeType=t,this.name=i,this.description=r,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!==void 0&&typeof t!="string")throw new TypeError("mimeType, when provided, must be a string.");if(i!==void 0&&typeof i!="string")throw new TypeError("name, when provided, must be a string.");if(r!==void 0&&typeof r!="string")throw new TypeError("description, when provided, must be a string.")}}const cl=s=>{if(!s||typeof s!="object")throw new TypeError("tags must be an object.");if(s.title!==void 0&&typeof s.title!="string")throw new TypeError("tags.title, when provided, must be a string.");if(s.description!==void 0&&typeof s.description!="string")throw new TypeError("tags.description, when provided, must be a string.");if(s.artist!==void 0&&typeof s.artist!="string")throw new TypeError("tags.artist, when provided, must be a string.");if(s.album!==void 0&&typeof s.album!="string")throw new TypeError("tags.album, when provided, must be a string.");if(s.albumArtist!==void 0&&typeof s.albumArtist!="string")throw new TypeError("tags.albumArtist, when provided, must be a string.");if(s.trackNumber!==void 0&&(!Number.isInteger(s.trackNumber)||s.trackNumber<=0))throw new TypeError("tags.trackNumber, when provided, must be a positive integer.");if(s.tracksTotal!==void 0&&(!Number.isInteger(s.tracksTotal)||s.tracksTotal<=0))throw new TypeError("tags.tracksTotal, when provided, must be a positive integer.");if(s.discNumber!==void 0&&(!Number.isInteger(s.discNumber)||s.discNumber<=0))throw new TypeError("tags.discNumber, when provided, must be a positive integer.");if(s.discsTotal!==void 0&&(!Number.isInteger(s.discsTotal)||s.discsTotal<=0))throw new TypeError("tags.discsTotal, when provided, must be a positive integer.");if(s.genre!==void 0&&typeof s.genre!="string")throw new TypeError("tags.genre, when provided, must be a string.");if(s.date!==void 0&&(!(s.date instanceof Date)||Number.isNaN(s.date.getTime())))throw new TypeError("tags.date, when provided, must be a valid Date.");if(s.lyrics!==void 0&&typeof s.lyrics!="string")throw new TypeError("tags.lyrics, when provided, must be a string.");if(s.images!==void 0){if(!Array.isArray(s.images))throw new TypeError("tags.images, when provided, must be an array.");for(const e of s.images){if(!e||typeof e!="object")throw new TypeError("Each image in tags.images must be an object.");if(!(e.data instanceof Uint8Array))throw new TypeError("Each image.data must be a Uint8Array.");if(typeof e.mimeType!="string")throw new TypeError("Each image.mimeType must be a string.");if(!["coverFront","coverBack","unknown"].includes(e.kind))throw new TypeError("Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.")}}if(s.comment!==void 0&&typeof s.comment!="string")throw new TypeError("tags.comment, when provided, must be a string.");if(s.raw!==void 0){if(!s.raw||typeof s.raw!="object")throw new TypeError("tags.raw, when provided, must be an object.");for(const e of Object.values(s.raw))if(e!==null&&typeof e!="string"&&!(e instanceof Uint8Array)&&!(e instanceof Dr)&&!(e instanceof ll))throw new TypeError("Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, or null.")}};/*!
201
+ */class Xu{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(typeof t!="string")throw new TypeError("mimeType must be a string.")}}class yv{constructor(e,t,i,r){if(this.data=e,this.mimeType=t,this.name=i,this.description=r,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!==void 0&&typeof t!="string")throw new TypeError("mimeType, when provided, must be a string.");if(i!==void 0&&typeof i!="string")throw new TypeError("name, when provided, must be a string.");if(r!==void 0&&typeof r!="string")throw new TypeError("description, when provided, must be a string.")}}const bv=s=>{if(!s||typeof s!="object")throw new TypeError("tags must be an object.");if(s.title!==void 0&&typeof s.title!="string")throw new TypeError("tags.title, when provided, must be a string.");if(s.description!==void 0&&typeof s.description!="string")throw new TypeError("tags.description, when provided, must be a string.");if(s.artist!==void 0&&typeof s.artist!="string")throw new TypeError("tags.artist, when provided, must be a string.");if(s.album!==void 0&&typeof s.album!="string")throw new TypeError("tags.album, when provided, must be a string.");if(s.albumArtist!==void 0&&typeof s.albumArtist!="string")throw new TypeError("tags.albumArtist, when provided, must be a string.");if(s.trackNumber!==void 0&&(!Number.isInteger(s.trackNumber)||s.trackNumber<=0))throw new TypeError("tags.trackNumber, when provided, must be a positive integer.");if(s.tracksTotal!==void 0&&(!Number.isInteger(s.tracksTotal)||s.tracksTotal<=0))throw new TypeError("tags.tracksTotal, when provided, must be a positive integer.");if(s.discNumber!==void 0&&(!Number.isInteger(s.discNumber)||s.discNumber<=0))throw new TypeError("tags.discNumber, when provided, must be a positive integer.");if(s.discsTotal!==void 0&&(!Number.isInteger(s.discsTotal)||s.discsTotal<=0))throw new TypeError("tags.discsTotal, when provided, must be a positive integer.");if(s.genre!==void 0&&typeof s.genre!="string")throw new TypeError("tags.genre, when provided, must be a string.");if(s.date!==void 0&&(!(s.date instanceof Date)||Number.isNaN(s.date.getTime())))throw new TypeError("tags.date, when provided, must be a valid Date.");if(s.lyrics!==void 0&&typeof s.lyrics!="string")throw new TypeError("tags.lyrics, when provided, must be a string.");if(s.images!==void 0){if(!Array.isArray(s.images))throw new TypeError("tags.images, when provided, must be an array.");for(const e of s.images){if(!e||typeof e!="object")throw new TypeError("Each image in tags.images must be an object.");if(!(e.data instanceof Uint8Array))throw new TypeError("Each image.data must be a Uint8Array.");if(typeof e.mimeType!="string")throw new TypeError("Each image.mimeType must be a string.");if(!["coverFront","coverBack","unknown"].includes(e.kind))throw new TypeError("Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.")}}if(s.comment!==void 0&&typeof s.comment!="string")throw new TypeError("tags.comment, when provided, must be a string.");if(s.raw!==void 0){if(!s.raw||typeof s.raw!="object")throw new TypeError("tags.raw, when provided, must be an object.");for(const e of Object.values(s.raw))if(e!==null&&typeof e!="string"&&!(e instanceof Uint8Array)&&!(e instanceof Xu)&&!(e instanceof yv))throw new TypeError("Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, or null.")}};/*!
200
202
  * Copyright (c) 2025-present, Vanilagy and contributors
201
203
  *
202
204
  * This Source Code Form is subject to the terms of the Mozilla Public
203
205
  * License, v. 2.0. If a copy of the MPL was not distributed with this
204
206
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
205
- */const bt=["avc","hevc","vp9","av1","vp8"],Ne=["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"],zr=["aac","opus","mp3","vorbis","flac"],Mt=[...zr,...Ne],Ci=["webvtt"],Hr=[{maxMacroblocks:99,maxBitrate:64e3,level:10},{maxMacroblocks:396,maxBitrate:192e3,level:11},{maxMacroblocks:396,maxBitrate:384e3,level:12},{maxMacroblocks:396,maxBitrate:768e3,level:13},{maxMacroblocks:396,maxBitrate:2e6,level:20},{maxMacroblocks:792,maxBitrate:4e6,level:21},{maxMacroblocks:1620,maxBitrate:4e6,level:22},{maxMacroblocks:1620,maxBitrate:1e7,level:30},{maxMacroblocks:3600,maxBitrate:14e6,level:31},{maxMacroblocks:5120,maxBitrate:2e7,level:32},{maxMacroblocks:8192,maxBitrate:2e7,level:40},{maxMacroblocks:8192,maxBitrate:5e7,level:41},{maxMacroblocks:8704,maxBitrate:5e7,level:42},{maxMacroblocks:22080,maxBitrate:135e6,level:50},{maxMacroblocks:36864,maxBitrate:24e7,level:51},{maxMacroblocks:36864,maxBitrate:24e7,level:52},{maxMacroblocks:139264,maxBitrate:24e7,level:60},{maxMacroblocks:139264,maxBitrate:48e7,level:61},{maxMacroblocks:139264,maxBitrate:8e8,level:62}],Nr=[{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}],Ur=[{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}],jr=[{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}],hl=(s,e,t,i)=>{if(s==="avc"){const n=Math.ceil(e/16)*Math.ceil(t/16),o=Hr.find(l=>n<=l.maxMacroblocks&&i<=l.maxBitrate)??ze(Hr),a=o?o.level:0,p="64".padStart(2,"0"),m="00",d=a.toString(16).padStart(2,"0");return`avc1.${p}${m}${d}`}else if(s==="hevc"){const r="",o="6",a=e*t,p=Nr.find(d=>a<=d.maxPictureSize&&i<=d.maxBitrate)??ze(Nr);return`hev1.${r}1.${o}.${p.tier}${p.level}.B0`}else{if(s==="vp8")return"vp8";if(s==="vp9"){const r="00",n=e*t,o=Ur.find(p=>n<=p.maxPictureSize&&i<=p.maxBitrate)??ze(Ur);return`vp09.${r}.${o.level.toString().padStart(2,"0")}.08`}else if(s==="av1"){const n=e*t,o=jr.find(m=>n<=m.maxPictureSize&&i<=m.maxBitrate)??ze(jr);return`av01.0.${o.level.toString().padStart(2,"0")}${o.tier}.08`}}throw new TypeError(`Unhandled codec '${s}'.`)},ul=s=>{const e=s.split("."),r=(1<<7)+1,n=Number(e[1]),o=e[2],a=Number(o.slice(0,-1)),p=(n<<5)+a,m=o.slice(-1)==="H"?1:0,l=Number(e[3])===8?0:1,c=0,u=e[4]?Number(e[4]):0,h=e[5]?Number(e[5][0]):1,f=e[5]?Number(e[5][1]):1,b=e[5]?Number(e[5][2]):0,g=(m<<7)+(l<<6)+(c<<5)+(u<<4)+(h<<3)+(f<<2)+b;return[r,p,g,0]},dl=(s,e,t)=>{if(s==="aac")return e>=2&&t<=24e3?"mp4a.40.29":t<=24e3?"mp4a.40.5":"mp4a.40.2";if(s==="mp3")return"mp3";if(s==="opus")return"opus";if(s==="vorbis")return"vorbis";if(s==="flac")return"flac";if(Ne.includes(s))return s;throw new TypeError(`Unhandled codec '${s}'.`)},Vr=/^pcm-([usf])(\d+)+(be)?$/,Lt=s=>{if($(Ne.includes(s)),s==="ulaw")return{dataType:"ulaw",sampleSize:1,littleEndian:!0,silentValue:255};if(s==="alaw")return{dataType:"alaw",sampleSize:1,littleEndian:!0,silentValue:213};const e=Vr.exec(s);$(e);let t;e[1]==="u"?t="unsigned":e[1]==="s"?t="signed":t="float";const i=Number(e[2])/8,r=e[3]!=="be",n=s==="pcm-u8"?2**7:0;return{dataType:t,sampleSize:i,littleEndian:r,silentValue:n}},Wr=s=>s.startsWith("avc1")||s.startsWith("avc3")?"avc":s.startsWith("hev1")||s.startsWith("hvc1")?"hevc":s==="vp8"?"vp8":s.startsWith("vp09")?"vp9":s.startsWith("av01")?"av1":s.startsWith("mp4a.40")||s==="mp4a.67"?"aac":s==="mp3"||s==="mp4a.69"||s==="mp4a.6B"||s==="mp4a.6b"?"mp3":s==="opus"?"opus":s==="vorbis"?"vorbis":s==="flac"?"flac":s==="ulaw"?"ulaw":s==="alaw"?"alaw":Vr.test(s)?s:s==="webvtt"?"webvtt":null,fl=s=>s==="avc"?{avc:{format:"avc"}}:s==="hevc"?{hevc:{format:"hevc"}}:{},pl=s=>s==="aac"?{aac:{format:"aac"}}:s==="opus"?{opus:{format:"opus"}}:{},ml=["avc1","avc3","hev1","hvc1","vp8","vp09","av01"],gl=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,yl=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,bl=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,vl=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,wl=s=>{if(!s)throw new TypeError("Video chunk metadata must be provided.");if(typeof s!="object")throw new TypeError("Video chunk metadata must be an object.");if(!s.decoderConfig)throw new TypeError("Video chunk metadata must include a decoder configuration.");if(typeof s.decoderConfig!="object")throw new TypeError("Video chunk metadata decoder configuration must be an object.");if(typeof s.decoderConfig.codec!="string")throw new TypeError("Video chunk metadata decoder configuration must specify a codec string.");if(!ml.some(e=>s.decoderConfig.codec.startsWith(e)))throw new TypeError("Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(s.decoderConfig.codedWidth)||s.decoderConfig.codedWidth<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).");if(!Number.isInteger(s.decoderConfig.codedHeight)||s.decoderConfig.codedHeight<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).");if(s.decoderConfig.description!==void 0&&!xi(s.decoderConfig.description))throw new TypeError("Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(s.decoderConfig.colorSpace!==void 0){const{colorSpace:e}=s.decoderConfig;if(typeof e!="object")throw new TypeError("Video chunk metadata decoder configuration colorSpace, when provided, must be an object.");const t=Object.keys(vi);if(e.primaries!=null&&!t.includes(e.primaries))throw new TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${t.join(", ")}.`);const i=Object.keys(wi);if(e.transfer!=null&&!i.includes(e.transfer))throw new TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${i.join(", ")}.`);const r=Object.keys(_i);if(e.matrix!=null&&!r.includes(e.matrix))throw new TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${r.join(", ")}.`);if(e.fullRange!=null&&typeof e.fullRange!="boolean")throw new TypeError("Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.")}if(s.decoderConfig.codec.startsWith("avc1")||s.decoderConfig.codec.startsWith("avc3")){if(!gl.test(s.decoderConfig.codec))throw new 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(s.decoderConfig.codec.startsWith("hev1")||s.decoderConfig.codec.startsWith("hvc1")){if(!yl.test(s.decoderConfig.codec))throw new 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(s.decoderConfig.codec.startsWith("vp8")){if(s.decoderConfig.codec!=="vp8")throw new TypeError('Video chunk metadata decoder configuration codec string for VP8 must be "vp8".')}else if(s.decoderConfig.codec.startsWith("vp09")){if(!bl.test(s.decoderConfig.codec))throw new 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(s.decoderConfig.codec.startsWith("av01")&&!vl.test(s.decoderConfig.codec))throw new 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/.')},_l=["mp4a","mp3","opus","vorbis","flac","ulaw","alaw","pcm"],xl=s=>{if(!s)throw new TypeError("Audio chunk metadata must be provided.");if(typeof s!="object")throw new TypeError("Audio chunk metadata must be an object.");if(!s.decoderConfig)throw new TypeError("Audio chunk metadata must include a decoder configuration.");if(typeof s.decoderConfig!="object")throw new TypeError("Audio chunk metadata decoder configuration must be an object.");if(typeof s.decoderConfig.codec!="string")throw new TypeError("Audio chunk metadata decoder configuration must specify a codec string.");if(!_l.some(e=>s.decoderConfig.codec.startsWith(e)))throw new TypeError("Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(s.decoderConfig.sampleRate)||s.decoderConfig.sampleRate<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).");if(!Number.isInteger(s.decoderConfig.numberOfChannels)||s.decoderConfig.numberOfChannels<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).");if(s.decoderConfig.description!==void 0&&!xi(s.decoderConfig.description))throw new TypeError("Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(s.decoderConfig.codec.startsWith("mp4a")&&s.decoderConfig.codec!=="mp4a.69"&&s.decoderConfig.codec!=="mp4a.6B"&&s.decoderConfig.codec!=="mp4a.6b"){if(!["mp4a.40.2","mp4a.40.02","mp4a.40.5","mp4a.40.05","mp4a.40.29","mp4a.67"].includes(s.decoderConfig.codec))throw new 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/.");if(!s.decoderConfig.description)throw new TypeError("Audio chunk metadata decoder configuration for AAC must include a description, which is expected to be an AudioSpecificConfig as specified in ISO 14496-3.")}else if(s.decoderConfig.codec.startsWith("mp3")||s.decoderConfig.codec.startsWith("mp4a")){if(s.decoderConfig.codec!=="mp3"&&s.decoderConfig.codec!=="mp4a.69"&&s.decoderConfig.codec!=="mp4a.6B"&&s.decoderConfig.codec!=="mp4a.6b")throw new TypeError('Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".')}else if(s.decoderConfig.codec.startsWith("opus")){if(s.decoderConfig.codec!=="opus")throw new TypeError('Audio chunk metadata decoder configuration codec string for Opus must be "opus".');if(s.decoderConfig.description&&s.decoderConfig.description.byteLength<18)throw new 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(s.decoderConfig.codec.startsWith("vorbis")){if(s.decoderConfig.codec!=="vorbis")throw new TypeError('Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".');if(!s.decoderConfig.description)throw new 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(s.decoderConfig.codec.startsWith("flac")){if(s.decoderConfig.codec!=="flac")throw new TypeError('Audio chunk metadata decoder configuration codec string for FLAC must be "flac".');if(!s.decoderConfig.description||s.decoderConfig.description.byteLength<42)throw new 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((s.decoderConfig.codec.startsWith("pcm")||s.decoderConfig.codec.startsWith("ulaw")||s.decoderConfig.codec.startsWith("alaw"))&&!Ne.includes(s.decoderConfig.codec))throw new TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${Ne.join(", ")}).`)},Cl=s=>{if(!s)throw new TypeError("Subtitle metadata must be provided.");if(typeof s!="object")throw new TypeError("Subtitle metadata must be an object.");if(!s.config)throw new TypeError("Subtitle metadata must include a config object.");if(typeof s.config!="object")throw new TypeError("Subtitle metadata config must be an object.");if(typeof s.config.description!="string")throw new TypeError("Subtitle metadata config description must be a string.")};/*!
207
+ */const Ki=["avc","hevc","vp9","av1","vp8"],Xt=["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"],Zu=["aac","opus","mp3","vorbis","flac"],Cr=[...Zu,...Xt],yn=["webvtt"],Ku=[{maxMacroblocks:99,maxBitrate:64e3,level:10},{maxMacroblocks:396,maxBitrate:192e3,level:11},{maxMacroblocks:396,maxBitrate:384e3,level:12},{maxMacroblocks:396,maxBitrate:768e3,level:13},{maxMacroblocks:396,maxBitrate:2e6,level:20},{maxMacroblocks:792,maxBitrate:4e6,level:21},{maxMacroblocks:1620,maxBitrate:4e6,level:22},{maxMacroblocks:1620,maxBitrate:1e7,level:30},{maxMacroblocks:3600,maxBitrate:14e6,level:31},{maxMacroblocks:5120,maxBitrate:2e7,level:32},{maxMacroblocks:8192,maxBitrate:2e7,level:40},{maxMacroblocks:8192,maxBitrate:5e7,level:41},{maxMacroblocks:8704,maxBitrate:5e7,level:42},{maxMacroblocks:22080,maxBitrate:135e6,level:50},{maxMacroblocks:36864,maxBitrate:24e7,level:51},{maxMacroblocks:36864,maxBitrate:24e7,level:52},{maxMacroblocks:139264,maxBitrate:24e7,level:60},{maxMacroblocks:139264,maxBitrate:48e7,level:61},{maxMacroblocks:139264,maxBitrate:8e8,level:62}],Yu=[{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}],Ju=[{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}],Qu=[{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}],vv=(s,e,t,i)=>{if(s==="avc"){const n=Math.ceil(e/16)*Math.ceil(t/16),a=Ku.find(l=>n<=l.maxMacroblocks&&i<=l.maxBitrate)??Gt(Ku),o=a?a.level:0,c="64".padStart(2,"0"),u="00",h=o.toString(16).padStart(2,"0");return`avc1.${c}${u}${h}`}else if(s==="hevc"){const r="",a="6",o=e*t,c=Yu.find(h=>o<=h.maxPictureSize&&i<=h.maxBitrate)??Gt(Yu);return`hev1.${r}1.${a}.${c.tier}${c.level}.B0`}else{if(s==="vp8")return"vp8";if(s==="vp9"){const r="00",n=e*t,a=Ju.find(c=>n<=c.maxPictureSize&&i<=c.maxBitrate)??Gt(Ju);return`vp09.${r}.${a.level.toString().padStart(2,"0")}.08`}else if(s==="av1"){const n=e*t,a=Qu.find(u=>n<=u.maxPictureSize&&i<=u.maxBitrate)??Gt(Qu);return`av01.0.${a.level.toString().padStart(2,"0")}${a.tier}.08`}}throw new TypeError(`Unhandled codec '${s}'.`)},wv=s=>{const e=s.split("."),r=(1<<7)+1,n=Number(e[1]),a=e[2],o=Number(a.slice(0,-1)),c=(n<<5)+o,u=a.slice(-1)==="H"?1:0,l=Number(e[3])===8?0:1,d=0,f=e[4]?Number(e[4]):0,p=e[5]?Number(e[5][0]):1,m=e[5]?Number(e[5][1]):1,b=e[5]?Number(e[5][2]):0,g=(u<<7)+(l<<6)+(d<<5)+(f<<4)+(p<<3)+(m<<2)+b;return[r,c,g,0]},xv=(s,e,t)=>{if(s==="aac")return e>=2&&t<=24e3?"mp4a.40.29":t<=24e3?"mp4a.40.5":"mp4a.40.2";if(s==="mp3")return"mp3";if(s==="opus")return"opus";if(s==="vorbis")return"vorbis";if(s==="flac")return"flac";if(Xt.includes(s))return s;throw new TypeError(`Unhandled codec '${s}'.`)},e0=/^pcm-([usf])(\d+)+(be)?$/,kr=s=>{if(q(Xt.includes(s)),s==="ulaw")return{dataType:"ulaw",sampleSize:1,littleEndian:!0,silentValue:255};if(s==="alaw")return{dataType:"alaw",sampleSize:1,littleEndian:!0,silentValue:213};const e=e0.exec(s);q(e);let t;e[1]==="u"?t="unsigned":e[1]==="s"?t="signed":t="float";const i=Number(e[2])/8,r=e[3]!=="be",n=s==="pcm-u8"?2**7:0;return{dataType:t,sampleSize:i,littleEndian:r,silentValue:n}},t0=s=>s.startsWith("avc1")||s.startsWith("avc3")?"avc":s.startsWith("hev1")||s.startsWith("hvc1")?"hevc":s==="vp8"?"vp8":s.startsWith("vp09")?"vp9":s.startsWith("av01")?"av1":s.startsWith("mp4a.40")||s==="mp4a.67"?"aac":s==="mp3"||s==="mp4a.69"||s==="mp4a.6B"||s==="mp4a.6b"?"mp3":s==="opus"?"opus":s==="vorbis"?"vorbis":s==="flac"?"flac":s==="ulaw"?"ulaw":s==="alaw"?"alaw":e0.test(s)?s:s==="webvtt"?"webvtt":null,Cv=s=>s==="avc"?{avc:{format:"avc"}}:s==="hevc"?{hevc:{format:"hevc"}}:{},kv=s=>s==="aac"?{aac:{format:"aac"}}:s==="opus"?{opus:{format:"opus"}}:{},Sv=["avc1","avc3","hev1","hvc1","vp8","vp09","av01"],Tv=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,Ev=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,_v=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,Av=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,Iv=s=>{if(!s)throw new TypeError("Video chunk metadata must be provided.");if(typeof s!="object")throw new TypeError("Video chunk metadata must be an object.");if(!s.decoderConfig)throw new TypeError("Video chunk metadata must include a decoder configuration.");if(typeof s.decoderConfig!="object")throw new TypeError("Video chunk metadata decoder configuration must be an object.");if(typeof s.decoderConfig.codec!="string")throw new TypeError("Video chunk metadata decoder configuration must specify a codec string.");if(!Sv.some(e=>s.decoderConfig.codec.startsWith(e)))throw new TypeError("Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(s.decoderConfig.codedWidth)||s.decoderConfig.codedWidth<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).");if(!Number.isInteger(s.decoderConfig.codedHeight)||s.decoderConfig.codedHeight<=0)throw new TypeError("Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).");if(s.decoderConfig.description!==void 0&&!gn(s.decoderConfig.description))throw new TypeError("Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(s.decoderConfig.colorSpace!==void 0){const{colorSpace:e}=s.decoderConfig;if(typeof e!="object")throw new TypeError("Video chunk metadata decoder configuration colorSpace, when provided, must be an object.");const t=Object.keys(fn);if(e.primaries!=null&&!t.includes(e.primaries))throw new TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${t.join(", ")}.`);const i=Object.keys(pn);if(e.transfer!=null&&!i.includes(e.transfer))throw new TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${i.join(", ")}.`);const r=Object.keys(mn);if(e.matrix!=null&&!r.includes(e.matrix))throw new TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${r.join(", ")}.`);if(e.fullRange!=null&&typeof e.fullRange!="boolean")throw new TypeError("Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.")}if(s.decoderConfig.codec.startsWith("avc1")||s.decoderConfig.codec.startsWith("avc3")){if(!Tv.test(s.decoderConfig.codec))throw new 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(s.decoderConfig.codec.startsWith("hev1")||s.decoderConfig.codec.startsWith("hvc1")){if(!Ev.test(s.decoderConfig.codec))throw new 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(s.decoderConfig.codec.startsWith("vp8")){if(s.decoderConfig.codec!=="vp8")throw new TypeError('Video chunk metadata decoder configuration codec string for VP8 must be "vp8".')}else if(s.decoderConfig.codec.startsWith("vp09")){if(!_v.test(s.decoderConfig.codec))throw new 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(s.decoderConfig.codec.startsWith("av01")&&!Av.test(s.decoderConfig.codec))throw new 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/.')},Pv=["mp4a","mp3","opus","vorbis","flac","ulaw","alaw","pcm"],Ov=s=>{if(!s)throw new TypeError("Audio chunk metadata must be provided.");if(typeof s!="object")throw new TypeError("Audio chunk metadata must be an object.");if(!s.decoderConfig)throw new TypeError("Audio chunk metadata must include a decoder configuration.");if(typeof s.decoderConfig!="object")throw new TypeError("Audio chunk metadata decoder configuration must be an object.");if(typeof s.decoderConfig.codec!="string")throw new TypeError("Audio chunk metadata decoder configuration must specify a codec string.");if(!Pv.some(e=>s.decoderConfig.codec.startsWith(e)))throw new TypeError("Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(s.decoderConfig.sampleRate)||s.decoderConfig.sampleRate<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).");if(!Number.isInteger(s.decoderConfig.numberOfChannels)||s.decoderConfig.numberOfChannels<=0)throw new TypeError("Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).");if(s.decoderConfig.description!==void 0&&!gn(s.decoderConfig.description))throw new TypeError("Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(s.decoderConfig.codec.startsWith("mp4a")&&s.decoderConfig.codec!=="mp4a.69"&&s.decoderConfig.codec!=="mp4a.6B"&&s.decoderConfig.codec!=="mp4a.6b"){if(!["mp4a.40.2","mp4a.40.02","mp4a.40.5","mp4a.40.05","mp4a.40.29","mp4a.67"].includes(s.decoderConfig.codec))throw new 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/.");if(!s.decoderConfig.description)throw new TypeError("Audio chunk metadata decoder configuration for AAC must include a description, which is expected to be an AudioSpecificConfig as specified in ISO 14496-3.")}else if(s.decoderConfig.codec.startsWith("mp3")||s.decoderConfig.codec.startsWith("mp4a")){if(s.decoderConfig.codec!=="mp3"&&s.decoderConfig.codec!=="mp4a.69"&&s.decoderConfig.codec!=="mp4a.6B"&&s.decoderConfig.codec!=="mp4a.6b")throw new TypeError('Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".')}else if(s.decoderConfig.codec.startsWith("opus")){if(s.decoderConfig.codec!=="opus")throw new TypeError('Audio chunk metadata decoder configuration codec string for Opus must be "opus".');if(s.decoderConfig.description&&s.decoderConfig.description.byteLength<18)throw new 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(s.decoderConfig.codec.startsWith("vorbis")){if(s.decoderConfig.codec!=="vorbis")throw new TypeError('Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".');if(!s.decoderConfig.description)throw new 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(s.decoderConfig.codec.startsWith("flac")){if(s.decoderConfig.codec!=="flac")throw new TypeError('Audio chunk metadata decoder configuration codec string for FLAC must be "flac".');if(!s.decoderConfig.description||s.decoderConfig.description.byteLength<42)throw new 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((s.decoderConfig.codec.startsWith("pcm")||s.decoderConfig.codec.startsWith("ulaw")||s.decoderConfig.codec.startsWith("alaw"))&&!Xt.includes(s.decoderConfig.codec))throw new TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${Xt.join(", ")}).`)},Fv=s=>{if(!s)throw new TypeError("Subtitle metadata must be provided.");if(typeof s!="object")throw new TypeError("Subtitle metadata must be an object.");if(!s.config)throw new TypeError("Subtitle metadata must include a config object.");if(typeof s.config!="object")throw new TypeError("Subtitle metadata config must be an object.");if(typeof s.config.description!="string")throw new TypeError("Subtitle metadata config description must be a string.")};/*!
206
208
  * Copyright (c) 2025-present, Vanilagy and contributors
207
209
  *
208
210
  * This Source Code Form is subject to the terms of the Mozilla Public
209
211
  * License, v. 2.0. If a copy of the MPL was not distributed with this
210
212
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
211
- */class kl{constructor(e){this.mutex=new Mr,this.firstMediaStreamTimestamp=null,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateAndNormalizeTimestamp(e,t,i){t+=e.source._timestampOffset;let r=this.trackTimestampInfo.get(e);if(!r){if(!i)throw new Error("First frame must be a key frame.");r={maxTimestamp:t,maxTimestampBeforeLastKeyFrame:t},this.trackTimestampInfo.set(e,r)}if(t<0)throw new Error(`Timestamps must be non-negative (got ${t}s).`);if(i&&(r.maxTimestampBeforeLastKeyFrame=r.maxTimestamp),t<r.maxTimestampBeforeLastKeyFrame)throw new Error(`Timestamps cannot be smaller than the highest timestamp of the previous GOP (a GOP begins with a key frame and ends right before the next key frame). Got ${t}s, but highest timestamp is ${r.maxTimestampBeforeLastKeyFrame}s.`);return r.maxTimestamp=Math.max(r.maxTimestamp,t),t}}/*!
213
+ */class Rv{constructor(e){this.mutex=new ju,this.firstMediaStreamTimestamp=null,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateAndNormalizeTimestamp(e,t,i){t+=e.source._timestampOffset;let r=this.trackTimestampInfo.get(e);if(!r){if(!i)throw new Error("First frame must be a key frame.");r={maxTimestamp:t,maxTimestampBeforeLastKeyFrame:t},this.trackTimestampInfo.set(e,r)}if(t<0)throw new Error(`Timestamps must be non-negative (got ${t}s).`);if(i&&(r.maxTimestampBeforeLastKeyFrame=r.maxTimestamp),t<r.maxTimestampBeforeLastKeyFrame)throw new Error(`Timestamps cannot be smaller than the highest timestamp of the previous GOP (a GOP begins with a key frame and ends right before the next key frame). Got ${t}s, but highest timestamp is ${r.maxTimestampBeforeLastKeyFrame}s.`);return r.maxTimestamp=Math.max(r.maxTimestamp,t),t}}/*!
212
214
  * Copyright (c) 2025-present, Vanilagy and contributors
213
215
  *
214
216
  * This Source Code Form is subject to the terms of the Mozilla Public
215
217
  * License, v. 2.0. If a copy of the MPL was not distributed with this
216
218
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
217
- */var Jt;(function(s){s[s.IDR=5]="IDR",s[s.SPS=7]="SPS",s[s.PPS=8]="PPS",s[s.SPS_EXT=13]="SPS_EXT"})(Jt||(Jt={}));var Ue;(function(s){s[s.RASL_N=8]="RASL_N",s[s.RASL_R=9]="RASL_R",s[s.BLA_W_LP=16]="BLA_W_LP",s[s.RSV_IRAP_VCL23=23]="RSV_IRAP_VCL23",s[s.VPS_NUT=32]="VPS_NUT",s[s.SPS_NUT=33]="SPS_NUT",s[s.PPS_NUT=34]="PPS_NUT",s[s.PREFIX_SEI_NUT=39]="PREFIX_SEI_NUT",s[s.SUFFIX_SEI_NUT=40]="SUFFIX_SEI_NUT"})(Ue||(Ue={}));const cs=s=>{const e=[];let t=0;for(;t<s.length;){let i=-1,r=0;for(let n=t;n<s.length-3;n++){if(s[n]===0&&s[n+1]===0&&s[n+2]===1){i=n,r=3;break}if(n<s.length-4&&s[n]===0&&s[n+1]===0&&s[n+2]===0&&s[n+3]===1){i=n,r=4;break}}if(i===-1)break;if(t>0&&i>t){const n=s.subarray(t,i);n.length>0&&e.push(n)}t=i+r}if(t<s.length){const i=s.subarray(t);i.length>0&&e.push(i)}return e},hs=s=>{const e=[],t=s.length;for(let i=0;i<t;i++)i+2<t&&s[i]===0&&s[i+1]===0&&s[i+2]===3?(e.push(0,0),i+=2):e.push(s[i]);return new Uint8Array(e)},Tl=s=>{const t=cs(s);if(t.length===0)return null;let i=0;for(const a of t)i+=4+a.byteLength;const r=new Uint8Array(i),n=new DataView(r.buffer);let o=0;for(const a of t){const p=a.byteLength;n.setUint32(o,p,!1),o+=4,r.set(a,o),o+=a.byteLength}return r},us=s=>s[0]&31,Sl=s=>{try{const e=cs(s),t=e.filter(c=>us(c)===Jt.SPS),i=e.filter(c=>us(c)===Jt.PPS),r=e.filter(c=>us(c)===Jt.SPS_EXT);if(t.length===0||i.length===0)return null;const n=t[0],o=new Yt(hs(n));if(o.skipBits(1),o.skipBits(2),o.readBits(5)!==7)return console.error("Invalid SPS NAL unit type"),null;const p=o.readAlignedByte(),m=o.readAlignedByte(),d=o.readAlignedByte(),l={configurationVersion:1,avcProfileIndication:p,profileCompatibility:m,avcLevelIndication:d,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:i,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if(p===100||p===110||p===122||p===144){W(o);const c=W(o);c===3&&o.skipBits(1);const u=W(o),h=W(o);l.chromaFormat=c,l.bitDepthLumaMinus8=u,l.bitDepthChromaMinus8=h,l.sequenceParameterSetExt=r}return l}catch(e){return console.error("Error building AVC Decoder Configuration Record:",e),null}},El=s=>{const e=[];e.push(s.configurationVersion),e.push(s.avcProfileIndication),e.push(s.profileCompatibility),e.push(s.avcLevelIndication),e.push(252|s.lengthSizeMinusOne&3),e.push(224|s.sequenceParameterSets.length&31);for(const t of s.sequenceParameterSets){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}e.push(s.pictureParameterSets.length);for(const t of s.pictureParameterSets){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}if(s.avcProfileIndication===100||s.avcProfileIndication===110||s.avcProfileIndication===122||s.avcProfileIndication===144){$(s.chromaFormat!==null),$(s.bitDepthLumaMinus8!==null),$(s.bitDepthChromaMinus8!==null),$(s.sequenceParameterSetExt!==null),e.push(252|s.chromaFormat&3),e.push(248|s.bitDepthLumaMinus8&7),e.push(248|s.bitDepthChromaMinus8&7),e.push(s.sequenceParameterSetExt.length);for(const t of s.sequenceParameterSetExt){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}}return new Uint8Array(e)},Bt=s=>s[0]>>1&63,Al=s=>{try{const e=cs(s),t=e.filter(k=>Bt(k)===Ue.VPS_NUT),i=e.filter(k=>Bt(k)===Ue.SPS_NUT),r=e.filter(k=>Bt(k)===Ue.PPS_NUT),n=e.filter(k=>Bt(k)===Ue.PREFIX_SEI_NUT||Bt(k)===Ue.SUFFIX_SEI_NUT);if(i.length===0||r.length===0)return null;const o=i[0],a=new Yt(hs(o));a.skipBits(16),a.readBits(4);const p=a.readBits(3),m=a.readBits(1),{general_profile_space:d,general_tier_flag:l,general_profile_idc:c,general_profile_compatibility_flags:u,general_constraint_indicator_flags:h,general_level_idc:f}=Il(a,p);W(a);const b=W(a);b===3&&a.skipBits(1),W(a),W(a),a.readBits(1)&&(W(a),W(a),W(a),W(a));const g=W(a),y=W(a);W(a);const _=a.readBits(1)?0:p;for(let k=_;k<=p;k++)W(a),W(a),W(a);W(a),W(a),W(a),W(a),W(a),W(a),a.readBits(1)&&a.readBits(1)&&Pl(a),a.skipBits(1),a.skipBits(1),a.readBits(1)&&(a.skipBits(4),a.skipBits(4),W(a),W(a),a.skipBits(1));const C=W(a);if(Rl(a,C),a.readBits(1)){const k=W(a);for(let E=0;E<k;E++)W(a),a.skipBits(1)}a.skipBits(1),a.skipBits(1);let S=0;a.readBits(1)&&(S=Fl(a,p));let T=0;if(r.length>0){const k=r[0],E=new Yt(hs(k));E.skipBits(16),W(E),W(E),E.skipBits(1),E.skipBits(1),E.skipBits(3),E.skipBits(1),E.skipBits(1),W(E),W(E),Qt(E),E.skipBits(1),E.skipBits(1),E.readBits(1)&&W(E),Qt(E),Qt(E),E.skipBits(1),E.skipBits(1),E.skipBits(1),E.skipBits(1);const P=E.readBits(1),O=E.readBits(1);!P&&!O?T=0:P&&!O?T=2:!P&&O?T=3:T=0}const w=[...t.length?[{arrayCompleteness:1,nalUnitType:Ue.VPS_NUT,nalUnits:t}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:Ue.SPS_NUT,nalUnits:i}]:[],...r.length?[{arrayCompleteness:1,nalUnitType:Ue.PPS_NUT,nalUnits:r}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:Bt(n[0]),nalUnits:n}]:[]];return{configurationVersion:1,generalProfileSpace:d,generalTierFlag:l,generalProfileIdc:c,generalProfileCompatibilityFlags:u,generalConstraintIndicatorFlags:h,generalLevelIdc:f,minSpatialSegmentationIdc:S,parallelismType:T,chromaFormatIdc:b,bitDepthLumaMinus8:g,bitDepthChromaMinus8:y,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:p+1,temporalIdNested:m,lengthSizeMinusOne:3,arrays:w}}catch(e){return console.error("Error building HEVC Decoder Configuration Record:",e),null}},Il=(s,e)=>{const t=s.readBits(2),i=s.readBits(1),r=s.readBits(5);let n=0;for(let d=0;d<32;d++)n=n<<1|s.readBits(1);const o=new Uint8Array(6);for(let d=0;d<6;d++)o[d]=s.readBits(8);const a=s.readBits(8),p=[],m=[];for(let d=0;d<e;d++)p.push(s.readBits(1)),m.push(s.readBits(1));if(e>0)for(let d=e;d<8;d++)s.skipBits(2);for(let d=0;d<e;d++)p[d]&&s.skipBits(88),m[d]&&s.skipBits(8);return{general_profile_space:t,general_tier_flag:i,general_profile_idc:r,general_profile_compatibility_flags:n,general_constraint_indicator_flags:o,general_level_idc:a}},Pl=s=>{for(let e=0;e<4;e++)for(let t=0;t<(e===3?2:6);t++)if(!s.readBits(1))W(s);else{const r=Math.min(64,1<<4+(e<<1));e>1&&Qt(s);for(let n=0;n<r;n++)Qt(s)}},Rl=(s,e)=>{const t=[];for(let i=0;i<e;i++)t[i]=Ol(s,i,e,t)},Ol=(s,e,t,i)=>{let r=0,n=0,o=0;if(e!==0&&(n=s.readBits(1)),n){if(e===t){const p=W(s);o=e-(p+1)}else o=e-1;s.readBits(1),W(s);const a=i[o]??0;for(let p=0;p<=a;p++)s.readBits(1)||s.readBits(1);r=i[o]}else{const a=W(s),p=W(s);for(let m=0;m<a;m++)W(s),s.readBits(1);for(let m=0;m<p;m++)W(s),s.readBits(1);r=a+p}return r},Fl=(s,e)=>{if(s.readBits(1)&&s.readBits(8)===255&&(s.readBits(16),s.readBits(16)),s.readBits(1)&&s.readBits(1),s.readBits(1)&&(s.readBits(3),s.readBits(1),s.readBits(1)&&(s.readBits(8),s.readBits(8),s.readBits(8))),s.readBits(1)&&(W(s),W(s)),s.readBits(1),s.readBits(1),s.readBits(1),s.readBits(1)&&(W(s),W(s),W(s),W(s)),s.readBits(1)&&(s.readBits(32),s.readBits(32),s.readBits(1)&&W(s),s.readBits(1)&&Ml(s,!0,e)),s.readBits(1)){s.readBits(1),s.readBits(1),s.readBits(1);const t=W(s);return W(s),W(s),W(s),W(s),t}return 0},Ml=(s,e,t)=>{let i=!1,r=!1,n=!1;i=s.readBits(1)===1,r=s.readBits(1)===1,(i||r)&&(n=s.readBits(1)===1,n&&(s.readBits(8),s.readBits(5),s.readBits(1),s.readBits(5)),s.readBits(4),s.readBits(4),n&&s.readBits(4),s.readBits(5),s.readBits(5),s.readBits(5));for(let o=0;o<=t;o++){const a=s.readBits(1)===1;let p=!0;a||(p=s.readBits(1)===1);let m=!1;p?W(s):m=s.readBits(1)===1;let d=1;m||(d=W(s)+1),i&&Gr(s,d,n),r&&Gr(s,d,n)}},Gr=(s,e,t)=>{for(let i=0;i<e;i++)W(s),W(s),t&&(W(s),W(s)),s.readBits(1)},Ll=s=>{const e=[];e.push(s.configurationVersion),e.push((s.generalProfileSpace&3)<<6|(s.generalTierFlag&1)<<5|s.generalProfileIdc&31),e.push(s.generalProfileCompatibilityFlags>>>24&255),e.push(s.generalProfileCompatibilityFlags>>>16&255),e.push(s.generalProfileCompatibilityFlags>>>8&255),e.push(s.generalProfileCompatibilityFlags&255),e.push(...s.generalConstraintIndicatorFlags),e.push(s.generalLevelIdc&255),e.push(240|s.minSpatialSegmentationIdc>>8&15),e.push(s.minSpatialSegmentationIdc&255),e.push(252|s.parallelismType&3),e.push(252|s.chromaFormatIdc&3),e.push(248|s.bitDepthLumaMinus8&7),e.push(248|s.bitDepthChromaMinus8&7),e.push(s.avgFrameRate>>8&255),e.push(s.avgFrameRate&255),e.push((s.constantFrameRate&3)<<6|(s.numTemporalLayers&7)<<3|(s.temporalIdNested&1)<<2|s.lengthSizeMinusOne&3),e.push(s.arrays.length&255);for(const t of s.arrays){e.push((t.arrayCompleteness&1)<<7|0|t.nalUnitType&63),e.push(t.nalUnits.length>>8&255),e.push(t.nalUnits.length&255);for(const i of t.nalUnits){e.push(i.length>>8&255),e.push(i.length&255);for(let r=0;r<i.length;r++)e.push(i[r])}}return new Uint8Array(e)},Bl=s=>{const e=Fr(s),t=e.getUint8(9),i=e.getUint16(10,!0),r=e.getUint32(12,!0),n=e.getInt16(16,!0),o=e.getUint8(18);let a=null;return o&&(a=s.subarray(19,21+t)),{outputChannelCount:t,preSkip:i,inputSampleRate:r,outputGain:n,channelMappingFamily:o,channelMappingTable:a}};var Zr;(function(s){s[s.STREAMINFO=0]="STREAMINFO",s[s.VORBIS_COMMENT=4]="VORBIS_COMMENT",s[s.PICTURE=6]="PICTURE"})(Zr||(Zr={}));/*!
219
+ */var os;(function(s){s[s.IDR=5]="IDR",s[s.SPS=7]="SPS",s[s.PPS=8]="PPS",s[s.SPS_EXT=13]="SPS_EXT"})(os||(os={}));var Zt;(function(s){s[s.RASL_N=8]="RASL_N",s[s.RASL_R=9]="RASL_R",s[s.BLA_W_LP=16]="BLA_W_LP",s[s.RSV_IRAP_VCL23=23]="RSV_IRAP_VCL23",s[s.VPS_NUT=32]="VPS_NUT",s[s.SPS_NUT=33]="SPS_NUT",s[s.PPS_NUT=34]="PPS_NUT",s[s.PREFIX_SEI_NUT=39]="PREFIX_SEI_NUT",s[s.SUFFIX_SEI_NUT=40]="SUFFIX_SEI_NUT"})(Zt||(Zt={}));const io=s=>{const e=[];let t=0;for(;t<s.length;){let i=-1,r=0;for(let n=t;n<s.length-3;n++){if(s[n]===0&&s[n+1]===0&&s[n+2]===1){i=n,r=3;break}if(n<s.length-4&&s[n]===0&&s[n+1]===0&&s[n+2]===0&&s[n+3]===1){i=n,r=4;break}}if(i===-1)break;if(t>0&&i>t){const n=s.subarray(t,i);n.length>0&&e.push(n)}t=i+r}if(t<s.length){const i=s.subarray(t);i.length>0&&e.push(i)}return e},ro=s=>{const e=[],t=s.length;for(let i=0;i<t;i++)i+2<t&&s[i]===0&&s[i+1]===0&&s[i+2]===3?(e.push(0,0),i+=2):e.push(s[i]);return new Uint8Array(e)},Mv=s=>{const t=io(s);if(t.length===0)return null;let i=0;for(const o of t)i+=4+o.byteLength;const r=new Uint8Array(i),n=new DataView(r.buffer);let a=0;for(const o of t){const c=o.byteLength;n.setUint32(a,c,!1),a+=4,r.set(o,a),a+=o.byteLength}return r},so=s=>s[0]&31,Dv=s=>{try{const e=io(s),t=e.filter(d=>so(d)===os.SPS),i=e.filter(d=>so(d)===os.PPS),r=e.filter(d=>so(d)===os.SPS_EXT);if(t.length===0||i.length===0)return null;const n=t[0],a=new ns(ro(n));if(a.skipBits(1),a.skipBits(2),a.readBits(5)!==7)return console.error("Invalid SPS NAL unit type"),null;const c=a.readAlignedByte(),u=a.readAlignedByte(),h=a.readAlignedByte(),l={configurationVersion:1,avcProfileIndication:c,profileCompatibility:u,avcLevelIndication:h,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:i,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if(c===100||c===110||c===122||c===144){re(a);const d=re(a);d===3&&a.skipBits(1);const f=re(a),p=re(a);l.chromaFormat=d,l.bitDepthLumaMinus8=f,l.bitDepthChromaMinus8=p,l.sequenceParameterSetExt=r}return l}catch(e){return console.error("Error building AVC Decoder Configuration Record:",e),null}},Bv=s=>{const e=[];e.push(s.configurationVersion),e.push(s.avcProfileIndication),e.push(s.profileCompatibility),e.push(s.avcLevelIndication),e.push(252|s.lengthSizeMinusOne&3),e.push(224|s.sequenceParameterSets.length&31);for(const t of s.sequenceParameterSets){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}e.push(s.pictureParameterSets.length);for(const t of s.pictureParameterSets){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}if(s.avcProfileIndication===100||s.avcProfileIndication===110||s.avcProfileIndication===122||s.avcProfileIndication===144){q(s.chromaFormat!==null),q(s.bitDepthLumaMinus8!==null),q(s.bitDepthChromaMinus8!==null),q(s.sequenceParameterSetExt!==null),e.push(252|s.chromaFormat&3),e.push(248|s.bitDepthLumaMinus8&7),e.push(248|s.bitDepthChromaMinus8&7),e.push(s.sequenceParameterSetExt.length);for(const t of s.sequenceParameterSetExt){const i=t.byteLength;e.push(i>>8),e.push(i&255);for(let r=0;r<i;r++)e.push(t[r])}}return new Uint8Array(e)},Sr=s=>s[0]>>1&63,Lv=s=>{try{const e=io(s),t=e.filter(T=>Sr(T)===Zt.VPS_NUT),i=e.filter(T=>Sr(T)===Zt.SPS_NUT),r=e.filter(T=>Sr(T)===Zt.PPS_NUT),n=e.filter(T=>Sr(T)===Zt.PREFIX_SEI_NUT||Sr(T)===Zt.SUFFIX_SEI_NUT);if(i.length===0||r.length===0)return null;const a=i[0],o=new ns(ro(a));o.skipBits(16),o.readBits(4);const c=o.readBits(3),u=o.readBits(1),{general_profile_space:h,general_tier_flag:l,general_profile_idc:d,general_profile_compatibility_flags:f,general_constraint_indicator_flags:p,general_level_idc:m}=zv(o,c);re(o);const b=re(o);b===3&&o.skipBits(1),re(o),re(o),o.readBits(1)&&(re(o),re(o),re(o),re(o));const g=re(o),y=re(o);re(o);const k=o.readBits(1)?0:c;for(let T=k;T<=c;T++)re(o),re(o),re(o);re(o),re(o),re(o),re(o),re(o),re(o),o.readBits(1)&&o.readBits(1)&&$v(o),o.skipBits(1),o.skipBits(1),o.readBits(1)&&(o.skipBits(4),o.skipBits(4),re(o),re(o),o.skipBits(1));const C=re(o);if(Nv(o,C),o.readBits(1)){const T=re(o);for(let A=0;A<T;A++)re(o),o.skipBits(1)}o.skipBits(1),o.skipBits(1);let _=0;o.readBits(1)&&(_=Vv(o,c));let E=0;if(r.length>0){const T=r[0],A=new ns(ro(T));A.skipBits(16),re(A),re(A),A.skipBits(1),A.skipBits(1),A.skipBits(3),A.skipBits(1),A.skipBits(1),re(A),re(A),as(A),A.skipBits(1),A.skipBits(1),A.readBits(1)&&re(A),as(A),as(A),A.skipBits(1),A.skipBits(1),A.skipBits(1),A.skipBits(1);const R=A.readBits(1),M=A.readBits(1);!R&&!M?E=0:R&&!M?E=2:!R&&M?E=3:E=0}const x=[...t.length?[{arrayCompleteness:1,nalUnitType:Zt.VPS_NUT,nalUnits:t}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:Zt.SPS_NUT,nalUnits:i}]:[],...r.length?[{arrayCompleteness:1,nalUnitType:Zt.PPS_NUT,nalUnits:r}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:Sr(n[0]),nalUnits:n}]:[]];return{configurationVersion:1,generalProfileSpace:h,generalTierFlag:l,generalProfileIdc:d,generalProfileCompatibilityFlags:f,generalConstraintIndicatorFlags:p,generalLevelIdc:m,minSpatialSegmentationIdc:_,parallelismType:E,chromaFormatIdc:b,bitDepthLumaMinus8:g,bitDepthChromaMinus8:y,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:c+1,temporalIdNested:u,lengthSizeMinusOne:3,arrays:x}}catch(e){return console.error("Error building HEVC Decoder Configuration Record:",e),null}},zv=(s,e)=>{const t=s.readBits(2),i=s.readBits(1),r=s.readBits(5);let n=0;for(let h=0;h<32;h++)n=n<<1|s.readBits(1);const a=new Uint8Array(6);for(let h=0;h<6;h++)a[h]=s.readBits(8);const o=s.readBits(8),c=[],u=[];for(let h=0;h<e;h++)c.push(s.readBits(1)),u.push(s.readBits(1));if(e>0)for(let h=e;h<8;h++)s.skipBits(2);for(let h=0;h<e;h++)c[h]&&s.skipBits(88),u[h]&&s.skipBits(8);return{general_profile_space:t,general_tier_flag:i,general_profile_idc:r,general_profile_compatibility_flags:n,general_constraint_indicator_flags:a,general_level_idc:o}},$v=s=>{for(let e=0;e<4;e++)for(let t=0;t<(e===3?2:6);t++)if(!s.readBits(1))re(s);else{const r=Math.min(64,1<<4+(e<<1));e>1&&as(s);for(let n=0;n<r;n++)as(s)}},Nv=(s,e)=>{const t=[];for(let i=0;i<e;i++)t[i]=Uv(s,i,e,t)},Uv=(s,e,t,i)=>{let r=0,n=0,a=0;if(e!==0&&(n=s.readBits(1)),n){if(e===t){const c=re(s);a=e-(c+1)}else a=e-1;s.readBits(1),re(s);const o=i[a]??0;for(let c=0;c<=o;c++)s.readBits(1)||s.readBits(1);r=i[a]}else{const o=re(s),c=re(s);for(let u=0;u<o;u++)re(s),s.readBits(1);for(let u=0;u<c;u++)re(s),s.readBits(1);r=o+c}return r},Vv=(s,e)=>{if(s.readBits(1)&&s.readBits(8)===255&&(s.readBits(16),s.readBits(16)),s.readBits(1)&&s.readBits(1),s.readBits(1)&&(s.readBits(3),s.readBits(1),s.readBits(1)&&(s.readBits(8),s.readBits(8),s.readBits(8))),s.readBits(1)&&(re(s),re(s)),s.readBits(1),s.readBits(1),s.readBits(1),s.readBits(1)&&(re(s),re(s),re(s),re(s)),s.readBits(1)&&(s.readBits(32),s.readBits(32),s.readBits(1)&&re(s),s.readBits(1)&&Hv(s,!0,e)),s.readBits(1)){s.readBits(1),s.readBits(1),s.readBits(1);const t=re(s);return re(s),re(s),re(s),re(s),t}return 0},Hv=(s,e,t)=>{let i=!1,r=!1,n=!1;i=s.readBits(1)===1,r=s.readBits(1)===1,(i||r)&&(n=s.readBits(1)===1,n&&(s.readBits(8),s.readBits(5),s.readBits(1),s.readBits(5)),s.readBits(4),s.readBits(4),n&&s.readBits(4),s.readBits(5),s.readBits(5),s.readBits(5));for(let a=0;a<=t;a++){const o=s.readBits(1)===1;let c=!0;o||(c=s.readBits(1)===1);let u=!1;c?re(s):u=s.readBits(1)===1;let h=1;u||(h=re(s)+1),i&&i0(s,h,n),r&&i0(s,h,n)}},i0=(s,e,t)=>{for(let i=0;i<e;i++)re(s),re(s),t&&(re(s),re(s)),s.readBits(1)},jv=s=>{const e=[];e.push(s.configurationVersion),e.push((s.generalProfileSpace&3)<<6|(s.generalTierFlag&1)<<5|s.generalProfileIdc&31),e.push(s.generalProfileCompatibilityFlags>>>24&255),e.push(s.generalProfileCompatibilityFlags>>>16&255),e.push(s.generalProfileCompatibilityFlags>>>8&255),e.push(s.generalProfileCompatibilityFlags&255),e.push(...s.generalConstraintIndicatorFlags),e.push(s.generalLevelIdc&255),e.push(240|s.minSpatialSegmentationIdc>>8&15),e.push(s.minSpatialSegmentationIdc&255),e.push(252|s.parallelismType&3),e.push(252|s.chromaFormatIdc&3),e.push(248|s.bitDepthLumaMinus8&7),e.push(248|s.bitDepthChromaMinus8&7),e.push(s.avgFrameRate>>8&255),e.push(s.avgFrameRate&255),e.push((s.constantFrameRate&3)<<6|(s.numTemporalLayers&7)<<3|(s.temporalIdNested&1)<<2|s.lengthSizeMinusOne&3),e.push(s.arrays.length&255);for(const t of s.arrays){e.push((t.arrayCompleteness&1)<<7|0|t.nalUnitType&63),e.push(t.nalUnits.length>>8&255),e.push(t.nalUnits.length&255);for(const i of t.nalUnits){e.push(i.length>>8&255),e.push(i.length&255);for(let r=0;r<i.length;r++)e.push(i[r])}}return new Uint8Array(e)},Wv=s=>{const e=Hu(s),t=e.getUint8(9),i=e.getUint16(10,!0),r=e.getUint32(12,!0),n=e.getInt16(16,!0),a=e.getUint8(18);let o=null;return a&&(o=s.subarray(19,21+t)),{outputChannelCount:t,preSkip:i,inputSampleRate:r,outputGain:n,channelMappingFamily:a,channelMappingTable:o}};var r0;(function(s){s[s.STREAMINFO=0]="STREAMINFO",s[s.VORBIS_COMMENT=4]="VORBIS_COMMENT",s[s.PICTURE=6]="PICTURE"})(r0||(r0={}));/*!
218
220
  * Copyright (c) 2025-present, Vanilagy and contributors
219
221
  *
220
222
  * This Source Code Form is subject to the terms of the Mozilla Public
221
223
  * License, v. 2.0. If a copy of the MPL was not distributed with this
222
224
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
223
- */const $l=[],Dl=[];/*!
225
+ */const Gv=[],qv=[];/*!
224
226
  * Copyright (c) 2025-present, Vanilagy and contributors
225
227
  *
226
228
  * This Source Code Form is subject to the terms of the Mozilla Public
227
229
  * License, v. 2.0. If a copy of the MPL was not distributed with this
228
230
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
229
- */const Kr=new Uint8Array(0);class ct{constructor(e,t,i,r,n=-1,o,a){if(this.data=e,this.type=t,this.timestamp=i,this.duration=r,this.sequenceNumber=n,e===Kr&&o===void 0)throw new Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(o===void 0&&(o=e.byteLength),!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!=="key"&&t!=="delta")throw new TypeError('type must be either "key" or "delta".');if(!Number.isFinite(i))throw new TypeError("timestamp must be a number.");if(!Number.isFinite(r)||r<0)throw new TypeError("duration must be a non-negative number.");if(!Number.isFinite(n))throw new TypeError("sequenceNumber must be a number.");if(!Number.isInteger(o)||o<0)throw new TypeError("byteLength must be a non-negative integer.");if(a!==void 0&&(typeof a!="object"||!a))throw new TypeError("sideData, when provided, must be an object.");if(a?.alpha!==void 0&&!(a.alpha instanceof Uint8Array))throw new TypeError("sideData.alpha, when provided, must be a Uint8Array.");if(a?.alphaByteLength!==void 0&&(!Number.isInteger(a.alphaByteLength)||a.alphaByteLength<0))throw new TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");this.byteLength=o,this.sideData=a??{},this.sideData.alpha&&this.sideData.alphaByteLength===void 0&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===Kr}get microsecondTimestamp(){return Math.trunc(lt*this.timestamp)}get microsecondDuration(){return Math.trunc(lt*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw new TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");if(typeof EncodedAudioChunk>"u")throw new Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(e,t){if(!(e instanceof EncodedVideoChunk||e instanceof EncodedAudioChunk))throw new TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");const i=new Uint8Array(e.byteLength);return e.copyTo(i),new ct(i,e.type,e.timestamp/1e6,(e.duration??0)/1e6,void 0,void 0,t)}clone(e){if(e!==void 0&&(typeof e!="object"||e===null))throw new TypeError("options, when provided, must be an object.");if(e?.timestamp!==void 0&&!Number.isFinite(e.timestamp))throw new TypeError("options.timestamp, when provided, must be a number.");if(e?.duration!==void 0&&!Number.isFinite(e.duration))throw new TypeError("options.duration, when provided, must be a number.");return new ct(this.data,this.type,e?.timestamp??this.timestamp,e?.duration??this.duration,this.sequenceNumber,this.byteLength)}}/*!
231
+ */const s0=new Uint8Array(0);class Oi{constructor(e,t,i,r,n=-1,a,o){if(this.data=e,this.type=t,this.timestamp=i,this.duration=r,this.sequenceNumber=n,e===s0&&a===void 0)throw new Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(a===void 0&&(a=e.byteLength),!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!=="key"&&t!=="delta")throw new TypeError('type must be either "key" or "delta".');if(!Number.isFinite(i))throw new TypeError("timestamp must be a number.");if(!Number.isFinite(r)||r<0)throw new TypeError("duration must be a non-negative number.");if(!Number.isFinite(n))throw new TypeError("sequenceNumber must be a number.");if(!Number.isInteger(a)||a<0)throw new TypeError("byteLength must be a non-negative integer.");if(o!==void 0&&(typeof o!="object"||!o))throw new TypeError("sideData, when provided, must be an object.");if(o?.alpha!==void 0&&!(o.alpha instanceof Uint8Array))throw new TypeError("sideData.alpha, when provided, must be a Uint8Array.");if(o?.alphaByteLength!==void 0&&(!Number.isInteger(o.alphaByteLength)||o.alphaByteLength<0))throw new 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===s0}get microsecondTimestamp(){return Math.trunc(Pi*this.timestamp)}get microsecondDuration(){return Math.trunc(Pi*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw new TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");if(typeof EncodedAudioChunk>"u")throw new Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(e,t){if(!(e instanceof EncodedVideoChunk||e instanceof EncodedAudioChunk))throw new TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");const i=new Uint8Array(e.byteLength);return e.copyTo(i),new Oi(i,e.type,e.timestamp/1e6,(e.duration??0)/1e6,void 0,void 0,t)}clone(e){if(e!==void 0&&(typeof e!="object"||e===null))throw new TypeError("options, when provided, must be an object.");if(e?.timestamp!==void 0&&!Number.isFinite(e.timestamp))throw new TypeError("options.timestamp, when provided, must be a number.");if(e?.duration!==void 0&&!Number.isFinite(e.duration))throw new TypeError("options.duration, when provided, must be a number.");return new Oi(this.data,this.type,e?.timestamp??this.timestamp,e?.duration??this.duration,this.sequenceNumber,this.byteLength)}}/*!
230
232
  * Copyright (c) 2025-present, Vanilagy and contributors
231
233
  *
232
234
  * This Source Code Form is subject to the terms of the Mozilla Public
233
235
  * License, v. 2.0. If a copy of the MPL was not distributed with this
234
236
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
235
- */const zl=s=>{let i=s,r=4096,n=0,o=12,a=0;for(i<0&&(i=-i,n=128),i+=33,i>8191&&(i=8191);(i&r)!==r&&o>=5;)r>>=1,o--;return a=i>>o-4&15,~(n|o-5<<4|a)&255},Hl=s=>{let t=2048,i=0,r=11,n=0,o=s;for(o<0&&(o=-o,i=128),o>4095&&(o=4095);(o&t)!==t&&r>=5;)t>>=1,r--;return n=o>>(r===4?1:r-4)&15,(i|r-4<<4|n)^85};/*!
237
+ */const Xv=s=>{let i=s,r=4096,n=0,a=12,o=0;for(i<0&&(i=-i,n=128),i+=33,i>8191&&(i=8191);(i&r)!==r&&a>=5;)r>>=1,a--;return o=i>>a-4&15,~(n|a-5<<4|o)&255},Zv=s=>{let t=2048,i=0,r=11,n=0,a=s;for(a<0&&(a=-a,i=128),a>4095&&(a=4095);(a&t)!==t&&r>=5;)t>>=1,r--;return n=a>>(r===4?1:r-4)&15,(i|r-4<<4|n)^85};/*!
236
238
  * Copyright (c) 2025-present, Vanilagy and contributors
237
239
  *
238
240
  * This Source Code Form is subject to the terms of the Mozilla Public
239
241
  * License, v. 2.0. If a copy of the MPL was not distributed with this
240
242
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
241
- */ol();class vt{get displayWidth(){return this.rotation%180===0?this.codedWidth:this.codedHeight}get displayHeight(){return this.rotation%180===0?this.codedHeight:this.codedWidth}get microsecondTimestamp(){return Math.trunc(lt*this.timestamp)}get microsecondDuration(){return Math.trunc(lt*this.duration)}get hasAlpha(){return this.format&&this.format.includes("A")}constructor(e,t){if(this._closed=!1,e instanceof ArrayBuffer||ArrayBuffer.isView(e)){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(!("format"in t)||typeof t.format!="string")throw new TypeError("init.format must be a string.");if(!Number.isInteger(t.codedWidth)||t.codedWidth<=0)throw new TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(t.codedHeight)||t.codedHeight<=0)throw new TypeError("init.codedHeight must be a positive integer.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=ot(e).slice(),this.format=t.format,this.codedWidth=t.codedWidth,this.codedHeight=t.codedHeight,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new VideoColorSpace(t.colorSpace)}else if(typeof VideoFrame<"u"&&e instanceof VideoFrame){if(t?.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(t?.timestamp!==void 0&&!Number.isFinite(t?.timestamp))throw new TypeError("init.timestamp, when provided, must be a number.");if(t?.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=e,this.format=e.format,this.codedWidth=e.displayWidth,this.codedHeight=e.displayHeight,this.rotation=t?.rotation??0,this.timestamp=t?.timestamp??e.timestamp/1e6,this.duration=t?.duration??(e.duration??0)/1e6,this.colorSpace=e.colorSpace}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof SVGImageElement<"u"&&e instanceof SVGImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if(typeof VideoFrame<"u")return new vt(new VideoFrame(e,{timestamp:Math.trunc(t.timestamp*lt),duration:Math.trunc((t.duration??0)*lt)||void 0}),t);let i=0,r=0;if("naturalWidth"in e?(i=e.naturalWidth,r=e.naturalHeight):"videoWidth"in e?(i=e.videoWidth,r=e.videoHeight):"width"in e&&(i=Number(e.width),r=Number(e.height)),!i||!r)throw new TypeError("Could not determine dimensions.");const n=new OffscreenCanvas(i,r),o=n.getContext("2d",{alpha:ls(),willReadFrequently:!0});$(o),o.drawImage(e,0,0),this._data=n,this.format="RGBX",this.codedWidth=i,this.codedHeight=r,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new VideoColorSpace({matrix:"rgb",primaries:"bt709",transfer:"iec61966-2-1",fullRange:!0})}else throw new TypeError("Invalid data type: Must be a BufferSource or CanvasImageSource.")}clone(){if(this._closed)throw new Error("VideoSample is closed.");return $(this._data!==null),ei(this._data)?new vt(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation}):this._data instanceof Uint8Array?new vt(this._data.slice(),{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation}):new vt(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})}close(){this._closed||(ei(this._data)?this._data.close():this._data=null,this._closed=!0)}allocationSize(){if(this._closed)throw new Error("VideoSample is closed.");return $(this._data!==null),ei(this._data)?this._data.allocationSize():this._data instanceof Uint8Array?this._data.byteLength:this.codedWidth*this.codedHeight*4}async copyTo(e){if(!xi(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(this._closed)throw new Error("VideoSample is closed.");if($(this._data!==null),ei(this._data))await this._data.copyTo(e);else if(this._data instanceof Uint8Array)ot(e).set(this._data);else{const i=this._data.getContext("2d");$(i);const r=i.getImageData(0,0,this.codedWidth,this.codedHeight);ot(e).set(r.data)}}toVideoFrame(){if(this._closed)throw new Error("VideoSample is closed.");return $(this._data!==null),ei(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace}):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,i,r,n,o,a,p,m){let d=0,l=0,c=this.displayWidth,u=this.displayHeight,h=0,f=0,b=this.displayWidth,g=this.displayHeight;if(o!==void 0?(d=t,l=i,c=r,u=n,h=o,f=a,p!==void 0?(b=p,g=m):(b=c,g=u)):(h=t,f=i,r!==void 0&&(b=r,g=n)),!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!Number.isFinite(d))throw new TypeError("sx must be a number.");if(!Number.isFinite(l))throw new TypeError("sy must be a number.");if(!Number.isFinite(c)||c<0)throw new TypeError("sWidth must be a non-negative number.");if(!Number.isFinite(u)||u<0)throw new TypeError("sHeight must be a non-negative number.");if(!Number.isFinite(h))throw new TypeError("dx must be a number.");if(!Number.isFinite(f))throw new TypeError("dy must be a number.");if(!Number.isFinite(b)||b<0)throw new TypeError("dWidth must be a non-negative number.");if(!Number.isFinite(g)||g<0)throw new TypeError("dHeight must be a non-negative number.");if(this._closed)throw new Error("VideoSample is closed.");({sx:d,sy:l,sWidth:c,sHeight:u}=this._rotateSourceRegion(d,l,c,u,this.rotation));const y=this.toCanvasImageSource();e.save();const v=h+b/2,_=f+g/2;e.translate(v,_),e.rotate(this.rotation*Math.PI/180);const C=this.rotation%180===0?1:b/g;e.scale(1/C,C),e.drawImage(y,d,l,c,u,-b/2,-g/2,b,g),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!["fill","contain","cover"].includes(t.fit))throw new TypeError("options.fit must be 'fill', 'contain', or 'cover'.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");t.crop!==void 0&&Ul(t.crop,"options.");const i=e.canvas.width,r=e.canvas.height,n=t.rotation??this.rotation,[o,a]=n%180===0?[this.codedWidth,this.codedHeight]:[this.codedHeight,this.codedWidth];t.crop&&Nl(t.crop,o,a);let p,m,d,l;const{sx:c,sy:u,sWidth:h,sHeight:f}=this._rotateSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??o,t.crop?.height??a,n);if(t.fit==="fill")p=0,m=0,d=i,l=r;else{const[g,y]=t.crop?[t.crop.width,t.crop.height]:[o,a],v=t.fit==="contain"?Math.min(i/g,r/y):Math.max(i/g,r/y);d=g*v,l=y*v,p=(i-d)/2,m=(r-l)/2}const b=n%180===0?1:d/l;e.translate(i/2,r/2),e.rotate(n*Math.PI/180),e.scale(1/b,b),e.translate(-i/2,-r/2),e.drawImage(this.toCanvasImageSource(),c,u,h,f,p,m,d,l)}_rotateSourceRegion(e,t,i,r,n){return n===90?[e,t,i,r]=[t,this.codedHeight-e-i,r,i]:n===180?[e,t]=[this.codedWidth-e-i,this.codedHeight-t-r]:n===270&&([e,t,i,r]=[this.codedWidth-t-r,e,r,i]),{sx:e,sy:t,sWidth:i,sHeight:r}}toCanvasImageSource(){if(this._closed)throw new Error("VideoSample is closed.");if($(this._data!==null),this._data instanceof Uint8Array){const e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}else return this._data}setRotation(e){if(![0,90,180,270].includes(e))throw new TypeError("newRotation must be 0, 90, 180, or 270.");this.rotation=e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw new TypeError("newDuration must be a non-negative number.");this.duration=e}[Symbol.dispose](){this.close()}}const ei=s=>typeof VideoFrame<"u"&&s instanceof VideoFrame,Nl=(s,e,t)=>{s.left=Math.min(s.left,e),s.top=Math.min(s.top,t),s.width=Math.min(s.width,e-s.left),s.height=Math.min(s.height,t-s.top),$(s.width>=0),$(s.height>=0)},Ul=(s,e)=>{if(!s||typeof s!="object")throw new TypeError(e+"crop, when provided, must be an object.");if(!Number.isInteger(s.left)||s.left<0)throw new TypeError(e+"crop.left must be a non-negative integer.");if(!Number.isInteger(s.top)||s.top<0)throw new TypeError(e+"crop.top must be a non-negative integer.");if(!Number.isInteger(s.width)||s.width<0)throw new TypeError(e+"crop.width must be a non-negative integer.");if(!Number.isInteger(s.height)||s.height<0)throw new TypeError(e+"crop.height must be a non-negative integer.")},ds=new Set(["f32","f32-planar","s16","s16-planar","s32","s32-planar","u8","u8-planar"]);class wt{get microsecondTimestamp(){return Math.trunc(lt*this.timestamp)}get microsecondDuration(){return Math.trunc(lt*this.duration)}constructor(e){if(this._closed=!1,ii(e)){if(e.format===null)throw new TypeError("AudioData with null format is not supported.");this._data=e,this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=e.numberOfFrames,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp/1e6,this.duration=e.numberOfFrames/e.sampleRate}else{if(!e||typeof e!="object")throw new TypeError("Invalid AudioDataInit: must be an object.");if(!ds.has(e.format))throw new TypeError("Invalid AudioDataInit: invalid format.");if(!Number.isFinite(e.sampleRate)||e.sampleRate<=0)throw new TypeError("Invalid AudioDataInit: sampleRate must be > 0.");if(!Number.isInteger(e.numberOfChannels)||e.numberOfChannels===0)throw new TypeError("Invalid AudioDataInit: numberOfChannels must be an integer > 0.");if(!Number.isFinite(e?.timestamp))throw new TypeError("init.timestamp must be a number.");const t=e.data.byteLength/(ti(e.format)*e.numberOfChannels);if(!Number.isInteger(t))throw new TypeError("Invalid AudioDataInit: data size is not a multiple of frame size.");this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=t,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp,this.duration=t/e.sampleRate;let i;if(e.data instanceof ArrayBuffer)i=new Uint8Array(e.data);else if(ArrayBuffer.isView(e.data))i=new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength);else throw new TypeError("Invalid AudioDataInit: data is not a BufferSource.");const r=this.numberOfFrames*this.numberOfChannels*ti(this.format);if(i.byteLength<r)throw new TypeError("Invalid AudioDataInit: insufficient data size.");this._data=i}}allocationSize(e){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(e.planeIndex)||e.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(e.format!==void 0&&!ds.has(e.format))throw new TypeError("Invalid format.");if(e.frameOffset!==void 0&&(!Number.isInteger(e.frameOffset)||e.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(e.frameCount!==void 0&&(!Number.isInteger(e.frameCount)||e.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const t=e.format??this.format,i=e.frameOffset??0;if(i>=this.numberOfFrames)throw new RangeError("frameOffset out of range");const r=e.frameCount!==void 0?e.frameCount:this.numberOfFrames-i;if(r>this.numberOfFrames-i)throw new RangeError("frameCount out of range");const n=ti(t),o=ki(t);if(o&&e.planeIndex>=this.numberOfChannels)throw new RangeError("planeIndex out of range");if(!o&&e.planeIndex!==0)throw new RangeError("planeIndex out of range");return(o?r:r*this.numberOfChannels)*n}copyTo(e,t){if(!xi(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(t.planeIndex)||t.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(t.format!==void 0&&!ds.has(t.format))throw new TypeError("Invalid format.");if(t.frameOffset!==void 0&&(!Number.isInteger(t.frameOffset)||t.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(t.frameCount!==void 0&&(!Number.isInteger(t.frameCount)||t.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const{planeIndex:i,format:r,frameCount:n,frameOffset:o}=t,a=r??this.format;if(!a)throw new Error("Destination format not determined");const p=this.numberOfFrames,m=this.numberOfChannels,d=o??0;if(d>=p)throw new RangeError("frameOffset out of range");const l=n!==void 0?n:p-d;if(l>p-d)throw new RangeError("frameCount out of range");const c=ti(a),u=ki(a);if(u&&i>=m)throw new RangeError("planeIndex out of range");if(!u&&i!==0)throw new RangeError("planeIndex out of range");const f=(u?l:l*m)*c;if(e.byteLength<f)throw new RangeError("Destination buffer is too small");const b=Fr(e),g=Vl(a);if(ii(this._data))if(u)if(a==="f32-planar")this._data.copyTo(e,{planeIndex:i,frameOffset:d,frameCount:l,format:"f32-planar"});else{const y=new ArrayBuffer(l*4),v=new Float32Array(y);this._data.copyTo(v,{planeIndex:i,frameOffset:d,frameCount:l,format:"f32-planar"});const _=new DataView(y);for(let C=0;C<l;C++){const S=C*c,T=_.getFloat32(C*4,!0);g(b,S,T)}}else{const y=m,v=new Float32Array(l);for(let _=0;_<y;_++){this._data.copyTo(v,{planeIndex:_,frameOffset:d,frameCount:l,format:"f32-planar"});for(let C=0;C<l;C++){const T=(C*y+_)*c;g(b,T,v[C])}}}else{const y=this._data,v=new DataView(y.buffer,y.byteOffset,y.byteLength),_=this.format,C=jl(_),S=ti(_),T=ki(_);for(let w=0;w<l;w++)if(u){const x=w*c;let k;T?k=(i*p+(w+d))*S:k=((w+d)*m+i)*S;const E=C(v,k);g(b,x,E)}else for(let x=0;x<m;x++){const E=(w*m+x)*c;let P;T?P=(x*p+(w+d))*S:P=((w+d)*m+x)*S;const O=C(v,P);g(b,E,O)}}}clone(){if(this._closed)throw new Error("AudioSample is closed.");if(ii(this._data)){const e=new wt(this._data.clone());return e.setTimestamp(this.timestamp),e}else return new wt({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp,data:this._data})}close(){this._closed||(ii(this._data)?this._data.close():this._data=new Uint8Array(0),this._closed=!0)}toAudioData(){if(this._closed)throw new Error("AudioSample is closed.");if(ii(this._data)){if(this._data.timestamp===this.microsecondTimestamp)return this._data.clone();if(ki(this.format)){const e=this.allocationSize({planeIndex:0,format:this.format}),t=new ArrayBuffer(e*this.numberOfChannels);for(let i=0;i<this.numberOfChannels;i++)this.copyTo(new Uint8Array(t,i*e,e),{planeIndex:i,format:this.format});return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:t})}else{const e=new ArrayBuffer(this.allocationSize({planeIndex:0,format:this.format}));return this.copyTo(e,{planeIndex:0,format:this.format}),new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:e})}}else return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:this._data})}toAudioBuffer(){if(this._closed)throw new Error("AudioSample is closed.");const e=new AudioBuffer({numberOfChannels:this.numberOfChannels,length:this.numberOfFrames,sampleRate:this.sampleRate}),t=new Float32Array(this.allocationSize({planeIndex:0,format:"f32-planar"})/4);for(let i=0;i<this.numberOfChannels;i++)this.copyTo(t,{planeIndex:i,format:"f32-planar"}),e.copyToChannel(t,i);return e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}[Symbol.dispose](){this.close()}static*_fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const i=48e3*5,r=e.numberOfChannels,n=e.sampleRate,o=e.length,a=Math.floor(i/r);let p=0,m=o;for(;m>0;){const d=Math.min(a,m),l=new Float32Array(r*d);for(let c=0;c<r;c++)e.copyFromChannel(l.subarray(c*d,(c+1)*d),c,p);yield new wt({format:"f32-planar",sampleRate:n,numberOfFrames:d,numberOfChannels:r,timestamp:t+p/n,data:l}),p+=d,m-=d}}static fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const i=48e3*5,r=e.numberOfChannels,n=e.sampleRate,o=e.length,a=Math.floor(i/r);let p=0,m=o;const d=[];for(;m>0;){const l=Math.min(a,m),c=new Float32Array(r*l);for(let h=0;h<r;h++)e.copyFromChannel(c.subarray(h*l,(h+1)*l),h,p);const u=new wt({format:"f32-planar",sampleRate:n,numberOfFrames:l,numberOfChannels:r,timestamp:t+p/n,data:c});d.push(u),p+=l,m-=l}return d}}const ti=s=>{switch(s){case"u8":case"u8-planar":return 1;case"s16":case"s16-planar":return 2;case"s32":case"s32-planar":return 4;case"f32":case"f32-planar":return 4;default:throw new Error("Unknown AudioSampleFormat")}},ki=s=>{switch(s){case"u8-planar":case"s16-planar":case"s32-planar":case"f32-planar":return!0;default:return!1}},jl=s=>{switch(s){case"u8":case"u8-planar":return(e,t)=>(e.getUint8(t)-128)/128;case"s16":case"s16-planar":return(e,t)=>e.getInt16(t,!0)/32768;case"s32":case"s32-planar":return(e,t)=>e.getInt32(t,!0)/2147483648;case"f32":case"f32-planar":return(e,t)=>e.getFloat32(t,!0)}},Vl=s=>{switch(s){case"u8":case"u8-planar":return(e,t,i)=>e.setUint8(t,Se((i+1)*127.5,0,255));case"s16":case"s16-planar":return(e,t,i)=>e.setInt16(t,Se(Math.round(i*32767),-32768,32767),!0);case"s32":case"s32-planar":return(e,t,i)=>e.setInt32(t,Se(Math.round(i*2147483647),-2147483648,2147483647),!0);case"f32":case"f32-planar":return(e,t,i)=>e.setFloat32(t,i,!0)}},ii=s=>typeof AudioData<"u"&&s instanceof AudioData;/*!
243
+ */gv();class Yi{get displayWidth(){return this.rotation%180===0?this.codedWidth:this.codedHeight}get displayHeight(){return this.rotation%180===0?this.codedHeight:this.codedWidth}get microsecondTimestamp(){return Math.trunc(Pi*this.timestamp)}get microsecondDuration(){return Math.trunc(Pi*this.duration)}get hasAlpha(){return this.format&&this.format.includes("A")}constructor(e,t){if(this._closed=!1,e instanceof ArrayBuffer||ArrayBuffer.isView(e)){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(!("format"in t)||typeof t.format!="string")throw new TypeError("init.format must be a string.");if(!Number.isInteger(t.codedWidth)||t.codedWidth<=0)throw new TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(t.codedHeight)||t.codedHeight<=0)throw new TypeError("init.codedHeight must be a positive integer.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=Ii(e).slice(),this.format=t.format,this.codedWidth=t.codedWidth,this.codedHeight=t.codedHeight,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new VideoColorSpace(t.colorSpace)}else if(typeof VideoFrame<"u"&&e instanceof VideoFrame){if(t?.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(t?.timestamp!==void 0&&!Number.isFinite(t?.timestamp))throw new TypeError("init.timestamp, when provided, must be a number.");if(t?.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=e,this.format=e.format,this.codedWidth=e.displayWidth,this.codedHeight=e.displayHeight,this.rotation=t?.rotation??0,this.timestamp=t?.timestamp??e.timestamp/1e6,this.duration=t?.duration??(e.duration??0)/1e6,this.colorSpace=e.colorSpace}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof SVGImageElement<"u"&&e instanceof SVGImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if(typeof VideoFrame<"u")return new Yi(new VideoFrame(e,{timestamp:Math.trunc(t.timestamp*Pi),duration:Math.trunc((t.duration??0)*Pi)||void 0}),t);let i=0,r=0;if("naturalWidth"in e?(i=e.naturalWidth,r=e.naturalHeight):"videoWidth"in e?(i=e.videoWidth,r=e.videoHeight):"width"in e&&(i=Number(e.width),r=Number(e.height)),!i||!r)throw new TypeError("Could not determine dimensions.");const n=new OffscreenCanvas(i,r),a=n.getContext("2d",{alpha:to(),willReadFrequently:!0});q(a),a.drawImage(e,0,0),this._data=n,this.format="RGBX",this.codedWidth=i,this.codedHeight=r,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new VideoColorSpace({matrix:"rgb",primaries:"bt709",transfer:"iec61966-2-1",fullRange:!0})}else throw new TypeError("Invalid data type: Must be a BufferSource or CanvasImageSource.")}clone(){if(this._closed)throw new Error("VideoSample is closed.");return q(this._data!==null),ls(this._data)?new Yi(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation}):this._data instanceof Uint8Array?new Yi(this._data.slice(),{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation}):new Yi(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})}close(){this._closed||(ls(this._data)?this._data.close():this._data=null,this._closed=!0)}allocationSize(){if(this._closed)throw new Error("VideoSample is closed.");return q(this._data!==null),ls(this._data)?this._data.allocationSize():this._data instanceof Uint8Array?this._data.byteLength:this.codedWidth*this.codedHeight*4}async copyTo(e){if(!gn(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(this._closed)throw new Error("VideoSample is closed.");if(q(this._data!==null),ls(this._data))await this._data.copyTo(e);else if(this._data instanceof Uint8Array)Ii(e).set(this._data);else{const i=this._data.getContext("2d");q(i);const r=i.getImageData(0,0,this.codedWidth,this.codedHeight);Ii(e).set(r.data)}}toVideoFrame(){if(this._closed)throw new Error("VideoSample is closed.");return q(this._data!==null),ls(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace}):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,i,r,n,a,o,c,u){let h=0,l=0,d=this.displayWidth,f=this.displayHeight,p=0,m=0,b=this.displayWidth,g=this.displayHeight;if(a!==void 0?(h=t,l=i,d=r,f=n,p=a,m=o,c!==void 0?(b=c,g=u):(b=d,g=f)):(p=t,m=i,r!==void 0&&(b=r,g=n)),!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!Number.isFinite(h))throw new TypeError("sx must be a number.");if(!Number.isFinite(l))throw new TypeError("sy must be a number.");if(!Number.isFinite(d)||d<0)throw new TypeError("sWidth must be a non-negative number.");if(!Number.isFinite(f)||f<0)throw new TypeError("sHeight must be a non-negative number.");if(!Number.isFinite(p))throw new TypeError("dx must be a number.");if(!Number.isFinite(m))throw new TypeError("dy must be a number.");if(!Number.isFinite(b)||b<0)throw new TypeError("dWidth must be a non-negative number.");if(!Number.isFinite(g)||g<0)throw new TypeError("dHeight must be a non-negative number.");if(this._closed)throw new Error("VideoSample is closed.");({sx:h,sy:l,sWidth:d,sHeight:f}=this._rotateSourceRegion(h,l,d,f,this.rotation));const y=this.toCanvasImageSource();e.save();const v=p+b/2,k=m+g/2;e.translate(v,k),e.rotate(this.rotation*Math.PI/180);const C=this.rotation%180===0?1:b/g;e.scale(1/C,C),e.drawImage(y,h,l,d,f,-b/2,-g/2,b,g),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!["fill","contain","cover"].includes(t.fit))throw new TypeError("options.fit must be 'fill', 'contain', or 'cover'.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");t.crop!==void 0&&Yv(t.crop,"options.");const i=e.canvas.width,r=e.canvas.height,n=t.rotation??this.rotation,[a,o]=n%180===0?[this.codedWidth,this.codedHeight]:[this.codedHeight,this.codedWidth];t.crop&&Kv(t.crop,a,o);let c,u,h,l;const{sx:d,sy:f,sWidth:p,sHeight:m}=this._rotateSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??a,t.crop?.height??o,n);if(t.fit==="fill")c=0,u=0,h=i,l=r;else{const[g,y]=t.crop?[t.crop.width,t.crop.height]:[a,o],v=t.fit==="contain"?Math.min(i/g,r/y):Math.max(i/g,r/y);h=g*v,l=y*v,c=(i-h)/2,u=(r-l)/2}const b=n%180===0?1:h/l;e.translate(i/2,r/2),e.rotate(n*Math.PI/180),e.scale(1/b,b),e.translate(-i/2,-r/2),e.drawImage(this.toCanvasImageSource(),d,f,p,m,c,u,h,l)}_rotateSourceRegion(e,t,i,r,n){return n===90?[e,t,i,r]=[t,this.codedHeight-e-i,r,i]:n===180?[e,t]=[this.codedWidth-e-i,this.codedHeight-t-r]:n===270&&([e,t,i,r]=[this.codedWidth-t-r,e,r,i]),{sx:e,sy:t,sWidth:i,sHeight:r}}toCanvasImageSource(){if(this._closed)throw new Error("VideoSample is closed.");if(q(this._data!==null),this._data instanceof Uint8Array){const e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}else return this._data}setRotation(e){if(![0,90,180,270].includes(e))throw new TypeError("newRotation must be 0, 90, 180, or 270.");this.rotation=e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw new TypeError("newDuration must be a non-negative number.");this.duration=e}[Symbol.dispose](){this.close()}}const ls=s=>typeof VideoFrame<"u"&&s instanceof VideoFrame,Kv=(s,e,t)=>{s.left=Math.min(s.left,e),s.top=Math.min(s.top,t),s.width=Math.min(s.width,e-s.left),s.height=Math.min(s.height,t-s.top),q(s.width>=0),q(s.height>=0)},Yv=(s,e)=>{if(!s||typeof s!="object")throw new TypeError(e+"crop, when provided, must be an object.");if(!Number.isInteger(s.left)||s.left<0)throw new TypeError(e+"crop.left must be a non-negative integer.");if(!Number.isInteger(s.top)||s.top<0)throw new TypeError(e+"crop.top must be a non-negative integer.");if(!Number.isInteger(s.width)||s.width<0)throw new TypeError(e+"crop.width must be a non-negative integer.");if(!Number.isInteger(s.height)||s.height<0)throw new TypeError(e+"crop.height must be a non-negative integer.")},no=new Set(["f32","f32-planar","s16","s16-planar","s32","s32-planar","u8","u8-planar"]);class Ji{get microsecondTimestamp(){return Math.trunc(Pi*this.timestamp)}get microsecondDuration(){return Math.trunc(Pi*this.duration)}constructor(e){if(this._closed=!1,us(e)){if(e.format===null)throw new TypeError("AudioData with null format is not supported.");this._data=e,this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=e.numberOfFrames,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp/1e6,this.duration=e.numberOfFrames/e.sampleRate}else{if(!e||typeof e!="object")throw new TypeError("Invalid AudioDataInit: must be an object.");if(!no.has(e.format))throw new TypeError("Invalid AudioDataInit: invalid format.");if(!Number.isFinite(e.sampleRate)||e.sampleRate<=0)throw new TypeError("Invalid AudioDataInit: sampleRate must be > 0.");if(!Number.isInteger(e.numberOfChannels)||e.numberOfChannels===0)throw new TypeError("Invalid AudioDataInit: numberOfChannels must be an integer > 0.");if(!Number.isFinite(e?.timestamp))throw new TypeError("init.timestamp must be a number.");const t=e.data.byteLength/(cs(e.format)*e.numberOfChannels);if(!Number.isInteger(t))throw new TypeError("Invalid AudioDataInit: data size is not a multiple of frame size.");this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=t,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp,this.duration=t/e.sampleRate;let i;if(e.data instanceof ArrayBuffer)i=new Uint8Array(e.data);else if(ArrayBuffer.isView(e.data))i=new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength);else throw new TypeError("Invalid AudioDataInit: data is not a BufferSource.");const r=this.numberOfFrames*this.numberOfChannels*cs(this.format);if(i.byteLength<r)throw new TypeError("Invalid AudioDataInit: insufficient data size.");this._data=i}}allocationSize(e){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(e.planeIndex)||e.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(e.format!==void 0&&!no.has(e.format))throw new TypeError("Invalid format.");if(e.frameOffset!==void 0&&(!Number.isInteger(e.frameOffset)||e.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(e.frameCount!==void 0&&(!Number.isInteger(e.frameCount)||e.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const t=e.format??this.format,i=e.frameOffset??0;if(i>=this.numberOfFrames)throw new RangeError("frameOffset out of range");const r=e.frameCount!==void 0?e.frameCount:this.numberOfFrames-i;if(r>this.numberOfFrames-i)throw new RangeError("frameCount out of range");const n=cs(t),a=bn(t);if(a&&e.planeIndex>=this.numberOfChannels)throw new RangeError("planeIndex out of range");if(!a&&e.planeIndex!==0)throw new RangeError("planeIndex out of range");return(a?r:r*this.numberOfChannels)*n}copyTo(e,t){if(!gn(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(t.planeIndex)||t.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(t.format!==void 0&&!no.has(t.format))throw new TypeError("Invalid format.");if(t.frameOffset!==void 0&&(!Number.isInteger(t.frameOffset)||t.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(t.frameCount!==void 0&&(!Number.isInteger(t.frameCount)||t.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");const{planeIndex:i,format:r,frameCount:n,frameOffset:a}=t,o=r??this.format;if(!o)throw new Error("Destination format not determined");const c=this.numberOfFrames,u=this.numberOfChannels,h=a??0;if(h>=c)throw new RangeError("frameOffset out of range");const l=n!==void 0?n:c-h;if(l>c-h)throw new RangeError("frameCount out of range");const d=cs(o),f=bn(o);if(f&&i>=u)throw new RangeError("planeIndex out of range");if(!f&&i!==0)throw new RangeError("planeIndex out of range");const m=(f?l:l*u)*d;if(e.byteLength<m)throw new RangeError("Destination buffer is too small");const b=Hu(e),g=Qv(o);if(us(this._data))if(f)if(o==="f32-planar")this._data.copyTo(e,{planeIndex:i,frameOffset:h,frameCount:l,format:"f32-planar"});else{const y=new ArrayBuffer(l*4),v=new Float32Array(y);this._data.copyTo(v,{planeIndex:i,frameOffset:h,frameCount:l,format:"f32-planar"});const k=new DataView(y);for(let C=0;C<l;C++){const _=C*d,E=k.getFloat32(C*4,!0);g(b,_,E)}}else{const y=u,v=new Float32Array(l);for(let k=0;k<y;k++){this._data.copyTo(v,{planeIndex:k,frameOffset:h,frameCount:l,format:"f32-planar"});for(let C=0;C<l;C++){const E=(C*y+k)*d;g(b,E,v[C])}}}else{const y=this._data,v=new DataView(y.buffer,y.byteOffset,y.byteLength),k=this.format,C=Jv(k),_=cs(k),E=bn(k);for(let x=0;x<l;x++)if(f){const S=x*d;let T;E?T=(i*c+(x+h))*_:T=((x+h)*u+i)*_;const A=C(v,T);g(b,S,A)}else for(let S=0;S<u;S++){const A=(x*u+S)*d;let R;E?R=(S*c+(x+h))*_:R=((x+h)*u+S)*_;const M=C(v,R);g(b,A,M)}}}clone(){if(this._closed)throw new Error("AudioSample is closed.");if(us(this._data)){const e=new Ji(this._data.clone());return e.setTimestamp(this.timestamp),e}else return new Ji({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp,data:this._data})}close(){this._closed||(us(this._data)?this._data.close():this._data=new Uint8Array(0),this._closed=!0)}toAudioData(){if(this._closed)throw new Error("AudioSample is closed.");if(us(this._data)){if(this._data.timestamp===this.microsecondTimestamp)return this._data.clone();if(bn(this.format)){const e=this.allocationSize({planeIndex:0,format:this.format}),t=new ArrayBuffer(e*this.numberOfChannels);for(let i=0;i<this.numberOfChannels;i++)this.copyTo(new Uint8Array(t,i*e,e),{planeIndex:i,format:this.format});return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:t})}else{const e=new ArrayBuffer(this.allocationSize({planeIndex:0,format:this.format}));return this.copyTo(e,{planeIndex:0,format:this.format}),new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:e})}}else return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:this._data})}toAudioBuffer(){if(this._closed)throw new Error("AudioSample is closed.");const e=new AudioBuffer({numberOfChannels:this.numberOfChannels,length:this.numberOfFrames,sampleRate:this.sampleRate}),t=new Float32Array(this.allocationSize({planeIndex:0,format:"f32-planar"})/4);for(let i=0;i<this.numberOfChannels;i++)this.copyTo(t,{planeIndex:i,format:"f32-planar"}),e.copyToChannel(t,i);return e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}[Symbol.dispose](){this.close()}static*_fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const i=48e3*5,r=e.numberOfChannels,n=e.sampleRate,a=e.length,o=Math.floor(i/r);let c=0,u=a;for(;u>0;){const h=Math.min(o,u),l=new Float32Array(r*h);for(let d=0;d<r;d++)e.copyFromChannel(l.subarray(d*h,(d+1)*h),d,c);yield new Ji({format:"f32-planar",sampleRate:n,numberOfFrames:h,numberOfChannels:r,timestamp:t+c/n,data:l}),c+=h,u-=h}}static fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");const i=48e3*5,r=e.numberOfChannels,n=e.sampleRate,a=e.length,o=Math.floor(i/r);let c=0,u=a;const h=[];for(;u>0;){const l=Math.min(o,u),d=new Float32Array(r*l);for(let p=0;p<r;p++)e.copyFromChannel(d.subarray(p*l,(p+1)*l),p,c);const f=new Ji({format:"f32-planar",sampleRate:n,numberOfFrames:l,numberOfChannels:r,timestamp:t+c/n,data:d});h.push(f),c+=l,u-=l}return h}}const cs=s=>{switch(s){case"u8":case"u8-planar":return 1;case"s16":case"s16-planar":return 2;case"s32":case"s32-planar":return 4;case"f32":case"f32-planar":return 4;default:throw new Error("Unknown AudioSampleFormat")}},bn=s=>{switch(s){case"u8-planar":case"s16-planar":case"s32-planar":case"f32-planar":return!0;default:return!1}},Jv=s=>{switch(s){case"u8":case"u8-planar":return(e,t)=>(e.getUint8(t)-128)/128;case"s16":case"s16-planar":return(e,t)=>e.getInt16(t,!0)/32768;case"s32":case"s32-planar":return(e,t)=>e.getInt32(t,!0)/2147483648;case"f32":case"f32-planar":return(e,t)=>e.getFloat32(t,!0)}},Qv=s=>{switch(s){case"u8":case"u8-planar":return(e,t,i)=>e.setUint8(t,mt((i+1)*127.5,0,255));case"s16":case"s16-planar":return(e,t,i)=>e.setInt16(t,mt(Math.round(i*32767),-32768,32767),!0);case"s32":case"s32-planar":return(e,t,i)=>e.setInt32(t,mt(Math.round(i*2147483647),-2147483648,2147483647),!0);case"f32":case"f32-planar":return(e,t,i)=>e.setFloat32(t,i,!0)}},us=s=>typeof AudioData<"u"&&s instanceof AudioData;/*!
242
244
  * Copyright (c) 2025-present, Vanilagy and contributors
243
245
  *
244
246
  * This Source Code Form is subject to the terms of the Mozilla Public
245
247
  * License, v. 2.0. If a copy of the MPL was not distributed with this
246
248
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
247
- */const Wl=s=>{let t=(s.hasVideo?"video/":s.hasAudio?"audio/":"application/")+(s.isQuickTime?"quicktime":"mp4");if(s.codecStrings.length>0){const i=[...new Set(s.codecStrings)];t+=`; codecs="${i.join(", ")}"`}return t};/*!
249
+ */const e2=s=>{let t=(s.hasVideo?"video/":s.hasAudio?"audio/":"application/")+(s.isQuickTime?"quicktime":"mp4");if(s.codecStrings.length>0){const i=[...new Set(s.codecStrings)];t+=`; codecs="${i.join(", ")}"`}return t};/*!
248
250
  * Copyright (c) 2025-present, Vanilagy and contributors
249
251
  *
250
252
  * This Source Code Form is subject to the terms of the Mozilla Public
251
253
  * License, v. 2.0. If a copy of the MPL was not distributed with this
252
254
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
253
- */const fs=8,qr=16,Gl=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));/*!
255
+ */const ao=8,n0=16,oo=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));/*!
254
256
  * Copyright (c) 2025-present, Vanilagy and contributors
255
257
  *
256
258
  * This Source Code Form is subject to the terms of the Mozilla Public
257
259
  * License, v. 2.0. If a copy of the MPL was not distributed with this
258
260
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
259
- */const Xr=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,Zl=s=>{const e=Math.floor(s/36e5),t=Math.floor(s%(60*60*1e3)/(60*1e3)),i=Math.floor(s%(60*1e3)/1e3),r=s%1e3;return e.toString().padStart(2,"0")+":"+t.toString().padStart(2,"0")+":"+i.toString().padStart(2,"0")+"."+r.toString().padStart(3,"0")};/*!
261
+ */const a0=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,t2=s=>{const e=Math.floor(s/36e5),t=Math.floor(s%(60*60*1e3)/(60*1e3)),i=Math.floor(s%(60*1e3)/1e3),r=s%1e3;return e.toString().padStart(2,"0")+":"+t.toString().padStart(2,"0")+":"+i.toString().padStart(2,"0")+"."+r.toString().padStart(3,"0")};/*!
260
262
  * Copyright (c) 2025-present, Vanilagy and contributors
261
263
  *
262
264
  * This Source Code Form is subject to the terms of the Mozilla Public
263
265
  * License, v. 2.0. If a copy of the MPL was not distributed with this
264
266
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
265
- */class Yr{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{const t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(const n of e.children)n&&this.writeBox(n);const i=this.writer.getPos(),r=e.size??i-t;this.writer.seek(t),this.writeBoxHeader(e,r),this.writer.seek(i)}}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){const t=this.offsets.get(e);$(t!==void 0);const i=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(i)}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(const i of e.children)i&&(t+=this.measureBox(i));return t}}}const ne=new Uint8Array(8),je=new DataView(ne.buffer),me=s=>[(s%256+256)%256],G=s=>(je.setUint16(0,s,!1),[ne[0],ne[1]]),Qr=s=>(je.setInt16(0,s,!1),[ne[0],ne[1]]),Jr=s=>(je.setUint32(0,s,!1),[ne[1],ne[2],ne[3]]),B=s=>(je.setUint32(0,s,!1),[ne[0],ne[1],ne[2],ne[3]]),ht=s=>(je.setInt32(0,s,!1),[ne[0],ne[1],ne[2],ne[3]]),_t=s=>(je.setUint32(0,Math.floor(s/2**32),!1),je.setUint32(4,s,!1),[ne[0],ne[1],ne[2],ne[3],ne[4],ne[5],ne[6],ne[7]]),en=s=>(je.setInt16(0,2**8*s,!1),[ne[0],ne[1]]),Xe=s=>(je.setInt32(0,2**16*s,!1),[ne[0],ne[1],ne[2],ne[3]]),ps=s=>(je.setInt32(0,2**30*s,!1),[ne[0],ne[1],ne[2],ne[3]]),ms=(s,e)=>{const t=[];let i=s;do{let r=i&127;i>>=7,t.length>0&&(r|=128),t.push(r)}while(i>0||e);return t.reverse()},Te=(s,e=!1)=>{const t=Array(s.length).fill(null).map((i,r)=>s.charCodeAt(r));return e&&t.push(0),t},gs=s=>{let e=null;for(const t of s)(!e||t.timestamp>e.timestamp)&&(e=t);return e},tn=s=>{const e=s*(Math.PI/180),t=Math.round(Math.cos(e)),i=Math.round(Math.sin(e));return[t,i,0,-i,t,0,0,0,1]},sn=tn(0),rn=s=>[Xe(s[0]),Xe(s[1]),ps(s[2]),Xe(s[3]),Xe(s[4]),ps(s[5]),Xe(s[6]),Xe(s[7]),ps(s[8])],K=(s,e,t)=>({type:s,contents:e&&new Uint8Array(e.flat(10)),children:t}),le=(s,e,t,i,r)=>K(s,[me(e),Jr(t),i??[]],r),Kl=s=>s.isQuickTime?K("ftyp",[Te("qt "),B(512),Te("qt ")]):s.fragmented?K("ftyp",[Te("iso5"),B(512),Te("iso5"),Te("iso6"),Te("mp41")]):K("ftyp",[Te("isom"),B(512),Te("isom"),s.holdsAvc?Te("avc1"):[],Te("mp41")]),Ti=s=>({type:"mdat",largeSize:s}),ql=s=>({type:"free",size:s}),si=s=>K("moov",void 0,[Xl(s.creationTime,s.trackDatas),...s.trackDatas.map(e=>Yl(e,s.creationTime)),s.isFragmented?Ic(s.trackDatas):null,Uc(s)]),Xl=(s,e)=>{const t=xe(Math.max(0,...e.filter(o=>o.samples.length>0).map(o=>{const a=gs(o.samples);return a.timestamp+a.duration})),_s),i=Math.max(0,...e.map(o=>o.track.id))+1,r=!Ft(s)||!Ft(t),n=r?_t:B;return le("mvhd",+r,0,[n(s),n(s),B(_s),n(t),Xe(1),en(1),Array(10).fill(0),rn(sn),Array(24).fill(0),B(i)])},Yl=(s,e)=>{const t=Jc(s);return K("trak",void 0,[Ql(s,e),Jl(s,e),t.name!==void 0?K("udta",void 0,[K("name",[...He.encode(t.name)])]):null])},Ql=(s,e)=>{const t=gs(s.samples),i=xe(t?t.timestamp+t.duration:0,_s),r=!Ft(e)||!Ft(i),n=r?_t:B;let o;if(s.type==="video"){const a=s.track.metadata.rotation;o=tn(a??0)}else o=sn;return le("tkhd",+r,3,[n(e),n(e),B(s.track.id),B(0),n(i),Array(8).fill(0),G(0),G(s.track.id),en(s.type==="audio"?1:0),G(0),rn(o),Xe(s.type==="video"?s.info.width:0),Xe(s.type==="video"?s.info.height:0)])},Jl=(s,e)=>K("mdia",void 0,[ec(s,e),ys(!0,tc[s.type],ic[s.type]),sc(s)]),ec=(s,e)=>{const t=gs(s.samples),i=xe(t?t.timestamp+t.duration:0,s.timescale),r=!Ft(e)||!Ft(i),n=r?_t:B;return le("mdhd",+r,0,[n(e),n(e),B(s.timescale),n(i),G(un(s.track.metadata.languageCode??sl)),G(0)])},tc={video:"vide",audio:"soun",subtitle:"text"},ic={video:"MediabunnyVideoHandler",audio:"MediabunnySoundHandler",subtitle:"MediabunnyTextHandler"},ys=(s,e,t,i="\0\0\0\0")=>le("hdlr",0,0,[s?Te("mhlr"):B(0),Te(e),Te(i),B(0),B(0),Te(t,!0)]),sc=s=>K("minf",void 0,[rc[s.type](),nc(),lc(s)]),rc={video:()=>le("vmhd",0,1,[G(0),G(0),G(0),G(0)]),audio:()=>le("smhd",0,0,[G(0),G(0)]),subtitle:()=>le("nmhd",0,0)},nc=()=>K("dinf",void 0,[ac()]),ac=()=>le("dref",0,0,[B(1)],[oc()]),oc=()=>le("url ",0,1),lc=s=>{const e=s.compositionTimeOffsetTable.length>1||s.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return K("stbl",void 0,[cc(s),xc(s),e?Ec(s):null,e?Ac(s):null,kc(s),Tc(s),Sc(s),Cc(s)])},cc=s=>{let e;if(s.type==="video")e=hc(Gc[s.track.source._codec],s);else if(s.type==="audio"){const t=hn(s.track.source._codec,s.muxer.isQuickTime);$(t),e=mc(t,s)}else s.type==="subtitle"&&(e=wc(qc[s.track.source._codec],s));return $(e),le("stsd",0,0,[B(1)],[e])},hc=(s,e)=>K(s,[Array(6).fill(0),G(1),G(0),G(0),Array(12).fill(0),G(e.info.width),G(e.info.height),B(4718592),B(4718592),B(0),G(1),Array(32).fill(0),G(24),Qr(65535)],[Zc[e.track.source._codec](e),el(e.info.decoderConfig.colorSpace)?uc(e):null]),uc=s=>K("colr",[Te("nclx"),G(vi[s.info.decoderConfig.colorSpace.primaries]),G(wi[s.info.decoderConfig.colorSpace.transfer]),G(_i[s.info.decoderConfig.colorSpace.matrix]),me((s.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),dc=s=>s.info.decoderConfig&&K("avcC",[...ot(s.info.decoderConfig.description)]),fc=s=>s.info.decoderConfig&&K("hvcC",[...ot(s.info.decoderConfig.description)]),nn=s=>{if(!s.info.decoderConfig)return null;const e=s.info.decoderConfig,t=e.codec.split("."),i=Number(t[1]),r=Number(t[2]),n=Number(t[3]),o=t[4]?Number(t[4]):1,a=t[8]?Number(t[8]):Number(e.colorSpace?.fullRange??0),p=(n<<4)+(o<<1)+a,m=t[5]?Number(t[5]):e.colorSpace?.primaries?vi[e.colorSpace.primaries]:2,d=t[6]?Number(t[6]):e.colorSpace?.transfer?wi[e.colorSpace.transfer]:2,l=t[7]?Number(t[7]):e.colorSpace?.matrix?_i[e.colorSpace.matrix]:2;return le("vpcC",1,0,[me(i),me(r),me(p),me(m),me(d),me(l),G(0)])},pc=s=>K("av1C",ul(s.info.decoderConfig.codec)),mc=(s,e)=>{let t=0,i,r=16;if(Ne.includes(e.track.source._codec)){const n=e.track.source._codec,{sampleSize:o}=Lt(n);r=8*o,r>16&&(t=1)}return t===0?i=[Array(6).fill(0),G(1),G(t),G(0),B(0),G(e.info.numberOfChannels),G(r),G(0),G(0),G(e.info.sampleRate<2**16?e.info.sampleRate:0),G(0)]:i=[Array(6).fill(0),G(1),G(t),G(0),B(0),G(e.info.numberOfChannels),G(Math.min(r,16)),G(0),G(0),G(e.info.sampleRate<2**16?e.info.sampleRate:0),G(0),B(1),B(r/8),B(e.info.numberOfChannels*r/8),B(2)],K(s,i,[Kc(e.track.source._codec,e.muxer.isQuickTime)?.(e)??null])},bs=s=>{let e;switch(s.track.source._codec){case"aac":e=64;break;case"mp3":e=107;break;case"vorbis":e=221;break;default:throw new Error(`Unhandled audio codec: ${s.track.source._codec}`)}let t=[...me(e),...me(21),...Jr(0),...B(0),...B(0)];if(s.info.decoderConfig.description){const i=ot(s.info.decoderConfig.description);t=[...t,...me(5),...ms(i.byteLength),...i]}return t=[...G(1),...me(0),...me(4),...ms(t.length),...t,...me(6),...me(1),...me(2)],t=[...me(3),...ms(t.length),...t],le("esds",0,0,t)},ut=s=>K("wave",void 0,[gc(s),yc(s),K("\0\0\0\0")]),gc=s=>K("frma",[Te(hn(s.track.source._codec,s.muxer.isQuickTime))]),yc=s=>{const{littleEndian:e}=Lt(s.track.source._codec);return K("enda",[G(+e)])},bc=s=>{let e=s.info.numberOfChannels,t=3840,i=s.info.sampleRate,r=0,n=0,o=new Uint8Array(0);const a=s.info.decoderConfig?.description;if(a){$(a.byteLength>=18);const p=ot(a),m=Bl(p);e=m.outputChannelCount,t=m.preSkip,i=m.inputSampleRate,r=m.outputGain,n=m.channelMappingFamily,m.channelMappingTable&&(o=m.channelMappingTable)}return K("dOps",[me(0),me(e),G(t),B(i),Qr(r),me(n),...o])},vc=s=>{const e=s.info.decoderConfig?.description;$(e);const t=ot(e);return le("dfLa",0,0,[...t.subarray(4)])},Ve=s=>{const{littleEndian:e,sampleSize:t}=Lt(s.track.source._codec),i=+e;return le("pcmC",0,0,[me(i),me(8*t)])},wc=(s,e)=>K(s,[Array(6).fill(0),G(1)],[Xc[e.track.source._codec](e)]),_c=s=>K("vttC",[...He.encode(s.info.config.description)]),xc=s=>le("stts",0,0,[B(s.timeToSampleTable.length),s.timeToSampleTable.map(e=>[B(e.sampleCount),B(e.sampleDelta)])]),Cc=s=>{if(s.samples.every(t=>t.type==="key"))return null;const e=[...s.samples.entries()].filter(([,t])=>t.type==="key");return le("stss",0,0,[B(e.length),e.map(([t])=>B(t+1))])},kc=s=>le("stsc",0,0,[B(s.compactlyCodedChunkTable.length),s.compactlyCodedChunkTable.map(e=>[B(e.firstChunk),B(e.samplesPerChunk),B(1)])]),Tc=s=>{if(s.type==="audio"&&s.info.requiresPcmTransformation){const{sampleSize:e}=Lt(s.track.source._codec);return le("stsz",0,0,[B(e*s.info.numberOfChannels),B(s.samples.reduce((t,i)=>t+xe(i.duration,s.timescale),0))])}return le("stsz",0,0,[B(0),B(s.samples.length),s.samples.map(e=>B(e.size))])},Sc=s=>s.finalizedChunks.length>0&&ze(s.finalizedChunks).offset>=2**32?le("co64",0,0,[B(s.finalizedChunks.length),s.finalizedChunks.map(e=>_t(e.offset))]):le("stco",0,0,[B(s.finalizedChunks.length),s.finalizedChunks.map(e=>B(e.offset))]),Ec=s=>le("ctts",1,0,[B(s.compositionTimeOffsetTable.length),s.compositionTimeOffsetTable.map(e=>[B(e.sampleCount),ht(e.sampleCompositionTimeOffset)])]),Ac=s=>{let e=1/0,t=-1/0,i=1/0,r=-1/0;$(s.compositionTimeOffsetTable.length>0),$(s.samples.length>0);for(let o=0;o<s.compositionTimeOffsetTable.length;o++){const a=s.compositionTimeOffsetTable[o];e=Math.min(e,a.sampleCompositionTimeOffset),t=Math.max(t,a.sampleCompositionTimeOffset)}for(let o=0;o<s.samples.length;o++){const a=s.samples[o];i=Math.min(i,xe(a.timestamp,s.timescale)),r=Math.max(r,xe(a.timestamp+a.duration,s.timescale))}const n=Math.max(-e,0);return r>=2**31?null:le("cslg",0,0,[ht(n),ht(e),ht(t),ht(i),ht(r)])},Ic=s=>K("mvex",void 0,s.map(Pc)),Pc=s=>le("trex",0,0,[B(s.track.id),B(1),B(0),B(0),B(0)]),an=(s,e)=>K("moof",void 0,[Rc(s),...e.map(Oc)]),Rc=s=>le("mfhd",0,0,[B(s)]),on=s=>{let e=0,t=0;const i=0,r=0,n=s.type==="delta";return t|=+n,n?e|=1:e|=2,e<<24|t<<16|i<<8|r},Oc=s=>K("traf",void 0,[Fc(s),Mc(s),Lc(s)]),Fc=s=>{$(s.currentChunk);let e=0;e|=8,e|=16,e|=32,e|=131072;const t=s.currentChunk.samples[1]??s.currentChunk.samples[0],i={duration:t.timescaleUnitsToNextSample,size:t.size,flags:on(t)};return le("tfhd",0,e,[B(s.track.id),B(i.duration),B(i.size),B(i.flags)])},Mc=s=>($(s.currentChunk),le("tfdt",1,0,[_t(xe(s.currentChunk.startTimestamp,s.timescale))])),Lc=s=>{$(s.currentChunk);const e=s.currentChunk.samples.map(f=>f.timescaleUnitsToNextSample),t=s.currentChunk.samples.map(f=>f.size),i=s.currentChunk.samples.map(on),r=s.currentChunk.samples.map(f=>xe(f.timestamp-f.decodeTimestamp,s.timescale)),n=new Set(e),o=new Set(t),a=new Set(i),p=new Set(r),m=a.size===2&&i[0]!==i[1],d=n.size>1,l=o.size>1,c=!m&&a.size>1,u=p.size>1||[...p].some(f=>f!==0);let h=0;return h|=1,h|=4*+m,h|=256*+d,h|=512*+l,h|=1024*+c,h|=2048*+u,le("trun",1,h,[B(s.currentChunk.samples.length),B(s.currentChunk.offset-s.currentChunk.moofOffset||0),m?B(i[0]):[],s.currentChunk.samples.map((f,b)=>[d?B(e[b]):[],l?B(t[b]):[],c?B(i[b]):[],u?ht(r[b]):[]])])},Bc=s=>K("mfra",void 0,[...s.map($c),Dc()]),$c=(s,e)=>le("tfra",1,0,[B(s.track.id),B(63),B(s.finalizedChunks.length),s.finalizedChunks.map(i=>[_t(xe(i.samples[0].timestamp,s.timescale)),_t(i.moofOffset),B(e+1),B(1),B(1)])]),Dc=()=>le("mfro",0,0,[B(0)]),zc=()=>K("vtte"),Hc=(s,e,t,i,r)=>K("vttc",void 0,[r!==null?K("vsid",[ht(r)]):null,t!==null?K("iden",[...He.encode(t)]):null,e!==null?K("ctim",[...He.encode(Zl(e))]):null,i!==null?K("sttg",[...He.encode(i)]):null,K("payl",[...He.encode(s)])]),Nc=s=>K("vtta",[...He.encode(s)]),Uc=s=>{const e=[],t=s.format._options.metadataFormat??"auto",i=s.output._metadataTags;if(t==="mdir"||t==="auto"&&!s.isQuickTime){const r=Vc(i);r&&e.push(r)}else if(t==="mdta"){const r=Wc(i);r&&e.push(r)}else(t==="udta"||t==="auto"&&s.isQuickTime)&&jc(e,s.output._metadataTags);return e.length===0?null:K("udta",void 0,e)},jc=(s,e)=>{for(const{key:t,value:i}of $r(e))switch(t){case"title":s.push(We("©nam",i));break;case"description":s.push(We("©des",i));break;case"artist":s.push(We("©ART",i));break;case"album":s.push(We("©alb",i));break;case"albumArtist":s.push(We("albr",i));break;case"genre":s.push(We("©gen",i));break;case"date":s.push(We("©day",i.toISOString().slice(0,10)));break;case"comment":s.push(We("©cmt",i));break;case"lyrics":s.push(We("©lyr",i));break;case"raw":break;case"discNumber":case"discsTotal":case"trackNumber":case"tracksTotal":case"images":break;default:as(t)}if(e.raw)for(const t in e.raw){const i=e.raw[t];i==null||t.length!==4||s.some(r=>r.type===t)||(typeof i=="string"?s.push(We(t,i)):i instanceof Uint8Array&&s.push(K(t,Array.from(i))))}},We=(s,e)=>{const t=He.encode(e);return K(s,[G(t.length),G(un("und")),Array.from(t)])},ln={"image/jpeg":13,"image/png":14,"image/bmp":27},cn=(s,e)=>{const t=[];for(const{key:i,value:r}of $r(s))switch(i){case"title":t.push({key:e?"title":"©nam",value:Me(r)});break;case"description":t.push({key:e?"description":"©des",value:Me(r)});break;case"artist":t.push({key:e?"artist":"©ART",value:Me(r)});break;case"album":t.push({key:e?"album":"©alb",value:Me(r)});break;case"albumArtist":t.push({key:e?"album_artist":"aART",value:Me(r)});break;case"comment":t.push({key:e?"comment":"©cmt",value:Me(r)});break;case"genre":t.push({key:e?"genre":"©gen",value:Me(r)});break;case"lyrics":t.push({key:e?"lyrics":"©lyr",value:Me(r)});break;case"date":t.push({key:e?"date":"©day",value:Me(r.toISOString().slice(0,10))});break;case"images":for(const n of r)n.kind==="coverFront"&&t.push({key:"covr",value:K("data",[B(ln[n.mimeType]??0),B(0),Array.from(n.data)])});break;case"trackNumber":if(e){const n=s.tracksTotal!==void 0?`${r}/${s.tracksTotal}`:r.toString();t.push({key:"track",value:Me(n)})}else t.push({key:"trkn",value:K("data",[B(0),B(0),G(0),G(r),G(s.tracksTotal??0),G(0)])});break;case"discNumber":e||t.push({key:"disc",value:K("data",[B(0),B(0),G(0),G(r),G(s.discsTotal??0),G(0)])});break;case"tracksTotal":case"discsTotal":break;case"raw":break;default:as(i)}if(s.raw)for(const i in s.raw){const r=s.raw[i];r==null||!e&&i.length!==4||t.some(n=>n.key===i)||(typeof r=="string"?t.push({key:i,value:Me(r)}):r instanceof Uint8Array?t.push({key:i,value:K("data",[B(0),B(0),Array.from(r)])}):r instanceof Dr&&t.push({key:i,value:K("data",[B(ln[r.mimeType]??0),B(0),Array.from(r.data)])}))}return t},Vc=s=>{const e=cn(s,!1);return e.length===0?null:le("meta",0,0,void 0,[ys(!1,"mdir","","appl"),K("ilst",void 0,e.map(t=>K(t.key,void 0,[t.value])))])},Wc=s=>{const e=cn(s,!0);return e.length===0?null:K("meta",void 0,[ys(!1,"mdta",""),le("keys",0,0,[B(e.length)],e.map(t=>K("mdta",[...He.encode(t.key)]))),K("ilst",void 0,e.map((t,i)=>{const r=String.fromCharCode(...B(i+1));return K(r,void 0,[t.value])}))])},Me=s=>K("data",[B(1),B(0),...He.encode(s)]),Gc={avc:"avc1",hevc:"hvc1",vp8:"vp08",vp9:"vp09",av1:"av01"},Zc={avc:dc,hevc:fc,vp8:nn,vp9:nn,av1:pc},hn=(s,e)=>{switch(s){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"}if(e)switch(s){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(s){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"}},Kc=(s,e)=>{switch(s){case"aac":return bs;case"mp3":return bs;case"opus":return bc;case"vorbis":return bs;case"flac":return vc}if(e)switch(s){case"pcm-s24":return ut;case"pcm-s24be":return ut;case"pcm-s32":return ut;case"pcm-s32be":return ut;case"pcm-f32":return ut;case"pcm-f32be":return ut;case"pcm-f64":return ut;case"pcm-f64be":return ut}else switch(s){case"pcm-s16":return Ve;case"pcm-s16be":return Ve;case"pcm-s24":return Ve;case"pcm-s24be":return Ve;case"pcm-s32":return Ve;case"pcm-s32be":return Ve;case"pcm-f32":return Ve;case"pcm-f32be":return Ve;case"pcm-f64":return Ve;case"pcm-f64be":return Ve}return null},qc={webvtt:"wvtt"},Xc={webvtt:_c},un=s=>{$(s.length===3);let e=0;for(let t=0;t<3;t++)e<<=5,e+=s.charCodeAt(t)-96;return e};/*!
267
+ */class o0{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{const t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(const n of e.children)n&&this.writeBox(n);const i=this.writer.getPos(),r=e.size??i-t;this.writer.seek(t),this.writeBoxHeader(e,r),this.writer.seek(i)}}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){const t=this.offsets.get(e);q(t!==void 0);const i=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(i)}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(const i of e.children)i&&(t+=this.measureBox(i));return t}}}const Ae=new Uint8Array(8),Kt=new DataView(Ae.buffer),je=s=>[(s%256+256)%256],le=s=>(Kt.setUint16(0,s,!1),[Ae[0],Ae[1]]),l0=s=>(Kt.setInt16(0,s,!1),[Ae[0],Ae[1]]),c0=s=>(Kt.setUint32(0,s,!1),[Ae[1],Ae[2],Ae[3]]),U=s=>(Kt.setUint32(0,s,!1),[Ae[0],Ae[1],Ae[2],Ae[3]]),Fi=s=>(Kt.setInt32(0,s,!1),[Ae[0],Ae[1],Ae[2],Ae[3]]),Qi=s=>(Kt.setUint32(0,Math.floor(s/2**32),!1),Kt.setUint32(4,s,!1),[Ae[0],Ae[1],Ae[2],Ae[3],Ae[4],Ae[5],Ae[6],Ae[7]]),u0=s=>(Kt.setInt16(0,2**8*s,!1),[Ae[0],Ae[1]]),ai=s=>(Kt.setInt32(0,2**16*s,!1),[Ae[0],Ae[1],Ae[2],Ae[3]]),lo=s=>(Kt.setInt32(0,2**30*s,!1),[Ae[0],Ae[1],Ae[2],Ae[3]]),co=(s,e)=>{const t=[];let i=s;do{let r=i&127;i>>=7,t.length>0&&(r|=128),t.push(r)}while(i>0||e);return t.reverse()},ct=(s,e=!1)=>{const t=Array(s.length).fill(null).map((i,r)=>s.charCodeAt(r));return e&&t.push(0),t},uo=s=>{let e=null;for(const t of s)(!e||t.timestamp>e.timestamp)&&(e=t);return e},h0=s=>{const e=s*(Math.PI/180),t=Math.round(Math.cos(e)),i=Math.round(Math.sin(e));return[t,i,0,-i,t,0,0,0,1]},d0=h0(0),f0=s=>[ai(s[0]),ai(s[1]),lo(s[2]),ai(s[3]),ai(s[4]),lo(s[5]),ai(s[6]),ai(s[7]),lo(s[8])],fe=(s,e,t)=>({type:s,contents:e&&new Uint8Array(e.flat(10)),children:t}),Oe=(s,e,t,i,r)=>fe(s,[je(e),c0(t),i??[]],r),i2=s=>s.isQuickTime?fe("ftyp",[ct("qt "),U(512),ct("qt ")]):s.fragmented?fe("ftyp",[ct("iso5"),U(512),ct("iso5"),ct("iso6"),ct("mp41")]):fe("ftyp",[ct("isom"),U(512),ct("isom"),s.holdsAvc?ct("avc1"):[],ct("mp41")]),vn=s=>({type:"mdat",largeSize:s}),r2=s=>({type:"free",size:s}),hs=s=>fe("moov",void 0,[s2(s.creationTime,s.trackDatas),...s.trackDatas.map(e=>n2(e,s.creationTime)),s.isFragmented?L2(s.trackDatas):null,K2(s)]),s2=(s,e)=>{const t=Qe(Math.max(0,...e.filter(a=>a.samples.length>0).map(a=>{const o=uo(a.samples);return o.timestamp+o.duration})),go),i=Math.max(0,...e.map(a=>a.track.id))+1,r=!xr(s)||!xr(t),n=r?Qi:U;return Oe("mvhd",+r,0,[n(s),n(s),U(go),n(t),ai(1),u0(1),Array(10).fill(0),f0(d0),Array(24).fill(0),U(i)])},n2=(s,e)=>{const t=ow(s);return fe("trak",void 0,[a2(s,e),o2(s,e),t.name!==void 0?fe("udta",void 0,[fe("name",[...qt.encode(t.name)])]):null])},a2=(s,e)=>{const t=uo(s.samples),i=Qe(t?t.timestamp+t.duration:0,go),r=!xr(e)||!xr(i),n=r?Qi:U;let a;if(s.type==="video"){const o=s.track.metadata.rotation;a=h0(o??0)}else a=d0;return Oe("tkhd",+r,3,[n(e),n(e),U(s.track.id),U(0),n(i),Array(8).fill(0),le(0),le(s.track.id),u0(s.type==="audio"?1:0),le(0),f0(a),ai(s.type==="video"?s.info.width:0),ai(s.type==="video"?s.info.height:0)])},o2=(s,e)=>fe("mdia",void 0,[l2(s,e),ho(!0,c2[s.type],u2[s.type]),h2(s)]),l2=(s,e)=>{const t=uo(s.samples),i=Qe(t?t.timestamp+t.duration:0,s.timescale),r=!xr(e)||!xr(i),n=r?Qi:U;return Oe("mdhd",+r,0,[n(e),n(e),U(s.timescale),n(i),le(w0(s.track.metadata.languageCode??dv)),le(0)])},c2={video:"vide",audio:"soun",subtitle:"text"},u2={video:"MediabunnyVideoHandler",audio:"MediabunnySoundHandler",subtitle:"MediabunnyTextHandler"},ho=(s,e,t,i="\0\0\0\0")=>Oe("hdlr",0,0,[s?ct("mhlr"):U(0),ct(e),ct(i),U(0),U(0),ct(t,!0)]),h2=s=>fe("minf",void 0,[d2[s.type](),f2(),g2(s)]),d2={video:()=>Oe("vmhd",0,1,[le(0),le(0),le(0),le(0)]),audio:()=>Oe("smhd",0,0,[le(0),le(0)]),subtitle:()=>Oe("nmhd",0,0)},f2=()=>fe("dinf",void 0,[p2()]),p2=()=>Oe("dref",0,0,[U(1)],[m2()]),m2=()=>Oe("url ",0,1),g2=s=>{const e=s.compositionTimeOffsetTable.length>1||s.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return fe("stbl",void 0,[y2(s),P2(s),e?D2(s):null,e?B2(s):null,F2(s),R2(s),M2(s),O2(s)])},y2=s=>{let e;if(s.type==="video")e=b2(ew[s.track.source._codec],s);else if(s.type==="audio"){const t=v0(s.track.source._codec,s.muxer.isQuickTime);q(t),e=k2(t,s)}else s.type==="subtitle"&&(e=A2(rw[s.track.source._codec],s));return q(e),Oe("stsd",0,0,[U(1)],[e])},b2=(s,e)=>fe(s,[Array(6).fill(0),le(1),le(0),le(0),Array(12).fill(0),le(e.info.width),le(e.info.height),U(4718592),U(4718592),U(0),le(1),Array(32).fill(0),le(24),l0(65535)],[tw[e.track.source._codec](e),cv(e.info.decoderConfig.colorSpace)?v2(e):null]),v2=s=>fe("colr",[ct("nclx"),le(fn[s.info.decoderConfig.colorSpace.primaries]),le(pn[s.info.decoderConfig.colorSpace.transfer]),le(mn[s.info.decoderConfig.colorSpace.matrix]),je((s.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),w2=s=>s.info.decoderConfig&&fe("avcC",[...Ii(s.info.decoderConfig.description)]),x2=s=>s.info.decoderConfig&&fe("hvcC",[...Ii(s.info.decoderConfig.description)]),p0=s=>{if(!s.info.decoderConfig)return null;const e=s.info.decoderConfig,t=e.codec.split("."),i=Number(t[1]),r=Number(t[2]),n=Number(t[3]),a=t[4]?Number(t[4]):1,o=t[8]?Number(t[8]):Number(e.colorSpace?.fullRange??0),c=(n<<4)+(a<<1)+o,u=t[5]?Number(t[5]):e.colorSpace?.primaries?fn[e.colorSpace.primaries]:2,h=t[6]?Number(t[6]):e.colorSpace?.transfer?pn[e.colorSpace.transfer]:2,l=t[7]?Number(t[7]):e.colorSpace?.matrix?mn[e.colorSpace.matrix]:2;return Oe("vpcC",1,0,[je(i),je(r),je(c),je(u),je(h),je(l),le(0)])},C2=s=>fe("av1C",wv(s.info.decoderConfig.codec)),k2=(s,e)=>{let t=0,i,r=16;if(Xt.includes(e.track.source._codec)){const n=e.track.source._codec,{sampleSize:a}=kr(n);r=8*a,r>16&&(t=1)}return t===0?i=[Array(6).fill(0),le(1),le(t),le(0),U(0),le(e.info.numberOfChannels),le(r),le(0),le(0),le(e.info.sampleRate<2**16?e.info.sampleRate:0),le(0)]:i=[Array(6).fill(0),le(1),le(t),le(0),U(0),le(e.info.numberOfChannels),le(Math.min(r,16)),le(0),le(0),le(e.info.sampleRate<2**16?e.info.sampleRate:0),le(0),U(1),U(r/8),U(e.info.numberOfChannels*r/8),U(2)],fe(s,i,[iw(e.track.source._codec,e.muxer.isQuickTime)?.(e)??null])},fo=s=>{let e;switch(s.track.source._codec){case"aac":e=64;break;case"mp3":e=107;break;case"vorbis":e=221;break;default:throw new Error(`Unhandled audio codec: ${s.track.source._codec}`)}let t=[...je(e),...je(21),...c0(0),...U(0),...U(0)];if(s.info.decoderConfig.description){const i=Ii(s.info.decoderConfig.description);t=[...t,...je(5),...co(i.byteLength),...i]}return t=[...le(1),...je(0),...je(4),...co(t.length),...t,...je(6),...je(1),...je(2)],t=[...je(3),...co(t.length),...t],Oe("esds",0,0,t)},Ri=s=>fe("wave",void 0,[S2(s),T2(s),fe("\0\0\0\0")]),S2=s=>fe("frma",[ct(v0(s.track.source._codec,s.muxer.isQuickTime))]),T2=s=>{const{littleEndian:e}=kr(s.track.source._codec);return fe("enda",[le(+e)])},E2=s=>{let e=s.info.numberOfChannels,t=3840,i=s.info.sampleRate,r=0,n=0,a=new Uint8Array(0);const o=s.info.decoderConfig?.description;if(o){q(o.byteLength>=18);const c=Ii(o),u=Wv(c);e=u.outputChannelCount,t=u.preSkip,i=u.inputSampleRate,r=u.outputGain,n=u.channelMappingFamily,u.channelMappingTable&&(a=u.channelMappingTable)}return fe("dOps",[je(0),je(e),le(t),U(i),l0(r),je(n),...a])},_2=s=>{const e=s.info.decoderConfig?.description;q(e);const t=Ii(e);return Oe("dfLa",0,0,[...t.subarray(4)])},Yt=s=>{const{littleEndian:e,sampleSize:t}=kr(s.track.source._codec),i=+e;return Oe("pcmC",0,0,[je(i),je(8*t)])},A2=(s,e)=>fe(s,[Array(6).fill(0),le(1)],[sw[e.track.source._codec](e)]),I2=s=>fe("vttC",[...qt.encode(s.info.config.description)]),P2=s=>Oe("stts",0,0,[U(s.timeToSampleTable.length),s.timeToSampleTable.map(e=>[U(e.sampleCount),U(e.sampleDelta)])]),O2=s=>{if(s.samples.every(t=>t.type==="key"))return null;const e=[...s.samples.entries()].filter(([,t])=>t.type==="key");return Oe("stss",0,0,[U(e.length),e.map(([t])=>U(t+1))])},F2=s=>Oe("stsc",0,0,[U(s.compactlyCodedChunkTable.length),s.compactlyCodedChunkTable.map(e=>[U(e.firstChunk),U(e.samplesPerChunk),U(1)])]),R2=s=>{if(s.type==="audio"&&s.info.requiresPcmTransformation){const{sampleSize:e}=kr(s.track.source._codec);return Oe("stsz",0,0,[U(e*s.info.numberOfChannels),U(s.samples.reduce((t,i)=>t+Qe(i.duration,s.timescale),0))])}return Oe("stsz",0,0,[U(0),U(s.samples.length),s.samples.map(e=>U(e.size))])},M2=s=>s.finalizedChunks.length>0&&Gt(s.finalizedChunks).offset>=2**32?Oe("co64",0,0,[U(s.finalizedChunks.length),s.finalizedChunks.map(e=>Qi(e.offset))]):Oe("stco",0,0,[U(s.finalizedChunks.length),s.finalizedChunks.map(e=>U(e.offset))]),D2=s=>Oe("ctts",1,0,[U(s.compositionTimeOffsetTable.length),s.compositionTimeOffsetTable.map(e=>[U(e.sampleCount),Fi(e.sampleCompositionTimeOffset)])]),B2=s=>{let e=1/0,t=-1/0,i=1/0,r=-1/0;q(s.compositionTimeOffsetTable.length>0),q(s.samples.length>0);for(let a=0;a<s.compositionTimeOffsetTable.length;a++){const o=s.compositionTimeOffsetTable[a];e=Math.min(e,o.sampleCompositionTimeOffset),t=Math.max(t,o.sampleCompositionTimeOffset)}for(let a=0;a<s.samples.length;a++){const o=s.samples[a];i=Math.min(i,Qe(o.timestamp,s.timescale)),r=Math.max(r,Qe(o.timestamp+o.duration,s.timescale))}const n=Math.max(-e,0);return r>=2**31?null:Oe("cslg",0,0,[Fi(n),Fi(e),Fi(t),Fi(i),Fi(r)])},L2=s=>fe("mvex",void 0,s.map(z2)),z2=s=>Oe("trex",0,0,[U(s.track.id),U(1),U(0),U(0),U(0)]),m0=(s,e)=>fe("moof",void 0,[$2(s),...e.map(N2)]),$2=s=>Oe("mfhd",0,0,[U(s)]),g0=s=>{let e=0,t=0;const i=0,r=0,n=s.type==="delta";return t|=+n,n?e|=1:e|=2,e<<24|t<<16|i<<8|r},N2=s=>fe("traf",void 0,[U2(s),V2(s),H2(s)]),U2=s=>{q(s.currentChunk);let e=0;e|=8,e|=16,e|=32,e|=131072;const t=s.currentChunk.samples[1]??s.currentChunk.samples[0],i={duration:t.timescaleUnitsToNextSample,size:t.size,flags:g0(t)};return Oe("tfhd",0,e,[U(s.track.id),U(i.duration),U(i.size),U(i.flags)])},V2=s=>(q(s.currentChunk),Oe("tfdt",1,0,[Qi(Qe(s.currentChunk.startTimestamp,s.timescale))])),H2=s=>{q(s.currentChunk);const e=s.currentChunk.samples.map(m=>m.timescaleUnitsToNextSample),t=s.currentChunk.samples.map(m=>m.size),i=s.currentChunk.samples.map(g0),r=s.currentChunk.samples.map(m=>Qe(m.timestamp-m.decodeTimestamp,s.timescale)),n=new Set(e),a=new Set(t),o=new Set(i),c=new Set(r),u=o.size===2&&i[0]!==i[1],h=n.size>1,l=a.size>1,d=!u&&o.size>1,f=c.size>1||[...c].some(m=>m!==0);let p=0;return p|=1,p|=4*+u,p|=256*+h,p|=512*+l,p|=1024*+d,p|=2048*+f,Oe("trun",1,p,[U(s.currentChunk.samples.length),U(s.currentChunk.offset-s.currentChunk.moofOffset||0),u?U(i[0]):[],s.currentChunk.samples.map((m,b)=>[h?U(e[b]):[],l?U(t[b]):[],d?U(i[b]):[],f?Fi(r[b]):[]])])},j2=s=>fe("mfra",void 0,[...s.map(W2),G2()]),W2=(s,e)=>Oe("tfra",1,0,[U(s.track.id),U(63),U(s.finalizedChunks.length),s.finalizedChunks.map(i=>[Qi(Qe(i.samples[0].timestamp,s.timescale)),Qi(i.moofOffset),U(e+1),U(1),U(1)])]),G2=()=>Oe("mfro",0,0,[U(0)]),q2=()=>fe("vtte"),X2=(s,e,t,i,r)=>fe("vttc",void 0,[r!==null?fe("vsid",[Fi(r)]):null,t!==null?fe("iden",[...qt.encode(t)]):null,e!==null?fe("ctim",[...qt.encode(t2(e))]):null,i!==null?fe("sttg",[...qt.encode(i)]):null,fe("payl",[...qt.encode(s)])]),Z2=s=>fe("vtta",[...qt.encode(s)]),K2=s=>{const e=[],t=s.format._options.metadataFormat??"auto",i=s.output._metadataTags;if(t==="mdir"||t==="auto"&&!s.isQuickTime){const r=J2(i);r&&e.push(r)}else if(t==="mdta"){const r=Q2(i);r&&e.push(r)}else(t==="udta"||t==="auto"&&s.isQuickTime)&&Y2(e,s.output._metadataTags);return e.length===0?null:fe("udta",void 0,e)},Y2=(s,e)=>{for(const{key:t,value:i}of qu(e))switch(t){case"title":s.push(Jt("©nam",i));break;case"description":s.push(Jt("©des",i));break;case"artist":s.push(Jt("©ART",i));break;case"album":s.push(Jt("©alb",i));break;case"albumArtist":s.push(Jt("albr",i));break;case"genre":s.push(Jt("©gen",i));break;case"date":s.push(Jt("©day",i.toISOString().slice(0,10)));break;case"comment":s.push(Jt("©cmt",i));break;case"lyrics":s.push(Jt("©lyr",i));break;case"raw":break;case"discNumber":case"discsTotal":case"trackNumber":case"tracksTotal":case"images":break;default:Qa(t)}if(e.raw)for(const t in e.raw){const i=e.raw[t];i==null||t.length!==4||s.some(r=>r.type===t)||(typeof i=="string"?s.push(Jt(t,i)):i instanceof Uint8Array&&s.push(fe(t,Array.from(i))))}},Jt=(s,e)=>{const t=qt.encode(e);return fe(s,[le(t.length),le(w0("und")),Array.from(t)])},y0={"image/jpeg":13,"image/png":14,"image/bmp":27},b0=(s,e)=>{const t=[];for(const{key:i,value:r}of qu(s))switch(i){case"title":t.push({key:e?"title":"©nam",value:Pt(r)});break;case"description":t.push({key:e?"description":"©des",value:Pt(r)});break;case"artist":t.push({key:e?"artist":"©ART",value:Pt(r)});break;case"album":t.push({key:e?"album":"©alb",value:Pt(r)});break;case"albumArtist":t.push({key:e?"album_artist":"aART",value:Pt(r)});break;case"comment":t.push({key:e?"comment":"©cmt",value:Pt(r)});break;case"genre":t.push({key:e?"genre":"©gen",value:Pt(r)});break;case"lyrics":t.push({key:e?"lyrics":"©lyr",value:Pt(r)});break;case"date":t.push({key:e?"date":"©day",value:Pt(r.toISOString().slice(0,10))});break;case"images":for(const n of r)n.kind==="coverFront"&&t.push({key:"covr",value:fe("data",[U(y0[n.mimeType]??0),U(0),Array.from(n.data)])});break;case"trackNumber":if(e){const n=s.tracksTotal!==void 0?`${r}/${s.tracksTotal}`:r.toString();t.push({key:"track",value:Pt(n)})}else t.push({key:"trkn",value:fe("data",[U(0),U(0),le(0),le(r),le(s.tracksTotal??0),le(0)])});break;case"discNumber":e||t.push({key:"disc",value:fe("data",[U(0),U(0),le(0),le(r),le(s.discsTotal??0),le(0)])});break;case"tracksTotal":case"discsTotal":break;case"raw":break;default:Qa(i)}if(s.raw)for(const i in s.raw){const r=s.raw[i];r==null||!e&&i.length!==4||t.some(n=>n.key===i)||(typeof r=="string"?t.push({key:i,value:Pt(r)}):r instanceof Uint8Array?t.push({key:i,value:fe("data",[U(0),U(0),Array.from(r)])}):r instanceof Xu&&t.push({key:i,value:fe("data",[U(y0[r.mimeType]??0),U(0),Array.from(r.data)])}))}return t},J2=s=>{const e=b0(s,!1);return e.length===0?null:Oe("meta",0,0,void 0,[ho(!1,"mdir","","appl"),fe("ilst",void 0,e.map(t=>fe(t.key,void 0,[t.value])))])},Q2=s=>{const e=b0(s,!0);return e.length===0?null:fe("meta",void 0,[ho(!1,"mdta",""),Oe("keys",0,0,[U(e.length)],e.map(t=>fe("mdta",[...qt.encode(t.key)]))),fe("ilst",void 0,e.map((t,i)=>{const r=String.fromCharCode(...U(i+1));return fe(r,void 0,[t.value])}))])},Pt=s=>fe("data",[U(1),U(0),...qt.encode(s)]),ew={avc:"avc1",hevc:"hvc1",vp8:"vp08",vp9:"vp09",av1:"av01"},tw={avc:w2,hevc:x2,vp8:p0,vp9:p0,av1:C2},v0=(s,e)=>{switch(s){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"}if(e)switch(s){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(s){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"}},iw=(s,e)=>{switch(s){case"aac":return fo;case"mp3":return fo;case"opus":return E2;case"vorbis":return fo;case"flac":return _2}if(e)switch(s){case"pcm-s24":return Ri;case"pcm-s24be":return Ri;case"pcm-s32":return Ri;case"pcm-s32be":return Ri;case"pcm-f32":return Ri;case"pcm-f32be":return Ri;case"pcm-f64":return Ri;case"pcm-f64be":return Ri}else switch(s){case"pcm-s16":return Yt;case"pcm-s16be":return Yt;case"pcm-s24":return Yt;case"pcm-s24be":return Yt;case"pcm-s32":return Yt;case"pcm-s32be":return Yt;case"pcm-f32":return Yt;case"pcm-f32be":return Yt;case"pcm-f64":return Yt;case"pcm-f64be":return Yt}return null},rw={webvtt:"wvtt"},sw={webvtt:I2},w0=s=>{q(s.length===3);let e=0;for(let t=0;t<3;t++)e<<=5,e+=s.charCodeAt(t)-96;return e};/*!
266
268
  * Copyright (c) 2025-present, Vanilagy and contributors
267
269
  *
268
270
  * This Source Code Form is subject to the terms of the Mozilla Public
269
271
  * License, v. 2.0. If a copy of the MPL was not distributed with this
270
272
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
271
- */class Yc{constructor(){this.ensureMonotonicity=!1,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1}start(){}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}const i=t+e.byteLength-this.trackedStart;let r=this.trackedWrites.byteLength;for(;r<i;)r*=2;if(r!==this.trackedWrites.byteLength){const n=new Uint8Array(r);n.set(this.trackedWrites,0),this.trackedWrites=n}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(2**10),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw new Error("Internal error: Can't get tracked writes since nothing was tracked.");const t={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,t}}const vs=2**16,ws=2**32;class dn extends Yc{constructor(e){if(super(),this.pos=0,this.maxPos=0,this.target=e,this.supportsResize="resize"in new ArrayBuffer(0),this.supportsResize)try{this.buffer=new ArrayBuffer(vs,{maxByteLength:ws})}catch{this.buffer=new ArrayBuffer(vs),this.supportsResize=!1}else this.buffer=new ArrayBuffer(vs);this.bytes=new Uint8Array(this.buffer)}ensureSize(e){let t=this.buffer.byteLength;for(;t<e;)t*=2;if(t!==this.buffer.byteLength){if(t>ws)throw new Error(`ArrayBuffer exceeded maximum size of ${ws} bytes. Please consider using another target.`);if(this.supportsResize)this.buffer.resize(t);else{const i=new ArrayBuffer(t),r=new Uint8Array(i);r.set(this.bytes,0),this.buffer=i,this.bytes=r}}}write(e){this.maybeTrackWrites(e),this.ensureSize(this.pos+e.byteLength),this.bytes.set(e,this.pos),this.target.onwrite?.(this.pos,this.pos+e.byteLength),this.pos+=e.byteLength,this.maxPos=Math.max(this.maxPos,this.pos)}seek(e){this.pos=e}getPos(){return this.pos}async flush(){}async finalize(){this.ensureSize(this.pos),this.target.buffer=this.buffer.slice(0,Math.max(this.maxPos,this.pos))}async close(){}getSlice(e,t){return this.bytes.slice(e,t)}}/*!
273
+ */class nw{constructor(){this.ensureMonotonicity=!1,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1}start(){}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}const i=t+e.byteLength-this.trackedStart;let r=this.trackedWrites.byteLength;for(;r<i;)r*=2;if(r!==this.trackedWrites.byteLength){const n=new Uint8Array(r);n.set(this.trackedWrites,0),this.trackedWrites=n}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(2**10),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw new Error("Internal error: Can't get tracked writes since nothing was tracked.");const t={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,t}}const po=2**16,mo=2**32;class x0 extends nw{constructor(e){if(super(),this.pos=0,this.maxPos=0,this.target=e,this.supportsResize="resize"in new ArrayBuffer(0),this.supportsResize)try{this.buffer=new ArrayBuffer(po,{maxByteLength:mo})}catch{this.buffer=new ArrayBuffer(po),this.supportsResize=!1}else this.buffer=new ArrayBuffer(po);this.bytes=new Uint8Array(this.buffer)}ensureSize(e){let t=this.buffer.byteLength;for(;t<e;)t*=2;if(t!==this.buffer.byteLength){if(t>mo)throw new Error(`ArrayBuffer exceeded maximum size of ${mo} bytes. Please consider using another target.`);if(this.supportsResize)this.buffer.resize(t);else{const i=new ArrayBuffer(t),r=new Uint8Array(i);r.set(this.bytes,0),this.buffer=i,this.bytes=r}}}write(e){this.maybeTrackWrites(e),this.ensureSize(this.pos+e.byteLength),this.bytes.set(e,this.pos),this.target.onwrite?.(this.pos,this.pos+e.byteLength),this.pos+=e.byteLength,this.maxPos=Math.max(this.maxPos,this.pos)}seek(e){this.pos=e}getPos(){return this.pos}async flush(){}async finalize(){this.ensureSize(this.pos),this.target.buffer=this.buffer.slice(0,Math.max(this.maxPos,this.pos))}async close(){}getSlice(e,t){return this.bytes.slice(e,t)}}/*!
272
274
  * Copyright (c) 2025-present, Vanilagy and contributors
273
275
  *
274
276
  * This Source Code Form is subject to the terms of the Mozilla Public
275
277
  * License, v. 2.0. If a copy of the MPL was not distributed with this
276
278
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
277
- */class fn{constructor(){this._output=null,this.onwrite=null}}class pn extends fn{constructor(){super(...arguments),this.buffer=null}_createWriter(){return new dn(this)}}/*!
279
+ */class C0{constructor(){this._output=null,this.onwrite=null}}class k0 extends C0{constructor(){super(...arguments),this.buffer=null}_createWriter(){return new x0(this)}}/*!
278
280
  * Copyright (c) 2025-present, Vanilagy and contributors
279
281
  *
280
282
  * This Source Code Form is subject to the terms of the Mozilla Public
281
283
  * License, v. 2.0. If a copy of the MPL was not distributed with this
282
284
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
283
- */const _s=1e3,Qc=2082844800,Jc=s=>{const e={},t=s.track;return t.metadata.name!==void 0&&(e.name=t.metadata.name),e},xe=(s,e,t=!0)=>{const i=s*e;return t?Math.round(i):i};class eh extends kl{constructor(e,t){super(e),this.auxTarget=new pn,this.auxWriter=this.auxTarget._createWriter(),this.auxBoxWriter=new Yr(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=tl(),this.creationTime=Math.floor(Date.now()/1e3)+Qc,this.finalizedChunks=[],this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.format=t,this.writer=e._writer,this.boxWriter=new Yr(this.writer),this.isQuickTime=t instanceof bn;const i=this.writer instanceof dn?"in-memory":!1;this.fastStart=t._options.fastStart??i,this.isFragmented=this.fastStart==="fragmented",(this.fastStart==="in-memory"||this.isFragmented)&&(this.writer.ensureMonotonicity=!0),this.minimumFragmentDuration=t._options.minimumFragmentDuration??1}async start(){const e=await this.mutex.acquire(),t=this.output._tracks.some(i=>i.type==="video"&&i.source._codec==="avc");if(this.format._options.onFtyp&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(Kl({isQuickTime:this.isQuickTime,holdsAvc:t,fragmented:this.isFragmented})),this.format._options.onFtyp){const{data:i,start:r}=this.writer.stopTrackingWrites();this.format._options.onFtyp(i,r)}if(this.ftypSize=this.writer.getPos(),this.fastStart!=="in-memory")if(this.fastStart==="reserve"){for(const i of this.output._tracks)if(i.metadata.maximumPacketCount===void 0)throw new Error("All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.")}else this.isFragmented||(this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=Ti(!0),this.boxWriter.writeBox(this.mdat));await this.writer.flush(),e()}allTracksAreKnown(){for(const 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;const e=this.trackDatas.map(t=>t.type==="video"||t.type==="audio"?t.info.decoderConfig.codec:{webvtt:"wvtt"}[t.track.source._codec]);return Wl({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(t=>t.type==="video"),hasAudio:this.trackDatas.some(t=>t.type==="audio"),codecStrings:e})}getVideoTrackData(e,t,i){const r=this.trackDatas.find(m=>m.track===e);if(r)return r;wl(i),$(i),$(i.decoderConfig);const n={...i.decoderConfig};$(n.codedWidth!==void 0),$(n.codedHeight!==void 0);let o=!1;if(e.source._codec==="avc"&&!n.description){const m=Sl(t.data);if(!m)throw new 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.");n.description=El(m),o=!0}else if(e.source._codec==="hevc"&&!n.description){const m=Al(t.data);if(!m)throw new 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.");n.description=Ll(m),o=!0}const a=al(1/(e.metadata.frameRate??57600),1e6).denominator,p={muxer:this,track:e,type:"video",info:{width:n.codedWidth,height:n.codedHeight,decoderConfig:n,requiresAnnexBTransformation:o},timescale:a,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(p),this.trackDatas.sort((m,d)=>m.track.id-d.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),p}getAudioTrackData(e,t){const i=this.trackDatas.find(n=>n.track===e);if(i)return i;xl(t),$(t),$(t.decoderConfig);const r={muxer:this,track:e,type:"audio",info:{numberOfChannels:t.decoderConfig.numberOfChannels,sampleRate:t.decoderConfig.sampleRate,decoderConfig:t.decoderConfig,requiresPcmTransformation:!this.isFragmented&&Ne.includes(e.source._codec)},timescale:t.decoderConfig.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(r),this.trackDatas.sort((n,o)=>n.track.id-o.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}getSubtitleTrackData(e,t){const i=this.trackDatas.find(n=>n.track===e);if(i)return i;Cl(t),$(t),$(t.config);const r={muxer:this,track:e,type:"subtitle",info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],lastCueEndTimestamp:0,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(r),this.trackDatas.sort((n,o)=>n.track.id-o.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,i){const r=await this.mutex.acquire();try{const n=this.getVideoTrackData(e,t,i);let o=t.data;if(n.info.requiresAnnexBTransformation){const m=Tl(o);if(!m)throw new 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.");o=m}const a=this.validateAndNormalizeTimestamp(n.track,t.timestamp,t.type==="key"),p=this.createSampleForTrack(n,o,a,t.duration,t.type);await this.registerSample(n,p)}finally{r()}}async addEncodedAudioPacket(e,t,i){const r=await this.mutex.acquire();try{const n=this.getAudioTrackData(e,i),o=this.validateAndNormalizeTimestamp(n.track,t.timestamp,t.type==="key"),a=this.createSampleForTrack(n,t.data,o,t.duration,t.type);n.info.requiresPcmTransformation&&await this.maybePadWithSilence(n,o),await this.registerSample(n,a)}finally{r()}}async maybePadWithSilence(e,t){const i=ze(e.samples),r=i?i.timestamp+i.duration:0,n=t-r,o=xe(n,e.timescale);if(o>0){const{sampleSize:a,silentValue:p}=Lt(e.info.decoderConfig.codec),m=o*e.info.numberOfChannels,d=new Uint8Array(a*m).fill(p),l=this.createSampleForTrack(e,new Uint8Array(d.buffer),r,n,"key");await this.registerSample(e,l)}}async addSubtitleCue(e,t,i){const r=await this.mutex.acquire();try{const n=this.getSubtitleTrackData(e,i);this.validateAndNormalizeTimestamp(n.track,t.timestamp,!0),e.source._codec==="webvtt"&&(n.cueQueue.push(t),await this.processWebVTTCues(n,t.timestamp))}finally{r()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){const i=new Set([]);for(const m of e.cueQueue)$(m.timestamp<=t),$(e.lastCueEndTimestamp<=m.timestamp+m.duration),i.add(Math.max(m.timestamp,e.lastCueEndTimestamp)),i.add(m.timestamp+m.duration);const r=[...i].sort((m,d)=>m-d),n=r[0],o=r[1]??n;if(t<o)break;if(e.lastCueEndTimestamp<n){this.auxWriter.seek(0);const m=zc();this.auxBoxWriter.writeBox(m);const d=this.auxWriter.getSlice(0,this.auxWriter.getPos()),l=this.createSampleForTrack(e,d,e.lastCueEndTimestamp,n-e.lastCueEndTimestamp,"key");await this.registerSample(e,l),e.lastCueEndTimestamp=n}this.auxWriter.seek(0);for(let m=0;m<e.cueQueue.length;m++){const d=e.cueQueue[m];if(d.timestamp>=o)break;Xr.lastIndex=0;const l=Xr.test(d.text),c=d.timestamp+d.duration;let u=e.cueToSourceId.get(d);if(u===void 0&&o<c&&(u=e.nextSourceId++,e.cueToSourceId.set(d,u)),d.notes){const f=Nc(d.notes);this.auxBoxWriter.writeBox(f)}const h=Hc(d.text,l?n:null,d.identifier??null,d.settings??null,u??null);this.auxBoxWriter.writeBox(h),c===o&&e.cueQueue.splice(m--,1)}const a=this.auxWriter.getSlice(0,this.auxWriter.getPos()),p=this.createSampleForTrack(e,a,n,o-n,"key");await this.registerSample(e,p),e.lastCueEndTimestamp=o}}createSampleForTrack(e,t,i,r,n){return{timestamp:i,decodeTimestamp:i,duration:r,data:t,size:t.byteLength,type:n,timescaleUnitsToNextSample:xe(r,e.timescale)}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type==="audio"&&e.info.requiresPcmTransformation){let r=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){const o=e.timestampProcessingQueue[n],a=xe(o.duration,e.timescale);r+=a}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:r,sampleDelta:1});else{const n=ze(e.timeToSampleTable);n.sampleCount+=r}e.timestampProcessingQueue.length=0;return}const i=e.timestampProcessingQueue.map(r=>r.timestamp).sort((r,n)=>r-n);for(let r=0;r<e.timestampProcessingQueue.length;r++){const n=e.timestampProcessingQueue[r];n.decodeTimestamp=i[r],!this.isFragmented&&e.lastTimescaleUnits===null&&(n.decodeTimestamp=0);const o=xe(n.timestamp-n.decodeTimestamp,e.timescale),a=xe(n.duration,e.timescale);if(e.lastTimescaleUnits!==null){$(e.lastSample);const p=xe(n.decodeTimestamp,e.timescale,!1),m=Math.round(p-e.lastTimescaleUnits);if($(m>=0),e.lastTimescaleUnits+=m,e.lastSample.timescaleUnitsToNextSample=m,!this.isFragmented){let d=ze(e.timeToSampleTable);if($(d),d.sampleCount===1){d.sampleDelta=m;const c=e.timeToSampleTable[e.timeToSampleTable.length-2];c&&c.sampleDelta===m&&(c.sampleCount++,e.timeToSampleTable.pop(),d=c)}else d.sampleDelta!==m&&(d.sampleCount--,e.timeToSampleTable.push(d={sampleCount:1,sampleDelta:m}));d.sampleDelta===a?d.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:a});const l=ze(e.compositionTimeOffsetTable);$(l),l.sampleCompositionTimeOffset===o?l.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:o})}}else e.lastTimescaleUnits=xe(n.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:a}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:o}));e.lastSample=n}if(e.timestampProcessingQueue.length=0,$(e.lastSample),$(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){$(t.type==="key");const r=xe(t.timestamp,e.timescale,!1),n=Math.round(r-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=n}}async registerSample(e,t){t.type==="key"&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),this.isFragmented?(e.sampleQueue.push(t),await this.interleaveSamples()):this.fastStart==="reserve"?await this.registerSampleFastStartReserve(e,t):await this.addSampleToTrack(e,t)}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart==="reserve")){const r=e.track.metadata.maximumPacketCount;if($(r!==void 0),e.samples.length>r)throw new Error(`Track #${e.track.id} has already reached the maximum packet count (${r}). Either add less packets or increase the maximum packet count.`)}let i=!1;if(!e.currentChunk)i=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);const r=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){const n=this.trackDatas.every(o=>{if(e===o)return t.type==="key";const a=o.sampleQueue[0];return a?a.type==="key":o.track.source._closed});r>=this.minimumFragmentDuration&&n&&t.timestamp>this.maxWrittenTimestamp&&(i=!0,await this.finalizeFragment())}else i=r>=.5}i&&(e.currentChunk&&await this.finalizeCurrentChunk(e),e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null}),$(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){if($(!this.isFragmented),!e.currentChunk)return;e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk);let t=e.currentChunk.samples.length;if(e.type==="audio"&&e.info.requiresPcmTransformation&&(t=e.currentChunk.samples.reduce((i,r)=>i+xe(r.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||ze(e.compactlyCodedChunkTable).samplesPerChunk!==t)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:t}),this.fastStart==="in-memory"){e.currentChunk.offset=0;return}e.currentChunk.offset=this.writer.getPos();for(const i of e.currentChunk.samples)$(i.data),this.writer.write(i.data),i.data=null;await this.writer.flush()}async interleaveSamples(e=!1){if($(this.isFragmented),!(!e&&!this.allTracksAreKnown()))e:for(;;){let t=null,i=1/0;for(const n of this.trackDatas){if(!e&&n.sampleQueue.length===0&&!n.track.source._closed)break e;n.sampleQueue.length>0&&n.sampleQueue[0].timestamp<i&&(t=n,i=n.sampleQueue[0].timestamp)}if(!t)break;const r=t.sampleQueue.shift();await this.addSampleToTrack(t,r)}}async finalizeFragment(e=!0){$(this.isFragmented);const t=this.nextFragmentNumber++;if(t===1){this.format._options.onMoov&&this.writer.startTrackingWrites();const u=si(this);if(this.boxWriter.writeBox(u),this.format._options.onMoov){const{data:h,start:f}=this.writer.stopTrackingWrites();this.format._options.onMoov(h,f)}}const i=this.trackDatas.filter(u=>u.currentChunk),r=an(t,i),n=this.writer.getPos(),o=n+this.boxWriter.measureBox(r);let a=o+fs,p=1/0;for(const u of i){u.currentChunk.offset=a,u.currentChunk.moofOffset=n;for(const h of u.currentChunk.samples)a+=h.size;p=Math.min(p,u.currentChunk.startTimestamp)}const m=a-o,d=m>=2**32;if(d)for(const u of i)u.currentChunk.offset+=qr-fs;this.format._options.onMoof&&this.writer.startTrackingWrites();const l=an(t,i);if(this.boxWriter.writeBox(l),this.format._options.onMoof){const{data:u,start:h}=this.writer.stopTrackingWrites();this.format._options.onMoof(u,h,p)}$(this.writer.getPos()===o),this.format._options.onMdat&&this.writer.startTrackingWrites();const c=Ti(d);c.size=m,this.boxWriter.writeBox(c),this.writer.seek(o+(d?qr:fs));for(const u of i)for(const h of u.currentChunk.samples)this.writer.write(h.data),h.data=null;if(this.format._options.onMdat){const{data:u,start:h}=this.writer.stopTrackingWrites();this.format._options.onMdat(u,h)}for(const u of i)u.finalizedChunks.push(u.currentChunk),this.finalizedChunks.push(u.currentChunk),u.currentChunk=null;e&&await this.writer.flush()}async registerSampleFastStartReserve(e,t){if(this.allTracksAreKnown()){if(!this.mdat){const i=si(this),n=this.boxWriter.measureBox(i)+this.computeSampleTableSizeUpperBound()+4096;$(this.ftypSize!==null),this.writer.seek(this.ftypSize+n),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=Ti(!0),this.boxWriter.writeBox(this.mdat);for(const o of this.trackDatas){for(const a of o.sampleQueue)await this.addSampleToTrack(o,a);o.sampleQueue.length=0}}await this.addSampleToTrack(e,t)}else e.sampleQueue.push(t)}computeSampleTableSizeUpperBound(){$(this.fastStart==="reserve");let e=0;for(const t of this.trackDatas){const i=t.track.metadata.maximumPacketCount;$(i!==void 0),e+=8*Math.ceil(2/3*i),e+=4*i,e+=8*Math.ceil(2/3*i),e+=12*Math.ceil(2/3*i),e+=4*i,e+=8*i}return e}async onTrackClose(e){const t=await this.mutex.acquire();if(e.type==="subtitle"&&e.source._codec==="webvtt"){const i=this.trackDatas.find(r=>r.track===e);i&&await this.processWebVTTCues(i,1/0)}this.allTracksAreKnown()&&this.allTracksKnown.resolve(),this.isFragmented&&await this.interleaveSamples(),t()}async finalize(){const e=await this.mutex.acquire();this.allTracksKnown.resolve();for(const t of this.trackDatas)t.type==="subtitle"&&t.track.source._codec==="webvtt"&&await this.processWebVTTCues(t,1/0);if(this.isFragmented){await this.interleaveSamples(!0);for(const t of this.trackDatas)this.processTimestamps(t);await this.finalizeFragment(!1)}else for(const t of this.trackDatas)this.processTimestamps(t),await this.finalizeCurrentChunk(t);if(this.fastStart==="in-memory"){this.mdat=Ti(!1);let t;for(let r=0;r<2;r++){const n=si(this),o=this.boxWriter.measureBox(n);t=this.boxWriter.measureBox(this.mdat);let a=this.writer.getPos()+o+t;for(const p of this.finalizedChunks){p.offset=a;for(const{data:m}of p.samples)$(m),a+=m.byteLength,t+=m.byteLength}if(a<2**32)break;t>=2**32&&(this.mdat.largeSize=!0)}this.format._options.onMoov&&this.writer.startTrackingWrites();const i=si(this);if(this.boxWriter.writeBox(i),this.format._options.onMoov){const{data:r,start:n}=this.writer.stopTrackingWrites();this.format._options.onMoov(r,n)}this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=t,this.boxWriter.writeBox(this.mdat);for(const r of this.finalizedChunks)for(const n of r.samples)$(n.data),this.writer.write(n.data),n.data=null;if(this.format._options.onMdat){const{data:r,start:n}=this.writer.stopTrackingWrites();this.format._options.onMdat(r,n)}}else if(this.isFragmented){const t=this.writer.getPos(),i=Bc(this.trackDatas);this.boxWriter.writeBox(i);const r=this.writer.getPos()-t;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(r)}else{$(this.mdat);const t=this.boxWriter.offsets.get(this.mdat);$(t!==void 0);const i=this.writer.getPos()-t;if(this.mdat.size=i,this.mdat.largeSize=i>=2**32,this.boxWriter.patchBox(this.mdat),this.format._options.onMdat){const{data:n,start:o}=this.writer.stopTrackingWrites();this.format._options.onMdat(n,o)}const r=si(this);if(this.fastStart==="reserve"){$(this.ftypSize!==null),this.writer.seek(this.ftypSize),this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(r);const n=this.boxWriter.offsets.get(this.mdat)-this.writer.getPos();this.boxWriter.writeBox(ql(n))}else this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(r);if(this.format._options.onMoov){const{data:n,start:o}=this.writer.stopTrackingWrites();this.format._options.onMoov(n,o)}}e()}}/*!
285
+ */const go=1e3,aw=2082844800,ow=s=>{const e={},t=s.track;return t.metadata.name!==void 0&&(e.name=t.metadata.name),e},Qe=(s,e,t=!0)=>{const i=s*e;return t?Math.round(i):i};class lw extends Rv{constructor(e,t){super(e),this.auxTarget=new k0,this.auxWriter=this.auxTarget._createWriter(),this.auxBoxWriter=new o0(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=uv(),this.creationTime=Math.floor(Date.now()/1e3)+aw,this.finalizedChunks=[],this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.format=t,this.writer=e._writer,this.boxWriter=new o0(this.writer),this.isQuickTime=t instanceof _0;const i=this.writer instanceof x0?"in-memory":!1;this.fastStart=t._options.fastStart??i,this.isFragmented=this.fastStart==="fragmented",(this.fastStart==="in-memory"||this.isFragmented)&&(this.writer.ensureMonotonicity=!0),this.minimumFragmentDuration=t._options.minimumFragmentDuration??1}async start(){const e=await this.mutex.acquire(),t=this.output._tracks.some(i=>i.type==="video"&&i.source._codec==="avc");if(this.format._options.onFtyp&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(i2({isQuickTime:this.isQuickTime,holdsAvc:t,fragmented:this.isFragmented})),this.format._options.onFtyp){const{data:i,start:r}=this.writer.stopTrackingWrites();this.format._options.onFtyp(i,r)}if(this.ftypSize=this.writer.getPos(),this.fastStart!=="in-memory")if(this.fastStart==="reserve"){for(const i of this.output._tracks)if(i.metadata.maximumPacketCount===void 0)throw new Error("All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.")}else this.isFragmented||(this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=vn(!0),this.boxWriter.writeBox(this.mdat));await this.writer.flush(),e()}allTracksAreKnown(){for(const 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;const e=this.trackDatas.map(t=>t.type==="video"||t.type==="audio"?t.info.decoderConfig.codec:{webvtt:"wvtt"}[t.track.source._codec]);return e2({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(t=>t.type==="video"),hasAudio:this.trackDatas.some(t=>t.type==="audio"),codecStrings:e})}getVideoTrackData(e,t,i){const r=this.trackDatas.find(u=>u.track===e);if(r)return r;Iv(i),q(i),q(i.decoderConfig);const n={...i.decoderConfig};q(n.codedWidth!==void 0),q(n.codedHeight!==void 0);let a=!1;if(e.source._codec==="avc"&&!n.description){const u=Dv(t.data);if(!u)throw new 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.");n.description=Bv(u),a=!0}else if(e.source._codec==="hevc"&&!n.description){const u=Lv(t.data);if(!u)throw new 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.");n.description=jv(u),a=!0}const o=mv(1/(e.metadata.frameRate??57600),1e6).denominator,c={muxer:this,track:e,type:"video",info:{width:n.codedWidth,height:n.codedHeight,decoderConfig:n,requiresAnnexBTransformation:a},timescale:o,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(c),this.trackDatas.sort((u,h)=>u.track.id-h.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),c}getAudioTrackData(e,t){const i=this.trackDatas.find(n=>n.track===e);if(i)return i;Ov(t),q(t),q(t.decoderConfig);const r={muxer:this,track:e,type:"audio",info:{numberOfChannels:t.decoderConfig.numberOfChannels,sampleRate:t.decoderConfig.sampleRate,decoderConfig:t.decoderConfig,requiresPcmTransformation:!this.isFragmented&&Xt.includes(e.source._codec)},timescale:t.decoderConfig.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(r),this.trackDatas.sort((n,a)=>n.track.id-a.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}getSubtitleTrackData(e,t){const i=this.trackDatas.find(n=>n.track===e);if(i)return i;Fv(t),q(t),q(t.config);const r={muxer:this,track:e,type:"subtitle",info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],lastCueEndTimestamp:0,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(r),this.trackDatas.sort((n,a)=>n.track.id-a.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,i){const r=await this.mutex.acquire();try{const n=this.getVideoTrackData(e,t,i);let a=t.data;if(n.info.requiresAnnexBTransformation){const u=Mv(a);if(!u)throw new 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.");a=u}const o=this.validateAndNormalizeTimestamp(n.track,t.timestamp,t.type==="key"),c=this.createSampleForTrack(n,a,o,t.duration,t.type);await this.registerSample(n,c)}finally{r()}}async addEncodedAudioPacket(e,t,i){const r=await this.mutex.acquire();try{const n=this.getAudioTrackData(e,i),a=this.validateAndNormalizeTimestamp(n.track,t.timestamp,t.type==="key"),o=this.createSampleForTrack(n,t.data,a,t.duration,t.type);n.info.requiresPcmTransformation&&await this.maybePadWithSilence(n,a),await this.registerSample(n,o)}finally{r()}}async maybePadWithSilence(e,t){const i=Gt(e.samples),r=i?i.timestamp+i.duration:0,n=t-r,a=Qe(n,e.timescale);if(a>0){const{sampleSize:o,silentValue:c}=kr(e.info.decoderConfig.codec),u=a*e.info.numberOfChannels,h=new Uint8Array(o*u).fill(c),l=this.createSampleForTrack(e,new Uint8Array(h.buffer),r,n,"key");await this.registerSample(e,l)}}async addSubtitleCue(e,t,i){const r=await this.mutex.acquire();try{const n=this.getSubtitleTrackData(e,i);this.validateAndNormalizeTimestamp(n.track,t.timestamp,!0),e.source._codec==="webvtt"&&(n.cueQueue.push(t),await this.processWebVTTCues(n,t.timestamp))}finally{r()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){const i=new Set([]);for(const u of e.cueQueue)q(u.timestamp<=t),q(e.lastCueEndTimestamp<=u.timestamp+u.duration),i.add(Math.max(u.timestamp,e.lastCueEndTimestamp)),i.add(u.timestamp+u.duration);const r=[...i].sort((u,h)=>u-h),n=r[0],a=r[1]??n;if(t<a)break;if(e.lastCueEndTimestamp<n){this.auxWriter.seek(0);const u=q2();this.auxBoxWriter.writeBox(u);const h=this.auxWriter.getSlice(0,this.auxWriter.getPos()),l=this.createSampleForTrack(e,h,e.lastCueEndTimestamp,n-e.lastCueEndTimestamp,"key");await this.registerSample(e,l),e.lastCueEndTimestamp=n}this.auxWriter.seek(0);for(let u=0;u<e.cueQueue.length;u++){const h=e.cueQueue[u];if(h.timestamp>=a)break;a0.lastIndex=0;const l=a0.test(h.text),d=h.timestamp+h.duration;let f=e.cueToSourceId.get(h);if(f===void 0&&a<d&&(f=e.nextSourceId++,e.cueToSourceId.set(h,f)),h.notes){const m=Z2(h.notes);this.auxBoxWriter.writeBox(m)}const p=X2(h.text,l?n:null,h.identifier??null,h.settings??null,f??null);this.auxBoxWriter.writeBox(p),d===a&&e.cueQueue.splice(u--,1)}const o=this.auxWriter.getSlice(0,this.auxWriter.getPos()),c=this.createSampleForTrack(e,o,n,a-n,"key");await this.registerSample(e,c),e.lastCueEndTimestamp=a}}createSampleForTrack(e,t,i,r,n){return{timestamp:i,decodeTimestamp:i,duration:r,data:t,size:t.byteLength,type:n,timescaleUnitsToNextSample:Qe(r,e.timescale)}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type==="audio"&&e.info.requiresPcmTransformation){let r=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){const a=e.timestampProcessingQueue[n],o=Qe(a.duration,e.timescale);r+=o}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:r,sampleDelta:1});else{const n=Gt(e.timeToSampleTable);n.sampleCount+=r}e.timestampProcessingQueue.length=0;return}const i=e.timestampProcessingQueue.map(r=>r.timestamp).sort((r,n)=>r-n);for(let r=0;r<e.timestampProcessingQueue.length;r++){const n=e.timestampProcessingQueue[r];n.decodeTimestamp=i[r],!this.isFragmented&&e.lastTimescaleUnits===null&&(n.decodeTimestamp=0);const a=Qe(n.timestamp-n.decodeTimestamp,e.timescale),o=Qe(n.duration,e.timescale);if(e.lastTimescaleUnits!==null){q(e.lastSample);const c=Qe(n.decodeTimestamp,e.timescale,!1),u=Math.round(c-e.lastTimescaleUnits);if(q(u>=0),e.lastTimescaleUnits+=u,e.lastSample.timescaleUnitsToNextSample=u,!this.isFragmented){let h=Gt(e.timeToSampleTable);if(q(h),h.sampleCount===1){h.sampleDelta=u;const d=e.timeToSampleTable[e.timeToSampleTable.length-2];d&&d.sampleDelta===u&&(d.sampleCount++,e.timeToSampleTable.pop(),h=d)}else h.sampleDelta!==u&&(h.sampleCount--,e.timeToSampleTable.push(h={sampleCount:1,sampleDelta:u}));h.sampleDelta===o?h.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:o});const l=Gt(e.compositionTimeOffsetTable);q(l),l.sampleCompositionTimeOffset===a?l.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:a})}}else e.lastTimescaleUnits=Qe(n.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:o}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:a}));e.lastSample=n}if(e.timestampProcessingQueue.length=0,q(e.lastSample),q(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){q(t.type==="key");const r=Qe(t.timestamp,e.timescale,!1),n=Math.round(r-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=n}}async registerSample(e,t){t.type==="key"&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),this.isFragmented?(e.sampleQueue.push(t),await this.interleaveSamples()):this.fastStart==="reserve"?await this.registerSampleFastStartReserve(e,t):await this.addSampleToTrack(e,t)}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart==="reserve")){const r=e.track.metadata.maximumPacketCount;if(q(r!==void 0),e.samples.length>r)throw new Error(`Track #${e.track.id} has already reached the maximum packet count (${r}). Either add less packets or increase the maximum packet count.`)}let i=!1;if(!e.currentChunk)i=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);const r=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){const n=this.trackDatas.every(a=>{if(e===a)return t.type==="key";const o=a.sampleQueue[0];return o?o.type==="key":a.track.source._closed});r>=this.minimumFragmentDuration&&n&&t.timestamp>this.maxWrittenTimestamp&&(i=!0,await this.finalizeFragment())}else i=r>=.5}i&&(e.currentChunk&&await this.finalizeCurrentChunk(e),e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null}),q(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){if(q(!this.isFragmented),!e.currentChunk)return;e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk);let t=e.currentChunk.samples.length;if(e.type==="audio"&&e.info.requiresPcmTransformation&&(t=e.currentChunk.samples.reduce((i,r)=>i+Qe(r.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||Gt(e.compactlyCodedChunkTable).samplesPerChunk!==t)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:t}),this.fastStart==="in-memory"){e.currentChunk.offset=0;return}e.currentChunk.offset=this.writer.getPos();for(const i of e.currentChunk.samples)q(i.data),this.writer.write(i.data),i.data=null;await this.writer.flush()}async interleaveSamples(e=!1){if(q(this.isFragmented),!(!e&&!this.allTracksAreKnown()))e:for(;;){let t=null,i=1/0;for(const n of this.trackDatas){if(!e&&n.sampleQueue.length===0&&!n.track.source._closed)break e;n.sampleQueue.length>0&&n.sampleQueue[0].timestamp<i&&(t=n,i=n.sampleQueue[0].timestamp)}if(!t)break;const r=t.sampleQueue.shift();await this.addSampleToTrack(t,r)}}async finalizeFragment(e=!0){q(this.isFragmented);const t=this.nextFragmentNumber++;if(t===1){this.format._options.onMoov&&this.writer.startTrackingWrites();const f=hs(this);if(this.boxWriter.writeBox(f),this.format._options.onMoov){const{data:p,start:m}=this.writer.stopTrackingWrites();this.format._options.onMoov(p,m)}}const i=this.trackDatas.filter(f=>f.currentChunk),r=m0(t,i),n=this.writer.getPos(),a=n+this.boxWriter.measureBox(r);let o=a+ao,c=1/0;for(const f of i){f.currentChunk.offset=o,f.currentChunk.moofOffset=n;for(const p of f.currentChunk.samples)o+=p.size;c=Math.min(c,f.currentChunk.startTimestamp)}const u=o-a,h=u>=2**32;if(h)for(const f of i)f.currentChunk.offset+=n0-ao;this.format._options.onMoof&&this.writer.startTrackingWrites();const l=m0(t,i);if(this.boxWriter.writeBox(l),this.format._options.onMoof){const{data:f,start:p}=this.writer.stopTrackingWrites();this.format._options.onMoof(f,p,c)}q(this.writer.getPos()===a),this.format._options.onMdat&&this.writer.startTrackingWrites();const d=vn(h);d.size=u,this.boxWriter.writeBox(d),this.writer.seek(a+(h?n0:ao));for(const f of i)for(const p of f.currentChunk.samples)this.writer.write(p.data),p.data=null;if(this.format._options.onMdat){const{data:f,start:p}=this.writer.stopTrackingWrites();this.format._options.onMdat(f,p)}for(const f of i)f.finalizedChunks.push(f.currentChunk),this.finalizedChunks.push(f.currentChunk),f.currentChunk=null;e&&await this.writer.flush()}async registerSampleFastStartReserve(e,t){if(this.allTracksAreKnown()){if(!this.mdat){const i=hs(this),n=this.boxWriter.measureBox(i)+this.computeSampleTableSizeUpperBound()+4096;q(this.ftypSize!==null),this.writer.seek(this.ftypSize+n),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=vn(!0),this.boxWriter.writeBox(this.mdat);for(const a of this.trackDatas){for(const o of a.sampleQueue)await this.addSampleToTrack(a,o);a.sampleQueue.length=0}}await this.addSampleToTrack(e,t)}else e.sampleQueue.push(t)}computeSampleTableSizeUpperBound(){q(this.fastStart==="reserve");let e=0;for(const t of this.trackDatas){const i=t.track.metadata.maximumPacketCount;q(i!==void 0),e+=8*Math.ceil(2/3*i),e+=4*i,e+=8*Math.ceil(2/3*i),e+=12*Math.ceil(2/3*i),e+=4*i,e+=8*i}return e}async onTrackClose(e){const t=await this.mutex.acquire();if(e.type==="subtitle"&&e.source._codec==="webvtt"){const i=this.trackDatas.find(r=>r.track===e);i&&await this.processWebVTTCues(i,1/0)}this.allTracksAreKnown()&&this.allTracksKnown.resolve(),this.isFragmented&&await this.interleaveSamples(),t()}async finalize(){const e=await this.mutex.acquire();this.allTracksKnown.resolve();for(const t of this.trackDatas)t.type==="subtitle"&&t.track.source._codec==="webvtt"&&await this.processWebVTTCues(t,1/0);if(this.isFragmented){await this.interleaveSamples(!0);for(const t of this.trackDatas)this.processTimestamps(t);await this.finalizeFragment(!1)}else for(const t of this.trackDatas)this.processTimestamps(t),await this.finalizeCurrentChunk(t);if(this.fastStart==="in-memory"){this.mdat=vn(!1);let t;for(let r=0;r<2;r++){const n=hs(this),a=this.boxWriter.measureBox(n);t=this.boxWriter.measureBox(this.mdat);let o=this.writer.getPos()+a+t;for(const c of this.finalizedChunks){c.offset=o;for(const{data:u}of c.samples)q(u),o+=u.byteLength,t+=u.byteLength}if(o<2**32)break;t>=2**32&&(this.mdat.largeSize=!0)}this.format._options.onMoov&&this.writer.startTrackingWrites();const i=hs(this);if(this.boxWriter.writeBox(i),this.format._options.onMoov){const{data:r,start:n}=this.writer.stopTrackingWrites();this.format._options.onMoov(r,n)}this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=t,this.boxWriter.writeBox(this.mdat);for(const r of this.finalizedChunks)for(const n of r.samples)q(n.data),this.writer.write(n.data),n.data=null;if(this.format._options.onMdat){const{data:r,start:n}=this.writer.stopTrackingWrites();this.format._options.onMdat(r,n)}}else if(this.isFragmented){const t=this.writer.getPos(),i=j2(this.trackDatas);this.boxWriter.writeBox(i);const r=this.writer.getPos()-t;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(r)}else{q(this.mdat);const t=this.boxWriter.offsets.get(this.mdat);q(t!==void 0);const i=this.writer.getPos()-t;if(this.mdat.size=i,this.mdat.largeSize=i>=2**32,this.boxWriter.patchBox(this.mdat),this.format._options.onMdat){const{data:n,start:a}=this.writer.stopTrackingWrites();this.format._options.onMdat(n,a)}const r=hs(this);if(this.fastStart==="reserve"){q(this.ftypSize!==null),this.writer.seek(this.ftypSize),this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(r);const n=this.boxWriter.offsets.get(this.mdat)-this.writer.getPos();this.boxWriter.writeBox(r2(n))}else this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(r);if(this.format._options.onMoov){const{data:n,start:a}=this.writer.stopTrackingWrites();this.format._options.onMoov(n,a)}}e()}}/*!
284
286
  * Copyright (c) 2025-present, Vanilagy and contributors
285
287
  *
286
288
  * This Source Code Form is subject to the terms of the Mozilla Public
287
289
  * License, v. 2.0. If a copy of the MPL was not distributed with this
288
290
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
289
- */class mn{getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>bt.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>Mt.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>Ci.includes(e))}_codecUnsupportedHint(e){return""}}class gn extends mn{constructor(e={}){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(e.fastStart!==void 0&&![!1,"in-memory","reserve","fragmented"].includes(e.fastStart))throw new TypeError("options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.");if(e.minimumFragmentDuration!==void 0&&(!Number.isFinite(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw new TypeError("options.minimumFragmentDuration, when provided, must be a non-negative number.");if(e.onFtyp!==void 0&&typeof e.onFtyp!="function")throw new TypeError("options.onFtyp, when provided, must be a function.");if(e.onMoov!==void 0&&typeof e.onMoov!="function")throw new TypeError("options.onMoov, when provided, must be a function.");if(e.onMdat!==void 0&&typeof e.onMdat!="function")throw new TypeError("options.onMdat, when provided, must be a function.");if(e.onMoof!==void 0&&typeof e.onMoof!="function")throw new TypeError("options.onMoof, when provided, must be a function.");if(e.metadataFormat!==void 0&&!["mdir","mdta","udta","auto"].includes(e.metadataFormat))throw new TypeError("options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.");super(),this._options=e}getSupportedTrackCounts(){return{video:{min:0,max:1/0},audio:{min:0,max:1/0},subtitle:{min:0,max:1/0},total:{min:1,max:2**32-1}}}get supportsVideoRotationMetadata(){return!0}_createMuxer(e){return new eh(e,this)}}class yn extends gn{constructor(e){super(e)}get _name(){return"MP4"}get fileExtension(){return".mp4"}get mimeType(){return"video/mp4"}getSupportedCodecs(){return[...bt,...zr,"pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be",...Ci]}_codecUnsupportedHint(e){return new bn().getSupportedCodecs().includes(e)?" Switching to MOV will grant support for this codec.":""}}class bn extends gn{constructor(e){super(e)}get _name(){return"MOV"}get fileExtension(){return".mov"}get mimeType(){return"video/quicktime"}getSupportedCodecs(){return[...bt,...Mt]}_codecUnsupportedHint(e){return new yn().getSupportedCodecs().includes(e)?" Switching to MP4 will grant support for this codec.":""}}/*!
291
+ */class S0{getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>Ki.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>Cr.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>yn.includes(e))}_codecUnsupportedHint(e){return""}}class T0 extends S0{constructor(e={}){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(e.fastStart!==void 0&&![!1,"in-memory","reserve","fragmented"].includes(e.fastStart))throw new TypeError("options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.");if(e.minimumFragmentDuration!==void 0&&(!Number.isFinite(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw new TypeError("options.minimumFragmentDuration, when provided, must be a non-negative number.");if(e.onFtyp!==void 0&&typeof e.onFtyp!="function")throw new TypeError("options.onFtyp, when provided, must be a function.");if(e.onMoov!==void 0&&typeof e.onMoov!="function")throw new TypeError("options.onMoov, when provided, must be a function.");if(e.onMdat!==void 0&&typeof e.onMdat!="function")throw new TypeError("options.onMdat, when provided, must be a function.");if(e.onMoof!==void 0&&typeof e.onMoof!="function")throw new TypeError("options.onMoof, when provided, must be a function.");if(e.metadataFormat!==void 0&&!["mdir","mdta","udta","auto"].includes(e.metadataFormat))throw new TypeError("options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.");super(),this._options=e}getSupportedTrackCounts(){return{video:{min:0,max:1/0},audio:{min:0,max:1/0},subtitle:{min:0,max:1/0},total:{min:1,max:2**32-1}}}get supportsVideoRotationMetadata(){return!0}_createMuxer(e){return new lw(e,this)}}class E0 extends T0{constructor(e){super(e)}get _name(){return"MP4"}get fileExtension(){return".mp4"}get mimeType(){return"video/mp4"}getSupportedCodecs(){return[...Ki,...Zu,"pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be",...yn]}_codecUnsupportedHint(e){return new _0().getSupportedCodecs().includes(e)?" Switching to MOV will grant support for this codec.":""}}class _0 extends T0{constructor(e){super(e)}get _name(){return"MOV"}get fileExtension(){return".mov"}get mimeType(){return"video/quicktime"}getSupportedCodecs(){return[...Ki,...Cr]}_codecUnsupportedHint(e){return new E0().getSupportedCodecs().includes(e)?" Switching to MP4 will grant support for this codec.":""}}/*!
290
292
  * Copyright (c) 2025-present, Vanilagy and contributors
291
293
  *
292
294
  * This Source Code Form is subject to the terms of the Mozilla Public
293
295
  * License, v. 2.0. If a copy of the MPL was not distributed with this
294
296
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
295
- */const th=s=>{if(!s||typeof s!="object")throw new TypeError("Encoding config must be an object.");if(!bt.includes(s.codec))throw new TypeError(`Invalid video codec '${s.codec}'. Must be one of: ${bt.join(", ")}.`);if(!(s.bitrate instanceof Si)&&(!Number.isInteger(s.bitrate)||s.bitrate<=0))throw new TypeError("config.bitrate must be a positive integer or a quality.");if(s.keyFrameInterval!==void 0&&(!Number.isFinite(s.keyFrameInterval)||s.keyFrameInterval<0))throw new TypeError("config.keyFrameInterval, when provided, must be a non-negative number.");if(s.sizeChangeBehavior!==void 0&&!["deny","passThrough","fill","contain","cover"].includes(s.sizeChangeBehavior))throw new TypeError("config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.");if(s.onEncodedPacket!==void 0&&typeof s.onEncodedPacket!="function")throw new TypeError("config.onEncodedChunk, when provided, must be a function.");if(s.onEncoderConfig!==void 0&&typeof s.onEncoderConfig!="function")throw new TypeError("config.onEncoderConfig, when provided, must be a function.");ih(s.codec,s)},ih=(s,e)=>{if(!e||typeof e!="object")throw new TypeError("Encoding options must be an object.");if(e.alpha!==void 0&&!["discard","keep"].includes(e.alpha))throw new TypeError("options.alpha, when provided, must be 'discard' or 'keep'.");if(e.bitrateMode!==void 0&&!["constant","variable"].includes(e.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(e.latencyMode!==void 0&&!["quality","realtime"].includes(e.latencyMode))throw new TypeError("latencyMode, when provided, must be 'quality' or 'realtime'.");if(e.fullCodecString!==void 0&&typeof e.fullCodecString!="string")throw new TypeError("fullCodecString, when provided, must be a string.");if(e.fullCodecString!==void 0&&Wr(e.fullCodecString)!==s)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${s}).`);if(e.hardwareAcceleration!==void 0&&!["no-preference","prefer-hardware","prefer-software"].includes(e.hardwareAcceleration))throw new TypeError("hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(e.scalabilityMode!==void 0&&typeof e.scalabilityMode!="string")throw new TypeError("scalabilityMode, when provided, must be a string.");if(e.contentHint!==void 0&&typeof e.contentHint!="string")throw new TypeError("contentHint, when provided, must be a string.")},sh=s=>{const e=s.bitrate instanceof Si?s.bitrate._toVideoBitrate(s.codec,s.width,s.height):s.bitrate;return{codec:s.fullCodecString??hl(s.codec,s.width,s.height,e),width:s.width,height:s.height,bitrate:e,bitrateMode:s.bitrateMode,alpha:s.alpha??"discard",framerate:s.framerate,latencyMode:s.latencyMode,hardwareAcceleration:s.hardwareAcceleration,scalabilityMode:s.scalabilityMode,contentHint:s.contentHint,...fl(s.codec)}},rh=s=>{if(!s||typeof s!="object")throw new TypeError("Encoding config must be an object.");if(!Mt.includes(s.codec))throw new TypeError(`Invalid audio codec '${s.codec}'. Must be one of: ${Mt.join(", ")}.`);if(s.bitrate===void 0&&(!Ne.includes(s.codec)||s.codec==="flac"))throw new TypeError("config.bitrate must be provided for compressed audio codecs.");if(s.bitrate!==void 0&&!(s.bitrate instanceof Si)&&(!Number.isInteger(s.bitrate)||s.bitrate<=0))throw new TypeError("config.bitrate, when provided, must be a positive integer or a quality.");if(s.onEncodedPacket!==void 0&&typeof s.onEncodedPacket!="function")throw new TypeError("config.onEncodedChunk, when provided, must be a function.");if(s.onEncoderConfig!==void 0&&typeof s.onEncoderConfig!="function")throw new TypeError("config.onEncoderConfig, when provided, must be a function.");nh(s.codec,s)},nh=(s,e)=>{if(!e||typeof e!="object")throw new TypeError("Encoding options must be an object.");if(e.bitrateMode!==void 0&&!["constant","variable"].includes(e.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(e.fullCodecString!==void 0&&typeof e.fullCodecString!="string")throw new TypeError("fullCodecString, when provided, must be a string.");if(e.fullCodecString!==void 0&&Wr(e.fullCodecString)!==s)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${s}).`)},ah=s=>{const e=s.bitrate instanceof Si?s.bitrate._toAudioBitrate(s.codec):s.bitrate;return{codec:s.fullCodecString??dl(s.codec,s.numberOfChannels,s.sampleRate),numberOfChannels:s.numberOfChannels,sampleRate:s.sampleRate,bitrate:e,bitrateMode:s.bitrateMode,...pl(s.codec)}};class Si{constructor(e){this._factor=e}_toVideoBitrate(e,t,i){const r=t*i,n={avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2},o=1920*1080,a=3e6,p=Math.pow(r/o,.95),l=a*p*n[e]*this._factor;return Math.ceil(l/1e3)*1e3}_toAudioBitrate(e){if(Ne.includes(e)||e==="flac")return;const i={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3}[e];if(!i)throw new Error(`Unhandled codec: ${e}`);let r=i*this._factor;return e==="aac"?r=[96e3,128e3,16e4,192e3].reduce((o,a)=>Math.abs(a-r)<Math.abs(o-r)?a:o):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((o,a)=>Math.abs(a-r)<Math.abs(o-r)?a:o)),Math.round(r/1e3)*1e3}}/*!
297
+ */const cw=s=>{if(!s||typeof s!="object")throw new TypeError("Encoding config must be an object.");if(!Ki.includes(s.codec))throw new TypeError(`Invalid video codec '${s.codec}'. Must be one of: ${Ki.join(", ")}.`);if(!(s.bitrate instanceof wn)&&(!Number.isInteger(s.bitrate)||s.bitrate<=0))throw new TypeError("config.bitrate must be a positive integer or a quality.");if(s.keyFrameInterval!==void 0&&(!Number.isFinite(s.keyFrameInterval)||s.keyFrameInterval<0))throw new TypeError("config.keyFrameInterval, when provided, must be a non-negative number.");if(s.sizeChangeBehavior!==void 0&&!["deny","passThrough","fill","contain","cover"].includes(s.sizeChangeBehavior))throw new TypeError("config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.");if(s.onEncodedPacket!==void 0&&typeof s.onEncodedPacket!="function")throw new TypeError("config.onEncodedChunk, when provided, must be a function.");if(s.onEncoderConfig!==void 0&&typeof s.onEncoderConfig!="function")throw new TypeError("config.onEncoderConfig, when provided, must be a function.");uw(s.codec,s)},uw=(s,e)=>{if(!e||typeof e!="object")throw new TypeError("Encoding options must be an object.");if(e.alpha!==void 0&&!["discard","keep"].includes(e.alpha))throw new TypeError("options.alpha, when provided, must be 'discard' or 'keep'.");if(e.bitrateMode!==void 0&&!["constant","variable"].includes(e.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(e.latencyMode!==void 0&&!["quality","realtime"].includes(e.latencyMode))throw new TypeError("latencyMode, when provided, must be 'quality' or 'realtime'.");if(e.fullCodecString!==void 0&&typeof e.fullCodecString!="string")throw new TypeError("fullCodecString, when provided, must be a string.");if(e.fullCodecString!==void 0&&t0(e.fullCodecString)!==s)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${s}).`);if(e.hardwareAcceleration!==void 0&&!["no-preference","prefer-hardware","prefer-software"].includes(e.hardwareAcceleration))throw new TypeError("hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(e.scalabilityMode!==void 0&&typeof e.scalabilityMode!="string")throw new TypeError("scalabilityMode, when provided, must be a string.");if(e.contentHint!==void 0&&typeof e.contentHint!="string")throw new TypeError("contentHint, when provided, must be a string.")},hw=s=>{const e=s.bitrate instanceof wn?s.bitrate._toVideoBitrate(s.codec,s.width,s.height):s.bitrate;return{codec:s.fullCodecString??vv(s.codec,s.width,s.height,e),width:s.width,height:s.height,bitrate:e,bitrateMode:s.bitrateMode,alpha:s.alpha??"discard",framerate:s.framerate,latencyMode:s.latencyMode,hardwareAcceleration:s.hardwareAcceleration,scalabilityMode:s.scalabilityMode,contentHint:s.contentHint,...Cv(s.codec)}},dw=s=>{if(!s||typeof s!="object")throw new TypeError("Encoding config must be an object.");if(!Cr.includes(s.codec))throw new TypeError(`Invalid audio codec '${s.codec}'. Must be one of: ${Cr.join(", ")}.`);if(s.bitrate===void 0&&(!Xt.includes(s.codec)||s.codec==="flac"))throw new TypeError("config.bitrate must be provided for compressed audio codecs.");if(s.bitrate!==void 0&&!(s.bitrate instanceof wn)&&(!Number.isInteger(s.bitrate)||s.bitrate<=0))throw new TypeError("config.bitrate, when provided, must be a positive integer or a quality.");if(s.onEncodedPacket!==void 0&&typeof s.onEncodedPacket!="function")throw new TypeError("config.onEncodedChunk, when provided, must be a function.");if(s.onEncoderConfig!==void 0&&typeof s.onEncoderConfig!="function")throw new TypeError("config.onEncoderConfig, when provided, must be a function.");fw(s.codec,s)},fw=(s,e)=>{if(!e||typeof e!="object")throw new TypeError("Encoding options must be an object.");if(e.bitrateMode!==void 0&&!["constant","variable"].includes(e.bitrateMode))throw new TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");if(e.fullCodecString!==void 0&&typeof e.fullCodecString!="string")throw new TypeError("fullCodecString, when provided, must be a string.");if(e.fullCodecString!==void 0&&t0(e.fullCodecString)!==s)throw new TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${s}).`)},pw=s=>{const e=s.bitrate instanceof wn?s.bitrate._toAudioBitrate(s.codec):s.bitrate;return{codec:s.fullCodecString??xv(s.codec,s.numberOfChannels,s.sampleRate),numberOfChannels:s.numberOfChannels,sampleRate:s.sampleRate,bitrate:e,bitrateMode:s.bitrateMode,...kv(s.codec)}};class wn{constructor(e){this._factor=e}_toVideoBitrate(e,t,i){const r=t*i,n={avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2},a=1920*1080,o=3e6,c=Math.pow(r/a,.95),l=o*c*n[e]*this._factor;return Math.ceil(l/1e3)*1e3}_toAudioBitrate(e){if(Xt.includes(e)||e==="flac")return;const i={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3}[e];if(!i)throw new Error(`Unhandled codec: ${e}`);let r=i*this._factor;return e==="aac"?r=[96e3,128e3,16e4,192e3].reduce((a,o)=>Math.abs(o-r)<Math.abs(a-r)?o:a):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((a,o)=>Math.abs(o-r)<Math.abs(a-r)?o:a)),Math.round(r/1e3)*1e3}}/*!
296
298
  * Copyright (c) 2025-present, Vanilagy and contributors
297
299
  *
298
300
  * This Source Code Form is subject to the terms of the Mozilla Public
299
301
  * License, v. 2.0. If a copy of the MPL was not distributed with this
300
302
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
301
- */class xs{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._timestampOffset=0}_ensureValidAdd(){if(!this._connectedTrack)throw new Error("Source is not connected to an output track.");if(this._connectedTrack.output.state==="canceled")throw new Error("Output has been canceled.");if(this._connectedTrack.output.state==="finalizing"||this._connectedTrack.output.state==="finalized")throw new Error("Output has been finalized.");if(this._connectedTrack.output.state==="pending")throw new Error("Output has not started.");if(this._closed)throw new Error("Source is closed.")}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;const e=this._connectedTrack;if(!e)throw new Error("Cannot call close without connecting the source to an output track.");if(e.output.state==="pending")throw new 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?this._closingPromise:this._flushAndClose(e)}}class vn extends xs{constructor(e){if(super(),this._connectedTrack=null,!bt.includes(e))throw new TypeError(`Invalid video codec '${e}'. Must be one of: ${bt.join(", ")}.`);this._codec=e}}class oh{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.codedWidth=null,this.codedHeight=null,this.resizeCanvas=null,this.customEncoder=null,this.customEncoderCallSerializer=new Br,this.customEncoderQueueSize=0,this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null,this.errorNeedsNewStack=!0}async add(e,t,i){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.codedWidth!==null&&this.codedHeight!==null){if(e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight){const a=this.encodingConfig.sizeChangeBehavior??"deny";if(a!=="passThrough"){if(a==="deny")throw new 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 'strict' in the encoding options.`);{let p=!1;this.resizeCanvas||(typeof document<"u"?(this.resizeCanvas=document.createElement("canvas"),this.resizeCanvas.width=this.codedWidth,this.resizeCanvas.height=this.codedHeight):this.resizeCanvas=new OffscreenCanvas(this.codedWidth,this.codedHeight),p=!0);const m=this.resizeCanvas.getContext("2d",{alpha:ls()});$(m),p||(ls()?(m.fillStyle="black",m.fillRect(0,0,this.codedWidth,this.codedHeight)):m.clearRect(0,0,this.codedWidth,this.codedHeight)),e.drawWithFit(m,{fit:a}),t&&e.close(),e=new vt(this.resizeCanvas,{timestamp:e.timestamp,duration:e.duration,rotation:e.rotation}),t=!0}}}}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),$(this.encoderInitialized);const r=this.encodingConfig.keyFrameInterval??5,n=Math.floor(e.timestamp/r),o={...i,keyFrame:i?.keyFrame||r===0||n!==this.lastMultipleOfKeyFrameInterval};if(this.lastMultipleOfKeyFrameInterval=n,this.customEncoder){this.customEncoderQueueSize++;const a=e.clone(),p=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(a,o)).then(()=>this.customEncoderQueueSize--).catch(m=>this.error??=m).finally(()=>{a.close()});this.customEncoderQueueSize>=4&&await p}else{$(this.encoder);const a=e.toVideoFrame();if(!this.alphaEncoder)this.encoder.encode(a,o),a.close();else if(!!a.format&&!a.format.includes("A")||this.splitterCreationFailed)this.alphaFrameQueue.push(null),this.encoder.encode(a,o),a.close();else{const m=a.displayWidth,d=a.displayHeight;if(!this.splitter)try{this.splitter=new lh(m,d)}catch(l){console.error("Due to an error, only color data will be encoded.",l),this.splitterCreationFailed=!0,this.alphaFrameQueue.push(null),this.encoder.encode(a,o),a.close()}if(this.splitter){const l=this.splitter.extractColor(a),c=this.splitter.extractAlpha(a);this.alphaFrameQueue.push(c),this.encoder.encode(l,o),l.close(),a.close()}}t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(p=>this.encoder.addEventListener("dequeue",p,{once:!0}))}await this.muxer.mutex.currentPromise}finally{t&&e.close()}}ensureEncoder(e){const t=new Error;this.ensureEncoderPromise=(async()=>{const i=sh({width:e.codedWidth,height:e.codedHeight,...this.encodingConfig,framerate:this.source._connectedTrack?.metadata.frameRate});this.encodingConfig.onEncoderConfig?.(i);const r=$l.find(n=>n.supports(this.encodingConfig.codec,i));if(r)this.customEncoder=new r,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=i,this.customEncoder.onPacket=(n,o)=>{if(!(n instanceof ct))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(o!==void 0&&(!o||typeof o!="object"))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(n,o),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,n,o).catch(a=>{this.error??=a,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else{if(typeof VideoEncoder>"u")throw new Error("VideoEncoder is not supported by this browser.");if(i.alpha="discard",this.encodingConfig.alpha==="keep"&&(i.latencyMode="quality"),(i.width%2===1||i.height%2===1)&&(this.encodingConfig.codec==="avc"||this.encodingConfig.codec==="hevc"))throw new Error(`The dimensions ${i.width}x${i.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.`);if(!(await VideoEncoder.isConfigSupported(i)).supported)throw new Error(`This specific encoder configuration (${i.codec}, ${i.bitrate} bps, ${i.width}x${i.height}, hardware acceleration: ${i.hardwareAcceleration??"no-preference"}) is not supported by this browser. Consider using another codec or changing your video parameters.`);const a=[],p=[];let m=0,d=0;const l=(c,u,h)=>{const f={};if(u){const g=new Uint8Array(u.byteLength);u.copyTo(g),f.alpha=g}const b=ct.fromEncodedChunk(c,f);this.encodingConfig.onEncodedPacket?.(b,h),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,b,h).catch(g=>{this.error??=g,this.errorNeedsNewStack=!1})};this.encoder=new VideoEncoder({output:(c,u)=>{if(!this.alphaEncoder){l(c,null,u);return}const h=this.alphaFrameQueue.shift();$(h!==void 0),h?(this.alphaEncoder.encode(h,{keyFrame:c.type==="key"}),d++,h.close(),a.push({chunk:c,meta:u})):d===0?l(c,null,u):(p.push(m+d),a.push({chunk:c,meta:u}))},error:c=>{c.stack=t.stack,this.error??=c}}),this.encoder.configure(i),this.encodingConfig.alpha==="keep"&&(this.alphaEncoder=new VideoEncoder({output:(c,u)=>{d--;const h=a.shift();for($(h!==void 0),l(h.chunk,c,h.meta),m++;p.length>0&&p[0]===m;){p.shift();const f=a.shift();$(f!==void 0),l(f.chunk,null,f.meta)}},error:c=>{c.stack=t.stack,this.error??=c}}),this.alphaEncoder.configure(i))}$(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||(await this.encoder.flush(),await this.alphaEncoder?.flush()),this.encoder.state!=="closed"&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!=="closed"&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(t=>t?.close()),this.splitter?.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=new Error().stack),this.error}}class lh{constructor(e,t){this.lastFrame=null,typeof OffscreenCanvas<"u"?this.canvas=new OffscreenCanvas(e,t):(this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t);const i=this.canvas.getContext("webgl2",{alpha:!0});if(!i)throw new Error("Couldn't acquire WebGL 2 context.");this.gl=i,this.colorProgram=this.createColorProgram(),this.alphaProgram=this.createAlphaProgram(),this.vao=this.createVAO(),this.sourceTexture=this.createTexture(),this.alphaResolutionLocation=this.gl.getUniformLocation(this.alphaProgram,"u_resolution"),this.gl.useProgram(this.colorProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.colorProgram,"u_sourceTexture"),0),this.gl.useProgram(this.alphaProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.alphaProgram,"u_sourceTexture"),0)}createVertexShader(){return this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
303
+ */class yo{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._timestampOffset=0}_ensureValidAdd(){if(!this._connectedTrack)throw new Error("Source is not connected to an output track.");if(this._connectedTrack.output.state==="canceled")throw new Error("Output has been canceled.");if(this._connectedTrack.output.state==="finalizing"||this._connectedTrack.output.state==="finalized")throw new Error("Output has been finalized.");if(this._connectedTrack.output.state==="pending")throw new Error("Output has not started.");if(this._closed)throw new Error("Source is closed.")}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;const e=this._connectedTrack;if(!e)throw new Error("Cannot call close without connecting the source to an output track.");if(e.output.state==="pending")throw new 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?this._closingPromise:this._flushAndClose(e)}}class A0 extends yo{constructor(e){if(super(),this._connectedTrack=null,!Ki.includes(e))throw new TypeError(`Invalid video codec '${e}'. Must be one of: ${Ki.join(", ")}.`);this._codec=e}}class mw{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.codedWidth=null,this.codedHeight=null,this.resizeCanvas=null,this.customEncoder=null,this.customEncoderCallSerializer=new Gu,this.customEncoderQueueSize=0,this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null,this.errorNeedsNewStack=!0}async add(e,t,i){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.codedWidth!==null&&this.codedHeight!==null){if(e.codedWidth!==this.codedWidth||e.codedHeight!==this.codedHeight){const o=this.encodingConfig.sizeChangeBehavior??"deny";if(o!=="passThrough"){if(o==="deny")throw new 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 'strict' in the encoding options.`);{let c=!1;this.resizeCanvas||(typeof document<"u"?(this.resizeCanvas=document.createElement("canvas"),this.resizeCanvas.width=this.codedWidth,this.resizeCanvas.height=this.codedHeight):this.resizeCanvas=new OffscreenCanvas(this.codedWidth,this.codedHeight),c=!0);const u=this.resizeCanvas.getContext("2d",{alpha:to()});q(u),c||(to()?(u.fillStyle="black",u.fillRect(0,0,this.codedWidth,this.codedHeight)):u.clearRect(0,0,this.codedWidth,this.codedHeight)),e.drawWithFit(u,{fit:o}),t&&e.close(),e=new Yi(this.resizeCanvas,{timestamp:e.timestamp,duration:e.duration,rotation:e.rotation}),t=!0}}}}else this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight;this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),q(this.encoderInitialized);const r=this.encodingConfig.keyFrameInterval??5,n=Math.floor(e.timestamp/r),a={...i,keyFrame:i?.keyFrame||r===0||n!==this.lastMultipleOfKeyFrameInterval};if(this.lastMultipleOfKeyFrameInterval=n,this.customEncoder){this.customEncoderQueueSize++;const o=e.clone(),c=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(o,a)).then(()=>this.customEncoderQueueSize--).catch(u=>this.error??=u).finally(()=>{o.close()});this.customEncoderQueueSize>=4&&await c}else{q(this.encoder);const o=e.toVideoFrame();if(!this.alphaEncoder)this.encoder.encode(o,a),o.close();else if(!!o.format&&!o.format.includes("A")||this.splitterCreationFailed)this.alphaFrameQueue.push(null),this.encoder.encode(o,a),o.close();else{const u=o.displayWidth,h=o.displayHeight;if(!this.splitter)try{this.splitter=new gw(u,h)}catch(l){console.error("Due to an error, only color data will be encoded.",l),this.splitterCreationFailed=!0,this.alphaFrameQueue.push(null),this.encoder.encode(o,a),o.close()}if(this.splitter){const l=this.splitter.extractColor(o),d=this.splitter.extractAlpha(o);this.alphaFrameQueue.push(d),this.encoder.encode(l,a),l.close(),o.close()}}t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(c=>this.encoder.addEventListener("dequeue",c,{once:!0}))}await this.muxer.mutex.currentPromise}finally{t&&e.close()}}ensureEncoder(e){const t=new Error;this.ensureEncoderPromise=(async()=>{const i=hw({width:e.codedWidth,height:e.codedHeight,...this.encodingConfig,framerate:this.source._connectedTrack?.metadata.frameRate});this.encodingConfig.onEncoderConfig?.(i);const r=Gv.find(n=>n.supports(this.encodingConfig.codec,i));if(r)this.customEncoder=new r,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=i,this.customEncoder.onPacket=(n,a)=>{if(!(n instanceof Oi))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(a!==void 0&&(!a||typeof a!="object"))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(n,a),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,n,a).catch(o=>{this.error??=o,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else{if(typeof VideoEncoder>"u")throw new Error("VideoEncoder is not supported by this browser.");if(i.alpha="discard",this.encodingConfig.alpha==="keep"&&(i.latencyMode="quality"),(i.width%2===1||i.height%2===1)&&(this.encodingConfig.codec==="avc"||this.encodingConfig.codec==="hevc"))throw new Error(`The dimensions ${i.width}x${i.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.`);if(!(await VideoEncoder.isConfigSupported(i)).supported)throw new Error(`This specific encoder configuration (${i.codec}, ${i.bitrate} bps, ${i.width}x${i.height}, hardware acceleration: ${i.hardwareAcceleration??"no-preference"}) is not supported by this browser. Consider using another codec or changing your video parameters.`);const o=[],c=[];let u=0,h=0;const l=(d,f,p)=>{const m={};if(f){const g=new Uint8Array(f.byteLength);f.copyTo(g),m.alpha=g}const b=Oi.fromEncodedChunk(d,m);this.encodingConfig.onEncodedPacket?.(b,p),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,b,p).catch(g=>{this.error??=g,this.errorNeedsNewStack=!1})};this.encoder=new VideoEncoder({output:(d,f)=>{if(!this.alphaEncoder){l(d,null,f);return}const p=this.alphaFrameQueue.shift();q(p!==void 0),p?(this.alphaEncoder.encode(p,{keyFrame:d.type==="key"}),h++,p.close(),o.push({chunk:d,meta:f})):h===0?l(d,null,f):(c.push(u+h),o.push({chunk:d,meta:f}))},error:d=>{d.stack=t.stack,this.error??=d}}),this.encoder.configure(i),this.encodingConfig.alpha==="keep"&&(this.alphaEncoder=new VideoEncoder({output:(d,f)=>{h--;const p=o.shift();for(q(p!==void 0),l(p.chunk,d,p.meta),u++;c.length>0&&c[0]===u;){c.shift();const m=o.shift();q(m!==void 0),l(m.chunk,null,m.meta)}},error:d=>{d.stack=t.stack,this.error??=d}}),this.alphaEncoder.configure(i))}q(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||(await this.encoder.flush(),await this.alphaEncoder?.flush()),this.encoder.state!=="closed"&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!=="closed"&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(t=>t?.close()),this.splitter?.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=new Error().stack),this.error}}class gw{constructor(e,t){this.lastFrame=null,typeof OffscreenCanvas<"u"?this.canvas=new OffscreenCanvas(e,t):(this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t);const i=this.canvas.getContext("webgl2",{alpha:!0});if(!i)throw new Error("Couldn't acquire WebGL 2 context.");this.gl=i,this.colorProgram=this.createColorProgram(),this.alphaProgram=this.createAlphaProgram(),this.vao=this.createVAO(),this.sourceTexture=this.createTexture(),this.alphaResolutionLocation=this.gl.getUniformLocation(this.alphaProgram,"u_resolution"),this.gl.useProgram(this.colorProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.colorProgram,"u_sourceTexture"),0),this.gl.useProgram(this.alphaProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.alphaProgram,"u_sourceTexture"),0)}createVertexShader(){return this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
302
304
  in vec2 a_position;
303
305
  in vec2 a_texCoord;
304
306
  out vec2 v_texCoord;
@@ -362,10 +364,10 @@ const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,Qn=Object.defineProperty
362
364
 
363
365
  fragColor = result;
364
366
  }
365
- `),i=this.gl.createProgram();return this.gl.attachShader(i,e),this.gl.attachShader(i,t),this.gl.linkProgram(i),i}createShader(e,t){const i=this.gl.createShader(e);return this.gl.shaderSource(i,t),this.gl.compileShader(i),this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS)||console.error("Shader compile error:",this.gl.getShaderInfoLog(i)),i}createVAO(){const e=this.gl.createVertexArray();this.gl.bindVertexArray(e);const t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),i=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,i),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW);const r=this.gl.getAttribLocation(this.colorProgram,"a_position"),n=this.gl.getAttribLocation(this.colorProgram,"a_texCoord");return this.gl.enableVertexAttribArray(r),this.gl.vertexAttribPointer(r,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(n),this.gl.vertexAttribPointer(n,2,this.gl.FLOAT,!1,16,8),e}createTexture(){const e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}updateTexture(e){this.lastFrame!==e&&((e.displayWidth!==this.canvas.width||e.displayHeight!==this.canvas.height)&&(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.lastFrame=e)}extractColor(e){return this.updateTexture(e),this.gl.useProgram(this.colorProgram),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),new VideoFrame(this.canvas,{timestamp:e.timestamp,duration:e.duration??void 0,alpha:"discard"})}extractAlpha(e){this.updateTexture(e),this.gl.useProgram(this.alphaProgram),this.gl.uniform2f(this.alphaResolutionLocation,this.canvas.width,this.canvas.height),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);const{width:t,height:i}=this.canvas,r=Math.ceil(t/2)*Math.ceil(i/2),n=t*i+r*2,o=Math.ceil(n/(t*4));let a=new Uint8Array(4*t*o);this.gl.readPixels(0,0,t,o,this.gl.RGBA,this.gl.UNSIGNED_BYTE,a),a=a.subarray(0,n),$(a[t*i]===128),$(a[a.length-1]===128);const p={format:"I420",codedWidth:t,codedHeight:i,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[a.buffer]};return new VideoFrame(a,p)}close(){this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null}}class ch extends vn{constructor(e,t){if(!(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas))throw new TypeError("canvas must be an HTMLCanvasElement or OffscreenCanvas.");th(t),super(t.codec),this._encoder=new oh(this,t),this._canvas=e}add(e,t=0,i){if(!Number.isFinite(e)||e<0)throw new TypeError("timestamp must be a non-negative number.");if(!Number.isFinite(t)||t<0)throw new TypeError("duration must be a non-negative number.");const r=new vt(this._canvas,{timestamp:e,duration:t});return this._encoder.add(r,!0,i)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class wn extends xs{constructor(e){if(super(),this._connectedTrack=null,!Mt.includes(e))throw new TypeError(`Invalid audio codec '${e}'. Must be one of: ${Mt.join(", ")}.`);this._codec=e}}class hh{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastNumberOfChannels=null,this.lastSampleRate=null,this.isPcmEncoder=!1,this.outputSampleSize=null,this.writeOutputValue=null,this.customEncoder=null,this.customEncoderCallSerializer=new Br,this.customEncoderQueueSize=0,this.error=null,this.errorNeedsNewStack=!0}async add(e,t){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.lastNumberOfChannels!==null&&this.lastSampleRate!==null){if(e.numberOfChannels!==this.lastNumberOfChannels||e.sampleRate!==this.lastSampleRate)throw new Error(`Audio parameters must remain constant. Expected ${this.lastNumberOfChannels} channels at ${this.lastSampleRate} Hz, got ${e.numberOfChannels} channels at ${e.sampleRate} Hz.`)}else this.lastNumberOfChannels=e.numberOfChannels,this.lastSampleRate=e.sampleRate;if(this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),$(this.encoderInitialized),this.customEncoder){this.customEncoderQueueSize++;const i=e.clone(),r=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(i)).then(()=>this.customEncoderQueueSize--).catch(n=>this.error??=n).finally(()=>{i.close()});this.customEncoderQueueSize>=4&&await r,await this.muxer.mutex.currentPromise}else if(this.isPcmEncoder)await this.doPcmEncoding(e,t);else{$(this.encoder);const i=e.toAudioData();this.encoder.encode(i),i.close(),t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(r=>this.encoder.addEventListener("dequeue",r,{once:!0})),await this.muxer.mutex.currentPromise}}finally{t&&e.close()}}async doPcmEncoding(e,t){$(this.outputSampleSize),$(this.writeOutputValue);const{numberOfChannels:i,numberOfFrames:r,sampleRate:n,timestamp:o}=e,a=2048,p=[];for(let c=0;c<r;c+=a){const u=Math.min(a,e.numberOfFrames-c),h=u*i*this.outputSampleSize,f=new ArrayBuffer(h),b=new DataView(f);p.push({frameCount:u,view:b})}const m=e.allocationSize({planeIndex:0,format:"f32-planar"}),d=new Float32Array(m/Float32Array.BYTES_PER_ELEMENT);for(let c=0;c<i;c++){e.copyTo(d,{planeIndex:c,format:"f32-planar"});for(let u=0;u<p.length;u++){const{frameCount:h,view:f}=p[u];for(let b=0;b<h;b++)this.writeOutputValue(f,(b*i+c)*this.outputSampleSize,d[u*a+b])}}t&&e.close();const l={decoderConfig:{codec:this.encodingConfig.codec,numberOfChannels:i,sampleRate:n}};for(let c=0;c<p.length;c++){const{frameCount:u,view:h}=p[c],f=h.buffer,b=c*a,g=new ct(new Uint8Array(f),"key",o+b/n,u/n);this.encodingConfig.onEncodedPacket?.(g,l),await this.muxer.addEncodedAudioPacket(this.source._connectedTrack,g,l)}}ensureEncoder(e){const t=new Error;this.ensureEncoderPromise=(async()=>{const{numberOfChannels:i,sampleRate:r}=e,n=ah({numberOfChannels:i,sampleRate:r,...this.encodingConfig});this.encodingConfig.onEncoderConfig?.(n);const o=Dl.find(a=>a.supports(this.encodingConfig.codec,n));if(o)this.customEncoder=new o,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=n,this.customEncoder.onPacket=(a,p)=>{if(!(a instanceof ct))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(p!==void 0&&(!p||typeof p!="object"))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(a,p),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,a,p).catch(m=>{this.error??=m,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else if(Ne.includes(this.encodingConfig.codec))this.initPcmEncoder();else{if(typeof AudioEncoder>"u")throw new Error("AudioEncoder is not supported by this browser.");if(!(await AudioEncoder.isConfigSupported(n)).supported)throw new Error(`This specific encoder configuration (${n.codec}, ${n.bitrate} bps, ${n.numberOfChannels} channels, ${n.sampleRate} Hz) is not supported by this browser. Consider using another codec or changing your audio parameters.`);this.encoder=new AudioEncoder({output:(p,m)=>{const d=ct.fromEncodedChunk(p);this.encodingConfig.onEncodedPacket?.(d,m),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,d,m).catch(l=>{this.error??=l,this.errorNeedsNewStack=!1})},error:p=>{p.stack=t.stack,this.error??=p}}),this.encoder.configure(n)}$(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}initPcmEncoder(){this.isPcmEncoder=!0;const e=this.encodingConfig.codec,{dataType:t,sampleSize:i,littleEndian:r}=Lt(e);switch(this.outputSampleSize=i,i){case 1:t==="unsigned"?this.writeOutputValue=(n,o,a)=>n.setUint8(o,Se((a+1)*127.5,0,255)):t==="signed"?this.writeOutputValue=(n,o,a)=>{n.setInt8(o,Se(Math.round(a*128),-128,127))}:t==="ulaw"?this.writeOutputValue=(n,o,a)=>{const p=Se(Math.floor(a*32767),-32768,32767);n.setUint8(o,zl(p))}:t==="alaw"?this.writeOutputValue=(n,o,a)=>{const p=Se(Math.floor(a*32767),-32768,32767);n.setUint8(o,Hl(p))}:$(!1);break;case 2:t==="unsigned"?this.writeOutputValue=(n,o,a)=>n.setUint16(o,Se((a+1)*32767.5,0,65535),r):t==="signed"?this.writeOutputValue=(n,o,a)=>n.setInt16(o,Se(Math.round(a*32767),-32768,32767),r):$(!1);break;case 3:t==="unsigned"?this.writeOutputValue=(n,o,a)=>Lr(n,o,Se((a+1)*83886075e-1,0,16777215),r):t==="signed"?this.writeOutputValue=(n,o,a)=>il(n,o,Se(Math.round(a*8388607),-8388608,8388607),r):$(!1);break;case 4:t==="unsigned"?this.writeOutputValue=(n,o,a)=>n.setUint32(o,Se((a+1)*21474836475e-1,0,4294967295),r):t==="signed"?this.writeOutputValue=(n,o,a)=>n.setInt32(o,Se(Math.round(a*2147483647),-2147483648,2147483647),r):t==="float"?this.writeOutputValue=(n,o,a)=>n.setFloat32(o,a,r):$(!1);break;case 8:t==="float"?this.writeOutputValue=(n,o,a)=>n.setFloat64(o,a,r):$(!1);break;default:as(i),$(!1)}}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||await this.encoder.flush(),this.encoder.state!=="closed"&&this.encoder.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.isPcmEncoder?0:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=new Error().stack),this.error}}class uh extends wn{constructor(e){rh(e),super(e.codec),this._encoder=new hh(this,e)}add(e){if(!(e instanceof wt))throw new TypeError("audioSample must be an AudioSample.");return this._encoder.add(e,!1)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class dh extends xs{constructor(e){if(super(),this._connectedTrack=null,!Ci.includes(e))throw new TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${Ci.join(", ")}.`);this._codec=e}}/*!
367
+ `),i=this.gl.createProgram();return this.gl.attachShader(i,e),this.gl.attachShader(i,t),this.gl.linkProgram(i),i}createShader(e,t){const i=this.gl.createShader(e);return this.gl.shaderSource(i,t),this.gl.compileShader(i),this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS)||console.error("Shader compile error:",this.gl.getShaderInfoLog(i)),i}createVAO(){const e=this.gl.createVertexArray();this.gl.bindVertexArray(e);const t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),i=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,i),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW);const r=this.gl.getAttribLocation(this.colorProgram,"a_position"),n=this.gl.getAttribLocation(this.colorProgram,"a_texCoord");return this.gl.enableVertexAttribArray(r),this.gl.vertexAttribPointer(r,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(n),this.gl.vertexAttribPointer(n,2,this.gl.FLOAT,!1,16,8),e}createTexture(){const e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}updateTexture(e){this.lastFrame!==e&&((e.displayWidth!==this.canvas.width||e.displayHeight!==this.canvas.height)&&(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.lastFrame=e)}extractColor(e){return this.updateTexture(e),this.gl.useProgram(this.colorProgram),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),new VideoFrame(this.canvas,{timestamp:e.timestamp,duration:e.duration??void 0,alpha:"discard"})}extractAlpha(e){this.updateTexture(e),this.gl.useProgram(this.alphaProgram),this.gl.uniform2f(this.alphaResolutionLocation,this.canvas.width,this.canvas.height),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);const{width:t,height:i}=this.canvas,r=Math.ceil(t/2)*Math.ceil(i/2),n=t*i+r*2,a=Math.ceil(n/(t*4));let o=new Uint8Array(4*t*a);this.gl.readPixels(0,0,t,a,this.gl.RGBA,this.gl.UNSIGNED_BYTE,o),o=o.subarray(0,n),q(o[t*i]===128),q(o[o.length-1]===128);const c={format:"I420",codedWidth:t,codedHeight:i,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[o.buffer]};return new VideoFrame(o,c)}close(){this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null}}class yw extends A0{constructor(e,t){if(!(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas))throw new TypeError("canvas must be an HTMLCanvasElement or OffscreenCanvas.");cw(t),super(t.codec),this._encoder=new mw(this,t),this._canvas=e}add(e,t=0,i){if(!Number.isFinite(e)||e<0)throw new TypeError("timestamp must be a non-negative number.");if(!Number.isFinite(t)||t<0)throw new TypeError("duration must be a non-negative number.");const r=new Yi(this._canvas,{timestamp:e,duration:t});return this._encoder.add(r,!0,i)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class I0 extends yo{constructor(e){if(super(),this._connectedTrack=null,!Cr.includes(e))throw new TypeError(`Invalid audio codec '${e}'. Must be one of: ${Cr.join(", ")}.`);this._codec=e}}class bw{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastNumberOfChannels=null,this.lastSampleRate=null,this.isPcmEncoder=!1,this.outputSampleSize=null,this.writeOutputValue=null,this.customEncoder=null,this.customEncoderCallSerializer=new Gu,this.customEncoderQueueSize=0,this.error=null,this.errorNeedsNewStack=!0}async add(e,t){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.lastNumberOfChannels!==null&&this.lastSampleRate!==null){if(e.numberOfChannels!==this.lastNumberOfChannels||e.sampleRate!==this.lastSampleRate)throw new Error(`Audio parameters must remain constant. Expected ${this.lastNumberOfChannels} channels at ${this.lastSampleRate} Hz, got ${e.numberOfChannels} channels at ${e.sampleRate} Hz.`)}else this.lastNumberOfChannels=e.numberOfChannels,this.lastSampleRate=e.sampleRate;if(this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),q(this.encoderInitialized),this.customEncoder){this.customEncoderQueueSize++;const i=e.clone(),r=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(i)).then(()=>this.customEncoderQueueSize--).catch(n=>this.error??=n).finally(()=>{i.close()});this.customEncoderQueueSize>=4&&await r,await this.muxer.mutex.currentPromise}else if(this.isPcmEncoder)await this.doPcmEncoding(e,t);else{q(this.encoder);const i=e.toAudioData();this.encoder.encode(i),i.close(),t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(r=>this.encoder.addEventListener("dequeue",r,{once:!0})),await this.muxer.mutex.currentPromise}}finally{t&&e.close()}}async doPcmEncoding(e,t){q(this.outputSampleSize),q(this.writeOutputValue);const{numberOfChannels:i,numberOfFrames:r,sampleRate:n,timestamp:a}=e,o=2048,c=[];for(let d=0;d<r;d+=o){const f=Math.min(o,e.numberOfFrames-d),p=f*i*this.outputSampleSize,m=new ArrayBuffer(p),b=new DataView(m);c.push({frameCount:f,view:b})}const u=e.allocationSize({planeIndex:0,format:"f32-planar"}),h=new Float32Array(u/Float32Array.BYTES_PER_ELEMENT);for(let d=0;d<i;d++){e.copyTo(h,{planeIndex:d,format:"f32-planar"});for(let f=0;f<c.length;f++){const{frameCount:p,view:m}=c[f];for(let b=0;b<p;b++)this.writeOutputValue(m,(b*i+d)*this.outputSampleSize,h[f*o+b])}}t&&e.close();const l={decoderConfig:{codec:this.encodingConfig.codec,numberOfChannels:i,sampleRate:n}};for(let d=0;d<c.length;d++){const{frameCount:f,view:p}=c[d],m=p.buffer,b=d*o,g=new Oi(new Uint8Array(m),"key",a+b/n,f/n);this.encodingConfig.onEncodedPacket?.(g,l),await this.muxer.addEncodedAudioPacket(this.source._connectedTrack,g,l)}}ensureEncoder(e){const t=new Error;this.ensureEncoderPromise=(async()=>{const{numberOfChannels:i,sampleRate:r}=e,n=pw({numberOfChannels:i,sampleRate:r,...this.encodingConfig});this.encodingConfig.onEncoderConfig?.(n);const a=qv.find(o=>o.supports(this.encodingConfig.codec,n));if(a)this.customEncoder=new a,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=n,this.customEncoder.onPacket=(o,c)=>{if(!(o instanceof Oi))throw new TypeError("The first argument passed to onPacket must be an EncodedPacket.");if(c!==void 0&&(!c||typeof c!="object"))throw new TypeError("The second argument passed to onPacket must be an object or undefined.");this.encodingConfig.onEncodedPacket?.(o,c),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,o,c).catch(u=>{this.error??=u,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else if(Xt.includes(this.encodingConfig.codec))this.initPcmEncoder();else{if(typeof AudioEncoder>"u")throw new Error("AudioEncoder is not supported by this browser.");if(!(await AudioEncoder.isConfigSupported(n)).supported)throw new Error(`This specific encoder configuration (${n.codec}, ${n.bitrate} bps, ${n.numberOfChannels} channels, ${n.sampleRate} Hz) is not supported by this browser. Consider using another codec or changing your audio parameters.`);this.encoder=new AudioEncoder({output:(c,u)=>{const h=Oi.fromEncodedChunk(c);this.encodingConfig.onEncodedPacket?.(h,u),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,h,u).catch(l=>{this.error??=l,this.errorNeedsNewStack=!1})},error:c=>{c.stack=t.stack,this.error??=c}}),this.encoder.configure(n)}q(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}initPcmEncoder(){this.isPcmEncoder=!0;const e=this.encodingConfig.codec,{dataType:t,sampleSize:i,littleEndian:r}=kr(e);switch(this.outputSampleSize=i,i){case 1:t==="unsigned"?this.writeOutputValue=(n,a,o)=>n.setUint8(a,mt((o+1)*127.5,0,255)):t==="signed"?this.writeOutputValue=(n,a,o)=>{n.setInt8(a,mt(Math.round(o*128),-128,127))}:t==="ulaw"?this.writeOutputValue=(n,a,o)=>{const c=mt(Math.floor(o*32767),-32768,32767);n.setUint8(a,Xv(c))}:t==="alaw"?this.writeOutputValue=(n,a,o)=>{const c=mt(Math.floor(o*32767),-32768,32767);n.setUint8(a,Zv(c))}:q(!1);break;case 2:t==="unsigned"?this.writeOutputValue=(n,a,o)=>n.setUint16(a,mt((o+1)*32767.5,0,65535),r):t==="signed"?this.writeOutputValue=(n,a,o)=>n.setInt16(a,mt(Math.round(o*32767),-32768,32767),r):q(!1);break;case 3:t==="unsigned"?this.writeOutputValue=(n,a,o)=>Wu(n,a,mt((o+1)*83886075e-1,0,16777215),r):t==="signed"?this.writeOutputValue=(n,a,o)=>hv(n,a,mt(Math.round(o*8388607),-8388608,8388607),r):q(!1);break;case 4:t==="unsigned"?this.writeOutputValue=(n,a,o)=>n.setUint32(a,mt((o+1)*21474836475e-1,0,4294967295),r):t==="signed"?this.writeOutputValue=(n,a,o)=>n.setInt32(a,mt(Math.round(o*2147483647),-2147483648,2147483647),r):t==="float"?this.writeOutputValue=(n,a,o)=>n.setFloat32(a,o,r):q(!1);break;case 8:t==="float"?this.writeOutputValue=(n,a,o)=>n.setFloat64(a,o,r):q(!1);break;default:Qa(i),q(!1)}}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||await this.encoder.flush(),this.encoder.state!=="closed"&&this.encoder.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.isPcmEncoder?0:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=new Error().stack),this.error}}class vw extends I0{constructor(e){dw(e),super(e.codec),this._encoder=new bw(this,e)}add(e){if(!(e instanceof Ji))throw new TypeError("audioSample must be an AudioSample.");return this._encoder.add(e,!1)}_flushAndClose(e){return this._encoder.flushAndClose(e)}}class ww extends yo{constructor(e){if(super(),this._connectedTrack=null,!yn.includes(e))throw new TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${yn.join(", ")}.`);this._codec=e}}/*!
366
368
  * Copyright (c) 2025-present, Vanilagy and contributors
367
369
  *
368
370
  * This Source Code Form is subject to the terms of the Mozilla Public
369
371
  * License, v. 2.0. If a copy of the MPL was not distributed with this
370
372
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
371
- */const fh=["video","audio","subtitle"],Cs=s=>{if(!s||typeof s!="object")throw new TypeError("metadata must be an object.");if(s.languageCode!==void 0&&!nl(s.languageCode))throw new TypeError("metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.");if(s.name!==void 0&&typeof s.name!="string")throw new TypeError("metadata.name, when provided, must be a string.");if(s.maximumPacketCount!==void 0&&(!Number.isInteger(s.maximumPacketCount)||s.maximumPacketCount<0))throw new TypeError("metadata.maximumPacketCount, when provided, must be a non-negative integer.")};class ph{constructor(e){if(this.state="pending",this._tracks=[],this._startPromise=null,this._cancelPromise=null,this._finalizePromise=null,this._mutex=new Mr,this._metadataTags={},!e||typeof e!="object")throw new TypeError("options must be an object.");if(!(e.format instanceof mn))throw new TypeError("options.format must be an OutputFormat.");if(!(e.target instanceof fn))throw new TypeError("options.target must be a Target.");if(e.target._output)throw new Error("Target is already used for another output.");e.target._output=this,this.format=e.format,this.target=e.target,this._writer=e.target._createWriter(),this._muxer=e.format._createMuxer(this)}addVideoTrack(e,t={}){if(!(e instanceof vn))throw new TypeError("source must be a VideoSource.");if(Cs(t),t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);if(!this.format.supportsVideoRotationMetadata&&t.rotation)throw new Error(`${this.format._name} does not support video rotation metadata.`);if(t.frameRate!==void 0&&(!Number.isFinite(t.frameRate)||t.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);this._addTrack("video",e,t)}addAudioTrack(e,t={}){if(!(e instanceof wn))throw new TypeError("source must be an AudioSource.");Cs(t),this._addTrack("audio",e,t)}addSubtitleTrack(e,t={}){if(!(e instanceof dh))throw new TypeError("source must be a SubtitleSource.");Cs(t),this._addTrack("subtitle",e,t)}setMetadataTags(e){if(cl(e),this.state!=="pending")throw new Error("Cannot set metadata tags after output has been started or canceled.");this._metadataTags=e}_addTrack(e,t,i){if(this.state!=="pending")throw new Error("Cannot add track after output has been started or canceled.");if(t._connectedTrack)throw new Error("Source is already used for a track.");const r=this.format.getSupportedTrackCounts(),n=this._tracks.reduce((m,d)=>m+(d.type===e?1:0),0),o=r[e].max;if(n===o)throw new Error(o===0?`${this.format._name} does not support ${e} tracks.`:`${this.format._name} does not support more than ${o} ${e} track${o===1?"":"s"}.`);const a=r.total.max;if(this._tracks.length===a)throw new Error(`${this.format._name} does not support more than ${a} tracks${a===1?"":"s"} in total.`);const p={id:this._tracks.length+1,output:this,type:e,source:t,metadata:i};if(p.type==="video"){const m=this.format.getSupportedVideoCodecs();if(m.length===0)throw new Error(`${this.format._name} does not support video tracks.`+this.format._codecUnsupportedHint(p.source._codec));if(!m.includes(p.source._codec))throw new Error(`Codec '${p.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${m.map(d=>`'${d}'`).join(", ")}.`+this.format._codecUnsupportedHint(p.source._codec))}else if(p.type==="audio"){const m=this.format.getSupportedAudioCodecs();if(m.length===0)throw new Error(`${this.format._name} does not support audio tracks.`+this.format._codecUnsupportedHint(p.source._codec));if(!m.includes(p.source._codec))throw new Error(`Codec '${p.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${m.map(d=>`'${d}'`).join(", ")}.`+this.format._codecUnsupportedHint(p.source._codec))}else if(p.type==="subtitle"){const m=this.format.getSupportedSubtitleCodecs();if(m.length===0)throw new Error(`${this.format._name} does not support subtitle tracks.`+this.format._codecUnsupportedHint(p.source._codec));if(!m.includes(p.source._codec))throw new Error(`Codec '${p.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${m.map(d=>`'${d}'`).join(", ")}.`+this.format._codecUnsupportedHint(p.source._codec))}this._tracks.push(p),t._connectedTrack=p}async start(){const e=this.format.getSupportedTrackCounts();for(const i of fh){const r=this._tracks.reduce((o,a)=>o+(a.type===i?1:0),0),n=e[i].min;if(r<n)throw new Error(n===e[i].max?`${this.format._name} requires exactly ${n} ${i} track${n===1?"":"s"}.`:`${this.format._name} requires at least ${n} ${i} track${n===1?"":"s"}.`)}const t=e.total.min;if(this._tracks.length<t)throw new 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 new Error("Output has been canceled.");return this._startPromise?(console.warn("Output has already been started."),this._startPromise):this._startPromise=(async()=>{this.state="started",this._writer.start();const i=await this._mutex.acquire();await this._muxer.start();const r=this._tracks.map(n=>n.source._start());await Promise.all(r),i()})()}getMimeType(){return this._muxer.getMimeType()}async cancel(){if(this._cancelPromise)return console.warn("Output has already been canceled."),this._cancelPromise;if(this.state==="finalizing"||this.state==="finalized"){console.warn("Output has already been finalized.");return}return this._cancelPromise=(async()=>{this.state="canceled";const e=await this._mutex.acquire(),t=this._tracks.map(i=>i.source._flushOrWaitForOngoingClose(!0));await Promise.all(t),await this._writer.close(),e()})()}async finalize(){if(this.state==="pending")throw new Error("Cannot finalize before starting.");if(this.state==="canceled")throw new Error("Cannot finalize after canceling.");return this._finalizePromise?(console.warn("Output has already been finalized."),this._finalizePromise):this._finalizePromise=(async()=>{this.state="finalizing";const e=await this._mutex.acquire(),t=this._tracks.map(i=>i.source._flushOrWaitForOngoingClose(!1));await Promise.all(t),await this._muxer.finalize(),await this._writer.flush(),await this._writer.finalize(),this.state="finalized",e()})()}}class mh{audioTracks=[];async setupAudioTracks(e,t){const i=this.findAudioPlayers(e);if(!i.length)return null;this.audioTracks=[];for(const n of i){const o=await this.processAudioTrack(n);o&&this.audioTracks.push(o)}if(!this.audioTracks.length)return null;const r=new uh({codec:"aac",bitrate:128e3});return t.addAudioTrack(r),r}async processAudioSamples(e){if(!this.audioTracks?.length)return;const t=new AudioContext;for(const i of this.audioTracks){const r=await t.decodeAudioData(i.data.slice(0)),{numberOfChannels:n,sampleRate:o,length:a}=r,p=Math.min(a,Math.floor(o*i.duration/1e3)),m=new Float32Array(p*n);for(let d=0;d<n;d+=1){const l=r.getChannelData(d);for(let c=0;c<p;c+=1)m[c*n+d]=l[c]*i.volume}await e.add(new wt({data:m,format:"f32",numberOfChannels:n,sampleRate:o,timestamp:i.start/1e3}))}this.audioTracks=[]}findAudioPlayers(e){const t=[];for(const i of e)for(const r of i)this.isAudioPlayer(r)&&!t.includes(r)&&t.push(r);return t}async processAudioTrack(e){try{const t=e.clipConfiguration?.asset;if(!t?.src)return null;const i=await fetch(t.src);return i.ok?{data:await i.arrayBuffer(),start:e.getStart(),duration:e.getLength(),volume:e.getVolume()}:null}catch(t){return console.warn("Failed to process audio track:",t),null}}isAudioPlayer(e){if(e instanceof Os)return!0;if(!e||typeof e!="object")return!1;const t=e,i=t.constructor?.name==="AudioPlayer",o=t.clipConfiguration?.asset?.type==="audio";return i||o}}class gh{overlay=null;bar=null;percent=null;status=null;create(){this.overlay=Object.assign(document.createElement("div"),{style:"position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:9999;display:flex;justify-content:center;align-items:center;color:white;font-family:Arial"});const e=Object.assign(document.createElement("div"),{style:"background:#222;border-radius:8px;padding:20px;box-shadow:0 4px 8px rgba(0,0,0,0.2);width:300px;text-align:center"});e.innerHTML='<h3 style="margin:0 0 15px 0;font-weight:normal">Exporting Video</h3>',this.status=Object.assign(document.createElement("div"),{style:"font-size:12px;margin-bottom:10px;opacity:0.8"}),e.appendChild(this.status);const t=Object.assign(document.createElement("div"),{style:"width:100%;height:6px;background:#444;border-radius:3px;overflow:hidden;margin-bottom:10px"});this.bar=Object.assign(document.createElement("div"),{style:"width:0%;height:100%;background:#3498db;transition:width 0.3s"}),t.appendChild(this.bar),e.appendChild(t),this.percent=Object.assign(document.createElement("div"),{style:"font-size:12px",innerText:"0%"}),e.appendChild(this.percent),this.overlay.appendChild(e),document.body.appendChild(this.overlay)}update(e,t,i){if(!this.overlay)return;const r=Math.round(e/t*100);this.bar&&(this.bar.style.width=`${r}%`),this.percent&&(this.percent.innerText=`${r}%`),this.status&&i&&(this.status.innerText=i)}remove(){this.overlay?.remove(),this.overlay=null,this.bar=null,this.percent=null,this.status=null}}class _n extends Map{constructor(e){super(),this.maxSize=e}get(e){const t=super.get(e);if(t!==void 0)return super.delete(e),super.set(e,t),t}set(e,t){if(super.delete(e),super.set(e,t),this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}class Ei extends Error{constructor(e,t="unknown",i={},r){super(e),this.phase=t,this.context=i,this.name="ExportError",this.cause=r}}class yh extends Ei{constructor(e,t){super(e,"initialization",{missingFeatures:t}),this.name="BrowserCompatibilityError"}}function xn(s){if(!s||typeof s!="object")return!1;const e=s,t=e.constructor?.name==="VideoPlayer",r=e.texture?.source?.resource instanceof HTMLVideoElement;return e.constructor?.name==="RichTextPlayer"?!1:t||r}class bh{frameCache=new _n(10);textureCache=new _n(5);videoElements=new Map;extractionCanvas=null;extractionContext=null;async initialize(e){for(const t of e)if(xn(t)){const i=t,r=i.texture?.source?.resource;r&&this.videoElements.set(this.getVideoKey(i),{element:r,player:i})}this.extractionCanvas=document.createElement("canvas"),this.extractionCanvas.width=3840,this.extractionCanvas.height=2160,this.extractionContext=this.extractionCanvas.getContext("2d",{willReadFrequently:!0,alpha:!0})}async extractFrame(e,t){const i=`${e}-${t}`,r=this.frameCache.get(i);if(r)return r;const n=this.videoElements.get(e);if(!n||!this.extractionContext||!this.extractionCanvas)return null;try{const{element:o,player:a}=n,p=(t-(a.getStart?.()||0))/1e3+(a.clipConfiguration?.asset?.trim||0);await this.seekToTime(o,p);const m=o.videoWidth||o.width||1920,d=o.videoHeight||o.height||1080;this.extractionContext.clearRect(0,0,m,d),this.extractionContext.drawImage(o,0,0,m,d);const l=this.extractionContext.getImageData(0,0,m,d);return this.frameCache.set(i,l),l}catch{return null}}async replaceVideoTexture(e,t){const i=await this.extractFrame(this.getVideoKey(e),t);if(!i)return;const r=`${this.getVideoKey(e)}-${t}`;let n=this.textureCache.get(r);if(!n){const o=document.createElement("canvas");o.width=i.width,o.height=i.height;const a=o.getContext("2d");a&&(a.putImageData(i,0,0),n=R.Texture.from(o),this.textureCache.set(r,n))}n&&e.texture&&(e.originalTextureSource||(e.originalTextureSource=e.texture.source,e.texture.source?.resource instanceof HTMLVideoElement&&(e.originalVideoElement=e.texture.source.resource)),e.texture=n,e.sprite?.texture&&(e.sprite.texture=n),e.lastReplacedTimestamp=t)}disableVideoPlayback(e){const t=[];for(const i of e)if(xn(i)){const r=i;t.push(r),r.texture?.source?.resource instanceof HTMLVideoElement&&r.texture.source.resource.pause(),r.skipVideoUpdate=!0}return t}getVideoKey(e){return e.clipConfiguration?.asset?.src||""}dispose(){this.frameCache.clear(),this.textureCache.clear(),this.videoElements.clear(),this.extractionCanvas=null,this.extractionContext=null}async seekToTime(e,t){return new Promise(i=>{if(Math.abs(e.currentTime-t)<.1){i();return}const r=()=>{e.removeEventListener("seeked",r),setTimeout(i,1)};e.addEventListener("seeked",r),e.currentTime=t})}}class vh{edit;canvas;app;isExporting=!1;videoProcessor=new bh;audioProcessor=new mh;progressUI=new gh;exportCommand=new Jo;constructor(e,t){this.edit=e,this.canvas=t,this.app=t.application,document.addEventListener("keydown",this.handleKeyDown)}async export(e="shotstack-export.mp4",t){if(typeof VideoEncoder>"u")throw new yh("WebCodecs API not supported",["VideoEncoder"]);if(this.isExporting)throw new Ei("Export in progress","init");this.isExporting=!0;const i=this.saveEditState();this.edit.setExportMode(!0);try{this.progressUI.create(),this.canvas.pauseTicker();const r=this.prepareConfig(t??this.edit.getEdit().output?.fps??30);this.progressUI.update(0,100,"Preparing..."),this.edit.executeEditCommand(this.exportCommand),await this.videoProcessor.initialize(this.exportCommand.getClips()),this.progressUI.update(10,100,"Video ready");const n=new ph({format:new yn,target:new pn}),o=document.createElement("canvas");o.width=r.size.width,o.height=r.size.height;const a=o.getContext("2d");if(!a)throw new Error("No 2D context");const p=new ch(o,{codec:"avc",bitrate:5e6});n.addVideoTrack(p),this.progressUI.update(15,100,"Audio...");const m=await this.audioProcessor.setupAudioTracks(this.exportCommand.getTracks(),n);await n.start(),m&&(this.progressUI.update(20,100,"Encoding audio..."),await this.audioProcessor.processAudioSamples(m)),this.progressUI.update(25,100,"Exporting..."),await this.processFrames(r,p,o,a),await n.finalize();const d=n.target.buffer;if(!d)throw new Error("No video data");const l=new Blob([d],{type:"video/mp4"}),c=URL.createObjectURL(l),u=document.createElement("a");u.href=c,u.download=e,u.click(),URL.revokeObjectURL(c),this.progressUI.update(100,100,"Complete!")}catch(r){throw r instanceof Ei?r:new Ei(`Export failed: ${r}`,"export")}finally{this.isExporting=!1,this.edit.setExportMode(!1),this.canvas.resumeTicker(),this.progressUI.remove(),this.restoreEditState(i)}}async processFrames(e,t,i,r){const n=this.edit.getContainer();this.edit.pause(),Object.assign(n.position,{x:0,y:0}),Object.assign(n.scale,{x:1,y:1}),n.visible=!0;const o=this.videoProcessor.disableVideoPlayback(this.exportCommand.getClips());for(let a=0;a<e.frames;a+=1){const p=a*e.frameDuration;this.edit.playbackTime=p;for(const l of this.exportCommand.getClips())l.update(0,0);for(const l of o){const c=l.getStart?.()||0,u=l.getEnd?.()||c+(l.getLength?.()||0);p>=c&&p<u&&await this.videoProcessor.replaceVideoTexture(l,p)}this.edit.draw(),this.app.renderer.render(this.app.stage);const m=this.app.renderer.extract.pixels({target:n,frame:new R.Rectangle(0,0,e.size.width,e.size.height)}),d=new ImageData(new Uint8ClampedArray(m.pixels),m.width,m.height);r.putImageData(d,0,0),await t.add(a/e.fps,1/e.fps),this.progressUI.update(25+Math.round((a+1)/e.frames*75),100,"Exporting...")}}handleKeyDown=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.code==="KeyE"&&(e.metaKey||e.ctrlKey)&&!this.isExporting&&(e.preventDefault(),this.export("shotstack-export.mp4",this.edit.getEdit().output?.fps||30).catch(t=>console.error("Export failed:",t)))};dispose(){document.removeEventListener("keydown",this.handleKeyDown),this.videoProcessor.dispose(),this.progressUI.remove()}prepareConfig(e){const t=this.edit.getEdit().output?.size||{width:1920,height:1080},i=this.edit.totalDuration/1e3;return{fps:e,size:t,frames:Math.ceil(i*e),frameDuration:1e3/e}}saveEditState(){const e=this.edit.getContainer();return{wasPlaying:this.edit.isPlaying,time:this.edit.playbackTime,visible:e.visible,pos:{x:e.position.x,y:e.position.y},scale:{x:e.scale.x,y:e.scale.y}}}restoreEditState(e){const t=this.edit.getContainer();this.edit.setExportMode(!1);for(const i of this.exportCommand.getClips())if(this.isVideoPlayer(i)){const r=i;if(r.skipVideoUpdate=!1,r.originalVideoElement&&r.texture){const n=R.Texture.from(r.originalVideoElement);r.texture=n,r.sprite&&(r.sprite.texture=n),delete r.originalVideoElement,delete r.originalTextureSource,delete r.lastReplacedTimestamp}else r.originalTextureSource&&r.texture&&(r.texture.source=r.originalTextureSource,delete r.originalTextureSource,delete r.lastReplacedTimestamp)}Object.assign(t.position,e.pos),Object.assign(t.scale,e.scale),t.visible=e.visible,this.edit.seek(e.time),e.wasPlaying&&this.edit.play()}isVideoPlayer(e){if(!e||typeof e!="object")return!1;const t=e,i=t.constructor?.name==="VideoPlayer",n=t.texture?.source?.resource instanceof HTMLVideoElement;return i||n}}function Cn(s){const e=s.replace("#",""),t=parseInt(e,16);return Number.isNaN(t)?(console.warn(`Invalid hex color: ${s}, defaulting to black`),0):t}function wh(s){const e=t=>{if(typeof t=="string")return Cn(t);if(typeof t=="object"&&t!==null){const i=Array.isArray(t)?[]:{};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=e(t[r]));return i}return t};return e(s)}function kn(s){if(typeof s=="string")return Cn(s);if(typeof s=="object"&&s!==null){const e=Array.isArray(s)?[]:{};for(const t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=kn(s[t]));return e}return s}const Tn=wh({timeline:{background:"#1a1a1a",divider:"#1a1a1a",toolbar:{background:"#1a1a1a",surface:"#2a2a2a",hover:"#3a3a3a",active:"#007acc",divider:"#3a3a3a",icon:"#888888",text:"#ffffff",height:36},ruler:{background:"#404040",text:"#ffffff",markers:"#666666",height:40},tracks:{surface:"#2a2a2a",surfaceAlt:"#242424",border:"#3a3a3a",height:60},clips:{video:"#4a90e2",audio:"#7ed321",image:"#f5a623",text:"#d0021b",shape:"#9013fe",html:"#50e3c2",luma:"#b8e986",default:"#8e8e93",selected:"#007acc",radius:4},playhead:"#ff4444",snapGuide:"#888888",dropZone:"#00ff00",trackInsertion:"#00ff00"}});class Sn{static resolveTheme(e){if(!e||!e.theme)return this.deepClone(Tn);const t=kn(e.theme),i=this.deepClone(Tn);return this.deepMerge(i,t)}static validateTheme(e){try{if(!e.timeline)return!1;const{timeline:t}=e;if(typeof t.background!="number"||typeof t.divider!="number"||typeof t.playhead!="number"||typeof t.snapGuide!="number"||typeof t.dropZone!="number"||typeof t.trackInsertion!="number"||!t.toolbar)return!1;const{toolbar:i}=t;if(typeof i.background!="number"||typeof i.surface!="number"||typeof i.hover!="number"||typeof i.active!="number"||typeof i.divider!="number"||typeof i.icon!="number"||typeof i.text!="number"||typeof i.height!="number"||i.height<=0||!t.ruler)return!1;const{ruler:r}=t;if(typeof r.background!="number"||typeof r.text!="number"||typeof r.markers!="number"||typeof r.height!="number"||r.height<=0||!t.tracks)return!1;const{tracks:n}=t;if(typeof n.surface!="number"||typeof n.surfaceAlt!="number"||typeof n.border!="number"||typeof n.height!="number"||n.height<=0||!t.clips)return!1;const{clips:o}=t,a=["video","audio","image","text","shape","html","luma","default","selected"];for(const p of a)if(typeof o[p]!="number")return!1;return!(typeof o.radius!="number"||o.radius<0)}catch(t){return console.error("Theme validation error:",t),!1}}static deepClone(e){if(e===null||typeof e!="object")return e;if(e instanceof Array)return e.map(i=>this.deepClone(i));const t={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=this.deepClone(e[i]));return t}static deepMerge(e,t){const i={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const n=t[r],o=i[r];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?i[r]=this.deepMerge(o,n):i[r]=n)}return i}}class _h{timeline;constructor(e){this.timeline=e}getValidDropPosition(e,t,i,r){const n=this.timeline.getVisualTracks()[i];if(!n)return{validTime:e,wouldOverlap:!1};const o=this.getOtherClipBounds(n,r),a=e+t,p=o.find(u=>!(a<=u.start||e>=u.end));if(!p)return{validTime:e,wouldOverlap:!1};const m=p.start-t,d=p.end,l=Math.abs(e-m)<Math.abs(e-d)&&m>=0?m:d;return{validTime:this.getValidDropPosition(l,t,i,r).validTime,wouldOverlap:!0}}checkOverlap(e,t,i,r){const n=this.timeline.getVisualTracks()[i];if(!n)return!1;const o=this.getOtherClipBounds(n,r),a=e+t;return o.some(p=>!(a<=p.start||e>=p.end))}getOtherClipBounds(e,t){return e.getClips().map((i,r)=>({clip:i,index:r})).filter(({index:i})=>i!==t).map(({clip:i})=>{const r=i.getClipConfig();return r?{start:r.start||0,end:(r.start||0)+(r.length||0)}:null}).filter(i=>i!==null).sort((i,r)=>i.start-r.start)}findAvailableGaps(e,t){const i=this.timeline.getVisualTracks()[e];if(!i)return[];const r=this.getOtherClipBounds(i),n=[];r.length>0&&r[0].start>=t&&n.push({start:0,end:r[0].start});for(let o=0;o<r.length-1;o+=1)r[o+1].start-r[o].end>=t&&n.push({start:r[o].end,end:r[o+1].start});return n}}class En{constructor(e,t,i,r){this.fromTrackIndex=e,this.fromClipIndex=t,this.toTrackIndex=i,this.newStart=r,this.originalTrackIndex=e,this.originalClipIndex=t}name="moveClip";player;originalTrackIndex;originalClipIndex;originalStart;execute(e){if(!e)return;const t=e.getTracks();if(this.fromTrackIndex<0||this.fromTrackIndex>=t.length){console.warn(`Invalid source track index: ${this.fromTrackIndex}`);return}const i=t[this.fromTrackIndex];if(this.fromClipIndex<0||this.fromClipIndex>=i.length){console.warn(`Invalid clip index: ${this.fromClipIndex}`);return}if(this.player=i[this.fromClipIndex],this.originalStart=this.player.clipConfiguration.start,this.fromTrackIndex!==this.toTrackIndex){if(this.toTrackIndex<0||this.toTrackIndex>=t.length){console.warn(`Invalid destination track index: ${this.toTrackIndex}`);return}i.splice(this.fromClipIndex,1),this.player.layer=this.toTrackIndex+1;const r=t[this.toTrackIndex];let n=0;for(let o=0;o<r.length;o+=1){const a=r[o];if(a.clipConfiguration&&a.clipConfiguration.start!==void 0&&this.newStart<a.clipConfiguration.start)break;n+=1}r.splice(n,0,this.player),this.originalClipIndex=n}if(this.player.clipConfiguration.start=this.newStart,e.movePlayerToTrackContainer(this.player,this.fromTrackIndex,this.toTrackIndex),this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),this.fromTrackIndex!==this.toTrackIndex){const r=t[this.fromTrackIndex],n=t[this.toTrackIndex];[...r,...n].forEach(o=>{o&&o!==this.player&&o.draw()})}e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,start:this.originalStart},trackIndex:this.fromTrackIndex,clipIndex:this.fromClipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.toTrackIndex,clipIndex:this.originalClipIndex}})}undo(e){if(!e||!this.player||this.originalStart===void 0)return;const t=e.getTracks();if(this.fromTrackIndex!==this.toTrackIndex){const i=t[this.toTrackIndex],r=i.indexOf(this.player);r!==-1&&i.splice(r,1),this.player.layer=this.fromTrackIndex+1,t[this.fromTrackIndex].splice(this.fromClipIndex,0,this.player)}this.player.clipConfiguration.start=this.originalStart,e.movePlayerToTrackContainer(this.player,this.toTrackIndex,this.fromTrackIndex),this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,start:this.newStart},trackIndex:this.toTrackIndex,clipIndex:this.originalClipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.fromTrackIndex,clipIndex:this.fromClipIndex}})}}class xh{constructor(e,t,i,r){this.insertionIndex=e,this.fromTrackIndex=t,this.fromClipIndex=i,this.newStart=r,this.addTrackCommand=new Sr(e);const n=t>=e?t+1:t;this.moveClipCommand=new En(n,i,e,r)}name="createTrackAndMoveClip";addTrackCommand;moveClipCommand;wasExecuted=!1;async execute(e){if(e)try{this.addTrackCommand.execute(e),this.moveClipCommand.execute(e),this.wasExecuted=!0}catch(t){if(this.wasExecuted)try{this.undo(e)}catch{}throw t}}undo(e){!e||!this.wasExecuted||(this.moveClipCommand.undo(e),this.addTrackCommand.undo(e),this.wasExecuted=!1,e.emitEvent("track:created:undone",{trackIndex:this.insertionIndex}))}}class Ch{timeline;thresholds;snapManager;collisionDetector;visualFeedback;dragInfo=null;currentDropZone=null;constructor(e,t,i,r,n){this.timeline=e,this.thresholds=t,this.snapManager=i,this.collisionDetector=r,this.visualFeedback=n}activate(){}deactivate(){this.endDrag()}canStartDrag(e,t){const i=Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),{trackHeight:r}=this.timeline.getLayout(),n=r<20?2:this.thresholds.drag.base;return i>n}startDrag(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return console.warn(`Clip data not found for track ${e.trackIndex}, clip ${e.clipIndex}`),!1;const r=this.timeline.getContainer().toLocal(t.global),n=this.timeline.getLayout(),o=n.getXAtTime(i.start||0),a=e.trackIndex*n.trackHeight;return this.dragInfo={trackIndex:e.trackIndex,clipIndex:e.clipIndex,startTime:i.start||0,offsetX:r.x-o,offsetY:r.y-a},this.timeline.getPixiApp().canvas.style.cursor="grabbing",this.timeline.getEdit().events.emit("drag:started",this.dragInfo),!0}updateDrag(e){if(!this.dragInfo)return;const t=this.calculateDragPosition(e),i=this.detectDropZone(t.y);i?this.handleDropZonePreview(i,t):this.handleNormalDragPreview(t),this.emitDragUpdate(t,i)}completeDrag(e){if(!this.dragInfo)return;const t={...this.dragInfo},i=this.calculateDragPosition(e),r=this.detectDropZone(i.y);this.endDrag(),r?this.executeDropZoneMove(r,t,i):this.executeNormalMove(t,i)}calculateDragPosition(e){if(!this.dragInfo)throw new Error("No drag info available");const t=this.timeline.getContainer().toLocal(e.global),i=this.timeline.getLayout(),r=Math.max(0,i.getTimeAtX(t.x-this.dragInfo.offsetX)),n=t.y-this.dragInfo.offsetY,o=n+i.trackHeight/2,a=Math.max(0,Math.floor(o/i.trackHeight)),p=this.timeline.getVisualTracks().length-1,m=Math.max(0,Math.min(p,a));return{x:t.x,y:t.y+i.viewportY,time:r,track:m,ghostY:n}}detectDropZone(e){const t=this.timeline.getLayout(),i=this.timeline.getVisualTracks(),r=t.trackHeight*this.thresholds.dropZone.ratio;for(let n=0;n<=i.length;n+=1){const o=t.tracksY+n*t.trackHeight;if(Math.abs(e-o)<r){let a;return n===0?a="above":n===i.length?a="below":a="between",{type:a,position:n}}}return null}handleDropZonePreview(e,t){(!this.currentDropZone||this.currentDropZone.type!==e.type||this.currentDropZone.position!==e.position)&&(this.currentDropZone=e,this.visualFeedback.showDropZone(e)),this.timeline.hideDragGhost(),this.visualFeedback.hideSnapGuidelines(),this.visualFeedback.hideTargetTrack()}handleNormalDragPreview(e){if(!this.dragInfo)return;this.currentDropZone&&(this.visualFeedback.hideDropZone(),this.currentDropZone=null);const t=this.timeline.getClipData(this.dragInfo.trackIndex,this.dragInfo.clipIndex);if(!t)return;const i=t.length||0,r=e.track===this.dragInfo.trackIndex?this.dragInfo.clipIndex:void 0,n=this.calculateFinalPosition(e.time,e.track,i,r),o=this.snapManager.findAlignedElements(n,i,e.track,r);o.length>0?this.visualFeedback.showSnapGuidelines(o):this.visualFeedback.hideSnapGuidelines(),this.visualFeedback.showTargetTrack(e.track),this.timeline.showDragGhost(e.track,n,e.ghostY)}calculateFinalPosition(e,t,i,r){const n=this.snapManager.calculateSnapPosition(e,t,i,r);return this.collisionDetector.getValidDropPosition(n.time,i,t,r).validTime}emitDragUpdate(e,t){if(!this.dragInfo)return;const i=this.timeline.getClipData(this.dragInfo.trackIndex,this.dragInfo.clipIndex);if(!i)return;const r=i.length||0,n=t?e.time:this.calculateFinalPosition(e.time,e.track,r,e.track===this.dragInfo.trackIndex?this.dragInfo.clipIndex:void 0);this.timeline.getEdit().events.emit("drag:moved",{...this.dragInfo,currentTime:n,currentTrack:t?-1:e.track})}executeDropZoneMove(e,t,i){const r=new xh(e.position,t.trackIndex,t.clipIndex,i.time);this.timeline.getEdit().executeEditCommand(r)}executeNormalMove(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return;const r=i.length||0,n=t.track===e.trackIndex?e.clipIndex:void 0,o=this.calculateFinalPosition(t.time,t.track,r,n);if(t.track!==e.trackIndex||Math.abs(o-e.startTime)>.01){const p=new En(e.trackIndex,e.clipIndex,t.track,o);this.timeline.getEdit().executeEditCommand(p)}}endDrag(){this.dragInfo=null,this.currentDropZone=null,this.visualFeedback.hideAll(),this.timeline.getPixiApp().canvas.style.cursor="default",this.timeline.getEdit().events.emit("drag:ended",{})}getDragInfo(){return this.dragInfo}dispose(){this.endDrag()}}class kh{constructor(e,t,i){this.trackIndex=e,this.clipIndex=t,this.newLength=i}name="resizeClip";originalLength;player;execute(e){if(!e)return;const t=e.getTrack(this.trackIndex);if(!t){console.warn(`Invalid track index: ${this.trackIndex}`);return}if(this.clipIndex<0||this.clipIndex>=t.length){console.warn(`Invalid clip index: ${this.clipIndex} for track ${this.trackIndex}`);return}this.player=t[this.clipIndex],this.originalLength=this.player.clipConfiguration.length,this.player.clipConfiguration.length=this.newLength,this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,length:this.originalLength},trackIndex:this.trackIndex,clipIndex:this.clipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}})}undo(e){!e||!this.player||this.originalLength===void 0||(this.player.clipConfiguration.length=this.originalLength,this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,length:this.newLength},trackIndex:this.trackIndex,clipIndex:this.clipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}}))}}class Th{timeline;thresholds;resizeInfo=null;constructor(e,t){this.timeline=e,this.thresholds=t}activate(){}deactivate(){this.endResize()}isOnClipRightEdge(e,t){const i=this.timeline.getVisualTracks()[e.trackIndex];if(!i)return!1;const r=i.getClip(e.clipIndex);if(!r)return!1;const o=r.getContainer().getBounds(),a=o.x+o.width,p=Math.abs(t.global.x-a),m=this.getResizeThreshold();return p<=m}startResize(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return!1;this.resizeInfo={trackIndex:e.trackIndex,clipIndex:e.clipIndex,originalLength:i.length||0,startX:t.global.x},this.timeline.getPixiApp().canvas.style.cursor="ew-resize";const r=this.timeline.getVisualTracks()[e.trackIndex];if(r){const n=r.getClip(e.clipIndex);n&&n.setResizing(!0)}return this.timeline.getEdit().events.emit("resize:started",this.resizeInfo),!0}updateResize(e){if(!this.resizeInfo)return;const t=e.global.x-this.resizeInfo.startX,i=this.timeline.getOptions().pixelsPerSecond||50,r=t/i,n=Math.max(.1,this.resizeInfo.originalLength+r),o=this.timeline.getVisualTracks()[this.resizeInfo.trackIndex];if(o){const a=o.getClip(this.resizeInfo.clipIndex);if(a){const p=n*i;a.setPreviewWidth(p),this.timeline.getEdit().events.emit("resize:updated",{width:p})}}}completeResize(e){if(!this.resizeInfo)return;const t=e.global.x-this.resizeInfo.startX,i=this.timeline.getOptions().pixelsPerSecond||50,r=t/i,n=Math.max(.1,this.resizeInfo.originalLength+r),o=this.timeline.getVisualTracks()[this.resizeInfo.trackIndex];if(o){const a=o.getClip(this.resizeInfo.clipIndex);a&&(a.setResizing(!1),a.setPreviewWidth(null))}if(Math.abs(n-this.resizeInfo.originalLength)>.01){const a=new kh(this.resizeInfo.trackIndex,this.resizeInfo.clipIndex,n);this.timeline.getEdit().executeEditCommand(a),this.timeline.getEdit().events.emit("resize:ended",{newLength:n})}this.endResize()}getCursorForPosition(e,t){return e&&this.isOnClipRightEdge(e,t)?"ew-resize":""}getResizeThreshold(){const{trackHeight:e}=this.timeline.getLayout();return Math.max(this.thresholds.resize.min,Math.min(this.thresholds.resize.max,e*this.thresholds.resize.ratio))}endResize(){this.resizeInfo=null,this.timeline.getPixiApp().canvas.style.cursor="default"}getResizeInfo(){return this.resizeInfo}dispose(){this.endResize()}}class Sh{timeline;thresholds;constructor(e,t){this.timeline=e,this.thresholds=t}getAllSnapPoints(e,t){const i=[];this.timeline.getVisualTracks().forEach((o,a)=>{o.getClips().forEach((m,d)=>{if(a===e&&d===t)return;const l=m.getClipConfig();l&&(i.push({time:l.start||0,type:"clip-start",trackIndex:a,clipIndex:d}),i.push({time:(l.start||0)+(l.length||0),type:"clip-end",trackIndex:a,clipIndex:d}))})});const n=this.timeline.getPlayheadTime();return i.push({time:n,type:"playhead"}),i}getTrackSnapPoints(e,t){return this.getAllSnapPoints(e,t).filter(i=>i.trackIndex===void 0||i.trackIndex===e)}calculateSnapPosition(e,t,i,r){const n=this.timeline.getOptions().pixelsPerSecond||50,o=this.thresholds.snap.pixels/n,a=this.getTrackSnapPoints(t,r);let p=null;for(const m of a){const d=Math.abs(e-m.time);d<o&&(!p||d<p.distance)&&(p={time:m.time,type:m.type,distance:d});const l=Math.abs(e+i-m.time);l<o&&(!p||l<p.distance)&&(p={time:m.time-i,type:m.type,distance:l})}return p?{time:p.time,snapped:!0,snapType:p.type}:{time:e,snapped:!1}}findAlignedElements(e,t,i,r){const o=e+t,a=new Map;this.timeline.getVisualTracks().forEach((m,d)=>{m.getClips().forEach((l,c)=>{if(d===i&&c===r)return;const u=l.getClipConfig();if(!u)return;const h=u.start||0,f=h+(u.length||0);[{time:h,aligns:[e,o]},{time:f,aligns:[e,o]}].forEach(({time:b,aligns:g})=>{g.some(y=>Math.abs(y-b)<.1)&&(a.has(b)||a.set(b,{tracks:new Set,isPlayhead:!1}),a.get(b).tracks.add(d))})})});const p=this.timeline.getPlayheadTime();return(Math.abs(e-p)<.1||Math.abs(o-p)<.1)&&(a.has(p)||a.set(p,{tracks:new Set,isPlayhead:!0}),a.get(p).isPlayhead=!0),Array.from(a.entries()).map(([m,d])=>({time:m,tracks:Array.from(d.tracks).concat(i),isPlayhead:d.isPlayhead}))}}class Eh{timeline;graphics=new Map;constructor(e){this.timeline=e}showDropZone(e){this.hideDropZone();const t=new R.Graphics,i=this.timeline.getLayout(),r=this.timeline.getExtendedTimelineWidth(),n=e.position*i.trackHeight,a=this.timeline.getTheme().timeline.trackInsertion;t.setStrokeStyle({width:4,color:a,alpha:.8}),t.moveTo(0,n),t.lineTo(r,n),t.stroke(),t.setStrokeStyle({width:8,color:a,alpha:.3}),t.moveTo(0,n),t.lineTo(r,n),t.stroke(),this.timeline.getContainer().addChild(t),this.graphics.set("dropZone",t)}hideDropZone(){this.hideGraphics("dropZone")}showSnapGuidelines(e){this.hideSnapGuidelines();const t=new R.Graphics,i=this.timeline.getLayout(),r=this.timeline.getTheme();e.forEach(({time:n,tracks:o,isPlayhead:a})=>{const p=i.getXAtTime(n),m=Math.min(...o),d=Math.max(...o),l=m*i.trackHeight,c=(d+1)*i.trackHeight,u=a?r.timeline.playhead:r.timeline.snapGuide;t.setStrokeStyle({width:3,color:u,alpha:.3}),t.moveTo(p,l),t.lineTo(p,c),t.stroke(),t.setStrokeStyle({width:1,color:u,alpha:.8}),t.moveTo(p,l),t.lineTo(p,c),t.stroke()}),this.timeline.getContainer().addChild(t),this.graphics.set("snapGuidelines",t)}hideSnapGuidelines(){this.hideGraphics("snapGuidelines")}showTargetTrack(e){this.hideTargetTrack();const t=new R.Graphics,i=this.timeline.getLayout(),r=this.timeline.getExtendedTimelineWidth(),n=e*i.trackHeight,o=i.trackHeight,p=this.timeline.getTheme().timeline.dropZone;t.rect(0,n,r,o),t.fill({color:p,alpha:.1}),t.setStrokeStyle({width:1,color:p,alpha:.3}),t.rect(0,n,r,o),t.stroke(),this.timeline.getContainer().addChild(t),this.graphics.set("targetTrack",t)}hideTargetTrack(){this.hideGraphics("targetTrack")}hideAll(){this.graphics.forEach((e,t)=>this.hideGraphics(t))}hideGraphics(e){const t=this.graphics.get(e);t&&(t.clear(),t.parent&&t.parent.removeChild(t),t.destroy(),this.graphics.delete(e))}dispose(){this.hideAll(),this.graphics.clear()}}class Ah{timeline;state={type:"idle"};abortController;dragHandler;resizeHandler;snapManager;collisionDetector;visualFeedback;thresholds={drag:{base:3,small:2},resize:{min:12,max:20,ratio:.4},dropZone:{ratio:.15},snap:{pixels:10,time:.1}};constructor(e,t){if(this.timeline=e,t){const i=structuredClone(this.thresholds);t.drag&&Object.assign(i.drag,t.drag),t.resize&&Object.assign(i.resize,t.resize),t.dropZone&&Object.assign(i.dropZone,t.dropZone),t.snap&&Object.assign(i.snap,t.snap),this.thresholds=i}this.snapManager=new Sh(e,this.thresholds),this.collisionDetector=new _h(e),this.visualFeedback=new Eh(e),this.dragHandler=new Ch(e,this.thresholds,this.snapManager,this.collisionDetector,this.visualFeedback),this.resizeHandler=new Th(e,this.thresholds)}activate(){this.abortController=new AbortController,this.setupEventListeners(),this.dragHandler.activate(),this.resizeHandler.activate()}deactivate(){this.abortController&&(this.abortController.abort(),this.abortController=void 0),this.resetState(),this.dragHandler.deactivate(),this.resizeHandler.deactivate()}setupEventListeners(){const e=this.timeline.getPixiApp();e.stage.interactive=!0,e.stage.on("pointerdown",this.handlePointerDown.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointermove",this.handlePointerMove.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointerup",this.handlePointerUp.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointerupoutside",this.handlePointerUp.bind(this),{signal:this.abortController?.signal})}handlePointerDown(e){const t=e.target;if(t.label){const i=this.parseClipLabel(t.label);if(i){if(this.resizeHandler.isOnClipRightEdge(i,e)){if(this.resizeHandler.startResize(i,e)){const r=this.resizeHandler.getResizeInfo();r&&(this.state={type:"resizing",resizeInfo:r})}return}this.state={type:"selecting",startPos:{x:e.global.x,y:e.global.y},clipInfo:i},this.timeline.getPixiApp().canvas.style.cursor="grab";return}}this.timeline.getEdit().clearSelection()}handlePointerMove(e){switch(this.state.type){case"selecting":this.handleSelectingMove(e);break;case"dragging":this.timeline.getPixiApp().canvas.style.cursor="grabbing",this.dragHandler.updateDrag(e);break;case"resizing":this.timeline.getPixiApp().canvas.style.cursor="ew-resize",this.resizeHandler.updateResize(e);break;case"idle":this.updateCursorForPosition(e);break}}handlePointerUp(e){switch(this.state.type){case"selecting":this.timeline.getEdit().selectClip(this.state.clipInfo.trackIndex,this.state.clipInfo.clipIndex);break;case"dragging":this.dragHandler.completeDrag(e);break;case"resizing":this.resizeHandler.completeResize(e);break}this.resetState()}handleSelectingMove(e){if(this.state.type!=="selecting")return;const t={x:e.global.x,y:e.global.y};if(this.dragHandler.canStartDrag(this.state.startPos,t)&&this.dragHandler.startDrag(this.state.clipInfo,e)){const i=this.dragHandler.getDragInfo();i&&(this.state={type:"dragging",dragInfo:i})}}updateCursorForPosition(e){const t=e.target;if(t.label){const i=this.parseClipLabel(t.label);if(i){const r=this.resizeHandler.getCursorForPosition(i,e);if(r){this.timeline.getPixiApp().canvas.style.cursor=r;return}this.timeline.getPixiApp().canvas.style.cursor="grab";return}}this.timeline.getPixiApp().canvas.style.cursor="default"}parseClipLabel(e){if(!e?.startsWith("clip-"))return null;const t=e.split("-");if(t.length!==3)return null;const i=parseInt(t[1],10),r=parseInt(t[2],10);return Number.isNaN(i)||Number.isNaN(r)?null:{trackIndex:i,clipIndex:r}}resetState(){this.state={type:"idle"},this.visualFeedback.hideAll(),this.timeline.getPixiApp().canvas.style.cursor="default"}dispose(){this.deactivate(),this.dragHandler.dispose(),this.resizeHandler.dispose(),this.visualFeedback.dispose()}}class Ih{constructor(e,t,i,r,n){this.container=e,this.layout=t,this.getPixelsPerSecond=i,this.getTrackHeight=r,this.getVisualTracks=n}dragPreviewContainer=null;dragPreviewGraphics=null;draggedClipInfo=null;showDragPreview(e,t,i){if(!i)return;this.draggedClipInfo={trackIndex:e,clipIndex:t,clipConfig:i},this.dragPreviewContainer=new R.Container,this.dragPreviewGraphics=new R.Graphics,this.dragPreviewContainer.addChild(this.dragPreviewGraphics),this.container.addChild(this.dragPreviewContainer),this.getVisualTracks()[e]?.getClip(t)?.setDragging(!0),this.drawDragPreview(e,i.start||0)}drawDragPreview(e,t){if(!this.dragPreviewContainer||!this.dragPreviewGraphics||!this.draggedClipInfo)return;const{clipConfig:i}=this.draggedClipInfo,r=this.layout.getXAtTime(t),n=e*this.layout.trackHeight,o=(i.length||0)*this.getPixelsPerSecond();this.dragPreviewGraphics.clear(),this.dragPreviewGraphics.roundRect(0,0,o,this.getTrackHeight(),4),this.dragPreviewGraphics.fill({color:9342611,alpha:.6}),this.dragPreviewGraphics.stroke({width:2,color:65280}),this.dragPreviewContainer.position.set(r,n)}drawDragPreviewAtPosition(e,t,i){if(!this.dragPreviewContainer||!this.dragPreviewGraphics||!this.draggedClipInfo)return;const{clipConfig:r}=this.draggedClipInfo,n=this.layout.getXAtTime(e),o=(r.length||0)*this.getPixelsPerSecond(),a=this.getTrackHeight();this.dragPreviewGraphics.clear(),this.dragPreviewGraphics.roundRect(0,0,o,a,4),this.dragPreviewGraphics.fill({color:9342611,alpha:.6});const p=i*this.layout.trackHeight,d=Math.abs(t-p)<5?65280:16755200;this.dragPreviewGraphics.stroke({width:2,color:d}),this.dragPreviewContainer.position.set(n,t)}hideDragPreview(){this.dragPreviewContainer&&(this.dragPreviewContainer.destroy({children:!0}),this.dragPreviewContainer=null,this.dragPreviewGraphics=null),this.draggedClipInfo&&(this.getVisualTracks()[this.draggedClipInfo.trackIndex]?.getClip(this.draggedClipInfo.clipIndex)?.setDragging(!1),this.draggedClipInfo=null)}hideDragGhost(){this.dragPreviewContainer&&(this.dragPreviewContainer.visible=!1)}showDragGhost(e,t,i){!this.dragPreviewContainer||!this.draggedClipInfo||(this.dragPreviewContainer.visible=!0,i!==void 0?this.drawDragPreviewAtPosition(t,i,e):this.drawDragPreview(e,t))}getDraggedClipInfo(){return this.draggedClipInfo}hasActivePreview(){return this.dragPreviewContainer!==null}dispose(){this.hideDragPreview()}}class Ph{constructor(e,t,i,r,n){this.layout=e,this.trackLayer=t,this.overlayLayer=i,this.entityContainer=r,this.onRender=n}scrollX=0;scrollY=0;zoomLevel=1;viewport;rulerViewport;playheadContainer;async setupViewport(){this.rulerViewport=new R.Container,this.rulerViewport.label="ruler-viewport",this.overlayLayer.addChild(this.rulerViewport),this.playheadContainer=new R.Container,this.playheadContainer.label="playhead-container",this.overlayLayer.addChild(this.playheadContainer),this.viewport=new R.Container,this.viewport.label="viewport",this.trackLayer.addChild(this.viewport),this.viewport.addChild(this.entityContainer)}updateViewportTransform(){const e=this.layout.calculateViewportPosition(this.scrollX,this.scrollY);this.viewport.position.set(e.x,e.y),this.viewport.scale.set(this.zoomLevel,this.zoomLevel),this.rulerViewport.position.x=e.x,this.rulerViewport.scale.x=this.zoomLevel,this.playheadContainer.position.x=e.x,this.playheadContainer.scale.x=this.zoomLevel}setScroll(e,t){this.scrollX=e,this.scrollY=t,this.updateViewportTransform(),this.onRender()}setZoom(e){this.zoomLevel=Math.max(.1,Math.min(10,e)),this.updateViewportTransform(),this.onRender()}getViewport(){return{x:this.scrollX,y:this.scrollY,zoom:this.zoomLevel}}getMainViewport(){return this.viewport}getRulerViewport(){return this.rulerViewport}getPlayheadContainer(){return this.playheadContainer}}const Pe={MIN_WIDTH:50,PADDING:4,DEFAULT_ALPHA:1,DRAG_OPACITY:.6,RESIZE_OPACITY:.9,BORDER_WIDTH:2,CORNER_RADIUS:4,SELECTED_BORDER_MULTIPLIER:2,TEXT_FONT_SIZE:12,TEXT_TRUNCATE_SUFFIX_LENGTH:3},ri={PADDING:2,LABEL_PADDING:8,DEFAULT_OPACITY:.8,BORDER_WIDTH:1},Le={TOOLBAR_HEIGHT_RATIO:.12,RULER_HEIGHT_RATIO:.133,TOOLBAR_HEIGHT_DEFAULT:36,RULER_HEIGHT_DEFAULT:40,TRACK_HEIGHT_DEFAULT:80,BORDER_WIDTH:2,CORNER_RADIUS:4,CLIP_PADDING:4,LABEL_PADDING:8,TRACK_PADDING:2,MIN_CLIP_WIDTH:50};function Ai(s){const e=s.split("/");return e[e.length-1]||s}function Rh(s){switch(s.type){case"video":return s.src?Ai(s.src):"Video";case"audio":return s.src?Ai(s.src):"Audio";case"image":return s.src?Ai(s.src):"Image";case"text":return s.text||"Text";case"rich-text":return s.text||"Rich Text";case"shape":return s.shape||"Shape";case"html":return"HTML";case"luma":return s.src?Ai(s.src):"Luma";default:return"Unknown Asset"}}class Oh extends Je{clipConfig;options;graphics;background;text;selectionRenderer;lastGlobalX=-1;lastGlobalY=-1;visualState={mode:"normal"};CLIP_PADDING=Pe.PADDING;BORDER_WIDTH=Pe.BORDER_WIDTH;get CORNER_RADIUS(){return this.options.theme.timeline.clips.radius||Pe.CORNER_RADIUS}constructor(e,t){super(),this.clipConfig=e,this.options=t,this.selectionRenderer=t.selectionRenderer,this.graphics=new R.Graphics,this.background=new R.Graphics,this.text=new R.Text,this.setupContainer()}async load(){this.setupGraphics(),this.updateVisualState()}setupContainer(){const e=this.getContainer();e.label=`clip-${this.options.trackIndex}-${this.options.clipIndex}`,e.interactive=!0,e.cursor="pointer",e.addChild(this.background),e.addChild(this.graphics),e.addChild(this.text)}setupGraphics(){this.text.style=new R.TextStyle({fontSize:Pe.TEXT_FONT_SIZE,fill:this.options.theme.timeline.toolbar.text,fontWeight:"bold",wordWrap:!1,fontFamily:"Arial, sans-serif"}),this.text.anchor.set(0,0),this.text.x=this.CLIP_PADDING,this.text.y=this.CLIP_PADDING}updateFromConfig(e){this.clipConfig=e,this.updateVisualState()}updateVisualState(){this.updatePosition(),this.updateAppearance(),this.updateSize(),this.updateText()}setVisualState(e){this.visualState={...this.visualState,...e},this.updateVisualState()}updatePosition(){const e=this.getContainer(),t=this.clipConfig.start||0;e.x=t*this.options.pixelsPerSecond,e.y=0}updateSize(){const e=this.getEffectiveWidth(),t=this.options.trackHeight;this.drawClipBackground(e,t),this.drawClipBorder(e,t)}getEffectiveWidth(){if(this.visualState.previewWidth!==void 0)return this.visualState.previewWidth;const t=(this.clipConfig.length||0)*this.options.pixelsPerSecond;return Math.max(Pe.MIN_WIDTH,t)}drawClipBackground(e,t){const i=this.getClipColor(),r=this.getStateStyles();this.background.clear(),this.background.roundRect(0,0,e,t,this.CORNER_RADIUS),this.background.fill({color:i,alpha:r.alpha})}drawClipBorder(e,t){const i=this.getStateStyles(),r=this.BORDER_WIDTH;this.graphics.clear(),this.graphics.roundRect(0,0,e,t,this.CORNER_RADIUS),this.graphics.stroke({width:r,color:i.borderColor}),this.updateSelectionState(e,t)}updateSelectionState(e,t){if(!this.selectionRenderer)return;const i=this.visualState.mode==="selected",r=this.getClipId();if(!i){this.selectionRenderer.clearSelection(r);return}const o=this.getContainer().toGlobal(new R.Point(0,0)),p=this.selectionRenderer.getOverlay().toLocal(o);this.selectionRenderer.renderSelection(r,{x:p.x,y:p.y,width:e,height:t,cornerRadius:this.CORNER_RADIUS,borderWidth:this.BORDER_WIDTH},i)}getClipColor(){const e=this.clipConfig.asset?.type,t=this.options.theme.timeline.clips;switch(e){case"video":return t.video;case"audio":return t.audio;case"image":return t.image;case"text":return t.text;case"rich-text":return t["rich-text"]||t.text;case"shape":return t.shape;case"html":return t.html;case"luma":return t.luma;default:return t.default}}updateAppearance(){const e=this.getContainer();e.alpha=this.visualState.mode==="dragging"?Pe.DRAG_OPACITY:Pe.DEFAULT_ALPHA}updateText(){const e=this.clipConfig.asset?Rh(this.clipConfig.asset):"Clip";this.text.text=e;const i=(this.clipConfig.length||0)*this.options.pixelsPerSecond-this.CLIP_PADDING*2;if(this.text.width>i){const r=i/this.text.width,n=Math.floor(e.length*r)-Pe.TEXT_TRUNCATE_SUFFIX_LENGTH;this.text.text=`${e.substring(0,Math.max(1,n))}...`}}getStateStyles(){const{theme:e}=this.options;switch(this.visualState.mode){case"dragging":return{alpha:Pe.DRAG_OPACITY,borderColor:e.timeline.tracks.border};case"resizing":return{alpha:Pe.RESIZE_OPACITY,borderColor:e.timeline.dropZone};case"selected":return{alpha:Pe.DEFAULT_ALPHA,borderColor:e.timeline.clips.selected};default:return{alpha:Pe.DEFAULT_ALPHA,borderColor:e.timeline.tracks.border}}}setSelected(e){this.setVisualState({mode:e?"selected":"normal"})}setDragging(e){this.setVisualState({mode:e?"dragging":"normal"})}setResizing(e){this.setVisualState({mode:e?"resizing":"normal",...e?{}:{previewWidth:void 0}})}setPreviewWidth(e){this.setVisualState({previewWidth:e||void 0})}setPixelsPerSecond(e){if(this.updateOptions({pixelsPerSecond:e}),this.visualState.mode==="selected"){const t=this.getEffectiveWidth(),i=this.options.trackHeight;this.updateSelectionState(t,i)}}updateOptions(e){this.options={...this.options,...e},this.updateVisualState()}getClipConfig(){return this.clipConfig}getOptions(){return{...this.options}}getVisualState(){return{...this.visualState}}getSelected(){return this.visualState.mode==="selected"}getClipId(){return`${this.options.trackIndex}-${this.options.clipIndex}`}getDragging(){return this.visualState.mode==="dragging"}getRightEdgeX(){const e=this.getEffectiveWidth();return(this.clipConfig.start||0)*this.options.pixelsPerSecond+e}update(e,t){if(this.visualState.mode==="selected"&&this.selectionRenderer){const r=this.getContainer().toGlobal(new R.Point(0,0));if(r.x!==this.lastGlobalX||r.y!==this.lastGlobalY){this.lastGlobalX=r.x,this.lastGlobalY=r.y;const n=this.getEffectiveWidth(),o=this.options.trackHeight;this.updateSelectionState(n,o)}}}draw(){}dispose(){this.selectionRenderer&&this.selectionRenderer.clearSelection(this.getClipId()),this.background.destroy(),this.graphics.destroy(),this.text.destroy()}}class Fh extends Je{clips=[];options;background;TRACK_PADDING=ri.PADDING;LABEL_PADDING=ri.LABEL_PADDING;constructor(e){super(),this.options=e,this.background=new R.Graphics,this.setupContainer()}async load(){this.updateTrackAppearance()}setupContainer(){const e=this.getContainer();e.label=`track-${this.options.trackIndex}`,e.addChild(this.background),e.y=this.options.trackIndex*this.options.trackHeight}updateTrackAppearance(){const{width:e}=this.options,t=this.options.trackHeight,{theme:i}=this.options;this.background.clear();const r=this.options.trackIndex%2===0?i.timeline.tracks.surface:i.timeline.tracks.surfaceAlt;this.background.rect(0,0,e,t),this.background.fill({color:r,alpha:ri.DEFAULT_OPACITY}),this.background.rect(0,0,e,t),this.background.stroke({width:ri.BORDER_WIDTH,color:i.timeline.tracks.border}),this.background.moveTo(0,t-1),this.background.lineTo(e,t-1),this.background.stroke({width:ri.BORDER_WIDTH,color:i.timeline.divider})}rebuildFromTrackData(e,t){this.options={...this.options,pixelsPerSecond:t},this.clearAllClips(),e.clips&&e.clips.forEach((i,r)=>{const n={pixelsPerSecond:this.options.pixelsPerSecond,trackHeight:this.options.trackHeight,trackIndex:this.options.trackIndex,clipIndex:r,theme:this.options.theme,selectionRenderer:this.options.selectionRenderer},o=new Oh(i,n);this.addClip(o)}),this.updateTrackAppearance()}async addClip(e){this.clips.push(e),await e.load(),this.getContainer().addChild(e.getContainer())}clearAllClips(){const e=this.getContainer();for(const t of this.clips)e.removeChild(t.getContainer()),t.dispose();this.clips=[]}removeClip(e){if(e>=0&&e<this.clips.length){const t=this.clips[e];this.getContainer().removeChild(t.getContainer()),t.dispose(),this.clips.splice(e,1)}}updateClip(e,t){e>=0&&e<this.clips.length&&this.clips[e].updateFromConfig(t)}setPixelsPerSecond(e){this.options={...this.options,pixelsPerSecond:e},this.clips.forEach(t=>{t.setPixelsPerSecond(e)})}setWidth(e){this.options={...this.options,width:e},this.updateTrackAppearance()}setTrackIndex(e){this.options={...this.options,trackIndex:e};const t=this.getContainer();t.y=e*this.options.trackHeight,this.clips.forEach((i,r)=>{i.updateOptions({trackIndex:e})})}selectClip(e){this.clearAllSelections(),e>=0&&e<this.clips.length&&this.clips[e].setSelected(!0)}clearAllSelections(){this.clips.forEach(e=>{e.setSelected(!1)})}getSelectedClip(){return this.clips.find(e=>e.getSelected())||null}getSelectedClipIndex(){return this.clips.findIndex(e=>e.getSelected())}getClips(){return[...this.clips]}getClip(e){return this.clips[e]||null}getClipCount(){return this.clips.length}getTrackIndex(){return this.options.trackIndex}getTrackHeight(){return this.options.trackHeight}getOptions(){return{...this.options}}findClipAtPosition(e,t){if(t<0||t>this.options.trackHeight)return null;const i=e/this.options.pixelsPerSecond;for(let r=0;r<this.clips.length;r+=1){const n=this.clips[r],o=n.getClipConfig(),a=o.start||0,p=a+(o.length||0);if(i>=a&&i<=p)return{clip:n,clipIndex:r}}return null}update(e,t){this.clips.forEach(i=>{i.update(e,t)})}draw(){this.clips.forEach(e=>{e.draw()})}dispose(){this.clearAllClips(),this.background.destroy()}}class Mh{constructor(e,t){this.overlay=e,this.theme=t}selectionGraphics=new Map;renderSelection(e,t,i){if(!i){this.clearSelection(e);return}let r=this.selectionGraphics.get(e);r||(r=new R.Graphics,r.label=`selection-border-${e}`,this.selectionGraphics.set(e,r),this.overlay.addChild(r)),r.position.set(t.x,t.y),r.clear(),r.setStrokeStyle({width:t.borderWidth*Pe.SELECTED_BORDER_MULTIPLIER,color:this.theme.timeline.clips.selected}),r.roundRect(0,0,t.width,t.height,t.cornerRadius),r.stroke()}clearSelection(e){const t=this.selectionGraphics.get(e);t&&(this.overlay.removeChild(t),t.destroy(),this.selectionGraphics.delete(e))}clearAllSelections(){this.selectionGraphics.forEach((e,t)=>{this.clearSelection(t)})}updateTheme(e){this.theme=e,this.selectionGraphics.forEach(t=>{t.clear()})}getOverlay(){return this.overlay}dispose(){this.clearAllSelections()}}class Lh{constructor(e,t,i,r,n){this.container=e,this.layout=t,this.theme=i,this.getPixelsPerSecond=r,this.getExtendedTimelineWidth=n,this.selectionOverlay=new R.Container,this.selectionOverlay.label="selectionOverlay",this.container.addChild(this.selectionOverlay),this.selectionRenderer=new Mh(this.selectionOverlay,this.theme)}visualTracks=[];selectionOverlay;selectionRenderer;async rebuildFromEdit(e,t){if(e?.timeline?.tracks){this.clearAllVisualState();for(let i=0;i<e.timeline.tracks.length;i+=1){const r=e.timeline.tracks[i],n={pixelsPerSecond:t,trackHeight:this.layout.trackHeight,trackIndex:i,width:this.getExtendedTimelineWidth(),theme:this.theme,selectionRenderer:this.selectionRenderer},o=new Fh(n);await o.load(),o.rebuildFromTrackData(r,t),this.container.addChild(o.getContainer()),this.visualTracks.push(o)}this.container.setChildIndex(this.selectionOverlay,this.container.children.length-1)}}clearAllVisualState(){this.visualTracks.forEach(e=>{this.container.removeChild(e.getContainer()),e.dispose()}),this.visualTracks=[],this.selectionRenderer.clearAllSelections()}updateVisualSelection(e,t){this.clearVisualSelection();const i=this.visualTracks[e];if(i){const r=i.getClip(t);r&&r.setSelected(!0)}}clearVisualSelection(){this.visualTracks.forEach(e=>{e.getClips().forEach(i=>{i.setSelected(!1)})})}findClipAtPosition(e,t){const i=Math.floor(t/this.layout.trackHeight);if(i<0||i>=this.visualTracks.length)return null;const r=this.visualTracks[i],n=t-i*this.layout.trackHeight,o=r.findClipAtPosition(e,n);return o?{trackIndex:i,clipIndex:o.clipIndex,clipConfig:o.clip.getClipConfig(),x:(o.clip.getClipConfig().start||0)*this.getPixelsPerSecond(),y:i*this.layout.trackHeight,width:(o.clip.getClipConfig().length||0)*this.getPixelsPerSecond(),height:this.layout.trackHeight}:null}updateTrackWidths(e){this.visualTracks.forEach(t=>{t.setWidth(e)})}getVisualTracks(){return this.visualTracks}updatePixelsPerSecond(e){this.visualTracks.forEach(t=>{t.setPixelsPerSecond(e)})}getSelectionOverlay(){return this.selectionOverlay}getSelectionRenderer(){return this.selectionRenderer}dispose(){this.clearAllVisualState(),this.selectionRenderer&&this.selectionRenderer.dispose(),this.selectionOverlay&&this.container&&(this.container.removeChild(this.selectionOverlay),this.selectionOverlay.destroy())}}class Bh{constructor(e,t){this.edit=e,this.callbacks=t}setupEventListeners(){this.edit.events.on("timeline:updated",this.handleTimelineUpdated.bind(this)),this.edit.events.on("clip:updated",this.handleClipUpdated.bind(this)),this.edit.events.on("clip:selected",this.handleClipSelected.bind(this)),this.edit.events.on("selection:cleared",this.handleSelectionCleared.bind(this)),this.edit.events.on("drag:started",this.handleDragStarted.bind(this)),this.edit.events.on("drag:ended",this.handleDragEnded.bind(this)),this.edit.events.on("track:created",this.handleTrackCreated.bind(this))}async handleTimelineUpdated(e){await this.callbacks.onEditChange(e.current)}async handleClipUpdated(){await this.callbacks.onEditChange()}handleClipSelected(e){this.callbacks.onClipSelected(e.trackIndex,e.clipIndex)}handleSelectionCleared(){this.callbacks.onSelectionCleared()}handleDragStarted(e){this.callbacks.onDragStarted(e.trackIndex,e.clipIndex)}handleDragEnded(){this.callbacks.onDragEnded()}async handleTrackCreated(){await this.callbacks.onEditChange()}handleSeek(e){this.callbacks.onSeek(e.time*1e3)}dispose(){this.edit.events.off("timeline:updated",this.handleTimelineUpdated.bind(this)),this.edit.events.off("clip:updated",this.handleClipUpdated.bind(this)),this.edit.events.off("clip:selected",this.handleClipSelected.bind(this)),this.edit.events.off("selection:cleared",this.handleSelectionCleared.bind(this)),this.edit.events.off("drag:started",this.handleDragStarted.bind(this)),this.edit.events.off("drag:ended",this.handleDragEnded.bind(this)),this.edit.events.off("track:created",this.handleTrackCreated.bind(this))}}class $h{constructor(e,t){this.options=e,this.onUpdate=t}app;trackLayer;overlayLayer;animationFrameId=null;async initializePixiApp(){this.app=new R.Application,await this.app.init({width:this.options.width,height:this.options.height,backgroundColor:this.options.backgroundColor,antialias:this.options.antialias,resolution:this.options.resolution,autoDensity:!0,preference:"webgl"});const e=document.querySelector("[data-shotstack-timeline]");if(!e)throw new Error("Timeline container element [data-shotstack-timeline] not found");e.appendChild(this.app.canvas)}async setupRenderLayers(){this.trackLayer=new R.Container,this.overlayLayer=new R.Container,this.trackLayer.label="track-layer",this.overlayLayer.label="overlay-layer",this.app.stage.addChild(this.trackLayer),this.app.stage.addChild(this.overlayLayer)}startAnimationLoop(){let e=performance.now();const t=i=>{const r=i-e;e=i;const n=r/16.667;this.onUpdate(n,r),this.draw(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}draw(){this.app.render()}render(){this.app.render()}updateBackgroundColor(e){this.app&&(this.app.renderer.background.color=e)}getApp(){return this.app}getStage(){return this.app.stage}getTrackLayer(){return this.trackLayer}getOverlayLayer(){return this.overlayLayer}dispose(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.app&&this.app.destroy(!0)}}const $t={RULER:{DEFAULT_HEIGHT:40,LABEL_FONT_SIZE:10,LABEL_PADDING_X:2},PLAYHEAD:{LINE_WIDTH:2},SCROLL:{HORIZONTAL_SPEED:2,VERTICAL_SPEED:.5}};class An extends Je{events;rulerContainer;rulerBackground;timeMarkers;timeLabels;pixelsPerSecond;timelineDuration;rulerHeight;theme;constructor(e){super(),this.events=new Kt,this.pixelsPerSecond=e.pixelsPerSecond,this.timelineDuration=e.timelineDuration,this.rulerHeight=e.rulerHeight??$t.RULER.DEFAULT_HEIGHT,this.theme=e.theme,this.rulerContainer=new R.Container,this.rulerBackground=new R.Graphics,this.timeMarkers=new R.Graphics,this.timeLabels=new R.Container}async load(){this.setupRuler(),this.draw()}setupRuler(){this.rulerContainer.label="ruler",this.rulerContainer.addChild(this.rulerBackground),this.rulerContainer.addChild(this.timeMarkers),this.rulerContainer.addChild(this.timeLabels),this.rulerContainer.eventMode="static",this.rulerContainer.cursor="pointer",this.rulerContainer.on("pointerdown",this.onRulerPointerDown.bind(this)),this.getContainer().addChild(this.rulerContainer)}drawRulerBackground(){this.rulerBackground.clear();const e=this.calculateRulerWidth(),t=this.theme?.timeline.ruler.background||4210752,i=this.theme?.timeline.tracks.border||6316128;this.rulerBackground.rect(0,0,e,this.rulerHeight),this.rulerBackground.fill(t),this.rulerBackground.rect(0,this.rulerHeight-1,e,1),this.rulerBackground.fill(i)}drawTimeMarkers(){this.timeMarkers.clear();const e=this.getTimeInterval(),t=this.getVisibleDuration(),i=this.theme?.timeline.ruler.markers||6710886,r=this.rulerHeight*.5;let n=4;e===10?n=9:(e===30||e===60)&&(n=5);const o=e/(n+1);for(let a=0;a<=t;a+=e)for(let p=1;p<=n;p+=1){const m=a+p*o;if(m<=t){const d=m*this.pixelsPerSecond;this.timeMarkers.circle(d,r,1.5),this.timeMarkers.fill(i)}}}drawTimeLabels(){this.timeLabels.removeChildren();const e=this.getTimeInterval(),t=this.getVisibleDuration(),i=this.theme?.timeline.ruler.text||16777215,r={fontSize:$t.RULER.LABEL_FONT_SIZE,fill:i,fontFamily:"Arial"};for(let n=0;n<=t;n+=e){const o=new R.Text({text:this.formatTime(n),style:r}),a=n*this.pixelsPerSecond;n===0?(o.anchor.set(0,.5),o.x=a+$t.RULER.LABEL_PADDING_X):(o.anchor.set(.5,.5),o.x=a),o.y=this.rulerHeight*.5,this.timeLabels.addChild(o)}}onRulerPointerDown(e){const t=this.rulerContainer.toLocal(e.global),i=Math.max(0,t.x/this.pixelsPerSecond);this.events.emit("ruler:seeked",{time:i})}updateRuler(e,t){this.pixelsPerSecond=e,this.timelineDuration=t,this.draw()}update(e,t){}draw(){this.drawRulerBackground(),this.drawTimeMarkers(),this.drawTimeLabels()}dispose(){this.timeLabels.removeChildren(),this.rulerContainer.removeChildren(),this.events.clear("*")}getViewportWidth(){return this.getContainer().parent?.width||800}calculateRulerWidth(){const e=this.timelineDuration*this.pixelsPerSecond;return Math.max(e,this.getViewportWidth())}getVisibleDuration(){return Math.max(this.timelineDuration,this.getViewportWidth()/this.pixelsPerSecond)}getTimeInterval(){const e=[1,5,10,30,60,120,300,600],t=80;for(const i of e)if(i*this.pixelsPerSecond>=t)return i;return Math.ceil(this.getVisibleDuration()/10)}formatTime(e){if(e===0)return"0s";const t=Math.floor(e/60),i=e%60;if(e<60)return`${e}s`;if(i===0)return`${t}m`;const r=i.toString().padStart(2,"0");return`${t}:${r}`}}class In extends Je{constructor(e){super(),this.options=e,this.graphics=new R.Graphics}events=new Kt;graphics;currentTime=0;isDragging=!1;async load(){this.setupPlayhead(),this.draw()}setupPlayhead(){this.graphics.label="playhead",this.graphics.eventMode="static",this.graphics.cursor="pointer",this.graphics.on("pointerdown",this.onPointerDown.bind(this)).on("pointermove",this.onPointerMove.bind(this)).on("pointerup",this.onPointerUp.bind(this)).on("pointerupoutside",this.onPointerUp.bind(this)),this.getContainer().addChild(this.graphics)}drawPlayhead(){const e=this.currentTime*this.options.pixelsPerSecond,t=this.options.theme?.timeline.playhead??16729156,i=$t.PLAYHEAD.LINE_WIDTH,r=e+i/2;this.graphics.clear(),this.graphics.fill(t),this.graphics.rect(e,0,i,this.options.timelineHeight);const n=8;this.graphics.moveTo(r,10),this.graphics.lineTo(r-n,0),this.graphics.lineTo(r+n,0),this.graphics.closePath(),this.graphics.fill()}onPointerDown(e){this.isDragging=!0,this.graphics.cursor="grabbing",this.updateTimeFromPointer(e)}onPointerMove(e){this.isDragging&&this.updateTimeFromPointer(e)}onPointerUp(){this.isDragging=!1,this.graphics.cursor="pointer"}updateTimeFromPointer(e){if(!this.graphics.parent)return;const t=this.graphics.parent.toLocal(e.global),i=Math.max(0,t.x/this.options.pixelsPerSecond);this.setTime(i),this.events.emit("playhead:seeked",{time:i})}setTime(e){this.currentTime=e,this.draw(),this.events.emit("playhead:timeChanged",{time:e})}getTime(){return this.currentTime}updatePlayhead(e,t){this.options.pixelsPerSecond=e,this.options.timelineHeight=t,this.draw()}update(){}draw(){this.drawPlayhead()}dispose(){this.graphics.removeAllListeners(),this.events.clear("*")}}class Dh{events;timeline;abortController;scrollX=0;scrollY=0;constructor(e){this.events=new Kt,this.timeline=e.timeline}async initialize(){this.setupEventListeners()}setupEventListeners(){this.abortController=new AbortController;const{canvas:e}=this.timeline.getPixiApp();e.addEventListener("wheel",this.handleWheel.bind(this),{passive:!1,signal:this.abortController.signal})}handleWheel(e){if(e.preventDefault(),e.ctrlKey||e.metaKey){this.handleZoom(e);return}this.handleScroll(e)}handleZoom(e){const t=e.deltaY>0?"out":"in",i=this.timeline.getPlayheadTime(),r=this.timeline.getActualEditDuration();t==="in"?this.timeline.zoomIn():this.timeline.zoomOut();const n=this.timeline.getOptions().pixelsPerSecond||50,o=i*n,a=this.timeline.getOptions().width||800,m=this.timeline.timeRange.endTime*n,d=r*n,l=this.calculateZoomScrollPosition({playheadXAfterZoom:o,viewportWidth:a,contentWidth:m,maxPlayheadX:d,actualEditDuration:r,playheadTime:i});this.scrollX=l,this.timeline.setScroll(this.scrollX,this.scrollY);const c=o-l;this.events.emit("zoom",{pixelsPerSecond:n,focusX:c,focusTime:i})}handleScroll(e){let{deltaX:t}=e,{deltaY:i}=e;e.shiftKey&&(t=i,i=0);const r=$t.SCROLL.HORIZONTAL_SPEED,n=$t.SCROLL.VERTICAL_SPEED;this.scrollX+=t*r,this.scrollY+=i*n,this.scrollX=this.clampScrollX(this.scrollX),this.scrollY=this.clampScrollY(this.scrollY),this.timeline.setScroll(this.scrollX,this.scrollY),this.events.emit("scroll",{x:this.scrollX,y:this.scrollY})}setScroll(e,t){this.scrollX=this.clampScrollX(e),this.scrollY=this.clampScrollY(t),this.timeline.setScroll(this.scrollX,this.scrollY),this.events.emit("scroll",{x:this.scrollX,y:this.scrollY})}clampScrollX(e){const t=this.timeline.getExtendedTimelineWidth(),i=this.timeline.getOptions().width||0,r=Math.max(0,t-i);return Math.max(0,Math.min(e,r))}clampScrollY(e){const t=this.timeline.getLayout(),i=this.timeline.getVisualTracks().length,r=this.timeline.getOptions().height||0,n=Math.max(0,i*t.trackHeight-(r-t.rulerHeight));return Math.max(0,Math.min(e,n))}getScroll(){return{x:this.scrollX,y:this.scrollY}}calculateZoomScrollPosition(e){const{playheadXAfterZoom:t,viewportWidth:i,contentWidth:r,maxPlayheadX:n,actualEditDuration:o,playheadTime:a}=e,p=t-i/2,m=Math.max(0,r-i);let d;const l=p+i,c=Math.max(0,n-i);r<=i||p<0?d=0:l>n&&a<=o?d=Math.min(c,m):p>m?d=m:d=p;const u=t-d;return(u<0||u>i)&&(t>r-i?d=Math.max(0,t-i+50):d=Math.max(0,t-50),d=Math.max(0,Math.min(d,m))),d}dispose(){this.abortController&&(this.abortController.abort(),this.abortController=void 0),this.events.clear("*")}}const ue={BUTTON_SIZE:24,BUTTON_HOVER_PADDING:4,BORDER_RADIUS:4,TEXT_SPACING:16,EDGE_MARGIN:10,FRAME_TIME_MS:16.67,ICON:{PLAY:{LEFT:6,TOP:4,RIGHT:18,MIDDLE:12,BOTTOM:20},PAUSE:{RECT1_X:6,RECT2_X:14,TOP:4,WIDTH:4,HEIGHT:16},FRAME_STEP:{TRIANGLE1:{BACK:{LEFT:11,RIGHT:3,MIDDLE:12},FORWARD:{LEFT:4,RIGHT:12,MIDDLE:12}},TRIANGLE2:{BACK:{LEFT:20,RIGHT:12,MIDDLE:12},FORWARD:{LEFT:13,RIGHT:21,MIDDLE:12}},TOP:4,BOTTOM:20}},CUT_BUTTON:{WIDTH:60,HEIGHT:24,FONT_SIZE:12},TIME_DISPLAY:{FONT_SIZE:14,FONT_FAMILY:"monospace"},HOVER_ANIMATION_ALPHA:1,ACTIVE_ANIMATION_ALPHA:.3,DIVIDER_ALPHA:.5};class Ii{static createIcon(e,t,i){const r=i?i/ue.BUTTON_SIZE:1;switch(e){case"play":return this.createPlayIcon(t,r);case"pause":return this.createPauseIcon(t,r);case"frame-back":return this.createFrameBackIcon(t,r);case"frame-forward":return this.createFrameForwardIcon(t,r);default:throw new Error(`Unknown icon type: ${e}`)}}static createPlayIcon(e,t=1){const i=new R.Graphics,{PLAY:r}=ue.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.LEFT*t,r.TOP*t),i.lineTo(r.RIGHT*t,r.MIDDLE*t),i.lineTo(r.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static createPauseIcon(e,t=1){const i=new R.Graphics,{PAUSE:r}=ue.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.rect(r.RECT1_X*t,r.TOP*t,r.WIDTH*t,r.HEIGHT*t),i.rect(r.RECT2_X*t,r.TOP*t,r.WIDTH*t,r.HEIGHT*t),i.fill(),i}static createFrameBackIcon(e,t=1){const i=new R.Graphics,{FRAME_STEP:r}=ue.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.TRIANGLE1.BACK.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE1.BACK.RIGHT*t,r.TRIANGLE1.BACK.MIDDLE*t),i.lineTo(r.TRIANGLE1.BACK.LEFT*t,r.BOTTOM*t),i.closePath(),i.moveTo(r.TRIANGLE2.BACK.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE2.BACK.RIGHT*t,r.TRIANGLE2.BACK.MIDDLE*t),i.lineTo(r.TRIANGLE2.BACK.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static createFrameForwardIcon(e,t=1){const i=new R.Graphics,{FRAME_STEP:r}=ue.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.TRIANGLE1.FORWARD.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE1.FORWARD.RIGHT*t,r.TRIANGLE1.FORWARD.MIDDLE*t),i.lineTo(r.TRIANGLE1.FORWARD.LEFT*t,r.BOTTOM*t),i.closePath(),i.moveTo(r.TRIANGLE2.FORWARD.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE2.FORWARD.RIGHT*t,r.TRIANGLE2.FORWARD.MIDDLE*t),i.lineTo(r.TRIANGLE2.FORWARD.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static updateIconColor(e,t){const i=e.getBounds();e.clear(),e.position.set(i.x,i.y)}}class Pn extends R.Container{background;hoverBackground;icon;alternateIcon;state={isHovering:!1,isPressed:!1,isActive:!1};size;theme;onClick;constructor(e){super(),this.size=e.size||ue.BUTTON_SIZE,this.theme=e.theme,this.onClick=e.onClick,this.eventMode="static",this.cursor="pointer",this.background=new R.Graphics,this.addChild(this.background),this.hoverBackground=new R.Graphics,this.addChild(this.hoverBackground);const i=this.size*.6,r=(this.size-i)/2;e.iconType&&(this.icon=Ii.createIcon(e.iconType,this.theme,i),this.icon.position.set(r,r),this.addChild(this.icon)),e.alternateIconType&&(this.alternateIcon=Ii.createIcon(e.alternateIconType,this.theme,i),this.alternateIcon.position.set(r,r),this.alternateIcon.visible=!1,this.addChild(this.alternateIcon)),this.setupEventListeners(),this.updateVisuals()}setupEventListeners(){this.on("pointerdown",this.handlePointerDown,this),this.on("pointerup",this.handlePointerUp,this),this.on("pointerupoutside",this.handlePointerUp,this),this.on("pointerover",this.handlePointerOver,this),this.on("pointerout",this.handlePointerOut,this)}handlePointerDown(){this.state.isPressed=!0,this.updateVisuals()}handlePointerUp(){this.state.isPressed&&this.onClick(),this.state.isPressed=!1,this.updateVisuals()}handlePointerOver(){this.state.isHovering=!0,this.updateVisuals()}handlePointerOut(){this.state.isHovering=!1,this.state.isPressed=!1,this.updateVisuals()}updateVisuals(){const e=ue.BUTTON_HOVER_PADDING,t=this.size/2;this.background.clear(),this.background.circle(t,t,t),this.background.fill({color:this.theme.timeline.toolbar.surface,alpha:.8}),this.hoverBackground.clear(),this.hoverBackground.circle(t,t,t+e),this.state.isPressed?this.hoverBackground.fill({color:this.theme.timeline.toolbar.active,alpha:ue.ACTIVE_ANIMATION_ALPHA}):this.state.isHovering?this.hoverBackground.fill({color:this.theme.timeline.toolbar.hover,alpha:ue.HOVER_ANIMATION_ALPHA}):this.hoverBackground.fill({color:this.theme.timeline.toolbar.hover,alpha:0})}setActive(e){this.state.isActive=e,this.icon&&this.alternateIcon&&(this.icon.visible=!e,this.alternateIcon.visible=e)}updateTheme(e){this.theme=e;const i=this.size*.6,r=(this.size-i)/2;if(this.icon){const n=this.getIconType(this.icon);n&&(this.removeChild(this.icon),this.icon=Ii.createIcon(n,e,i),this.icon.position.set(r,r),this.addChild(this.icon))}if(this.alternateIcon){const n=this.getIconType(this.alternateIcon);n&&(this.removeChild(this.alternateIcon),this.alternateIcon=Ii.createIcon(n,e,i),this.alternateIcon.position.set(r,r),this.alternateIcon.visible=this.state.isActive,this.addChild(this.alternateIcon))}this.updateVisuals()}getIconType(e){return null}destroy(){this.removeAllListeners(),super.destroy()}}class zh extends R.Container{edit;theme;toolbarHeight;frameBackButton;playPauseButton;frameForwardButton;constructor(e,t,i){super(),this.edit=e,this.theme=t,this.toolbarHeight=i||36,this.createButtons(),this.subscribeToEditEvents(),this.updatePlayPauseState()}createButtons(){const e=this.calculateButtonSizes(),t=(e.playButton-e.regularButton)/2,i=(r,n,o,a)=>new Pn({iconType:r,onClick:n,tooltip:o,theme:this.theme,size:a});this.frameBackButton=i("frame-back",()=>this.handleFrameBack(),"Previous frame",e.regularButton),this.frameBackButton.position.set(0,t),this.playPauseButton=new Pn({iconType:"play",alternateIconType:"pause",onClick:()=>this.handlePlayPause(),tooltip:"Play/Pause",theme:this.theme,size:e.playButton}),this.playPauseButton.position.set(e.regularButton+e.spacing,0),this.frameForwardButton=i("frame-forward",()=>this.handleFrameForward(),"Next frame",e.regularButton),this.frameForwardButton.position.set(e.regularButton+e.spacing+e.playButton+e.spacing,t),this.addChild(this.frameBackButton,this.playPauseButton,this.frameForwardButton)}calculateButtonSizes(){const e=Math.round(this.toolbarHeight*.5);return{regularButton:e,playButton:Math.round(e*1.5),spacing:Math.round(this.toolbarHeight*.15)}}handleFrameBack(){this.edit.seek(this.edit.playbackTime-ue.FRAME_TIME_MS)}handlePlayPause(){this.edit.isPlaying?this.edit.pause():this.edit.play()}handleFrameForward(){this.edit.seek(this.edit.playbackTime+ue.FRAME_TIME_MS)}subscribeToEditEvents(){this.edit.events.on("playback:play",this.updatePlayPauseState),this.edit.events.on("playback:pause",this.updatePlayPauseState)}updatePlayPauseState=()=>{this.playPauseButton.setActive(this.edit.isPlaying)};update(){}resize(e){}updateTheme(e){this.theme=e,this.frameBackButton.updateTheme(e),this.playPauseButton.updateTheme(e),this.frameForwardButton.updateTheme(e)}destroy(){this.edit.events.off("playback:play",this.updatePlayPauseState),this.edit.events.off("playback:pause",this.updatePlayPauseState),this.frameBackButton.destroy(),this.playPauseButton.destroy(),this.frameForwardButton.destroy(),super.destroy()}getWidth(){const e=this.calculateButtonSizes();return e.regularButton*2+e.playButton+e.spacing*2}}class Hh extends R.Container{edit;theme;timeText;formatOptions;constructor(e,t,i={}){super(),this.edit=e,this.theme=t,this.formatOptions={showMilliseconds:!1,showHours:!1,...i},this.createDisplay(),this.subscribeToEditEvents(),this.updateTimeDisplay()}createDisplay(){const e=new R.TextStyle({fontFamily:ue.TIME_DISPLAY.FONT_FAMILY,fontSize:ue.TIME_DISPLAY.FONT_SIZE,fill:this.theme.timeline.toolbar.text});this.timeText=new R.Text("0:00 / 0:00",e),this.timeText.anchor.set(0,.5),this.addChild(this.timeText)}subscribeToEditEvents(){this.edit.events.on("playback:time",this.updateTimeDisplay),this.edit.events.on("duration:changed",this.updateTimeDisplay)}updateTimeDisplay=()=>{const e=this.formatTime(this.edit.playbackTime/1e3),t=this.formatTime(this.edit.getTotalDuration()/1e3);this.timeText.text=`${e} / ${t}`};formatTime(e){const t=Math.floor(e/3600),i=Math.floor(e%3600/60),r=Math.floor(e%60),n=Math.floor(e%1*10);let o="";return this.formatOptions.showHours||t>0?o+=`${t}:${i.toString().padStart(2,"0")}`:o+=`${i}`,o+=`:${r.toString().padStart(2,"0")}`,this.formatOptions.showMilliseconds?o+=`.${n}`:o+=`.${n}`,o}update(){this.updateTimeDisplay()}resize(e){}updateTheme(e){this.theme=e,this.timeText.style.fill=e.timeline.toolbar.text}destroy(){this.edit.events.off("playback:time",this.updateTimeDisplay),this.edit.events.off("duration:changed",this.updateTimeDisplay),super.destroy()}getWidth(){return this.timeText.width}}class Nh extends R.Container{edit;theme;cutButton;cutButtonBackground;cutButtonText;constructor(e,t){super(),this.edit=e,this.theme=t,this.createCutButton()}createCutButton(){this.cutButton=new R.Container,this.cutButton.eventMode="static",this.cutButton.cursor="pointer";const{WIDTH:e,HEIGHT:t,FONT_SIZE:i}=ue.CUT_BUTTON;this.cutButtonBackground=new R.Graphics,this.cutButtonBackground.roundRect(0,0,e,t,ue.BORDER_RADIUS),this.cutButtonBackground.fill({color:this.theme.timeline.toolbar.surface||4473924}),this.cutButtonBackground.stroke({color:this.theme.timeline.tracks.border||6710886,width:1}),this.cutButton.addChild(this.cutButtonBackground);const r=new R.TextStyle({fontFamily:"Arial",fontSize:i,fill:this.theme.timeline.toolbar.text||16777215});this.cutButtonText=new R.Text("SPLIT",r),this.cutButtonText.anchor.set(.5),this.cutButtonText.position.set(e/2,t/2),this.cutButton.addChild(this.cutButtonText),this.cutButton.on("click",this.handleCutClick,this),this.cutButton.on("pointerdown",this.handlePointerDown,this),this.cutButton.on("pointerover",this.handlePointerOver,this),this.cutButton.on("pointerout",this.handlePointerOut,this),this.addChild(this.cutButton)}handleCutClick=e=>{e.stopPropagation(),this.performCutClip()};handlePointerDown=e=>{e.stopPropagation(),this.updateButtonVisual(!0,!1)};handlePointerOver=()=>{this.updateButtonVisual(!1,!0)};handlePointerOut=()=>{this.updateButtonVisual(!1,!1)};updateButtonVisual(e,t){this.cutButtonBackground.clear(),this.cutButtonBackground.roundRect(0,0,ue.CUT_BUTTON.WIDTH,ue.CUT_BUTTON.HEIGHT,ue.BORDER_RADIUS);let i=this.theme.timeline.toolbar.surface||4473924;const r=1;e?i=this.theme.timeline.toolbar.active||3355443:t&&(i=this.theme.timeline.toolbar.hover||5592405),this.cutButtonBackground.fill({color:i,alpha:r}),this.cutButtonBackground.stroke({color:this.theme.timeline.tracks.border||6710886,width:1})}performCutClip(){const e=this.edit.getSelectedClipInfo();if(!e)return;const{trackIndex:t,clipIndex:i}=e,r=this.edit.playbackTime/1e3;this.edit.splitClip(t,i,r)}update(){const e=this.edit.getSelectedClipInfo()!==null;this.cutButton.alpha=e?1:.5,this.cutButton.eventMode=e?"static":"none",this.cutButton.cursor=e?"pointer":"default"}resize(e){}updateTheme(e){this.theme=e,this.updateButtonVisual(!1,!1),this.cutButtonText.style.fill=e.timeline.toolbar.text||16777215}destroy(){this.cutButton.removeAllListeners(),super.destroy()}getWidth(){return ue.CUT_BUTTON.WIDTH}}class Uh{config;constructor(e,t){this.config={width:e,height:t,buttonSize:Math.round(t*.5),buttonSpacing:Math.round(t*.15),edgeMargin:ue.EDGE_MARGIN}}getPlaybackControlsPosition(){const e=this.calculatePlaybackControlsWidth(),t=(this.config.width-e)/2,i=(this.config.height-this.getMaxButtonHeight())/2;return{x:t,y:i}}getMaxButtonHeight(){const e=this.config.buttonSize;return Math.round(e*1.5)}getTimeDisplayPosition(e){const i=(this.config.width-e)/2+e+ue.TEXT_SPACING,r=this.config.height/2;return{x:i,y:r}}getEditControlsPosition(){const e=this.config.width-ue.CUT_BUTTON.WIDTH-this.config.edgeMargin,t=(this.config.height-ue.CUT_BUTTON.HEIGHT)/2;return{x:e,y:t}}calculatePlaybackControlsWidth(){const e=this.config.buttonSize,t=Math.round(e*1.5);return e*2+t+this.config.buttonSpacing*2}updateWidth(e){this.config.width=e}getConfig(){return{...this.config}}}class jh extends R.Container{constructor(e,t,i,r){super(),this.edit=e,this.theme=t,this.layout=i,this.toolbarWidth=r,this.toolbarHeight=i.toolbarHeight,this.position.set(0,i.toolbarY),this.toolbarLayout=new Uh(r,this.toolbarHeight),this.createBackground(),this.createComponents(),this.positionComponents(),this.subscribeToEditEvents()}background;playbackControls;timeDisplay;editControls;toolbarLayout;toolbarWidth;toolbarHeight;get width(){return this.toolbarWidth}get height(){return this.toolbarHeight}createBackground(){this.background=new R.Graphics,this.drawBackground(),this.addChild(this.background)}drawBackground(){this.background.clear(),this.background.rect(0,0,this.toolbarWidth,this.toolbarHeight),this.background.fill({color:this.theme.timeline.toolbar.background}),this.background.setStrokeStyle({width:1,color:this.theme.timeline.toolbar.divider,alpha:ue.DIVIDER_ALPHA}),this.background.moveTo(0,this.toolbarHeight-.5),this.background.lineTo(this.toolbarWidth,this.toolbarHeight-.5),this.background.stroke()}createComponents(){this.playbackControls=new zh(this.edit,this.theme,this.toolbarHeight),this.addChild(this.playbackControls),this.timeDisplay=new Hh(this.edit,this.theme),this.addChild(this.timeDisplay),this.editControls=new Nh(this.edit,this.theme),this.addChild(this.editControls)}positionComponents(){const e=this.toolbarLayout.getPlaybackControlsPosition();this.playbackControls.position.set(e.x,e.y);const t=this.toolbarLayout.getTimeDisplayPosition(this.playbackControls.getWidth());this.timeDisplay.position.set(t.x,t.y);const i=this.toolbarLayout.getEditControlsPosition();this.editControls.position.set(i.x,i.y)}subscribeToEditEvents(){this.edit.events.on("clip:selected",this.updateEditControls),this.edit.events.on("selection:cleared",this.updateEditControls)}updateEditControls=()=>{this.editControls.update()};resize(e){this.toolbarWidth=e,this.toolbarLayout.updateWidth(e),this.drawBackground(),this.positionComponents(),this.playbackControls.resize(e),this.timeDisplay.resize(e),this.editControls.resize(e)}updateTheme(e){this.theme=e,this.drawBackground(),this.playbackControls.updateTheme(e),this.timeDisplay.updateTheme(e),this.editControls.updateTheme(e)}updateTimeDisplay=()=>{this.timeDisplay.update()};destroy(){this.edit.events.off("clip:selected",this.updateEditControls),this.edit.events.off("selection:cleared",this.updateEditControls),this.playbackControls.destroy(),this.timeDisplay.destroy(),this.editControls.destroy(),super.destroy()}}class Vh{constructor(e,t,i,r,n,o){this.edit=e,this.layout=t,this.renderer=i,this.viewportManager=r,this.eventHandler=n,this.getTimelineContext=o}toolbar;ruler;playhead;scroll;async setupTimelineFeatures(e,t,i,r,n){this.toolbar=new jh(this.edit,e,this.layout,i),this.renderer.getStage().addChild(this.toolbar);const o={pixelsPerSecond:t,timelineDuration:n,rulerHeight:this.layout.rulerHeight,theme:e};this.ruler=new An(o),await this.ruler.load(),this.ruler.getContainer().y=this.layout.rulerY,this.viewportManager.getRulerViewport().addChild(this.ruler.getContainer()),this.ruler.events.on("ruler:seeked",this.eventHandler.handleSeek.bind(this.eventHandler));const a={pixelsPerSecond:t,timelineHeight:r,theme:e};this.playhead=new In(a),await this.playhead.load(),this.playhead.getContainer().y=this.layout.rulerY,this.viewportManager.getPlayheadContainer().addChild(this.playhead.getContainer()),this.playhead.events.on("playhead:seeked",this.eventHandler.handleSeek.bind(this.eventHandler));const p={timeline:this.getTimelineContext()};this.scroll=new Dh(p),await this.scroll.initialize(),this.viewportManager.updateViewportTransform()}recreateTimelineFeatures(e,t,i,r){if(this.ruler){this.ruler.dispose();const{rulerHeight:n}=this.layout,o={pixelsPerSecond:t,timelineDuration:r,rulerHeight:n,theme:e};this.ruler=new An(o),this.ruler.load(),this.ruler.getContainer().y=this.layout.rulerY,this.viewportManager.getRulerViewport().addChild(this.ruler.getContainer()),this.ruler.events.on("ruler:seeked",this.eventHandler.handleSeek.bind(this.eventHandler))}if(this.playhead){this.playhead.dispose();const n={pixelsPerSecond:t,timelineHeight:i,theme:e};this.playhead=new In(n),this.playhead.load(),this.playhead.getContainer().y=this.layout.rulerY,this.viewportManager.getPlayheadContainer().addChild(this.playhead.getContainer()),this.playhead.events.on("playhead:seeked",this.eventHandler.handleSeek.bind(this.eventHandler))}}updateRuler(e,t){this.ruler.updateRuler(e,t)}updatePlayhead(e,t){this.playhead&&this.playhead.updatePlayhead(e,t)}getFeatures(){return{toolbar:this.toolbar,ruler:this.ruler,playhead:this.playhead,scroll:this.scroll}}getToolbar(){return this.toolbar}getPlayhead(){return this.playhead}dispose(){this.toolbar&&this.toolbar.destroy(),this.ruler&&this.ruler.dispose(),this.playhead&&this.playhead.dispose(),this.scroll&&this.scroll.dispose()}}class Ye{constructor(e,t){this.options=e,this.theme=t,this.config=this.calculateLayout()}static TOOLBAR_HEIGHT_RATIO=Le.TOOLBAR_HEIGHT_RATIO;static RULER_HEIGHT_RATIO=Le.RULER_HEIGHT_RATIO;static TOOLBAR_HEIGHT_DEFAULT=Le.TOOLBAR_HEIGHT_DEFAULT;static RULER_HEIGHT_DEFAULT=Le.RULER_HEIGHT_DEFAULT;static TRACK_HEIGHT_DEFAULT=Le.TRACK_HEIGHT_DEFAULT;static CLIP_PADDING=Le.CLIP_PADDING;static BORDER_WIDTH=Le.BORDER_WIDTH;static CORNER_RADIUS=Le.CORNER_RADIUS;static LABEL_PADDING=Le.LABEL_PADDING;static TRACK_PADDING=Le.TRACK_PADDING;config;calculateLayout(){const e=this.options.height;let t=this.theme?.timeline.toolbar.height||Math.round(e*Ye.TOOLBAR_HEIGHT_RATIO),i=this.theme?.timeline.ruler.height||Math.round(e*Ye.RULER_HEIGHT_RATIO);t=Math.max(t,Ye.TOOLBAR_HEIGHT_DEFAULT),i=Math.max(i,Ye.RULER_HEIGHT_DEFAULT);const{trackHeight:r}=this.options;return{toolbarHeight:t,rulerHeight:i,trackHeight:r,toolbarY:0,rulerY:t,tracksY:t+i,gridY:t+i,playheadY:t,viewportY:t+i}}get toolbarHeight(){return this.config.toolbarHeight}get toolbarY(){return this.config.toolbarY}get rulerHeight(){return this.config.rulerHeight}get trackHeight(){return this.config.trackHeight}get rulerY(){return this.config.rulerY}get tracksY(){return this.config.tracksY}get gridY(){return this.config.gridY}get playheadY(){return this.config.playheadY}get viewportY(){return this.config.viewportY}positionTrack(e){return e*this.trackHeight}positionClip(e){return e*this.options.pixelsPerSecond}calculateClipWidth(e){return Math.max(Le.MIN_CLIP_WIDTH,e*this.options.pixelsPerSecond)}calculateDropPosition(e,t){const i=t-this.tracksY,r=Math.floor(i/this.trackHeight),n=Math.max(0,e/this.options.pixelsPerSecond);return{track:Math.max(0,r),time:n,x:e,y:i}}getTrackAtY(e){const t=e-this.tracksY;return Math.floor(t/this.trackHeight)}getTimeAtX(e){return e/this.options.pixelsPerSecond}getXAtTime(e){return e*this.options.pixelsPerSecond}getYAtTrack(e){return this.tracksY+e*this.trackHeight}getGridHeight(){return this.options.height-this.toolbarHeight-this.rulerHeight}getRulerWidth(){return this.options.width}getGridWidth(){return this.options.width}calculateViewportPosition(e,t){return{x:-e,y:this.viewportY-t}}updateOptions(e,t){this.options=e,this.theme=t,this.config=this.calculateLayout()}isPointInToolbar(e,t){return t>=this.toolbarY&&t<=this.toolbarY+this.toolbarHeight}isPointInRuler(e,t){return t>=this.rulerY&&t<=this.rulerY+this.rulerHeight}isPointInTracks(e,t){return t>=this.tracksY&&t<=this.options.height}getVisibleTrackRange(e,t){const i=e,r=Math.floor(i/this.trackHeight),n=Math.ceil((i+t)/this.trackHeight);return{start:Math.max(0,r),end:Math.max(0,n)}}}class Ge{constructor(e,t,i,r){this.layout=i,this.onResize=r,this.width=e.width,this.height=e.height,this.pixelsPerSecond=50;const n=t.timeline.tracks.height||Ye.TRACK_HEIGHT_DEFAULT;this.trackHeight=Math.max(40,n),this.backgroundColor=t.timeline.background,this.antialias=!0,this.resolution=window.devicePixelRatio||1}pixelsPerSecond;trackHeight;backgroundColor;antialias;resolution;width;height;static MIN_PIXELS_PER_SECOND=10;static MAX_PIXELS_PER_SECOND=500;static ZOOM_FACTOR=1.1;getOptions(){return{width:this.width,height:this.height,pixelsPerSecond:this.pixelsPerSecond,trackHeight:this.trackHeight,backgroundColor:this.backgroundColor,antialias:this.antialias,resolution:this.resolution}}setOptions(e){e.width!==void 0&&(this.width=e.width,this.onResize&&this.onResize(this.width)),e.height!==void 0&&(this.height=e.height),e.pixelsPerSecond!==void 0&&(this.pixelsPerSecond=e.pixelsPerSecond),e.trackHeight!==void 0&&(this.trackHeight=e.trackHeight),e.backgroundColor!==void 0&&(this.backgroundColor=e.backgroundColor),e.antialias!==void 0&&(this.antialias=e.antialias),e.resolution!==void 0&&(this.resolution=e.resolution),this.layout.updateOptions(this.getOptions())}updateFromTheme(e){this.backgroundColor=e.timeline.background;const t=e.timeline.tracks.height||Ye.TRACK_HEIGHT_DEFAULT;this.trackHeight=Math.max(40,t),this.layout.updateOptions(this.getOptions(),e)}getWidth(){return this.width}getHeight(){return this.height}getPixelsPerSecond(){return this.pixelsPerSecond}getTrackHeight(){return this.trackHeight}getBackgroundColor(){return this.backgroundColor}getAntialias(){return this.antialias}getResolution(){return this.resolution}zoomIn(){const e=Math.min(this.pixelsPerSecond*Ge.ZOOM_FACTOR,Ge.MAX_PIXELS_PER_SECOND);this.setPixelsPerSecond(e)}zoomOut(){const e=Math.max(this.pixelsPerSecond/Ge.ZOOM_FACTOR,Ge.MIN_PIXELS_PER_SECOND);this.setPixelsPerSecond(e)}setPixelsPerSecond(e){this.pixelsPerSecond=Math.max(Ge.MIN_PIXELS_PER_SECOND,Math.min(Ge.MAX_PIXELS_PER_SECOND,e)),this.layout.updateOptions(this.getOptions())}canZoomIn(){return this.pixelsPerSecond<Ge.MAX_PIXELS_PER_SECOND}canZoomOut(){return this.pixelsPerSecond>Ge.MIN_PIXELS_PER_SECOND}}class ks extends Je{constructor(e,t,i){super(),this.edit=e,this.theme=Sn.resolveTheme(i),this.layout=new Ye({width:t.width,height:t.height,pixelsPerSecond:50,trackHeight:Math.max(40,this.theme.timeline.tracks.height||Ye.TRACK_HEIGHT_DEFAULT),backgroundColor:this.theme.timeline.background,antialias:!0,resolution:window.devicePixelRatio||1},this.theme),this.optionsManager=new Ge(t,this.theme,this.layout,r=>this.featureManager?.getToolbar()?.resize(r)),this.initializeManagers(),this.setupInteraction()}currentEditType=null;layout;theme;lastPlaybackTime=0;static TIMELINE_BUFFER_MULTIPLIER=1.5;interaction;dragPreviewManager;viewportManager;visualTrackManager;eventHandler;renderer;featureManager;optionsManager;initializeManagers(){const e=this.optionsManager.getOptions();this.renderer=new $h({width:e.width||800,height:e.height||600,backgroundColor:e.backgroundColor||0,antialias:e.antialias??!0,resolution:e.resolution||window.devicePixelRatio||1},(t,i)=>this.update(t,i)),this.eventHandler=new Bh(this.edit,{onEditChange:this.handleEditChange.bind(this),onSeek:t=>this.edit.seek(t),onClipSelected:(t,i)=>this.visualTrackManager.updateVisualSelection(t,i),onSelectionCleared:()=>this.visualTrackManager.clearVisualSelection(),onDragStarted:(t,i)=>{const r=this.getClipData(t,i);r&&this.dragPreviewManager.showDragPreview(t,i,r)},onDragEnded:()=>this.dragPreviewManager.hideDragPreview()}),this.eventHandler.setupEventListeners()}async load(){await this.renderer.initializePixiApp(),await this.renderer.setupRenderLayers(),await this.setupViewport(),await this.setupTimelineFeatures(),this.interaction.activate();try{const e=this.edit.getEdit();e&&(this.currentEditType=e,await this.rebuildFromEdit(e))}catch{}this.renderer.startAnimationLoop()}async setupViewport(){this.viewportManager=new Ph(this.layout,this.renderer.getTrackLayer(),this.renderer.getOverlayLayer(),this.getContainer(),()=>this.renderer.render()),await this.viewportManager.setupViewport(),this.visualTrackManager=new Lh(this.getContainer(),this.layout,this.theme,()=>this.optionsManager.getPixelsPerSecond(),()=>this.getExtendedTimelineWidth()),this.dragPreviewManager=new Ih(this.getContainer(),this.layout,()=>this.optionsManager.getPixelsPerSecond(),()=>this.optionsManager.getTrackHeight(),()=>this.visualTrackManager.getVisualTracks()),this.featureManager=new Vh(this.edit,this.layout,this.renderer,this.viewportManager,this.eventHandler,()=>this)}async setupTimelineFeatures(){const e=this.getExtendedTimelineDuration();await this.featureManager.setupTimelineFeatures(this.theme,this.optionsManager.getPixelsPerSecond(),this.optionsManager.getWidth(),this.optionsManager.getHeight(),e)}recreateTimelineFeatures(){const e=this.getExtendedTimelineDuration();this.featureManager.recreateTimelineFeatures(this.theme,this.optionsManager.getPixelsPerSecond(),this.optionsManager.getHeight(),e)}setScroll(e,t){this.viewportManager.setScroll(e,t)}setZoom(e){this.viewportManager.setZoom(e)}getViewport(){return this.viewportManager.getViewport()}getPixiApp(){return this.renderer.getApp()}getTrackLayer(){return this.renderer.getTrackLayer()}getOverlayLayer(){return this.renderer.getOverlayLayer()}getClipData(e,t){return this.currentEditType?.timeline?.tracks&&this.currentEditType.timeline.tracks[e]?.clips?.[t]||null}getLayout(){return this.layout}getVisualTracks(){return this.visualTrackManager.getVisualTracks()}getEdit(){return this.edit}getExtendedTimelineWidth(){const e=this.getExtendedTimelineDuration()*this.optionsManager.getPixelsPerSecond(),t=this.optionsManager.getWidth();return Math.max(e,t)}hideDragGhost(){this.dragPreviewManager.hideDragGhost()}showDragGhost(e,t,i){this.dragPreviewManager.showDragGhost(e,t,i)}setPlayheadTime(e){this.featureManager.getPlayhead().setTime(e)}getPlayheadTime(){return this.featureManager.getPlayhead().getTime()}getActualEditDuration(){return this.edit.totalDuration/1e3||60}setupInteraction(){this.interaction=new Ah(this)}async handleEditChange(e){this.dragPreviewManager.hideDragPreview();const t=e||this.edit.getEdit();t&&(this.currentEditType=t,this.updateRulerDuration(),this.clearAllVisualState(),await this.rebuildFromEdit(t))}getExtendedTimelineDuration(){const e=this.edit.totalDuration/1e3||60;return Math.max(60,e*ks.TIMELINE_BUFFER_MULTIPLIER)}updateRulerDuration(){const e=this.getExtendedTimelineDuration(),t=this.getExtendedTimelineWidth();this.featureManager.updateRuler(this.optionsManager.getPixelsPerSecond(),e),this.visualTrackManager.updateTrackWidths(t)}clearAllVisualState(){this.dragPreviewManager.hideDragPreview(),this.visualTrackManager.clearAllVisualState()}async rebuildFromEdit(e){await this.visualTrackManager.rebuildFromEdit(e,this.optionsManager.getPixelsPerSecond()),this.renderer.render()}findClipAtPosition(e,t){return this.currentEditType?this.visualTrackManager.findClipAtPosition(e,t):null}setTheme(e){this.theme=Sn.resolveTheme(e),this.optionsManager.updateFromTheme(this.theme),this.featureManager.getToolbar()&&this.featureManager.getToolbar().updateTheme(this.theme),this.recreateTimelineFeatures(),this.currentEditType&&(this.clearAllVisualState(),this.rebuildFromEdit(this.currentEditType)),this.renderer.updateBackgroundColor(this.optionsManager.getBackgroundColor()),this.renderer.render()}getTheme(){return this.theme}getCurrentEditType(){return this.currentEditType}getOptions(){return this.optionsManager.getOptions()}setOptions(e){this.optionsManager.setOptions(e)}update(e,t){(this.edit.isPlaying||this.lastPlaybackTime!==this.edit.playbackTime)&&(this.featureManager.getPlayhead().setTime(this.edit.playbackTime/1e3),this.lastPlaybackTime=this.edit.playbackTime,this.featureManager.getToolbar()&&this.featureManager.getToolbar().updateTimeDisplay())}draw(){this.renderer.draw()}getTimeDisplay(){return this.featureManager.getToolbar()}updateTime(e,t){this.setPlayheadTime(e),t&&this.edit.seek(e*1e3)}get timeRange(){return{startTime:0,endTime:this.getExtendedTimelineDuration()}}get viewportHeight(){return this.optionsManager.getHeight()}get zoomLevelIndex(){const e=this.viewportManager.getViewport();return Math.round(Math.log2(e.zoom)+5)}zoomIn(){this.optionsManager.zoomIn(),this.onZoomChanged()}zoomOut(){this.optionsManager.zoomOut(),this.onZoomChanged()}onZoomChanged(){const e=this.optionsManager.getPixelsPerSecond();this.visualTrackManager.updatePixelsPerSecond(e);const t=this.getExtendedTimelineWidth();this.visualTrackManager.updateTrackWidths(t),this.featureManager.updateRuler(e,this.getExtendedTimelineDuration()),this.featureManager.updatePlayhead(e,this.optionsManager.getHeight()),this.renderer.render()}dispose(){this.dragPreviewManager.dispose(),this.visualTrackManager.dispose(),this.eventHandler.dispose(),this.featureManager.dispose(),this.interaction&&this.interaction.dispose(),this.renderer.dispose()}}var Rn={exports:{}};function Wh(s){var e=s.wasmExports,t=new TextDecoder("utf8");let i=s.addFunction,r=s.removeFunction;var n=i(function(I){e.free(I)},"vi"),o=2,a=-1,p=2,m=0,d=1,l=2;function c(I){return(I.charCodeAt(0)&255)<<24|(I.charCodeAt(1)&255)<<16|(I.charCodeAt(2)&255)<<8|(I.charCodeAt(3)&255)<<0}var u=c("JSON"),h=4;function f(I){return[String.fromCharCode(I>>24&255),String.fromCharCode(I>>16&255),String.fromCharCode(I>>8&255),String.fromCharCode(I>>0&255)].join("")}function b(I){return I=="BOT"?1:I=="EOT"?2:I=="PRESERVE_DEFAULT_IGNORABLES"?4:I=="REMOVE_DEFAULT_IGNORABLES"?8:I=="DO_NOT_INSERT_DOTTED_CIRCLE"?16:I=="PRODUCE_UNSAFE_TO_CONCAT"?64:0}function g(I){var L=e.malloc(I.byteLength);s.HEAPU8.set(new Uint8Array(I),L);var F=e.hb_blob_create(L,I.byteLength,o,L,n);return{ptr:F,destroy:function(){e.hb_blob_destroy(F)}}}function y(I){const L=e.hb_set_get_population(I),F=e.malloc(L<<2),Z=F>>2,Q=s.HEAPU32.subarray(Z,Z+L);return s.HEAPU32.set(Q,Z),e.hb_set_next_many(I,a,F,L),Q}function v(I,L){var F=e.hb_face_create(I.ptr,L);const Z=e.hb_face_get_upem(F);return{ptr:F,upem:Z,reference_table:function(Q){var X=e.hb_face_reference_table(F,c(Q)),Y=e.hb_blob_get_length(X);if(Y){var se=e.hb_blob_get_data(X,null),re=s.HEAPU8.subarray(se,se+Y);return re}},getAxisInfos:function(){var Q=e.malloc(2048),X=e.malloc(4);s.HEAPU32[X/4]=64,e.hb_ot_var_get_axis_infos(F,0,X,Q);var Y={};return Array.from({length:s.HEAPU32[X/4]}).forEach(function(se,re){Y[f(s.HEAPU32[Q/4+re*8+1])]={min:s.HEAPF32[Q/4+re*8+4],default:s.HEAPF32[Q/4+re*8+5],max:s.HEAPF32[Q/4+re*8+6]}}),e.free(X),e.free(Q),Y},collectUnicodes:function(){var Q=e.hb_set_create();e.hb_face_collect_unicodes(F,Q);var X=y(Q);return e.hb_set_destroy(Q),X},destroy:function(){e.hb_face_destroy(F)}}}var _="",C=256,S=e.malloc(C);function T(I){var L=e.hb_font_create(I.ptr),F=null,Z=null,Q=null,X=null,Y=null,se=null;function re(ve){if(!F){var ge=function(Fe,Dt,dt,Ze,Ke,xt){_+=`M${Ze},${Ke}`},de=function(Fe,Dt,dt,Ze,Ke,xt){_+=`L${Ze},${Ke}`},Oe=function(Fe,Dt,dt,Ze,Ke,xt,Qe,ni,Ri,Ts){_+=`C${Ze},${Ke} ${xt},${Qe} ${ni},${Ri}`},Ee=function(Fe,Dt,dt,Ze,Ke,xt,Qe,ni){_+=`Q${Ze},${Ke} ${xt},${Qe}`},Pi=function(Fe,Dt,dt,Ze){_+="Z"};Z=i(ge,"viiiffi"),Q=i(de,"viiiffi"),X=i(Oe,"viiiffffffi"),Y=i(Ee,"viiiffffi"),se=i(Pi,"viiii"),F=e.hb_draw_funcs_create(),e.hb_draw_funcs_set_move_to_func(F,Z,0,0),e.hb_draw_funcs_set_line_to_func(F,Q,0,0),e.hb_draw_funcs_set_cubic_to_func(F,X,0,0),e.hb_draw_funcs_set_quadratic_to_func(F,Y,0,0),e.hb_draw_funcs_set_close_path_func(F,se,0,0)}return _="",e.hb_font_draw_glyph(L,ve,F,0),_}function Ce(ve){e.hb_font_glyph_to_string(L,ve,S,C);var ge=s.HEAPU8.subarray(S,S+C);return t.decode(ge.slice(0,ge.indexOf(0)))}return{ptr:L,glyphName:Ce,glyphToPath:re,glyphToJson:function(ve){var ge=re(ve);return ge.replace(/([MLQCZ])/g,"|$1 ").split("|").filter(function(de){return de.length}).map(function(de){var Oe=de.split(/[ ,]/g);return{type:Oe[0],values:Oe.slice(1).filter(function(Ee){return Ee.length}).map(function(Ee){return+Ee})}})},setScale:function(ve,ge){e.hb_font_set_scale(L,ve,ge)},setVariations:function(ve){var ge=Object.entries(ve),de=e.malloc(8*ge.length);ge.forEach(function(Oe,Ee){s.HEAPU32[de/4+Ee*2+0]=c(Oe[0]),s.HEAPF32[de/4+Ee*2+1]=Oe[1]}),e.hb_font_set_variations(L,de,ge.length),e.free(de)},destroy:function(){e.hb_font_destroy(L),F&&(e.hb_draw_funcs_destroy(F),F=null,r(Z),r(Q),r(X),r(Y),r(se))}}}function w(I){var L=e.malloc(I.length+1);for(let F=0;F<I.length;++F){const Z=I.charCodeAt(F);if(Z>127)throw new Error("Expected ASCII text");s.HEAPU8[L+F]=Z}return s.HEAPU8[L+I.length]=0,{ptr:L,length:I.length,free:function(){e.free(L)}}}function x(I){const L=e.malloc(I.length*2),F=new Uint16Array(s.wasmMemory.buffer,L,I.length);for(let Z=0;Z<F.length;++Z)F[Z]=I.charCodeAt(Z);return{ptr:L,length:F.length,free:function(){e.free(L)}}}function k(){var I=e.hb_buffer_create();return{ptr:I,addText:function(L){const F=x(L);e.hb_buffer_add_utf16(I,F.ptr,F.length,0,F.length),F.free()},guessSegmentProperties:function(){return e.hb_buffer_guess_segment_properties(I)},setDirection:function(L){e.hb_buffer_set_direction(I,{ltr:4,rtl:5,ttb:6,btt:7}[L]||0)},setFlags:function(L){var F=0;L.forEach(function(Z){F|=b(Z)}),e.hb_buffer_set_flags(I,F)},setLanguage:function(L){var F=w(L);e.hb_buffer_set_language(I,e.hb_language_from_string(F.ptr,-1)),F.free()},setScript:function(L){var F=w(L);e.hb_buffer_set_script(I,e.hb_script_from_string(F.ptr,-1)),F.free()},setClusterLevel:function(L){e.hb_buffer_set_cluster_level(I,L)},json:function(){for(var L=e.hb_buffer_get_length(I),F=[],Z=e.hb_buffer_get_glyph_infos(I,0),Q=Z/4,X=e.hb_buffer_get_glyph_positions(I,0)/4,Y=s.HEAPU32.subarray(Q,Q+5*L),se=s.HEAP32.subarray(X,X+5*L),re=0;re<L;++re)F.push({g:Y[re*5+0],cl:Y[re*5+2],ax:se[re*5+0],ay:se[re*5+1],dx:se[re*5+2],dy:se[re*5+3],flags:e.hb_glyph_info_get_glyph_flags(Z+re*20)});return F},destroy:function(){e.hb_buffer_destroy(I)}}}function E(I,L,F){var Z=0,Q=0;F&&(F=F.split(","),Z=e.malloc(16*F.length),F.forEach(function(X,Y){var se=w(X);e.hb_feature_from_string(se.ptr,-1,Z+Q*16)&&Q++,se.free()})),e.hb_shape(I.ptr,L.ptr,Z,Q),Z&&e.free(Z)}function P(I,L,F,Z,Q){var X=[],Y=m,se=!1,re=1024*1024,Ce=e.malloc(re),ve=function(de,Oe,Ee,Pi){var Fe=t.decode(s.HEAPU8.subarray(Ee,s.HEAPU8.indexOf(0,Ee)));return Fe.startsWith("start table GSUB")?Y=d:Fe.startsWith("start table GPOS")&&(Y=l),Y!=Q&&(se=!1),Q!=m&&Y==Q&&Fe.startsWith("end lookup "+Z)&&(se=!0),se?0:(e.hb_buffer_serialize_glyphs(de,0,e.hb_buffer_get_length(de),Ce,re,0,Oe,u,h),X.push({m:Fe,t:JSON.parse(t.decode(s.HEAPU8.subarray(Ce,s.HEAPU8.indexOf(0,Ce)))),glyphs:e.hb_buffer_get_content_type(de)==p}),1)},ge=i(ve,"iiiii");return e.hb_buffer_set_message_func(L.ptr,ge,0,0),E(I,L,F),e.free(Ce),r(ge),X}function O(){var I=e.malloc(12);e.hb_version(I,I+4,I+8);var L={major:s.HEAPU32[I/4],minor:s.HEAPU32[(I+4)/4],micro:s.HEAPU32[(I+8)/4]};return e.free(I),L}function z(){var I=e.hb_version_string(),L=t.decode(s.HEAPU8.subarray(I,s.HEAPU8.indexOf(0,I)));return L}return{createBlob:g,createFace:v,createFont:T,createBuffer:k,shape:E,shapeWithTrace:P,version:O,version_string:z}}try{Rn.exports=Wh}catch{}var Gh=Rn.exports,On={exports:{}};const Zh=za(Gl);(function(s,e){var t=(()=>{var i=typeof document<"u"?document.currentScript?.src:void 0;return async function(r={}){var n,o=r,a=typeof window=="object",p=typeof WorkerGlobalScope<"u",m=typeof process=="object"&&process.versions?.node&&process.type!="renderer",d=(A,U)=>{throw U};typeof __filename<"u"?i=__filename:p&&(i=self.location.href);var l="";function c(A){return o.locateFile?o.locateFile(A,l):l+A}var u,h;if(m){var f=Zh;l=__dirname+"/",h=A=>{A=_(A)?new URL(A):A;var U=f.readFileSync(A);return U},u=async(A,U=!0)=>{A=_(A)?new URL(A):A;var ce=f.readFileSync(A,U?void 0:"utf8");return ce},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),d=(A,U)=>{throw process.exitCode=A,U}}else if(a||p){try{l=new URL(".",i).href}catch{}p&&(h=A=>{var U=new XMLHttpRequest;return U.open("GET",A,!1),U.responseType="arraybuffer",U.send(null),new Uint8Array(U.response)}),u=async A=>{if(_(A))return new Promise((ce,fe)=>{var he=new XMLHttpRequest;he.open("GET",A,!0),he.responseType="arraybuffer",he.onload=()=>{if(he.status==200||he.status==0&&he.response){ce(he.response);return}fe(he.status)},he.onerror=fe,he.send(null)});var U=await fetch(A,{credentials:"same-origin"});if(U.ok)return U.arrayBuffer();throw new Error(U.status+" : "+U.url)}}console.log.bind(console);var b=console.error.bind(console),g,y=!1,v,_=A=>A.startsWith("file://"),C,S,T,w,x=!1;function k(){var A=T.buffer;o.HEAP8=new Int8Array(A),o.HEAPU8=w=new Uint8Array(A),o.HEAP32=new Int32Array(A),o.HEAPU32=new Uint32Array(A),o.HEAPF32=new Float32Array(A),new BigInt64Array(A),new BigUint64Array(A)}function E(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Dt(o.preRun.shift());Oe(Fe)}function P(){x=!0,ft.__wasm_call_ctors()}function O(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)Pi(o.postRun.shift());Oe(Ee)}var z=0,I=null;function L(A){z++,o.monitorRunDependencies?.(z)}function F(A){if(z--,o.monitorRunDependencies?.(z),z==0&&I){var U=I;I=null,U()}}function Z(A){o.onAbort?.(A),A="Aborted("+A+")",b(A),y=!0,A+=". Build with -sASSERTIONS for more info.";var U=new WebAssembly.RuntimeError(A);throw S?.(U),U}var Q;function X(){return c("hb.wasm")}function Y(A){if(A==Q&&g)return new Uint8Array(g);if(h)return h(A);throw"both async and sync fetching of the wasm failed"}async function se(A){if(!g)try{var U=await u(A);return new Uint8Array(U)}catch{}return Y(A)}async function re(A,U){try{var ce=await se(A),fe=await WebAssembly.instantiate(ce,U);return fe}catch(he){b(`failed to asynchronously prepare wasm: ${he}`),Z(he)}}async function Ce(A,U,ce){if(!A&&!_(U)&&!m)try{var fe=fetch(U,{credentials:"same-origin"}),he=await WebAssembly.instantiateStreaming(fe,ce);return he}catch(Ae){b(`wasm streaming compile failed: ${Ae}`),b("falling back to ArrayBuffer instantiation")}return re(U,ce)}function ve(){return{env:Dn,wasi_snapshot_preview1:Dn}}async function ge(){function A(Ae,Is){return ft=Ae.exports,o.wasmExports=ft,T=ft.memory,o.wasmMemory=T,k(),ai=ft.__indirect_function_table,mu(ft),F(),ft}L();function U(Ae){return A(Ae.instance)}var ce=ve();if(o.instantiateWasm)return new Promise((Ae,Is)=>{o.instantiateWasm(ce,(yu,ku)=>{Ae(A(yu))})});Q??=X();var fe=await Ce(g,Q,ce),he=U(fe);return he}class de{name="ExitStatus";constructor(U){this.message=`Program terminated with exit(${U})`,this.status=U}}var Oe=A=>{for(;A.length>0;)A.shift()(o)},Ee=[],Pi=A=>Ee.push(A),Fe=[],Dt=A=>Fe.push(A),dt=!0,Ze=()=>Z(""),Ke=0,xt=()=>{dt=!1,Ke=0},Qe={},ni=A=>{if(A instanceof de||A=="unwind")return v;d(1,A)},Ri=()=>dt||Ke>0,Ts=A=>{v=A,Ri()||(o.onExit?.(A),y=!0),d(A,new de(A))},Qh=(A,U)=>{v=A,Ts(A)},Jh=Qh,eu=()=>{if(!Ri())try{Jh(v)}catch(A){ni(A)}},tu=A=>{if(!y)try{A(),eu()}catch(U){ni(U)}},iu=()=>performance.now(),su=(A,U)=>{if(Qe[A]&&(clearTimeout(Qe[A].id),delete Qe[A]),!U)return 0;var ce=setTimeout(()=>{delete Qe[A],tu(()=>$n(A,iu()))},U);return Qe[A]={id:ce,timeout_ms:U},0},ru=()=>2147483648,nu=(A,U)=>Math.ceil(A/U)*U,au=A=>{var U=T.buffer.byteLength,ce=(A-U+65535)/65536|0;try{return T.grow(ce),k(),1}catch{}},ou=A=>{var U=w.length;A>>>=0;var ce=ru();if(A>ce)return!1;for(var fe=1;fe<=4;fe*=2){var he=U*(1+.2/fe);he=Math.min(he,A+100663296);var Ae=Math.min(ce,nu(Math.max(A,he),65536)),Is=au(Ae);if(Is)return!0}return!1},Mn=A=>{const U=A.length;return[U%128|128,U>>7,...A]},lu={i:127,p:127,j:126,f:125,d:124,e:111},Ln=A=>Mn(Array.from(A,U=>{var ce=lu[U];return ce})),cu=(A,U)=>{var ce=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Mn([1,96,...Ln(U.slice(1)),...Ln(U[0]==="v"?"":U[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),fe=new WebAssembly.Module(ce),he=new WebAssembly.Instance(fe,{e:{f:A}}),Ae=he.exports.f;return Ae},ai,Bn=A=>ai.get(A),hu=(A,U)=>{if(Ct)for(var ce=A;ce<A+U;ce++){var fe=Bn(ce);fe&&Ct.set(fe,ce)}},Ct,uu=A=>(Ct||(Ct=new WeakMap,hu(0,ai.length)),Ct.get(A)||0),Ss=[],du=()=>Ss.length?Ss.pop():ai.grow(1),Es=(A,U)=>ai.set(A,U),fu=(A,U)=>{var ce=uu(A);if(ce)return ce;var fe=du();try{Es(fe,A)}catch(Ae){if(!(Ae instanceof TypeError))throw Ae;var he=cu(A,U);Es(fe,he)}return Ct.set(A,fe),fe},pu=A=>{Ct.delete(Bn(A)),Es(A,null),Ss.push(A)};o.noExitRuntime&&(dt=o.noExitRuntime),o.print&&o.print,o.printErr&&(b=o.printErr),o.wasmBinary&&(g=o.wasmBinary),o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.wasmMemory=T,o.wasmExports=ft,o.addFunction=fu,o.removeFunction=pu;var $n;function mu(A){o._hb_blob_create=A.hb_blob_create,o._hb_blob_destroy=A.hb_blob_destroy,o._hb_blob_get_length=A.hb_blob_get_length,o._hb_blob_get_data=A.hb_blob_get_data,o._hb_buffer_serialize_glyphs=A.hb_buffer_serialize_glyphs,o._hb_buffer_create=A.hb_buffer_create,o._hb_buffer_destroy=A.hb_buffer_destroy,o._hb_buffer_get_content_type=A.hb_buffer_get_content_type,o._hb_buffer_set_direction=A.hb_buffer_set_direction,o._hb_buffer_set_script=A.hb_buffer_set_script,o._hb_buffer_set_language=A.hb_buffer_set_language,o._hb_buffer_set_flags=A.hb_buffer_set_flags,o._hb_buffer_set_cluster_level=A.hb_buffer_set_cluster_level,o._hb_buffer_get_length=A.hb_buffer_get_length,o._hb_buffer_get_glyph_infos=A.hb_buffer_get_glyph_infos,o._hb_buffer_get_glyph_positions=A.hb_buffer_get_glyph_positions,o._hb_glyph_info_get_glyph_flags=A.hb_glyph_info_get_glyph_flags,o._hb_buffer_guess_segment_properties=A.hb_buffer_guess_segment_properties,o._hb_buffer_add_utf8=A.hb_buffer_add_utf8,o._hb_buffer_add_utf16=A.hb_buffer_add_utf16,o._hb_buffer_set_message_func=A.hb_buffer_set_message_func,o._hb_language_from_string=A.hb_language_from_string,o._hb_script_from_string=A.hb_script_from_string,o._hb_version=A.hb_version,o._hb_version_string=A.hb_version_string,o._hb_feature_from_string=A.hb_feature_from_string,o._malloc=A.malloc,o._free=A.free,o._hb_draw_funcs_set_move_to_func=A.hb_draw_funcs_set_move_to_func,o._hb_draw_funcs_set_line_to_func=A.hb_draw_funcs_set_line_to_func,o._hb_draw_funcs_set_quadratic_to_func=A.hb_draw_funcs_set_quadratic_to_func,o._hb_draw_funcs_set_cubic_to_func=A.hb_draw_funcs_set_cubic_to_func,o._hb_draw_funcs_set_close_path_func=A.hb_draw_funcs_set_close_path_func,o._hb_draw_funcs_create=A.hb_draw_funcs_create,o._hb_draw_funcs_destroy=A.hb_draw_funcs_destroy,o._hb_face_create=A.hb_face_create,o._hb_face_destroy=A.hb_face_destroy,o._hb_face_reference_table=A.hb_face_reference_table,o._hb_face_get_upem=A.hb_face_get_upem,o._hb_face_collect_unicodes=A.hb_face_collect_unicodes,o._hb_font_draw_glyph=A.hb_font_draw_glyph,o._hb_font_glyph_to_string=A.hb_font_glyph_to_string,o._hb_font_create=A.hb_font_create,o._hb_font_set_variations=A.hb_font_set_variations,o._hb_font_destroy=A.hb_font_destroy,o._hb_font_set_scale=A.hb_font_set_scale,o._hb_set_create=A.hb_set_create,o._hb_set_destroy=A.hb_set_destroy,o._hb_ot_var_get_axis_infos=A.hb_ot_var_get_axis_infos,o._hb_set_get_population=A.hb_set_get_population,o._hb_set_next_many=A.hb_set_next_many,o._hb_shape=A.hb_shape,$n=A._emscripten_timeout}var Dn={_abort_js:Ze,_emscripten_runtime_keepalive_clear:xt,_setitimer_js:su,emscripten_resize_heap:ou,proc_exit:Ts},ft=await ge();function As(){if(z>0){I=As;return}if(E(),z>0){I=As;return}function A(){o.calledRun=!0,!y&&(P(),C?.(o),o.onRuntimeInitialized?.(),O())}o.setStatus?(o.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>o.setStatus(""),1),A()},1)):A()}function gu(){if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.shift()()}return gu(),As(),x?n=o:n=new Promise((A,U)=>{C=A,S=U}),n}})();s.exports=t,s.exports.default=t})(On);var Kh=On.exports,qh=Gh,Xh=Kh,Fn=new Promise(function(s,e){Xh().then(t=>{s(qh(t))},e)});const Yh=Nn({__proto__:null,default:Qs(Fn)},[Fn]);q.AssetSchema=kr,q.AudioAssetSchema=Zi,q.AudioAssetUrlSchema=hr,q.AudioAssetVolumeSchema=ur,q.Canvas=yt,q.ClipSchema=rs,q.Controls=Qo,q.Edit=Ot,q.EditSchema=Or,q.FontSourceSchema=Ir,q.FontSourceUrlSchema=Ar,q.HtmlAssetSchema=Ki,q.ImageAssetCropSchema=fr,q.ImageAssetSchema=qi,q.ImageAssetUrlSchema=dr,q.KeyframeEasingSchema=cr,q.KeyframeInterpolationSchema=lr,q.KeyframeSchema=at,q.LumaAssetSchema=Xi,q.LumaAssetUrlSchema=pr,q.OutputSchema=Rr,q.RichTextAssetSchema=fi,q.ShapeAssetCircleSchema=Ji,q.ShapeAssetColorSchema=Yi,q.ShapeAssetFillSchema=mr,q.ShapeAssetLineSchema=es,q.ShapeAssetRectangleSchema=Qi,q.ShapeAssetSchema=ts,q.ShapeAssetStrokeSchema=gr,q.TextAssetAlignmentSchema=br,q.TextAssetBackgroundSchema=vr,q.TextAssetColorSchema=yi,q.TextAssetFontSchema=yr,q.TextAssetSchema=is,q.TextAssetStrokeSchema=wr,q.Timeline=ks,q.TimelineSchema=Pr,q.TrackSchema=Er,q.VideoAssetCropSchema=xr,q.VideoAssetSchema=ss,q.VideoAssetUrlSchema=_r,q.VideoAssetVolumeSchema=Cr,q.VideoExporter=vh,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});
373
+ */const xw=["video","audio","subtitle"],bo=s=>{if(!s||typeof s!="object")throw new TypeError("metadata must be an object.");if(s.languageCode!==void 0&&!pv(s.languageCode))throw new TypeError("metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.");if(s.name!==void 0&&typeof s.name!="string")throw new TypeError("metadata.name, when provided, must be a string.");if(s.maximumPacketCount!==void 0&&(!Number.isInteger(s.maximumPacketCount)||s.maximumPacketCount<0))throw new TypeError("metadata.maximumPacketCount, when provided, must be a non-negative integer.")};class Cw{constructor(e){if(this.state="pending",this._tracks=[],this._startPromise=null,this._cancelPromise=null,this._finalizePromise=null,this._mutex=new ju,this._metadataTags={},!e||typeof e!="object")throw new TypeError("options must be an object.");if(!(e.format instanceof S0))throw new TypeError("options.format must be an OutputFormat.");if(!(e.target instanceof C0))throw new TypeError("options.target must be a Target.");if(e.target._output)throw new Error("Target is already used for another output.");e.target._output=this,this.format=e.format,this.target=e.target,this._writer=e.target._createWriter(),this._muxer=e.format._createMuxer(this)}addVideoTrack(e,t={}){if(!(e instanceof A0))throw new TypeError("source must be a VideoSource.");if(bo(t),t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);if(!this.format.supportsVideoRotationMetadata&&t.rotation)throw new Error(`${this.format._name} does not support video rotation metadata.`);if(t.frameRate!==void 0&&(!Number.isFinite(t.frameRate)||t.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);this._addTrack("video",e,t)}addAudioTrack(e,t={}){if(!(e instanceof I0))throw new TypeError("source must be an AudioSource.");bo(t),this._addTrack("audio",e,t)}addSubtitleTrack(e,t={}){if(!(e instanceof ww))throw new TypeError("source must be a SubtitleSource.");bo(t),this._addTrack("subtitle",e,t)}setMetadataTags(e){if(bv(e),this.state!=="pending")throw new Error("Cannot set metadata tags after output has been started or canceled.");this._metadataTags=e}_addTrack(e,t,i){if(this.state!=="pending")throw new Error("Cannot add track after output has been started or canceled.");if(t._connectedTrack)throw new Error("Source is already used for a track.");const r=this.format.getSupportedTrackCounts(),n=this._tracks.reduce((u,h)=>u+(h.type===e?1:0),0),a=r[e].max;if(n===a)throw new Error(a===0?`${this.format._name} does not support ${e} tracks.`:`${this.format._name} does not support more than ${a} ${e} track${a===1?"":"s"}.`);const o=r.total.max;if(this._tracks.length===o)throw new Error(`${this.format._name} does not support more than ${o} tracks${o===1?"":"s"} in total.`);const c={id:this._tracks.length+1,output:this,type:e,source:t,metadata:i};if(c.type==="video"){const u=this.format.getSupportedVideoCodecs();if(u.length===0)throw new Error(`${this.format._name} does not support video tracks.`+this.format._codecUnsupportedHint(c.source._codec));if(!u.includes(c.source._codec))throw new Error(`Codec '${c.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${u.map(h=>`'${h}'`).join(", ")}.`+this.format._codecUnsupportedHint(c.source._codec))}else if(c.type==="audio"){const u=this.format.getSupportedAudioCodecs();if(u.length===0)throw new Error(`${this.format._name} does not support audio tracks.`+this.format._codecUnsupportedHint(c.source._codec));if(!u.includes(c.source._codec))throw new Error(`Codec '${c.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${u.map(h=>`'${h}'`).join(", ")}.`+this.format._codecUnsupportedHint(c.source._codec))}else if(c.type==="subtitle"){const u=this.format.getSupportedSubtitleCodecs();if(u.length===0)throw new Error(`${this.format._name} does not support subtitle tracks.`+this.format._codecUnsupportedHint(c.source._codec));if(!u.includes(c.source._codec))throw new Error(`Codec '${c.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${u.map(h=>`'${h}'`).join(", ")}.`+this.format._codecUnsupportedHint(c.source._codec))}this._tracks.push(c),t._connectedTrack=c}async start(){const e=this.format.getSupportedTrackCounts();for(const i of xw){const r=this._tracks.reduce((a,o)=>a+(o.type===i?1:0),0),n=e[i].min;if(r<n)throw new Error(n===e[i].max?`${this.format._name} requires exactly ${n} ${i} track${n===1?"":"s"}.`:`${this.format._name} requires at least ${n} ${i} track${n===1?"":"s"}.`)}const t=e.total.min;if(this._tracks.length<t)throw new 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 new Error("Output has been canceled.");return this._startPromise?(console.warn("Output has already been started."),this._startPromise):this._startPromise=(async()=>{this.state="started",this._writer.start();const i=await this._mutex.acquire();await this._muxer.start();const r=this._tracks.map(n=>n.source._start());await Promise.all(r),i()})()}getMimeType(){return this._muxer.getMimeType()}async cancel(){if(this._cancelPromise)return console.warn("Output has already been canceled."),this._cancelPromise;if(this.state==="finalizing"||this.state==="finalized"){console.warn("Output has already been finalized.");return}return this._cancelPromise=(async()=>{this.state="canceled";const e=await this._mutex.acquire(),t=this._tracks.map(i=>i.source._flushOrWaitForOngoingClose(!0));await Promise.all(t),await this._writer.close(),e()})()}async finalize(){if(this.state==="pending")throw new Error("Cannot finalize before starting.");if(this.state==="canceled")throw new Error("Cannot finalize after canceling.");return this._finalizePromise?(console.warn("Output has already been finalized."),this._finalizePromise):this._finalizePromise=(async()=>{this.state="finalizing";const e=await this._mutex.acquire(),t=this._tracks.map(i=>i.source._flushOrWaitForOngoingClose(!1));await Promise.all(t),await this._muxer.finalize(),await this._writer.flush(),await this._writer.finalize(),this.state="finalized",e()})()}}class kw{audioTracks=[];async setupAudioTracks(e,t){const i=this.findAudioPlayers(e);if(!i.length)return null;this.audioTracks=[];for(const n of i){const a=await this.processAudioTrack(n);a&&this.audioTracks.push(a)}if(!this.audioTracks.length)return null;const r=new vw({codec:"aac",bitrate:128e3});return t.addAudioTrack(r),r}async processAudioSamples(e){if(!this.audioTracks?.length)return;const t=new AudioContext;for(const i of this.audioTracks){const r=await t.decodeAudioData(i.data.slice(0)),{numberOfChannels:n,sampleRate:a,length:o}=r,c=Math.min(o,Math.floor(a*i.duration/1e3)),u=new Float32Array(c*n);for(let h=0;h<n;h+=1){const l=r.getChannelData(h);for(let d=0;d<c;d+=1)u[d*n+h]=l[d]*i.volume}await e.add(new Ji({data:u,format:"f32",numberOfChannels:n,sampleRate:a,timestamp:i.start/1e3}))}this.audioTracks=[]}findAudioPlayers(e){const t=[];for(const i of e)for(const r of i)this.isAudioPlayer(r)&&!t.includes(r)&&t.push(r);return t}async processAudioTrack(e){try{const t=e.clipConfiguration?.asset;if(!t?.src)return null;const i=await fetch(t.src);return i.ok?{data:await i.arrayBuffer(),start:e.getStart(),duration:e.getLength(),volume:e.getVolume()}:null}catch(t){return console.warn("Failed to process audio track:",t),null}}isAudioPlayer(e){if(e instanceof Ro)return!0;if(!e||typeof e!="object")return!1;const t=e,i=t.constructor?.name==="AudioPlayer",a=t.clipConfiguration?.asset?.type==="audio";return i||a}}class Sw{overlay=null;bar=null;percent=null;status=null;create(){this.overlay=Object.assign(document.createElement("div"),{style:"position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:9999;display:flex;justify-content:center;align-items:center;color:white;font-family:Arial"});const e=Object.assign(document.createElement("div"),{style:"background:#222;border-radius:8px;padding:20px;box-shadow:0 4px 8px rgba(0,0,0,0.2);width:300px;text-align:center"});e.innerHTML='<h3 style="margin:0 0 15px 0;font-weight:normal">Exporting Video</h3>',this.status=Object.assign(document.createElement("div"),{style:"font-size:12px;margin-bottom:10px;opacity:0.8"}),e.appendChild(this.status);const t=Object.assign(document.createElement("div"),{style:"width:100%;height:6px;background:#444;border-radius:3px;overflow:hidden;margin-bottom:10px"});this.bar=Object.assign(document.createElement("div"),{style:"width:0%;height:100%;background:#3498db;transition:width 0.3s"}),t.appendChild(this.bar),e.appendChild(t),this.percent=Object.assign(document.createElement("div"),{style:"font-size:12px",innerText:"0%"}),e.appendChild(this.percent),this.overlay.appendChild(e),document.body.appendChild(this.overlay)}update(e,t,i){if(!this.overlay)return;const r=Math.round(e/t*100);this.bar&&(this.bar.style.width=`${r}%`),this.percent&&(this.percent.innerText=`${r}%`),this.status&&i&&(this.status.innerText=i)}remove(){this.overlay?.remove(),this.overlay=null,this.bar=null,this.percent=null,this.status=null}}class P0 extends Map{constructor(e){super(),this.maxSize=e}get(e){const t=super.get(e);if(t!==void 0)return super.delete(e),super.set(e,t),t}set(e,t){if(super.delete(e),super.set(e,t),this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}class xn extends Error{constructor(e,t="unknown",i={},r){super(e),this.phase=t,this.context=i,this.name="ExportError",this.cause=r}}class Tw extends xn{constructor(e,t){super(e,"initialization",{missingFeatures:t}),this.name="BrowserCompatibilityError"}}function O0(s){if(!s||typeof s!="object")return!1;const e=s,t=e.constructor?.name==="VideoPlayer",r=e.texture?.source?.resource instanceof HTMLVideoElement;return e.constructor?.name==="RichTextPlayer"?!1:t||r}class Ew{frameCache=new P0(10);textureCache=new P0(5);videoElements=new Map;extractionCanvas=null;extractionContext=null;async initialize(e){for(const t of e)if(O0(t)){const i=t,r=i.texture?.source?.resource;r&&this.videoElements.set(this.getVideoKey(i),{element:r,player:i})}this.extractionCanvas=document.createElement("canvas"),this.extractionCanvas.width=3840,this.extractionCanvas.height=2160,this.extractionContext=this.extractionCanvas.getContext("2d",{willReadFrequently:!0,alpha:!0})}async extractFrame(e,t){const i=`${e}-${t}`,r=this.frameCache.get(i);if(r)return r;const n=this.videoElements.get(e);if(!n||!this.extractionContext||!this.extractionCanvas)return null;try{const{element:a,player:o}=n,c=(t-(o.getStart?.()||0))/1e3+(o.clipConfiguration?.asset?.trim||0);await this.seekToTime(a,c);const u=a.videoWidth||a.width||1920,h=a.videoHeight||a.height||1080;this.extractionContext.clearRect(0,0,u,h),this.extractionContext.drawImage(a,0,0,u,h);const l=this.extractionContext.getImageData(0,0,u,h);return this.frameCache.set(i,l),l}catch{return null}}async replaceVideoTexture(e,t){const i=await this.extractFrame(this.getVideoKey(e),t);if(!i)return;const r=`${this.getVideoKey(e)}-${t}`;let n=this.textureCache.get(r);if(!n){const a=document.createElement("canvas");a.width=i.width,a.height=i.height;const o=a.getContext("2d");o&&(o.putImageData(i,0,0),n=L.Texture.from(a),this.textureCache.set(r,n))}n&&e.texture&&(e.originalTextureSource||(e.originalTextureSource=e.texture.source,e.texture.source?.resource instanceof HTMLVideoElement&&(e.originalVideoElement=e.texture.source.resource)),e.texture=n,e.sprite?.texture&&(e.sprite.texture=n),e.lastReplacedTimestamp=t)}disableVideoPlayback(e){const t=[];for(const i of e)if(O0(i)){const r=i;t.push(r),r.texture?.source?.resource instanceof HTMLVideoElement&&r.texture.source.resource.pause(),r.skipVideoUpdate=!0}return t}getVideoKey(e){return e.clipConfiguration?.asset?.src||""}dispose(){this.frameCache.clear(),this.textureCache.clear(),this.videoElements.clear(),this.extractionCanvas=null,this.extractionContext=null}async seekToTime(e,t){return new Promise(i=>{if(Math.abs(e.currentTime-t)<.1){i();return}const r=()=>{e.removeEventListener("seeked",r),setTimeout(i,1)};e.addEventListener("seeked",r),e.currentTime=t})}}class _w{edit;canvas;app;isExporting=!1;videoProcessor=new Ew;audioProcessor=new kw;progressUI=new Sw;exportCommand=new lv;constructor(e,t){this.edit=e,this.canvas=t,this.app=t.application,document.addEventListener("keydown",this.handleKeyDown)}async export(e="shotstack-export.mp4",t){if(typeof VideoEncoder>"u")throw new Tw("WebCodecs API not supported",["VideoEncoder"]);if(this.isExporting)throw new xn("Export in progress","init");this.isExporting=!0;const i=this.saveEditState();this.edit.setExportMode(!0);try{this.progressUI.create(),this.canvas.pauseTicker();const r=this.prepareConfig(t??this.edit.getEdit().output?.fps??30);this.progressUI.update(0,100,"Preparing..."),this.edit.executeEditCommand(this.exportCommand),await this.videoProcessor.initialize(this.exportCommand.getClips()),this.progressUI.update(10,100,"Video ready");const n=new Cw({format:new E0,target:new k0}),a=document.createElement("canvas");a.width=r.size.width,a.height=r.size.height;const o=a.getContext("2d");if(!o)throw new Error("No 2D context");const c=new yw(a,{codec:"avc",bitrate:5e6});n.addVideoTrack(c),this.progressUI.update(15,100,"Audio...");const u=await this.audioProcessor.setupAudioTracks(this.exportCommand.getTracks(),n);await n.start(),u&&(this.progressUI.update(20,100,"Encoding audio..."),await this.audioProcessor.processAudioSamples(u)),this.progressUI.update(25,100,"Exporting..."),await this.processFrames(r,c,a,o),await n.finalize();const h=n.target.buffer;if(!h)throw new Error("No video data");const l=new Blob([h],{type:"video/mp4"}),d=URL.createObjectURL(l),f=document.createElement("a");f.href=d,f.download=e,f.click(),URL.revokeObjectURL(d),this.progressUI.update(100,100,"Complete!")}catch(r){throw r instanceof xn?r:new xn(`Export failed: ${r}`,"export")}finally{this.isExporting=!1,this.edit.setExportMode(!1),this.canvas.resumeTicker(),this.progressUI.remove(),this.restoreEditState(i)}}async processFrames(e,t,i,r){const n=this.edit.getContainer();this.edit.pause(),Object.assign(n.position,{x:0,y:0}),Object.assign(n.scale,{x:1,y:1}),n.visible=!0;const a=this.videoProcessor.disableVideoPlayback(this.exportCommand.getClips());for(let o=0;o<e.frames;o+=1){const c=o*e.frameDuration;this.edit.playbackTime=c;for(const l of this.exportCommand.getClips())l.update(0,0);for(const l of a){const d=l.getStart?.()||0,f=l.getEnd?.()||d+(l.getLength?.()||0);c>=d&&c<f&&await this.videoProcessor.replaceVideoTexture(l,c)}this.edit.draw(),this.app.renderer.render(this.app.stage);const u=this.app.renderer.extract.pixels({target:n,frame:new L.Rectangle(0,0,e.size.width,e.size.height)}),h=new ImageData(new Uint8ClampedArray(u.pixels),u.width,u.height);r.putImageData(h,0,0),await t.add(o/e.fps,1/e.fps),this.progressUI.update(25+Math.round((o+1)/e.frames*75),100,"Exporting...")}}handleKeyDown=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.code==="KeyE"&&(e.metaKey||e.ctrlKey)&&!this.isExporting&&(e.preventDefault(),this.export("shotstack-export.mp4",this.edit.getEdit().output?.fps||30).catch(t=>console.error("Export failed:",t)))};dispose(){document.removeEventListener("keydown",this.handleKeyDown),this.videoProcessor.dispose(),this.progressUI.remove()}prepareConfig(e){const t=this.edit.getEdit().output?.size||{width:1920,height:1080},i=this.edit.totalDuration/1e3;return{fps:e,size:t,frames:Math.ceil(i*e),frameDuration:1e3/e}}saveEditState(){const e=this.edit.getContainer();return{wasPlaying:this.edit.isPlaying,time:this.edit.playbackTime,visible:e.visible,pos:{x:e.position.x,y:e.position.y},scale:{x:e.scale.x,y:e.scale.y}}}restoreEditState(e){const t=this.edit.getContainer();this.edit.setExportMode(!1);for(const i of this.exportCommand.getClips())if(this.isVideoPlayer(i)){const r=i;if(r.skipVideoUpdate=!1,r.originalVideoElement&&r.texture){const n=L.Texture.from(r.originalVideoElement);r.texture=n,r.sprite&&(r.sprite.texture=n),delete r.originalVideoElement,delete r.originalTextureSource,delete r.lastReplacedTimestamp}else r.originalTextureSource&&r.texture&&(r.texture.source=r.originalTextureSource,delete r.originalTextureSource,delete r.lastReplacedTimestamp)}Object.assign(t.position,e.pos),Object.assign(t.scale,e.scale),t.visible=e.visible,this.edit.seek(e.time),e.wasPlaying&&this.edit.play()}isVideoPlayer(e){if(!e||typeof e!="object")return!1;const t=e,i=t.constructor?.name==="VideoPlayer",n=t.texture?.source?.resource instanceof HTMLVideoElement;return i||n}}function F0(s){const e=s.replace("#",""),t=parseInt(e,16);return Number.isNaN(t)?(console.warn(`Invalid hex color: ${s}, defaulting to black`),0):t}function Aw(s){const e=t=>{if(typeof t=="string")return F0(t);if(typeof t=="object"&&t!==null){const i=Array.isArray(t)?[]:{};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=e(t[r]));return i}return t};return e(s)}function R0(s){if(typeof s=="string")return F0(s);if(typeof s=="object"&&s!==null){const e=Array.isArray(s)?[]:{};for(const t in s)Object.prototype.hasOwnProperty.call(s,t)&&(e[t]=R0(s[t]));return e}return s}const M0=Aw({timeline:{background:"#1a1a1a",divider:"#1a1a1a",toolbar:{background:"#1a1a1a",surface:"#2a2a2a",hover:"#3a3a3a",active:"#007acc",divider:"#3a3a3a",icon:"#888888",text:"#ffffff",height:36},ruler:{background:"#404040",text:"#ffffff",markers:"#666666",height:40},tracks:{surface:"#2a2a2a",surfaceAlt:"#242424",border:"#3a3a3a",height:60},clips:{video:"#4a90e2",audio:"#7ed321",image:"#f5a623",text:"#d0021b",shape:"#9013fe",html:"#50e3c2",luma:"#b8e986",default:"#8e8e93",selected:"#007acc",radius:4},playhead:"#ff4444",snapGuide:"#888888",dropZone:"#00ff00",trackInsertion:"#00ff00"}});class D0{static resolveTheme(e){if(!e||!e.theme)return this.deepClone(M0);const t=R0(e.theme),i=this.deepClone(M0);return this.deepMerge(i,t)}static validateTheme(e){try{if(!e.timeline)return!1;const{timeline:t}=e;if(typeof t.background!="number"||typeof t.divider!="number"||typeof t.playhead!="number"||typeof t.snapGuide!="number"||typeof t.dropZone!="number"||typeof t.trackInsertion!="number"||!t.toolbar)return!1;const{toolbar:i}=t;if(typeof i.background!="number"||typeof i.surface!="number"||typeof i.hover!="number"||typeof i.active!="number"||typeof i.divider!="number"||typeof i.icon!="number"||typeof i.text!="number"||typeof i.height!="number"||i.height<=0||!t.ruler)return!1;const{ruler:r}=t;if(typeof r.background!="number"||typeof r.text!="number"||typeof r.markers!="number"||typeof r.height!="number"||r.height<=0||!t.tracks)return!1;const{tracks:n}=t;if(typeof n.surface!="number"||typeof n.surfaceAlt!="number"||typeof n.border!="number"||typeof n.height!="number"||n.height<=0||!t.clips)return!1;const{clips:a}=t,o=["video","audio","image","text","shape","html","luma","default","selected"];for(const c of o)if(typeof a[c]!="number")return!1;return!(typeof a.radius!="number"||a.radius<0)}catch(t){return console.error("Theme validation error:",t),!1}}static deepClone(e){if(e===null||typeof e!="object")return e;if(e instanceof Array)return e.map(i=>this.deepClone(i));const t={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=this.deepClone(e[i]));return t}static deepMerge(e,t){const i={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const n=t[r],a=i[r];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?i[r]=this.deepMerge(a,n):i[r]=n)}return i}}class Iw{timeline;constructor(e){this.timeline=e}getValidDropPosition(e,t,i,r){const n=this.timeline.getVisualTracks()[i];if(!n)return{validTime:e,wouldOverlap:!1};const a=this.getOtherClipBounds(n,r),o=e+t,c=a.find(f=>!(o<=f.start||e>=f.end));if(!c)return{validTime:e,wouldOverlap:!1};const u=c.start-t,h=c.end,l=Math.abs(e-u)<Math.abs(e-h)&&u>=0?u:h;return{validTime:this.getValidDropPosition(l,t,i,r).validTime,wouldOverlap:!0}}checkOverlap(e,t,i,r){const n=this.timeline.getVisualTracks()[i];if(!n)return!1;const a=this.getOtherClipBounds(n,r),o=e+t;return a.some(c=>!(o<=c.start||e>=c.end))}getOtherClipBounds(e,t){return e.getClips().map((i,r)=>({clip:i,index:r})).filter(({index:i})=>i!==t).map(({clip:i})=>{const r=i.getClipConfig();return r?{start:r.start||0,end:(r.start||0)+(r.length||0)}:null}).filter(i=>i!==null).sort((i,r)=>i.start-r.start)}findAvailableGaps(e,t){const i=this.timeline.getVisualTracks()[e];if(!i)return[];const r=this.getOtherClipBounds(i),n=[];r.length>0&&r[0].start>=t&&n.push({start:0,end:r[0].start});for(let a=0;a<r.length-1;a+=1)r[a+1].start-r[a].end>=t&&n.push({start:r[a].end,end:r[a+1].start});return n}}class B0{constructor(e,t,i,r){this.fromTrackIndex=e,this.fromClipIndex=t,this.toTrackIndex=i,this.newStart=r,this.originalTrackIndex=e,this.originalClipIndex=t}name="moveClip";player;originalTrackIndex;originalClipIndex;originalStart;execute(e){if(!e)return;const t=e.getTracks();if(this.fromTrackIndex<0||this.fromTrackIndex>=t.length){console.warn(`Invalid source track index: ${this.fromTrackIndex}`);return}const i=t[this.fromTrackIndex];if(this.fromClipIndex<0||this.fromClipIndex>=i.length){console.warn(`Invalid clip index: ${this.fromClipIndex}`);return}if(this.player=i[this.fromClipIndex],this.originalStart=this.player.clipConfiguration.start,this.fromTrackIndex!==this.toTrackIndex){if(this.toTrackIndex<0||this.toTrackIndex>=t.length){console.warn(`Invalid destination track index: ${this.toTrackIndex}`);return}i.splice(this.fromClipIndex,1),this.player.layer=this.toTrackIndex+1;const r=t[this.toTrackIndex];let n=0;for(let a=0;a<r.length;a+=1){const o=r[a];if(o.clipConfiguration&&o.clipConfiguration.start!==void 0&&this.newStart<o.clipConfiguration.start)break;n+=1}r.splice(n,0,this.player),this.originalClipIndex=n}if(this.player.clipConfiguration.start=this.newStart,e.movePlayerToTrackContainer(this.player,this.fromTrackIndex,this.toTrackIndex),this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),this.fromTrackIndex!==this.toTrackIndex){const r=t[this.fromTrackIndex],n=t[this.toTrackIndex];[...r,...n].forEach(a=>{a&&a!==this.player&&a.draw()})}e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,start:this.originalStart},trackIndex:this.fromTrackIndex,clipIndex:this.fromClipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.toTrackIndex,clipIndex:this.originalClipIndex}})}undo(e){if(!e||!this.player||this.originalStart===void 0)return;const t=e.getTracks();if(this.fromTrackIndex!==this.toTrackIndex){const i=t[this.toTrackIndex],r=i.indexOf(this.player);r!==-1&&i.splice(r,1),this.player.layer=this.fromTrackIndex+1,t[this.fromTrackIndex].splice(this.fromClipIndex,0,this.player)}this.player.clipConfiguration.start=this.originalStart,e.movePlayerToTrackContainer(this.player,this.toTrackIndex,this.fromTrackIndex),this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,start:this.newStart},trackIndex:this.toTrackIndex,clipIndex:this.originalClipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.fromTrackIndex,clipIndex:this.fromClipIndex}})}}class Pw{constructor(e,t,i,r){this.insertionIndex=e,this.fromTrackIndex=t,this.fromClipIndex=i,this.newStart=r,this.addTrackCommand=new Bu(e);const n=t>=e?t+1:t;this.moveClipCommand=new B0(n,i,e,r)}name="createTrackAndMoveClip";addTrackCommand;moveClipCommand;wasExecuted=!1;async execute(e){if(e)try{this.addTrackCommand.execute(e),this.moveClipCommand.execute(e),this.wasExecuted=!0}catch(t){if(this.wasExecuted)try{this.undo(e)}catch{}throw t}}undo(e){!e||!this.wasExecuted||(this.moveClipCommand.undo(e),this.addTrackCommand.undo(e),this.wasExecuted=!1,e.emitEvent("track:created:undone",{trackIndex:this.insertionIndex}))}}class Ow{timeline;thresholds;snapManager;collisionDetector;visualFeedback;dragInfo=null;currentDropZone=null;constructor(e,t,i,r,n){this.timeline=e,this.thresholds=t,this.snapManager=i,this.collisionDetector=r,this.visualFeedback=n}activate(){}deactivate(){this.endDrag()}canStartDrag(e,t){const i=Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),{trackHeight:r}=this.timeline.getLayout(),n=r<20?2:this.thresholds.drag.base;return i>n}startDrag(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return console.warn(`Clip data not found for track ${e.trackIndex}, clip ${e.clipIndex}`),!1;const r=this.timeline.getContainer().toLocal(t.global),n=this.timeline.getLayout(),a=n.getXAtTime(i.start||0),o=e.trackIndex*n.trackHeight;return this.dragInfo={trackIndex:e.trackIndex,clipIndex:e.clipIndex,startTime:i.start||0,offsetX:r.x-a,offsetY:r.y-o},this.timeline.getPixiApp().canvas.style.cursor="grabbing",this.timeline.getEdit().events.emit("drag:started",this.dragInfo),!0}updateDrag(e){if(!this.dragInfo)return;const t=this.calculateDragPosition(e),i=this.detectDropZone(t.y);i?this.handleDropZonePreview(i,t):this.handleNormalDragPreview(t),this.emitDragUpdate(t,i)}completeDrag(e){if(!this.dragInfo)return;const t={...this.dragInfo},i=this.calculateDragPosition(e),r=this.detectDropZone(i.y);this.endDrag(),r?this.executeDropZoneMove(r,t,i):this.executeNormalMove(t,i)}calculateDragPosition(e){if(!this.dragInfo)throw new Error("No drag info available");const t=this.timeline.getContainer().toLocal(e.global),i=this.timeline.getLayout(),r=Math.max(0,i.getTimeAtX(t.x-this.dragInfo.offsetX)),n=t.y-this.dragInfo.offsetY,a=n+i.trackHeight/2,o=Math.max(0,Math.floor(a/i.trackHeight)),c=this.timeline.getVisualTracks().length-1,u=Math.max(0,Math.min(c,o));return{x:t.x,y:t.y+i.viewportY,time:r,track:u,ghostY:n}}detectDropZone(e){const t=this.timeline.getLayout(),i=this.timeline.getVisualTracks(),r=t.trackHeight*this.thresholds.dropZone.ratio;for(let n=0;n<=i.length;n+=1){const a=t.tracksY+n*t.trackHeight;if(Math.abs(e-a)<r){let o;return n===0?o="above":n===i.length?o="below":o="between",{type:o,position:n}}}return null}handleDropZonePreview(e,t){(!this.currentDropZone||this.currentDropZone.type!==e.type||this.currentDropZone.position!==e.position)&&(this.currentDropZone=e,this.visualFeedback.showDropZone(e)),this.timeline.hideDragGhost(),this.visualFeedback.hideSnapGuidelines(),this.visualFeedback.hideTargetTrack()}handleNormalDragPreview(e){if(!this.dragInfo)return;this.currentDropZone&&(this.visualFeedback.hideDropZone(),this.currentDropZone=null);const t=this.timeline.getClipData(this.dragInfo.trackIndex,this.dragInfo.clipIndex);if(!t)return;const i=t.length||0,r=e.track===this.dragInfo.trackIndex?this.dragInfo.clipIndex:void 0,n=this.calculateFinalPosition(e.time,e.track,i,r),a=this.snapManager.findAlignedElements(n,i,e.track,r);a.length>0?this.visualFeedback.showSnapGuidelines(a):this.visualFeedback.hideSnapGuidelines(),this.visualFeedback.showTargetTrack(e.track),this.timeline.showDragGhost(e.track,n,e.ghostY)}calculateFinalPosition(e,t,i,r){const n=this.snapManager.calculateSnapPosition(e,t,i,r);return this.collisionDetector.getValidDropPosition(n.time,i,t,r).validTime}emitDragUpdate(e,t){if(!this.dragInfo)return;const i=this.timeline.getClipData(this.dragInfo.trackIndex,this.dragInfo.clipIndex);if(!i)return;const r=i.length||0,n=t?e.time:this.calculateFinalPosition(e.time,e.track,r,e.track===this.dragInfo.trackIndex?this.dragInfo.clipIndex:void 0);this.timeline.getEdit().events.emit("drag:moved",{...this.dragInfo,currentTime:n,currentTrack:t?-1:e.track})}executeDropZoneMove(e,t,i){const r=new Pw(e.position,t.trackIndex,t.clipIndex,i.time);this.timeline.getEdit().executeEditCommand(r)}executeNormalMove(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return;const r=i.length||0,n=t.track===e.trackIndex?e.clipIndex:void 0,a=this.calculateFinalPosition(t.time,t.track,r,n);if(t.track!==e.trackIndex||Math.abs(a-e.startTime)>.01){const c=new B0(e.trackIndex,e.clipIndex,t.track,a);this.timeline.getEdit().executeEditCommand(c)}}endDrag(){this.dragInfo=null,this.currentDropZone=null,this.visualFeedback.hideAll(),this.timeline.getPixiApp().canvas.style.cursor="default",this.timeline.getEdit().events.emit("drag:ended",{})}getDragInfo(){return this.dragInfo}dispose(){this.endDrag()}}class Fw{constructor(e,t,i){this.trackIndex=e,this.clipIndex=t,this.newLength=i}name="resizeClip";originalLength;player;execute(e){if(!e)return;const t=e.getTrack(this.trackIndex);if(!t){console.warn(`Invalid track index: ${this.trackIndex}`);return}if(this.clipIndex<0||this.clipIndex>=t.length){console.warn(`Invalid clip index: ${this.clipIndex} for track ${this.trackIndex}`);return}this.player=t[this.clipIndex],this.originalLength=this.player.clipConfiguration.length,this.player.clipConfiguration.length=this.newLength,this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,length:this.originalLength},trackIndex:this.trackIndex,clipIndex:this.clipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}})}undo(e){!e||!this.player||this.originalLength===void 0||(this.player.clipConfiguration.length=this.originalLength,this.player.reconfigureAfterRestore(),this.player.draw(),e.updateDuration(),e.emitEvent("clip:updated",{previous:{clip:{...this.player.clipConfiguration,length:this.newLength},trackIndex:this.trackIndex,clipIndex:this.clipIndex},current:{clip:this.player.clipConfiguration,trackIndex:this.trackIndex,clipIndex:this.clipIndex}}))}}class Rw{timeline;thresholds;resizeInfo=null;constructor(e,t){this.timeline=e,this.thresholds=t}activate(){}deactivate(){this.endResize()}isOnClipRightEdge(e,t){const i=this.timeline.getVisualTracks()[e.trackIndex];if(!i)return!1;const r=i.getClip(e.clipIndex);if(!r)return!1;const a=r.getContainer().getBounds(),o=a.x+a.width,c=Math.abs(t.global.x-o),u=this.getResizeThreshold();return c<=u}startResize(e,t){const i=this.timeline.getClipData(e.trackIndex,e.clipIndex);if(!i)return!1;this.resizeInfo={trackIndex:e.trackIndex,clipIndex:e.clipIndex,originalLength:i.length||0,startX:t.global.x},this.timeline.getPixiApp().canvas.style.cursor="ew-resize";const r=this.timeline.getVisualTracks()[e.trackIndex];if(r){const n=r.getClip(e.clipIndex);n&&n.setResizing(!0)}return this.timeline.getEdit().events.emit("resize:started",this.resizeInfo),!0}updateResize(e){if(!this.resizeInfo)return;const t=e.global.x-this.resizeInfo.startX,i=this.timeline.getOptions().pixelsPerSecond||50,r=t/i,n=Math.max(.1,this.resizeInfo.originalLength+r),a=this.timeline.getVisualTracks()[this.resizeInfo.trackIndex];if(a){const o=a.getClip(this.resizeInfo.clipIndex);if(o){const c=n*i;o.setPreviewWidth(c),this.timeline.getEdit().events.emit("resize:updated",{width:c})}}}completeResize(e){if(!this.resizeInfo)return;const t=e.global.x-this.resizeInfo.startX,i=this.timeline.getOptions().pixelsPerSecond||50,r=t/i,n=Math.max(.1,this.resizeInfo.originalLength+r),a=this.timeline.getVisualTracks()[this.resizeInfo.trackIndex];if(a){const o=a.getClip(this.resizeInfo.clipIndex);o&&(o.setResizing(!1),o.setPreviewWidth(null))}if(Math.abs(n-this.resizeInfo.originalLength)>.01){const o=new Fw(this.resizeInfo.trackIndex,this.resizeInfo.clipIndex,n);this.timeline.getEdit().executeEditCommand(o),this.timeline.getEdit().events.emit("resize:ended",{newLength:n})}this.endResize()}getCursorForPosition(e,t){return e&&this.isOnClipRightEdge(e,t)?"ew-resize":""}getResizeThreshold(){const{trackHeight:e}=this.timeline.getLayout();return Math.max(this.thresholds.resize.min,Math.min(this.thresholds.resize.max,e*this.thresholds.resize.ratio))}endResize(){this.resizeInfo=null,this.timeline.getPixiApp().canvas.style.cursor="default"}getResizeInfo(){return this.resizeInfo}dispose(){this.endResize()}}class Mw{timeline;thresholds;constructor(e,t){this.timeline=e,this.thresholds=t}getAllSnapPoints(e,t){const i=[];this.timeline.getVisualTracks().forEach((a,o)=>{a.getClips().forEach((u,h)=>{if(o===e&&h===t)return;const l=u.getClipConfig();l&&(i.push({time:l.start||0,type:"clip-start",trackIndex:o,clipIndex:h}),i.push({time:(l.start||0)+(l.length||0),type:"clip-end",trackIndex:o,clipIndex:h}))})});const n=this.timeline.getPlayheadTime();return i.push({time:n,type:"playhead"}),i}getTrackSnapPoints(e,t){return this.getAllSnapPoints(e,t).filter(i=>i.trackIndex===void 0||i.trackIndex===e)}calculateSnapPosition(e,t,i,r){const n=this.timeline.getOptions().pixelsPerSecond||50,a=this.thresholds.snap.pixels/n,o=this.getTrackSnapPoints(t,r);let c=null;for(const u of o){const h=Math.abs(e-u.time);h<a&&(!c||h<c.distance)&&(c={time:u.time,type:u.type,distance:h});const l=Math.abs(e+i-u.time);l<a&&(!c||l<c.distance)&&(c={time:u.time-i,type:u.type,distance:l})}return c?{time:c.time,snapped:!0,snapType:c.type}:{time:e,snapped:!1}}findAlignedElements(e,t,i,r){const a=e+t,o=new Map;this.timeline.getVisualTracks().forEach((u,h)=>{u.getClips().forEach((l,d)=>{if(h===i&&d===r)return;const f=l.getClipConfig();if(!f)return;const p=f.start||0,m=p+(f.length||0);[{time:p,aligns:[e,a]},{time:m,aligns:[e,a]}].forEach(({time:b,aligns:g})=>{g.some(y=>Math.abs(y-b)<.1)&&(o.has(b)||o.set(b,{tracks:new Set,isPlayhead:!1}),o.get(b).tracks.add(h))})})});const c=this.timeline.getPlayheadTime();return(Math.abs(e-c)<.1||Math.abs(a-c)<.1)&&(o.has(c)||o.set(c,{tracks:new Set,isPlayhead:!0}),o.get(c).isPlayhead=!0),Array.from(o.entries()).map(([u,h])=>({time:u,tracks:Array.from(h.tracks).concat(i),isPlayhead:h.isPlayhead}))}}class Dw{timeline;graphics=new Map;constructor(e){this.timeline=e}showDropZone(e){this.hideDropZone();const t=new L.Graphics,i=this.timeline.getLayout(),r=this.timeline.getExtendedTimelineWidth(),n=e.position*i.trackHeight,o=this.timeline.getTheme().timeline.trackInsertion;t.setStrokeStyle({width:4,color:o,alpha:.8}),t.moveTo(0,n),t.lineTo(r,n),t.stroke(),t.setStrokeStyle({width:8,color:o,alpha:.3}),t.moveTo(0,n),t.lineTo(r,n),t.stroke(),this.timeline.getContainer().addChild(t),this.graphics.set("dropZone",t)}hideDropZone(){this.hideGraphics("dropZone")}showSnapGuidelines(e){this.hideSnapGuidelines();const t=new L.Graphics,i=this.timeline.getLayout(),r=this.timeline.getTheme();e.forEach(({time:n,tracks:a,isPlayhead:o})=>{const c=i.getXAtTime(n),u=Math.min(...a),h=Math.max(...a),l=u*i.trackHeight,d=(h+1)*i.trackHeight,f=o?r.timeline.playhead:r.timeline.snapGuide;t.setStrokeStyle({width:3,color:f,alpha:.3}),t.moveTo(c,l),t.lineTo(c,d),t.stroke(),t.setStrokeStyle({width:1,color:f,alpha:.8}),t.moveTo(c,l),t.lineTo(c,d),t.stroke()}),this.timeline.getContainer().addChild(t),this.graphics.set("snapGuidelines",t)}hideSnapGuidelines(){this.hideGraphics("snapGuidelines")}showTargetTrack(e){this.hideTargetTrack();const t=new L.Graphics,i=this.timeline.getLayout(),r=this.timeline.getExtendedTimelineWidth(),n=e*i.trackHeight,a=i.trackHeight,c=this.timeline.getTheme().timeline.dropZone;t.rect(0,n,r,a),t.fill({color:c,alpha:.1}),t.setStrokeStyle({width:1,color:c,alpha:.3}),t.rect(0,n,r,a),t.stroke(),this.timeline.getContainer().addChild(t),this.graphics.set("targetTrack",t)}hideTargetTrack(){this.hideGraphics("targetTrack")}hideAll(){this.graphics.forEach((e,t)=>this.hideGraphics(t))}hideGraphics(e){const t=this.graphics.get(e);t&&(t.clear(),t.parent&&t.parent.removeChild(t),t.destroy(),this.graphics.delete(e))}dispose(){this.hideAll(),this.graphics.clear()}}class Bw{timeline;state={type:"idle"};abortController;dragHandler;resizeHandler;snapManager;collisionDetector;visualFeedback;thresholds={drag:{base:3,small:2},resize:{min:12,max:20,ratio:.4},dropZone:{ratio:.15},snap:{pixels:10,time:.1}};constructor(e,t){if(this.timeline=e,t){const i=structuredClone(this.thresholds);t.drag&&Object.assign(i.drag,t.drag),t.resize&&Object.assign(i.resize,t.resize),t.dropZone&&Object.assign(i.dropZone,t.dropZone),t.snap&&Object.assign(i.snap,t.snap),this.thresholds=i}this.snapManager=new Mw(e,this.thresholds),this.collisionDetector=new Iw(e),this.visualFeedback=new Dw(e),this.dragHandler=new Ow(e,this.thresholds,this.snapManager,this.collisionDetector,this.visualFeedback),this.resizeHandler=new Rw(e,this.thresholds)}activate(){this.abortController=new AbortController,this.setupEventListeners(),this.dragHandler.activate(),this.resizeHandler.activate()}deactivate(){this.abortController&&(this.abortController.abort(),this.abortController=void 0),this.resetState(),this.dragHandler.deactivate(),this.resizeHandler.deactivate()}setupEventListeners(){const e=this.timeline.getPixiApp();e.stage.interactive=!0,e.stage.on("pointerdown",this.handlePointerDown.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointermove",this.handlePointerMove.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointerup",this.handlePointerUp.bind(this),{signal:this.abortController?.signal}),e.stage.on("pointerupoutside",this.handlePointerUp.bind(this),{signal:this.abortController?.signal})}handlePointerDown(e){const t=e.target;if(t.label){const i=this.parseClipLabel(t.label);if(i){if(this.resizeHandler.isOnClipRightEdge(i,e)){if(this.resizeHandler.startResize(i,e)){const r=this.resizeHandler.getResizeInfo();r&&(this.state={type:"resizing",resizeInfo:r})}return}this.state={type:"selecting",startPos:{x:e.global.x,y:e.global.y},clipInfo:i},this.timeline.getPixiApp().canvas.style.cursor="grab";return}}this.timeline.getEdit().clearSelection()}handlePointerMove(e){switch(this.state.type){case"selecting":this.handleSelectingMove(e);break;case"dragging":this.timeline.getPixiApp().canvas.style.cursor="grabbing",this.dragHandler.updateDrag(e);break;case"resizing":this.timeline.getPixiApp().canvas.style.cursor="ew-resize",this.resizeHandler.updateResize(e);break;case"idle":this.updateCursorForPosition(e);break}}handlePointerUp(e){switch(this.state.type){case"selecting":this.timeline.getEdit().selectClip(this.state.clipInfo.trackIndex,this.state.clipInfo.clipIndex);break;case"dragging":this.dragHandler.completeDrag(e);break;case"resizing":this.resizeHandler.completeResize(e);break}this.resetState()}handleSelectingMove(e){if(this.state.type!=="selecting")return;const t={x:e.global.x,y:e.global.y};if(this.dragHandler.canStartDrag(this.state.startPos,t)&&this.dragHandler.startDrag(this.state.clipInfo,e)){const i=this.dragHandler.getDragInfo();i&&(this.state={type:"dragging",dragInfo:i})}}updateCursorForPosition(e){const t=e.target;if(t.label){const i=this.parseClipLabel(t.label);if(i){const r=this.resizeHandler.getCursorForPosition(i,e);if(r){this.timeline.getPixiApp().canvas.style.cursor=r;return}this.timeline.getPixiApp().canvas.style.cursor="grab";return}}this.timeline.getPixiApp().canvas.style.cursor="default"}parseClipLabel(e){if(!e?.startsWith("clip-"))return null;const t=e.split("-");if(t.length!==3)return null;const i=parseInt(t[1],10),r=parseInt(t[2],10);return Number.isNaN(i)||Number.isNaN(r)?null:{trackIndex:i,clipIndex:r}}resetState(){this.state={type:"idle"},this.visualFeedback.hideAll(),this.timeline.getPixiApp().canvas.style.cursor="default"}dispose(){this.deactivate(),this.dragHandler.dispose(),this.resizeHandler.dispose(),this.visualFeedback.dispose()}}class Lw{constructor(e,t,i,r,n){this.container=e,this.layout=t,this.getPixelsPerSecond=i,this.getTrackHeight=r,this.getVisualTracks=n}dragPreviewContainer=null;dragPreviewGraphics=null;draggedClipInfo=null;showDragPreview(e,t,i){if(!i)return;this.draggedClipInfo={trackIndex:e,clipIndex:t,clipConfig:i},this.dragPreviewContainer=new L.Container,this.dragPreviewGraphics=new L.Graphics,this.dragPreviewContainer.addChild(this.dragPreviewGraphics),this.container.addChild(this.dragPreviewContainer),this.getVisualTracks()[e]?.getClip(t)?.setDragging(!0),this.drawDragPreview(e,i.start||0)}drawDragPreview(e,t){if(!this.dragPreviewContainer||!this.dragPreviewGraphics||!this.draggedClipInfo)return;const{clipConfig:i}=this.draggedClipInfo,r=this.layout.getXAtTime(t),n=e*this.layout.trackHeight,a=(i.length||0)*this.getPixelsPerSecond();this.dragPreviewGraphics.clear(),this.dragPreviewGraphics.roundRect(0,0,a,this.getTrackHeight(),4),this.dragPreviewGraphics.fill({color:9342611,alpha:.6}),this.dragPreviewGraphics.stroke({width:2,color:65280}),this.dragPreviewContainer.position.set(r,n)}drawDragPreviewAtPosition(e,t,i){if(!this.dragPreviewContainer||!this.dragPreviewGraphics||!this.draggedClipInfo)return;const{clipConfig:r}=this.draggedClipInfo,n=this.layout.getXAtTime(e),a=(r.length||0)*this.getPixelsPerSecond(),o=this.getTrackHeight();this.dragPreviewGraphics.clear(),this.dragPreviewGraphics.roundRect(0,0,a,o,4),this.dragPreviewGraphics.fill({color:9342611,alpha:.6});const c=i*this.layout.trackHeight,h=Math.abs(t-c)<5?65280:16755200;this.dragPreviewGraphics.stroke({width:2,color:h}),this.dragPreviewContainer.position.set(n,t)}hideDragPreview(){this.dragPreviewContainer&&(this.dragPreviewContainer.destroy({children:!0}),this.dragPreviewContainer=null,this.dragPreviewGraphics=null),this.draggedClipInfo&&(this.getVisualTracks()[this.draggedClipInfo.trackIndex]?.getClip(this.draggedClipInfo.clipIndex)?.setDragging(!1),this.draggedClipInfo=null)}hideDragGhost(){this.dragPreviewContainer&&(this.dragPreviewContainer.visible=!1)}showDragGhost(e,t,i){!this.dragPreviewContainer||!this.draggedClipInfo||(this.dragPreviewContainer.visible=!0,i!==void 0?this.drawDragPreviewAtPosition(t,i,e):this.drawDragPreview(e,t))}getDraggedClipInfo(){return this.draggedClipInfo}hasActivePreview(){return this.dragPreviewContainer!==null}dispose(){this.hideDragPreview()}}class zw{constructor(e,t,i,r,n){this.layout=e,this.trackLayer=t,this.overlayLayer=i,this.entityContainer=r,this.onRender=n}scrollX=0;scrollY=0;zoomLevel=1;viewport;rulerViewport;playheadContainer;async setupViewport(){this.rulerViewport=new L.Container,this.rulerViewport.label="ruler-viewport",this.overlayLayer.addChild(this.rulerViewport),this.playheadContainer=new L.Container,this.playheadContainer.label="playhead-container",this.overlayLayer.addChild(this.playheadContainer),this.viewport=new L.Container,this.viewport.label="viewport",this.trackLayer.addChild(this.viewport),this.viewport.addChild(this.entityContainer)}updateViewportTransform(){const e=this.layout.calculateViewportPosition(this.scrollX,this.scrollY);this.viewport.position.set(e.x,e.y),this.viewport.scale.set(this.zoomLevel,this.zoomLevel),this.rulerViewport.position.x=e.x,this.rulerViewport.scale.x=this.zoomLevel,this.playheadContainer.position.x=e.x,this.playheadContainer.scale.x=this.zoomLevel}setScroll(e,t){this.scrollX=e,this.scrollY=t,this.updateViewportTransform(),this.onRender()}setZoom(e){this.zoomLevel=Math.max(.1,Math.min(10,e)),this.updateViewportTransform(),this.onRender()}getViewport(){return{x:this.scrollX,y:this.scrollY,zoom:this.zoomLevel}}getMainViewport(){return this.viewport}getRulerViewport(){return this.rulerViewport}getPlayheadContainer(){return this.playheadContainer}}const vt={MIN_WIDTH:50,PADDING:4,DEFAULT_ALPHA:1,DRAG_OPACITY:.6,RESIZE_OPACITY:.9,BORDER_WIDTH:2,CORNER_RADIUS:4,SELECTED_BORDER_MULTIPLIER:2,TEXT_FONT_SIZE:12,TEXT_TRUNCATE_SUFFIX_LENGTH:3},ds={PADDING:2,LABEL_PADDING:8,DEFAULT_OPACITY:.8,BORDER_WIDTH:1},Ot={TOOLBAR_HEIGHT_RATIO:.12,RULER_HEIGHT_RATIO:.133,TOOLBAR_HEIGHT_DEFAULT:36,RULER_HEIGHT_DEFAULT:40,TRACK_HEIGHT_DEFAULT:80,BORDER_WIDTH:2,CORNER_RADIUS:4,CLIP_PADDING:4,LABEL_PADDING:8,TRACK_PADDING:2,MIN_CLIP_WIDTH:50};function Cn(s){const e=s.split("/");return e[e.length-1]||s}function $w(s){switch(s.type){case"video":return s.src?Cn(s.src):"Video";case"audio":return s.src?Cn(s.src):"Audio";case"image":return s.src?Cn(s.src):"Image";case"text":return s.text||"Text";case"rich-text":return s.text||"Rich Text";case"shape":return s.shape||"Shape";case"html":return"HTML";case"luma":return s.src?Cn(s.src):"Luma";default:return"Unknown Asset"}}class Nw extends ci{clipConfig;options;graphics;background;text;selectionRenderer;lastGlobalX=-1;lastGlobalY=-1;visualState={mode:"normal"};CLIP_PADDING=vt.PADDING;BORDER_WIDTH=vt.BORDER_WIDTH;get CORNER_RADIUS(){return this.options.theme.timeline.clips.radius||vt.CORNER_RADIUS}constructor(e,t){super(),this.clipConfig=e,this.options=t,this.selectionRenderer=t.selectionRenderer,this.graphics=new L.Graphics,this.background=new L.Graphics,this.text=new L.Text,this.setupContainer()}async load(){this.setupGraphics(),this.updateVisualState()}setupContainer(){const e=this.getContainer();e.label=`clip-${this.options.trackIndex}-${this.options.clipIndex}`,e.interactive=!0,e.cursor="pointer",e.addChild(this.background),e.addChild(this.graphics),e.addChild(this.text)}setupGraphics(){this.text.style=new L.TextStyle({fontSize:vt.TEXT_FONT_SIZE,fill:this.options.theme.timeline.toolbar.text,fontWeight:"bold",wordWrap:!1,fontFamily:"Arial, sans-serif"}),this.text.anchor.set(0,0),this.text.x=this.CLIP_PADDING,this.text.y=this.CLIP_PADDING}updateFromConfig(e){this.clipConfig=e,this.updateVisualState()}updateVisualState(){this.updatePosition(),this.updateAppearance(),this.updateSize(),this.updateText()}setVisualState(e){this.visualState={...this.visualState,...e},this.updateVisualState()}updatePosition(){const e=this.getContainer(),t=this.clipConfig.start||0;e.x=t*this.options.pixelsPerSecond,e.y=0}updateSize(){const e=this.getEffectiveWidth(),t=this.options.trackHeight;this.drawClipBackground(e,t),this.drawClipBorder(e,t)}getEffectiveWidth(){if(this.visualState.previewWidth!==void 0)return this.visualState.previewWidth;const t=(this.clipConfig.length||0)*this.options.pixelsPerSecond;return Math.max(vt.MIN_WIDTH,t)}drawClipBackground(e,t){const i=this.getClipColor(),r=this.getStateStyles();this.background.clear(),this.background.roundRect(0,0,e,t,this.CORNER_RADIUS),this.background.fill({color:i,alpha:r.alpha})}drawClipBorder(e,t){const i=this.getStateStyles(),r=this.BORDER_WIDTH;this.graphics.clear(),this.graphics.roundRect(0,0,e,t,this.CORNER_RADIUS),this.graphics.stroke({width:r,color:i.borderColor}),this.updateSelectionState(e,t)}updateSelectionState(e,t){if(!this.selectionRenderer)return;const i=this.visualState.mode==="selected",r=this.getClipId();if(!i){this.selectionRenderer.clearSelection(r);return}const a=this.getContainer().toGlobal(new L.Point(0,0)),c=this.selectionRenderer.getOverlay().toLocal(a);this.selectionRenderer.renderSelection(r,{x:c.x,y:c.y,width:e,height:t,cornerRadius:this.CORNER_RADIUS,borderWidth:this.BORDER_WIDTH},i)}getClipColor(){const e=this.clipConfig.asset?.type,t=this.options.theme.timeline.clips;switch(e){case"video":return t.video;case"audio":return t.audio;case"image":return t.image;case"text":return t.text;case"rich-text":return t["rich-text"]||t.text;case"shape":return t.shape;case"html":return t.html;case"luma":return t.luma;default:return t.default}}updateAppearance(){const e=this.getContainer();e.alpha=this.visualState.mode==="dragging"?vt.DRAG_OPACITY:vt.DEFAULT_ALPHA}updateText(){const e=this.clipConfig.asset?$w(this.clipConfig.asset):"Clip";this.text.text=e;const i=(this.clipConfig.length||0)*this.options.pixelsPerSecond-this.CLIP_PADDING*2;if(this.text.width>i){const r=i/this.text.width,n=Math.floor(e.length*r)-vt.TEXT_TRUNCATE_SUFFIX_LENGTH;this.text.text=`${e.substring(0,Math.max(1,n))}...`}}getStateStyles(){const{theme:e}=this.options;switch(this.visualState.mode){case"dragging":return{alpha:vt.DRAG_OPACITY,borderColor:e.timeline.tracks.border};case"resizing":return{alpha:vt.RESIZE_OPACITY,borderColor:e.timeline.dropZone};case"selected":return{alpha:vt.DEFAULT_ALPHA,borderColor:e.timeline.clips.selected};default:return{alpha:vt.DEFAULT_ALPHA,borderColor:e.timeline.tracks.border}}}setSelected(e){this.setVisualState({mode:e?"selected":"normal"})}setDragging(e){this.setVisualState({mode:e?"dragging":"normal"})}setResizing(e){this.setVisualState({mode:e?"resizing":"normal",...e?{}:{previewWidth:void 0}})}setPreviewWidth(e){this.setVisualState({previewWidth:e||void 0})}setPixelsPerSecond(e){if(this.updateOptions({pixelsPerSecond:e}),this.visualState.mode==="selected"){const t=this.getEffectiveWidth(),i=this.options.trackHeight;this.updateSelectionState(t,i)}}updateOptions(e){this.options={...this.options,...e},this.updateVisualState()}getClipConfig(){return this.clipConfig}getOptions(){return{...this.options}}getVisualState(){return{...this.visualState}}getSelected(){return this.visualState.mode==="selected"}getClipId(){return`${this.options.trackIndex}-${this.options.clipIndex}`}getDragging(){return this.visualState.mode==="dragging"}getRightEdgeX(){const e=this.getEffectiveWidth();return(this.clipConfig.start||0)*this.options.pixelsPerSecond+e}update(e,t){if(this.visualState.mode==="selected"&&this.selectionRenderer){const r=this.getContainer().toGlobal(new L.Point(0,0));if(r.x!==this.lastGlobalX||r.y!==this.lastGlobalY){this.lastGlobalX=r.x,this.lastGlobalY=r.y;const n=this.getEffectiveWidth(),a=this.options.trackHeight;this.updateSelectionState(n,a)}}}draw(){}dispose(){this.selectionRenderer&&this.selectionRenderer.clearSelection(this.getClipId()),this.background.destroy(),this.graphics.destroy(),this.text.destroy()}}class Uw extends ci{clips=[];options;background;TRACK_PADDING=ds.PADDING;LABEL_PADDING=ds.LABEL_PADDING;constructor(e){super(),this.options=e,this.background=new L.Graphics,this.setupContainer()}async load(){this.updateTrackAppearance()}setupContainer(){const e=this.getContainer();e.label=`track-${this.options.trackIndex}`,e.addChild(this.background),e.y=this.options.trackIndex*this.options.trackHeight}updateTrackAppearance(){const{width:e}=this.options,t=this.options.trackHeight,{theme:i}=this.options;this.background.clear();const r=this.options.trackIndex%2===0?i.timeline.tracks.surface:i.timeline.tracks.surfaceAlt;this.background.rect(0,0,e,t),this.background.fill({color:r,alpha:ds.DEFAULT_OPACITY}),this.background.rect(0,0,e,t),this.background.stroke({width:ds.BORDER_WIDTH,color:i.timeline.tracks.border}),this.background.moveTo(0,t-1),this.background.lineTo(e,t-1),this.background.stroke({width:ds.BORDER_WIDTH,color:i.timeline.divider})}rebuildFromTrackData(e,t){this.options={...this.options,pixelsPerSecond:t},this.clearAllClips(),e.clips&&e.clips.forEach((i,r)=>{const n={pixelsPerSecond:this.options.pixelsPerSecond,trackHeight:this.options.trackHeight,trackIndex:this.options.trackIndex,clipIndex:r,theme:this.options.theme,selectionRenderer:this.options.selectionRenderer},a=new Nw(i,n);this.addClip(a)}),this.updateTrackAppearance()}async addClip(e){this.clips.push(e),await e.load(),this.getContainer().addChild(e.getContainer())}clearAllClips(){const e=this.getContainer();for(const t of this.clips)e.removeChild(t.getContainer()),t.dispose();this.clips=[]}removeClip(e){if(e>=0&&e<this.clips.length){const t=this.clips[e];this.getContainer().removeChild(t.getContainer()),t.dispose(),this.clips.splice(e,1)}}updateClip(e,t){e>=0&&e<this.clips.length&&this.clips[e].updateFromConfig(t)}setPixelsPerSecond(e){this.options={...this.options,pixelsPerSecond:e},this.clips.forEach(t=>{t.setPixelsPerSecond(e)})}setWidth(e){this.options={...this.options,width:e},this.updateTrackAppearance()}setTrackIndex(e){this.options={...this.options,trackIndex:e};const t=this.getContainer();t.y=e*this.options.trackHeight,this.clips.forEach((i,r)=>{i.updateOptions({trackIndex:e})})}selectClip(e){this.clearAllSelections(),e>=0&&e<this.clips.length&&this.clips[e].setSelected(!0)}clearAllSelections(){this.clips.forEach(e=>{e.setSelected(!1)})}getSelectedClip(){return this.clips.find(e=>e.getSelected())||null}getSelectedClipIndex(){return this.clips.findIndex(e=>e.getSelected())}getClips(){return[...this.clips]}getClip(e){return this.clips[e]||null}getClipCount(){return this.clips.length}getTrackIndex(){return this.options.trackIndex}getTrackHeight(){return this.options.trackHeight}getOptions(){return{...this.options}}findClipAtPosition(e,t){if(t<0||t>this.options.trackHeight)return null;const i=e/this.options.pixelsPerSecond;for(let r=0;r<this.clips.length;r+=1){const n=this.clips[r],a=n.getClipConfig(),o=a.start||0,c=o+(a.length||0);if(i>=o&&i<=c)return{clip:n,clipIndex:r}}return null}update(e,t){this.clips.forEach(i=>{i.update(e,t)})}draw(){this.clips.forEach(e=>{e.draw()})}dispose(){this.clearAllClips(),this.background.destroy()}}class Vw{constructor(e,t){this.overlay=e,this.theme=t}selectionGraphics=new Map;renderSelection(e,t,i){if(!i){this.clearSelection(e);return}let r=this.selectionGraphics.get(e);r||(r=new L.Graphics,r.label=`selection-border-${e}`,this.selectionGraphics.set(e,r),this.overlay.addChild(r)),r.position.set(t.x,t.y),r.clear(),r.setStrokeStyle({width:t.borderWidth*vt.SELECTED_BORDER_MULTIPLIER,color:this.theme.timeline.clips.selected}),r.roundRect(0,0,t.width,t.height,t.cornerRadius),r.stroke()}clearSelection(e){const t=this.selectionGraphics.get(e);t&&(this.overlay.removeChild(t),t.destroy(),this.selectionGraphics.delete(e))}clearAllSelections(){this.selectionGraphics.forEach((e,t)=>{this.clearSelection(t)})}updateTheme(e){this.theme=e,this.selectionGraphics.forEach(t=>{t.clear()})}getOverlay(){return this.overlay}dispose(){this.clearAllSelections()}}class Hw{constructor(e,t,i,r,n){this.container=e,this.layout=t,this.theme=i,this.getPixelsPerSecond=r,this.getExtendedTimelineWidth=n,this.selectionOverlay=new L.Container,this.selectionOverlay.label="selectionOverlay",this.container.addChild(this.selectionOverlay),this.selectionRenderer=new Vw(this.selectionOverlay,this.theme)}visualTracks=[];selectionOverlay;selectionRenderer;async rebuildFromEdit(e,t){if(e?.timeline?.tracks){this.clearAllVisualState();for(let i=0;i<e.timeline.tracks.length;i+=1){const r=e.timeline.tracks[i],n={pixelsPerSecond:t,trackHeight:this.layout.trackHeight,trackIndex:i,width:this.getExtendedTimelineWidth(),theme:this.theme,selectionRenderer:this.selectionRenderer},a=new Uw(n);await a.load(),a.rebuildFromTrackData(r,t),this.container.addChild(a.getContainer()),this.visualTracks.push(a)}this.container.setChildIndex(this.selectionOverlay,this.container.children.length-1)}}clearAllVisualState(){this.visualTracks.forEach(e=>{this.container.removeChild(e.getContainer()),e.dispose()}),this.visualTracks=[],this.selectionRenderer.clearAllSelections()}updateVisualSelection(e,t){this.clearVisualSelection();const i=this.visualTracks[e];if(i){const r=i.getClip(t);r&&r.setSelected(!0)}}clearVisualSelection(){this.visualTracks.forEach(e=>{e.getClips().forEach(i=>{i.setSelected(!1)})})}findClipAtPosition(e,t){const i=Math.floor(t/this.layout.trackHeight);if(i<0||i>=this.visualTracks.length)return null;const r=this.visualTracks[i],n=t-i*this.layout.trackHeight,a=r.findClipAtPosition(e,n);return a?{trackIndex:i,clipIndex:a.clipIndex,clipConfig:a.clip.getClipConfig(),x:(a.clip.getClipConfig().start||0)*this.getPixelsPerSecond(),y:i*this.layout.trackHeight,width:(a.clip.getClipConfig().length||0)*this.getPixelsPerSecond(),height:this.layout.trackHeight}:null}updateTrackWidths(e){this.visualTracks.forEach(t=>{t.setWidth(e)})}getVisualTracks(){return this.visualTracks}updatePixelsPerSecond(e){this.visualTracks.forEach(t=>{t.setPixelsPerSecond(e)})}getSelectionOverlay(){return this.selectionOverlay}getSelectionRenderer(){return this.selectionRenderer}dispose(){this.clearAllVisualState(),this.selectionRenderer&&this.selectionRenderer.dispose(),this.selectionOverlay&&this.container&&(this.container.removeChild(this.selectionOverlay),this.selectionOverlay.destroy())}}class jw{constructor(e,t){this.edit=e,this.callbacks=t}setupEventListeners(){this.edit.events.on("timeline:updated",this.handleTimelineUpdated.bind(this)),this.edit.events.on("clip:updated",this.handleClipUpdated.bind(this)),this.edit.events.on("clip:selected",this.handleClipSelected.bind(this)),this.edit.events.on("selection:cleared",this.handleSelectionCleared.bind(this)),this.edit.events.on("drag:started",this.handleDragStarted.bind(this)),this.edit.events.on("drag:ended",this.handleDragEnded.bind(this)),this.edit.events.on("track:created",this.handleTrackCreated.bind(this))}async handleTimelineUpdated(e){await this.callbacks.onEditChange(e.current)}async handleClipUpdated(){await this.callbacks.onEditChange()}handleClipSelected(e){this.callbacks.onClipSelected(e.trackIndex,e.clipIndex)}handleSelectionCleared(){this.callbacks.onSelectionCleared()}handleDragStarted(e){this.callbacks.onDragStarted(e.trackIndex,e.clipIndex)}handleDragEnded(){this.callbacks.onDragEnded()}async handleTrackCreated(){await this.callbacks.onEditChange()}handleSeek(e){this.callbacks.onSeek(e.time*1e3)}dispose(){this.edit.events.off("timeline:updated",this.handleTimelineUpdated.bind(this)),this.edit.events.off("clip:updated",this.handleClipUpdated.bind(this)),this.edit.events.off("clip:selected",this.handleClipSelected.bind(this)),this.edit.events.off("selection:cleared",this.handleSelectionCleared.bind(this)),this.edit.events.off("drag:started",this.handleDragStarted.bind(this)),this.edit.events.off("drag:ended",this.handleDragEnded.bind(this)),this.edit.events.off("track:created",this.handleTrackCreated.bind(this))}}class Ww{constructor(e,t){this.options=e,this.onUpdate=t}app;trackLayer;overlayLayer;animationFrameId=null;async initializePixiApp(){this.app=new L.Application,await this.app.init({width:this.options.width,height:this.options.height,backgroundColor:this.options.backgroundColor,antialias:this.options.antialias,resolution:this.options.resolution,autoDensity:!0,preference:"webgl"});const e=document.querySelector("[data-shotstack-timeline]");if(!e)throw new Error("Timeline container element [data-shotstack-timeline] not found");e.appendChild(this.app.canvas)}async setupRenderLayers(){this.trackLayer=new L.Container,this.overlayLayer=new L.Container,this.trackLayer.label="track-layer",this.overlayLayer.label="overlay-layer",this.app.stage.addChild(this.trackLayer),this.app.stage.addChild(this.overlayLayer)}startAnimationLoop(){let e=performance.now();const t=i=>{const r=i-e;e=i;const n=r/16.667;this.onUpdate(n,r),this.draw(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}draw(){this.app.render()}render(){this.app.render()}updateBackgroundColor(e){this.app&&(this.app.renderer.background.color=e)}getApp(){return this.app}getStage(){return this.app.stage}getTrackLayer(){return this.trackLayer}getOverlayLayer(){return this.overlayLayer}dispose(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.app&&this.app.destroy(!0)}}const Tr={RULER:{DEFAULT_HEIGHT:40,LABEL_FONT_SIZE:10,LABEL_PADDING_X:2},PLAYHEAD:{LINE_WIDTH:2},SCROLL:{HORIZONTAL_SPEED:2,VERTICAL_SPEED:.5}};class L0 extends ci{events;rulerContainer;rulerBackground;timeMarkers;timeLabels;pixelsPerSecond;timelineDuration;rulerHeight;theme;constructor(e){super(),this.events=new is,this.pixelsPerSecond=e.pixelsPerSecond,this.timelineDuration=e.timelineDuration,this.rulerHeight=e.rulerHeight??Tr.RULER.DEFAULT_HEIGHT,this.theme=e.theme,this.rulerContainer=new L.Container,this.rulerBackground=new L.Graphics,this.timeMarkers=new L.Graphics,this.timeLabels=new L.Container}async load(){this.setupRuler(),this.draw()}setupRuler(){this.rulerContainer.label="ruler",this.rulerContainer.addChild(this.rulerBackground),this.rulerContainer.addChild(this.timeMarkers),this.rulerContainer.addChild(this.timeLabels),this.rulerContainer.eventMode="static",this.rulerContainer.cursor="pointer",this.rulerContainer.on("pointerdown",this.onRulerPointerDown.bind(this)),this.getContainer().addChild(this.rulerContainer)}drawRulerBackground(){this.rulerBackground.clear();const e=this.calculateRulerWidth(),t=this.theme?.timeline.ruler.background||4210752,i=this.theme?.timeline.tracks.border||6316128;this.rulerBackground.rect(0,0,e,this.rulerHeight),this.rulerBackground.fill(t),this.rulerBackground.rect(0,this.rulerHeight-1,e,1),this.rulerBackground.fill(i)}drawTimeMarkers(){this.timeMarkers.clear();const e=this.getTimeInterval(),t=this.getVisibleDuration(),i=this.theme?.timeline.ruler.markers||6710886,r=this.rulerHeight*.5;let n=4;e===10?n=9:(e===30||e===60)&&(n=5);const a=e/(n+1);for(let o=0;o<=t;o+=e)for(let c=1;c<=n;c+=1){const u=o+c*a;if(u<=t){const h=u*this.pixelsPerSecond;this.timeMarkers.circle(h,r,1.5),this.timeMarkers.fill(i)}}}drawTimeLabels(){this.timeLabels.removeChildren();const e=this.getTimeInterval(),t=this.getVisibleDuration(),i=this.theme?.timeline.ruler.text||16777215,r={fontSize:Tr.RULER.LABEL_FONT_SIZE,fill:i,fontFamily:"Arial"};for(let n=0;n<=t;n+=e){const a=new L.Text({text:this.formatTime(n),style:r}),o=n*this.pixelsPerSecond;n===0?(a.anchor.set(0,.5),a.x=o+Tr.RULER.LABEL_PADDING_X):(a.anchor.set(.5,.5),a.x=o),a.y=this.rulerHeight*.5,this.timeLabels.addChild(a)}}onRulerPointerDown(e){const t=this.rulerContainer.toLocal(e.global),i=Math.max(0,t.x/this.pixelsPerSecond);this.events.emit("ruler:seeked",{time:i})}updateRuler(e,t){this.pixelsPerSecond=e,this.timelineDuration=t,this.draw()}update(e,t){}draw(){this.drawRulerBackground(),this.drawTimeMarkers(),this.drawTimeLabels()}dispose(){this.timeLabels.removeChildren(),this.rulerContainer.removeChildren(),this.events.clear("*")}getViewportWidth(){return this.getContainer().parent?.width||800}calculateRulerWidth(){const e=this.timelineDuration*this.pixelsPerSecond;return Math.max(e,this.getViewportWidth())}getVisibleDuration(){return Math.max(this.timelineDuration,this.getViewportWidth()/this.pixelsPerSecond)}getTimeInterval(){const e=[1,5,10,30,60,120,300,600],t=80;for(const i of e)if(i*this.pixelsPerSecond>=t)return i;return Math.ceil(this.getVisibleDuration()/10)}formatTime(e){if(e===0)return"0s";const t=Math.floor(e/60),i=e%60;if(e<60)return`${e}s`;if(i===0)return`${t}m`;const r=i.toString().padStart(2,"0");return`${t}:${r}`}}class z0 extends ci{constructor(e){super(),this.options=e,this.graphics=new L.Graphics}events=new is;graphics;currentTime=0;isDragging=!1;async load(){this.setupPlayhead(),this.draw()}setupPlayhead(){this.graphics.label="playhead",this.graphics.eventMode="static",this.graphics.cursor="pointer",this.graphics.on("pointerdown",this.onPointerDown.bind(this)).on("pointermove",this.onPointerMove.bind(this)).on("pointerup",this.onPointerUp.bind(this)).on("pointerupoutside",this.onPointerUp.bind(this)),this.getContainer().addChild(this.graphics)}drawPlayhead(){const e=this.currentTime*this.options.pixelsPerSecond,t=this.options.theme?.timeline.playhead??16729156,i=Tr.PLAYHEAD.LINE_WIDTH,r=e+i/2;this.graphics.clear(),this.graphics.fill(t),this.graphics.rect(e,0,i,this.options.timelineHeight);const n=8;this.graphics.moveTo(r,10),this.graphics.lineTo(r-n,0),this.graphics.lineTo(r+n,0),this.graphics.closePath(),this.graphics.fill()}onPointerDown(e){this.isDragging=!0,this.graphics.cursor="grabbing",this.updateTimeFromPointer(e)}onPointerMove(e){this.isDragging&&this.updateTimeFromPointer(e)}onPointerUp(){this.isDragging=!1,this.graphics.cursor="pointer"}updateTimeFromPointer(e){if(!this.graphics.parent)return;const t=this.graphics.parent.toLocal(e.global),i=Math.max(0,t.x/this.options.pixelsPerSecond);this.setTime(i),this.events.emit("playhead:seeked",{time:i})}setTime(e){this.currentTime=e,this.draw(),this.events.emit("playhead:timeChanged",{time:e})}getTime(){return this.currentTime}updatePlayhead(e,t){this.options.pixelsPerSecond=e,this.options.timelineHeight=t,this.draw()}update(){}draw(){this.drawPlayhead()}dispose(){this.graphics.removeAllListeners(),this.events.clear("*")}}class Gw{events;timeline;abortController;scrollX=0;scrollY=0;constructor(e){this.events=new is,this.timeline=e.timeline}async initialize(){this.setupEventListeners()}setupEventListeners(){this.abortController=new AbortController;const{canvas:e}=this.timeline.getPixiApp();e.addEventListener("wheel",this.handleWheel.bind(this),{passive:!1,signal:this.abortController.signal})}handleWheel(e){if(e.preventDefault(),e.ctrlKey||e.metaKey){this.handleZoom(e);return}this.handleScroll(e)}handleZoom(e){const t=e.deltaY>0?"out":"in",i=this.timeline.getPlayheadTime(),r=this.timeline.getActualEditDuration();t==="in"?this.timeline.zoomIn():this.timeline.zoomOut();const n=this.timeline.getOptions().pixelsPerSecond||50,a=i*n,o=this.timeline.getOptions().width||800,u=this.timeline.timeRange.endTime*n,h=r*n,l=this.calculateZoomScrollPosition({playheadXAfterZoom:a,viewportWidth:o,contentWidth:u,maxPlayheadX:h,actualEditDuration:r,playheadTime:i});this.scrollX=l,this.timeline.setScroll(this.scrollX,this.scrollY);const d=a-l;this.events.emit("zoom",{pixelsPerSecond:n,focusX:d,focusTime:i})}handleScroll(e){let{deltaX:t}=e,{deltaY:i}=e;e.shiftKey&&(t=i,i=0);const r=Tr.SCROLL.HORIZONTAL_SPEED,n=Tr.SCROLL.VERTICAL_SPEED;this.scrollX+=t*r,this.scrollY+=i*n,this.scrollX=this.clampScrollX(this.scrollX),this.scrollY=this.clampScrollY(this.scrollY),this.timeline.setScroll(this.scrollX,this.scrollY),this.events.emit("scroll",{x:this.scrollX,y:this.scrollY})}setScroll(e,t){this.scrollX=this.clampScrollX(e),this.scrollY=this.clampScrollY(t),this.timeline.setScroll(this.scrollX,this.scrollY),this.events.emit("scroll",{x:this.scrollX,y:this.scrollY})}clampScrollX(e){const t=this.timeline.getExtendedTimelineWidth(),i=this.timeline.getOptions().width||0,r=Math.max(0,t-i);return Math.max(0,Math.min(e,r))}clampScrollY(e){const t=this.timeline.getLayout(),i=this.timeline.getVisualTracks().length,r=this.timeline.getOptions().height||0,n=Math.max(0,i*t.trackHeight-(r-t.rulerHeight));return Math.max(0,Math.min(e,n))}getScroll(){return{x:this.scrollX,y:this.scrollY}}calculateZoomScrollPosition(e){const{playheadXAfterZoom:t,viewportWidth:i,contentWidth:r,maxPlayheadX:n,actualEditDuration:a,playheadTime:o}=e,c=t-i/2,u=Math.max(0,r-i);let h;const l=c+i,d=Math.max(0,n-i);r<=i||c<0?h=0:l>n&&o<=a?h=Math.min(d,u):c>u?h=u:h=c;const f=t-h;return(f<0||f>i)&&(t>r-i?h=Math.max(0,t-i+50):h=Math.max(0,t-50),h=Math.max(0,Math.min(h,u))),h}dispose(){this.abortController&&(this.abortController.abort(),this.abortController=void 0),this.events.clear("*")}}const Ne={BUTTON_SIZE:24,BUTTON_HOVER_PADDING:4,BORDER_RADIUS:4,TEXT_SPACING:16,EDGE_MARGIN:10,FRAME_TIME_MS:16.67,ICON:{PLAY:{LEFT:6,TOP:4,RIGHT:18,MIDDLE:12,BOTTOM:20},PAUSE:{RECT1_X:6,RECT2_X:14,TOP:4,WIDTH:4,HEIGHT:16},FRAME_STEP:{TRIANGLE1:{BACK:{LEFT:11,RIGHT:3,MIDDLE:12},FORWARD:{LEFT:4,RIGHT:12,MIDDLE:12}},TRIANGLE2:{BACK:{LEFT:20,RIGHT:12,MIDDLE:12},FORWARD:{LEFT:13,RIGHT:21,MIDDLE:12}},TOP:4,BOTTOM:20}},CUT_BUTTON:{WIDTH:60,HEIGHT:24,FONT_SIZE:12},TIME_DISPLAY:{FONT_SIZE:14,FONT_FAMILY:"monospace"},HOVER_ANIMATION_ALPHA:1,ACTIVE_ANIMATION_ALPHA:.3,DIVIDER_ALPHA:.5};class kn{static createIcon(e,t,i){const r=i?i/Ne.BUTTON_SIZE:1;switch(e){case"play":return this.createPlayIcon(t,r);case"pause":return this.createPauseIcon(t,r);case"frame-back":return this.createFrameBackIcon(t,r);case"frame-forward":return this.createFrameForwardIcon(t,r);default:throw new Error(`Unknown icon type: ${e}`)}}static createPlayIcon(e,t=1){const i=new L.Graphics,{PLAY:r}=Ne.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.LEFT*t,r.TOP*t),i.lineTo(r.RIGHT*t,r.MIDDLE*t),i.lineTo(r.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static createPauseIcon(e,t=1){const i=new L.Graphics,{PAUSE:r}=Ne.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.rect(r.RECT1_X*t,r.TOP*t,r.WIDTH*t,r.HEIGHT*t),i.rect(r.RECT2_X*t,r.TOP*t,r.WIDTH*t,r.HEIGHT*t),i.fill(),i}static createFrameBackIcon(e,t=1){const i=new L.Graphics,{FRAME_STEP:r}=Ne.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.TRIANGLE1.BACK.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE1.BACK.RIGHT*t,r.TRIANGLE1.BACK.MIDDLE*t),i.lineTo(r.TRIANGLE1.BACK.LEFT*t,r.BOTTOM*t),i.closePath(),i.moveTo(r.TRIANGLE2.BACK.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE2.BACK.RIGHT*t,r.TRIANGLE2.BACK.MIDDLE*t),i.lineTo(r.TRIANGLE2.BACK.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static createFrameForwardIcon(e,t=1){const i=new L.Graphics,{FRAME_STEP:r}=Ne.ICON;return i.fill({color:e.timeline.toolbar.icon}),i.moveTo(r.TRIANGLE1.FORWARD.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE1.FORWARD.RIGHT*t,r.TRIANGLE1.FORWARD.MIDDLE*t),i.lineTo(r.TRIANGLE1.FORWARD.LEFT*t,r.BOTTOM*t),i.closePath(),i.moveTo(r.TRIANGLE2.FORWARD.LEFT*t,r.TOP*t),i.lineTo(r.TRIANGLE2.FORWARD.RIGHT*t,r.TRIANGLE2.FORWARD.MIDDLE*t),i.lineTo(r.TRIANGLE2.FORWARD.LEFT*t,r.BOTTOM*t),i.closePath(),i.fill(),i}static updateIconColor(e,t){const i=e.getBounds();e.clear(),e.position.set(i.x,i.y)}}class $0 extends L.Container{background;hoverBackground;icon;alternateIcon;state={isHovering:!1,isPressed:!1,isActive:!1};size;theme;onClick;constructor(e){super(),this.size=e.size||Ne.BUTTON_SIZE,this.theme=e.theme,this.onClick=e.onClick,this.eventMode="static",this.cursor="pointer",this.background=new L.Graphics,this.addChild(this.background),this.hoverBackground=new L.Graphics,this.addChild(this.hoverBackground);const i=this.size*.6,r=(this.size-i)/2;e.iconType&&(this.icon=kn.createIcon(e.iconType,this.theme,i),this.icon.position.set(r,r),this.addChild(this.icon)),e.alternateIconType&&(this.alternateIcon=kn.createIcon(e.alternateIconType,this.theme,i),this.alternateIcon.position.set(r,r),this.alternateIcon.visible=!1,this.addChild(this.alternateIcon)),this.setupEventListeners(),this.updateVisuals()}setupEventListeners(){this.on("pointerdown",this.handlePointerDown,this),this.on("pointerup",this.handlePointerUp,this),this.on("pointerupoutside",this.handlePointerUp,this),this.on("pointerover",this.handlePointerOver,this),this.on("pointerout",this.handlePointerOut,this)}handlePointerDown(){this.state.isPressed=!0,this.updateVisuals()}handlePointerUp(){this.state.isPressed&&this.onClick(),this.state.isPressed=!1,this.updateVisuals()}handlePointerOver(){this.state.isHovering=!0,this.updateVisuals()}handlePointerOut(){this.state.isHovering=!1,this.state.isPressed=!1,this.updateVisuals()}updateVisuals(){const e=Ne.BUTTON_HOVER_PADDING,t=this.size/2;this.background.clear(),this.background.circle(t,t,t),this.background.fill({color:this.theme.timeline.toolbar.surface,alpha:.8}),this.hoverBackground.clear(),this.hoverBackground.circle(t,t,t+e),this.state.isPressed?this.hoverBackground.fill({color:this.theme.timeline.toolbar.active,alpha:Ne.ACTIVE_ANIMATION_ALPHA}):this.state.isHovering?this.hoverBackground.fill({color:this.theme.timeline.toolbar.hover,alpha:Ne.HOVER_ANIMATION_ALPHA}):this.hoverBackground.fill({color:this.theme.timeline.toolbar.hover,alpha:0})}setActive(e){this.state.isActive=e,this.icon&&this.alternateIcon&&(this.icon.visible=!e,this.alternateIcon.visible=e)}updateTheme(e){this.theme=e;const i=this.size*.6,r=(this.size-i)/2;if(this.icon){const n=this.getIconType(this.icon);n&&(this.removeChild(this.icon),this.icon=kn.createIcon(n,e,i),this.icon.position.set(r,r),this.addChild(this.icon))}if(this.alternateIcon){const n=this.getIconType(this.alternateIcon);n&&(this.removeChild(this.alternateIcon),this.alternateIcon=kn.createIcon(n,e,i),this.alternateIcon.position.set(r,r),this.alternateIcon.visible=this.state.isActive,this.addChild(this.alternateIcon))}this.updateVisuals()}getIconType(e){return null}destroy(){this.removeAllListeners(),super.destroy()}}class qw extends L.Container{edit;theme;toolbarHeight;frameBackButton;playPauseButton;frameForwardButton;constructor(e,t,i){super(),this.edit=e,this.theme=t,this.toolbarHeight=i||36,this.createButtons(),this.subscribeToEditEvents(),this.updatePlayPauseState()}createButtons(){const e=this.calculateButtonSizes(),t=(e.playButton-e.regularButton)/2,i=(r,n,a,o)=>new $0({iconType:r,onClick:n,tooltip:a,theme:this.theme,size:o});this.frameBackButton=i("frame-back",()=>this.handleFrameBack(),"Previous frame",e.regularButton),this.frameBackButton.position.set(0,t),this.playPauseButton=new $0({iconType:"play",alternateIconType:"pause",onClick:()=>this.handlePlayPause(),tooltip:"Play/Pause",theme:this.theme,size:e.playButton}),this.playPauseButton.position.set(e.regularButton+e.spacing,0),this.frameForwardButton=i("frame-forward",()=>this.handleFrameForward(),"Next frame",e.regularButton),this.frameForwardButton.position.set(e.regularButton+e.spacing+e.playButton+e.spacing,t),this.addChild(this.frameBackButton,this.playPauseButton,this.frameForwardButton)}calculateButtonSizes(){const e=Math.round(this.toolbarHeight*.5);return{regularButton:e,playButton:Math.round(e*1.5),spacing:Math.round(this.toolbarHeight*.15)}}handleFrameBack(){this.edit.seek(this.edit.playbackTime-Ne.FRAME_TIME_MS)}handlePlayPause(){this.edit.isPlaying?this.edit.pause():this.edit.play()}handleFrameForward(){this.edit.seek(this.edit.playbackTime+Ne.FRAME_TIME_MS)}subscribeToEditEvents(){this.edit.events.on("playback:play",this.updatePlayPauseState),this.edit.events.on("playback:pause",this.updatePlayPauseState)}updatePlayPauseState=()=>{this.playPauseButton.setActive(this.edit.isPlaying)};update(){}resize(e){}updateTheme(e){this.theme=e,this.frameBackButton.updateTheme(e),this.playPauseButton.updateTheme(e),this.frameForwardButton.updateTheme(e)}destroy(){this.edit.events.off("playback:play",this.updatePlayPauseState),this.edit.events.off("playback:pause",this.updatePlayPauseState),this.frameBackButton.destroy(),this.playPauseButton.destroy(),this.frameForwardButton.destroy(),super.destroy()}getWidth(){const e=this.calculateButtonSizes();return e.regularButton*2+e.playButton+e.spacing*2}}class Xw extends L.Container{edit;theme;timeText;formatOptions;constructor(e,t,i={}){super(),this.edit=e,this.theme=t,this.formatOptions={showMilliseconds:!1,showHours:!1,...i},this.createDisplay(),this.subscribeToEditEvents(),this.updateTimeDisplay()}createDisplay(){const e=new L.TextStyle({fontFamily:Ne.TIME_DISPLAY.FONT_FAMILY,fontSize:Ne.TIME_DISPLAY.FONT_SIZE,fill:this.theme.timeline.toolbar.text});this.timeText=new L.Text("0:00 / 0:00",e),this.timeText.anchor.set(0,.5),this.addChild(this.timeText)}subscribeToEditEvents(){this.edit.events.on("playback:time",this.updateTimeDisplay),this.edit.events.on("duration:changed",this.updateTimeDisplay)}updateTimeDisplay=()=>{const e=this.formatTime(this.edit.playbackTime/1e3),t=this.formatTime(this.edit.getTotalDuration()/1e3);this.timeText.text=`${e} / ${t}`};formatTime(e){const t=Math.floor(e/3600),i=Math.floor(e%3600/60),r=Math.floor(e%60),n=Math.floor(e%1*10);let a="";return this.formatOptions.showHours||t>0?a+=`${t}:${i.toString().padStart(2,"0")}`:a+=`${i}`,a+=`:${r.toString().padStart(2,"0")}`,this.formatOptions.showMilliseconds?a+=`.${n}`:a+=`.${n}`,a}update(){this.updateTimeDisplay()}resize(e){}updateTheme(e){this.theme=e,this.timeText.style.fill=e.timeline.toolbar.text}destroy(){this.edit.events.off("playback:time",this.updateTimeDisplay),this.edit.events.off("duration:changed",this.updateTimeDisplay),super.destroy()}getWidth(){return this.timeText.width}}class Zw extends L.Container{edit;theme;cutButton;cutButtonBackground;cutButtonText;constructor(e,t){super(),this.edit=e,this.theme=t,this.createCutButton()}createCutButton(){this.cutButton=new L.Container,this.cutButton.eventMode="static",this.cutButton.cursor="pointer";const{WIDTH:e,HEIGHT:t,FONT_SIZE:i}=Ne.CUT_BUTTON;this.cutButtonBackground=new L.Graphics,this.cutButtonBackground.roundRect(0,0,e,t,Ne.BORDER_RADIUS),this.cutButtonBackground.fill({color:this.theme.timeline.toolbar.surface||4473924}),this.cutButtonBackground.stroke({color:this.theme.timeline.tracks.border||6710886,width:1}),this.cutButton.addChild(this.cutButtonBackground);const r=new L.TextStyle({fontFamily:"Arial",fontSize:i,fill:this.theme.timeline.toolbar.text||16777215});this.cutButtonText=new L.Text("SPLIT",r),this.cutButtonText.anchor.set(.5),this.cutButtonText.position.set(e/2,t/2),this.cutButton.addChild(this.cutButtonText),this.cutButton.on("click",this.handleCutClick,this),this.cutButton.on("pointerdown",this.handlePointerDown,this),this.cutButton.on("pointerover",this.handlePointerOver,this),this.cutButton.on("pointerout",this.handlePointerOut,this),this.addChild(this.cutButton)}handleCutClick=e=>{e.stopPropagation(),this.performCutClip()};handlePointerDown=e=>{e.stopPropagation(),this.updateButtonVisual(!0,!1)};handlePointerOver=()=>{this.updateButtonVisual(!1,!0)};handlePointerOut=()=>{this.updateButtonVisual(!1,!1)};updateButtonVisual(e,t){this.cutButtonBackground.clear(),this.cutButtonBackground.roundRect(0,0,Ne.CUT_BUTTON.WIDTH,Ne.CUT_BUTTON.HEIGHT,Ne.BORDER_RADIUS);let i=this.theme.timeline.toolbar.surface||4473924;const r=1;e?i=this.theme.timeline.toolbar.active||3355443:t&&(i=this.theme.timeline.toolbar.hover||5592405),this.cutButtonBackground.fill({color:i,alpha:r}),this.cutButtonBackground.stroke({color:this.theme.timeline.tracks.border||6710886,width:1})}performCutClip(){const e=this.edit.getSelectedClipInfo();if(!e)return;const{trackIndex:t,clipIndex:i}=e,r=this.edit.playbackTime/1e3;this.edit.splitClip(t,i,r)}update(){const e=this.edit.getSelectedClipInfo()!==null;this.cutButton.alpha=e?1:.5,this.cutButton.eventMode=e?"static":"none",this.cutButton.cursor=e?"pointer":"default"}resize(e){}updateTheme(e){this.theme=e,this.updateButtonVisual(!1,!1),this.cutButtonText.style.fill=e.timeline.toolbar.text||16777215}destroy(){this.cutButton.removeAllListeners(),super.destroy()}getWidth(){return Ne.CUT_BUTTON.WIDTH}}class Kw{config;constructor(e,t){this.config={width:e,height:t,buttonSize:Math.round(t*.5),buttonSpacing:Math.round(t*.15),edgeMargin:Ne.EDGE_MARGIN}}getPlaybackControlsPosition(){const e=this.calculatePlaybackControlsWidth(),t=(this.config.width-e)/2,i=(this.config.height-this.getMaxButtonHeight())/2;return{x:t,y:i}}getMaxButtonHeight(){const e=this.config.buttonSize;return Math.round(e*1.5)}getTimeDisplayPosition(e){const i=(this.config.width-e)/2+e+Ne.TEXT_SPACING,r=this.config.height/2;return{x:i,y:r}}getEditControlsPosition(){const e=this.config.width-Ne.CUT_BUTTON.WIDTH-this.config.edgeMargin,t=(this.config.height-Ne.CUT_BUTTON.HEIGHT)/2;return{x:e,y:t}}calculatePlaybackControlsWidth(){const e=this.config.buttonSize,t=Math.round(e*1.5);return e*2+t+this.config.buttonSpacing*2}updateWidth(e){this.config.width=e}getConfig(){return{...this.config}}}class Yw extends L.Container{constructor(e,t,i,r){super(),this.edit=e,this.theme=t,this.layout=i,this.toolbarWidth=r,this.toolbarHeight=i.toolbarHeight,this.position.set(0,i.toolbarY),this.toolbarLayout=new Kw(r,this.toolbarHeight),this.createBackground(),this.createComponents(),this.positionComponents(),this.subscribeToEditEvents()}background;playbackControls;timeDisplay;editControls;toolbarLayout;toolbarWidth;toolbarHeight;get width(){return this.toolbarWidth}get height(){return this.toolbarHeight}createBackground(){this.background=new L.Graphics,this.drawBackground(),this.addChild(this.background)}drawBackground(){this.background.clear(),this.background.rect(0,0,this.toolbarWidth,this.toolbarHeight),this.background.fill({color:this.theme.timeline.toolbar.background}),this.background.setStrokeStyle({width:1,color:this.theme.timeline.toolbar.divider,alpha:Ne.DIVIDER_ALPHA}),this.background.moveTo(0,this.toolbarHeight-.5),this.background.lineTo(this.toolbarWidth,this.toolbarHeight-.5),this.background.stroke()}createComponents(){this.playbackControls=new qw(this.edit,this.theme,this.toolbarHeight),this.addChild(this.playbackControls),this.timeDisplay=new Xw(this.edit,this.theme),this.addChild(this.timeDisplay),this.editControls=new Zw(this.edit,this.theme),this.addChild(this.editControls)}positionComponents(){const e=this.toolbarLayout.getPlaybackControlsPosition();this.playbackControls.position.set(e.x,e.y);const t=this.toolbarLayout.getTimeDisplayPosition(this.playbackControls.getWidth());this.timeDisplay.position.set(t.x,t.y);const i=this.toolbarLayout.getEditControlsPosition();this.editControls.position.set(i.x,i.y)}subscribeToEditEvents(){this.edit.events.on("clip:selected",this.updateEditControls),this.edit.events.on("selection:cleared",this.updateEditControls)}updateEditControls=()=>{this.editControls.update()};resize(e){this.toolbarWidth=e,this.toolbarLayout.updateWidth(e),this.drawBackground(),this.positionComponents(),this.playbackControls.resize(e),this.timeDisplay.resize(e),this.editControls.resize(e)}updateTheme(e){this.theme=e,this.drawBackground(),this.playbackControls.updateTheme(e),this.timeDisplay.updateTheme(e),this.editControls.updateTheme(e)}updateTimeDisplay=()=>{this.timeDisplay.update()};destroy(){this.edit.events.off("clip:selected",this.updateEditControls),this.edit.events.off("selection:cleared",this.updateEditControls),this.playbackControls.destroy(),this.timeDisplay.destroy(),this.editControls.destroy(),super.destroy()}}class Jw{constructor(e,t,i,r,n,a){this.edit=e,this.layout=t,this.renderer=i,this.viewportManager=r,this.eventHandler=n,this.getTimelineContext=a}toolbar;ruler;playhead;scroll;async setupTimelineFeatures(e,t,i,r,n){this.toolbar=new Yw(this.edit,e,this.layout,i),this.renderer.getStage().addChild(this.toolbar);const a={pixelsPerSecond:t,timelineDuration:n,rulerHeight:this.layout.rulerHeight,theme:e};this.ruler=new L0(a),await this.ruler.load(),this.ruler.getContainer().y=this.layout.rulerY,this.viewportManager.getRulerViewport().addChild(this.ruler.getContainer()),this.ruler.events.on("ruler:seeked",this.eventHandler.handleSeek.bind(this.eventHandler));const o={pixelsPerSecond:t,timelineHeight:r,theme:e};this.playhead=new z0(o),await this.playhead.load(),this.playhead.getContainer().y=this.layout.rulerY,this.viewportManager.getPlayheadContainer().addChild(this.playhead.getContainer()),this.playhead.events.on("playhead:seeked",this.eventHandler.handleSeek.bind(this.eventHandler));const c={timeline:this.getTimelineContext()};this.scroll=new Gw(c),await this.scroll.initialize(),this.viewportManager.updateViewportTransform()}recreateTimelineFeatures(e,t,i,r){if(this.ruler){this.ruler.dispose();const{rulerHeight:n}=this.layout,a={pixelsPerSecond:t,timelineDuration:r,rulerHeight:n,theme:e};this.ruler=new L0(a),this.ruler.load(),this.ruler.getContainer().y=this.layout.rulerY,this.viewportManager.getRulerViewport().addChild(this.ruler.getContainer()),this.ruler.events.on("ruler:seeked",this.eventHandler.handleSeek.bind(this.eventHandler))}if(this.playhead){this.playhead.dispose();const n={pixelsPerSecond:t,timelineHeight:i,theme:e};this.playhead=new z0(n),this.playhead.load(),this.playhead.getContainer().y=this.layout.rulerY,this.viewportManager.getPlayheadContainer().addChild(this.playhead.getContainer()),this.playhead.events.on("playhead:seeked",this.eventHandler.handleSeek.bind(this.eventHandler))}}updateRuler(e,t){this.ruler.updateRuler(e,t)}updatePlayhead(e,t){this.playhead&&this.playhead.updatePlayhead(e,t)}getFeatures(){return{toolbar:this.toolbar,ruler:this.ruler,playhead:this.playhead,scroll:this.scroll}}getToolbar(){return this.toolbar}getPlayhead(){return this.playhead}dispose(){this.toolbar&&this.toolbar.destroy(),this.ruler&&this.ruler.dispose(),this.playhead&&this.playhead.dispose(),this.scroll&&this.scroll.dispose()}}class oi{constructor(e,t){this.options=e,this.theme=t,this.config=this.calculateLayout()}static TOOLBAR_HEIGHT_RATIO=Ot.TOOLBAR_HEIGHT_RATIO;static RULER_HEIGHT_RATIO=Ot.RULER_HEIGHT_RATIO;static TOOLBAR_HEIGHT_DEFAULT=Ot.TOOLBAR_HEIGHT_DEFAULT;static RULER_HEIGHT_DEFAULT=Ot.RULER_HEIGHT_DEFAULT;static TRACK_HEIGHT_DEFAULT=Ot.TRACK_HEIGHT_DEFAULT;static CLIP_PADDING=Ot.CLIP_PADDING;static BORDER_WIDTH=Ot.BORDER_WIDTH;static CORNER_RADIUS=Ot.CORNER_RADIUS;static LABEL_PADDING=Ot.LABEL_PADDING;static TRACK_PADDING=Ot.TRACK_PADDING;config;calculateLayout(){const e=this.options.height;let t=this.theme?.timeline.toolbar.height||Math.round(e*oi.TOOLBAR_HEIGHT_RATIO),i=this.theme?.timeline.ruler.height||Math.round(e*oi.RULER_HEIGHT_RATIO);t=Math.max(t,oi.TOOLBAR_HEIGHT_DEFAULT),i=Math.max(i,oi.RULER_HEIGHT_DEFAULT);const{trackHeight:r}=this.options;return{toolbarHeight:t,rulerHeight:i,trackHeight:r,toolbarY:0,rulerY:t,tracksY:t+i,gridY:t+i,playheadY:t,viewportY:t+i}}get toolbarHeight(){return this.config.toolbarHeight}get toolbarY(){return this.config.toolbarY}get rulerHeight(){return this.config.rulerHeight}get trackHeight(){return this.config.trackHeight}get rulerY(){return this.config.rulerY}get tracksY(){return this.config.tracksY}get gridY(){return this.config.gridY}get playheadY(){return this.config.playheadY}get viewportY(){return this.config.viewportY}positionTrack(e){return e*this.trackHeight}positionClip(e){return e*this.options.pixelsPerSecond}calculateClipWidth(e){return Math.max(Ot.MIN_CLIP_WIDTH,e*this.options.pixelsPerSecond)}calculateDropPosition(e,t){const i=t-this.tracksY,r=Math.floor(i/this.trackHeight),n=Math.max(0,e/this.options.pixelsPerSecond);return{track:Math.max(0,r),time:n,x:e,y:i}}getTrackAtY(e){const t=e-this.tracksY;return Math.floor(t/this.trackHeight)}getTimeAtX(e){return e/this.options.pixelsPerSecond}getXAtTime(e){return e*this.options.pixelsPerSecond}getYAtTrack(e){return this.tracksY+e*this.trackHeight}getGridHeight(){return this.options.height-this.toolbarHeight-this.rulerHeight}getRulerWidth(){return this.options.width}getGridWidth(){return this.options.width}calculateViewportPosition(e,t){return{x:-e,y:this.viewportY-t}}updateOptions(e,t){this.options=e,this.theme=t,this.config=this.calculateLayout()}isPointInToolbar(e,t){return t>=this.toolbarY&&t<=this.toolbarY+this.toolbarHeight}isPointInRuler(e,t){return t>=this.rulerY&&t<=this.rulerY+this.rulerHeight}isPointInTracks(e,t){return t>=this.tracksY&&t<=this.options.height}getVisibleTrackRange(e,t){const i=e,r=Math.floor(i/this.trackHeight),n=Math.ceil((i+t)/this.trackHeight);return{start:Math.max(0,r),end:Math.max(0,n)}}}class Qt{constructor(e,t,i,r){this.layout=i,this.onResize=r,this.width=e.width,this.height=e.height,this.pixelsPerSecond=50;const n=t.timeline.tracks.height||oi.TRACK_HEIGHT_DEFAULT;this.trackHeight=Math.max(40,n),this.backgroundColor=t.timeline.background,this.antialias=!0,this.resolution=window.devicePixelRatio||1}pixelsPerSecond;trackHeight;backgroundColor;antialias;resolution;width;height;static MIN_PIXELS_PER_SECOND=10;static MAX_PIXELS_PER_SECOND=500;static ZOOM_FACTOR=1.1;getOptions(){return{width:this.width,height:this.height,pixelsPerSecond:this.pixelsPerSecond,trackHeight:this.trackHeight,backgroundColor:this.backgroundColor,antialias:this.antialias,resolution:this.resolution}}setOptions(e){e.width!==void 0&&(this.width=e.width,this.onResize&&this.onResize(this.width)),e.height!==void 0&&(this.height=e.height),e.pixelsPerSecond!==void 0&&(this.pixelsPerSecond=e.pixelsPerSecond),e.trackHeight!==void 0&&(this.trackHeight=e.trackHeight),e.backgroundColor!==void 0&&(this.backgroundColor=e.backgroundColor),e.antialias!==void 0&&(this.antialias=e.antialias),e.resolution!==void 0&&(this.resolution=e.resolution),this.layout.updateOptions(this.getOptions())}updateFromTheme(e){this.backgroundColor=e.timeline.background;const t=e.timeline.tracks.height||oi.TRACK_HEIGHT_DEFAULT;this.trackHeight=Math.max(40,t),this.layout.updateOptions(this.getOptions(),e)}getWidth(){return this.width}getHeight(){return this.height}getPixelsPerSecond(){return this.pixelsPerSecond}getTrackHeight(){return this.trackHeight}getBackgroundColor(){return this.backgroundColor}getAntialias(){return this.antialias}getResolution(){return this.resolution}zoomIn(){const e=Math.min(this.pixelsPerSecond*Qt.ZOOM_FACTOR,Qt.MAX_PIXELS_PER_SECOND);this.setPixelsPerSecond(e)}zoomOut(){const e=Math.max(this.pixelsPerSecond/Qt.ZOOM_FACTOR,Qt.MIN_PIXELS_PER_SECOND);this.setPixelsPerSecond(e)}setPixelsPerSecond(e){this.pixelsPerSecond=Math.max(Qt.MIN_PIXELS_PER_SECOND,Math.min(Qt.MAX_PIXELS_PER_SECOND,e)),this.layout.updateOptions(this.getOptions())}canZoomIn(){return this.pixelsPerSecond<Qt.MAX_PIXELS_PER_SECOND}canZoomOut(){return this.pixelsPerSecond>Qt.MIN_PIXELS_PER_SECOND}}class vo extends ci{constructor(e,t,i){super(),this.edit=e,this.theme=D0.resolveTheme(i),this.layout=new oi({width:t.width,height:t.height,pixelsPerSecond:50,trackHeight:Math.max(40,this.theme.timeline.tracks.height||oi.TRACK_HEIGHT_DEFAULT),backgroundColor:this.theme.timeline.background,antialias:!0,resolution:window.devicePixelRatio||1},this.theme),this.optionsManager=new Qt(t,this.theme,this.layout,r=>this.featureManager?.getToolbar()?.resize(r)),this.initializeManagers(),this.setupInteraction()}currentEditType=null;layout;theme;lastPlaybackTime=0;static TIMELINE_BUFFER_MULTIPLIER=1.5;interaction;dragPreviewManager;viewportManager;visualTrackManager;eventHandler;renderer;featureManager;optionsManager;initializeManagers(){const e=this.optionsManager.getOptions();this.renderer=new Ww({width:e.width||800,height:e.height||600,backgroundColor:e.backgroundColor||0,antialias:e.antialias??!0,resolution:e.resolution||window.devicePixelRatio||1},(t,i)=>this.update(t,i)),this.eventHandler=new jw(this.edit,{onEditChange:this.handleEditChange.bind(this),onSeek:t=>this.edit.seek(t),onClipSelected:(t,i)=>this.visualTrackManager.updateVisualSelection(t,i),onSelectionCleared:()=>this.visualTrackManager.clearVisualSelection(),onDragStarted:(t,i)=>{const r=this.getClipData(t,i);r&&this.dragPreviewManager.showDragPreview(t,i,r)},onDragEnded:()=>this.dragPreviewManager.hideDragPreview()}),this.eventHandler.setupEventListeners()}async load(){await this.renderer.initializePixiApp(),await this.renderer.setupRenderLayers(),await this.setupViewport(),await this.setupTimelineFeatures(),this.interaction.activate();try{const e=this.edit.getEdit();e&&(this.currentEditType=e,await this.rebuildFromEdit(e))}catch{}this.renderer.startAnimationLoop()}async setupViewport(){this.viewportManager=new zw(this.layout,this.renderer.getTrackLayer(),this.renderer.getOverlayLayer(),this.getContainer(),()=>this.renderer.render()),await this.viewportManager.setupViewport(),this.visualTrackManager=new Hw(this.getContainer(),this.layout,this.theme,()=>this.optionsManager.getPixelsPerSecond(),()=>this.getExtendedTimelineWidth()),this.dragPreviewManager=new Lw(this.getContainer(),this.layout,()=>this.optionsManager.getPixelsPerSecond(),()=>this.optionsManager.getTrackHeight(),()=>this.visualTrackManager.getVisualTracks()),this.featureManager=new Jw(this.edit,this.layout,this.renderer,this.viewportManager,this.eventHandler,()=>this)}async setupTimelineFeatures(){const e=this.getExtendedTimelineDuration();await this.featureManager.setupTimelineFeatures(this.theme,this.optionsManager.getPixelsPerSecond(),this.optionsManager.getWidth(),this.optionsManager.getHeight(),e)}recreateTimelineFeatures(){const e=this.getExtendedTimelineDuration();this.featureManager.recreateTimelineFeatures(this.theme,this.optionsManager.getPixelsPerSecond(),this.optionsManager.getHeight(),e)}setScroll(e,t){this.viewportManager.setScroll(e,t)}setZoom(e){this.viewportManager.setZoom(e)}getViewport(){return this.viewportManager.getViewport()}getPixiApp(){return this.renderer.getApp()}getTrackLayer(){return this.renderer.getTrackLayer()}getOverlayLayer(){return this.renderer.getOverlayLayer()}getClipData(e,t){return this.currentEditType?.timeline?.tracks&&this.currentEditType.timeline.tracks[e]?.clips?.[t]||null}getLayout(){return this.layout}getVisualTracks(){return this.visualTrackManager.getVisualTracks()}getEdit(){return this.edit}getExtendedTimelineWidth(){const e=this.getExtendedTimelineDuration()*this.optionsManager.getPixelsPerSecond(),t=this.optionsManager.getWidth();return Math.max(e,t)}hideDragGhost(){this.dragPreviewManager.hideDragGhost()}showDragGhost(e,t,i){this.dragPreviewManager.showDragGhost(e,t,i)}setPlayheadTime(e){this.featureManager.getPlayhead().setTime(e)}getPlayheadTime(){return this.featureManager.getPlayhead().getTime()}getActualEditDuration(){return this.edit.totalDuration/1e3||60}setupInteraction(){this.interaction=new Bw(this)}async handleEditChange(e){this.dragPreviewManager.hideDragPreview();const t=e||this.edit.getEdit();t&&(this.currentEditType=t,this.updateRulerDuration(),this.clearAllVisualState(),await this.rebuildFromEdit(t))}getExtendedTimelineDuration(){const e=this.edit.totalDuration/1e3||60;return Math.max(60,e*vo.TIMELINE_BUFFER_MULTIPLIER)}updateRulerDuration(){const e=this.getExtendedTimelineDuration(),t=this.getExtendedTimelineWidth();this.featureManager.updateRuler(this.optionsManager.getPixelsPerSecond(),e),this.visualTrackManager.updateTrackWidths(t)}clearAllVisualState(){this.dragPreviewManager.hideDragPreview(),this.visualTrackManager.clearAllVisualState()}async rebuildFromEdit(e){await this.visualTrackManager.rebuildFromEdit(e,this.optionsManager.getPixelsPerSecond()),this.renderer.render()}findClipAtPosition(e,t){return this.currentEditType?this.visualTrackManager.findClipAtPosition(e,t):null}setTheme(e){this.theme=D0.resolveTheme(e),this.optionsManager.updateFromTheme(this.theme),this.featureManager.getToolbar()&&this.featureManager.getToolbar().updateTheme(this.theme),this.recreateTimelineFeatures(),this.currentEditType&&(this.clearAllVisualState(),this.rebuildFromEdit(this.currentEditType)),this.renderer.updateBackgroundColor(this.optionsManager.getBackgroundColor()),this.renderer.render()}getTheme(){return this.theme}getCurrentEditType(){return this.currentEditType}getOptions(){return this.optionsManager.getOptions()}setOptions(e){this.optionsManager.setOptions(e)}update(e,t){(this.edit.isPlaying||this.lastPlaybackTime!==this.edit.playbackTime)&&(this.featureManager.getPlayhead().setTime(this.edit.playbackTime/1e3),this.lastPlaybackTime=this.edit.playbackTime,this.featureManager.getToolbar()&&this.featureManager.getToolbar().updateTimeDisplay())}draw(){this.renderer.draw()}getTimeDisplay(){return this.featureManager.getToolbar()}updateTime(e,t){this.setPlayheadTime(e),t&&this.edit.seek(e*1e3)}get timeRange(){return{startTime:0,endTime:this.getExtendedTimelineDuration()}}get viewportHeight(){return this.optionsManager.getHeight()}get zoomLevelIndex(){const e=this.viewportManager.getViewport();return Math.round(Math.log2(e.zoom)+5)}zoomIn(){this.optionsManager.zoomIn(),this.onZoomChanged()}zoomOut(){this.optionsManager.zoomOut(),this.onZoomChanged()}onZoomChanged(){const e=this.optionsManager.getPixelsPerSecond();this.visualTrackManager.updatePixelsPerSecond(e);const t=this.getExtendedTimelineWidth();this.visualTrackManager.updateTrackWidths(t),this.featureManager.updateRuler(e,this.getExtendedTimelineDuration()),this.featureManager.updatePlayhead(e,this.optionsManager.getHeight()),this.renderer.render()}dispose(){this.dragPreviewManager.dispose(),this.visualTrackManager.dispose(),this.eventHandler.dispose(),this.featureManager.dispose(),this.interaction&&this.interaction.dispose(),this.renderer.dispose()}}pe.AssetSchema=Mu,pe.AudioAssetSchema=Na,pe.AudioAssetUrlSchema=wu,pe.AudioAssetVolumeSchema=xu,pe.Canvas=Zi,pe.ClipSchema=Ya,pe.Controls=ov,pe.Edit=wr,pe.EditSchema=Vu,pe.FontSourceSchema=$u,pe.FontSourceUrlSchema=zu,pe.HtmlAssetSchema=Ua,pe.ImageAssetCropSchema=ku,pe.ImageAssetSchema=Va,pe.ImageAssetUrlSchema=Cu,pe.KeyframeEasingSchema=vu,pe.KeyframeInterpolationSchema=bu,pe.KeyframeSchema=Ai,pe.LumaAssetSchema=Ha,pe.LumaAssetUrlSchema=Su,pe.OutputSchema=Uu,pe.RichTextAssetSchema=Ss,pe.ShapeAssetCircleSchema=Ga,pe.ShapeAssetColorSchema=ja,pe.ShapeAssetFillSchema=Tu,pe.ShapeAssetLineSchema=qa,pe.ShapeAssetRectangleSchema=Wa,pe.ShapeAssetSchema=Xa,pe.ShapeAssetStrokeSchema=Eu,pe.TextAssetAlignmentSchema=Au,pe.TextAssetBackgroundSchema=Iu,pe.TextAssetColorSchema=hn,pe.TextAssetFontSchema=_u,pe.TextAssetSchema=Za,pe.TextAssetStrokeSchema=Pu,pe.Timeline=vo,pe.TimelineSchema=Nu,pe.TrackSchema=Lu,pe.VideoAssetCropSchema=Fu,pe.VideoAssetSchema=Ka,pe.VideoAssetUrlSchema=Ou,pe.VideoAssetVolumeSchema=Ru,pe.VideoExporter=_w,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})});