import{j as G,M as Gt,S as Qt}from"./vendor-mui-69397583.js";import{g as Xt,r as te}from"./vendor-react-ece1c85f.js";import{bB as lt,b9 as Yt,d as pt,b6 as qt,B as $e,bC as Kt,O as $t,Q as Jt}from"./index-c62ac197.js";import{_ as er,h as fe}from"./vendor-devex-33a39e11.js";function tr(g){return lt({tag:"svg",attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13.85 4.44L10.57 1.14L10.22 1H2.5L2 1.5V14.5L2.5 15H13.5L14 14.5V4.8L13.85 4.44ZM13 5H10V2L13 5ZM3 14V2H9V5.5L9.5 6H13V14H3Z"},child:[]}]})(g)}function rr(g){return lt({tag:"svg",attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{d:"M7 12V13H6V12H7Z"},child:[]},{tag:"path",attr:{d:"M6 12H5V11H6V12Z"},child:[]},{tag:"path",attr:{d:"M7 11H6V10H7V11Z"},child:[]},{tag:"path",attr:{d:"M6 10H5V9H6V10Z"},child:[]},{tag:"path",attr:{d:"M7 9H6V8H7V9Z"},child:[]},{tag:"path",attr:{d:"M6 8H5V7H6V8Z"},child:[]},{tag:"path",attr:{d:"M7 7H6V6H7V7Z"},child:[]},{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M15 1.5V6.5L14.8496 6.84961L14 7.70996V14.5L13.5 15H2.5L2 14.5V1.5L2.5 1L14.5 1L15 1.5ZM3 14H5V13H6V14H11V7.67969L10.1504 6.83008L10 6.46973V2H7V4.5L6.5 5H6V6H5V5H4.5L4 4.5V2H3V14ZM11 6.26953L11.8496 7.12012L12 7.46973V14H13V7.5L13.1504 7.15039L14 6.29004V2H11V6.26953ZM5 4H6V2H5V4Z"},child:[]}]})(g)}function nr(g){return lt({tag:"svg",attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M13.85 4.44l-3.28-3.3-.35-.14H2.5l-.5.5V7h1V2h6v3.5l.5.5H13v1h1V4.8l-.15-.36zM10 5V2l3 3h-3zM2.5 8l-.5.5v6l.5.5h11l.5-.5v-6l-.5-.5h-11zM13 13v1H3V9h10v4zm-8-1h-.32v1H4v-3h1.06c.75 0 1.13.36 1.13 1a.94.94 0 0 1-.32.72A1.33 1.33 0 0 1 5 12zm-.06-1.45h-.26v.93h.26c.36 0 .54-.16.54-.47 0-.31-.18-.46-.54-.46zM9 12.58a1.48 1.48 0 0 0 .44-1.12c0-1-.53-1.46-1.6-1.46H6.78v3h1.06A1.6 1.6 0 0 0 9 12.58zm-1.55-.13v-1.9h.33a.94.94 0 0 1 .7.25.91.91 0 0 1 .25.67 1 1 0 0 1-.25.72.94.94 0 0 1-.69.26h-.34zm4.45-.61h-.97V13h-.68v-3h1.74v.55h-1.06v.74h.97v.55z"},child:[]}]})(g)}const or=1e3,ir=g=>Math.round(g/or),Je=({children:g})=>G.jsx("span",{className:"text-4xl",children:g}),Et=g=>{const{file:v,children:t}=g,{type:n,name:e,size:r}=v,c=()=>n.split("/")[0]==="image"?G.jsx("img",{className:"upload-file-image",src:URL.createObjectURL(v),alt:`file preview ${e}`}):n==="application/zip"?G.jsx(Je,{children:G.jsx(rr,{})}):n==="application/pdf"?G.jsx(Je,{children:G.jsx(nr,{})}):G.jsx(Je,{children:G.jsx(tr,{})});return G.jsxs("div",{className:"upload-file",children:[G.jsxs("div",{className:"flex",children:[G.jsx("div",{className:"upload-file-thumbnail",children:c()}),G.jsxs("div",{className:"upload-file-info",children:[G.jsx("h6",{className:"upload-file-name",children:e}),G.jsxs("span",{className:"upload-file-size",children:[ir(r)," kb"]})]})]}),t]})};Et.displayName="UploadFileItem";var gt=!1,Fe,tt,rt,ke,je,_t,We,nt,ot,it,Rt,at,st,Mt,Ft;function he(){if(!gt){gt=!0;var g=navigator.userAgent,v=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(g),t=/(Mac OS X)|(Windows)|(Linux)/.exec(g);if(at=/\b(iPhone|iP[ao]d)/.exec(g),st=/\b(iP[ao]d)/.exec(g),it=/Android/i.exec(g),Mt=/FBAN\/\w+;/i.exec(g),Ft=/Mobile/i.exec(g),Rt=!!/Win64/.exec(g),v){Fe=v[1]?parseFloat(v[1]):v[5]?parseFloat(v[5]):NaN,Fe&&document&&document.documentMode&&(Fe=document.documentMode);var n=/(?:Trident\/(\d+.\d+))/.exec(g);_t=n?parseFloat(n[1])+4:Fe,tt=v[2]?parseFloat(v[2]):NaN,rt=v[3]?parseFloat(v[3]):NaN,ke=v[4]?parseFloat(v[4]):NaN,ke?(v=/(?:Chrome\/(\d+\.\d+))/.exec(g),je=v&&v[1]?parseFloat(v[1]):NaN):je=NaN}else Fe=tt=rt=je=ke=NaN;if(t){if(t[1]){var e=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(g);We=e?parseFloat(e[1].replace("_",".")):!0}else We=!1;nt=!!t[2],ot=!!t[3]}else We=nt=ot=!1}}var ct={ie:function(){return he()||Fe},ieCompatibilityMode:function(){return he()||_t>Fe},ie64:function(){return ct.ie()&&Rt},firefox:function(){return he()||tt},opera:function(){return he()||rt},webkit:function(){return he()||ke},safari:function(){return ct.webkit()},chrome:function(){return he()||je},windows:function(){return he()||nt},osx:function(){return he()||We},linux:function(){return he()||ot},iphone:function(){return he()||at},mobile:function(){return he()||at||st||it||Ft},nativeApp:function(){return he()||Mt},android:function(){return he()||it},ipad:function(){return he()||st}},ar=ct,Oe=!!(typeof window<"u"&&window.document&&window.document.createElement),sr={canUseDOM:Oe,canUseWorkers:typeof Worker<"u",canUseEventListeners:Oe&&!!(window.addEventListener||window.attachEvent),canUseViewport:Oe&&!!window.screen,isInWorker:!Oe},cr=sr,Ut=cr,Dt;Ut.canUseDOM&&(Dt=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0);/**
 * Checks if an event is supported in the current execution environment.
 *
 * NOTE: This will not work correctly for non-generic events such as `change`,
 * `reset`, `load`, `error`, and `select`.
 *
 * Borrows from Modernizr.
 *
 * @param {string} eventNameSuffix Event name, e.g. "click".
 * @param {?boolean} capture Check if the capture phase is supported.
 * @return {boolean} True if the event is supported.
 * @internal
 * @license Modernizr 3.0.0pre (Custom Build) | MIT
 */function lr(g,v){if(!Ut.canUseDOM||v&&!("addEventListener"in document))return!1;var t="on"+g,n=t in document;if(!n){var e=document.createElement("div");e.setAttribute(t,"return;"),n=typeof e[t]=="function"}return!n&&Dt&&g==="wheel"&&(n=document.implementation.hasFeature("Events.wheel","3.0")),n}var fr=lr,ur=ar,hr=fr,vt=10,mt=40,wt=800;function Pt(g){var v=0,t=0,n=0,e=0;return"detail"in g&&(t=g.detail),"wheelDelta"in g&&(t=-g.wheelDelta/120),"wheelDeltaY"in g&&(t=-g.wheelDeltaY/120),"wheelDeltaX"in g&&(v=-g.wheelDeltaX/120),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(v=t,t=0),n=v*vt,e=t*vt,"deltaY"in g&&(e=g.deltaY),"deltaX"in g&&(n=g.deltaX),(n||e)&&g.deltaMode&&(g.deltaMode==1?(n*=mt,e*=mt):(n*=wt,e*=wt)),n&&!v&&(v=n<1?-1:1),e&&!t&&(t=e<1?-1:1),{spinX:v,spinY:t,pixelX:n,pixelY:e}}Pt.getEventType=function(){return ur.firefox()?"DOMMouseScroll":hr("wheel")?"wheel":"mousewheel"};var dr=Pt,pr=dr;const gr=Xt(pr);function vr(g,v,t,n,e,r){r===void 0&&(r=0);var c=ze(g,v,r),s=c.width,p=c.height,w=Math.min(s,t),i=Math.min(p,n);return w>i*e?{width:i*e,height:i}:{width:w,height:w/e}}function mr(g){return g.width>g.height?g.width/g.naturalWidth:g.height/g.naturalHeight}function Le(g,v,t,n,e){e===void 0&&(e=0);var r=ze(v.width,v.height,e),c=r.width,s=r.height;return{x:bt(g.x,c,t.width,n),y:bt(g.y,s,t.height,n)}}function bt(g,v,t,n){var e=Math.abs(v*n/2-t/2);return Xe(g,-e,e)}function yt(g,v){return Math.sqrt(Math.pow(g.y-v.y,2)+Math.pow(g.x-v.x,2))}function At(g,v){return Math.atan2(v.y-g.y,v.x-g.x)*180/Math.PI}function wr(g,v,t,n,e,r,c){r===void 0&&(r=0),c===void 0&&(c=!0);var s=c?br:yr,p=ze(v.width,v.height,r),w=ze(v.naturalWidth,v.naturalHeight,r),i={x:s(100,((p.width-t.width/e)/2-g.x/e)/p.width*100),y:s(100,((p.height-t.height/e)/2-g.y/e)/p.height*100),width:s(100,t.width/p.width*100/e),height:s(100,t.height/p.height*100/e)},a=Math.round(s(w.width,i.width*w.width/100)),o=Math.round(s(w.height,i.height*w.height/100)),l=w.width>=w.height*n,m=l?{width:Math.round(o*n),height:o}:{width:a,height:Math.round(a/n)},E=fe(fe({},m),{x:Math.round(s(w.width-m.width,i.x*w.width/100)),y:Math.round(s(w.height-m.height,i.y*w.height/100))});return{croppedAreaPercentages:i,croppedAreaPixels:E}}function br(g,v){return Math.min(g,Math.max(0,v))}function yr(g,v){return v}function Ar(g,v,t,n,e,r){var c=ze(v.width,v.height,t),s=Xe(n.width/c.width*(100/g.width),e,r),p={x:s*c.width/2-n.width/2-c.width*s*(g.x/100),y:s*c.height/2-n.height/2-c.height*s*(g.y/100)};return{crop:p,zoom:s}}function Cr(g,v,t){var n=mr(v);return t.height>t.width?t.height/(g.height*n):t.width/(g.width*n)}function xr(g,v,t,n,e,r){t===void 0&&(t=0);var c=ze(v.naturalWidth,v.naturalHeight,t),s=Xe(Cr(g,v,n),e,r),p=n.height>n.width?n.height/g.height:n.width/g.width,w={x:((c.width-g.width)/2-g.x)*p,y:((c.height-g.height)/2-g.y)*p};return{crop:w,zoom:s}}function Ct(g,v){return{x:(v.x+g.x)/2,y:(v.y+g.y)/2}}function Sr(g){return g*Math.PI/180}function ze(g,v,t){var n=Sr(t);return{width:Math.abs(Math.cos(n)*g)+Math.abs(Math.sin(n)*v),height:Math.abs(Math.sin(n)*g)+Math.abs(Math.cos(n)*v)}}function Xe(g,v,t){return Math.min(Math.max(g,v),t)}function Ne(){for(var g=[],v=0;v<arguments.length;v++)g[v]=arguments[v];return g.filter(function(t){return typeof t=="string"&&t.length>0}).join(" ").trim()}var Er=`.reactEasyCrop_Container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: move;
  display: flex;
  justify-content: center;
  align-items: center;
}

.reactEasyCrop_Image,
.reactEasyCrop_Video {
  will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */
}

.reactEasyCrop_Contain {
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}
.reactEasyCrop_Cover_Horizontal {
  width: 100%;
  height: auto;
}
.reactEasyCrop_Cover_Vertical {
  width: auto;
  height: 100%;
}

.reactEasyCrop_CropArea {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
  box-shadow: 0 0 0 9999em;
  color: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.reactEasyCrop_CropAreaRound {
  border-radius: 50%;
}

.reactEasyCrop_CropAreaGrid::before {
  content: ' ';
  box-sizing: border-box;
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.5);
  top: 0;
  bottom: 0;
  left: 33.33%;
  right: 33.33%;
  border-top: 0;
  border-bottom: 0;
}

.reactEasyCrop_CropAreaGrid::after {
  content: ' ';
  box-sizing: border-box;
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.5);
  top: 33.33%;
  bottom: 33.33%;
  left: 0;
  right: 0;
  border-left: 0;
  border-right: 0;
}
`,_r=1,Rr=3,Mr=1,Fr=function(g){er(v,g);function v(){var t=g!==null&&g.apply(this,arguments)||this;return t.cropperRef=te.createRef(),t.imageRef=te.createRef(),t.videoRef=te.createRef(),t.containerPosition={x:0,y:0},t.containerRef=null,t.styleRef=null,t.containerRect=null,t.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},t.dragStartPosition={x:0,y:0},t.dragStartCrop={x:0,y:0},t.gestureZoomStart=0,t.gestureRotationStart=0,t.isTouching=!1,t.lastPinchDistance=0,t.lastPinchRotation=0,t.rafDragTimeout=null,t.rafPinchTimeout=null,t.wheelTimer=null,t.currentDoc=typeof document<"u"?document:null,t.currentWindow=typeof window<"u"?window:null,t.resizeObserver=null,t.previousCropSize=null,t.isInitialized=!1,t.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},t.initResizeObserver=function(){if(!(typeof window.ResizeObserver>"u"||!t.containerRef)){var n=!0;t.resizeObserver=new window.ResizeObserver(function(e){if(n){n=!1;return}t.computeSizes()}),t.resizeObserver.observe(t.containerRef)}},t.preventZoomSafari=function(n){return n.preventDefault()},t.cleanEvents=function(){t.currentDoc&&(t.currentDoc.removeEventListener("mousemove",t.onMouseMove),t.currentDoc.removeEventListener("mouseup",t.onDragStopped),t.currentDoc.removeEventListener("touchmove",t.onTouchMove),t.currentDoc.removeEventListener("touchend",t.onDragStopped),t.currentDoc.removeEventListener("gesturechange",t.onGestureChange),t.currentDoc.removeEventListener("gestureend",t.onGestureEnd),t.currentDoc.removeEventListener("scroll",t.onScroll))},t.clearScrollEvent=function(){t.containerRef&&t.containerRef.removeEventListener("wheel",t.onWheel),t.wheelTimer&&clearTimeout(t.wheelTimer)},t.onMediaLoad=function(){var n=t.computeSizes();n&&(t.previousCropSize=n,t.emitCropData(),t.setInitialCrop(n),t.isInitialized=!0),t.props.onMediaLoaded&&t.props.onMediaLoaded(t.mediaSize)},t.setInitialCrop=function(n){if(t.props.initialCroppedAreaPercentages){var e=Ar(t.props.initialCroppedAreaPercentages,t.mediaSize,t.props.rotation,n,t.props.minZoom,t.props.maxZoom),r=e.crop,c=e.zoom;t.props.onCropChange(r),t.props.onZoomChange&&t.props.onZoomChange(c)}else if(t.props.initialCroppedAreaPixels){var s=xr(t.props.initialCroppedAreaPixels,t.mediaSize,t.props.rotation,n,t.props.minZoom,t.props.maxZoom),r=s.crop,c=s.zoom;t.props.onCropChange(r),t.props.onZoomChange&&t.props.onZoomChange(c)}},t.computeSizes=function(){var n,e,r,c,s,p,w=t.imageRef.current||t.videoRef.current;if(w&&t.containerRef){t.containerRect=t.containerRef.getBoundingClientRect(),t.saveContainerPosition();var i=t.containerRect.width/t.containerRect.height,a=((n=t.imageRef.current)===null||n===void 0?void 0:n.naturalWidth)||((e=t.videoRef.current)===null||e===void 0?void 0:e.videoWidth)||0,o=((r=t.imageRef.current)===null||r===void 0?void 0:r.naturalHeight)||((c=t.videoRef.current)===null||c===void 0?void 0:c.videoHeight)||0,l=w.offsetWidth<a||w.offsetHeight<o,m=a/o,E=void 0;if(l)switch(t.state.mediaObjectFit){default:case"contain":E=i>m?{width:t.containerRect.height*m,height:t.containerRect.height}:{width:t.containerRect.width,height:t.containerRect.width/m};break;case"horizontal-cover":E={width:t.containerRect.width,height:t.containerRect.width/m};break;case"vertical-cover":E={width:t.containerRect.height*m,height:t.containerRect.height};break}else E={width:w.offsetWidth,height:w.offsetHeight};t.mediaSize=fe(fe({},E),{naturalWidth:a,naturalHeight:o}),t.props.setMediaSize&&t.props.setMediaSize(t.mediaSize);var F=t.props.cropSize?t.props.cropSize:vr(t.mediaSize.width,t.mediaSize.height,t.containerRect.width,t.containerRect.height,t.props.aspect,t.props.rotation);return(((s=t.state.cropSize)===null||s===void 0?void 0:s.height)!==F.height||((p=t.state.cropSize)===null||p===void 0?void 0:p.width)!==F.width)&&t.props.onCropSizeChange&&t.props.onCropSizeChange(F),t.setState({cropSize:F},t.recomputeCropPosition),t.props.setCropSize&&t.props.setCropSize(F),F}},t.saveContainerPosition=function(){if(t.containerRef){var n=t.containerRef.getBoundingClientRect();t.containerPosition={x:n.left,y:n.top}}},t.onMouseDown=function(n){t.currentDoc&&(n.preventDefault(),t.currentDoc.addEventListener("mousemove",t.onMouseMove),t.currentDoc.addEventListener("mouseup",t.onDragStopped),t.saveContainerPosition(),t.onDragStart(v.getMousePoint(n)))},t.onMouseMove=function(n){return t.onDrag(v.getMousePoint(n))},t.onScroll=function(n){t.currentDoc&&(n.preventDefault(),t.saveContainerPosition())},t.onTouchStart=function(n){t.currentDoc&&(t.isTouching=!0,!(t.props.onTouchRequest&&!t.props.onTouchRequest(n))&&(t.currentDoc.addEventListener("touchmove",t.onTouchMove,{passive:!1}),t.currentDoc.addEventListener("touchend",t.onDragStopped),t.saveContainerPosition(),n.touches.length===2?t.onPinchStart(n):n.touches.length===1&&t.onDragStart(v.getTouchPoint(n.touches[0]))))},t.onTouchMove=function(n){n.preventDefault(),n.touches.length===2?t.onPinchMove(n):n.touches.length===1&&t.onDrag(v.getTouchPoint(n.touches[0]))},t.onGestureStart=function(n){t.currentDoc&&(n.preventDefault(),t.currentDoc.addEventListener("gesturechange",t.onGestureChange),t.currentDoc.addEventListener("gestureend",t.onGestureEnd),t.gestureZoomStart=t.props.zoom,t.gestureRotationStart=t.props.rotation)},t.onGestureChange=function(n){if(n.preventDefault(),!t.isTouching){var e=v.getMousePoint(n),r=t.gestureZoomStart-1+n.scale;if(t.setNewZoom(r,e,{shouldUpdatePosition:!0}),t.props.onRotationChange){var c=t.gestureRotationStart+n.rotation;t.props.onRotationChange(c)}}},t.onGestureEnd=function(n){t.cleanEvents()},t.onDragStart=function(n){var e,r,c=n.x,s=n.y;t.dragStartPosition={x:c,y:s},t.dragStartCrop=fe({},t.props.crop),(r=(e=t.props).onInteractionStart)===null||r===void 0||r.call(e)},t.onDrag=function(n){var e=n.x,r=n.y;t.currentWindow&&(t.rafDragTimeout&&t.currentWindow.cancelAnimationFrame(t.rafDragTimeout),t.rafDragTimeout=t.currentWindow.requestAnimationFrame(function(){if(t.state.cropSize&&!(e===void 0||r===void 0)){var c=e-t.dragStartPosition.x,s=r-t.dragStartPosition.y,p={x:t.dragStartCrop.x+c,y:t.dragStartCrop.y+s},w=t.props.restrictPosition?Le(p,t.mediaSize,t.state.cropSize,t.props.zoom,t.props.rotation):p;t.props.onCropChange(w)}}))},t.onDragStopped=function(){var n,e;t.isTouching=!1,t.cleanEvents(),t.emitCropData(),(e=(n=t.props).onInteractionEnd)===null||e===void 0||e.call(n)},t.onWheel=function(n){if(t.currentWindow&&!(t.props.onWheelRequest&&!t.props.onWheelRequest(n))){n.preventDefault();var e=v.getMousePoint(n),r=gr(n).pixelY,c=t.props.zoom-r*t.props.zoomSpeed/200;t.setNewZoom(c,e,{shouldUpdatePosition:!0}),t.state.hasWheelJustStarted||t.setState({hasWheelJustStarted:!0},function(){var s,p;return(p=(s=t.props).onInteractionStart)===null||p===void 0?void 0:p.call(s)}),t.wheelTimer&&clearTimeout(t.wheelTimer),t.wheelTimer=t.currentWindow.setTimeout(function(){return t.setState({hasWheelJustStarted:!1},function(){var s,p;return(p=(s=t.props).onInteractionEnd)===null||p===void 0?void 0:p.call(s)})},250)}},t.getPointOnContainer=function(n,e){var r=n.x,c=n.y;if(!t.containerRect)throw new Error("The Cropper is not mounted");return{x:t.containerRect.width/2-(r-e.x),y:t.containerRect.height/2-(c-e.y)}},t.getPointOnMedia=function(n){var e=n.x,r=n.y,c=t.props,s=c.crop,p=c.zoom;return{x:(e+s.x)/p,y:(r+s.y)/p}},t.setNewZoom=function(n,e,r){var c=r===void 0?{}:r,s=c.shouldUpdatePosition,p=s===void 0?!0:s;if(!(!t.state.cropSize||!t.props.onZoomChange)){var w=Xe(n,t.props.minZoom,t.props.maxZoom);if(p){var i=t.getPointOnContainer(e,t.containerPosition),a=t.getPointOnMedia(i),o={x:a.x*w-i.x,y:a.y*w-i.y},l=t.props.restrictPosition?Le(o,t.mediaSize,t.state.cropSize,w,t.props.rotation):o;t.props.onCropChange(l)}t.props.onZoomChange(w)}},t.getCropData=function(){if(!t.state.cropSize)return null;var n=t.props.restrictPosition?Le(t.props.crop,t.mediaSize,t.state.cropSize,t.props.zoom,t.props.rotation):t.props.crop;return wr(n,t.mediaSize,t.state.cropSize,t.getAspect(),t.props.zoom,t.props.rotation,t.props.restrictPosition)},t.emitCropData=function(){var n=t.getCropData();if(n){var e=n.croppedAreaPercentages,r=n.croppedAreaPixels;t.props.onCropComplete&&t.props.onCropComplete(e,r),t.props.onCropAreaChange&&t.props.onCropAreaChange(e,r)}},t.emitCropAreaChange=function(){var n=t.getCropData();if(n){var e=n.croppedAreaPercentages,r=n.croppedAreaPixels;t.props.onCropAreaChange&&t.props.onCropAreaChange(e,r)}},t.recomputeCropPosition=function(){var n,e;if(t.state.cropSize){var r=t.props.crop;if(t.isInitialized&&(!((n=t.previousCropSize)===null||n===void 0)&&n.width)&&(!((e=t.previousCropSize)===null||e===void 0)&&e.height)){var c=Math.abs(t.previousCropSize.width-t.state.cropSize.width)>1e-6||Math.abs(t.previousCropSize.height-t.state.cropSize.height)>1e-6;if(c){var s=t.state.cropSize.width/t.previousCropSize.width,p=t.state.cropSize.height/t.previousCropSize.height;r={x:t.props.crop.x*s,y:t.props.crop.y*p}}}var w=t.props.restrictPosition?Le(r,t.mediaSize,t.state.cropSize,t.props.zoom,t.props.rotation):r;t.previousCropSize=t.state.cropSize,t.props.onCropChange(w),t.emitCropData()}},t.onKeyDown=function(n){var e,r,c=t.props,s=c.crop,p=c.onCropChange,w=c.keyboardStep,i=c.zoom,a=c.rotation,o=w;if(t.state.cropSize){n.shiftKey&&(o*=.2);var l=fe({},s);switch(n.key){case"ArrowUp":l.y-=o,n.preventDefault();break;case"ArrowDown":l.y+=o,n.preventDefault();break;case"ArrowLeft":l.x-=o,n.preventDefault();break;case"ArrowRight":l.x+=o,n.preventDefault();break;default:return}t.props.restrictPosition&&(l=Le(l,t.mediaSize,t.state.cropSize,i,a)),n.repeat||(r=(e=t.props).onInteractionStart)===null||r===void 0||r.call(e),p(l)}},t.onKeyUp=function(n){var e,r;switch(n.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":n.preventDefault();break;default:return}t.emitCropData(),(r=(e=t.props).onInteractionEnd)===null||r===void 0||r.call(e)},t}return v.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),typeof window.ResizeObserver>"u"&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.currentDoc.addEventListener("scroll",this.onScroll),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=Er,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},v.prototype.componentWillUnmount=function(){var t,n;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((n=this.styleRef.parentNode)===null||n===void 0||n.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},v.prototype.componentDidUpdate=function(t){var n,e,r,c,s,p,w,i,a;t.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):t.aspect!==this.props.aspect?this.computeSizes():t.objectFit!==this.props.objectFit?this.computeSizes():t.zoom!==this.props.zoom?this.recomputeCropPosition():((n=t.cropSize)===null||n===void 0?void 0:n.height)!==((e=this.props.cropSize)===null||e===void 0?void 0:e.height)||((r=t.cropSize)===null||r===void 0?void 0:r.width)!==((c=this.props.cropSize)===null||c===void 0?void 0:c.width)?this.computeSizes():(((s=t.crop)===null||s===void 0?void 0:s.x)!==((p=this.props.crop)===null||p===void 0?void 0:p.x)||((w=t.crop)===null||w===void 0?void 0:w.y)!==((i=this.props.crop)===null||i===void 0?void 0:i.y))&&this.emitCropAreaChange(),t.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),t.video!==this.props.video&&((a=this.videoRef.current)===null||a===void 0||a.load());var o=this.getObjectFit();o!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:o},this.computeSizes)},v.prototype.getAspect=function(){var t=this.props,n=t.cropSize,e=t.aspect;return n?n.width/n.height:e},v.prototype.getObjectFit=function(){var t,n,e,r;if(this.props.objectFit==="cover"){var c=this.imageRef.current||this.videoRef.current;if(c&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var s=this.containerRect.width/this.containerRect.height,p=((t=this.imageRef.current)===null||t===void 0?void 0:t.naturalWidth)||((n=this.videoRef.current)===null||n===void 0?void 0:n.videoWidth)||0,w=((e=this.imageRef.current)===null||e===void 0?void 0:e.naturalHeight)||((r=this.videoRef.current)===null||r===void 0?void 0:r.videoHeight)||0,i=p/w;return i<s?"horizontal-cover":"vertical-cover"}return"horizontal-cover"}return this.props.objectFit},v.prototype.onPinchStart=function(t){var n=v.getTouchPoint(t.touches[0]),e=v.getTouchPoint(t.touches[1]);this.lastPinchDistance=yt(n,e),this.lastPinchRotation=At(n,e),this.onDragStart(Ct(n,e))},v.prototype.onPinchMove=function(t){var n=this;if(!(!this.currentDoc||!this.currentWindow)){var e=v.getTouchPoint(t.touches[0]),r=v.getTouchPoint(t.touches[1]),c=Ct(e,r);this.onDrag(c),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var s=yt(e,r),p=n.props.zoom*(s/n.lastPinchDistance);n.setNewZoom(p,c,{shouldUpdatePosition:!1}),n.lastPinchDistance=s;var w=At(e,r),i=n.props.rotation+(w-n.lastPinchRotation);n.props.onRotationChange&&n.props.onRotationChange(i),n.lastPinchRotation=w})}},v.prototype.render=function(){var t=this,n,e=this.props,r=e.image,c=e.video,s=e.mediaProps,p=e.cropperProps,w=e.transform,i=e.crop,a=i.x,o=i.y,l=e.rotation,m=e.zoom,E=e.cropShape,F=e.showGrid,C=e.roundCropAreaPixels,H=e.style,z=H.containerStyle,U=H.cropAreaStyle,I=H.mediaStyle,b=e.classes,P=b.containerClassName,h=b.cropAreaClassName,u=b.mediaClassName,y=(n=this.state.mediaObjectFit)!==null&&n!==void 0?n:this.getObjectFit();return te.createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(S){return t.containerRef=S},"data-testid":"container",style:z,className:Ne("reactEasyCrop_Container",P)},r?te.createElement("img",fe({alt:"",className:Ne("reactEasyCrop_Image",y==="contain"&&"reactEasyCrop_Contain",y==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",y==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",u)},s,{src:r,ref:this.imageRef,style:fe(fe({},I),{transform:w||"translate(".concat(a,"px, ").concat(o,"px) rotate(").concat(l,"deg) scale(").concat(m,")")}),onLoad:this.onMediaLoad})):c&&te.createElement("video",fe({autoPlay:!0,playsInline:!0,loop:!0,muted:!0,className:Ne("reactEasyCrop_Video",y==="contain"&&"reactEasyCrop_Contain",y==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",y==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",u)},s,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:fe(fe({},I),{transform:w||"translate(".concat(a,"px, ").concat(o,"px) rotate(").concat(l,"deg) scale(").concat(m,")")}),controls:!1}),(Array.isArray(c)?c:[{src:c}]).map(function(x){return te.createElement("source",fe({key:x.src},x))})),this.state.cropSize&&te.createElement("div",fe({ref:this.cropperRef,style:fe(fe({},U),{width:C?Math.round(this.state.cropSize.width):this.state.cropSize.width,height:C?Math.round(this.state.cropSize.height):this.state.cropSize.height}),tabIndex:0,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,"data-testid":"cropper",className:Ne("reactEasyCrop_CropArea",E==="round"&&"reactEasyCrop_CropAreaRound",F&&"reactEasyCrop_CropAreaGrid",h)},p)))},v.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:Rr,minZoom:_r,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},cropperProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0,keyboardStep:Mr},v.getMousePoint=function(t){return{x:Number(t.clientX),y:Number(t.clientY)}},v.getTouchPoint=function(t){return{x:Number(t.clientX),y:Number(t.clientY)}},v}(te.Component);function Ur(g,v){return new Promise((t,n)=>{const e=new Image;e.src=g,e.onload=()=>{const r=document.createElement("canvas");r.width=v.width,r.height=v.height;const c=r.getContext("2d");if(!c)return n(new Error("Canvas context error"));c.drawImage(e,v.x,v.y,v.width,v.height,0,0,v.width,v.height),r.toBlob(s=>{if(!s)return n(new Error("Crop failed"));t(s)},"image/jpeg")},e.onerror=()=>n(new Error("Image load error"))})}function Dr(g,v){return v.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if(n!=="default"&&!(n in g)){var e=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(g,n,e.get?e:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(g)}function zt(g,v){return new Promise(function(t,n){let e;return Pr(g).then(function(r){try{return e=r,t(new Blob([v.slice(0,2),e,v.slice(2)],{type:"image/jpeg"}))}catch(c){return n(c)}},n)})}const Pr=g=>new Promise((v,t)=>{const n=new FileReader;n.addEventListener("load",({target:{result:e}})=>{const r=new DataView(e);let c=0;if(r.getUint16(c)!==65496)return t("not a valid JPEG");for(c+=2;;){const s=r.getUint16(c);if(s===65498)break;const p=r.getUint16(c+2);if(s===65505&&r.getUint32(c+4)===1165519206){const w=c+10;let i;switch(r.getUint16(w)){case 18761:i=!0;break;case 19789:i=!1;break;default:return t("TIFF header contains invalid endian")}if(r.getUint16(w+2,i)!==42)return t("TIFF header contains invalid version");const a=r.getUint32(w+4,i),o=w+a+2+12*r.getUint16(w+a,i);for(let l=w+a+2;l<o;l+=12)if(r.getUint16(l,i)==274){if(r.getUint16(l+2,i)!==3)return t("Orientation data type is invalid");if(r.getUint32(l+4,i)!==1)return t("Orientation data count is invalid");r.setUint16(l+8,1,i);break}return v(e.slice(c,c+2+p))}c+=2+p}return v(new Blob)}),n.readAsArrayBuffer(g)});var Ze={},zr={get exports(){return Ze},set exports(g){Ze=g}};(function(g){var v,t,n={};zr.exports=n,n.parse=function(e,r){for(var c=n.bin.readUshort,s=n.bin.readUint,p=0,w={},i=new Uint8Array(e),a=i.length-4;s(i,a)!=101010256;)a--;p=a,p+=4;var o=c(i,p+=4);c(i,p+=2);var l=s(i,p+=2),m=s(i,p+=4);p+=4,p=m;for(var E=0;E<o;E++){s(i,p),p+=4,p+=4,p+=4,s(i,p+=4),l=s(i,p+=4);var F=s(i,p+=4),C=c(i,p+=4),H=c(i,p+2),z=c(i,p+4);p+=6;var U=s(i,p+=8);p+=4,p+=C+H+z,n._readLocal(i,U,w,l,F,r)}return w},n._readLocal=function(e,r,c,s,p,w){var i=n.bin.readUshort,a=n.bin.readUint;a(e,r),i(e,r+=4),i(e,r+=2);var o=i(e,r+=2);a(e,r+=2),a(e,r+=4),r+=4;var l=i(e,r+=8),m=i(e,r+=2);r+=2;var E=n.bin.readUTF8(e,r,l);if(r+=l,r+=m,w)c[E]={size:p,csize:s};else{var F=new Uint8Array(e.buffer,r);if(o==0)c[E]=new Uint8Array(F.buffer.slice(r,r+s));else{if(o!=8)throw"unknown compression method: "+o;var C=new Uint8Array(p);n.inflateRaw(F,C),c[E]=C}}},n.inflateRaw=function(e,r){return n.F.inflate(e,r)},n.inflate=function(e,r){return e[0],e[1],n.inflateRaw(new Uint8Array(e.buffer,e.byteOffset+2,e.length-6),r)},n.deflate=function(e,r){r==null&&(r={level:6});var c=0,s=new Uint8Array(50+Math.floor(1.1*e.length));s[c]=120,s[c+1]=156,c+=2,c=n.F.deflateRaw(e,s,c,r.level);var p=n.adler(e,0,e.length);return s[c+0]=p>>>24&255,s[c+1]=p>>>16&255,s[c+2]=p>>>8&255,s[c+3]=p>>>0&255,new Uint8Array(s.buffer,0,c+4)},n.deflateRaw=function(e,r){r==null&&(r={level:6});var c=new Uint8Array(50+Math.floor(1.1*e.length)),s=n.F.deflateRaw(e,c,s,r.level);return new Uint8Array(c.buffer,0,s)},n.encode=function(e,r){r==null&&(r=!1);var c=0,s=n.bin.writeUint,p=n.bin.writeUshort,w={};for(var i in e){var a=!n._noNeed(i)&&!r,o=e[i],l=n.crc.crc(o,0,o.length);w[i]={cpr:a,usize:o.length,crc:l,file:a?n.deflateRaw(o):o}}for(var i in w)c+=w[i].file.length+30+46+2*n.bin.sizeUTF8(i);c+=22;var m=new Uint8Array(c),E=0,F=[];for(var i in w){var C=w[i];F.push(E),E=n._writeHeader(m,E,i,C,0)}var H=0,z=E;for(var i in w)C=w[i],F.push(E),E=n._writeHeader(m,E,i,C,1,F[H++]);var U=E-z;return s(m,E,101010256),E+=4,p(m,E+=4,H),p(m,E+=2,H),s(m,E+=2,U),s(m,E+=4,z),E+=4,E+=2,m.buffer},n._noNeed=function(e){var r=e.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(r)!=-1},n._writeHeader=function(e,r,c,s,p,w){var i=n.bin.writeUint,a=n.bin.writeUshort,o=s.file;return i(e,r,p==0?67324752:33639248),r+=4,p==1&&(r+=2),a(e,r,20),a(e,r+=2,0),a(e,r+=2,s.cpr?8:0),i(e,r+=2,0),i(e,r+=4,s.crc),i(e,r+=4,o.length),i(e,r+=4,s.usize),a(e,r+=4,n.bin.sizeUTF8(c)),a(e,r+=2,0),r+=2,p==1&&(r+=2,r+=2,i(e,r+=6,w),r+=4),r+=n.bin.writeUTF8(e,r,c),p==0&&(e.set(o,r),r+=o.length),r},n.crc={table:function(){for(var e=new Uint32Array(256),r=0;r<256;r++){for(var c=r,s=0;s<8;s++)1&c?c=3988292384^c>>>1:c>>>=1;e[r]=c}return e}(),update:function(e,r,c,s){for(var p=0;p<s;p++)e=n.crc.table[255&(e^r[c+p])]^e>>>8;return e},crc:function(e,r,c){return 4294967295^n.crc.update(4294967295,e,r,c)}},n.adler=function(e,r,c){for(var s=1,p=0,w=r,i=r+c;w<i;){for(var a=Math.min(w+5552,i);w<a;)p+=s+=e[w++];s%=65521,p%=65521}return p<<16|s},n.bin={readUshort:function(e,r){return e[r]|e[r+1]<<8},writeUshort:function(e,r,c){e[r]=255&c,e[r+1]=c>>8&255},readUint:function(e,r){return 16777216*e[r+3]+(e[r+2]<<16|e[r+1]<<8|e[r])},writeUint:function(e,r,c){e[r]=255&c,e[r+1]=c>>8&255,e[r+2]=c>>16&255,e[r+3]=c>>24&255},readASCII:function(e,r,c){for(var s="",p=0;p<c;p++)s+=String.fromCharCode(e[r+p]);return s},writeASCII:function(e,r,c){for(var s=0;s<c.length;s++)e[r+s]=c.charCodeAt(s)},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(e,r,c){for(var s,p="",w=0;w<c;w++)p+="%"+n.bin.pad(e[r+w].toString(16));try{s=decodeURIComponent(p)}catch{return n.bin.readASCII(e,r,c)}return s},writeUTF8:function(e,r,c){for(var s=c.length,p=0,w=0;w<s;w++){var i=c.charCodeAt(w);if(!(4294967168&i))e[r+p]=i,p++;else if(!(4294965248&i))e[r+p]=192|i>>6,e[r+p+1]=128|i>>0&63,p+=2;else if(!(4294901760&i))e[r+p]=224|i>>12,e[r+p+1]=128|i>>6&63,e[r+p+2]=128|i>>0&63,p+=3;else{if(4292870144&i)throw"e";e[r+p]=240|i>>18,e[r+p+1]=128|i>>12&63,e[r+p+2]=128|i>>6&63,e[r+p+3]=128|i>>0&63,p+=4}}return p},sizeUTF8:function(e){for(var r=e.length,c=0,s=0;s<r;s++){var p=e.charCodeAt(s);if(!(4294967168&p))c++;else if(!(4294965248&p))c+=2;else if(!(4294901760&p))c+=3;else{if(4292870144&p)throw"e";c+=4}}return c}},n.F={},n.F.deflateRaw=function(e,r,c,s){var p=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][s],w=n.F.U,i=n.F._goodIndex;n.F._hash;var a=n.F._putsE,o=0,l=c<<3,m=0,E=e.length;if(s==0){for(;o<E;)a(r,l,o+(x=Math.min(65535,E-o))==E?1:0),l=n.F._copyExact(e,o,x,r,l+8),o+=x;return l>>>3}var F=w.lits,C=w.strt,H=w.prev,z=0,U=0,I=0,b=0,P=0,h=0;for(E>2&&(C[h=n.F._hash(e,0)]=0),o=0;o<E;o++){if(P=h,o+1<E-2){h=n.F._hash(e,o+1);var u=o+1&32767;H[u]=C[h],C[h]=u}if(m<=o){(z>14e3||U>26697)&&E-o>100&&(m<o&&(F[z]=o-m,z+=2,m=o),l=n.F._writeBlock(o==E-1||m==E?1:0,F,z,b,e,I,o-I,r,l),z=U=b=0,I=o);var y=0;o<E-2&&(y=n.F._bestMatch(e,o,H,P,Math.min(p[2],E-o),p[3]));var x=y>>>16,S=65535&y;if(y!=0){S=65535&y;var _=i(x=y>>>16,w.of0);w.lhst[257+_]++;var A=i(S,w.df0);w.dhst[A]++,b+=w.exb[_]+w.dxb[A],F[z]=x<<23|o-m,F[z+1]=S<<16|_<<8|A,z+=2,m=o+x}else w.lhst[e[o]]++;U++}}for(I==o&&e.length!=0||(m<o&&(F[z]=o-m,z+=2,m=o),l=n.F._writeBlock(1,F,z,b,e,I,o-I,r,l),z=0,U=0,z=U=b=0,I=o);7&l;)l++;return l>>>3},n.F._bestMatch=function(e,r,c,s,p,w){var i=32767&r,a=c[i],o=i-a+32768&32767;if(a==i||s!=n.F._hash(e,r-o))return 0;for(var l=0,m=0,E=Math.min(32767,r);o<=E&&--w!=0&&a!=i;){if(l==0||e[r+l]==e[r+l-o]){var F=n.F._howLong(e,r,o);if(F>l){if(m=o,(l=F)>=p)break;o+2<F&&(F=o+2);for(var C=0,H=0;H<F-2;H++){var z=r-o+H+32768&32767,U=z-c[z]+32768&32767;U>C&&(C=U,a=z)}}}o+=(i=a)-(a=c[i])+32768&32767}return l<<16|m},n.F._howLong=function(e,r,c){if(e[r]!=e[r-c]||e[r+1]!=e[r+1-c]||e[r+2]!=e[r+2-c])return 0;var s=r,p=Math.min(e.length,r+258);for(r+=3;r<p&&e[r]==e[r-c];)r++;return r-s},n.F._hash=function(e,r){return(e[r]<<8|e[r+1])+(e[r+2]<<4)&65535},n.saved=0,n.F._writeBlock=function(e,r,c,s,p,w,i,a,o){var l,m,E,F,C,H,z,U,I,b=n.F.U,P=n.F._putsF,h=n.F._putsE;b.lhst[256]++,m=(l=n.F.getTrees())[0],E=l[1],F=l[2],C=l[3],H=l[4],z=l[5],U=l[6],I=l[7];var u=32+(o+3&7?8-(o+3&7):0)+(i<<3),y=s+n.F.contSize(b.fltree,b.lhst)+n.F.contSize(b.fdtree,b.dhst),x=s+n.F.contSize(b.ltree,b.lhst)+n.F.contSize(b.dtree,b.dhst);x+=14+3*z+n.F.contSize(b.itree,b.ihst)+(2*b.ihst[16]+3*b.ihst[17]+7*b.ihst[18]);for(var S=0;S<286;S++)b.lhst[S]=0;for(S=0;S<30;S++)b.dhst[S]=0;for(S=0;S<19;S++)b.ihst[S]=0;var _=u<y&&u<x?0:y<x?1:2;if(P(a,o,e),P(a,o+1,_),o+=3,_==0){for(;7&o;)o++;o=n.F._copyExact(p,w,i,a,o)}else{var A,M;if(_==1&&(A=b.fltree,M=b.fdtree),_==2){n.F.makeCodes(b.ltree,m),n.F.revCodes(b.ltree,m),n.F.makeCodes(b.dtree,E),n.F.revCodes(b.dtree,E),n.F.makeCodes(b.itree,F),n.F.revCodes(b.itree,F),A=b.ltree,M=b.dtree,h(a,o,C-257),h(a,o+=5,H-1),h(a,o+=5,z-4),o+=4;for(var d=0;d<z;d++)h(a,o+3*d,b.itree[1+(b.ordr[d]<<1)]);o+=3*z,o=n.F._codeTiny(U,b.itree,a,o),o=n.F._codeTiny(I,b.itree,a,o)}for(var f=w,T=0;T<c;T+=2){for(var R=r[T],L=R>>>23,j=f+(8388607&R);f<j;)o=n.F._writeLit(p[f++],A,a,o);if(L!=0){var N=r[T+1],k=N>>16,O=N>>8&255,D=255&N;h(a,o=n.F._writeLit(257+O,A,a,o),L-b.of0[O]),o+=b.exb[O],P(a,o=n.F._writeLit(D,M,a,o),k-b.df0[D]),o+=b.dxb[D],f+=L}}o=n.F._writeLit(256,A,a,o)}return o},n.F._copyExact=function(e,r,c,s,p){var w=p>>>3;return s[w]=c,s[w+1]=c>>>8,s[w+2]=255-s[w],s[w+3]=255-s[w+1],w+=4,s.set(new Uint8Array(e.buffer,r,c),w),p+(c+4<<3)},n.F.getTrees=function(){for(var e=n.F.U,r=n.F._hufTree(e.lhst,e.ltree,15),c=n.F._hufTree(e.dhst,e.dtree,15),s=[],p=n.F._lenCodes(e.ltree,s),w=[],i=n.F._lenCodes(e.dtree,w),a=0;a<s.length;a+=2)e.ihst[s[a]]++;for(a=0;a<w.length;a+=2)e.ihst[w[a]]++;for(var o=n.F._hufTree(e.ihst,e.itree,7),l=19;l>4&&e.itree[1+(e.ordr[l-1]<<1)]==0;)l--;return[r,c,o,p,i,l,s,w]},n.F.getSecond=function(e){for(var r=[],c=0;c<e.length;c+=2)r.push(e[c+1]);return r},n.F.nonZero=function(e){for(var r="",c=0;c<e.length;c+=2)e[c+1]!=0&&(r+=(c>>1)+",");return r},n.F.contSize=function(e,r){for(var c=0,s=0;s<r.length;s++)c+=r[s]*e[1+(s<<1)];return c},n.F._codeTiny=function(e,r,c,s){for(var p=0;p<e.length;p+=2){var w=e[p],i=e[p+1];s=n.F._writeLit(w,r,c,s);var a=w==16?2:w==17?3:7;w>15&&(n.F._putsE(c,s,i,a),s+=a)}return s},n.F._lenCodes=function(e,r){for(var c=e.length;c!=2&&e[c-1]==0;)c-=2;for(var s=0;s<c;s+=2){var p=e[s+1],w=s+3<c?e[s+3]:-1,i=s+5<c?e[s+5]:-1,a=s==0?-1:e[s-1];if(p==0&&w==p&&i==p){for(var o=s+5;o+2<c&&e[o+2]==p;)o+=2;(l=Math.min(o+1-s>>>1,138))<11?r.push(17,l-3):r.push(18,l-11),s+=2*l-2}else if(p==a&&w==p&&i==p){for(o=s+5;o+2<c&&e[o+2]==p;)o+=2;var l=Math.min(o+1-s>>>1,6);r.push(16,l-3),s+=2*l-2}else r.push(p,0)}return c>>>1},n.F._hufTree=function(e,r,c){var s=[],p=e.length,w=r.length,i=0;for(i=0;i<w;i+=2)r[i]=0,r[i+1]=0;for(i=0;i<p;i++)e[i]!=0&&s.push({lit:i,f:e[i]});var a=s.length,o=s.slice(0);if(a==0)return 0;if(a==1){var l=s[0].lit;return o=l==0?1:0,r[1+(l<<1)]=1,r[1+(o<<1)]=1,1}s.sort(function(U,I){return U.f-I.f});var m=s[0],E=s[1],F=0,C=1,H=2;for(s[0]={lit:-1,f:m.f+E.f,l:m,r:E,d:0};C!=a-1;)m=F!=C&&(H==a||s[F].f<s[H].f)?s[F++]:s[H++],E=F!=C&&(H==a||s[F].f<s[H].f)?s[F++]:s[H++],s[C++]={lit:-1,f:m.f+E.f,l:m,r:E};var z=n.F.setDepth(s[C-1],0);for(z>c&&(n.F.restrictDepth(o,c,z),z=c),i=0;i<a;i++)r[1+(o[i].lit<<1)]=o[i].d;return z},n.F.setDepth=function(e,r){return e.lit!=-1?(e.d=r,r):Math.max(n.F.setDepth(e.l,r+1),n.F.setDepth(e.r,r+1))},n.F.restrictDepth=function(e,r,c){var s=0,p=1<<c-r,w=0;for(e.sort(function(a,o){return o.d==a.d?a.f-o.f:o.d-a.d}),s=0;s<e.length&&e[s].d>r;s++){var i=e[s].d;e[s].d=r,w+=p-(1<<c-i)}for(w>>>=c-r;w>0;)(i=e[s].d)<r?(e[s].d++,w-=1<<r-i-1):s++;for(;s>=0;s--)e[s].d==r&&w<0&&(e[s].d--,w++);w!=0&&console.log("debt left")},n.F._goodIndex=function(e,r){var c=0;return r[16|c]<=e&&(c|=16),r[8|c]<=e&&(c|=8),r[4|c]<=e&&(c|=4),r[2|c]<=e&&(c|=2),r[1|c]<=e&&(c|=1),c},n.F._writeLit=function(e,r,c,s){return n.F._putsF(c,s,r[e<<1]),s+r[1+(e<<1)]},n.F.inflate=function(e,r){var c=Uint8Array;if(e[0]==3&&e[1]==0)return r||new c(0);var s=n.F,p=s._bitsF,w=s._bitsE,i=s._decodeTiny,a=s.makeCodes,o=s.codes2map,l=s._get17,m=s.U,E=r==null;E&&(r=new c(e.length>>>2<<3));for(var F,C,H=0,z=0,U=0,I=0,b=0,P=0,h=0,u=0,y=0;H==0;)if(H=p(e,y,1),z=p(e,y+1,2),y+=3,z!=0){if(E&&(r=n.F._check(r,u+(1<<17))),z==1&&(F=m.flmap,C=m.fdmap,P=511,h=31),z==2){U=w(e,y,5)+257,I=w(e,y+5,5)+1,b=w(e,y+10,4)+4,y+=14;for(var x=0;x<38;x+=2)m.itree[x]=0,m.itree[x+1]=0;var S=1;for(x=0;x<b;x++){var _=w(e,y+3*x,3);m.itree[1+(m.ordr[x]<<1)]=_,_>S&&(S=_)}y+=3*b,a(m.itree,S),o(m.itree,S,m.imap),F=m.lmap,C=m.dmap,y=i(m.imap,(1<<S)-1,U+I,e,y,m.ttree);var A=s._copyOut(m.ttree,0,U,m.ltree);P=(1<<A)-1;var M=s._copyOut(m.ttree,U,I,m.dtree);h=(1<<M)-1,a(m.ltree,A),o(m.ltree,A,F),a(m.dtree,M),o(m.dtree,M,C)}for(;;){var d=F[l(e,y)&P];y+=15&d;var f=d>>>4;if(!(f>>>8))r[u++]=f;else{if(f==256)break;var T=u+f-254;if(f>264){var R=m.ldef[f-257];T=u+(R>>>3)+w(e,y,7&R),y+=7&R}var L=C[l(e,y)&h];y+=15&L;var j=L>>>4,N=m.ddef[j],k=(N>>>4)+p(e,y,15&N);for(y+=15&N,E&&(r=n.F._check(r,u+(1<<17)));u<T;)r[u]=r[u++-k],r[u]=r[u++-k],r[u]=r[u++-k],r[u]=r[u++-k];u=T}}}else{7&y&&(y+=8-(7&y));var O=4+(y>>>3),D=e[O-4]|e[O-3]<<8;E&&(r=n.F._check(r,u+D)),r.set(new c(e.buffer,e.byteOffset+O,D),u),y=O+D<<3,u+=D}return r.length==u?r:r.slice(0,u)},n.F._check=function(e,r){var c=e.length;if(r<=c)return e;var s=new Uint8Array(Math.max(c<<1,r));return s.set(e,0),s},n.F._decodeTiny=function(e,r,c,s,p,w){for(var i=n.F._bitsE,a=n.F._get17,o=0;o<c;){var l=e[a(s,p)&r];p+=15&l;var m=l>>>4;if(m<=15)w[o]=m,o++;else{var E=0,F=0;m==16?(F=3+i(s,p,2),p+=2,E=w[o-1]):m==17?(F=3+i(s,p,3),p+=3):m==18&&(F=11+i(s,p,7),p+=7);for(var C=o+F;o<C;)w[o]=E,o++}}return p},n.F._copyOut=function(e,r,c,s){for(var p=0,w=0,i=s.length>>>1;w<c;){var a=e[w+r];s[w<<1]=0,s[1+(w<<1)]=a,a>p&&(p=a),w++}for(;w<i;)s[w<<1]=0,s[1+(w<<1)]=0,w++;return p},n.F.makeCodes=function(e,r){for(var c,s,p,w,i=n.F.U,a=e.length,o=i.bl_count,l=0;l<=r;l++)o[l]=0;for(l=1;l<a;l+=2)o[e[l]]++;var m=i.next_code;for(c=0,o[0]=0,s=1;s<=r;s++)c=c+o[s-1]<<1,m[s]=c;for(p=0;p<a;p+=2)(w=e[p+1])!=0&&(e[p]=m[w],m[w]++)},n.F.codes2map=function(e,r,c){for(var s=e.length,p=n.F.U.rev15,w=0;w<s;w+=2)if(e[w+1]!=0)for(var i=w>>1,a=e[w+1],o=i<<4|a,l=r-a,m=e[w]<<l,E=m+(1<<l);m!=E;)c[p[m]>>>15-r]=o,m++},n.F.revCodes=function(e,r){for(var c=n.F.U.rev15,s=15-r,p=0;p<e.length;p+=2){var w=e[p]<<r-e[p+1];e[p]=c[w]>>>s}},n.F._putsE=function(e,r,c){c<<=7&r;var s=r>>>3;e[s]|=c,e[s+1]|=c>>>8},n.F._putsF=function(e,r,c){c<<=7&r;var s=r>>>3;e[s]|=c,e[s+1]|=c>>>8,e[s+2]|=c>>>16},n.F._bitsE=function(e,r,c){return(e[r>>>3]|e[1+(r>>>3)]<<8)>>>(7&r)&(1<<c)-1},n.F._bitsF=function(e,r,c){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)&(1<<c)-1},n.F._get17=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)},n.F._get25=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16|e[3+(r>>>3)]<<24)>>>(7&r)},n.F.U=(v=Uint16Array,t=Uint32Array,{next_code:new v(16),bl_count:new v(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new v(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new t(32),flmap:new v(512),fltree:[],fdmap:new v(32),fdtree:[],lmap:new v(32768),ltree:[],ttree:[],dmap:new v(32768),dtree:[],imap:new v(512),itree:[],rev15:new v(32768),lhst:new t(286),dhst:new t(30),ihst:new t(19),lits:new t(15e3),strt:new v(65536),prev:new v(32768)}),function(){for(var e=n.F.U,r=0;r<32768;r++){var c=r;c=(4278255360&(c=(4042322160&(c=(3435973836&(c=(2863311530&c)>>>1|(1431655765&c)<<1))>>>2|(858993459&c)<<2))>>>4|(252645135&c)<<4))>>>8|(16711935&c)<<8,e.rev15[r]=(c>>>16|c<<16)>>>17}function s(p,w,i){for(;w--!=0;)p.push(0,i)}for(r=0;r<32;r++)e.ldef[r]=e.of0[r]<<3|e.exb[r],e.ddef[r]=e.df0[r]<<4|e.dxb[r];s(e.fltree,144,8),s(e.fltree,112,9),s(e.fltree,24,7),s(e.fltree,8,8),n.F.makeCodes(e.fltree,9),n.F.codes2map(e.fltree,9,e.flmap),n.F.revCodes(e.fltree,9),s(e.fdtree,32,5),n.F.makeCodes(e.fdtree,5),n.F.codes2map(e.fdtree,5,e.fdmap),n.F.revCodes(e.fdtree,5),s(e.itree,19,0),s(e.ltree,286,0),s(e.dtree,30,0),s(e.ttree,320,0)}()})();var Ir=Dr({__proto__:null,default:Ze},[Ze]);const we=function(){var g={nextZero(i,a){for(;i[a]!=0;)a++;return a},readUshort:(i,a)=>i[a]<<8|i[a+1],writeUshort(i,a,o){i[a]=o>>8&255,i[a+1]=255&o},readUint:(i,a)=>16777216*i[a]+(i[a+1]<<16|i[a+2]<<8|i[a+3]),writeUint(i,a,o){i[a]=o>>24&255,i[a+1]=o>>16&255,i[a+2]=o>>8&255,i[a+3]=255&o},readASCII(i,a,o){let l="";for(let m=0;m<o;m++)l+=String.fromCharCode(i[a+m]);return l},writeASCII(i,a,o){for(let l=0;l<o.length;l++)i[a+l]=o.charCodeAt(l)},readBytes(i,a,o){const l=[];for(let m=0;m<o;m++)l.push(i[a+m]);return l},pad:i=>i.length<2?`0${i}`:i,readUTF8(i,a,o){let l,m="";for(let E=0;E<o;E++)m+=`%${g.pad(i[a+E].toString(16))}`;try{l=decodeURIComponent(m)}catch{return g.readASCII(i,a,o)}return l}};function v(i,a,o,l){const m=a*o,E=r(l),F=Math.ceil(a*E/8),C=new Uint8Array(4*m),H=new Uint32Array(C.buffer),{ctype:z}=l,{depth:U}=l,I=g.readUshort;if(z==6){const R=m<<2;if(U==8)for(var b=0;b<R;b+=4)C[b]=i[b],C[b+1]=i[b+1],C[b+2]=i[b+2],C[b+3]=i[b+3];if(U==16)for(b=0;b<R;b++)C[b]=i[b<<1]}else if(z==2){const R=l.tabs.tRNS;if(R==null){if(U==8)for(b=0;b<m;b++){var P=3*b;H[b]=255<<24|i[P+2]<<16|i[P+1]<<8|i[P]}if(U==16)for(b=0;b<m;b++)P=6*b,H[b]=255<<24|i[P+4]<<16|i[P+2]<<8|i[P]}else{var h=R[0];const L=R[1],j=R[2];if(U==8)for(b=0;b<m;b++){var u=b<<2;P=3*b,H[b]=255<<24|i[P+2]<<16|i[P+1]<<8|i[P],i[P]==h&&i[P+1]==L&&i[P+2]==j&&(C[u+3]=0)}if(U==16)for(b=0;b<m;b++)u=b<<2,P=6*b,H[b]=255<<24|i[P+4]<<16|i[P+2]<<8|i[P],I(i,P)==h&&I(i,P+2)==L&&I(i,P+4)==j&&(C[u+3]=0)}}else if(z==3){const R=l.tabs.PLTE,L=l.tabs.tRNS,j=L?L.length:0;if(U==1)for(var y=0;y<o;y++){var x=y*F,S=y*a;for(b=0;b<a;b++){u=S+b<<2;var _=3*(A=i[x+(b>>3)]>>7-((7&b)<<0)&1);C[u]=R[_],C[u+1]=R[_+1],C[u+2]=R[_+2],C[u+3]=A<j?L[A]:255}}if(U==2)for(y=0;y<o;y++)for(x=y*F,S=y*a,b=0;b<a;b++)u=S+b<<2,_=3*(A=i[x+(b>>2)]>>6-((3&b)<<1)&3),C[u]=R[_],C[u+1]=R[_+1],C[u+2]=R[_+2],C[u+3]=A<j?L[A]:255;if(U==4)for(y=0;y<o;y++)for(x=y*F,S=y*a,b=0;b<a;b++)u=S+b<<2,_=3*(A=i[x+(b>>1)]>>4-((1&b)<<2)&15),C[u]=R[_],C[u+1]=R[_+1],C[u+2]=R[_+2],C[u+3]=A<j?L[A]:255;if(U==8)for(b=0;b<m;b++){var A;u=b<<2,_=3*(A=i[b]),C[u]=R[_],C[u+1]=R[_+1],C[u+2]=R[_+2],C[u+3]=A<j?L[A]:255}}else if(z==4){if(U==8)for(b=0;b<m;b++){u=b<<2;var M=i[d=b<<1];C[u]=M,C[u+1]=M,C[u+2]=M,C[u+3]=i[d+1]}if(U==16)for(b=0;b<m;b++){var d;u=b<<2,M=i[d=b<<2],C[u]=M,C[u+1]=M,C[u+2]=M,C[u+3]=i[d+2]}}else if(z==0)for(h=l.tabs.tRNS?l.tabs.tRNS:-1,y=0;y<o;y++){const R=y*F,L=y*a;if(U==1)for(var f=0;f<a;f++){var T=(M=255*(i[R+(f>>>3)]>>>7-(7&f)&1))==255*h?0:255;H[L+f]=T<<24|M<<16|M<<8|M}else if(U==2)for(f=0;f<a;f++)T=(M=85*(i[R+(f>>>2)]>>>6-((3&f)<<1)&3))==85*h?0:255,H[L+f]=T<<24|M<<16|M<<8|M;else if(U==4)for(f=0;f<a;f++)T=(M=17*(i[R+(f>>>1)]>>>4-((1&f)<<2)&15))==17*h?0:255,H[L+f]=T<<24|M<<16|M<<8|M;else if(U==8)for(f=0;f<a;f++)T=(M=i[R+f])==h?0:255,H[L+f]=T<<24|M<<16|M<<8|M;else if(U==16)for(f=0;f<a;f++)M=i[R+(f<<1)],T=I(i,R+(f<<1))==h?0:255,H[L+f]=T<<24|M<<16|M<<8|M}return C}function t(i,a,o,l){const m=r(i),E=Math.ceil(o*m/8),F=new Uint8Array((E+1+i.interlace)*l);return a=i.tabs.CgBI?e(a,F):n(a,F),i.interlace==0?a=c(a,i,0,o,l):i.interlace==1&&(a=function(H,z){const U=z.width,I=z.height,b=r(z),P=b>>3,h=Math.ceil(U*b/8),u=new Uint8Array(I*h);let y=0;const x=[0,0,4,0,2,0,1],S=[0,4,0,2,0,1,0],_=[8,8,8,4,4,2,2],A=[8,8,4,4,2,2,1];let M=0;for(;M<7;){const f=_[M],T=A[M];let R=0,L=0,j=x[M];for(;j<I;)j+=f,L++;let N=S[M];for(;N<U;)N+=T,R++;const k=Math.ceil(R*b/8);c(H,z,y,R,L);let O=0,D=x[M];for(;D<I;){let V=S[M],q=y+O*k<<3;for(;V<U;){var d;if(b==1&&(d=(d=H[q>>3])>>7-(7&q)&1,u[D*h+(V>>3)]|=d<<7-((7&V)<<0)),b==2&&(d=(d=H[q>>3])>>6-(7&q)&3,u[D*h+(V>>2)]|=d<<6-((3&V)<<1)),b==4&&(d=(d=H[q>>3])>>4-(7&q)&15,u[D*h+(V>>1)]|=d<<4-((1&V)<<2)),b>=8){const Y=D*h+V*P;for(let Q=0;Q<P;Q++)u[Y+Q]=H[(q>>3)+Q]}q+=b,V+=T}O++,D+=f}R*L!=0&&(y+=L*(1+k)),M+=1}return u}(a,i)),a}function n(i,a){return e(new Uint8Array(i.buffer,2,i.length-6),a)}var e=function(){const i={H:{}};return i.H.N=function(a,o){const l=Uint8Array;let m,E,F=0,C=0,H=0,z=0,U=0,I=0,b=0,P=0,h=0;if(a[0]==3&&a[1]==0)return o||new l(0);const u=i.H,y=u.b,x=u.e,S=u.R,_=u.n,A=u.A,M=u.Z,d=u.m,f=o==null;for(f&&(o=new l(a.length>>>2<<5));F==0;)if(F=y(a,h,1),C=y(a,h+1,2),h+=3,C!=0){if(f&&(o=i.H.W(o,P+(1<<17))),C==1&&(m=d.J,E=d.h,I=511,b=31),C==2){H=x(a,h,5)+257,z=x(a,h+5,5)+1,U=x(a,h+10,4)+4,h+=14;let R=1;for(var T=0;T<38;T+=2)d.Q[T]=0,d.Q[T+1]=0;for(T=0;T<U;T++){const N=x(a,h+3*T,3);d.Q[1+(d.X[T]<<1)]=N,N>R&&(R=N)}h+=3*U,_(d.Q,R),A(d.Q,R,d.u),m=d.w,E=d.d,h=S(d.u,(1<<R)-1,H+z,a,h,d.v);const L=u.V(d.v,0,H,d.C);I=(1<<L)-1;const j=u.V(d.v,H,z,d.D);b=(1<<j)-1,_(d.C,L),A(d.C,L,m),_(d.D,j),A(d.D,j,E)}for(;;){const R=m[M(a,h)&I];h+=15&R;const L=R>>>4;if(!(L>>>8))o[P++]=L;else{if(L==256)break;{let j=P+L-254;if(L>264){const V=d.q[L-257];j=P+(V>>>3)+x(a,h,7&V),h+=7&V}const N=E[M(a,h)&b];h+=15&N;const k=N>>>4,O=d.c[k],D=(O>>>4)+y(a,h,15&O);for(h+=15&O;P<j;)o[P]=o[P++-D],o[P]=o[P++-D],o[P]=o[P++-D],o[P]=o[P++-D];P=j}}}}else{7&h&&(h+=8-(7&h));const R=4+(h>>>3),L=a[R-4]|a[R-3]<<8;f&&(o=i.H.W(o,P+L)),o.set(new l(a.buffer,a.byteOffset+R,L),P),h=R+L<<3,P+=L}return o.length==P?o:o.slice(0,P)},i.H.W=function(a,o){const l=a.length;if(o<=l)return a;const m=new Uint8Array(l<<1);return m.set(a,0),m},i.H.R=function(a,o,l,m,E,F){const C=i.H.e,H=i.H.Z;let z=0;for(;z<l;){const U=a[H(m,E)&o];E+=15&U;const I=U>>>4;if(I<=15)F[z]=I,z++;else{let b=0,P=0;I==16?(P=3+C(m,E,2),E+=2,b=F[z-1]):I==17?(P=3+C(m,E,3),E+=3):I==18&&(P=11+C(m,E,7),E+=7);const h=z+P;for(;z<h;)F[z]=b,z++}}return E},i.H.V=function(a,o,l,m){let E=0,F=0;const C=m.length>>>1;for(;F<l;){const H=a[F+o];m[F<<1]=0,m[1+(F<<1)]=H,H>E&&(E=H),F++}for(;F<C;)m[F<<1]=0,m[1+(F<<1)]=0,F++;return E},i.H.n=function(a,o){const l=i.H.m,m=a.length;let E,F,C,H;const z=l.j;for(var U=0;U<=o;U++)z[U]=0;for(U=1;U<m;U+=2)z[a[U]]++;const I=l.K;for(E=0,z[0]=0,F=1;F<=o;F++)E=E+z[F-1]<<1,I[F]=E;for(C=0;C<m;C+=2)H=a[C+1],H!=0&&(a[C]=I[H],I[H]++)},i.H.A=function(a,o,l){const m=a.length,E=i.H.m.r;for(let F=0;F<m;F+=2)if(a[F+1]!=0){const C=F>>1,H=a[F+1],z=C<<4|H,U=o-H;let I=a[F]<<U;const b=I+(1<<U);for(;I!=b;)l[E[I]>>>15-o]=z,I++}},i.H.l=function(a,o){const l=i.H.m.r,m=15-o;for(let E=0;E<a.length;E+=2){const F=a[E]<<o-a[E+1];a[E]=l[F]>>>m}},i.H.M=function(a,o,l){l<<=7&o;const m=o>>>3;a[m]|=l,a[m+1]|=l>>>8},i.H.I=function(a,o,l){l<<=7&o;const m=o>>>3;a[m]|=l,a[m+1]|=l>>>8,a[m+2]|=l>>>16},i.H.e=function(a,o,l){return(a[o>>>3]|a[1+(o>>>3)]<<8)>>>(7&o)&(1<<l)-1},i.H.b=function(a,o,l){return(a[o>>>3]|a[1+(o>>>3)]<<8|a[2+(o>>>3)]<<16)>>>(7&o)&(1<<l)-1},i.H.Z=function(a,o){return(a[o>>>3]|a[1+(o>>>3)]<<8|a[2+(o>>>3)]<<16)>>>(7&o)},i.H.i=function(a,o){return(a[o>>>3]|a[1+(o>>>3)]<<8|a[2+(o>>>3)]<<16|a[3+(o>>>3)]<<24)>>>(7&o)},i.H.m=function(){const a=Uint16Array,o=Uint32Array;return{K:new a(16),j:new a(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new a(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new o(32),J:new a(512),_:[],h:new a(32),$:[],w:new a(32768),C:[],v:[],d:new a(32768),D:[],u:new a(512),Q:[],r:new a(32768),s:new o(286),Y:new o(30),a:new o(19),t:new o(15e3),k:new a(65536),g:new a(32768)}}(),function(){const a=i.H.m;for(var o=0;o<32768;o++){let m=o;m=(2863311530&m)>>>1|(1431655765&m)<<1,m=(3435973836&m)>>>2|(858993459&m)<<2,m=(4042322160&m)>>>4|(252645135&m)<<4,m=(4278255360&m)>>>8|(16711935&m)<<8,a.r[o]=(m>>>16|m<<16)>>>17}function l(m,E,F){for(;E--!=0;)m.push(0,F)}for(o=0;o<32;o++)a.q[o]=a.S[o]<<3|a.T[o],a.c[o]=a.p[o]<<4|a.z[o];l(a._,144,8),l(a._,112,9),l(a._,24,7),l(a._,8,8),i.H.n(a._,9),i.H.A(a._,9,a.J),i.H.l(a._,9),l(a.$,32,5),i.H.n(a.$,5),i.H.A(a.$,5,a.h),i.H.l(a.$,5),l(a.Q,19,0),l(a.C,286,0),l(a.D,30,0),l(a.v,320,0)}(),i.H.N}();function r(i){return[1,null,3,1,2,null,4][i.ctype]*i.depth}function c(i,a,o,l,m){let E=r(a);const F=Math.ceil(l*E/8);let C,H;E=Math.ceil(E/8);let z=i[o],U=0;if(z>1&&(i[o]=[0,0,1][z-2]),z==3)for(U=E;U<F;U++)i[U+1]=i[U+1]+(i[U+1-E]>>>1)&255;for(let I=0;I<m;I++)if(C=o+I*F,H=C+I+1,z=i[H-1],U=0,z==0)for(;U<F;U++)i[C+U]=i[H+U];else if(z==1){for(;U<E;U++)i[C+U]=i[H+U];for(;U<F;U++)i[C+U]=i[H+U]+i[C+U-E]}else if(z==2)for(;U<F;U++)i[C+U]=i[H+U]+i[C+U-F];else if(z==3){for(;U<E;U++)i[C+U]=i[H+U]+(i[C+U-F]>>>1);for(;U<F;U++)i[C+U]=i[H+U]+(i[C+U-F]+i[C+U-E]>>>1)}else{for(;U<E;U++)i[C+U]=i[H+U]+s(0,i[C+U-F],0);for(;U<F;U++)i[C+U]=i[H+U]+s(i[C+U-E],i[C+U-F],i[C+U-E-F])}return i}function s(i,a,o){const l=i+a-o,m=l-i,E=l-a,F=l-o;return m*m<=E*E&&m*m<=F*F?i:E*E<=F*F?a:o}function p(i,a,o){o.width=g.readUint(i,a),a+=4,o.height=g.readUint(i,a),a+=4,o.depth=i[a],a++,o.ctype=i[a],a++,o.compress=i[a],a++,o.filter=i[a],a++,o.interlace=i[a],a++}function w(i,a,o,l,m,E,F,C,H){const z=Math.min(a,m),U=Math.min(o,E);let I=0,b=0;for(let M=0;M<U;M++)for(let d=0;d<z;d++)if(F>=0&&C>=0?(I=M*a+d<<2,b=(C+M)*m+F+d<<2):(I=(-C+M)*a-F+d<<2,b=M*m+d<<2),H==0)l[b]=i[I],l[b+1]=i[I+1],l[b+2]=i[I+2],l[b+3]=i[I+3];else if(H==1){var P=i[I+3]*.00392156862745098,h=i[I]*P,u=i[I+1]*P,y=i[I+2]*P,x=l[b+3]*(1/255),S=l[b]*x,_=l[b+1]*x,A=l[b+2]*x;const f=1-P,T=P+x*f,R=T==0?0:1/T;l[b+3]=255*T,l[b+0]=(h+S*f)*R,l[b+1]=(u+_*f)*R,l[b+2]=(y+A*f)*R}else if(H==2)P=i[I+3],h=i[I],u=i[I+1],y=i[I+2],x=l[b+3],S=l[b],_=l[b+1],A=l[b+2],P==x&&h==S&&u==_&&y==A?(l[b]=0,l[b+1]=0,l[b+2]=0,l[b+3]=0):(l[b]=h,l[b+1]=u,l[b+2]=y,l[b+3]=P);else if(H==3){if(P=i[I+3],h=i[I],u=i[I+1],y=i[I+2],x=l[b+3],S=l[b],_=l[b+1],A=l[b+2],P==x&&h==S&&u==_&&y==A)continue;if(P<220&&x>20)return!1}return!0}return{decode:function(a){const o=new Uint8Array(a);let l=8;const m=g,E=m.readUshort,F=m.readUint,C={tabs:{},frames:[]},H=new Uint8Array(o.length);let z,U=0,I=0;const b=[137,80,78,71,13,10,26,10];for(var P=0;P<8;P++)if(o[P]!=b[P])throw"The input is not a PNG file!";for(;l<o.length;){const M=m.readUint(o,l);l+=4;const d=m.readASCII(o,l,4);if(l+=4,d=="IHDR")p(o,l,C);else if(d=="iCCP"){for(var h=l;o[h]!=0;)h++;m.readASCII(o,l,h-l),o[h+1];const f=o.slice(h+2,l+M);let T=null;try{T=n(f)}catch{T=e(f)}C.tabs[d]=T}else if(d=="CgBI")C.tabs[d]=o.slice(l,l+4);else if(d=="IDAT"){for(P=0;P<M;P++)H[U+P]=o[l+P];U+=M}else if(d=="acTL")C.tabs[d]={num_frames:F(o,l),num_plays:F(o,l+4)},z=new Uint8Array(o.length);else if(d=="fcTL"){I!=0&&((A=C.frames[C.frames.length-1]).data=t(C,z.slice(0,I),A.rect.width,A.rect.height),I=0);const f={x:F(o,l+12),y:F(o,l+16),width:F(o,l+4),height:F(o,l+8)};let T=E(o,l+22);T=E(o,l+20)/(T==0?100:T);const R={rect:f,delay:Math.round(1e3*T),dispose:o[l+24],blend:o[l+25]};C.frames.push(R)}else if(d=="fdAT"){for(P=0;P<M-4;P++)z[I+P]=o[l+P+4];I+=M-4}else if(d=="pHYs")C.tabs[d]=[m.readUint(o,l),m.readUint(o,l+4),o[l+8]];else if(d=="cHRM")for(C.tabs[d]=[],P=0;P<8;P++)C.tabs[d].push(m.readUint(o,l+4*P));else if(d=="tEXt"||d=="zTXt"){C.tabs[d]==null&&(C.tabs[d]={});var u=m.nextZero(o,l),y=m.readASCII(o,l,u-l),x=l+M-u-1;if(d=="tEXt")_=m.readASCII(o,u+1,x);else{var S=n(o.slice(u+2,u+2+x));_=m.readUTF8(S,0,S.length)}C.tabs[d][y]=_}else if(d=="iTXt"){C.tabs[d]==null&&(C.tabs[d]={}),u=0,h=l,u=m.nextZero(o,h),y=m.readASCII(o,h,u-h);const f=o[h=u+1];var _;o[h+1],h+=2,u=m.nextZero(o,h),m.readASCII(o,h,u-h),h=u+1,u=m.nextZero(o,h),m.readUTF8(o,h,u-h),x=M-((h=u+1)-l),f==0?_=m.readUTF8(o,h,x):(S=n(o.slice(h,h+x)),_=m.readUTF8(S,0,S.length)),C.tabs[d][y]=_}else if(d=="PLTE")C.tabs[d]=m.readBytes(o,l,M);else if(d=="hIST"){const f=C.tabs.PLTE.length/3;for(C.tabs[d]=[],P=0;P<f;P++)C.tabs[d].push(E(o,l+2*P))}else if(d=="tRNS")C.ctype==3?C.tabs[d]=m.readBytes(o,l,M):C.ctype==0?C.tabs[d]=E(o,l):C.ctype==2&&(C.tabs[d]=[E(o,l),E(o,l+2),E(o,l+4)]);else if(d=="gAMA")C.tabs[d]=m.readUint(o,l)/1e5;else if(d=="sRGB")C.tabs[d]=o[l];else if(d=="bKGD")C.ctype==0||C.ctype==4?C.tabs[d]=[E(o,l)]:C.ctype==2||C.ctype==6?C.tabs[d]=[E(o,l),E(o,l+2),E(o,l+4)]:C.ctype==3&&(C.tabs[d]=o[l]);else if(d=="IEND")break;l+=M,m.readUint(o,l),l+=4}var A;return I!=0&&((A=C.frames[C.frames.length-1]).data=t(C,z.slice(0,I),A.rect.width,A.rect.height)),C.data=t(C,H,C.width,C.height),delete C.compress,delete C.interlace,delete C.filter,C},toRGBA8:function(a){const o=a.width,l=a.height;if(a.tabs.acTL==null)return[v(a.data,o,l,a).buffer];const m=[];a.frames[0].data==null&&(a.frames[0].data=a.data);const E=o*l*4,F=new Uint8Array(E),C=new Uint8Array(E),H=new Uint8Array(E);for(let U=0;U<a.frames.length;U++){const I=a.frames[U],b=I.rect.x,P=I.rect.y,h=I.rect.width,u=I.rect.height,y=v(I.data,h,u,a);if(U!=0)for(var z=0;z<E;z++)H[z]=F[z];if(I.blend==0?w(y,h,u,F,o,l,b,P,0):I.blend==1&&w(y,h,u,F,o,l,b,P,1),m.push(F.buffer.slice(0)),I.dispose!=0){if(I.dispose==1)w(C,h,u,F,o,l,b,P,0);else if(I.dispose==2)for(z=0;z<E;z++)F[z]=H[z]}}return m},_paeth:s,_copyTile:w,_bin:g}}();(function(){const{_copyTile:g}=we,{_bin:v}=we,t=we._paeth;var n={table:function(){const h=new Uint32Array(256);for(let u=0;u<256;u++){let y=u;for(let x=0;x<8;x++)1&y?y=3988292384^y>>>1:y>>>=1;h[u]=y}return h}(),update(h,u,y,x){for(let S=0;S<x;S++)h=n.table[255&(h^u[y+S])]^h>>>8;return h},crc:(h,u,y)=>4294967295^n.update(4294967295,h,u,y)};function e(h,u,y,x){u[y]+=h[0]*x>>4,u[y+1]+=h[1]*x>>4,u[y+2]+=h[2]*x>>4,u[y+3]+=h[3]*x>>4}function r(h){return Math.max(0,Math.min(255,h))}function c(h,u){const y=h[0]-u[0],x=h[1]-u[1],S=h[2]-u[2],_=h[3]-u[3];return y*y+x*x+S*S+_*_}function s(h,u,y,x,S,_,A){A==null&&(A=1);const M=x.length,d=[];for(var f=0;f<M;f++){const D=x[f];d.push([D>>>0&255,D>>>8&255,D>>>16&255,D>>>24&255])}for(f=0;f<M;f++){let D=4294967295;for(var T=0,R=0;R<M;R++){var L=c(d[f],d[R]);R!=f&&L<D&&(D=L,T=R)}}const j=new Uint32Array(S.buffer),N=new Int16Array(u*y*4),k=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(f=0;f<k.length;f++)k[f]=255*((k[f]+.5)/16-.5);for(let D=0;D<y;D++)for(let V=0;V<u;V++){var O;f=4*(D*u+V),A!=2?O=[r(h[f]+N[f]),r(h[f+1]+N[f+1]),r(h[f+2]+N[f+2]),r(h[f+3]+N[f+3])]:(L=k[4*(3&D)+(3&V)],O=[r(h[f]+L),r(h[f+1]+L),r(h[f+2]+L),r(h[f+3]+L)]),T=0;let q=16777215;for(R=0;R<M;R++){const K=c(O,d[R]);K<q&&(q=K,T=R)}const Y=d[T],Q=[O[0]-Y[0],O[1]-Y[1],O[2]-Y[2],O[3]-Y[3]];A==1&&(V!=u-1&&e(Q,N,f+4,7),D!=y-1&&(V!=0&&e(Q,N,f+4*u-4,3),e(Q,N,f+4*u,5),V!=u-1&&e(Q,N,f+4*u+4,1))),_[f>>2]=T,j[f>>2]=x[T]}}function p(h,u,y,x,S){S==null&&(S={});const{crc:_}=n,A=v.writeUint,M=v.writeUshort,d=v.writeASCII;let f=8;const T=h.frames.length>1;let R,L=!1,j=33+(T?20:0);if(S.sRGB!=null&&(j+=13),S.pHYs!=null&&(j+=21),S.iCCP!=null&&(R=pako.deflate(S.iCCP),j+=21+R.length+4),h.ctype==3){for(var N=h.plte.length,k=0;k<N;k++)h.plte[k]>>>24!=255&&(L=!0);j+=8+3*N+4+(L?8+1*N+4:0)}for(var O=0;O<h.frames.length;O++)T&&(j+=38),j+=(Y=h.frames[O]).cimg.length+12,O!=0&&(j+=4);j+=12;const D=new Uint8Array(j),V=[137,80,78,71,13,10,26,10];for(k=0;k<8;k++)D[k]=V[k];if(A(D,f,13),f+=4,d(D,f,"IHDR"),f+=4,A(D,f,u),f+=4,A(D,f,y),f+=4,D[f]=h.depth,f++,D[f]=h.ctype,f++,D[f]=0,f++,D[f]=0,f++,D[f]=0,f++,A(D,f,_(D,f-17,17)),f+=4,S.sRGB!=null&&(A(D,f,1),f+=4,d(D,f,"sRGB"),f+=4,D[f]=S.sRGB,f++,A(D,f,_(D,f-5,5)),f+=4),S.iCCP!=null){const Q=13+R.length;A(D,f,Q),f+=4,d(D,f,"iCCP"),f+=4,d(D,f,"ICC profile"),f+=11,f+=2,D.set(R,f),f+=R.length,A(D,f,_(D,f-(Q+4),Q+4)),f+=4}if(S.pHYs!=null&&(A(D,f,9),f+=4,d(D,f,"pHYs"),f+=4,A(D,f,S.pHYs[0]),f+=4,A(D,f,S.pHYs[1]),f+=4,D[f]=S.pHYs[2],f++,A(D,f,_(D,f-13,13)),f+=4),T&&(A(D,f,8),f+=4,d(D,f,"acTL"),f+=4,A(D,f,h.frames.length),f+=4,A(D,f,S.loop!=null?S.loop:0),f+=4,A(D,f,_(D,f-12,12)),f+=4),h.ctype==3){for(A(D,f,3*(N=h.plte.length)),f+=4,d(D,f,"PLTE"),f+=4,k=0;k<N;k++){const Q=3*k,K=h.plte[k],re=255&K,oe=K>>>8&255,Ae=K>>>16&255;D[f+Q+0]=re,D[f+Q+1]=oe,D[f+Q+2]=Ae}if(f+=3*N,A(D,f,_(D,f-3*N-4,3*N+4)),f+=4,L){for(A(D,f,N),f+=4,d(D,f,"tRNS"),f+=4,k=0;k<N;k++)D[f+k]=h.plte[k]>>>24&255;f+=N,A(D,f,_(D,f-N-4,N+4)),f+=4}}let q=0;for(O=0;O<h.frames.length;O++){var Y=h.frames[O];T&&(A(D,f,26),f+=4,d(D,f,"fcTL"),f+=4,A(D,f,q++),f+=4,A(D,f,Y.rect.width),f+=4,A(D,f,Y.rect.height),f+=4,A(D,f,Y.rect.x),f+=4,A(D,f,Y.rect.y),f+=4,M(D,f,x[O]),f+=2,M(D,f,1e3),f+=2,D[f]=Y.dispose,f++,D[f]=Y.blend,f++,A(D,f,_(D,f-30,30)),f+=4);const Q=Y.cimg;A(D,f,(N=Q.length)+(O==0?0:4)),f+=4;const K=f;d(D,f,O==0?"IDAT":"fdAT"),f+=4,O!=0&&(A(D,f,q++),f+=4),D.set(Q,f),f+=N,A(D,f,_(D,K,f-K)),f+=4}return A(D,f,0),f+=4,d(D,f,"IEND"),f+=4,A(D,f,_(D,f-4,4)),f+=4,D.buffer}function w(h,u,y){for(let x=0;x<h.frames.length;x++){const S=h.frames[x];S.rect.width;const _=S.rect.height,A=new Uint8Array(_*S.bpl+_);S.cimg=l(S.img,_,S.bpp,S.bpl,A,u,y)}}function i(h,u,y,x,S){const _=S[0],A=S[1],M=S[2],d=S[3],f=S[4],T=S[5];let R=6,L=8,j=255;for(var N=0;N<h.length;N++){const ae=new Uint8Array(h[N]);for(var k=ae.length,O=0;O<k;O+=4)j&=ae[O+3]}const D=j!=255,V=function(J,$,Z,W,B,ne){const ie=[];for(var X=0;X<J.length;X++){const ue=new Uint8Array(J[X]),me=new Uint32Array(ue.buffer);var se;let ve=0,Ce=0,be=$,_e=Z,qe=W?1:0;if(X!=0){const Zt=ne||W||X==1||ie[X-2].dispose!=0?1:2;let Ke=0,ht=1e9;for(let Ie=0;Ie<Zt;Ie++){var ge=new Uint8Array(J[X-1-Ie]);const Bt=new Uint32Array(J[X-1-Ie]);let xe=$,Se=Z,De=-1,Te=-1;for(let Re=0;Re<Z;Re++)for(let Me=0;Me<$;Me++)me[ce=Re*$+Me]!=Bt[ce]&&(Me<xe&&(xe=Me),Me>De&&(De=Me),Re<Se&&(Se=Re),Re>Te&&(Te=Re));De==-1&&(xe=Se=De=Te=0),B&&((1&xe)==1&&xe--,(1&Se)==1&&Se--);const dt=(De-xe+1)*(Te-Se+1);dt<ht&&(ht=dt,Ke=Ie,ve=xe,Ce=Se,be=De-xe+1,_e=Te-Se+1)}ge=new Uint8Array(J[X-1-Ke]),Ke==1&&(ie[X-1].dispose=2),se=new Uint8Array(be*_e*4),g(ge,$,Z,se,be,_e,-ve,-Ce,0),qe=g(ue,$,Z,se,be,_e,-ve,-Ce,3)?1:0,qe==1?o(ue,$,Z,se,{x:ve,y:Ce,width:be,height:_e}):g(ue,$,Z,se,be,_e,-ve,-Ce,0)}else se=ue.slice(0);ie.push({rect:{x:ve,y:Ce,width:be,height:_e},img:se,blend:qe,dispose:0})}if(W)for(X=0;X<ie.length;X++){if((Ee=ie[X]).blend==1)continue;const ue=Ee.rect,me=ie[X-1].rect,ve=Math.min(ue.x,me.x),Ce=Math.min(ue.y,me.y),be={x:ve,y:Ce,width:Math.max(ue.x+ue.width,me.x+me.width)-ve,height:Math.max(ue.y+ue.height,me.y+me.height)-Ce};ie[X-1].dispose=1,X-1!=0&&a(J,$,Z,ie,X-1,be,B),a(J,$,Z,ie,X,be,B)}let He=0;if(J.length!=1)for(var ce=0;ce<ie.length;ce++){var Ee;He+=(Ee=ie[ce]).rect.width*Ee.rect.height}return ie}(h,u,y,_,A,M),q={},Y=[],Q=[];if(x!=0){const ae=[];for(O=0;O<V.length;O++)ae.push(V[O].img.buffer);const J=function(B){let ne=0;for(var ie=0;ie<B.length;ie++)ne+=B[ie].byteLength;const X=new Uint8Array(ne);let se=0;for(ie=0;ie<B.length;ie++){const ge=new Uint8Array(B[ie]),He=ge.length;for(let ce=0;ce<He;ce+=4){let Ee=ge[ce],ue=ge[ce+1],me=ge[ce+2];const ve=ge[ce+3];ve==0&&(Ee=ue=me=0),X[se+ce]=Ee,X[se+ce+1]=ue,X[se+ce+2]=me,X[se+ce+3]=ve}se+=He}return X.buffer}(ae),$=E(J,x);for(O=0;O<$.plte.length;O++)Y.push($.plte[O].est.rgba);let Z=0;for(O=0;O<V.length;O++){const W=(re=V[O]).img.length;var K=new Uint8Array($.inds.buffer,Z>>2,W>>2);Q.push(K);const B=new Uint8Array($.abuf,Z,W);T&&s(re.img,re.rect.width,re.rect.height,Y,B,K),re.img.set(B),Z+=W}}else for(N=0;N<V.length;N++){var re=V[N];const ae=new Uint32Array(re.img.buffer);var oe=re.rect.width;for(k=ae.length,K=new Uint8Array(k),Q.push(K),O=0;O<k;O++){const J=ae[O];if(O!=0&&J==ae[O-1])K[O]=K[O-1];else if(O>oe&&J==ae[O-oe])K[O]=K[O-oe];else{let $=q[J];if($==null&&(q[J]=$=Y.length,Y.push(J),Y.length>=300))break;K[O]=$}}}const Ae=Y.length;for(Ae<=256&&f==0&&(L=Ae<=2?1:Ae<=4?2:Ae<=16?4:8,L=Math.max(L,d)),N=0;N<V.length;N++){(re=V[N]).rect.x,re.rect.y,oe=re.rect.width;const ae=re.rect.height;let J=re.img;new Uint32Array(J.buffer);let $=4*oe,Z=4;if(Ae<=256&&f==0){$=Math.ceil(L*oe/8);var pe=new Uint8Array($*ae);const W=Q[N];for(let B=0;B<ae;B++){O=B*$;const ne=B*oe;if(L==8)for(var ee=0;ee<oe;ee++)pe[O+ee]=W[ne+ee];else if(L==4)for(ee=0;ee<oe;ee++)pe[O+(ee>>1)]|=W[ne+ee]<<4-4*(1&ee);else if(L==2)for(ee=0;ee<oe;ee++)pe[O+(ee>>2)]|=W[ne+ee]<<6-2*(3&ee);else if(L==1)for(ee=0;ee<oe;ee++)pe[O+(ee>>3)]|=W[ne+ee]<<7-1*(7&ee)}J=pe,R=3,Z=1}else if(D==0&&V.length==1){pe=new Uint8Array(oe*ae*3);const W=oe*ae;for(O=0;O<W;O++){const B=3*O,ne=4*O;pe[B]=J[ne],pe[B+1]=J[ne+1],pe[B+2]=J[ne+2]}J=pe,R=2,Z=3,$=3*oe}re.img=J,re.bpl=$,re.bpp=Z}return{ctype:R,depth:L,plte:Y,frames:V}}function a(h,u,y,x,S,_,A){const M=Uint8Array,d=Uint32Array,f=new M(h[S-1]),T=new d(h[S-1]),R=S+1<h.length?new M(h[S+1]):null,L=new M(h[S]),j=new d(L.buffer);let N=u,k=y,O=-1,D=-1;for(let q=0;q<_.height;q++)for(let Y=0;Y<_.width;Y++){const Q=_.x+Y,K=_.y+q,re=K*u+Q,oe=j[re];oe==0||x[S-1].dispose==0&&T[re]==oe&&(R==null||R[4*re+3]!=0)||(Q<N&&(N=Q),Q>O&&(O=Q),K<k&&(k=K),K>D&&(D=K))}O==-1&&(N=k=O=D=0),A&&((1&N)==1&&N--,(1&k)==1&&k--),_={x:N,y:k,width:O-N+1,height:D-k+1};const V=x[S];V.rect=_,V.blend=1,V.img=new Uint8Array(_.width*_.height*4),x[S-1].dispose==0?(g(f,u,y,V.img,_.width,_.height,-_.x,-_.y,0),o(L,u,y,V.img,_)):g(L,u,y,V.img,_.width,_.height,-_.x,-_.y,0)}function o(h,u,y,x,S){g(h,u,y,x,S.width,S.height,-S.x,-S.y,2)}function l(h,u,y,x,S,_,A){const M=[];let d,f=[0,1,2,3,4];_!=-1?f=[_]:(u*x>5e5||y==1)&&(f=[0]),A&&(d={level:0});const T=Ir;for(var R=0;R<f.length;R++){for(let N=0;N<u;N++)m(S,h,N,x,y,f[R]);M.push(T.deflate(S,d))}let L,j=1e9;for(R=0;R<M.length;R++)M[R].length<j&&(L=R,j=M[R].length);return M[L]}function m(h,u,y,x,S,_){const A=y*x;let M=A+y;if(h[M]=_,M++,_==0)if(x<500)for(var d=0;d<x;d++)h[M+d]=u[A+d];else h.set(new Uint8Array(u.buffer,A,x),M);else if(_==1){for(d=0;d<S;d++)h[M+d]=u[A+d];for(d=S;d<x;d++)h[M+d]=u[A+d]-u[A+d-S]+256&255}else if(y==0){for(d=0;d<S;d++)h[M+d]=u[A+d];if(_==2)for(d=S;d<x;d++)h[M+d]=u[A+d];if(_==3)for(d=S;d<x;d++)h[M+d]=u[A+d]-(u[A+d-S]>>1)+256&255;if(_==4)for(d=S;d<x;d++)h[M+d]=u[A+d]-t(u[A+d-S],0,0)+256&255}else{if(_==2)for(d=0;d<x;d++)h[M+d]=u[A+d]+256-u[A+d-x]&255;if(_==3){for(d=0;d<S;d++)h[M+d]=u[A+d]+256-(u[A+d-x]>>1)&255;for(d=S;d<x;d++)h[M+d]=u[A+d]+256-(u[A+d-x]+u[A+d-S]>>1)&255}if(_==4){for(d=0;d<S;d++)h[M+d]=u[A+d]+256-t(0,u[A+d-x],0)&255;for(d=S;d<x;d++)h[M+d]=u[A+d]+256-t(u[A+d-S],u[A+d-x],u[A+d-S-x])&255}}}function E(h,u){const y=new Uint8Array(h),x=y.slice(0),S=new Uint32Array(x.buffer),_=F(x,u),A=_[0],M=_[1],d=y.length,f=new Uint8Array(d>>2);let T;if(y.length<2e7)for(var R=0;R<d;R+=4)T=C(A,L=y[R]*(1/255),j=y[R+1]*(1/255),N=y[R+2]*(1/255),k=y[R+3]*(1/255)),f[R>>2]=T.ind,S[R>>2]=T.est.rgba;else for(R=0;R<d;R+=4){var L=y[R]*.00392156862745098,j=y[R+1]*(1/255),N=y[R+2]*(1/255),k=y[R+3]*(1/255);for(T=A;T.left;)T=H(T.est,L,j,N,k)<=0?T.left:T.right;f[R>>2]=T.ind,S[R>>2]=T.est.rgba}return{abuf:x.buffer,inds:f,plte:M}}function F(h,u,y){y==null&&(y=1e-4);const x=new Uint32Array(h.buffer),S={i0:0,i1:h.length,bst:null,est:null,tdst:0,left:null,right:null};S.bst=I(h,S.i0,S.i1),S.est=b(S.bst);const _=[S];for(;_.length<u;){let M=0,d=0;for(var A=0;A<_.length;A++)_[A].est.L>M&&(M=_[A].est.L,d=A);if(M<y)break;const f=_[d],T=z(h,x,f.i0,f.i1,f.est.e,f.est.eMq255);if(f.i0>=T||f.i1<=T){f.est.L=0;continue}const R={i0:f.i0,i1:T,bst:null,est:null,tdst:0,left:null,right:null};R.bst=I(h,R.i0,R.i1),R.est=b(R.bst);const L={i0:T,i1:f.i1,bst:null,est:null,tdst:0,left:null,right:null};for(L.bst={R:[],m:[],N:f.bst.N-R.bst.N},A=0;A<16;A++)L.bst.R[A]=f.bst.R[A]-R.bst.R[A];for(A=0;A<4;A++)L.bst.m[A]=f.bst.m[A]-R.bst.m[A];L.est=b(L.bst),f.left=R,f.right=L,_[d]=R,_.push(L)}for(_.sort((M,d)=>d.bst.N-M.bst.N),A=0;A<_.length;A++)_[A].ind=A;return[S,_]}function C(h,u,y,x,S){if(h.left==null)return h.tdst=function(R,L,j,N,k){const O=L-R[0],D=j-R[1],V=N-R[2],q=k-R[3];return O*O+D*D+V*V+q*q}(h.est.q,u,y,x,S),h;const _=H(h.est,u,y,x,S);let A=h.left,M=h.right;_>0&&(A=h.right,M=h.left);const d=C(A,u,y,x,S);if(d.tdst<=_*_)return d;const f=C(M,u,y,x,S);return f.tdst<d.tdst?f:d}function H(h,u,y,x,S){const{e:_}=h;return _[0]*u+_[1]*y+_[2]*x+_[3]*S-h.eMq}function z(h,u,y,x,S,_){for(x-=4;y<x;){for(;U(h,y,S)<=_;)y+=4;for(;U(h,x,S)>_;)x-=4;if(y>=x)break;const A=u[y>>2];u[y>>2]=u[x>>2],u[x>>2]=A,y+=4,x-=4}for(;U(h,y,S)>_;)y-=4;return y+4}function U(h,u,y){return h[u]*y[0]+h[u+1]*y[1]+h[u+2]*y[2]+h[u+3]*y[3]}function I(h,u,y){const x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],S=[0,0,0,0],_=y-u>>2;for(let A=u;A<y;A+=4){const M=h[A]*.00392156862745098,d=h[A+1]*(1/255),f=h[A+2]*(1/255),T=h[A+3]*(1/255);S[0]+=M,S[1]+=d,S[2]+=f,S[3]+=T,x[0]+=M*M,x[1]+=M*d,x[2]+=M*f,x[3]+=M*T,x[5]+=d*d,x[6]+=d*f,x[7]+=d*T,x[10]+=f*f,x[11]+=f*T,x[15]+=T*T}return x[4]=x[1],x[8]=x[2],x[9]=x[6],x[12]=x[3],x[13]=x[7],x[14]=x[11],{R:x,m:S,N:_}}function b(h){const{R:u}=h,{m:y}=h,{N:x}=h,S=y[0],_=y[1],A=y[2],M=y[3],d=x==0?0:1/x,f=[u[0]-S*S*d,u[1]-S*_*d,u[2]-S*A*d,u[3]-S*M*d,u[4]-_*S*d,u[5]-_*_*d,u[6]-_*A*d,u[7]-_*M*d,u[8]-A*S*d,u[9]-A*_*d,u[10]-A*A*d,u[11]-A*M*d,u[12]-M*S*d,u[13]-M*_*d,u[14]-M*A*d,u[15]-M*M*d],T=f,R=P;let L=[Math.random(),Math.random(),Math.random(),Math.random()],j=0,N=0;if(x!=0)for(let O=0;O<16&&(L=R.multVec(T,L),N=Math.sqrt(R.dot(L,L)),L=R.sml(1/N,L),!(O!=0&&Math.abs(N-j)<1e-9));O++)j=N;const k=[S*d,_*d,A*d,M*d];return{Cov:f,q:k,e:L,L:j,eMq255:R.dot(R.sml(255,k),L),eMq:R.dot(L,k),rgba:(Math.round(255*k[3])<<24|Math.round(255*k[2])<<16|Math.round(255*k[1])<<8|Math.round(255*k[0])<<0)>>>0}}var P={multVec:(h,u)=>[h[0]*u[0]+h[1]*u[1]+h[2]*u[2]+h[3]*u[3],h[4]*u[0]+h[5]*u[1]+h[6]*u[2]+h[7]*u[3],h[8]*u[0]+h[9]*u[1]+h[10]*u[2]+h[11]*u[3],h[12]*u[0]+h[13]*u[1]+h[14]*u[2]+h[15]*u[3]],dot:(h,u)=>h[0]*u[0]+h[1]*u[1]+h[2]*u[2]+h[3]*u[3],sml:(h,u)=>[h*u[0],h*u[1],h*u[2],h*u[3]]};we.encode=function(u,y,x,S,_,A,M){S==null&&(S=0),M==null&&(M=!1);const d=i(u,y,x,S,[!1,!1,!1,0,M,!1]);return w(d,-1),p(d,y,x,_,A)},we.encodeLL=function(u,y,x,S,_,A,M,d){const f={ctype:0+(S==1?0:2)+(_==0?0:4),depth:A,frames:[]},T=(S+_)*A,R=T*y;for(let L=0;L<u.length;L++)f.frames.push({rect:{x:0,y:0,width:y,height:x},img:new Uint8Array(u[L]),blend:0,dispose:1,bpp:Math.ceil(T/8),bpl:Math.ceil(R/8)});return w(f,0,!0),p(f,y,x,M,d)},we.encode.compress=i,we.encode.dither=s,we.quantize=E,we.quantize.getKDtree=F,we.quantize.getNearest=C})();const It={toArrayBuffer(g,v){const t=g.width,n=g.height,e=t<<2,r=g.getContext("2d").getImageData(0,0,t,n),c=new Uint32Array(r.data.buffer),s=(32*t+31)/32<<2,p=s*n,w=122+p,i=new ArrayBuffer(w),a=new DataView(i),o=1<<20;let l,m,E,F,C=o,H=0,z=0,U=0;function I(h){a.setUint16(z,h,!0),z+=2}function b(h){a.setUint32(z,h,!0),z+=4}function P(h){z+=h}I(19778),b(w),P(4),b(122),b(108),b(t),b(-n>>>0),I(1),I(32),b(3),b(p),b(2835),b(2835),P(8),b(16711680),b(65280),b(255),b(4278190080),b(1466527264),function h(){for(;H<n&&C>0;){for(F=122+H*s,l=0;l<e;)C--,m=c[U++],E=m>>>24,a.setUint32(F+l,m<<8|E),l+=4;H++}U<c.length?(C=o,setTimeout(h,It._dly)):v(i)}()},toBlob(g,v){this.toArrayBuffer(g,t=>{v(new Blob([t],{type:"image/bmp"}))})},_dly:9};var de={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},Tr={[de.CHROME]:16384,[de.FIREFOX]:11180,[de.DESKTOP_SAFARI]:16384,[de.IE]:8192,[de.IOS]:4096,[de.ETC]:8192};const ft=typeof window<"u",Tt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Be=ft&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),Lr=(ft||Tt)&&(Be&&Be.getOriginalSymbol(window,"File")||typeof File<"u"&&File),Lt=(ft||Tt)&&(Be&&Be.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function ut(g,v,t=Date.now()){return new Promise(n=>{const e=g.split(","),r=e[0].match(/:(.*?);/)[1],c=globalThis.atob(e[1]);let s=c.length;const p=new Uint8Array(s);for(;s--;)p[s]=c.charCodeAt(s);const w=new Blob([p],{type:r});w.name=v,w.lastModified=t,n(w)})}function Ht(g){return new Promise((v,t)=>{const n=new Lt;n.onload=()=>v(n.result),n.onerror=e=>t(e),n.readAsDataURL(g)})}function Ot(g){return new Promise((v,t)=>{const n=new Image;n.onload=()=>v(n),n.onerror=e=>t(e),n.src=g})}function Ue(){if(Ue.cachedResult!==void 0)return Ue.cachedResult;let g=de.ETC;const{userAgent:v}=navigator;return/Chrom(e|ium)/i.test(v)?g=de.CHROME:/iP(ad|od|hone)/i.test(v)&&/WebKit/i.test(v)?g=de.IOS:/Safari/i.test(v)?g=de.DESKTOP_SAFARI:/Firefox/i.test(v)?g=de.FIREFOX:(/MSIE/i.test(v)||document.documentMode)&&(g=de.IE),Ue.cachedResult=g,Ue.cachedResult}function Nt(g,v){const t=Ue(),n=Tr[t];let e=g,r=v,c=e*r;const s=e>r?r/e:e/r;for(;c>n*n;){const p=(n+e)/2,w=(n+r)/2;p<w?(r=w,e=w*s):(r=p*s,e=p),c=e*r}return{width:e,height:r}}function Ye(g,v){let t,n;try{if(t=new OffscreenCanvas(g,v),n=t.getContext("2d"),n===null)throw new Error("getContext of OffscreenCanvas returns null")}catch{t=document.createElement("canvas"),n=t.getContext("2d")}return t.width=g,t.height=v,[t,n]}function kt(g,v){const{width:t,height:n}=Nt(g.width,g.height),[e,r]=Ye(t,n);return v&&/jpe?g/.test(v)&&(r.fillStyle="white",r.fillRect(0,0,e.width,e.height)),r.drawImage(g,0,0,e.width,e.height),e}function Ve(){return Ve.cachedResult!==void 0||(Ve.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&typeof document<"u"&&"ontouchend"in document),Ve.cachedResult}function Ge(g,v={}){return new Promise(function(t,n){let e,r;var c=function(){try{return r=kt(e,v.fileType||g.type),t([e,r])}catch(p){return n(p)}},s=function(p){try{var w=function(i){try{throw i}catch(a){return n(a)}};try{let i;return Ht(g).then(function(a){try{return i=a,Ot(i).then(function(o){try{return e=o,function(){try{return c()}catch(l){return n(l)}}()}catch(l){return w(l)}},w)}catch(o){return w(o)}},w)}catch(i){w(i)}}catch(i){return n(i)}};try{if(Ve()||[de.DESKTOP_SAFARI,de.MOBILE_SAFARI].includes(Ue()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(g).then(function(p){try{return e=p,c()}catch{return s()}},s)}catch{s()}})}function Qe(g,v,t,n,e=1){return new Promise(function(r,c){let s;if(v==="image/png"){let w,i,a;return w=g.getContext("2d"),{data:i}=w.getImageData(0,0,g.width,g.height),a=we.encode([i.buffer],g.width,g.height,4096*e),s=new Blob([a],{type:v}),s.name=t,s.lastModified=n,p.call(this)}{let w=function(){return p.call(this)};if(v==="image/bmp")return new Promise(i=>It.toBlob(g,i)).then((function(i){try{return s=i,s.name=t,s.lastModified=n,w.call(this)}catch(a){return c(a)}}).bind(this),c);{let i=function(){return w.call(this)};if(typeof OffscreenCanvas=="function"&&g instanceof OffscreenCanvas)return g.convertToBlob({type:v,quality:e}).then((function(a){try{return s=a,s.name=t,s.lastModified=n,i.call(this)}catch(o){return c(o)}}).bind(this),c);{let a;return a=g.toDataURL(v,e),ut(a,t,n).then((function(o){try{return s=o,i.call(this)}catch(l){return c(l)}}).bind(this),c)}}}function p(){return r(s)}})}function ye(g){g.width=0,g.height=0}function Pe(){return new Promise(function(g,v){let t,n,e,r;return Pe.cachedResult!==void 0?g(Pe.cachedResult):ut("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then(function(c){try{return t=c,Ge(t).then(function(s){try{return n=s[1],Qe(n,t.type,t.name,t.lastModified).then(function(p){try{return e=p,ye(n),Ge(e).then(function(w){try{return r=w[0],Pe.cachedResult=r.width===1&&r.height===2,g(Pe.cachedResult)}catch(i){return v(i)}},v)}catch(w){return v(w)}},v)}catch(p){return v(p)}},v)}catch(s){return v(s)}},v)})}function jt(g){return new Promise((v,t)=>{const n=new Lt;n.onload=e=>{const r=new DataView(e.target.result);if(r.getUint16(0,!1)!=65496)return v(-2);const c=r.byteLength;let s=2;for(;s<c;){if(r.getUint16(s+2,!1)<=8)return v(-1);const p=r.getUint16(s,!1);if(s+=2,p==65505){if(r.getUint32(s+=2,!1)!=1165519206)return v(-1);const w=r.getUint16(s+=6,!1)==18761;s+=r.getUint32(s+4,w);const i=r.getUint16(s,w);s+=2;for(let a=0;a<i;a++)if(r.getUint16(s+12*a,w)==274)return v(r.getUint16(s+12*a+8,w))}else{if((65280&p)!=65280)break;s+=r.getUint16(s,!1)}}return v(-1)},n.onerror=e=>t(e),n.readAsArrayBuffer(g)})}function Wt(g,v){const{width:t}=g,{height:n}=g,{maxWidthOrHeight:e}=v;let r,c=g;return isFinite(e)&&(t>e||n>e)&&([c,r]=Ye(t,n),t>n?(c.width=e,c.height=n/t*e):(c.width=t/n*e,c.height=e),r.drawImage(g,0,0,c.width,c.height),ye(g)),c}function Vt(g,v){const{width:t}=g,{height:n}=g,[e,r]=Ye(t,n);switch(v>4&&v<9?(e.width=n,e.height=t):(e.width=t,e.height=n),v){case 2:r.transform(-1,0,0,1,t,0);break;case 3:r.transform(-1,0,0,-1,t,n);break;case 4:r.transform(1,0,0,-1,0,n);break;case 5:r.transform(0,1,1,0,0,0);break;case 6:r.transform(0,1,-1,0,n,0);break;case 7:r.transform(0,-1,-1,0,n,t);break;case 8:r.transform(0,-1,1,0,0,t)}return r.drawImage(g,0,0,t,n),ye(g),e}function xt(g,v,t=0){return new Promise(function(n,e){let r,c,s,p,w,i,a,o,l,m,E,F,C,H,z,U,I,b,P,h;function u(x=5){if(v.signal&&v.signal.aborted)throw v.signal.reason;r+=x,v.onProgress(Math.min(r,100))}function y(x){if(v.signal&&v.signal.aborted)throw v.signal.reason;r=Math.min(Math.max(x,r),100),v.onProgress(r)}return r=t,c=v.maxIteration||10,s=1024*v.maxSizeMB*1024,u(),Ge(g,v).then((function(x){try{return[,p]=x,u(),w=Wt(p,v),u(),new Promise(function(S,_){var A;if(!(A=v.exifOrientation))return jt(g).then((function(d){try{return A=d,M.call(this)}catch(f){return _(f)}}).bind(this),_);function M(){return S(A)}return M.call(this)}).then((function(S){try{return i=S,u(),Pe().then((function(_){try{return a=_?w:Vt(w,i),u(),o=v.initialQuality||1,l=v.fileType||g.type,Qe(a,l,g.name,g.lastModified,o).then((function(A){try{{let d=function(){if(c--&&(z>s||z>C)){let T,R;return T=h?.95*P.width:P.width,R=h?.95*P.height:P.height,[I,b]=Ye(T,R),b.drawImage(P,0,0,T,R),o*=l==="image/png"?.85:.95,Qe(I,l,g.name,g.lastModified,o).then(function(L){try{return U=L,ye(P),P=I,z=U.size,y(Math.min(99,Math.floor((H-z)/(H-s)*100))),d}catch(j){return e(j)}},e)}return[1]},f=function(){return ye(P),ye(I),ye(w),ye(a),ye(p),y(100),n(U)};if(m=A,u(),E=m.size>s,F=m.size>g.size,!E&&!F)return y(100),n(m);var M;return C=g.size,H=m.size,z=H,P=a,h=!v.alwaysKeepResolution&&E,(M=(function(T){for(;T;){if(T.then)return void T.then(M,e);try{if(T.pop){if(T.length)return T.pop()?f.call(this):T;T=d}else T=T.call(this)}catch(R){return e(R)}}}).bind(this))(d)}}catch(d){return e(d)}}).bind(this),e)}catch(A){return e(A)}}).bind(this),e)}catch(_){return e(_)}}).bind(this),e)}catch(S){return e(S)}}).bind(this),e)})}const Hr=`
let scriptImported = false
self.addEventListener('message', async (e) => {
  const { file, id, imageCompressionLibUrl, options } = e.data
  options.onProgress = (progress) => self.postMessage({ progress, id })
  try {
    if (!scriptImported) {
      // console.log('[worker] importScripts', imageCompressionLibUrl)
      self.importScripts(imageCompressionLibUrl)
      scriptImported = true
    }
    // console.log('[worker] self', self)
    const compressedFile = await imageCompression(file, options)
    self.postMessage({ file: compressedFile, id })
  } catch (e) {
    // console.error('[worker] error', e)
    self.postMessage({ error: e.message + '\\n' + e.stack, id })
  }
})
`;let et;function Or(g,v){return new Promise((t,n)=>{et||(et=function(c){const s=[];return typeof c=="function"?s.push(`(${c})()`):s.push(c),URL.createObjectURL(new Blob(s))}(Hr));const e=new Worker(et);e.addEventListener("message",function(c){if(v.signal&&v.signal.aborted)e.terminate();else if(c.data.progress===void 0){if(c.data.error)return n(new Error(c.data.error)),void e.terminate();t(c.data.file),e.terminate()}else v.onProgress(c.data.progress)}),e.addEventListener("error",n),v.signal&&v.signal.addEventListener("abort",()=>{n(v.signal.reason),e.terminate()}),e.postMessage({file:g,imageCompressionLibUrl:v.libURL,options:{...v,onProgress:void 0,signal:void 0}})})}function le(g,v){return new Promise(function(t,n){let e,r,c,s,p,w;if(e={...v},c=0,{onProgress:s}=e,e.maxSizeMB=e.maxSizeMB||Number.POSITIVE_INFINITY,p=typeof e.useWebWorker!="boolean"||e.useWebWorker,delete e.useWebWorker,e.onProgress=l=>{c=l,typeof s=="function"&&s(c)},!(g instanceof Blob||g instanceof Lr))return n(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(g.type))return n(new Error("The file given is not an image"));if(w=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!p||typeof Worker!="function"||w)return xt(g,e).then((function(l){try{return r=l,o.call(this)}catch(m){return n(m)}}).bind(this),n);var i=(function(){try{return o.call(this)}catch(l){return n(l)}}).bind(this),a=function(l){try{return xt(g,e).then(function(m){try{return r=m,i()}catch(E){return n(E)}},n)}catch(m){return n(m)}};try{return e.libURL=e.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",Or(g,e).then(function(l){try{return r=l,i()}catch{return a()}},a)}catch{a()}function o(){try{r.name=g.name,r.lastModified=g.lastModified}catch{}try{e.preserveExif&&g.type==="image/jpeg"&&(!e.fileType||e.fileType&&e.fileType===g.type)&&(r=zt(g,r))}catch{}return t(r)}})}le.getDataUrlFromFile=Ht,le.getFilefromDataUrl=ut,le.loadImage=Ot,le.drawImageInCanvas=kt,le.drawFileInCanvas=Ge,le.canvasToFile=Qe,le.getExifOrientation=jt,le.handleMaxWidthOrHeight=Wt,le.followExifOrientation=Vt,le.cleanupCanvasMemory=ye,le.isAutoOrientationInBrowser=Pe,le.approximateBelowMaximumCanvasSizeOfBrowser=Nt,le.copyExifWithoutOrientation=zt,le.getBrowserName=Ue,le.version="2.0.2";function Nr({maxSizeMB:g=1,maxWidthOrHeight:v=1920}={}){const[t,n]=te.useState(!1);return{compressImage:async r=>{if(!r||!r.type.startsWith("image/"))return r;try{n(!0);const c=await le(r,{maxSizeMB:g,maxWidthOrHeight:v,useWebWorker:!0,fileType:r.type});return new File([c],r.name,{type:r.type})}catch(c){return console.error("Image compression failed:",c),r}finally{n(!1)}},loading:t}}const St=g=>Object.keys(g).map(v=>g[v]),kr=["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","jpg","jpeg","png","gif","bmp","webp","tiff","svg","zip","rar","7z","tar","gz","rtf","json","mp4","mov","avi","mkv","flv","wmv","webm","m4v","ics","ppt","PPT","pptx","PPTX"],jr=g=>{var t;const v=(t=g.name.split(".").pop())==null?void 0:t.toLowerCase();return kr.includes(v||"")},Wr=te.forwardRef((g,v)=>{const{accept:t,beforeUpload:n,disabled:e=!1,draggable:r=!1,fileList:c=[],multiple:s,onChange:p,onFileRemove:w,showList:i=!0,tip:a,uploadLimit:o,children:l,className:m,field:E,aspectRatio:F=2,objectFit:C="horizontal-cover",cropNeeded:H=!0,...z}=g,U=te.useRef(null),[I,b]=te.useState(c),[P,h]=te.useState(!1),[u,y]=te.useState(!1),[x,S]=te.useState(null),[_,A]=te.useState(null),[M,d]=te.useState({x:0,y:0}),[f,T]=te.useState(1),[R,L]=te.useState(null),{compressImage:j,loading:N}=Nr(),{themeColor:k,primaryColorLevel:O}=Yt();te.useEffect(()=>{JSON.stringify(I)!==JSON.stringify(c)&&b(c)},[c]);const D=(Z="")=>{$t.push(G.jsx(Jt,{type:"danger",duration:2e3,children:Z||"Upload Failed!"}),{placement:"top-center"})},V=(Z,W)=>{if(Z)for(const B of Array.from(Z))W.push(B);return W},q=Z=>{let W=Kt(I);return typeof o=="number"&&o!==0&&Object.keys(W).length>=o?(o===1&&(W.shift(),W=V(Z,W)),St({...W})):(W=V(Z,W),St({...W}))},Y=async Z=>{const{files:W}=Z.target,B=W==null?void 0:W[0];let ne=!0;if(n){if(ne=n(W,I),ne===!1){D();return}if(typeof ne=="string"&&ne.length>0){D(ne);return}}if(!(B&&jr(B))){D("Executable or unsafe file types are not allowed.");return}let X=B;if(B&&B.type.startsWith("image/")){if(X=await j(B),H){const ge=new FileReader;ge.onloadend=()=>{S(ge.result),y(!0),L(X)},ge.readAsDataURL(X);return}const se=q([X]);b(se),p==null||p(se,I);return}if(ne){const se=q(W);b(se),p==null||p(se,I)}},Q=Z=>{const W=I.filter((B,ne)=>ne!==Z);b(W),w==null||w(W)},K=Z=>{var W;e||(W=U.current)==null||W.click(),Z.stopPropagation()},re=()=>!r&&!l?G.jsx($e,{disabled:e,onClick:Z=>Z.preventDefault(),children:"Upload"}):r&&!l?G.jsx("span",{children:"Choose a file or drag and drop here"}):l,oe=te.useCallback(()=>{r&&h(!1)},[r]),Ae=te.useCallback(()=>{r&&!e&&h(!0)},[r,e]),pe=te.useCallback(()=>{r&&h(!1)},[r]),ee={onDragLeave:oe,onDragOver:Ae,onDrop:pe},ae=`border-${k}-${O}`,J=pt("upload",r&&"upload-draggable",r&&!e&&`hover:${ae}`,r&&e&&"disabled",P&&ae,m),$=pt("upload-input",r&&"draggable");return G.jsxs(G.Fragment,{children:[G.jsxs("div",{ref:v,className:J,...r?ee:{onClick:K},...z,children:[G.jsx("input",{ref:U,className:$,type:"file",disabled:e,multiple:s,accept:t,title:"",value:"",onChange:Y,...E,...z}),re()]}),a,i&&G.jsx("div",{className:"upload-file-list",children:I.map((Z,W)=>G.jsx(Et,{file:Z,children:G.jsx(qt,{className:"upload-file-remove",onClick:()=>Q(W)})},Z.name+W))}),G.jsx(Gt,{open:u,onClose:()=>y(!1),children:G.jsx("div",{className:"fixed inset-0 flex justify-center items-center bg-black bg-opacity-70 z-50",children:G.jsxs("div",{className:"bg-white p-4 rounded-lg w-[90vw] max-w-md",children:[G.jsx("div",{className:"relative w-full h-64",children:G.jsx(Fr,{image:x,crop:M,zoom:f,aspect:F,onCropChange:d,onZoomChange:T,objectFit:C,onCropComplete:(Z,W)=>A(W)})}),G.jsx(Qt,{value:f,min:1,max:3,step:.1,onChange:(Z,W)=>T(W)}),G.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[G.jsx($e,{onClick:()=>y(!1),children:"Cancel"}),G.jsx($e,{onClick:async()=>{const Z=await Ur(x,_),W=new File([Z],R.name,{type:R.type}),B=q({0:W,length:1,item:ne=>W});b(B),p==null||p(B,I),y(!1)},children:"Crop"})]})]})})})]})});Wr.displayName="Upload";export{Wr as U};
