"use strict";var W=Object.defineProperty;var E=(k,g)=>W(k,"name",{value:g,configurable:!0});exports.id=713;exports.ids=[713];exports.modules={1713:(k,g,y)=>{y.r(g),y.d(g,{toFormData:()=>K});var C=y(749),M=y(9951);let D=0;const t={START_BOUNDARY:D++,HEADER_FIELD_START:D++,HEADER_FIELD:D++,HEADER_VALUE_START:D++,HEADER_VALUE:D++,HEADER_VALUE_ALMOST_DONE:D++,HEADERS_ALMOST_DONE:D++,PART_DATA_START:D++,PART_DATA:D++,END:D++};let w=1;const T={PART_BOUNDARY:w,LAST_BOUNDARY:w*=2},N=10,U=13,Y=32,S=45,I=58,x=97,v=122,$=E(H=>H|32,"lower"),u=E(()=>{},"noop");class B{constructor(o){this.index=0,this.flags=0,this.onHeaderEnd=u,this.onHeaderField=u,this.onHeadersEnd=u,this.onHeaderValue=u,this.onPartBegin=u,this.onPartData=u,this.onPartEnd=u,this.boundaryChars={},o=`\r
--`+o;const n=new Uint8Array(o.length);for(let r=0;r<o.length;r++)n[r]=o.charCodeAt(r),this.boundaryChars[n[r]]=!0;this.boundary=n,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=t.START_BOUNDARY}write(o){let n=0;const r=o.length;let d=this.index,{lookbehind:A,boundary:c,boundaryChars:L,index:e,state:s,flags:l}=this;const P=this.boundary.length,p=P-1,F=o.length;let a,m;const f=E(h=>{this[h+"Mark"]=n},"mark"),i=E(h=>{delete this[h+"Mark"]},"clear"),_=E((h,O,R,V)=>{(O===void 0||O!==R)&&this[h](V&&V.subarray(O,R))},"callback"),b=E((h,O)=>{const R=h+"Mark";R in this&&(O?(_(h,this[R],n,o),delete this[R]):(_(h,this[R],o.length,o),this[R]=0))},"dataCallback");for(n=0;n<r;n++)switch(a=o[n],s){case t.START_BOUNDARY:if(e===c.length-2){if(a===S)l|=T.LAST_BOUNDARY;else if(a!==U)return;e++;break}else if(e-1===c.length-2){if(l&T.LAST_BOUNDARY&&a===S)s=t.END,l=0;else if(!(l&T.LAST_BOUNDARY)&&a===N)e=0,_("onPartBegin"),s=t.HEADER_FIELD_START;else return;break}a!==c[e+2]&&(e=-2),a===c[e+2]&&e++;break;case t.HEADER_FIELD_START:s=t.HEADER_FIELD,f("onHeaderField"),e=0;case t.HEADER_FIELD:if(a===U){i("onHeaderField"),s=t.HEADERS_ALMOST_DONE;break}if(e++,a===S)break;if(a===I){if(e===1)return;b("onHeaderField",!0),s=t.HEADER_VALUE_START;break}if(m=$(a),m<x||m>v)return;break;case t.HEADER_VALUE_START:if(a===Y)break;f("onHeaderValue"),s=t.HEADER_VALUE;case t.HEADER_VALUE:a===U&&(b("onHeaderValue",!0),_("onHeaderEnd"),s=t.HEADER_VALUE_ALMOST_DONE);break;case t.HEADER_VALUE_ALMOST_DONE:if(a!==N)return;s=t.HEADER_FIELD_START;break;case t.HEADERS_ALMOST_DONE:if(a!==N)return;_("onHeadersEnd"),s=t.PART_DATA_START;break;case t.PART_DATA_START:s=t.PART_DATA,f("onPartData");case t.PART_DATA:if(d=e,e===0){for(n+=p;n<F&&!(o[n]in L);)n+=P;n-=p,a=o[n]}if(e<c.length)c[e]===a?(e===0&&b("onPartData",!0),e++):e=0;else if(e===c.length)e++,a===U?l|=T.PART_BOUNDARY:a===S?l|=T.LAST_BOUNDARY:e=0;else if(e-1===c.length)if(l&T.PART_BOUNDARY){if(e=0,a===N){l&=~T.PART_BOUNDARY,_("onPartEnd"),_("onPartBegin"),s=t.HEADER_FIELD_START;break}}else l&T.LAST_BOUNDARY&&a===S?(_("onPartEnd"),s=t.END,l=0):e=0;if(e>0)A[e-1]=a;else if(d>0){const h=new Uint8Array(A.buffer,A.byteOffset,A.byteLength);_("onPartData",0,d,h),d=0,f("onPartData"),n--}break;case t.END:break;default:throw new Error(`Unexpected state entered: ${s}`)}b("onHeaderField"),b("onHeaderValue"),b("onPartData"),this.index=e,this.state=s,this.flags=l}end(){if(this.state===t.HEADER_FIELD_START&&this.index===0||this.state===t.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==t.END)throw new Error("MultipartParser.end(): stream ended unexpectedly")}}E(B,"MultipartParser");function j(H){const o=H.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!o)return;const n=o[2]||o[3]||"";let r=n.slice(n.lastIndexOf("\\")+1);return r=r.replace(/%22/g,'"'),r=r.replace(/&#(\d{4});/g,(d,A)=>String.fromCharCode(A)),r}E(j,"_fileName");async function K(H,o){if(!/multipart/i.test(o))throw new TypeError("Failed to fetch");const n=o.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n)throw new TypeError("no or bad content-type header, no multipart boundary");const r=new B(n[1]||n[2]);let d,A,c,L,e,s;const l=[],P=new M.Ct,p=E(i=>{c+=f.decode(i,{stream:!0})},"onPartData"),F=E(i=>{l.push(i)},"appendToFile"),a=E(()=>{const i=new C.$B(l,s,{type:e});P.append(L,i)},"appendFileToFormData"),m=E(()=>{P.append(L,c)},"appendEntryToFormData"),f=new TextDecoder("utf-8");f.decode(),r.onPartBegin=function(){r.onPartData=p,r.onPartEnd=m,d="",A="",c="",L="",e="",s=null,l.length=0},r.onHeaderField=function(i){d+=f.decode(i,{stream:!0})},r.onHeaderValue=function(i){A+=f.decode(i,{stream:!0})},r.onHeaderEnd=function(){if(A+=f.decode(),d=d.toLowerCase(),d==="content-disposition"){const i=A.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);i&&(L=i[2]||i[3]||""),s=j(A),s&&(r.onPartData=F,r.onPartEnd=a)}else d==="content-type"&&(e=A);A="",d=""};for await(const i of H)r.write(i);return r.end(),P}E(K,"toFormData")}};
