UNPKG

dgz-ui-shared

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library

11 lines 137 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../MyInput-3qarivly.cjs"),Bs=require("../../MySelect-PTD5YCMn.cjs"),L=require("../../jsx-runtime-DUiatUiq.cjs"),It=require("../../popover-DDxpKohG-lwQEtZjs.cjs"),Us=require("../../check-DE-1lGDl-C_ZPlJ0c.cjs"),He=require("../../timepicker-CVwZY2bQ-BCnAd1SD.cjs"),Vs=require("../../dayjs.min-BoFVZSwB.cjs"),ve=require("../../utils-D0f6bOsw-BmDOeWKv.cjs"),js=require("../../createLucideIcon-BnAj0RnC.cjs"),_t=require("react"),Ee=require("../../select-BehdTDP2-DZ8kbyVp.cjs");/** * @license lucide-react v0.511.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hs=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],qs=js.createLucideIcon("calendar",Hs),Ys=({control:e,name:t,label:n,helperText:s,required:r,rules:a,format:i=He.no,placeholder:l})=>{const o=n&&L.jsxRuntimeExports.jsxs(w.cf,{className:"my-3 text-body-xs-medium",children:[n," ",r&&L.jsxRuntimeExports.jsx("span",{className:"text-red-600",children:"*"})]});return L.jsxRuntimeExports.jsx(L.jsxRuntimeExports.Fragment,{children:t&&e&&L.jsxRuntimeExports.jsx(w.Gf,{control:e,name:t,rules:a,render:({field:d,formState:c})=>L.jsxRuntimeExports.jsxs(w.lf,{className:"flex flex-col relative",children:[o,L.jsxRuntimeExports.jsxs(It.Oe,{children:[L.jsxRuntimeExports.jsx(It._e,{asChild:!0,children:L.jsxRuntimeExports.jsx(w.uf,{children:L.jsxRuntimeExports.jsxs(Us.u,{variant:"secondary",className:ve.mo("pl-3 mb-0 text-left text-secondary !text-body-sm-regular font-normal border-alpha-strong bg-transparent hover:bg-transparent focus:ring-item-primary",w.lodashExports.get(c.errors,`${t}`)&&"focus:ring-item-destructive border-item-destructive bg-item-destructive-focus text-item-destructive hover:bg-item-destructive-focus dark:bg-transparent",d.value&&"text-primary"),children:[d.value?Vs.dayjs$1(d.value).format(i):l&&l,L.jsxRuntimeExports.jsx(qs,{className:"ml-auto h-4 w-4"})]})})}),L.jsxRuntimeExports.jsx(It.ue,{className:"w-auto p-0",align:"start",children:L.jsxRuntimeExports.jsx(He.Gs,{mode:"single",selected:d.value,onSelect:E=>d.onChange(E?new Date(E):void 0),disabled:E=>E>new Date||E<new Date("1900-01-01")})})]}),L.jsxRuntimeExports.jsx(w.df,{children:s}),L.jsxRuntimeExports.jsx("div",{className:"relative",children:L.jsxRuntimeExports.jsx(w.ff,{})})]})})})},Ws=({control:e,name:t,label:n,rules:s,helperText:r,...a})=>t&&e?L.jsxRuntimeExports.jsx(w.Gf,{control:e,name:t,rules:s,render:({field:i})=>L.jsxRuntimeExports.jsxs(w.lf,{className:"flex flex-row items-start space-x-3",children:[L.jsxRuntimeExports.jsx(w.uf,{children:L.jsxRuntimeExports.jsx(w.Ro,{checked:i.value,onCheckedChange:i.onChange,...a})}),L.jsxRuntimeExports.jsxs("div",{className:"space-y-1 leading-none",children:[n&&L.jsxRuntimeExports.jsx(w.cf,{children:n}),L.jsxRuntimeExports.jsx(w.df,{children:r})]})]})}):L.jsxRuntimeExports.jsxs("div",{className:"flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4",children:[L.jsxRuntimeExports.jsx(w.Ro,{...a}),L.jsxRuntimeExports.jsxs("div",{className:"space-y-1 leading-none",children:[n&&L.jsxRuntimeExports.jsx(w.cf,{children:n}),L.jsxRuntimeExports.jsx(w.df,{children:r})]})]}),$s=({control:e,name:t,label:n,helperText:s,rules:r,...a})=>t&&e?L.jsxRuntimeExports.jsx(w.Gf,{control:e,name:t,rules:r,render:({field:i})=>L.jsxRuntimeExports.jsxs(w.lf,{className:"flex items-center gap-2",children:[L.jsxRuntimeExports.jsx(w.uf,{children:L.jsxRuntimeExports.jsx(w._f,{className:"m-0",checked:i.value,onCheckedChange:i.onChange,...a})}),L.jsxRuntimeExports.jsxs("div",{className:"space-y-1 leading-none mb-1",children:[n&&L.jsxRuntimeExports.jsx(w.cf,{className:ve.mo("text-primary",a.disabled&&"opacity-40"),children:n}),L.jsxRuntimeExports.jsx(w.df,{children:s})]})]})}):L.jsxRuntimeExports.jsxs("div",{className:"flex flex-row items-center space-x-3",children:[L.jsxRuntimeExports.jsx(w._f,{...a}),L.jsxRuntimeExports.jsxs("div",{className:"space-y-1 leading-none mb-1",children:[n&&L.jsxRuntimeExports.jsx(w.cf,{className:ve.mo("text-primary",a.disabled&&"opacity-40"),children:n}),L.jsxRuntimeExports.jsx(w.df,{children:s})]})]});/*! * FilePond 4.32.8 * Licensed under MIT, https://opensource.org/licenses/MIT/ * Please visit https://pqina.nl/filepond/ for details. */const zs=e=>e instanceof HTMLElement,ks=(e,t=[],n=[])=>{const s={...e},r=[],a=[],i=()=>({...s}),l=()=>{const u=[...r];return r.length=0,u},o=()=>{const u=[...a];a.length=0,u.forEach(({type:I,data:T})=>{d(I,T)})},d=(u,I,T)=>{if(T&&!document.hidden){a.push({type:u,data:I});return}p[u]&&p[u](I),r.push({type:u,data:I})},c=(u,...I)=>m[u]?m[u](...I):null,E={getState:i,processActionQueue:l,processDispatchQueue:o,dispatch:d,query:c};let m={};t.forEach(u=>{m={...u(s),...m}});let p={};return n.forEach(u=>{p={...u(d,c,s),...p}}),E},Xs=(e,t,n)=>{if(typeof n=="function"){e[t]=n;return}Object.defineProperty(e,t,{...n})},q=(e,t)=>{for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])},ge=e=>{const t={};return q(e,n=>{Xs(t,n,e[n])}),t},z=(e,t,n=null)=>{if(n===null)return e.getAttribute(t)||e.hasAttribute(t);e.setAttribute(t,n)},Zs="http://www.w3.org/2000/svg",Qs=["svg","path"],Xt=e=>Qs.includes(e),rt=(e,t,n={})=>{typeof t=="object"&&(n=t,t=null);const s=Xt(e)?document.createElementNS(Zs,e):document.createElement(e);return t&&(Xt(e)?z(s,"class",t):s.className=t),q(n,(r,a)=>{z(s,r,a)}),s},Ks=e=>(t,n)=>{typeof n<"u"&&e.children[n]?e.insertBefore(t,e.children[n]):e.appendChild(t)},Js=(e,t)=>(n,s)=>(typeof s<"u"?t.splice(s,0,n):t.push(n),n),er=(e,t)=>n=>(t.splice(t.indexOf(n),1),n.element.parentNode&&e.removeChild(n.element),n),tr=typeof window<"u"&&typeof window.document<"u",$n=()=>tr,nr=$n()?rt("svg"):{},sr="children"in nr?e=>e.children.length:e=>e.childNodes.length,zn=(e,t,n,s)=>{const r=n[0]||e.left,a=n[1]||e.top,i=r+e.width,l=a+e.height*(s[1]||1),o={element:{...e},inner:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},outer:{left:r,top:a,right:i,bottom:l}};return t.filter(d=>!d.isRectIgnored()).map(d=>d.rect).forEach(d=>{Zt(o.inner,{...d.inner}),Zt(o.outer,{...d.outer})}),Qt(o.inner),o.outer.bottom+=o.element.marginBottom,o.outer.right+=o.element.marginRight,Qt(o.outer),o},Zt=(e,t)=>{t.top+=e.top,t.right+=e.left,t.bottom+=e.top,t.left+=e.left,t.bottom>e.bottom&&(e.bottom=t.bottom),t.right>e.right&&(e.right=t.right)},Qt=e=>{e.width=e.right-e.left,e.height=e.bottom-e.top},Re=e=>typeof e=="number",rr=(e,t,n,s=.001)=>Math.abs(e-t)<s&&Math.abs(n)<s,ir=({stiffness:e=.5,damping:t=.75,mass:n=10}={})=>{let s=null,r=null,a=0,i=!1;const d=ge({interpolate:(c,E)=>{if(i)return;if(!(Re(s)&&Re(r))){i=!0,a=0;return}const m=-(r-s)*e;a+=m/n,r+=a,a*=t,rr(r,s,a)||E?(r=s,a=0,i=!0,d.onupdate(r),d.oncomplete(r)):d.onupdate(r)},target:{set:c=>{if(Re(c)&&!Re(r)&&(r=c),s===null&&(s=c,r=c),s=c,r===s||typeof s>"u"){i=!0,a=0,d.onupdate(r),d.oncomplete(r);return}i=!1},get:()=>s},resting:{get:()=>i},onupdate:c=>{},oncomplete:c=>{}});return d},ar=e=>e<.5?2*e*e:-1+(4-2*e)*e,or=({duration:e=500,easing:t=ar,delay:n=0}={})=>{let s=null,r,a,i=!0,l=!1,o=null;const c=ge({interpolate:(E,m)=>{i||o===null||(s===null&&(s=E),!(E-s<n)&&(r=E-s-n,r>=e||m?(r=1,a=l?0:1,c.onupdate(a*o),c.oncomplete(a*o),i=!0):(a=r/e,c.onupdate((r>=0?t(l?1-a:a):0)*o))))},target:{get:()=>l?0:o,set:E=>{if(o===null){o=E,c.onupdate(E),c.oncomplete(E);return}E<o?(o=1,l=!0):(l=!1,o=E),i=!1,s=null}},resting:{get:()=>i},onupdate:E=>{},oncomplete:E=>{}});return c},Kt={spring:ir,tween:or},lr=(e,t,n)=>{const s=e[t]&&typeof e[t][n]=="object"?e[t][n]:e[t]||e,r=typeof s=="string"?s:s.type,a=typeof s=="object"?{...s}:{};return Kt[r]?Kt[r](a):null},Gt=(e,t,n,s=!1)=>{t=Array.isArray(t)?t:[t],t.forEach(r=>{e.forEach(a=>{let i=a,l=()=>n[a],o=d=>n[a]=d;typeof a=="object"&&(i=a.key,l=a.getter||l,o=a.setter||o),!(r[i]&&!s)&&(r[i]={get:l,set:o})})})},cr=({mixinConfig:e,viewProps:t,viewInternalAPI:n,viewExternalAPI:s})=>{const r={...t},a=[];return q(e,(i,l)=>{const o=lr(l);if(!o)return;o.onupdate=c=>{t[i]=c},o.target=r[i],Gt([{key:i,setter:c=>{o.target!==c&&(o.target=c)},getter:()=>t[i]}],[n,s],t,!0),a.push(o)}),{write:i=>{let l=document.hidden,o=!0;return a.forEach(d=>{d.resting||(o=!1),d.interpolate(i,l)}),o},destroy:()=>{}}},dr=e=>(t,n)=>{e.addEventListener(t,n)},ur=e=>(t,n)=>{e.removeEventListener(t,n)},Er=({mixinConfig:e,viewProps:t,viewInternalAPI:n,viewExternalAPI:s,viewState:r,view:a})=>{const i=[],l=dr(a.element),o=ur(a.element);return s.on=(d,c)=>{i.push({type:d,fn:c}),l(d,c)},s.off=(d,c)=>{i.splice(i.findIndex(E=>E.type===d&&E.fn===c),1),o(d,c)},{write:()=>!0,destroy:()=>{i.forEach(d=>{o(d.type,d.fn)})}}},fr=({mixinConfig:e,viewProps:t,viewExternalAPI:n})=>{Gt(e,n,t)},Q=e=>e!=null,pr={opacity:1,scaleX:1,scaleY:1,translateX:0,translateY:0,rotateX:0,rotateY:0,rotateZ:0,originX:0,originY:0},mr=({mixinConfig:e,viewProps:t,viewInternalAPI:n,viewExternalAPI:s,view:r})=>{const a={...t},i={};Gt(e,[n,s],t);const l=()=>[t.translateX||0,t.translateY||0],o=()=>[t.scaleX||0,t.scaleY||0],d=()=>r.rect?zn(r.rect,r.childViews,l(),o()):null;return n.rect={get:d},s.rect={get:d},e.forEach(c=>{t[c]=typeof a[c]>"u"?pr[c]:a[c]}),{write:()=>{if(Ir(i,t))return _r(r.element,t),Object.assign(i,{...t}),!0},destroy:()=>{}}},Ir=(e,t)=>{if(Object.keys(e).length!==Object.keys(t).length)return!0;for(const n in t)if(t[n]!==e[n])return!0;return!1},_r=(e,{opacity:t,perspective:n,translateX:s,translateY:r,scaleX:a,scaleY:i,rotateX:l,rotateY:o,rotateZ:d,originX:c,originY:E,width:m,height:p})=>{let u="",I="";(Q(c)||Q(E))&&(I+=`transform-origin: ${c||0}px ${E||0}px;`),Q(n)&&(u+=`perspective(${n}px) `),(Q(s)||Q(r))&&(u+=`translate3d(${s||0}px, ${r||0}px, 0) `),(Q(a)||Q(i))&&(u+=`scale3d(${Q(a)?a:1}, ${Q(i)?i:1}, 1) `),Q(d)&&(u+=`rotateZ(${d}rad) `),Q(l)&&(u+=`rotateX(${l}rad) `),Q(o)&&(u+=`rotateY(${o}rad) `),u.length&&(I+=`transform:${u};`),Q(t)&&(I+=`opacity:${t};`,t===0&&(I+="visibility:hidden;"),t<1&&(I+="pointer-events:none;")),Q(p)&&(I+=`height:${p}px;`),Q(m)&&(I+=`width:${m}px;`);const T=e.elementCurrentStyle||"";(I.length!==T.length||I!==T)&&(e.style.cssText=I,e.elementCurrentStyle=I)},Tr={styles:mr,listeners:Er,animations:cr,apis:fr},Jt=(e={},t={},n={})=>(t.layoutCalculated||(e.paddingTop=parseInt(n.paddingTop,10)||0,e.marginTop=parseInt(n.marginTop,10)||0,e.marginRight=parseInt(n.marginRight,10)||0,e.marginBottom=parseInt(n.marginBottom,10)||0,e.marginLeft=parseInt(n.marginLeft,10)||0,t.layoutCalculated=!0),e.left=t.offsetLeft||0,e.top=t.offsetTop||0,e.width=t.offsetWidth||0,e.height=t.offsetHeight||0,e.right=e.left+e.width,e.bottom=e.top+e.height,e.scrollTop=t.scrollTop,e.hidden=t.offsetParent===null,e),$=({tag:e="div",name:t=null,attributes:n={},read:s=()=>{},write:r=()=>{},create:a=()=>{},destroy:i=()=>{},filterFrameActionsForChild:l=(p,u)=>u,didCreateView:o=()=>{},didWriteView:d=()=>{},ignoreRect:c=!1,ignoreRectUpdate:E=!1,mixins:m=[]}={})=>(p,u={})=>{const I=rt(e,`filepond--${t}`,n),T=window.getComputedStyle(I,null),h=Jt();let f=null,_=!1;const R=[],S=[],M={},x={},D=[r],P=[s],G=[i],C=()=>I,b=()=>R.concat(),j=()=>M,A=V=>(Z,me)=>Z(V,me),U=()=>f||(f=zn(h,R,[0,0],[1,1]),f),O=()=>T,y=()=>{f=null,R.forEach(me=>me._read()),!(E&&h.width&&h.height)&&Jt(h,I,T);const Z={root:le,props:u,rect:h};P.forEach(me=>me(Z))},N=(V,Z,me)=>{let Pe=Z.length===0;return D.forEach(ee=>{ee({props:u,root:le,actions:Z,timestamp:V,shouldOptimize:me})===!1&&(Pe=!1)}),S.forEach(ee=>{ee.write(V)===!1&&(Pe=!1)}),R.filter(ee=>!!ee.element.parentNode).forEach(ee=>{ee._write(V,l(ee,Z),me)||(Pe=!1)}),R.forEach((ee,ze)=>{ee.element.parentNode||(le.appendChild(ee.element,ze),ee._read(),ee._write(V,l(ee,Z),me),Pe=!1)}),_=Pe,d({props:u,root:le,actions:Z,timestamp:V}),Pe},v=()=>{S.forEach(V=>V.destroy()),G.forEach(V=>{V({root:le,props:u})}),R.forEach(V=>V._destroy())},H={element:{get:C},style:{get:O},childViews:{get:b}},B={...H,rect:{get:U},ref:{get:j},is:V=>t===V,appendChild:Ks(I),createChildView:A(p),linkView:V=>(R.push(V),V),unlinkView:V=>{R.splice(R.indexOf(V),1)},appendChildView:Js(I,R),removeChildView:er(I,R),registerWriter:V=>D.push(V),registerReader:V=>P.push(V),registerDestroyer:V=>G.push(V),invalidateLayout:()=>I.layoutCalculated=!1,dispatch:p.dispatch,query:p.query},he={element:{get:C},childViews:{get:b},rect:{get:U},resting:{get:()=>_},isRectIgnored:()=>c,_read:y,_write:N,_destroy:v},Be={...H,rect:{get:()=>h}};Object.keys(m).sort((V,Z)=>V==="styles"?1:Z==="styles"?-1:0).forEach(V=>{const Z=Tr[V]({mixinConfig:m[V],viewProps:u,viewState:x,viewInternalAPI:B,viewExternalAPI:he,view:ge(Be)});Z&&S.push(Z)});const le=ge(B);a({root:le,props:u});const mt=sr(I);return R.forEach((V,Z)=>{le.appendChild(V.element,mt+Z)}),o(le),ge(he)},gr=(e,t,n=60)=>{const s="__framePainter";if(window[s]){window[s].readers.push(e),window[s].writers.push(t);return}window[s]={readers:[e],writers:[t]};const r=window[s],a=1e3/n;let i=null,l=null,o=null,d=null;const c=()=>{document.hidden?(o=()=>window.setTimeout(()=>E(performance.now()),a),d=()=>window.clearTimeout(l)):(o=()=>window.requestAnimationFrame(E),d=()=>window.cancelAnimationFrame(l))};document.addEventListener("visibilitychange",()=>{d&&d(),c(),E(performance.now())});const E=m=>{l=o(E),i||(i=m);const p=m-i;p<=a||(i=m-p%a,r.readers.forEach(u=>u()),r.writers.forEach(u=>u(m)))};return c(),E(performance.now()),{pause:()=>{d(l)}}},J=(e,t)=>({root:n,props:s,actions:r=[],timestamp:a,shouldOptimize:i})=>{r.filter(l=>e[l.type]).forEach(l=>e[l.type]({root:n,props:s,action:l.data,timestamp:a,shouldOptimize:i})),t&&t({root:n,props:s,actions:r,timestamp:a,shouldOptimize:i})},en=(e,t)=>t.parentNode.insertBefore(e,t),tn=(e,t)=>t.parentNode.insertBefore(e,t.nextSibling),lt=e=>Array.isArray(e),Ie=e=>e==null,hr=e=>e.trim(),ct=e=>""+e,Rr=(e,t=",")=>Ie(e)?[]:lt(e)?e:ct(e).split(t).map(hr).filter(n=>n.length),kn=e=>typeof e=="boolean",Xn=e=>kn(e)?e:e==="true",K=e=>typeof e=="string",Zn=e=>Re(e)?e:K(e)?ct(e).replace(/[a-z]+/gi,""):0,nt=e=>parseInt(Zn(e),10),nn=e=>parseFloat(Zn(e)),Fe=e=>Re(e)&&isFinite(e)&&Math.floor(e)===e,sn=(e,t=1e3)=>{if(Fe(e))return e;let n=ct(e).trim();return/MB$/i.test(n)?(n=n.replace(/MB$i/,"").trim(),nt(n)*t*t):/KB/i.test(n)?(n=n.replace(/KB$i/,"").trim(),nt(n)*t):nt(n)},Oe=e=>typeof e=="function",Or=e=>{let t=self,n=e.split("."),s=null;for(;s=n.shift();)if(t=t[s],!t)return null;return t},rn={process:"POST",patch:"PATCH",revert:"DELETE",fetch:"GET",restore:"GET",load:"GET"},Sr=e=>{const t={};return t.url=K(e)?e:e.url||"",t.timeout=e.timeout?parseInt(e.timeout,10):0,t.headers=e.headers?e.headers:{},q(rn,n=>{t[n]=Dr(n,e[n],rn[n],t.timeout,t.headers)}),t.process=e.process||K(e)||e.url?t.process:null,t.remove=e.remove||null,delete t.headers,t},Dr=(e,t,n,s,r)=>{if(t===null)return null;if(typeof t=="function")return t;const a={url:n==="GET"||n==="PATCH"?`?${e}=`:"",method:n,headers:r,withCredentials:!1,timeout:s,onload:null,ondata:null,onerror:null};if(K(t))return a.url=t,a;if(Object.assign(a,t),K(a.headers)){const i=a.headers.split(/:(.+)/);a.headers={header:i[0],value:i[1]}}return a.withCredentials=Xn(a.withCredentials),a},yr=e=>Sr(e),Ar=e=>e===null,X=e=>typeof e=="object"&&e!==null,Mr=e=>X(e)&&K(e.url)&&X(e.process)&&X(e.revert)&&X(e.restore)&&X(e.fetch),At=e=>lt(e)?"array":Ar(e)?"null":Fe(e)?"int":/^[0-9]+ ?(?:GB|MB|KB)$/gi.test(e)?"bytes":Mr(e)?"api":typeof e,Lr=e=>e.replace(/{\s*'/g,'{"').replace(/'\s*}/g,'"}').replace(/'\s*:/g,'":').replace(/:\s*'/g,':"').replace(/,\s*'/g,',"').replace(/'\s*,/g,'",'),wr={array:Rr,boolean:Xn,int:e=>At(e)==="bytes"?sn(e):nt(e),number:nn,float:nn,bytes:sn,string:e=>Oe(e)?e:ct(e),function:e=>Or(e),serverapi:yr,object:e=>{try{return JSON.parse(Lr(e))}catch{return null}}},Pr=(e,t)=>wr[t](e),Qn=(e,t,n)=>{if(e===t)return e;let s=At(e);if(s!==n){const r=Pr(e,n);if(s=At(r),r===null)throw`Trying to assign value with incorrect type to "${option}", allowed type: "${n}"`;e=r}return e},Cr=(e,t)=>{let n=e;return{enumerable:!0,get:()=>n,set:s=>{n=Qn(s,e,t)}}},br=e=>{const t={};return q(e,n=>{const s=e[n];t[n]=Cr(s[0],s[1])}),ge(t)},Nr=e=>({items:[],listUpdateTimeout:null,itemUpdateTimeout:null,processingQueue:[],options:br(e)}),dt=(e,t="-")=>e.split(/(?=[A-Z])/).map(n=>n.toLowerCase()).join(t),xr=(e,t)=>{const n={};return q(t,s=>{n[s]={get:()=>e.getState().options[s],set:r=>{e.dispatch(`SET_${dt(s,"_").toUpperCase()}`,{value:r})}}}),n},vr=e=>(t,n,s)=>{const r={};return q(e,a=>{const i=dt(a,"_").toUpperCase();r[`SET_${i}`]=l=>{try{s.options[a]=l.value}catch{}t(`DID_SET_${i}`,{value:s.options[a]})}}),r},Gr=e=>t=>{const n={};return q(e,s=>{n[`GET_${dt(s,"_").toUpperCase()}`]=r=>t.options[s]}),n},oe={API:1,DROP:2,BROWSE:3,PASTE:4,NONE:5},Ft=()=>Math.random().toString(36).substring(2,11),Bt=(e,t)=>e.splice(t,1),Fr=(e,t)=>{t?e():document.hidden?Promise.resolve(1).then(e):setTimeout(e,0)},ut=()=>{const e=[],t=(s,r)=>{Bt(e,e.findIndex(a=>a.event===s&&(a.cb===r||!r)))},n=(s,r,a)=>{e.filter(i=>i.event===s).map(i=>i.cb).forEach(i=>Fr(()=>i(...r),a))};return{fireSync:(s,...r)=>{n(s,r,!0)},fire:(s,...r)=>{n(s,r,!1)},on:(s,r)=>{e.push({event:s,cb:r})},onOnce:(s,r)=>{e.push({event:s,cb:(...a)=>{t(s,r),r(...a)}})},off:t}},Kn=(e,t,n)=>{Object.getOwnPropertyNames(e).filter(s=>!n.includes(s)).forEach(s=>Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s)))},Br=["fire","process","revert","load","on","off","onOnce","retryLoad","extend","archive","archived","release","released","requestProcessing","freeze"],te=e=>{const t={};return Kn(e,t,Br),t},Ur=e=>{e.forEach((t,n)=>{t.released&&Bt(e,n)})},F={INIT:1,IDLE:2,PROCESSING_QUEUED:9,PROCESSING:3,PROCESSING_COMPLETE:5,PROCESSING_ERROR:6,PROCESSING_REVERT_ERROR:10,LOADING:7,LOAD_ERROR:8},k={INPUT:1,LIMBO:2,LOCAL:3},Jn=e=>/[^0-9]+/.exec(e),es=()=>Jn(1.1.toLocaleString())[0],Vr=()=>{const e=es(),t=1e3.toLocaleString();return t!=="1000"?Jn(t)[0]:e==="."?",":"."},g={BOOLEAN:"boolean",INT:"int",NUMBER:"number",STRING:"string",ARRAY:"array",OBJECT:"object",FUNCTION:"function",ACTION:"action",SERVER_API:"serverapi",REGEX:"regex"},Ut=[],ce=(e,t,n)=>new Promise((s,r)=>{const a=Ut.filter(l=>l.key===e).map(l=>l.cb);if(a.length===0){s(t);return}const i=a.shift();a.reduce((l,o)=>l.then(d=>o(d,n)),i(t,n)).then(l=>s(l)).catch(l=>r(l))}),Le=(e,t,n)=>Ut.filter(s=>s.key===e).map(s=>s.cb(t,n)),jr=(e,t)=>Ut.push({key:e,cb:t}),Hr=e=>Object.assign(Ce,e),it=()=>({...Ce}),qr=e=>{q(e,(t,n)=>{Ce[t]&&(Ce[t][0]=Qn(n,Ce[t][0],Ce[t][1]))})},Ce={id:[null,g.STRING],name:["filepond",g.STRING],disabled:[!1,g.BOOLEAN],className:[null,g.STRING],required:[!1,g.BOOLEAN],captureMethod:[null,g.STRING],allowSyncAcceptAttribute:[!0,g.BOOLEAN],allowDrop:[!0,g.BOOLEAN],allowBrowse:[!0,g.BOOLEAN],allowPaste:[!0,g.BOOLEAN],allowMultiple:[!1,g.BOOLEAN],allowReplace:[!0,g.BOOLEAN],allowRevert:[!0,g.BOOLEAN],allowRemove:[!0,g.BOOLEAN],allowProcess:[!0,g.BOOLEAN],allowReorder:[!1,g.BOOLEAN],allowDirectoriesOnly:[!1,g.BOOLEAN],storeAsFile:[!1,g.BOOLEAN],forceRevert:[!1,g.BOOLEAN],maxFiles:[null,g.INT],checkValidity:[!1,g.BOOLEAN],itemInsertLocationFreedom:[!0,g.BOOLEAN],itemInsertLocation:["before",g.STRING],itemInsertInterval:[75,g.INT],dropOnPage:[!1,g.BOOLEAN],dropOnElement:[!0,g.BOOLEAN],dropValidation:[!1,g.BOOLEAN],ignoredFiles:[[".ds_store","thumbs.db","desktop.ini"],g.ARRAY],instantUpload:[!0,g.BOOLEAN],maxParallelUploads:[2,g.INT],allowMinimumUploadDuration:[!0,g.BOOLEAN],chunkUploads:[!1,g.BOOLEAN],chunkForce:[!1,g.BOOLEAN],chunkSize:[5e6,g.INT],chunkRetryDelays:[[500,1e3,3e3],g.ARRAY],server:[null,g.SERVER_API],fileSizeBase:[1e3,g.INT],labelFileSizeBytes:["bytes",g.STRING],labelFileSizeKilobytes:["KB",g.STRING],labelFileSizeMegabytes:["MB",g.STRING],labelFileSizeGigabytes:["GB",g.STRING],labelDecimalSeparator:[es(),g.STRING],labelThousandsSeparator:[Vr(),g.STRING],labelIdle:['Drag & Drop your files or <span class="filepond--label-action">Browse</span>',g.STRING],labelInvalidField:["Field contains invalid files",g.STRING],labelFileWaitingForSize:["Waiting for size",g.STRING],labelFileSizeNotAvailable:["Size not available",g.STRING],labelFileCountSingular:["file in list",g.STRING],labelFileCountPlural:["files in list",g.STRING],labelFileLoading:["Loading",g.STRING],labelFileAdded:["Added",g.STRING],labelFileLoadError:["Error during load",g.STRING],labelFileRemoved:["Removed",g.STRING],labelFileRemoveError:["Error during remove",g.STRING],labelFileProcessing:["Uploading",g.STRING],labelFileProcessingComplete:["Upload complete",g.STRING],labelFileProcessingAborted:["Upload cancelled",g.STRING],labelFileProcessingError:["Error during upload",g.STRING],labelFileProcessingRevertError:["Error during revert",g.STRING],labelTapToCancel:["tap to cancel",g.STRING],labelTapToRetry:["tap to retry",g.STRING],labelTapToUndo:["tap to undo",g.STRING],labelButtonRemoveItem:["Remove",g.STRING],labelButtonAbortItemLoad:["Abort",g.STRING],labelButtonRetryItemLoad:["Retry",g.STRING],labelButtonAbortItemProcessing:["Cancel",g.STRING],labelButtonUndoItemProcessing:["Undo",g.STRING],labelButtonRetryItemProcessing:["Retry",g.STRING],labelButtonProcessItem:["Upload",g.STRING],iconRemove:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M11.586 13l-2.293 2.293a1 1 0 0 0 1.414 1.414L13 14.414l2.293 2.293a1 1 0 0 0 1.414-1.414L14.414 13l2.293-2.293a1 1 0 0 0-1.414-1.414L13 11.586l-2.293-2.293a1 1 0 0 0-1.414 1.414L11.586 13z" fill="currentColor" fill-rule="nonzero"/></svg>',g.STRING],iconProcess:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M14 10.414v3.585a1 1 0 0 1-2 0v-3.585l-1.293 1.293a1 1 0 0 1-1.414-1.415l3-3a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1-1.414 1.415L14 10.414zM9 18a1 1 0 0 1 0-2h8a1 1 0 0 1 0 2H9z" fill="currentColor" fill-rule="evenodd"/></svg>',g.STRING],iconRetry:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M10.81 9.185l-.038.02A4.997 4.997 0 0 0 8 13.683a5 5 0 0 0 5 5 5 5 0 0 0 5-5 1 1 0 0 1 2 0A7 7 0 1 1 9.722 7.496l-.842-.21a.999.999 0 1 1 .484-1.94l3.23.806c.535.133.86.675.73 1.21l-.804 3.233a.997.997 0 0 1-1.21.73.997.997 0 0 1-.73-1.21l.23-.928v-.002z" fill="currentColor" fill-rule="nonzero"/></svg>',g.STRING],iconUndo:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M9.185 10.81l.02-.038A4.997 4.997 0 0 1 13.683 8a5 5 0 0 1 5 5 5 5 0 0 1-5 5 1 1 0 0 0 0 2A7 7 0 1 0 7.496 9.722l-.21-.842a.999.999 0 1 0-1.94.484l.806 3.23c.133.535.675.86 1.21.73l3.233-.803a.997.997 0 0 0 .73-1.21.997.997 0 0 0-1.21-.73l-.928.23-.002-.001z" fill="currentColor" fill-rule="nonzero"/></svg>',g.STRING],iconDone:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M18.293 9.293a1 1 0 0 1 1.414 1.414l-7.002 7a1 1 0 0 1-1.414 0l-3.998-4a1 1 0 1 1 1.414-1.414L12 15.586l6.294-6.293z" fill="currentColor" fill-rule="nonzero"/></svg>',g.STRING],oninit:[null,g.FUNCTION],onwarning:[null,g.FUNCTION],onerror:[null,g.FUNCTION],onactivatefile:[null,g.FUNCTION],oninitfile:[null,g.FUNCTION],onaddfilestart:[null,g.FUNCTION],onaddfileprogress:[null,g.FUNCTION],onaddfile:[null,g.FUNCTION],onprocessfilestart:[null,g.FUNCTION],onprocessfileprogress:[null,g.FUNCTION],onprocessfileabort:[null,g.FUNCTION],onprocessfilerevert:[null,g.FUNCTION],onprocessfile:[null,g.FUNCTION],onprocessfiles:[null,g.FUNCTION],onremovefile:[null,g.FUNCTION],onpreparefile:[null,g.FUNCTION],onupdatefiles:[null,g.FUNCTION],onreorderfiles:[null,g.FUNCTION],beforeDropFile:[null,g.FUNCTION],beforeAddFile:[null,g.FUNCTION],beforeRemoveFile:[null,g.FUNCTION],beforePrepareFile:[null,g.FUNCTION],stylePanelLayout:[null,g.STRING],stylePanelAspectRatio:[null,g.STRING],styleItemPanelAspectRatio:[null,g.STRING],styleButtonRemoveItemPosition:["left",g.STRING],styleButtonProcessItemPosition:["right",g.STRING],styleLoadIndicatorPosition:["right",g.STRING],styleProgressIndicatorPosition:["right",g.STRING],styleButtonRemoveItemAlign:[!1,g.BOOLEAN],files:[[],g.ARRAY],credits:[["https://pqina.nl/","Powered by PQINA"],g.ARRAY]},Se=(e,t)=>Ie(t)?e[0]||null:Fe(t)?e[t]||null:(typeof t=="object"&&(t=t.id),e.find(n=>n.id===t)||null),ts=e=>{if(Ie(e))return e;if(/:/.test(e)){const t=e.split(":");return t[1]/t[0]}return parseFloat(e)},de=e=>e.filter(t=>!t.archived),Yr={EMPTY:0,IDLE:1,ERROR:2,BUSY:3,READY:4};let ke=null;const Wr=()=>{if(ke===null)try{const e=new DataTransfer;e.items.add(new File(["hello world"],"This_Works.txt"));const t=document.createElement("input");t.setAttribute("type","file"),t.files=e.files,ke=t.files.length===1}catch{ke=!1}return ke},$r=[F.LOAD_ERROR,F.PROCESSING_ERROR,F.PROCESSING_REVERT_ERROR],zr=[F.LOADING,F.PROCESSING,F.PROCESSING_QUEUED,F.INIT],kr=[F.PROCESSING_COMPLETE],Xr=e=>$r.includes(e.status),Zr=e=>zr.includes(e.status),Qr=e=>kr.includes(e.status),an=e=>X(e.options.server)&&(X(e.options.server.process)||Oe(e.options.server.process)),Kr=e=>({GET_STATUS:()=>{const t=de(e.items),{EMPTY:n,ERROR:s,BUSY:r,IDLE:a,READY:i}=Yr;return t.length===0?n:t.some(Xr)?s:t.some(Zr)?r:t.some(Qr)?i:a},GET_ITEM:t=>Se(e.items,t),GET_ACTIVE_ITEM:t=>Se(de(e.items),t),GET_ACTIVE_ITEMS:()=>de(e.items),GET_ITEMS:()=>e.items,GET_ITEM_NAME:t=>{const n=Se(e.items,t);return n?n.filename:null},GET_ITEM_SIZE:t=>{const n=Se(e.items,t);return n?n.fileSize:null},GET_STYLES:()=>Object.keys(e.options).filter(t=>/^style/.test(t)).map(t=>({name:t,value:e.options[t]})),GET_PANEL_ASPECT_RATIO:()=>/circle/.test(e.options.stylePanelLayout)?1:ts(e.options.stylePanelAspectRatio),GET_ITEM_PANEL_ASPECT_RATIO:()=>e.options.styleItemPanelAspectRatio,GET_ITEMS_BY_STATUS:t=>de(e.items).filter(n=>n.status===t),GET_TOTAL_ITEMS:()=>de(e.items).length,SHOULD_UPDATE_FILE_INPUT:()=>e.options.storeAsFile&&Wr()&&!an(e),IS_ASYNC:()=>an(e),GET_FILE_SIZE_LABELS:t=>({labelBytes:t("GET_LABEL_FILE_SIZE_BYTES")||void 0,labelKilobytes:t("GET_LABEL_FILE_SIZE_KILOBYTES")||void 0,labelMegabytes:t("GET_LABEL_FILE_SIZE_MEGABYTES")||void 0,labelGigabytes:t("GET_LABEL_FILE_SIZE_GIGABYTES")||void 0})}),Jr=e=>{const t=de(e.items).length;if(!e.options.allowMultiple)return t===0;const n=e.options.maxFiles;return n===null||t<n},ns=(e,t,n)=>Math.max(Math.min(n,e),t),ei=(e,t,n)=>e.splice(t,0,n),ti=(e,t,n)=>Ie(t)?null:typeof n>"u"?(e.push(t),t):(n=ns(n,0,e.length),ei(e,n,t),t),Mt=e=>/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i.test(e),$e=e=>`${e}`.split("/").pop().split("?").shift(),Et=e=>e.split(".").pop(),ni=e=>{if(typeof e!="string")return"";const t=e.split("/").pop();return/svg/.test(t)?"svg":/zip|compressed/.test(t)?"zip":/plain/.test(t)?"txt":/msword/.test(t)?"doc":/[a-z]+/.test(t)?t==="jpeg"?"jpg":t:""},Ue=(e,t="")=>(t+e).slice(-t.length),ss=(e=new Date)=>`${e.getFullYear()}-${Ue(e.getMonth()+1,"00")}-${Ue(e.getDate(),"00")}_${Ue(e.getHours(),"00")}-${Ue(e.getMinutes(),"00")}-${Ue(e.getSeconds(),"00")}`,Ge=(e,t,n=null,s=null)=>{const r=typeof n=="string"?e.slice(0,e.size,n):e.slice(0,e.size,e.type);return r.lastModifiedDate=new Date,e._relativePath&&(r._relativePath=e._relativePath),K(t)||(t=ss()),t&&s===null&&Et(t)?r.name=t:(s=s||ni(r.type),r.name=t+(s?"."+s:"")),r},si=()=>window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,rs=(e,t)=>{const n=si();if(n){const s=new n;return s.append(e),s.getBlob(t)}return new Blob([e],{type:t})},ri=(e,t)=>{const n=new ArrayBuffer(e.length),s=new Uint8Array(n);for(let r=0;r<e.length;r++)s[r]=e.charCodeAt(r);return rs(n,t)},is=e=>(/^data:(.+);/.exec(e)||[])[1]||null,ii=e=>e.split(",")[1].replace(/\s/g,""),ai=e=>atob(ii(e)),oi=e=>{const t=is(e),n=ai(e);return ri(n,t)},li=(e,t,n)=>Ge(oi(e),t,null,n),ci=e=>{if(!/^content-disposition:/i.test(e))return null;const t=e.split(/filename=|filename\*=.+''/).splice(1).map(n=>n.trim().replace(/^["']|[;"']{0,2}$/g,"")).filter(n=>n.length);return t.length?decodeURI(t[t.length-1]):null},di=e=>{if(/content-length:/i.test(e)){const t=e.match(/[0-9]+/)[0];return t?parseInt(t,10):null}return null},ui=e=>/x-content-transfer-id:/i.test(e)&&(e.split(":")[1]||"").trim()||null,Vt=e=>{const t={source:null,name:null,size:null},n=e.split(` `);for(let s of n){const r=ci(s);if(r){t.name=r;continue}const a=di(s);if(a){t.size=a;continue}const i=ui(s);if(i){t.source=i;continue}}return t},Ei=e=>{const t={source:null,complete:!1,progress:0,size:null,timestamp:null,duration:0,request:null},n=()=>t.progress,s=()=>{t.request&&t.request.abort&&t.request.abort()},r=()=>{const l=t.source;i.fire("init",l),l instanceof File?i.fire("load",l):l instanceof Blob?i.fire("load",Ge(l,l.name)):Mt(l)?i.fire("load",li(l)):a(l)},a=l=>{if(!e){i.fire("error",{type:"error",body:"Can't load URL",code:400});return}t.timestamp=Date.now(),t.request=e(l,o=>{t.duration=Date.now()-t.timestamp,t.complete=!0,o instanceof Blob&&(o=Ge(o,o.name||$e(l))),i.fire("load",o instanceof Blob?o:o?o.body:null)},o=>{i.fire("error",typeof o=="string"?{type:"error",code:0,body:o}:o)},(o,d,c)=>{if(c&&(t.size=c),t.duration=Date.now()-t.timestamp,!o){t.progress=null;return}t.progress=d/c,i.fire("progress",t.progress)},()=>{i.fire("abort")},o=>{const d=Vt(typeof o=="string"?o:o.headers);i.fire("meta",{size:t.size||d.size,filename:d.name,source:d.source})})},i={...ut(),setSource:l=>t.source=l,getProgress:n,abort:s,load:r};return i},on=e=>/GET|HEAD/.test(e),De=(e,t,n)=>{const s={onheaders:()=>{},onprogress:()=>{},onload:()=>{},ontimeout:()=>{},onerror:()=>{},onabort:()=>{},abort:()=>{r=!0,i.abort()}};let r=!1,a=!1;n={method:"POST",headers:{},withCredentials:!1,...n},t=encodeURI(t),on(n.method)&&e&&(t=`${t}${encodeURIComponent(typeof e=="string"?e:JSON.stringify(e))}`);const i=new XMLHttpRequest,l=on(n.method)?i:i.upload;return l.onprogress=o=>{r||s.onprogress(o.lengthComputable,o.loaded,o.total)},i.onreadystatechange=()=>{i.readyState<2||i.readyState===4&&i.status===0||a||(a=!0,s.onheaders(i))},i.onload=()=>{i.status>=200&&i.status<300?s.onload(i):s.onerror(i)},i.onerror=()=>s.onerror(i),i.onabort=()=>{r=!0,s.onabort()},i.ontimeout=()=>s.ontimeout(i),i.open(n.method,t,!0),Fe(n.timeout)&&(i.timeout=n.timeout),Object.keys(n.headers).forEach(o=>{const d=unescape(encodeURIComponent(n.headers[o]));i.setRequestHeader(o,d)}),n.responseType&&(i.responseType=n.responseType),n.withCredentials&&(i.withCredentials=!0),i.send(e),s},Y=(e,t,n,s)=>({type:e,code:t,body:n,headers:s}),ye=e=>t=>{e(Y("error",0,"Timeout",t.getAllResponseHeaders()))},ln=e=>/\?/.test(e),qe=(...e)=>{let t="";return e.forEach(n=>{t+=ln(t)&&ln(n)?n.replace(/\?/,"&"):n}),t},Tt=(e="",t)=>{if(typeof t=="function")return t;if(!t||!K(t.url))return null;const n=t.onload||(r=>r),s=t.onerror||(r=>null);return(r,a,i,l,o,d)=>{const c=De(r,qe(e,t.url),{...t,responseType:"blob"});return c.onload=E=>{const m=E.getAllResponseHeaders(),p=Vt(m).name||$e(r);a(Y("load",E.status,t.method==="HEAD"?null:Ge(n(E.response),p),m))},c.onerror=E=>{i(Y("error",E.status,s(E.response)||E.statusText,E.getAllResponseHeaders()))},c.onheaders=E=>{d(Y("headers",E.status,null,E.getAllResponseHeaders()))},c.ontimeout=ye(i),c.onprogress=l,c.onabort=o,c}},re={QUEUED:0,COMPLETE:1,PROCESSING:2,ERROR:3,WAITING:4},fi=(e,t,n,s,r,a,i,l,o,d,c)=>{const E=[],{chunkTransferId:m,chunkServer:p,chunkSize:u,chunkRetryDelays:I}=c,T={serverId:m,aborted:!1},h=t.ondata||(A=>A),f=t.onload||((A,U)=>U==="HEAD"?A.getResponseHeader("Upload-Offset"):A.response),_=t.onerror||(A=>null),R=A=>{const U=new FormData;X(r)&&U.append(n,JSON.stringify(r));const O=typeof t.headers=="function"?t.headers(s,r):{...t.headers,"Upload-Length":s.size},y={...t,headers:O},N=De(h(U),qe(e,t.url),y);N.onload=v=>A(f(v,y.method)),N.onerror=v=>i(Y("error",v.status,_(v.response)||v.statusText,v.getAllResponseHeaders())),N.ontimeout=ye(i)},S=A=>{const U=qe(e,p.url,T.serverId),y={headers:typeof t.headers=="function"?t.headers(T.serverId):{...t.headers},method:"HEAD"},N=De(null,U,y);N.onload=v=>A(f(v,y.method)),N.onerror=v=>i(Y("error",v.status,_(v.response)||v.statusText,v.getAllResponseHeaders())),N.ontimeout=ye(i)},M=Math.floor(s.size/u);for(let A=0;A<=M;A++){const U=A*u,O=s.slice(U,U+u,"application/offset+octet-stream");E[A]={index:A,size:O.size,offset:U,data:O,file:s,progress:0,retries:[...I],status:re.QUEUED,error:null,request:null,timeout:null}}const x=()=>a(T.serverId),D=A=>A.status===re.QUEUED||A.status===re.ERROR,P=A=>{if(T.aborted)return;if(A=A||E.find(D),!A){E.every(B=>B.status===re.COMPLETE)&&x();return}A.status=re.PROCESSING,A.progress=null;const U=p.ondata||(B=>B),O=p.onerror||(B=>null),y=p.onload||(()=>{}),N=qe(e,p.url,T.serverId),v=typeof p.headers=="function"?p.headers(A):{...p.headers,"Content-Type":"application/offset+octet-stream","Upload-Offset":A.offset,"Upload-Length":s.size,"Upload-Name":s.name},H=A.request=De(U(A.data),N,{...p,headers:v});H.onload=B=>{y(B,A.index,E.length),A.status=re.COMPLETE,A.request=null,b()},H.onprogress=(B,he,Be)=>{A.progress=B?he:null,C()},H.onerror=B=>{A.status=re.ERROR,A.request=null,A.error=O(B.response)||B.statusText,G(A)||i(Y("error",B.status,O(B.response)||B.statusText,B.getAllResponseHeaders()))},H.ontimeout=B=>{A.status=re.ERROR,A.request=null,G(A)||ye(i)(B)},H.onabort=()=>{A.status=re.QUEUED,A.request=null,o()}},G=A=>A.retries.length===0?!1:(A.status=re.WAITING,clearTimeout(A.timeout),A.timeout=setTimeout(()=>{P(A)},A.retries.shift()),!0),C=()=>{const A=E.reduce((O,y)=>O===null||y.progress===null?null:O+y.progress,0);if(A===null)return l(!1,0,0);const U=E.reduce((O,y)=>O+y.size,0);l(!0,A,U)},b=()=>{E.filter(U=>U.status===re.PROCESSING).length>=1||P()},j=()=>{E.forEach(A=>{clearTimeout(A.timeout),A.request&&A.request.abort()})};return T.serverId?S(A=>{T.aborted||(E.filter(U=>U.offset<A).forEach(U=>{U.status=re.COMPLETE,U.progress=U.size}),b())}):R(A=>{T.aborted||(d(A),T.serverId=A,b())}),{abort:()=>{T.aborted=!0,j()}}},pi=(e,t,n,s)=>(r,a,i,l,o,d,c)=>{if(!r)return;const E=s.chunkUploads,m=E&&r.size>s.chunkSize,p=E&&(m||s.chunkForce);if(r instanceof Blob&&p)return fi(e,t,n,r,a,i,l,o,d,c,s);const u=t.ondata||(S=>S),I=t.onload||(S=>S),T=t.onerror||(S=>null),h=typeof t.headers=="function"?t.headers(r,a)||{}:{...t.headers},f={...t,headers:h};var _=new FormData;X(a)&&_.append(n,JSON.stringify(a)),(r instanceof Blob?[{name:null,file:r}]:r).forEach(S=>{_.append(n,S.file,S.name===null?S.file.name:`${S.name}${S.file.name}`)});const R=De(u(_),qe(e,t.url),f);return R.onload=S=>{i(Y("load",S.status,I(S.response),S.getAllResponseHeaders()))},R.onerror=S=>{l(Y("error",S.status,T(S.response)||S.statusText,S.getAllResponseHeaders()))},R.ontimeout=ye(l),R.onprogress=o,R.onabort=d,R},mi=(e="",t,n,s)=>typeof t=="function"?(...r)=>t(n,...r,s):!t||!K(t.url)?null:pi(e,t,n,s),Ve=(e="",t)=>{if(typeof t=="function")return t;if(!t||!K(t.url))return(r,a)=>a();const n=t.onload||(r=>r),s=t.onerror||(r=>null);return(r,a,i)=>{const l=De(r,e+t.url,t);return l.onload=o=>{a(Y("load",o.status,n(o.response),o.getAllResponseHeaders()))},l.onerror=o=>{i(Y("error",o.status,s(o.response)||o.statusText,o.getAllResponseHeaders()))},l.ontimeout=ye(i),l}},as=(e=0,t=1)=>e+Math.random()*(t-e),Ii=(e,t=1e3,n=0,s=25,r=250)=>{let a=null;const i=Date.now(),l=()=>{let o=Date.now()-i,d=as(s,r);o+d>t&&(d=o+d-t);let c=o/t;if(c>=1||document.hidden){e(1);return}e(c),a=setTimeout(l,d)};return t>0&&l(),{clear:()=>{clearTimeout(a)}}},_i=(e,t)=>{const n={complete:!1,perceivedProgress:0,perceivedPerformanceUpdater:null,progress:null,timestamp:null,perceivedDuration:0,duration:0,request:null,response:null},{allowMinimumUploadDuration:s}=t,r=(c,E)=>{const m=()=>{n.duration===0||n.progress===null||d.fire("progress",d.getProgress())},p=()=>{n.complete=!0,d.fire("load-perceived",n.response.body)};d.fire("start"),n.timestamp=Date.now(),n.perceivedPerformanceUpdater=Ii(u=>{n.perceivedProgress=u,n.perceivedDuration=Date.now()-n.timestamp,m(),n.response&&n.perceivedProgress===1&&!n.complete&&p()},s?as(750,1500):0),n.request=e(c,E,u=>{n.response=X(u)?u:{type:"load",code:200,body:`${u}`,headers:{}},n.duration=Date.now()-n.timestamp,n.progress=1,d.fire("load",n.response.body),(!s||s&&n.perceivedProgress===1)&&p()},u=>{n.perceivedPerformanceUpdater.clear(),d.fire("error",X(u)?u:{type:"error",code:0,body:`${u}`})},(u,I,T)=>{n.duration=Date.now()-n.timestamp,n.progress=u?I/T:null,m()},()=>{n.perceivedPerformanceUpdater.clear(),d.fire("abort",n.response?n.response.body:null)},u=>{d.fire("transfer",u)})},a=()=>{n.request&&(n.perceivedPerformanceUpdater.clear(),n.request.abort&&n.request.abort(),n.complete=!0)},i=()=>{a(),n.complete=!1,n.perceivedProgress=0,n.progress=0,n.timestamp=null,n.perceivedDuration=0,n.duration=0,n.request=null,n.response=null},l=s?()=>n.progress?Math.min(n.progress,n.perceivedProgress):null:()=>n.progress||null,o=s?()=>Math.min(n.duration,n.perceivedDuration):()=>n.duration,d={...ut(),process:r,abort:a,getProgress:l,getDuration:o,reset:i};return d},os=e=>e.substring(0,e.lastIndexOf("."))||e,Ti=e=>{let t=[e.name,e.size,e.type];return e instanceof Blob||Mt(e)?t[0]=e.name||ss():Mt(e)?(t[1]=e.length,t[2]=is(e)):K(e)&&(t[0]=$e(e),t[1]=0,t[2]="application/octet-stream"),{name:t[0],size:t[1],type:t[2]}},Ae=e=>!!(e instanceof File||e instanceof Blob&&e.name),ls=e=>{if(!X(e))return e;const t=lt(e)?[]:{};for(const n in e){if(!e.hasOwnProperty(n))continue;const s=e[n];t[n]=s&&X(s)?ls(s):s}return t},gi=(e=null,t=null,n=null)=>{const s=Ft(),r={archived:!1,frozen:!1,released:!1,source:null,file:n,serverFileReference:t,transferId:null,processingAborted:!1,status:t?F.PROCESSING_COMPLETE:F.INIT,activeLoader:null,activeProcessor:null};let a=null;const i={},l=D=>r.status=D,o=(D,...P)=>{r.released||r.frozen||M.fire(D,...P)},d=()=>Et(r.file.name),c=()=>r.file.type,E=()=>r.file.size,m=()=>r.file,p=(D,P,G)=>{if(r.source=D,M.fireSync("init"),r.file){M.fireSync("load-skip");return}r.file=Ti(D),P.on("init",()=>{o("load-init")}),P.on("meta",C=>{r.file.size=C.size,r.file.filename=C.filename,C.source&&(e=k.LIMBO,r.serverFileReference=C.source,r.status=F.PROCESSING_COMPLETE),o("load-meta")}),P.on("progress",C=>{l(F.LOADING),o("load-progress",C)}),P.on("error",C=>{l(F.LOAD_ERROR),o("load-request-error",C)}),P.on("abort",()=>{l(F.INIT),o("load-abort")}),P.on("load",C=>{r.activeLoader=null;const b=A=>{r.file=Ae(A)?A:r.file,e===k.LIMBO&&r.serverFileReference?l(F.PROCESSING_COMPLETE):l(F.IDLE),o("load")},j=A=>{r.file=C,o("load-meta"),l(F.LOAD_ERROR),o("load-file-error",A)};if(r.serverFileReference){b(C);return}G(C,b,j)}),P.setSource(D),r.activeLoader=P,P.load()},u=()=>{r.activeLoader&&r.activeLoader.load()},I=()=>{if(r.activeLoader){r.activeLoader.abort();return}l(F.INIT),o("load-abort")},T=(D,P)=>{if(r.processingAborted){r.processingAborted=!1;return}if(l(F.PROCESSING),a=null,!(r.file instanceof Blob)){M.on("load",()=>{T(D,P)});return}D.on("load",b=>{r.transferId=null,r.serverFileReference=b}),D.on("transfer",b=>{r.transferId=b}),D.on("load-perceived",b=>{r.activeProcessor=null,r.transferId=null,r.serverFileReference=b,l(F.PROCESSING_COMPLETE),o("process-complete",b)}),D.on("start",()=>{o("process-start")}),D.on("error",b=>{r.activeProcessor=null,l(F.PROCESSING_ERROR),o("process-error",b)}),D.on("abort",b=>{r.activeProcessor=null,r.serverFileReference=b,l(F.IDLE),o("process-abort"),a&&a()}),D.on("progress",b=>{o("process-progress",b)});const G=b=>{r.archived||D.process(b,{...i})},C=console.error;P(r.file,G,C),r.activeProcessor=D},h=()=>{r.processingAborted=!1,l(F.PROCESSING_QUEUED)},f=()=>new Promise(D=>{if(!r.activeProcessor){r.processingAborted=!0,l(F.IDLE),o("process-abort"),D();return}a=()=>{D()},r.activeProcessor.abort()}),_=(D,P)=>new Promise((G,C)=>{const b=r.serverFileReference!==null?r.serverFileReference:r.transferId;if(b===null){G();return}D(b,()=>{r.serverFileReference=null,r.transferId=null,G()},j=>{if(!P){G();return}l(F.PROCESSING_REVERT_ERROR),o("process-revert-error"),C(j)}),l(F.IDLE),o("process-revert")}),R=(D,P,G)=>{const C=D.split("."),b=C[0],j=C.pop();let A=i;C.forEach(U=>A=A[U]),JSON.stringify(A[j])!==JSON.stringify(P)&&(A[j]=P,o("metadata-update",{key:b,value:i[b],silent:G}))},M={id:{get:()=>s},origin:{get:()=>e,set:D=>e=D},serverId:{get:()=>r.serverFileReference},transferId:{get:()=>r.transferId},status:{get:()=>r.status},filename:{get:()=>r.file.name},filenameWithoutExtension:{get:()=>os(r.file.name)},fileExtension:{get:d},fileType:{get:c},fileSize:{get:E},file:{get:m},relativePath:{get:()=>r.file._relativePath},source:{get:()=>r.source},getMetadata:D=>ls(D?i[D]:i),setMetadata:(D,P,G)=>{if(X(D)){const C=D;return Object.keys(C).forEach(b=>{R(b,C[b],P)}),D}return R(D,P,G),P},extend:(D,P)=>x[D]=P,abortLoad:I,retryLoad:u,requestProcessing:h,abortProcessing:f,load:p,process:T,revert:_,...ut(),freeze:()=>r.frozen=!0,release:()=>r.released=!0,released:{get:()=>r.released},archive:()=>r.archived=!0,archived:{get:()=>r.archived},setFile:D=>r.file=D},x=ge(M);return x},hi=(e,t)=>Ie(t)?0:K(t)?e.findIndex(n=>n.id===t):-1,cn=(e,t)=>{const n=hi(e,t);if(!(n<0))return e[n]||null},dn=(e,t,n,s,r,a)=>{const i=De(null,e,{method:"GET",responseType:"blob"});return i.onload=l=>{const o=l.getAllResponseHeaders(),d=Vt(o).name||$e(e);t(Y("load",l.status,Ge(l.response,d),o))},i.onerror=l=>{n(Y("error",l.status,l.statusText,l.getAllResponseHeaders()))},i.onheaders=l=>{a(Y("headers",l.status,null,l.getAllResponseHeaders()))},i.ontimeout=ye(n),i.onprogress=s,i.onabort=r,i},un=e=>(e.indexOf("//")===0&&(e=location.protocol+e),e.toLowerCase().replace("blob:","").replace(/([a-z])?:\/\//,"$1").split("/")[0]),Ri=e=>(e.indexOf(":")>-1||e.indexOf("//")>-1)&&un(location.href)!==un(e),Xe=e=>(...t)=>Oe(e)?e(...t):e,Oi=e=>!Ae(e.file),gt=(e,t)=>{clearTimeout(t.listUpdateTimeout),t.listUpdateTimeout=setTimeout(()=>{e("DID_UPDATE_ITEMS",{items:de(t.items)})},0)},En=(e,...t)=>new Promise(n=>{if(!e)return n(!0);const s=e(...t);if(s==null)return n(!0);if(typeof s=="boolean")return n(s);typeof s.then=="function"&&s.then(n)}),ht=(e,t)=>{e.items.sort((n,s)=>t(te(n),te(s)))},ie=(e,t)=>({query:n,success:s=()=>{},failure:r=()=>{},...a}={})=>{const i=Se(e.items,n);if(!i){r({error:Y("error",0,"Item not found"),file:null});return}t(i,s,r,a||{})},Si=(e,t,n)=>({ABORT_ALL:()=>{de(n.items).forEach(s=>{s.freeze(),s.abortLoad(),s.abortProcessing()})},DID_SET_FILES:({value:s=[]})=>{const r=s.map(i=>({source:i.source?i.source:i,options:i.options}));let a=de(n.items);a.forEach(i=>{r.find(l=>l.source===i.source||l.source===i.file)||e("REMOVE_ITEM",{query:i,remove:!1})}),a=de(n.items),r.forEach((i,l)=>{a.find(o=>o.source===i.source||o.file===i.source)||e("ADD_ITEM",{...i,interactionMethod:oe.NONE,index:l})})},DID_UPDATE_ITEM_METADATA:({id:s,action:r,change:a})=>{a.silent||(clearTimeout(n.itemUpdateTimeout),n.itemUpdateTimeout=setTimeout(()=>{const i=cn(n.items,s);if(!t("IS_ASYNC")){ce("SHOULD_PREPARE_OUTPUT",!1,{item:i,query:t,action:r,change:a}).then(c=>{const E=t("GET_BEFORE_PREPARE_FILE");E&&(c=E(i,c)),c&&e("REQUEST_PREPARE_OUTPUT",{query:s,item:i,success:m=>{e("DID_PREPARE_OUTPUT",{id:s,file:m})}},!0)});return}i.origin===k.LOCAL&&e("DID_LOAD_ITEM",{id:i.id,error:null,serverFileReference:i.source});const l=()=>{setTimeout(()=>{e("REQUEST_ITEM_PROCESSING",{query:s})},32)},o=c=>{i.revert(Ve(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")).then(c?l:()=>{}).catch(()=>{})},d=c=>{i.abortProcessing().then(c?l:()=>{})};if(i.status===F.PROCESSING_COMPLETE)return o(n.options.instantUpload);if(i.status===F.PROCESSING)return d(n.options.instantUpload);n.options.instantUpload&&l()},0))},MOVE_ITEM:({query:s,index:r})=>{const a=Se(n.items,s);if(!a)return;const i=n.items.indexOf(a);r=ns(r,0,n.items.length-1),i!==r&&n.items.splice(r,0,n.items.splice(i,1)[0])},SORT:({compare:s})=>{ht(n,s),e("DID_SORT_ITEMS",{items:t("GET_ACTIVE_ITEMS")})},ADD_ITEMS:({items:s,index:r,interactionMethod:a,success:i=()=>{},failure:l=()=>{}})=>{let o=r;if(r===-1||typeof r>"u"){const p=t("GET_ITEM_INSERT_LOCATION"),u=t("GET_TOTAL_ITEMS");o=p==="before"?0:u}const d=t("GET_IGNORED_FILES"),c=p=>Ae(p)?!d.includes(p.name.toLowerCase()):!Ie(p),m=s.filter(c).map(p=>new Promise((u,I)=>{e("ADD_ITEM",{interactionMethod:a,source:p.source||p,success:u,failure:I,index:o++,options:p.options||{}})}));Promise.all(m).then(i).catch(l)},ADD_ITEM:({source:s,index:r=-1,interactionMethod:a,success:i=()=>{},failure:l=()=>{},options:o={}})=>{if(Ie(s)){l({error:Y("error",0,"No source"),file:null});return}if(Ae(s)&&n.options.ignoredFiles.includes(s.name.toLowerCase()))return;if(!Jr(n)){if(n.options.allowMultiple||!n.options.allowMultiple&&!n.options.allowReplace){const f=Y("warning",0,"Max files");e("DID_THROW_MAX_FILES",{source:s,error:f}),l({error:f,file:null});return}const h=de(n.items)[0];if(h.status===F.PROCESSING_COMPLETE||h.status===F.PROCESSING_REVERT_ERROR){const f=t("GET_FORCE_REVERT");if(h.revert(Ve(n.options.server.url,n.options.server.revert),f).then(()=>{f&&e("ADD_ITEM",{source:s,index:r,interactionMethod:a,success:i,failure:l,options:o})}).catch(()=>{}),f)return}e("REMOVE_ITEM",{query:h.id})}const d=o.type==="local"?k.LOCAL:o.type==="limbo"?k.LIMBO:k.INPUT,c=gi(d,d===k.INPUT?null:s,o.file);Object.keys(o.metadata||{}).forEach(h=>{c.setMetadata(h,o.metadata[h])}),Le("DID_CREATE_ITEM",c,{query:t,dispatch:e});const E=t("GET_ITEM_INSERT_LOCATION");n.options.itemInsertLocationFreedom||(r=E==="before"?-1:n.items.length),ti(n.items,c,r),Oe(E)&&s&&ht(n,E);const m=c.id;c.on("init",()=>{e("DID_INIT_ITEM",{id:m})}),c.on("load-init",()=>{e("DID_START_ITEM_LOAD",{id:m})}),c.on("load-meta",()=>{e("DID_UPDATE_ITEM_META",{id:m})}),c.on("load-progress",h=>{e("DID_UPDATE_ITEM_LOAD_PROGRESS",{id:m,progress:h})}),c.on("load-request-error",h=>{const f=Xe(n.options.labelFileLoadError)(h);if(h.code>=400&&h.code<500){e("DID_THROW_ITEM_INVALID",{id:m,error:h,status:{main:f,sub:`${h.code} (${h.body})`}}),l({error:h,file:te(c)});return}e("DID_THROW_ITEM_LOAD_ERROR",{id:m,error:h,status:{main:f,sub:n.options.labelTapToRetry}})}),c.on("load-file-error",h=>{e("DID_THROW_ITEM_INVALID",{id:m,error:h.status,status:h.status}),l({error:h.status,file:te(c)})}),c.on("load-abort",()=>{e("REMOVE_ITEM",{query:m})}),c.on("load-skip",()=>{c.on("metadata-update",h=>{Ae(c.file)&&e("DID_UPDATE_ITEM_METADATA",{id:m,change:h})}),e("COMPLETE_LOAD_ITEM",{query:m,item:c,data:{source:s,success:i}})}),c.on("load",()=>{const h=f=>{if(!f){e("REMOVE_ITEM",{query:m});return}c.on("metadata-update",_=>{e("DID_UPDATE_ITEM_METADATA",{id:m,change:_})}),ce("SHOULD_PREPARE_OUTPUT",!1,{item:c,query:t}).then(_=>{const R=t("GET_BEFORE_PREPARE_FILE");R&&(_=R(c,_));const S=()=>{e("COMPLETE_LOAD_ITEM",{query:m,item:c,data:{source:s,success:i}}),gt(e,n)};if(_){e("REQUEST_PREPARE_OUTPUT",{query:m,item:c,success:M=>{e("DID_PREPARE_OUTPUT",{id:m,file:M}),S()}},!0);return}S()})};ce("DID_LOAD_ITEM",c,{query:t,dispatch:e}).then(()=>{En(t("GET_BEFORE_ADD_FILE"),te(c)).then(h)}).catch(f=>{if(!f||!f.error||!f.status)return h(!1);e("DID_THROW_ITEM_INVALID",{id:m,error:f.error,status:f.status})})}),c.on("process-start",()=>{e("DID_START_ITEM_PROCESSING",{id:m})}),c.on("process-progress",h=>{e("DID_UPDATE_ITEM_PROCESS_PROGRESS",{id:m,progress:h})}),c.on("process-error",h=>{e("DID_THROW_ITEM_PROCESSING_ERROR",{id:m,error:h,status:{main:Xe(n.options.labelFileProcessingError)(h),sub:n.options.labelTapToRetry}})}),c.on("process-revert-error",h=>{e("DID_THROW_ITEM_PROCESSING_REVERT_ERROR",{id:m,error:h,status:{main:Xe(n.options.labelFileProcessingRevertError)(h),sub:n.options.labelTapToRetry}})}),c.on("process-complete",h=>{e("DID_COMPLETE_ITEM_PROCESSING",{id:m,error:null,serverFileReference:h}),e("DID_DEFINE_VALUE",{id:m,value:h})}),c.on("process-abort",()=>{e("DID_ABORT_ITEM_PROCESSING",{id:m})}),c.on("process-revert",()=>{e("DID_REVERT_ITEM_PROCESSING",{id:m}),e("DID_DEFINE_VALUE",{id:m,value:null})}),e("DID_ADD_ITEM",{id:m,index:r,interactionMethod:a}),gt(e,n);const{url:p,load:u,restore:I,fetch:T}=n.options.server||{};c.load(s,Ei(d===k.INPUT?K(s)&&Ri(s)&&T?Tt(p,T):dn:d===k.LIMBO?Tt(p,I):Tt(p,u)),(h,f,_)=>{ce("LOAD_FILE",h,{query:t}).then(f).catch(_)})},REQUEST_PREPARE_OUTPUT:({item:s,success:r,failure:a=()=>{}})=>{const i={error:Y("error",0,"Item not found"),file:null};if(s.archived)return a(i);ce("PREPARE_OUTPUT",s.file,{query:t,item:s}).then(l=>{ce("COMPLETE_PREPARE_OUTPUT",l,{query:t,item:s}).then(o=>{if(s.archived)return a(i);r(o)})})},COMPLETE_LOAD_ITEM:({item:s,data:r})=>{const{success:a,source:i}=r,l=t("GET_ITEM_INSERT_LOCATION");if(Oe(l)&&i&&ht(n,l),e("DID_LOAD_ITEM",{id:s.id,error:null,serverFileReference:s.origin===k.INPUT?null:i}),a(te(s)),s.origin===k.LOCAL){e("DID_LOAD_LOCAL_ITEM",{id:s.id});return}if(s.origin===k.LIMBO){e("DID_COMPLETE_ITEM_PROCESSING",{id:s.id,error:null,serverFileReference:i}),e("DID_DEFINE_VALUE",{id:s.id,value:s.serverId||i});return}t("IS_ASYNC")&&n.options.instantUpload&&e("REQUEST_ITEM_PROCESSING",{query:s.id})},RETRY_ITEM_LOAD:ie(n,s=>{s.retryLoad()}),REQUEST_ITEM_PREPARE:ie(n,(s,r,a)=>{e("REQUEST_PREPARE_OUTPUT",{query:s.id,item:s,success:i=>{e("DID_PREPARE_OUTPUT",{id:s.id,file:i}),r({file:s,output:i})},failure:a},!0)}),REQUEST_ITEM_PROCESSING:ie(n,(s,r,a)=>{if(!(s.status===F.IDLE||s.status===F.PROCESSING_ERROR)){const l=()=>e("REQUEST_ITEM_PROCESSING",{query:s,success:r,failure:a}),o=()=>document.hidden?l():setTimeout(l,32);s.status===F.PROCESSING_COMPLETE||s.status===F.PROCESSING_REVERT_ERROR?s.revert(Ve(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")).then(o).catch(()=>{}):s.status===F.PROCESSING&&s.abortProcessing().then(o);return}s.status!==F.PROCESSING_QUEUED&&(s.requestProcessing(),e("DID_REQUEST_ITEM_PROCESSING",{id:s.id}),e("PROCESS_ITEM",{query:s,success:r,failure:a},!0))}),PROCESS_ITEM:ie(n,(s,r,a)=>{const i=t("GET_MAX_PARALLEL_UPLOADS");if(t("GET_ITEMS_BY_STATUS",F.PROCESSING).length===i){n.processingQueue.push({id:s.id,success:r,failure:a});return}if(s.status===F.PROCESSING)return;const o=()=>{const c=n.processingQueue.shift();if(!c)return;const{id:E,success:m,failure:p}=c,u=Se(n.items,E);i